From 0791cac97ee689195e593cfca89c0b63fb721479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 22 Nov 2016 00:15:32 +0100 Subject: vis-lua: introduce pre-save hook The first argument is the file object while the second argument denotes the full path to which it will be written. Path might be `nil` if the file is going to be written to stdout. The Lua function is expected to return a boolean value indicating whether the write operation should proceed or be aborted. --- vis.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'vis.c') diff --git a/vis.c b/vis.c index dcd7457..f8d3dbf 100644 --- a/vis.c +++ b/vis.c @@ -58,6 +58,7 @@ bool vis_event_emit(Vis *vis, enum VisEvents id, ...) { vis->event->vis_start(vis); break; case VIS_EVENT_FILE_OPEN: + case VIS_EVENT_FILE_SAVE_PRE: case VIS_EVENT_FILE_SAVE_POST: case VIS_EVENT_FILE_CLOSE: { @@ -66,6 +67,9 @@ bool vis_event_emit(Vis *vis, enum VisEvents id, ...) { break; if (id == VIS_EVENT_FILE_OPEN && vis->event->file_open) { vis->event->file_open(vis, file); + } else if (id == VIS_EVENT_FILE_SAVE_PRE && vis->event->file_save_pre) { + const char *path = va_arg(ap, const char*); + ret = vis->event->file_save_pre(vis, file, path); } else if (id == VIS_EVENT_FILE_SAVE_POST && vis->event->file_save_post) { const char *path = va_arg(ap, const char*); vis->event->file_save_post(vis, file, path); -- cgit v1.2.3