Skip to content

handle cmd+q for exiting on osx #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ void editorMoveCursor(int key) {

int editorEvents(void) {
SDL_Event event;
int j, ksym;
int j, ksym, kmod;
time_t idletime;

/* Sleep 0.25 seconds if no body is pressing any key for a few seconds.
Expand All @@ -592,6 +592,12 @@ int editorEvents(void) {
return 1;
break;
default:
#ifdef __APPLE__
kmod = event.key.keysym.mod;
if (ksym == SDLK_q && (kmod == KMOD_RMETA || kmod == KMOD_LMETA)) {
exit(0);
} else
#endif
if (ksym >= 0 && ksym < KEY_MAX) {
E.key[ksym].counter = 1;
E.key[ksym].translation = (event.key.keysym.unicode & 0xff);
Expand Down
11 changes: 10 additions & 1 deletion load81.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,25 @@ void showFPS(void) {

int processSdlEvents(void) {
SDL_Event event;
int ksym, kmod;

resetEvents();
while (SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_KEYDOWN:
switch(event.key.keysym.sym) {
ksym = event.key.keysym.sym;
switch(ksym) {
case SDLK_ESCAPE:
return 1;
break;
default:
#ifdef __APPLE__
kmod = event.key.keysym.mod;
if (ksym == SDLK_q && (kmod == KMOD_RMETA || kmod == KMOD_LMETA)) {
exit(0);
break;
}
#endif
keyboardEvent(&event.key,1);
break;
}
Expand Down