From a72621c77fe6762e83d7a30a8dbf36b2a164407b Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Wed, 12 Feb 2020 06:46:35 -0800 Subject: [PATCH] tweaks and updates --- ke/TODO | 4 +++- ke/erow.c | 8 ++++++-- ke/main.c | 7 ++++--- ke/test.txt | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ke/TODO b/ke/TODO index 5f1431b..0dc37ab 100644 --- a/ke/TODO +++ b/ke/TODO @@ -1,5 +1,7 @@ -[ ] goto-line +[X] goto-line [ ] text-corruption bug [ ] alt-modifiers [ ] refresh-screen [ ] functions -> keymapping? +[X] rendering: need to skip over control characters like we do with tabs +[X] control-d -> delete diff --git a/ke/erow.c b/ke/erow.c index 45d1140..4cc495e 100644 --- a/ke/erow.c +++ b/ke/erow.c @@ -23,12 +23,12 @@ byte_to_hihex(char c) static char byte_to_lohex(char c) { - c &= 0x0f; + c = c & 0x0f; if (c < 10) { return c + 0x30; } - return c + 0x41; + return c + 0x37; } @@ -41,6 +41,8 @@ erow_render_to_cursor(struct erow *row, int cx) for (j = 0; j < cx; j++) { if (row->line[j] == '\t') { rx += (TAB_STOP-1) - (rx%TAB_STOP); + } else if (row->line[j] < 0x20) { + rx += 2; } rx++; } @@ -58,6 +60,8 @@ erow_cursor_to_render(struct erow *row, int rx) for (curx = 0; curx < row->size; curx++) { if (row->line[curx] == '\t') { cur_rx += (TAB_STOP - 1) - (cur_rx % TAB_STOP); + } else if (row->line[curx] < 0x20) { + cur_rx += 2; } cur_rx++; diff --git a/ke/main.c b/ke/main.c index 5b1f1e8..59c4c62 100644 --- a/ke/main.c +++ b/ke/main.c @@ -21,7 +21,7 @@ #include "defs.h" -#define KE_VERSION "0.0.1-pre" +#define KE_VERSION "0.9.0" #define ESCSEQ "\x1b[" #define CTRL_KEY(key) ((key)&0x1f) #define TAB_STOP 8 @@ -761,8 +761,9 @@ process_normal(int16_t c) return; case BACKSPACE: case CTRL_KEY('h'): + case CTRL_KEY('d'): case DEL_KEY: - if (c == DEL_KEY) { + if (c == DEL_KEY || c == CTRL_KEY('d')) { move_cursor(ARROW_RIGHT); } @@ -901,7 +902,7 @@ draw_rows(struct abuf *ab) if (filerow >= editor->nrows) { if ((editor->nrows == 0) && (y == editor->rows / 3)) { buflen = snprintf(buf, sizeof(buf), - "ke k%s", KE_VERSION); + "ke v%s", KE_VERSION); padding = (editor->rows - buflen) / 2; if (padding) { diff --git a/ke/test.txt b/ke/test.txt index e1c9674..e8a782f 100644 --- a/ke/test.txt +++ b/ke/test.txt @@ -1 +1 @@ -hello world s ome tex t for you \ No newline at end of file +hello world s ome tex t for you