From dfcceadd041ea5fc796db05beb06dc310538d501 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 2 Jan 2020 18:01:09 -0800 Subject: [PATCH] Got visual highlighting working --- hermes.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hermes.c b/hermes.c index 3d8d732..2a18d72 100644 --- a/hermes.c +++ b/hermes.c @@ -697,6 +697,11 @@ void editorDrawRows(struct abuf *ab) { char *c = &E.row[filerow].render[E.coloff]; unsigned char *hl = &E.row[filerow].hl[E.coloff]; int current_color = -1; + if (E.mode == VisualMode && len <= 0 && filerow == E.cy) { + char vbuf[16]; + int vclen = snprintf(vbuf, sizeof(vbuf), "\033[48;5;%dm", EDITOR_BG_COLOR); + abAppend(ab, vbuf, vclen); + } int j; for (j = 0; j < len; j++) { if (iscntrl(c[j])) { @@ -968,16 +973,18 @@ void editorMoveCursor(int key) { if (E.cy < E.numRows) { E.cy++; } + if (sizeof(row) > 0 && E.cx < 0) E.cx = 0; break; case 'k': case ARROW_UP: if (E.cy != 0) { E.cy--; } + if (sizeof(row) > 0 && E.cx < 0) E.cx = 0; break; case 'h': case ARROW_LEFT: - if (E.cx != 0) { + if (E.cx > 0) { E.cx--; } break;