aboutsummaryrefslogtreecommitdiff
path: root/editor.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-19 11:27:55 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-19 11:27:55 +0200
commitf212b9d4952c87052e23b5161195917410b7c911 (patch)
tree238e6fdefac447230b556779870dde4baa466247 /editor.c
parentdef913f428365d048ce30d71117421acbf379a75 (diff)
downloadvis-f212b9d4952c87052e23b5161195917410b7c911.tar.gz
vis-f212b9d4952c87052e23b5161195917410b7c911.tar.xz
Implement expand tab functionality, make tabwidth configurable
If expandtab is enabled then inserted tabs are replaced by tabwidth amount of spaces. Both settings apply to all windows files and can be changed via: :set tabwidth n # where 1 <= n <= 8 :set expandtab (1|yes|true)|(0|no|false)
Diffstat (limited to 'editor.c')
-rw-r--r--editor.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/editor.c b/editor.c
index c56aec4..e0f27cf 100644
--- a/editor.c
+++ b/editor.c
@@ -185,6 +185,16 @@ static void editor_windows_invalidate(Editor *ed, size_t start, size_t end) {
editor_window_draw(ed->win);
}
+int editor_tabwidth_get(Editor *ed) {
+ return ed->tabwidth;
+}
+
+void editor_tabwidth_set(Editor *ed, int tabwidth) {
+ if (tabwidth < 1 || tabwidth > 8)
+ return;
+ for (EditorWin *win = ed->windows; win; win = win->next)
+ window_tabwidth_set(win->win, tabwidth);
+}
bool editor_syntax_load(Editor *ed, Syntax *syntaxes, Color *colors) {
bool success = true;
@@ -296,6 +306,7 @@ static EditorWin *editor_window_new_text(Editor *ed, Text *text) {
return NULL;
}
window_cursor_watch(win->win, editor_window_cursor_moved, win);
+ window_tabwidth_set(win->win, ed->tabwidth);
if (ed->windows)
ed->windows->prev = win;
win->next = ed->windows;
@@ -381,6 +392,8 @@ Editor *editor_new(int width, int height) {
goto err;
ed->width = width;
ed->height = height;
+ ed->tabwidth = 8;
+ ed->expandtab = false;
ed->windows_arrange = editor_windows_arrange_horizontal;
return ed;
err: