aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/spawn.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-03-23fixed and optimized piping very large buffers via EC/EGRobin Haberkorn1-12/+16
* test case: HECcat$ on a large buffer (>= 64kb) truncates the buffer or repeats its beginning * it turns out that the incremental writing to the process' stdin was broken. We were always writing data from the beginning of the buffer which fails if the stdin watcher must be activated more than once. * Also, EOLWriter::convert() can validly return 0, even if bytes have been written on the data sink, so this value cannot be used to check whether the process has closed its stdin. We now make sure that the entire buffer range is written to stdin. * Piping large buffers no longer removes the buffer gap. This makes little difference when filtering via EC since it will change the buffer gap anyway. Can make a huge difference when not touching the buffer, though (e.g. HEGAcat$). * I did not add a test suite case since that requires a very large test file and it cannot be easily generated automatically.
2017-03-18fixed Q-Reg autocompletion for `Q` commandRobin Haberkorn1-0/+2
* StateQueryQReg is now derived from StateExpectQReg whose semantics have been changed slightly. * The alternative would have been another common base class for both StateQueryQReg and StateExpectQReg.
2017-03-03updated copyright to 2017Robin Haberkorn1-1/+1
2016-11-18the manual generator (generator-docs.tes) has been cleaned up and is now ↵Robin Haberkorn1-2/+2
called tedoc.tes * some code simplifications * it now supports command line arguments via getopt.tes. * the -C flag enabled C/C++ mode. By default tedoc parses SciTECO code which means it can be used to document macro packages as well. * Therefore it is installed as a separate tool now. It may be used as a Groff preprocessor for third-party macro authors to generate (wo)man pages. * there's a man page tedoc.tes(1) * The troff placeholder macro is now called ".TEDOC". * Help topics can now be specified after the starting comment /*$ or !*$. Topics have been defined for all built-in commands.
2016-08-19Integrated clipboard supportRobin Haberkorn1-84/+96
* mapped to different registers beginning with "~" * on supported platforms accessing the clipboard is as easy as X~ or G~. Naturally this also allows clipboards to be pasted in string arguments/insertions (^EQ~). * Currently, Gtk+, PDCurses and ncurses/XTerm are supported. For XTerm clipboard support, users must set 0,256ED to enable it since we cannot check for XTerm window ops programmatically (at least without libX11). * When clipboard regs exist, the clipboard can also be deemed functional. This allows macros to fall back to xclip(1) if necessary. * EOL handling has been moved into a new file eol.c and eol.h. EOL translation no longer depends on GIOChannels but can be memory-backed as well.
2016-06-04added ^E@ string building characterRobin Haberkorn1-0/+5
* allows expansion of Q-Register contents with UNIX shell quoting * This especially improves the usefulness of the EC/EG commands as we can reliably determine that a TECO string (ie. Q-Register) will end up as a single argument to the spawned process. A previous workaround was to enclose ^EQ in quotes, but it does not work e.g. if the register contains the wrong kind of quotes or other magic shell characters. * NOTE: In order to be absolutely sure about the runtime behaviour of EC plus ^E@, you will have to enable UNIX98 shell emulation in portable macros.
2016-02-24EG and EC use $SHELL and $COMSPEC as the default command interpreters nowRobin Haberkorn1-17/+28
* The default command interpreter will thus be inherited from the operating system. In the case of UNIX from the user's passwd entry. E.g. if bash is used, bash extensions can be used immediately if flag 128 is not set in the ED flags. * On DOS-like systems there are also alternative interpreters (e.g. 4NT, 4OS2) that are configurable now. * At least on UNIX with $SHELL it is not guaranteed that the interpreter supports the standard command line arguments like "-c". If they don't, this will cause problems with EC. Since $SHELL is mapped to a Q-Register, it can however always be easily customized for SciTECO sessions in the user's .teco_ini.
2016-01-28updated copyright to 2016Robin Haberkorn1-1/+1
2015-07-28added full Haiku OS support (non x86_gcc2)Robin Haberkorn1-1/+1
* Haiku can be handled like UNIX in most respects since it is POSIX compliant, has a UNIX-like terminal emulator and uses ncurses. * still the Glib platform macro is G_OS_HAIKU instead of G_OS_UNIX, so the preprocessor conditionals had to be adapted. * the only functional difference between a Haiku and UNIX build is the default SCITECOCONFIG path. We use the config path returned by Glib instead of $HOME, so .teco_ini will be in ~/config/settings on Haiku. Other UNIX ports appear to use the same conventions. * Some Haiku-specific restrictions still apply: * Haiku's terminal is xterm-compatible, but only supports 8 colors. Therefore only the terminal.tes color scheme can be used and the terminal must be set up to "Use bright instead of bold text". * The terminal has artifacts. This appears to be a Haiku bug and affects other curses applications as well. * GTK is yet unsupported on Haiku, so there may never be a GUI port (unless someone writes a QT GUI for SciTECO). * SciTECO cannot be built with the legacy gcc2 used for BeOS compatibility on Haiku. This would require too many changes for an obsolete platform. BeOS and the x86_gcc2 platform of Haiku will therefore never be supported. The PPC and ARM platforms of Haiku should work but are untested. * a HaikuPorts recipe will be provided for the next regular SciTECO release. This should hopefully allow installation via HaikuDepot.
2015-07-27work around segfaults on HaikuRobin Haberkorn1-0/+9
* there appears to be a bug in Haiku's glib v2.38 g_main_context_unref(). However I could not find a fix in glib's log. * as a workaround, simply do not unref the main context. Memory is reclaimed after program termination anyway.
2015-06-29MicroStateMachine::input() returns whether a result was set nowRobin Haberkorn1-2/+2
* this means that QRegSpecMachine::input() no longer has to return a dummy QRegister in parse-only mode. This saves an unnecessary QRegister table lookup and speeds up parsing. * QRegSpecMachine can now be easily extended to behave differently when returning a Q-Register, e.g. simply returning NULL if a register does not exist, or returning a register by prefix. This is important for some planned commands. * StateExpectQReg::got_register() now gets a QRegister *. It can theoretically be NULL - still we don't have to check for NULL in most cases since NULL is only passed in parse-only mode.
2015-06-14handle environment variables more consistentlyRobin Haberkorn1-3/+14
* the registers beginning with "$" are exported into sub-process environments. Therefore macros can now modify the environment (variables) of commands executed via EC/EG. A variable can be modified temporarily, e.g.: [[$FOO] ^U[$FOO]bar$ EC...$ ][$FOO] * SciTECO accesses the global environment registers instead of using g_getenv(). Therefore now, tilde-expansion will always use the current value of the "$HOME" register. Previously, both register and environment variable could diverge. * This effectively fully maps the process environment to a subset of Q-Registers beginning with "$". * This hasn't been implemented by mapping those registers to special implementations that updates the process environment directly, since g_setenv() is non-thread-safe on UNIX and we're expected to have threads soon - at least in the GTK+ UI.
2015-06-02added <FG> command and special Q-Register "$" to set and get the current ↵Robin Haberkorn1-2/+2
working directory * FG stands for "Folder Go" * FG behaves similar to a Unix shell `cd`. Without arguments, it changes to the $HOME directory. * The $HOME directory was previously only used by $SCITECOCONFIG on Unix. Now it is documented on its own, since the HOME directory should also be configurable on Windows - e.g. to adapt SciTECO to a MinGW or Cygwin installation. HOME is initialized just like the other environment variables. This also means that now, the $HOME Q-Register is always defined and can be used by platform-agnostic macros. * FG uses a new kind of tab-completion: for directories only. It would be annoying to complete the FG command after every directory, so this tab-completion does not close the command automatically. Theoretically, it would be possible to close the command after completing a directory with no subdirectories, but this is not supported currently. * Filename arguments are no longer completed with " " if {} escaping is in place as this brings no benefit. Instead no completion character is inserted for this escape mode. * "$" was mapped to the current directory to support an elegant way to insert/get the current directory. Also this allows the idiom "[$ FG...new_dir...$ ]$" for changing the current directory temporarily. * The Q-Register stack was extended to support restoring the string part of special Q-Registers (that overwrite the default functionality) when using the "[$" and "]$" commands. * fixed minor typos (american spelling)
2015-03-16documented the automatic EOL translation featureRobin Haberkorn1-0/+12
2015-03-16implemented automatic EOL translation supportRobin Haberkorn1-37/+69
* activated via bit 4 of the ED flag (enabled by default) * automatic EOL guessing on file loading and translation to LFs. * works with files that have inconsistent EOL sequences. * automatic translation to original EOL sequences on file saving * works with inconsistent EOL sequences in the buffer. This should usually not happen if the file was read in with automatic EOL translation enabled. * also works with the EC and EG commands * performance is OK, depending on the file being translated. When reading files with UNIX EOLs, the overhead is minimal typically-sized files. For DOS EOLs the overhead is larger but still acceptable. * Return (line feed) is now an immediate editing command. This centralizes EOL sequence insertion. Later, other features like auto-indent could be added to the editing command. * get_eol() has been moved to main.cpp (now called get_eol_seq() * Warn if file ownership could not be preserved when saving files. * IOView has been almost completely rewritten based on GIOChannels. The EOL translation code is also in IOView.
2015-03-02fixed minor typos in <EC> documentationRobin Haberkorn1-2/+2
2015-02-14updated Scintilla submodule: fixed tab stop calculation on CursesRobin Haberkorn1-1/+1
* also did some whitespace cleanup in SciTECO now that tabs are displayed properly
2015-02-11updated copyright to 2015Robin Haberkorn1-1/+1
2014-12-15fixup: the spawn context's GError must not be memory-managed by the state objectRobin Haberkorn1-4/+0
this is because ownership of the GError may be passed to GlibError()
2014-12-15always free glib's GError structuresRobin Haberkorn1-0/+6
* when throwing GlibError(), this is taken care of automatically. * fixes a memleak since there may be resources associated with the GError.
2014-12-15add workaround for missing g_spawn_check_exit_status() in libglib v2.33 and ↵Robin Haberkorn1-0/+41
earlier * Debian 7 is still at libglib v2.33 and since it should be supported, I reimplemented the missing function (UNIX-only). * This workaround can be removed once libglib v2.34 becomes common place. Closes #2
2014-11-16first working version of the one-view-per-buffer designRobin Haberkorn1-2/+2
The user interface provides a Scintilla view abstraction and every buffer is based on a view. All Q-Register strings use a single dedicated view to save memory and initialization time when using many string registers. * this means we can finally implement a working lexer configuration and it only has to be done once when the buffer is first added to the ring. It is unnecessary to magically restore the lexer styles upon rubout of EB (very hard to implement anyway). It is also not necessary to rerun the lexer configuration macro upon rubout which would be hard to reconcile with SciTECO's basic design since every side-effect should be attached to a character. * this means that opening buffers is slightly slower now because of the view initialization * on the other hand, macros with many string q-reg operations are faster now, since the document must no longer be changed on the buffer's view and restored later on. * also now we can make a difference between editing a document in a view and changing the current view, which reduces UI calls * the Document class has been retained as an abstraction about Scintilla documents, used by QRegister Strings. It had to be made virtual, so the view on which the document is created can be specified by a virtual function. There is no additional space overhead for Documents.
2014-11-11refactored SciTECO runtime errors: moved from parser.cpp to error.cppRobin Haberkorn1-2/+3
* the GError expection has been renamed to GlibError, to avoid nameclashes when working from the SciTECO namespace
2014-11-11added all of SciTECO's declarations to the "SciTECO" namespaceRobin Haberkorn1-0/+4
normally, since SciTECO is not a library, this is not strictly necessary since every library should use proper name prefixes or namespaces for all global declarations to avoid name clashes. However * you cannot always rely on that * Scintilla does violate the practice of using prefixes or namespaces. The public APIs are OK, but it does define global functions/methods, e.g. for "Document" that clashed with SciTECO's "TECODocument" class at link-time. Scintilla can put its definitions in a namespace, but this feature cannot be easily enabled without patching Scintilla. * a "SciTECO" namespace will be necessary if "SciTECO" is ever to be turned into a library. Even if this library will have only a C-linkage API, it must ensure it doesn't clutter the global namespace. So the old "TECODocument" class was renamed back to "Document" (SciTECO::Document).
2014-11-10fixed EG command: make sure to reset the register argument on termination,Robin Haberkorn1-0/+2
else the next EC command will not work as expected or even crash
2014-11-09fixed EC command for negative line rangesRobin Haberkorn1-0/+6
2014-11-09allow "-EC" command even though we do not generally imply the sign prefixRobin Haberkorn1-3/+13
2014-11-09documented EC and EG commandsRobin Haberkorn1-0/+105
2014-11-09added EG command: pipe from buffer into Q-RegisterRobin Haberkorn1-7/+34
2014-11-09implemented EC command (execute operating system command) in spawn.cppRobin Haberkorn1-0/+366
powerful command for filtering a SciTECO buffer through an external program. It will be described in the sciteco(7) man pages. The implementation uses an asynchronous background process with pipes but is platform independant thanks to glib's g_spawn functions, GIOChannels and event loops. There are however platform differences in how the operating system command is interpreted/parsed.