aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sam.c2
-rw-r--r--vis-cmds.c2
-rw-r--r--vis-core.h2
-rw-r--r--vis-lua.c20
-rw-r--r--vis-operators.c2
-rw-r--r--vis.c4
6 files changed, 16 insertions, 16 deletions
diff --git a/sam.c b/sam.c
index df8cf83..9902a66 100644
--- a/sam.c
+++ b/sam.c
@@ -323,7 +323,7 @@ static const OptionDef options[] = {
},
[OPTION_EXPANDTAB] = {
{ "expandtab", "et" },
- VIS_OPTION_TYPE_BOOL,
+ VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW,
VIS_HELP("Replace entered <Tab> with `tabwidth` spaces")
},
[OPTION_TABWIDTH] = {
diff --git a/vis-cmds.c b/vis-cmds.c
index 968b7f2..9e4ed21 100644
--- a/vis-cmds.c
+++ b/vis-cmds.c
@@ -255,7 +255,7 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Select
break;
}
case OPTION_EXPANDTAB:
- vis->expandtab = toggle ? !vis->expandtab : arg.b;
+ vis->win->expandtab = toggle ? !vis->win->expandtab : arg.b;
break;
case OPTION_AUTOINDENT:
vis->autoindent = toggle ? !vis->autoindent : arg.b;
diff --git a/vis-core.h b/vis-core.h
index e8bc27e..8d3980c 100644
--- a/vis-core.h
+++ b/vis-core.h
@@ -158,6 +158,7 @@ struct Win {
UiWin *ui; /* ui object handling visual appearance of this window */
File *file; /* file being displayed in this window */
View *view; /* currently displayed part of underlying text */
+ bool expandtab; /* whether typed tabs should be converted to spaces in this window*/
MarkList jumplist; /* LRU jump management */
Array saved_selections; /* register used to store selections */
Mode modes[VIS_MODE_INVALID]; /* overlay mods used for per window key bindings */
@@ -183,7 +184,6 @@ struct Vis {
char search_char[8]; /* last used character to search for via 'f', 'F', 't', 'T' */
int last_totill; /* last to/till movement used for ';' and ',' */
int search_direction; /* used for `n` and `N` */
- bool expandtab; /* whether typed tabs should be converted to spaces */
bool autoindent; /* whether indentation should be copied from previous line on newline */
bool change_colors; /* whether to adjust 256 color palette for true colors */
char *shell; /* shell used to launch external commands */
diff --git a/vis-lua.c b/vis-lua.c
index c3d3128..a92b186 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -1535,8 +1535,6 @@ static int vis_options_assign(Vis *vis, lua_State *L, const char *key, int next)
} else if (strcmp(key, "escdelay") == 0) {
TermKey *tk = vis->ui->termkey_get(vis->ui);
termkey_set_waittime(tk, luaL_checkint(L, next));
- } else if (strcmp(key, "expandtab") == 0 || strcmp(key, "et") == 0) {
- vis->expandtab = lua_toboolean(L, next);
} else if (strcmp(key, "ignorecase") == 0 || strcmp(key, "ic") == 0) {
vis->ignorecase = lua_toboolean(L, next);
} else if (strcmp(key, "loadmethod") == 0) {
@@ -1657,7 +1655,6 @@ static const struct luaL_Reg vis_lua[] = {
* @tfield[opt=false] boolean autoindent {ai}
* @tfield[opt=false] boolean changecolors
* @tfield[opt=50] int escdelay
- * @tfield[opt=false] boolean expandtab {et}
* @tfield[opt=false] boolean ignorecase {ic}
* @tfield[opt="auto"] string loadmethod `"auto"`, `"read"`, or `"mmap"`.
* @tfield[opt="/bin/sh"] string shell
@@ -1679,9 +1676,6 @@ static int vis_options_index(lua_State *L) {
TermKey *tk = vis->ui->termkey_get(vis->ui);
lua_pushunsigned(L, termkey_get_waittime(tk));
return 1;
- } else if (strcmp(key, "expandtab") == 0 || strcmp(key, "et") == 0) {
- lua_pushboolean(L, vis->expandtab);
- return 1;
} else if (strcmp(key, "ignorecase") == 0 || strcmp(key, "ic") == 0) {
lua_pushboolean(L, vis->ignorecase);
return 1;
@@ -1967,6 +1961,8 @@ static int window_options_assign(Win *win, lua_State *L, const char *key, int ne
view_wrapcolumn_set(win->view, luaL_checkint(L, next));
} else if (strcmp(key, "tabwidth") == 0 || strcmp(key, "tw") == 0) {
view_tabwidth_set(win->view, luaL_checkint(L, next));
+ } else if (strcmp(key, "expandtab") == 0 || strcmp(key, "et") == 0) {
+ win->expandtab = lua_toboolean(L, next);
}
return 0;
}
@@ -2169,14 +2165,15 @@ static const struct luaL_Reg window_funcs[] = {
* @tfield[opt=""] string breakat {brk}
* @tfield[opt=0] int colorcolumn {cc}
* @tfield[opt=false] boolean cursorline {cul}
+ * @tfield[opt=false] boolean expandtab {et}
* @tfield[opt=false] boolean numbers {nu}
* @tfield[opt=false] boolean relativenumbers {rnu}
* @tfield[opt=true] boolean showeof
* @tfield[opt=false] boolean shownewlines
* @tfield[opt=false] boolean showspaces
* @tfield[opt=false] boolean showtabs
- * @tfield[opt=0] int wrapcolumn {wc}
* @tfield[opt=8] int tabwidth {tw}
+ * @tfield[opt=0] int wrapcolumn {wc}
*/
static int window_options_index(lua_State *L) {
@@ -2194,6 +2191,9 @@ static int window_options_index(lua_State *L) {
} else if (strcmp(key, "cursorline") == 0 || strcmp(key, "cul") == 0) {
lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_CURSOR_LINE);
return 1;
+ } else if (strcmp(key, "expandtab") == 0 || strcmp(key, "et") == 0) {
+ lua_pushboolean(L, win->expandtab);
+ return 1;
} else if (strcmp(key, "numbers") == 0 || strcmp(key, "nu") == 0) {
lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_LINE_NUMBERS_ABSOLUTE);
return 1;
@@ -2212,12 +2212,12 @@ static int window_options_index(lua_State *L) {
} else if (strcmp(key, "showtabs") == 0) {
lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_SYMBOL_TAB);
return 1;
- } else if (strcmp(key, "wrapcolumn") == 0 || strcmp(key, "wc") == 0) {
- lua_pushunsigned(L, view_wrapcolumn_get(win->view));
- return 1;
} else if (strcmp(key, "tabwidth") == 0 || strcmp(key, "tw") == 0) {
lua_pushinteger(L, view_tabwidth_get(win->view));
return 1;
+ } else if (strcmp(key, "wrapcolumn") == 0 || strcmp(key, "wc") == 0) {
+ lua_pushunsigned(L, view_wrapcolumn_get(win->view));
+ return 1;
}
}
return index_common(L);
diff --git a/vis-operators.c b/vis-operators.c
index a447543..0e4f8b4 100644
--- a/vis-operators.c
+++ b/vis-operators.c
@@ -103,7 +103,7 @@ static size_t op_put(Vis *vis, Text *txt, OperatorContext *c) {
static size_t op_shift_right(Vis *vis, Text *txt, OperatorContext *c) {
char spaces[9] = " ";
spaces[MIN(view_tabwidth_get(vis->win->view), LENGTH(spaces) - 1)] = '\0';
- const char *tab = vis->expandtab ? spaces : "\t";
+ const char *tab = vis->win->expandtab ? spaces : "\t";
size_t tablen = strlen(tab);
size_t pos = text_line_begin(txt, c->range.end), prev_pos;
size_t newpos = c->pos;
diff --git a/vis.c b/vis.c
index c3899db..004295b 100644
--- a/vis.c
+++ b/vis.c
@@ -489,6 +489,7 @@ Win *window_new_file(Vis *vis, File *file, enum UiOption options) {
win->vis = vis;
win->file = file;
win->view = view_new(file->text);
+ win->expandtab = false;
win->ui = vis->ui->window_new(vis->ui, win, options);
if (!win->view || !win->ui) {
window_free(win);
@@ -694,7 +695,6 @@ Vis *vis_new(Ui *ui, VisEvent *event) {
return NULL;
vis->exit_status = -1;
vis->ui = ui;
- vis->expandtab = false;
vis->change_colors = true;
for (size_t i = 0; i < LENGTH(vis->registers); i++)
register_init(&vis->registers[i]);
@@ -1644,7 +1644,7 @@ void vis_insert_tab(Vis *vis) {
Win *win = vis->win;
if (!win)
return;
- if (!vis->expandtab) {
+ if (!win->expandtab) {
vis_insert_key(vis, "\t", 1);
return;
}