diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-12-03 20:19:32 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-12-03 20:19:32 -0800 |
commit | 267489c19fb8f80fec8f8edc0f174dbd08aa657c (patch) | |
tree | 74f50b6d94130201b014c919b4218ca1c0a18d50 | |
parent | 950957619c7e479bbb0f24e9af68461470b53d72 (diff) | |
download | teliva-267489c19fb8f80fec8f8edc0f174dbd08aa657c.tar.gz |
support the comment/uncomment hotkey on Macs
^/ works on Linux but not on Mac ^- emits the same character code on Mac ^_ seems to be the underlying character code, and works on both ctrl-7 also emits the same character code
-rw-r--r-- | src/kilo.c | 4 | ||||
-rw-r--r-- | src/teliva.h | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/kilo.c b/src/kilo.c index 85ace88..7349537 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -673,7 +673,7 @@ static void editorMenu(void) { draw_menu_item("^g", "go"); draw_menu_item("^b", "big picture"); draw_menu_item("^f", "find"); - draw_menu_item("^/", "(un)comment line"); + draw_menu_item("^/|^-|^_", "(un)comment line"); draw_menu_item("^h", "back up cursor"); draw_menu_item("^l", "end of line"); attrset(A_NORMAL); @@ -1145,7 +1145,7 @@ static void editorProcessKeypress(lua_State* L) { editorDelChar(); } break; - case CTRL_SLASH: + case CTRL_SLASH: /* same as CTRL_UNDERSCORE */ if (starts_with(E.row[E.rowoff+E.cy].chars, "--? ")) editorUncommentCursorRow(); else diff --git a/src/teliva.h b/src/teliva.h index 0f78bde..772f17a 100644 --- a/src/teliva.h +++ b/src/teliva.h @@ -21,6 +21,7 @@ enum KEY_ACTION { CTRL_U = 21, CTRL_X = 24, CTRL_SLASH = 31, + CTRL_UNDERSCORE = 31, DELETE = 127, }; |