From 1985aefc0e502048f92b91beef87c0dfbe669fed Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Fri, 7 Mar 2025 16:34:35 +0100 Subject: Restructuring Fluid source files. --- fluid/tools/ExternalCodeEditor_UNIX.h | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 fluid/tools/ExternalCodeEditor_UNIX.h (limited to 'fluid/tools/ExternalCodeEditor_UNIX.h') diff --git a/fluid/tools/ExternalCodeEditor_UNIX.h b/fluid/tools/ExternalCodeEditor_UNIX.h new file mode 100644 index 000000000..644f22afa --- /dev/null +++ b/fluid/tools/ExternalCodeEditor_UNIX.h @@ -0,0 +1,60 @@ +// +// External code editor management class for Unix +// +// Handles starting and keeping track of an external text editor, +// including process start, temp file creation/removal, bookkeeping, killing.. +// +#ifndef _EXTCODEEDITOR_H +#define _EXTCODEEDITOR_H + +#include "app/fluid.h" + +#include + +#include /* errno */ +#include /* strerror() */ +#include /* stat().. */ +#include +#include + +// ---- ExternalCodeEditor declaration + +class ExternalCodeEditor { + int pid_; + time_t file_mtime_; // last modify time of the file (used to determine if file changed) + size_t file_size_; // last file size (used to determine if changed) + const char *filename_; + std::string command_line_; + int last_error_; + int alert_pipe_[2]; + bool alert_pipe_open_; + static void alert_pipe_cb(FL_SOCKET, void*); + +protected: + void kill_editor(); + const char *create_tmpdir(); + const char *tmp_filename(); + int start_editor(const char *cmd, const char *filename); + void set_filename(const char *val); + void open_alert_pipe(); + +public: + ExternalCodeEditor(); + ~ExternalCodeEditor(); + int is_editing(); + int reap_editor(pid_t *pid_reaped=NULL); + void close_editor(); + const char *filename() { return filename_; } + int open_editor(const char *editor_cmd, const char *code); + int handle_changes(const char **code, int force=0); + int remove_tmpfile(); + // Public static methods + static void start_update_timer(); + static void stop_update_timer(); + static const char* tmpdir_name(); + static void tmpdir_clear(); + static int editors_open(); + static void set_update_timer_callback(Fl_Timeout_Handler); +}; + +#endif /*_EXTCODEEDITOR_H */ -- cgit v1.2.3