mirror of https://github.com/Sam1301/Lite.git
Prevent inserting special characters
This commit is contained in:
parent
327b216b14
commit
9469837890
14
editor.c
14
editor.c
|
@ -23,6 +23,7 @@
|
|||
#define EDITOR_TAB 8
|
||||
|
||||
enum editorKey {
|
||||
BACKSPACE = 127,
|
||||
ARROW_LEFT = 1000,
|
||||
ARROW_RIGHT,
|
||||
ARROW_UP,
|
||||
|
@ -479,7 +480,7 @@ void editorMoveCursor(int c) {
|
|||
|
||||
void editorProcessKey() {
|
||||
int c = editorReadKey();
|
||||
switch (c) {
|
||||
switch (c) {
|
||||
case CTRL_KEY('q') : // exit on CTrl+Q
|
||||
write(STDOUT_FILENO, "\x1b[2J", 4);
|
||||
write(STDOUT_FILENO, "\x1b[H", 3);
|
||||
|
@ -515,6 +516,17 @@ void editorProcessKey() {
|
|||
E.cursorX = E.erow[E.cursorY].length;
|
||||
}
|
||||
break;
|
||||
case '\r':
|
||||
/* TODO */
|
||||
break;
|
||||
case BACKSPACE:
|
||||
case DEL_KEY:
|
||||
case CTRL_KEY('h'):
|
||||
/* TODO */
|
||||
break;
|
||||
case CTRL_KEY('l'): // do nothing for escape key and Ctrl+L
|
||||
case '\x1b':
|
||||
break;
|
||||
default:
|
||||
editorInsertChar(c);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue