Files
fltk/fluid/tools/ExternalCodeEditor_UNIX.h
Matthias Melcher 51a55bc736
Some checks are pending
Build and Test / build-linux (push) Waiting to run
Build and Test / build-wayland (push) Waiting to run
Build and Test / build-macos (push) Waiting to run
Build and Test / build-windows (push) Waiting to run
Fluid: restructuring and rejuvenation of the source code.
* Add classes for application and project
* Removed all globals from Fluid.h
* Extracting args and project history into their own classes
* Moving globals into Application class
* Initialize values inside headers for some classes.
* Undo functionality wrapped in a class inside Project.
* File reader and writer are now linked to a project.
* Avoid global project access
* Nodes (former Types) will be managed by a new Tree class.
* Removed static members (hidden globals) form Node/Fl_Type.
* Adding Tree iterator.
* Use nullptr instead of 0, NULL, or 0L
* Renamed Fl_..._Type to ..._Node, FL_OVERRIDE -> override
* Renaming ..._type to ...::prototype
* Splitting Widget Panel into multiple files.
* Moved callback code into widget panel file.
* Cleaning up Fluid_Image -> Image_asset
* Moving Fd_Snap_Action into new namespace fld::app::Snap_Action etc.
* Moved mergeback into proj folder.
* `enum ID` is now `enum class Type`.
2025-03-16 17:16:12 -04:00

61 lines
1.7 KiB
C++

//
// 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 "Fluid.h"
#include <FL/Fl.H>
#include <errno.h> /* errno */
#include <string.h> /* strerror() */
#include <sys/types.h> /* stat().. */
#include <sys/stat.h>
#include <unistd.h>
// ---- 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=nullptr);
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 */