From e80af9206ca91a66455064e01454121ae7dc1ae7 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 28 Nov 2021 21:08:12 -0800 Subject: ctrl-/ to comment/uncomment line --- src/kilo.c | 27 +++++++++++++++++++++++++++ src/teliva.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/kilo.c b/src/kilo.c index 64d09db..2452751 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -572,6 +572,26 @@ static void editorDelChar() { E.dirty++; } +static void editorUncommentCursorRow() { + erow *row = &E.row[E.rowoff+E.cy]; + editorRowDelChar(row, 0); + editorRowDelChar(row, 0); + editorRowDelChar(row, 0); + editorRowDelChar(row, 0); + E.coloff = 0; + E.cx = 0; +} + +static void editorCommentCursorRow() { + erow *row = &E.row[E.rowoff+E.cy]; + editorRowInsertChar(row, 0, ' '); + editorRowInsertChar(row, 0, '?'); + editorRowInsertChar(row, 0, '-'); + editorRowInsertChar(row, 0, '-'); + E.coloff = 0; + E.cx = 0; +} + /* Load the specified program in the editor memory and returns 0 on success * or 1 on error. */ int editorOpen(char *filename) { @@ -656,6 +676,7 @@ static void editorMenu(void) { draw_menu_item("^l", "end of line"); draw_menu_item("^u", "delete to start of line"); draw_menu_item("^k", "delete to end of line"); + draw_menu_item("^/", "(un)comment line"); attrset(A_NORMAL); } @@ -1113,6 +1134,12 @@ static void editorProcessKeypress(lua_State* L) { editorDelChar(); } break; + case CTRL_SLASH: + if (starts_with(E.row[E.rowoff+E.cy].chars, "--? ")) + editorUncommentCursorRow(); + else + editorCommentCursorRow(); + break; case KEY_UP: case KEY_DOWN: case KEY_LEFT: diff --git a/src/teliva.h b/src/teliva.h index d3183b9..1f57a13 100644 --- a/src/teliva.h +++ b/src/teliva.h @@ -26,6 +26,7 @@ enum KEY_ACTION { CTRL_U = 21, CTRL_X = 24, ESC = 27, + CTRL_SLASH = 31, }; #endif -- cgit 1.4.1-2-gfad0 py'>
path: root/tests/manpage_completion_test.py
blob: b9504d06ff26421798690f6851e953abbf6c2cde (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13