From 028934db22453199d91d530a88675723193ed062 Mon Sep 17 00:00:00 2001 From: Rex2002 Date: Sun, 1 Oct 2023 19:07:48 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20add=20masking=20for=20=C3=B6=C3=A4?= =?UTF-8?q?=C3=BC=C3=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- useless.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/useless.c b/useless.c index f57b1a8..4e3fb1c 100644 --- a/useless.c +++ b/useless.c @@ -31,7 +31,11 @@ enum editorKey { HOME_KEY, END_KEY, PAGE_UP, - PAGE_DOWN + PAGE_DOWN, + A_UML, + O_UML, + U_UML, + S_Z }; enum editorHighlight { @@ -235,9 +239,25 @@ int editorReadKey(){ case 'F': return END_KEY; } } - return '\x1b'; } + if(c == '\xc3'){ + char val; + if(read(STDIN_FILENO, &val, 1) != 1) return '\xc3'; + + if(val == '\xa4'){ + return A_UML; + } + else if(val == '\xb6'){ + return O_UML; + } + else if(val == '\xbc'){ + return U_UML; + } + else if(val == '\x9f'){ + return S_Z; + } + } return c; } @@ -529,6 +549,7 @@ void editorDelRow(int at){ } void editorRowInsertChar(erow *row, int at, int c){ + if(at < 0 || at > row->size) at = row->size; row->chars = realloc(row->chars, row->size + 2); memmove(&row->chars[at + 1], &row->chars[at], row->size - at + 1); @@ -1062,6 +1083,22 @@ void editorProcessKeypress(){ case CTRL_KEY('l'): case '\x1b': break; + case A_UML: + editorInsertChar('a'); + editorInsertChar('e'); + break; + case U_UML: + editorInsertChar('u'); + editorInsertChar('e'); + break; + case O_UML: + editorInsertChar('o'); + editorInsertChar('e'); + break; + case S_Z: + editorInsertChar('s'); + editorInsertChar('s'); + break; default: editorInsertChar(c); break;