aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-18 16:31:26 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-18 16:31:26 +0200
commit61a0008ad75189f542df3818d3d0c43830b94990 (patch)
tree2c97860a71c358b98f79287300343ce3147c0382
parentef5c9d41e86a2c8af909308355518635a6007d56 (diff)
downloadvis-61a0008ad75189f542df3818d3d0c43830b94990.tar.gz
vis-61a0008ad75189f542df3818d3d0c43830b94990.tar.xz
vis: use internal file to show lua errors
This means no event handlers are run for it, hence there is no chance for recursive errors.
-rw-r--r--vis-core.h1
-rw-r--r--vis-prompt.c11
-rw-r--r--vis.c3
3 files changed, 9 insertions, 6 deletions
diff --git a/vis-core.h b/vis-core.h
index 4a5d3fc..5480589 100644
--- a/vis-core.h
+++ b/vis-core.h
@@ -139,6 +139,7 @@ struct Vis {
File *files; /* all files currently managed by this editor instance */
File *command_file; /* special internal file used to store :-command prompt */
File *search_file; /* special internal file used to store /,? search prompt */
+ File *error_file; /* special internal file used to store lua error messages */
Win *windows; /* all windows currently managed by this editor instance */
Win *win; /* currently active/focused window */
Win *message_window; /* special window to display multi line messages */
diff --git a/vis-prompt.c b/vis-prompt.c
index 3711cc9..01dc916 100644
--- a/vis-prompt.c
+++ b/vis-prompt.c
@@ -189,18 +189,17 @@ void vis_info_hide(Vis *vis) {
void vis_message_show(Vis *vis, const char *msg) {
if (!msg)
return;
- if (!vis->message_window) {
- if (!vis_window_new(vis, NULL))
- return;
- vis->message_window = vis->win;
- }
-
+ if (!vis->message_window)
+ vis->message_window = window_new_file(vis, vis->error_file);
Win *win = vis->message_window;
+ if (!win)
+ return;
Text *txt = win->file->text;
size_t pos = text_size(txt);
text_appendf(txt, "%s\n", msg);
text_save(txt, NULL);
view_cursor_to(win->view, pos);
+ vis_window_focus(win);
}
void vis_message_hide(Vis *vis) {
diff --git a/vis.c b/vis.c
index 1be6864..593c540 100644
--- a/vis.c
+++ b/vis.c
@@ -361,6 +361,8 @@ Vis *vis_new(Ui *ui, VisEvent *event) {
goto err;
if (!(vis->search_file = file_new_internal(vis, NULL)))
goto err;
+ if (!(vis->error_file = file_new_internal(vis, NULL)))
+ goto err;
if (!(vis->keymap = map_new()))
goto err;
vis->mode_prev = vis->mode = &vis_modes[VIS_MODE_NORMAL];
@@ -384,6 +386,7 @@ void vis_free(Vis *vis) {
vis_window_close(vis->windows);
file_free(vis, vis->command_file);
file_free(vis, vis->search_file);
+ file_free(vis, vis->error_file);
for (int i = 0; i < LENGTH(vis->registers); i++)
register_release(&vis->registers[i]);
vis->ui->free(vis->ui);