From 267489c19fb8f80fec8f8edc0f174dbd08aa657c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 3 Dec 2021 20:19:32 -0800 Subject: [PATCH] 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 --- src/kilo.c | 4 ++-- 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, };