diff --git a/config.h b/config.h index 5d80a67..6f472fb 100644 --- a/config.h +++ b/config.h @@ -23,8 +23,6 @@ #define MAUVE_BG "\033[38;2;203;166;247m" #define YELLOW_BG "\033[38;2;249;226;175m" - - enum keys { BACKSPACE = 127, ARROW_LEFT = 1000, @@ -93,6 +91,9 @@ typedef struct { language_t *syntax; } editor_t; +#define HL_NUMBERS (1 << 0) +#define HL_STRINGS (1 << 1) + language_t langs[] = { { "c", @@ -107,8 +108,5 @@ language_t langs[] = { #define LANGS_LEN (sizeof(langs) / sizeof(langs[0])) -#define HL_NUMBERS (1 << 0) -#define HL_STRINGS (1 << 1) - #define CTRL_KEY(k) ((k) & 0x1f) #define COLOR_LEN 19 diff --git a/vip.c b/vip.c index 4a155e0..2ebfb95 100644 --- a/vip.c +++ b/vip.c @@ -534,11 +534,11 @@ void save_file(void) } select_syntax(); } - int len; int fd = open(cur_editor->filename, O_RDWR | O_CREAT, 0644); if (fd != -1) { + int len; + char *buf = export_buffer(&len); if (ftruncate(fd, len) != -1) { - char *buf = export_buffer(&len); if (write(fd, buf, len) == len) { close(fd); free(buf); @@ -576,7 +576,6 @@ void draw_rows(void) unsigned char *hl = &cur_editor->row[filerow].hl[cur_editor->coloff]; char *current_color = malloc(COLOR_LEN * 2); - int current_color_len = 0; for (int j = 0; j < len; j++) { if (iscntrl(c[j])) { bprintf("\033[7m^%c\033[m", '@' + c[j]);