From a92c9cd07a75c45271adcf6fedaba47adb1bb189 Mon Sep 17 00:00:00 2001 From: night0721 Date: Fri, 15 Nov 2024 00:09:02 +0000 Subject: [PATCH] Add TODO and line numbers --- TODO | 6 ++++++ config.h | 3 ++- vip.c | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..b84fb3e --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +Line number +Auto indent +soft wrap lines +copy paste +multiple buffer information +keybinding in config diff --git a/config.h b/config.h index 0e8f86c..03a0d56 100644 --- a/config.h +++ b/config.h @@ -5,7 +5,8 @@ /* THEME */ /* 38 and 48 is reversed as bar's color is reversed */ -#define SURFACE_1_BG "\033[38;2;049;050;068m" +#define SURFACE_0_BG "\033[38;2;49;50;68m" +#define SURFACE_1_BG "\033[38;2;69;71;90m" #define OVERLAY_2_BG "\033[38;2;147;153;178m" #define BLACK_FG "\033[40m" #define BLACK_BG "\033[30m" diff --git a/vip.c b/vip.c index 64714ce..5cbf124 100644 --- a/vip.c +++ b/vip.c @@ -100,7 +100,7 @@ void draw_status_bar(void) } int coord_len = snprintf(coord, sizeof(coord), " %d:%d ", cur_editor->y + 1, cur_editor->x + 1); - bprintf(SURFACE_1_BG); /* background */ + bprintf(SURFACE_0_BG); /* background */ /* text */ switch (cur_editor->mode) { case NORMAL: @@ -120,7 +120,7 @@ void draw_status_bar(void) while (file_len < cols) { if (cols - mode_len - git_len - file_len == info_len + lines_len + coord_len) { - bprintf("%s%s", info, SURFACE_1_BG); + bprintf("%s%s", info, SURFACE_0_BG); if (cur_editor->mode == NORMAL) { bprintf(BLUE_FG); } else if (cur_editor->mode == INSERT) { @@ -585,11 +585,19 @@ void draw_rows(void) char *c = &cur_editor->row[filerow].render[cur_editor->coloff]; unsigned char *hl = &cur_editor->row[filerow].hl[cur_editor->coloff]; + int absydiff = abs(filerow - cur_editor->y); + if (absydiff == 0) { + int num_digits = snprintf(NULL, 0, "%d", cur_editor->y + 1); + int left_padding = (6 - num_digits) / 2; + int right_padding = 6 - num_digits - left_padding; + + bprintf("%s%*s%d%*s ", SURFACE_1_BG, left_padding, "", cur_editor->y + 1, right_padding, ""); + } else { + bprintf("%s%6d ", SURFACE_1_BG, absydiff); + } for (int j = 0; j < len; j++) { if (iscntrl(c[j])) { bprintf("%s%c\033[m", OVERLAY_2_BG, '@' + c[j]); - } else if (hl[j] == NORMAL) { - bprintf("%s%c", WHITE_BG, c[j]); } else { switch (hl[j]) { case NUMBER: