diff options
| author | Greg Ercolano <erco@seriss.com> | 2016-07-18 21:12:25 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2016-07-18 21:12:25 +0000 |
| commit | 8850c5c822ce0878b4d808c46b25463136a69231 (patch) | |
| tree | 07a74f064beca50b2e7ac8f48a22e244eb4a0437 /fluid/ExternalCodeEditor_WIN32.h | |
| parent | bcb75b518f47583a1265edfcd1984f6a675cbb60 (diff) | |
Adds external editor capability to fluid for all platforms.
Solves STR#3213. [CORRECTED]
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11818 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid/ExternalCodeEditor_WIN32.h')
| -rw-r--r-- | fluid/ExternalCodeEditor_WIN32.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/fluid/ExternalCodeEditor_WIN32.h b/fluid/ExternalCodeEditor_WIN32.h new file mode 100644 index 000000000..43492e632 --- /dev/null +++ b/fluid/ExternalCodeEditor_WIN32.h @@ -0,0 +1,63 @@ +// +// "$Id: ExternalCodeEditor_WIN32.h 10800 2016-07-10 00:00:00Z greg.ercolano $". +// +// External code editor management class for Windows +// +// 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 + +/* We require at least Windows 2000 (WINVER == 0x0500) for GetFileSizeEx(). */ +/* This must be defined before #include <windows.h> - MinGW doesn't do that. */ +#if !defined(WINVER) || (WINVER < 0x0500) +# ifdef WINVER +# undef WINVER +# endif +# define WINVER 0x0500 +#endif +#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500) +# ifdef _WIN32_WINNT +# undef _WIN32_WINNT +# endif +# define _WIN32_WINNT 0x0500 +#endif + +#include <windows.h> /* CreateFile().. */ +#include <string.h> /* sprintf().. */ + +class ExternalCodeEditor { + PROCESS_INFORMATION pinfo_; // CreateProcess() handle to running process + FILETIME file_mtime_; // last modify time of the file (used to determine if file changed) + LARGE_INTEGER file_size_; // last file size (used to determine if changed) + const char * filename_; // tmpfilename editor uses +protected: + void kill_editor(); + void reap_cleanup(); + const char *create_tmpdir(); + const char *tmp_filename(); + int start_editor(const char *cmd, const char *filename); + void set_filename(const char *val); +public: + ExternalCodeEditor(); + ~ExternalCodeEditor(); + int is_editing(); + DWORD reap_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 */ +// +// End of "$Id: ExternalCodeEditor_WIN32.h 10800 2016-07-10 00:00:00Z greg.ercolano $". +// |
