Age | Commit message (Collapse) | Author | Files | Lines |
|
* 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.
|
|
|
|
* a table reference was stored in the UndoToken.
* since there are only two tables at a given moment, this can
be avoided by having two different undo tokens, one for globals
and one for locals.
* Practically, undo tokens for locals are only created for the
top-level local Q-Reg table since macro calls with locals
with set must_undo to false since the local table is destroyed
with the macro return.
|
|
* on MSVCRT/MinGW, space allocated with alloca()/g_newa() was apparently
freed once the first exception was caught.
This prevented the proper destruction of local Q-Reg tables and
broke the Windows port.
* Since all alternatives to alloca() like VLAs are not practical,
the default Q-Register initialization has been moved out of the
QRegisterTable constructor into QRegisterTable::insert_defaults().
* The remaining QRegisterTable initialization and destruction is
very cheap, so we simply reserve an empty QRegisterTable for
local registers on every Execute::macro() call.
The default registers are only initialized when required, though.
* All of this has to change anyway once we replace the
C++ call-stack approach to macro calls with our own macro
call frame memory management.
|
|
* we can use root() instead of min() which is faster
|
|
implementation classes
* whenever the implementation class was not exactly RBEntryType,
it had to have a virtual destructor since RBTree cared about
cleanup and had to delete its members.
* Since it does not allocate them, it is consistent to remove RBTree::clear().
The destructor now only checks that subclasses have cleaned up.
Implementing cleanup in the subclasses is trivial.
* Consequently, RBEntryString no longer has to be virtual.
HelpIndex and GotoTables are completely non-virtual now
which saves memory (and a bit of cleanup speed).
For QRegister, not much changes, though.
|
|
* From what the documentation says, a dot may only be used
once to introduce a local Q-Register specification.
The parser was accepting arbitrarily many dots though.
* Now, ".." will refer to the local register ".".
|
|
* Using a common implementation in RBTreeString::auto_complete().
This is very efficient even for very huge tables since only
an O(log(n)) lookup is required and then all entries with a matching
prefix are iterated. Worst-case complexity is still O(n), since all
entries may be legitimate completions.
If necessary, the number of matching entries could be restricted, though.
* Auto completes short and long Q-Reg names.
Short names are "case-insensitive" (since they are upper-cased).
Long specs are terminated with a closing bracket.
* Long spec completions may have problems with names containing
funny characters since they may be misinterpreted as string building
characters or contain braces. All the auto-completions suffered from
this problem already (see TODO).
* This greatly simplifies investigating the Q-Register name spaces
interactively and e.g. calling macros with long names, inserting
environment registers etc.
* Goto labels are terminated with commas since they may be part
of a computed goto.
* Help topics are matched case insensitive (just like the topic
lookup itself) and are terminated with the escape character.
This greatly simplifies navigating womanpages and looking up
topics with long names.
|
|
* the old implementation tried to avoid template programming by
making the entry comparison function virtual.
* The new RBTree implementation takes a template argument with the
implementation of RBEntry. It is now partially conventional
that the template argument must be actually derived from RBTree::RBEntry
and must define a "compare" method.
* As an advantage we now get static polymorphism (avoiding virtual
calls and allowing for more compiler optimizations) and the
the RBEntry implementation no longer has to be virtual.
* The only RB-Trees actually used are string-keyed, though.
Therefore there's a common base class RBTreeString now which
defines two synonymous "key" and "name" attributes.
* The entry base class RBEntryString is virtual again because
we do not want to propagate the RBEntryType template parameter
even further and the RBTree base class needs to destroy
entries.
This might be avoided by not defining a RBTree::clear() method,
leaving this task to the implementations.
At least QRegisters have to be virtual, though.
* RBTreeString only depends on the strcmp() and strncmp() functions
used now and only case-sensitive and case-insensitive versions
are actually required, so we instantiate these templates statically
in rbtree.cpp.
This means there are still only two instantiations of the RBTree
in the binary.
* RBTreeString defines convenient wrappers for find() and nfind()
to look up by string.
This uses the RBEntryString base class, so no allocations whatsover
are required for lookups and less space is wasted on the call stack.
* A RBEntryOwnString base class is also provided which frees the
implementations from memory managing the tree keys.
* RBTreeString can now be used to add other common functionality
like auto-completions for Q-Registers, goto labels and help topics.
* some minor optimizations
* updated TODO
|
|
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.
|
|
* 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.
|
|
optimizationa and additional checks
* undo tokens emitted by the expression stack no longer waste
memory by pointing to the stack implementation.
This uses some ugly C++ constant template arguments but
saves 4 or 8 byte per undo token depending on the architecture.
* Round braces are counted now and the return command $$ will
use this information to discard all non-relevant brace levels.
* It is an error to close a brace when none have been opened.
* The bracing rules are still very liberal, allowing you to
close braces in macros belonging to a higher call frame
or leave them open at the end of a macro.
While this is technically possible, it is perhaps a good
idea to stricten these rules in some future release.
* Loops no longer (ab)use the expression stack to store
program counters and loop counters.
This removes flow control from the responsibility of the
expression stack which is much safer now since we can control
where we jump to.
This also eased implemented proper semantics for $$.
* It is an error to leave loops open at the end of a macro
or trying to close a loop opened in the caller of the macro.
Similarily it is only possible to close a loop from the
current invocation frame.
This means it is now impossible to accidentally jump to invalid
PCs.
* Even though loop context stacks could be attached directly to
the macro invocation frame, this would be inefficient.
Instead there's a loop frame pointer now that is part of the
invocation frame. All frames will reuse the same stack structure.
* Loops are automatically discarded when returning using $$.
* Special aggregating forms of the loop start (":<") and loop
end (":>") commands are possible now and have been implemented.
This improves SciTECO's capability as a stack-oriented language.
It is no longer necessary to write recursive macros to generate
stack values of arbitrary length dynamically or to process them.
* All expression and loop stacks are still fixed-size.
It may be a good idea to implement dynamic resizing (TODO).
* Added some G_UNLIKELYs to Execute::macro(). Should improve
the branch prediction of modern CPUs.
* Local Q-Register tables are allocated on the stack now instead
of on the heap (the bulk of a table is stored on the heap anyway).
Should improve performance of macro invocations.
* Document that "F<" will jump to the beginning of the macro
if there is no loop.
This is not in standard TECO, but I consider it a useful feature.
|
|
* test case: "@^Ua{eq.a$}Ma" and rubbing out until "}", reinserting it
* this means that probably a lot of rubout/reinsertion cases were
broken
|
|
* This is one of the most called functions (although a cheap one),
so having our own inline implementation speeds up things.
Benchmarks have shown that parsing is sped up by at least 4%.
|
|
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).
|
|
|
|
* the problem comes from StateExpectQReg resetting the QRegMachine
too early. StateExpectQReg(QREG_OPTIONAL) states cannot call
machine.fail() in their got_register() callback.
In other words, commands with both optional or required registers
depending on runtime state cannot be modelled with StateExpectQReg.
* instead we derive from State directly - most functionality is
encapsulated in QRegSpecMachine anyway.
* might also fix crashes on some systems.
|
|
* added a new OPTIONAL behaviour for QRegSpecMachines
* allows you to implement commands that have an optional Q-Register
argument that should not be initialized if undefined.
* Using QRegSpecMachine::fail() you may still check for existence of
the register conditionally to emulate the QREG_REQUIRED behaviour.
* Using :Q for checking for register existence makes sense, because
usually you will want to check for both existence and non-emptyness
as in :Qq">. So in this common case, you no longer have to
keep in mind that the register may also be undefined.
* This finally allows us to create arrays in the Q-Register
tables without keeping a separate entry for the number of elements.
E.g. an array.0 to array.N can be iterated like this:
0Ui <:Q[array.^E\i]:; ! work with element i ! %i>
|
|
* 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.
|
|
* relies on a patched version of Scinterm that allows you to
construct Scintilla objects, send messages etc. before Curses
is initialized.
The Scintilla and Scinterm submodules have been updated.
* This once and for all fixes batch mode and stdio redirections
in batch mode on all Curses platforms and operating systems.
* Fixes the ^C-does-not-interrupt bug on ncurses/UNIX.
See #4.
* On ncurses/UNIX we will still do a newterm()-initialization.
This allows us to keep stdout/stderr alone in case they are
redirected. This effectively allows redirecting SciTECO's
output into a file even in interactive mode.
ncurses/UNIX now behaves like, e.g. PDCurses/win32a and GTK+
in this regard.
* Curses environment variable handling fixed.
The environment registers are exported into the process environment
so that Curses environment variables can be set/modified by the
SciTECO profile.
* Use term.h for accessing terminfo now.
Explained set_window_title() limitations.
* fixed interruption via SIGINT. If the UI is waiting for user
input, SIGINT is effectively ignored instead of letting the
next character fail always.
* Updated sciteco(1) and sciteco(7): More options, environment variables
and signals documented. Also rewritten DESCRIPTION section
(different modes of operation).
|
|
* 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.
|
|
* 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
|
|
string formatting)
|
|
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)
|
|
* 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.
|
|
* 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
|
|
|
|
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()
|
|
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
|
|
* also did some whitespace cleanup in SciTECO now that tabs are
displayed properly
|
|
|
|
|
|
* EW can save Q-Registers now
* the new E% may be used to save a q-register without making it
the current document
|
|
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.
|
|
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... ! ]*
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
this eases handling of the "*" register
|
|
* 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
|
|
* 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)
|
|
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.
|
|
* the GError expection has been renamed to GlibError, to avoid
nameclashes when working from the SciTECO namespace
|
|
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).
|
|
the expression stack
now it's more like standard TECO's ^U command
|
|
* 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
|
|
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.
|
|
* 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)
|
|
|