diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-19 11:27:55 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-19 11:27:55 +0200 |
| commit | f212b9d4952c87052e23b5161195917410b7c911 (patch) | |
| tree | 238e6fdefac447230b556779870dde4baa466247 /editor.c | |
| parent | def913f428365d048ce30d71117421acbf379a75 (diff) | |
| download | vis-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.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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: |
