From 03ceb7943b7f28c0b52803d64f956ca549e2cc03 Mon Sep 17 00:00:00 2001 From: Philipp Emanuel Weidmann Date: Sat, 10 Jun 2017 20:15:36 +0530 Subject: [PATCH] More theme improvements --- lua/themes/dark-16.lua | 1 + lua/themes/light-16.lua | 1 + lua/themes/solarized.lua | 3 ++- lua/vis.lua | 1 + ui-terminal.c | 3 ++- ui.h | 1 + view.c | 2 +- vis-lua.c | 27 ++++++++++++++------------- vis.c | 2 +- 9 files changed, 24 insertions(+), 17 deletions(-) diff --git a/lua/themes/dark-16.lua b/lua/themes/dark-16.lua index fcfc1f8f7..fd7e1dbf9 100644 --- a/lua/themes/dark-16.lua +++ b/lua/themes/dark-16.lua @@ -24,6 +24,7 @@ lexers.STYLE_EMBEDDED = 'back:blue,bold' lexers.STYLE_IDENTIFIER = 'fore:white' lexers.STYLE_LINENUMBER = 'fore:white' +lexers.STYLE_LINENUMBER_CURSOR = lexers.STYLE_LINENUMBER lexers.STYLE_CURSOR = 'reverse' lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',fore:yellow' lexers.STYLE_CURSOR_LINE = 'underlined' diff --git a/lua/themes/light-16.lua b/lua/themes/light-16.lua index cf72f7fef..53d0e45e1 100644 --- a/lua/themes/light-16.lua +++ b/lua/themes/light-16.lua @@ -24,6 +24,7 @@ lexers.STYLE_EMBEDDED = 'back:blue,bold' lexers.STYLE_IDENTIFIER = 'fore:black' lexers.STYLE_LINENUMBER = 'fore:black' +lexers.STYLE_LINENUMBER_CURSOR = lexers.STYLE_LINENUMBER lexers.STYLE_CURSOR = 'reverse' lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',fore:yellow' lexers.STYLE_CURSOR_LINE = 'underlined' diff --git a/lua/themes/solarized.lua b/lua/themes/solarized.lua index 559902c85..a5d4c4d40 100644 --- a/lua/themes/solarized.lua +++ b/lua/themes/solarized.lua @@ -46,11 +46,12 @@ lexers.STYLE_PREPROCESSOR = 'fore:'..colors.orange lexers.STYLE_TAG = 'fore:'..colors.red lexers.STYLE_TYPE = 'fore:'..colors.yellow lexers.STYLE_VARIABLE = 'fore:'..colors.blue -lexers.STYLE_WHITESPACE = '' +lexers.STYLE_WHITESPACE = 'fore:'..colors.base01 lexers.STYLE_EMBEDDED = 'back:blue' lexers.STYLE_IDENTIFIER = fg lexers.STYLE_LINENUMBER = 'fore:'..colors.base00..',back:'..colors.base02 +lexers.STYLE_LINENUMBER_CURSOR = 'back:'..colors.base00..',fore:'..colors.base02 lexers.STYLE_CURSOR = 'fore:'..colors.base03..',back:'..colors.base0 lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',back:yellow' lexers.STYLE_CURSOR_LINE = 'back:'..colors.base02 diff --git a/lua/vis.lua b/lua/vis.lua index c7738e9de..870fc5230 100644 --- a/lua/vis.lua +++ b/lua/vis.lua @@ -243,6 +243,7 @@ vis.types.window.set_syntax = function(win, syntax) win:style_define(win.STYLE_CURSOR_LINE, lexers.STYLE_CURSOR_LINE or '') win:style_define(win.STYLE_SELECTION, lexers.STYLE_SELECTION or '') win:style_define(win.STYLE_LINENUMBER, lexers.STYLE_LINENUMBER or '') + win:style_define(win.STYLE_LINENUMBER_CURSOR, lexers.STYLE_LINENUMBER_CURSOR or '') win:style_define(win.STYLE_COLOR_COLUMN, lexers.STYLE_COLOR_COLUMN or '') win:style_define(win.STYLE_STATUS, lexers.STYLE_STATUS or '') win:style_define(win.STYLE_STATUS_FOCUSED, lexers.STYLE_STATUS_FOCUSED or '') diff --git a/ui-terminal.c b/ui-terminal.c index 8cdd655b5..93f78f037 100644 --- a/ui-terminal.c +++ b/ui-terminal.c @@ -271,7 +271,8 @@ static void ui_window_draw(UiWin *w) { } snprintf(buf, sizeof buf, "%*zu ", sidebar_width-1, number); } - ui_draw_string(ui, x, y, buf, win, UI_STYLE_LINENUMBER); + ui_draw_string(ui, x, y, buf, win, + (l->lineno == cursor_lineno) ? UI_STYLE_LINENUMBER_CURSOR : UI_STYLE_LINENUMBER); prev_lineno = l->lineno; } debug("draw-window: [%d][%d] ... cells[%d][%d]\n", y, x+sidebar_width, y, view_width); diff --git a/ui.h b/ui.h index c2e9bf399..786fdfb57 100644 --- a/ui.h +++ b/ui.h @@ -41,6 +41,7 @@ enum UiStyle { UI_STYLE_CURSOR_LINE, UI_STYLE_SELECTION, UI_STYLE_LINENUMBER, + UI_STYLE_LINENUMBER_CURSOR, UI_STYLE_COLOR_COLUMN, UI_STYLE_STATUS, UI_STYLE_STATUS_FOCUSED, diff --git a/view.c b/view.c index 76410aaa3..3ed89d9ea 100644 --- a/view.c +++ b/view.c @@ -421,7 +421,7 @@ void view_draw(View *view) { /* resync position of cursors within visible area */ for (Cursor *c = view->cursors; c; c = c->next) { size_t pos = view_cursors_pos(c); - if (!view_coord_get(view, pos, &c->line, &c->row, &c->col) && + if (!view_coord_get(view, pos, &c->line, &c->row, &c->col) && c == view->cursor) { c->line = view->topline; c->row = 0; diff --git a/vis-lua.c b/vis-lua.c index 8aaa2ed54..814a46a01 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -1640,7 +1640,7 @@ static int window_unmap(lua_State *L) { * Define a display style. * @function style_define * @tparam int id the style id to use - * @tparam string style the style definition + * @tparam string style the style definition * @treturn bool whether the style definition has been successfully * associated with the given id * @see style @@ -2623,18 +2623,19 @@ void vis_lua_init(Vis *vis) { enum UiStyle id; const char *name; } styles[] = { - { UI_STYLE_DEFAULT, "STYLE_DEFAULT" }, - { UI_STYLE_CURSOR, "STYLE_CURSOR" }, - { UI_STYLE_CURSOR_PRIMARY, "STYLE_CURSOR_PRIMARY" }, - { UI_STYLE_CURSOR_LINE, "STYLE_CURSOR_LINE" }, - { UI_STYLE_SELECTION, "STYLE_SELECTION" }, - { UI_STYLE_LINENUMBER, "STYLE_LINENUMBER" }, - { UI_STYLE_COLOR_COLUMN, "STYLE_COLOR_COLUMN" }, - { UI_STYLE_STATUS, "STYLE_STATUS" }, - { UI_STYLE_STATUS_FOCUSED, "STYLE_STATUS_FOCUSED" }, - { UI_STYLE_SEPARATOR, "STYLE_SEPARATOR" }, - { UI_STYLE_INFO, "STYLE_INFO" }, - { UI_STYLE_EOF, "STYLE_EOF" }, + { UI_STYLE_DEFAULT, "STYLE_DEFAULT" }, + { UI_STYLE_CURSOR, "STYLE_CURSOR" }, + { UI_STYLE_CURSOR_PRIMARY, "STYLE_CURSOR_PRIMARY" }, + { UI_STYLE_CURSOR_LINE, "STYLE_CURSOR_LINE" }, + { UI_STYLE_SELECTION, "STYLE_SELECTION" }, + { UI_STYLE_LINENUMBER, "STYLE_LINENUMBER" }, + { UI_STYLE_LINENUMBER_CURSOR, "STYLE_LINENUMBER_CURSOR" }, + { UI_STYLE_COLOR_COLUMN, "STYLE_COLOR_COLUMN" }, + { UI_STYLE_STATUS, "STYLE_STATUS" }, + { UI_STYLE_STATUS_FOCUSED, "STYLE_STATUS_FOCUSED" }, + { UI_STYLE_SEPARATOR, "STYLE_SEPARATOR" }, + { UI_STYLE_INFO, "STYLE_INFO" }, + { UI_STYLE_EOF, "STYLE_EOF" }, }; for (size_t i = 0; i < LENGTH(styles); i++) { diff --git a/vis.c b/vis.c index dc2c9844d..17270f284 100644 --- a/vis.c +++ b/vis.c @@ -306,7 +306,7 @@ static void window_draw_cursorline(Win *win) { return; if (view_cursors_multiple(view)) return; - + int width = view_width_get(view); CellStyle style = win->ui->style_get(win->ui, UI_STYLE_CURSOR_LINE); Cursor *cursor = view_cursors_primary_get(view);