tabline: Switch to functions, handle different click types

This commit is contained in:
ZyX
2015-12-20 09:00:37 +03:00
parent ef662498b1
commit 64038bf4e2
6 changed files with 100 additions and 32 deletions

View File

@@ -2846,7 +2846,7 @@ int build_stl_str_hl(
struct stl_item {
// Where the item starts in the status line output buffer
char_u *start;
// Command to run for ClickCmd items.
// Function to run for ClickFunc items.
char *cmd;
// The minimum width of the item
int minwid;
@@ -2859,7 +2859,7 @@ int build_stl_str_hl(
Middle,
Highlight,
TabPage,
ClickCmd,
ClickFunc,
Trunc
} type;
} item[STL_MAX_ITEM];
@@ -3167,17 +3167,19 @@ int build_stl_str_hl(
continue;
}
if (*fmt_p == STL_CLICK_CMD) {
if (*fmt_p == STL_CLICK_FUNC) {
fmt_p++;
char *t = (char *) fmt_p;
while (*fmt_p != ']' && *fmt_p) {
while (*fmt_p != STL_CLICK_FUNC && *fmt_p) {
fmt_p++;
}
if (*fmt_p != ']') {
if (*fmt_p != STL_CLICK_FUNC) {
break;
}
item[curitem].type = ClickCmd;
item[curitem].type = ClickFunc;
item[curitem].start = out_p;
item[curitem].cmd = xmemdupz(t + 1, (size_t) (((char *) fmt_p - t) - 1));
item[curitem].cmd = xmemdupz(t, (size_t) (((char *) fmt_p - t)));
item[curitem].minwid = minwid;
fmt_p++;
curitem++;
continue;
@@ -3858,20 +3860,20 @@ int build_stl_str_hl(
}
cur_tab_rec->def.tabnr = tabnr;
}
cur_tab_rec->def.cmd = NULL;
cur_tab_rec->def.func = NULL;
cur_tab_rec++;
} else if (item[l].type == ClickCmd) {
} else if (item[l].type == ClickFunc) {
cur_tab_rec->start = (char *) item[l].start;
cur_tab_rec->def.type = kStlClickCmd;
cur_tab_rec->def.tabnr = 0;
cur_tab_rec->def.cmd = item[l].cmd;
cur_tab_rec->def.type = kStlClickFuncRun;
cur_tab_rec->def.tabnr = item[l].minwid;
cur_tab_rec->def.func = item[l].cmd;
cur_tab_rec++;
}
}
cur_tab_rec->start = NULL;
cur_tab_rec->def.type = kStlClickDisabled;
cur_tab_rec->def.tabnr = 0;
cur_tab_rec->def.cmd = NULL;
cur_tab_rec->def.func = NULL;
}
return width;