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
This commit is contained in:
Kartik K. Agaram 2021-12-03 20:19:32 -08:00
parent 950957619c
commit 267489c19f
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -21,6 +21,7 @@ enum KEY_ACTION {
CTRL_U = 21,
CTRL_X = 24,
CTRL_SLASH = 31,
CTRL_UNDERSCORE = 31,
DELETE = 127,
};