ctrl-u/ctrl-k to make editing a bit more ergonomic
This commit is contained in:
parent
68211363ca
commit
eec4845c31
18
src/kilo.c
18
src/kilo.c
|
@ -389,7 +389,7 @@ static void editorFreeRow(erow *row) {
|
||||||
free(row->hl);
|
free(row->hl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the row at the specified position, shifting the remainign on the
|
/* Remove the row at the specified position, shifting the remaining on the
|
||||||
* top. */
|
* top. */
|
||||||
static void editorDelRow(int at) {
|
static void editorDelRow(int at) {
|
||||||
erow *row;
|
erow *row;
|
||||||
|
@ -654,6 +654,8 @@ static void editorMenu(void) {
|
||||||
draw_menu_item("^f", "find");
|
draw_menu_item("^f", "find");
|
||||||
draw_menu_item("^a", "start of line");
|
draw_menu_item("^a", "start of line");
|
||||||
draw_menu_item("^l", "end of line");
|
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");
|
||||||
attrset(A_NORMAL);
|
attrset(A_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1097,6 +1099,20 @@ static void editorProcessKeypress(lua_State* L) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CTRL_U:
|
||||||
|
while (!editorAtStartOfLine())
|
||||||
|
editorDelChar();
|
||||||
|
break;
|
||||||
|
case CTRL_K:
|
||||||
|
while (1) {
|
||||||
|
editorMoveCursor(KEY_RIGHT);
|
||||||
|
if (editorAtStartOfLine()) {
|
||||||
|
editorMoveCursor(KEY_LEFT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
editorDelChar();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
|
|
|
@ -18,6 +18,7 @@ enum KEY_ACTION {
|
||||||
#endif
|
#endif
|
||||||
TAB = 9,
|
TAB = 9,
|
||||||
ENTER = 10,
|
ENTER = 10,
|
||||||
|
CTRL_K = 11,
|
||||||
CTRL_L = 12,
|
CTRL_L = 12,
|
||||||
CTRL_Q = 17,
|
CTRL_Q = 17,
|
||||||
CTRL_R = 18,
|
CTRL_R = 18,
|
||||||
|
|
Loading…
Reference in New Issue