aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/qregisters.cpp
AgeCommit message (Collapse)AuthorFilesLines
2015-03-16implemented automatic EOL translation supportRobin Haberkorn1-0/+39
* 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-10always normalize directory separators to "/" in the "*" Q-RegisterRobin Haberkorn1-4/+23
* on Windows, this register contained backward slashes. This means that macros working with that register had to cope with both forward and backward slashes. * The file names are still displayed in the native style by the UI * This approach also has disadvantages: What if the user wants to insert the current file name somewhere where "\" is expected? However, this seems to be an unlikely case and the use can still replace the "/" with "\" again. * Avoid some virtual method calls in QRegisterBufferInfo
2015-03-07fixed m,nXq for m > n: this properly throws an error nowRobin Haberkorn1-3/+3
2015-03-01keep rubbed out command line for later re-insertion and massive Cmdline ↵Robin Haberkorn1-6/+7
cleanup/refactoring * characters rubbed out are not totally removed from the command line, but only from the *effective* command line. * The rubbed out command line is displayed after the command line cursor. On Curses it is grey and underlined. * When characters are inserted that are on the rubbed out part of the command line, the cursor simply moves forward. NOTE: There's currently no immediate editing command for reinserting the next character/word from the rubbed out command line. * Characters resulting in errors are no longer simply discarded but rubbed out, so they will stay in the rubbed out part of the command line, reminding you which character caused the error. * Improved Cmdline formatting on Curses UI: * Asterisk is printed bold * Control characters are printed in REVERSE style, similar to what Scinterm does. The controll character formatting has thus been moved from macro_echo() in cmdline.cpp to the UI implementations. * Updated the GTK+ UI (UNTESTED): I did only, the most important API adaptions. The command line still does not use any colors. * Refactored entire command line handling: * The command line is now a class (Cmdline), and most functions in cmdline.cpp have been converted to methods. * Esp. process_edit_cmd() (now Cmdline::process_edit_cmd()) has been simplified. There is no longer the possibility of a buffer overflow because of static insertion buffer sizes * Cleaned up usage of the cmdline_pos variable (now Cmdline::pc) which is really a program counter that used a different origin as macro_pc which was really confusing. * The new Cmdline class is theoretically 8-bit clean. However all of this will change again when we introduce Scintilla views for the command line. * Added 8-bit clean (null-byte aware) versions of QRegisterData::set_string() and QRegisterData::append_string()
2015-03-01moved String helper functions from sciteco.h and main.cpp to ↵Robin Haberkorn1-0/+1
string-utils.cpp and string-utils.h * also improved performance of String::append() by using g_realloc() * added String::append() variant for non-null-terminated strings
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-11-24implemented pQq and :Qq commandsRobin Haberkorn1-18/+104
2014-11-24Q-Register loading and saving using the IOView classRobin Haberkorn1-13/+62
* 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-22added variant of the ^U command with string building: the EU commandRobin Haberkorn1-5/+31
it became apparent, that something like this is very useful, when constructing the contents of a q-register without editing it. I have decided against introducing another modifier for toggling string building. Most commands have string building enabled and it doesn't hurt. For the few exceptions, an alternative variant can be introduced.
2014-11-22allow setting the "*" register as an alternative to nEBRobin Haberkorn1-7/+15
this is more consistent with SciTECO's idea of abstract registers and allows the currend buffer to be saved on the Q-Register stack. This allows the idiom: [* ! ...change current buffer... ! ]*
2014-11-22fixed document parameters when editing local q-registers (must_undo)Robin Haberkorn1-1/+6
2014-11-21finally implemented the CLOSE and QUIT hooksRobin Haberkorn1-20/+34
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-20renamed ED hook register to "ED" and protect ED hook executionsRobin Haberkorn1-1/+22
SciTECO commands usually only take parameters from the stack that they need. Without protecting the ED hook execution with brace operators, additional arguments not consumed by the hook-dispatching command are passed into the ED hook invocation. Also an ED hook macro could leave additional values on the expression stack (by accident). All of this may lead to undefined behaviour if ED hooks are involved.
2014-11-20Throw error when a macro terminates while a local q-reg is edited.Robin Haberkorn1-0/+24
This is only a problem if the macro created the local Q-Register table (i.e. not when called with ":M") but resulted in segfaults. Since we do not want to save in a Q-Reg whether it is local (and that wouldn't suffice anyway), we do it in the Q-Register table cleanup. The corresponding QRegisterTable::clear() must be called explicitly, since the RBTree::clear() called on destruction does not and cannot throw errors. If QRegisterTable::clear() has been called successfully, the default object destructor will not do much. If it has thrown an error, the destructor will clean up the remaining Q-Registers.
2014-11-20allow a current buffer if we're editing a Q-RegisterRobin Haberkorn1-7/+6
this eases handling of the "*" register
2014-11-17Make sure QRegister::view is properly initialized and cleaned upRobin Haberkorn1-22/+21
* it must be initialized after the UI (Interface::main), so I added a View::initialize() function * the old initialize() method was renamed to setup() * use a global instance of QRegister::view so it is guaranteed to be destroyed only after any QRegisters that could still need it * Document API adapted to work with ViewCurrent references
2014-11-16cleaned up Scintilla document "updating"Robin Haberkorn1-40/+28
* 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-16first working version of the one-view-per-buffer designRobin Haberkorn1-51/+56
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-4/+5
* 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-10extended ^U command: allow setting and appending of strings and characters fromRobin Haberkorn1-5/+58
the expression stack now it's more like standard TECO's ^U command
2014-11-09revised U command: fail if no argument is providedRobin Haberkorn1-5/+22
* there is no reasonable default value for U * omitting the parameter for U might be a frequent programming error * U can be colon-modified now, in which case it may be used * to check for the presence of arguments in macros
2014-11-02changed syntax for long Q-Register names: use [] brackets instead of {}Robin Haberkorn1-3/+3
this breaks many existing scripts, and means you may have to rebuild SciTECO with ./configure --enable-bootstrap The syntax of SciTECO might change in backwards-incompatible until version 1.0 is released.
2014-02-18removed unreliable CHR2STR() macroRobin Haberkorn1-1/+1
* referencing temporaries is unreliable/buggy in GNU C++, at least since v4.7 * in higher optimization levels it resulted in massive memory corruptions * this is responsible for the build issues (PPA build issues) * instead, always declare a buffer on the stack which guarantees that the variable lives long enough * the g_strdup(CHR2STR(x)) idiom has been replaced with String::chrdup(x)
2014-02-15updated Copyright to year 2014Robin Haberkorn1-1/+1
2014-02-15use GLib's GError information to yield errorsRobin Haberkorn1-8/+6
* 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-16/+16
* 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
2014-02-15added support for TECO stack tracingRobin Haberkorn1-3/+7
* when an error is thrown, stack frames are collected on clean up, up to the toplevel macro * the toplevel macro decides how to display the error * now errors in interactive and batch mode are displayed differently * in batch mode, a backtrace is displayed as a sequence of messages * Execute::file() forwards errors correctly * the correct error in the file is displayed in interactive mode * necessary to build the stack trace
2013-03-18explicitly instantiate MicroStateMachine: fixes compilation with gcc-4.4Robin Haberkorn1-1/+1
2013-03-18declare all global inter-dependant objects in main.cpp and get rid of ↵Robin Haberkorn1-7/+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-16fixed: prevent accessing registers in parse-only modeRobin Haberkorn1-0/+10
* they might not already exist, yielding bogus errors * in case the register might be initialized we do not want to do so in parse-only-mode * this fix is only a workaround: currently we must return a register sind got_register() expects one and must be called to determine the next state in parse only mode * proper solution would be to better separate parsing and execution
2013-03-16documented remaining commandsRobin Haberkorn1-0/+124
* 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-25EM...$ command to read macro from file and execute immediately (just like "M")Robin Haberkorn1-0/+13
* useful for using macro libraries
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-22fixed global object initialization order issueRobin Haberkorn1-0/+6
* Scintilla is now initialized from main() using Interface::main() * Scintilla initialization depends on initialization of objects in the global namespace (otherwise the Lexer catalogue may not be filled properly and lexing may not work). Lexer modules were initialized after SciTECO interface initialization * merged Scintilla initialization (Interface::main()) with interface option parsing
2013-02-22clean up QRegisterTable::insert|initialize usageRobin Haberkorn1-3/+3
* distinction no longer useful since string part of register is now never pre-initialized
2013-02-22clean up QRegister vs. Buffer redundancies using TECODocument classRobin Haberkorn1-33/+25
* 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-14hide some implementation details in MicroStateMachinesRobin Haberkorn1-4/+1
2013-02-14undo q-register table initializations (insertions) on ruboutRobin Haberkorn1-0/+1
2013-02-14option for q-reg spec state machine to allocate (insert) new q-registersRobin Haberkorn1-6/+10
* enabled for all modifying Q-Reg commands
2013-02-14micro state machine for Q-Register specifications: allow long Q-Reg namesRobin Haberkorn1-15/+78
syntax is as follows: ["."]("#" CHR1 CHR2 | "{" STRING_BUILDING "}" | CHR1) * the short one/two char names are turned upper case, while no case folding is performed on verbose names
2013-02-08fixed ring.current/QRegisters::current corruptionRobin Haberkorn1-0/+8
occurs when rubbing out a switch from q-reg string or to q-reg string
2013-02-08delegate commandline replacements ("}") to the cmdline macro levelRobin Haberkorn1-3/+3
allows commandline editing scripted by macros
2013-02-01fixed buffer Ring initializationRobin Haberkorn1-3/+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-23cleaned up QRegister state interface (can pass register by reference)Robin Haberkorn1-40/+40
2013-01-23moved StateExpectQReg from parser.h to qregisters.hRobin Haberkorn1-0/+28
* parser.cpp|h should be reserved for generic and misc. stuff. the StateExpectQReg class is used almost exclusively by qregisters.cpp|h * resolves a circular header dependency issue
2013-01-19updated copyright (2012-2013)Robin Haberkorn1-1/+1
2012-12-04added copyright notice to every source fileRobin Haberkorn1-0/+17
2012-12-04first working version of autotools based build-systemRobin Haberkorn1-0/+4