-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change ui_window_style_set and change the way cursorline is drawn #1229
base: master
Are you sure you want to change the base?
Conversation
Hi! I'm not sure I understand the point? CURSOR_LINE already doesn't override non-default styles if the user didn't request it. For example the zenburn theme only specifies the background for CURSOR_LINE so whatever foreground was set by the other rules remains unchanged when CURSOR_LINE is applied. |
If other styles on the same line have non-default background, then CURSOR_LINE will override them. That's is kind of the problem when using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delayed review. I'm fine with this if you address the comments I left inline.
ui-terminal.c
Outdated
@@ -269,25 +269,29 @@ static void ui_window_draw(Win *win) { | |||
} | |||
} | |||
|
|||
void ui_window_style_set(Ui *tui, int win_id, Cell *cell, enum UiStyle id) { | |||
void ui_window_style_set(Ui *tui, int win_id, Cell *cell, enum UiStyle id, bool keep) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a more descriptive name than keep
. What is being kept? It should be immediately clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to keep_non_default
, but I don't know if this name is more descriptive or not.
vis-lua.c
Outdated
@@ -2038,7 +2039,8 @@ static int window_style(lua_State *L) { | |||
enum UiStyle style = luaL_checkunsigned(L, 2); | |||
size_t start = checkpos(L, 3); | |||
size_t end = checkpos(L, 4); | |||
win_style(win, style, start, end); | |||
bool keep = lua_isboolean(L, 5) && lua_toboolean(L, 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool keep = lua_isboolean(L, 5) && lua_toboolean(L, 5); | |
if (!lua_isboolean(L, 5)) | |
return luaL_argerror(L, 5, "boolean expected"); |
I think we should raise an error rather than assume false when the caller passes something weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other functions use lua_isboolean(L, 5) && lua_toboolean(L, 5)
approach.
If we raise an error in this function it would be appropriate to do the same in all of the others.
vis-lua.c
Outdated
@@ -2063,7 +2066,8 @@ static int window_style_pos(lua_State *L) { | |||
enum UiStyle style = luaL_checkunsigned(L, 2); | |||
size_t x = checkpos(L, 3); | |||
size_t y = checkpos(L, 4); | |||
bool ret = ui_window_style_set_pos(win, (int)x, (int)y, style); | |||
bool keep = lua_isboolean(L, 5) && lua_toboolean(L, 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
Changes:
ui_window_style_set
now acceptskeep
flag, that allows to not override non-default style values (fg and bg);ui_window_style_set_pos
andwin_style
also accept the same flag;win:style
andwin:style_pos
both accept the samekeep
flag, but it is optional;This was mainly done so that CURSOR_LINE wouldn't override other styles, but plugins can potentially benefit from this as well.