diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-11 15:52:32 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-11 15:52:32 +0200 |
| commit | 6c5bdddbb5e7f79a04a0ee2bd7a9252035151812 (patch) | |
| tree | 128f04c8f39aac526414056fda2c4ac11eb46ea1 /editor.c | |
| parent | 89c99d64005f9e31b70f7eae8c0f6a76b24f4b14 (diff) | |
| download | vis-6c5bdddbb5e7f79a04a0ee2bd7a9252035151812.tar.gz vis-6c5bdddbb5e7f79a04a0ee2bd7a9252035151812.tar.xz | |
Add :edit command
Diffstat (limited to 'editor.c')
| -rw-r--r-- | editor.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -85,6 +85,29 @@ static void editor_windows_arrange_vertical(Editor *ed) { } } +bool editor_window_reload(EditorWin *win) { + const char *filename = text_filename(win->text); + /* can't reload unsaved file */ + if (!filename) + return false; + Text *text = text_load(filename); + if (!text) + return false; + /* check wether the text is displayed in another window */ + bool needed = false; + for (EditorWin *w = win->editor->windows; w; w = w->next) { + if (w != win && w->text == win->text) { + needed = true; + break; + } + } + if (!needed) + text_free(win->text); + win->text = text; + window_reload(win->win, text); + return true; +} + static void editor_window_split_internal(Editor *ed, const char *filename) { EditorWin *sel = ed->win; if (filename) { |
