aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ring.cpp
AgeCommit message (Collapse)AuthorFilesLines
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-11-01globbing supports character classes now and ^EN string building construct to ↵Robin Haberkorn1-2/+5
escape glob patterns * globbing is fnmatch(3) compatible, now on every supported platform. * which means that escaping of glob patterns is possible now. ^ENq has been introduced to ease this task. * This finally allows you to pass unmodified filenames to EB. Previously it was impossible to open file names containing glob wildcards. * this was achieved by moving from GPattern to GRegex as the underlying implementation. * The glob pattern is converted to a regular expression before being compiled to a GRegex. This turned out to be trickier than anticipated (~140 lines of code) and has a runtime penalty of course (complexity is O(2*n) over the pattern length). It is IMHO still better than the alternatives, like importing external code from libiberty, which is potentially non-cross-platform. * Using GRegex also opens the potential of supporting brace "expansions" later in the form of glob pattern constructs (they won't actually expand but match alternatives). * is_glob_pattern() has been simplified and moved to Globber::is_pattern(). It makes sense to reuse the Globber class namespace instead of using plain functions for functions working on glob patterns. * The documentation has a new subsection on glob patterns now. * Testsuite extended with glob pattern test cases
2016-02-10avoid unnecessary undo token allocations in batch mode: greatly speeds up ↵Robin Haberkorn1-2/+2
batch mode * by using variadic templates, UndoStack::push() is now responsible for allocating undo tokens. This is avoided in batch mode. * The old UndoStack::push(UndoToken *) method has been made private to avoid confusion around UndoStack's API. The old UndoStack::push() no longer needs to handle !undo.enabled, but at least asserts on it. * C++11 support is now required, so variadic templates can be used. This could have also been done using manual undo.enabled checks; or using multiple versions of the template with different numbers of template arguments. The latter could be done if we one day have to support a non-C++11 compiler. However since we're depending on GCC 4.4, variadic template use should be OK. Clang supports it since v2.9. * Sometimes, undo token pushing passed ownership of some memory to the undo token. The old behaviour was relied on to reclaim the memory even in batch mode -- the undo token was always deleted. To avoid leaks or repeated manual undo.enabled checking, another method UndoStack::push_own() had to be introduced that makes sure that an undo token is always created. In batch mode (!undo.enabled), this will however create the object on the stack which is much cheaper than using `new`. * Having to know which kind of undo token is to be pushed (taking ownership or not) is inconvenient. It may be better to add static methods to the UndoToken classes that can take care of reclaiming memory. * Benchmarking certain SciTECO scripts have shown 50% (!!!) speed increases at the highest possible optimization level (-O3 -mtune=native -march=native).
2016-01-28fixup: clarified :EX behaviour on modified unnamed filesRobin Haberkorn1-2/+4
* when the unnamed file was modified, :EW would just succeed discarding all changes to the unnamed file. * Instead now, :EX behaves like the EW$ command on each modified buffer including the unnamed file. * In other words, :EX will fail if there is a modified unnamed file * still refers to #4
2016-01-28added :EX (colon-modified EX): exits SciTECO saving all modified buffersRobin Haberkorn1-0/+10
* this allows you to exit and save only those buffers that are modified. This was not yet possible using macros, since there is currently no way to query the dirty state of buffers programmatically. * even if there was, the necessary key presses might be too much for some users. * the ability to save all modified buffers has been explicitly requested by an user in ticket #4. * the new behaviour is not compatible with classic TECO where EX would save the current file by default but provides a relatively short way to do just that. * updated the documentation: there was also one mistake regarding the boolean that EX accepts non-colon-modified.
2016-01-28updated copyright to 2016Robin Haberkorn1-1/+1
2015-06-12support UNIX-shell-like tilde-expansions in file names and directoriesRobin Haberkorn1-11/+11
* expands to the value of $HOME (the env variable instead of the register which currently makes a slight difference). * supported for tab-completions * supported for all file-name accepting commands. The expansion is done centrally in StateExpectFile::done(). A new virtual method StateExpectFile::got_file() has been introduced to pass the expanded/processed file name to command implementations. * sciteco(7) has been updated: There is now a separate section on file name arguments and file name handling in SciTECO. This information is important but has been scattered across the document previously. * optimized is_glob_pattern() in glob.h
2015-05-25restrict globbing in the EB command to regular files.Robin Haberkorn1-2/+2
As SciTECO can only edit regular files (or symlinks to regular files), we can exclude directories from the list of files matched by <EB> glob patterns.
2015-03-17fixed invalid memory accesses in the expression stack and reworked ↵Robin Haberkorn1-1/+1
expression stack this was probably a regression from d94b18819ad4ee3237c46ad43a962d0121f0c3fe and should not be in v0.5. The return value of Expressions::find_op() must always be checked since it might not find the operator, returning 0 (it used to be 0). A zero index pointed to uninitialized memory - in the worst case it pointed to invalid memory resulting in segfaults. Too large indices were also not handled. This was probably responsible for recent PPA build issues. Valgrind/memcheck reports this error but I misread it as a bogus warning. I took the opportunity to clean up the ValueStack implementation and made it more robust by adding a few assertions. ValueStacks now grow from large to small addresses (like stack data structures usually do). This means, there is no need to work with negative indices into the stack pointer. To reduce the potential for invalid stack accesses, stack indices are now unsigned and have origin 0. Previously, all indices < 1 were faulty but weren't checked. Also, I added some minor optimizations.
2015-03-07changed save point file format to .teco-<n>-<filename>~Robin Haberkorn1-2/+2
* It is no longer possible to accidentally open save point files of the same or another SciTECO instance when typing something like EB*.cpp$ * The use of a trailing ~ is common among editors. These files will be recognized more easily as temporary by users. * People will often already have VCS ignore rules for files with trailing tilde. Therefore SciTECO savepoints will often be already ignored by VCS. * Since they still have a unique ".teco" prefix, they will not be confused by other programs as backup files. * Also mention in sciteco(1) that save point files are hidden on Windows.
2015-02-11updated copyright to 2015Robin Haberkorn1-1/+1
2014-11-24turn off Scintilla undo collection by default and fixed memleakRobin Haberkorn1-0/+9
* in batch mode, Scintilla undo actions are simply leaked memory * Since we have more than one Scintilla view now, we must empty the undo buffer of all scintilla views when a command line is committed ($$)
2014-11-24Q-Register loading and saving using the IOView classRobin Haberkorn1-3/+9
* EW can save Q-Registers now * the new E% may be used to save a q-register without making it the current document
2014-11-24factored out file loading and saving into the View specialisation IOViewRobin Haberkorn1-342/+25
this will allow us to use the same algorithms for loading and saving Q-Registers (from/to file). * Saving with EW when a Q-Reg is edited has been fixed (was broken earlier) * SciTECO save point files are now named .teco-X-BASENAME When using IOView for Q-Regs, there will be no way to sensible count the save points. Each write of a Q-Reg may be to another file. Therefore, we number save-points globally. If the sequence of writes has to be reconstructed manually, one can still look at the save point files' modification dates * give more informative error messages when saving a file fails
2014-11-22added EJ command: return runtime propertiesRobin Haberkorn1-0/+15
* main motivation is to have a way of getting the number of buffers in the ring. "EJ" or "1EJ" will do that. This simplifies macros that will have to iterate all the buffers. They no longer have to close the existing buffers to do that. * "0EJ" will get the current user interface. This is useful to select a different color scheme in the startup profile depending on the UI, for instance.
2014-11-22added globbing command ENRobin Haberkorn1-32/+9
* implements the same globbing as the EB command already did * uses Globber helper class that behaves more like UNIX glob(). glib only has a glob-style pattern matcher. * The Globber class may be extended later to provide more UNIX-like globbing. * lexer.tes has been updated to make use of globbing. Now, lexers can be automatically loaded and registered at startup. To install a new lexer, it's sufficient to copy a file to the lexers/ directory.
2014-11-21finally implemented the CLOSE and QUIT hooksRobin Haberkorn1-0/+1
the QUIT hook is actually not that trivial and required some architectural changes. First, the QUIT hook execution and any error that might occurr cannot always be attached to an existing error stack frame. Thereforce, to give a stack frame for QUIT hooks and to improve the readability of error traces for ED hooks in general, a special EDHookFrame is added to every ED hook execution error. Secondly, since QUIT hooks can themselves throw errors, we cannot run it from an atexit() handler. Instead it's always called manually before __successful__ program termination. An error in a QUIT hook will result in a failure return code nevertheless. Thirdly, errors in QUIT hooks should not prevent program termination (in interactive mode), therefore they are only invoked from main() and always in batch mode. I.e. if the interactive mode is terminated (EX$$), SciTECO will switch back to batch mode and run the QUIT hook there. This is also symmetric to program startup, which is always in batch mode. This means that Interface::event_loop() no longer runs indefinitely. If it returns, this signals that the interface shut down and batch mode may be restored by SciTECO.
2014-11-20allow a current buffer if we're editing a Q-RegisterRobin Haberkorn1-3/+3
this eases handling of the "*" register
2014-11-16cleaned up Scintilla document "updating"Robin Haberkorn1-12/+12
* allowed me to remove some obscure global functions and methods like QRegister::update_string(). * Document updating is concentrated in qregisters.cpp now * also fixes some bugs introduced earlier, like undo tokens being generated for non-undo registers (resulting in segfaults on rubout)
2014-11-16rewritten View and Interface base classes using the Curiously Recurring ↵Robin Haberkorn1-8/+8
Template Pattern. * without the one-view-per-buffer designs, many Scintilla send message (SSM) calls could be inlined * with the new design, this was no longer possible using the abstract base classes. the CRT pattern allows inlining again but introduces a strange level of code obscurity. * tests suggest that at high optimization levels, the one-view-per-buffer design and the CRT pattern reduces typical macro runtimes by 30% (e.g. for symbols-extract.tes). * only updated the NCurses UI for the time being
2014-11-16first working version of the one-view-per-buffer designRobin Haberkorn1-7/+5
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-1/+2
* 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-2/+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-01fixed reversing EW (save as)Robin Haberkorn1-23/+22
when the file name changes, there will no longer be a use-less save point file. instead the new file is deleted upon rubout. * save points are properly created if a file already exists with the same name, even though it was not known to SciTECO before the save. (e.g. you do save-as to a file that already exists). * more effects of the save command can now be rubbed out correctly
2014-02-18comment on unused-result warning of fchown()Robin Haberkorn1-1/+5
2014-02-15updated Copyright to year 2014Robin Haberkorn1-1/+1
2014-02-15use GLib's GError information to yield errorsRobin Haberkorn1-5/+5
* results in better error messages, e.g. when opening files * the case that a file to be opened (EB) exists but is not readably is handled for the first time
2014-02-15removed most exception specifications: allow bad_allocs to propagateRobin Haberkorn1-5/+5
* specifications resulted in runtime errors (unexpected exception) when bad_alloc ocurred * specs should be used scarcely: only when the errors that may be thrown are all known and for documentary purposes
2013-03-18declare all global inter-dependant objects in main.cpp and get rid of ↵Robin Haberkorn1-3/+0
init_priority attribute * we cannot use weak symbols in MinGW, so we avoid init_priority for symbol initialization by compiling the empty definitions into sciteco-minimal but the real ones into sciteco (had to add new file symbols-minimal.cpp) * this fixes compilation/linking on LLVM Clang AND Dragonegg since their init_priority attribute is broken! this will likely be fixed in the near future but broken versions will be around for some time
2013-03-18make sure a (void*)0 is used as sentinelsRobin Haberkorn1-3/+3
since including glib.h on LLVM-Clang (32-bit) results in NULL being redefined to 0 and compiler warnings being emitted when NULL is used as sentinels
2013-03-16documented remaining commandsRobin Haberkorn1-0/+79
* flow control and other structures have not been documented this ways. I have not yet decided whether they should be documented in separate sections or use the documentation tool.
2013-02-22use typedef for SciTECO integers and make it configurable at configure timeRobin Haberkorn1-5/+5
* storage size should always be 64 (gint64) to aid macro portability * however, for performance reasons users compiling from source might explicitly compile with 32 bit integers
2013-02-22clean up QRegister vs. Buffer redundancies using TECODocument classRobin Haberkorn1-3/+3
* also encapsulates data properly (previously there were many public attributes to avoid permission issues) * new class also cares about saving/and restoring scroll state. now, buffer/q-reg edits and temporary accesses do not reset the scroll state anymore.
2013-02-01fixed buffer Ring initializationRobin Haberkorn1-1/+2
* there was a dependency on interface initialization. it did not cause issues because destruction order was by chance. * introduced INIT_PRIO and PRIO_* macros to easy initialization order declaration (using a PRIO_* formula makes code self-documenting) * also used this to clean up QRegisterTable initialization (we do not need the explicit initialize() method) * also used to clean up symbols initialization
2013-01-22This reverts commit 821c61e9967e62fd81038e4b879c5452bffe2dfb.Robin Haberkorn1-9/+30
memory mapping the entire file has been benchmarked to be less efficient than the old implementation (because of more than doubling page faults). A lengthy comment has been written to discuss different implementations of file reading.
2013-01-21improved reading files by using memory-mappingRobin Haberkorn1-6/+9
* file must be in primary memory for scintilla * we cannot write to scintilla's buffer memory directly * so mapping the file is best: in the best case it is not copied to primary memory and resides in kernel cache * in any case, mapping to memory is faster than read()ing into primary memory * copying from mapped virtual memory to scintilla buffer (via SCI_APPENDTEXT) is faster than copying from primary memory
2013-01-21fixed: preserve access mode and ownership (if possible) of file when savingRobin Haberkorn1-19/+109
* works with/without save-points (i.e. in batch and interactive mode, both were broken) * improved file-saving performance (avoid buffer gap removal) * only root can preserve the ownership of a file owned by another user after file saving
2013-01-19updated copyright (2012-2013)Robin Haberkorn1-1/+1
2012-12-04added copyright notice to every source fileRobin Haberkorn1-0/+17
2012-12-04additional minor changes: distribution building now possibleRobin Haberkorn1-1/+1
2012-12-04first working version of autotools based build-systemRobin Haberkorn1-0/+4
2012-12-04autoconf preparation: move everything into src/ subdirRobin Haberkorn1-0/+539