aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cmdline.cpp
AgeCommit message (Collapse)AuthorFilesLines
2015-03-17always enable ^G modifier after tab completion in ^G mode.Robin Haberkorn1-0/+3
If there was a rubbed out command line and you tab completed a file name in a string argument (TAB in ^G mode), the immediate editing modifier was automatically reset. This still happens if nothing could be tab completed and you type a few characters and try to complete again (since ^G mode will be reset). If this feature is used often, the user should perhaps define a function key as ^G^I^G.
2015-03-16implemented function key masking (context-sensitive function key macros)Robin Haberkorn1-4/+26
* fnkeys.tes has been updated to enable the command line editing macros (cursor keys, etc.) only in the "start" state. This avoids the annoying effect of inserting the macros into string arguments where they have no effect and must be rubbed out again.
2015-03-16implemented automatic EOL translation supportRobin Haberkorn1-14/+9
* 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-10simplified and optimized filename_complete()Robin Haberkorn1-54/+31
* dirname and basename calculations can be done easier with the new file_get_dirname_len() * platform-dependant derive_dir_separator() function has been removed
2015-03-07fixed TAB completion of files in the current directory beginning with "."Robin Haberkorn1-9/+14
We used g_path_get_dirname() which does not always return strict prefixes of the input file name. For file names without directory, it returns "." (the current directory). This is useful for passing that directory to functions expecting a proper directory (like g_dir_open()) but was unsuitable for building file name candidates for autocompletion. Therefore, we tried to determine if the dirname is a prefix of the filename. This however failed for "hidden" file names beginning with dot. All in all it is easier to calculate our own directory name based on the previously calculated basename than to handle the current-directory case with g_path_get_dirname(). Now we'll get "" for the current directory, so we have to handle the empty-string-is-current-dir case.
2015-03-07Curses UI: fixed translation of the backspace keyRobin Haberkorn1-1/+1
* for historic reasons, the backspace key can be transmitted as ^H by the terminal. Some terminal emulators might do that - these are fixed by this commit. * Use CTL_KEY('H') instead of standard C '\b' as the former is less ambiguous given the confusion around the backspace character.
2015-03-07cleaned up usage of the escape control character: introduced CTL_KEY_ESC and ↵Robin Haberkorn1-3/+3
CTL_KEY_ESC_STR * the reason for the CTL_KEY() macro is to get the control character resulting from a CTRL+Key press -- at least this is how SciTECO presents these key presses. It is also a macro and may be resolved to a constant expression, so it can be used in switch-case statements. Sometimes it is clearer to use standard C escape sequences (like '\t'). * CTL_KEY('[') for escape is hard to read, so I always used '\x1B' which is even more cryptic.
2015-03-07fixed 0EB command to display all buffers in the ringRobin Haberkorn1-22/+23
* the popup resetting was done after character insertion, so typing 0EB would clear the popup immediately * the new implementation is functionally equivalent to the old pre-reinsertion-commandline-handling, by resetting the popup based on the immediate editing command before insertion
2015-03-02fixed re-insertion of incomplete commandsRobin Haberkorn1-1/+3
we are not guaranteed to reach the start parser state again if the command is not terminated on the rubbed out command line
2015-03-02avoid warning about uninitialized variableRobin Haberkorn1-1/+1
2015-03-02fixed function key handling on GTK UIRobin Haberkorn1-1/+3
* we cannot prevent GTK from delivering the function key presses, as we can on Curses. Therefore Cmdline::fnmacro() checks again if function keys are enabled.
2015-03-02try hard to free heap memory after command-line termination using malloc_trim()Robin Haberkorn1-2/+13
* this is a Linux/glibc-only optimization
2015-03-02introduced the ^G immediate editing command for toggling the undo/redo mode ↵Robin Haberkorn1-85/+158
(also replaces ^T) * CTRL+G toggles the behaviour of the rubout (Backspace, ^W, ^U) commands: When the so called immediate editing command modifier is enabled/active, the rubout commands will do the opposite and insert from the rubbed out command line. This command is somewhat similar to Emacs' C-g command. * The CTRL+G command also replaces the ^T immediate editing command for auto-completing filenames in any string argument. Now the TAB key can be used for that purpose after activating the ^G modifier. ^T is a classic TECO command that will be supported sooner or later by SciTECO, so it's good to have it available directly.
2015-03-01keep rubbed out command line for later re-insertion and massive Cmdline ↵Robin Haberkorn1-164/+185
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-11updated copyright to 2015Robin Haberkorn1-1/+1
2015-02-11implemented support for different indention stylesRobin Haberkorn1-1/+11
* the ^I command was altered to insert indention characters rather than plain tabs always. * The <TAB> immediate editing command was added for all insertion arguments (I, ^I but also FR and FS) * documentation was extended for a discussion of indention
2014-12-09support filename auto completions with forward-slash directory separators on ↵Robin Haberkorn1-4/+52
Windows * this is actually UNTESTED on Windows
2014-12-09Curses: support cycling through long lists of possible auto-completions and ↵Robin Haberkorn1-21/+59
optimized screen refreshing/redrawing * pressing e.g. TAB when the popup is showing a list of auto-completions will show the next page, eventually beginning at the first one again. * do not redraw curses windows in the UI methods directly. this resulted in flickering during command-line editing macros and ordinary macro calls because the physical screen was updated immediately. Instead, window refreshing and updated is done centrally in event_loop_iter() only after a key has been processed. Also we use wnoutrefresh() and doupdate() to send as little to the terminal (emulator) as possible.
2014-12-08do not show possible completions for hidden files and directoriesRobin Haberkorn1-10/+19
* added platform-dependant file_is_visible() function
2014-11-24turn off Scintilla undo collection by default and fixed memleakRobin Haberkorn1-1/+3
* 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-22added globbing command ENRobin Haberkorn1-0/+1
* 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-5/+3
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-16rewritten View and Interface base classes using the Curiously Recurring ↵Robin Haberkorn1-5/+5
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-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-09TAB-completion for EC commandRobin Haberkorn1-2/+13
behaves just like ^T in string arguments. later we might add special Bash-completion support
2014-11-09implemented EC command (execute operating system command) in spawn.cppRobin Haberkorn1-0/+1
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.
2014-02-16rewritten command-line completion without Glib's g_complete_ functionsRobin Haberkorn1-40/+60
* they have been marked deprecated in recent libglib versions (since v2.26) * there is no alternative in recent libglib versions, so we simply do it with a little string handling. this works with older and newer libglib versions.
2014-02-15updated Copyright to year 2014Robin Haberkorn1-1/+1
2014-02-15removed most exception specifications: allow bad_allocs to propagateRobin Haberkorn1-1/+1
* 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-1/+4
* 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-18make sure a (void*)0 is used as sentinelsRobin Haberkorn1-2/+2
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-16common parent state for all file-name-expecting commands: fixes EM ↵Robin Haberkorn1-3/+1
tab-completions * StateExpectFile adds no functionality (currently), but is useful for checking state types
2013-03-16documented remaining commandsRobin Haberkorn1-0/+7
* 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-22resolved enter-key handling by introducing get_eol()Robin Haberkorn1-0/+14
2013-02-22Windows (MinGW) compatibility fixes: suspending impossible and environment ↵Robin Haberkorn1-1/+3
initialization revised * g_get_environ() appears to be broken, at least in Wine and Win2k
2013-02-16fixed commandline replacementsRobin Haberkorn1-15/+16
ensure that undo tokens for first differing characters are actually associated with this character instead of the next. (resulted in strange behaviour on rubout and subsequent replacements)
2013-02-16function key support (keys without printable representation) using keyboard ↵Robin Haberkorn1-0/+17
macros * if enabled, when a function key is pressed it is looked up in Q-Registers ^F... e.g. HOME key corresponds to register ^FHOME * the string if available is inserted as if it was entered by key-presses (later it may be entered as a single input token which may be removed in a single rubout) * only NCurses currently, key names directly correspond to Curses key names * on Curses if function keys are enabled ESCAPE will be inserted after a delay (because function keys are transmitted via escape sequences). A function key macro may be used to define an alternative escape character
2013-02-11properly support <CTL/Z> suspension as immediate commandRobin Haberkorn1-0/+12
see comment: special handling of <CTL/Z> in terminal might be disabled, or commandline input might be in X11 window...
2013-02-11<CTL/U> immediate editing command to rubout current string paramRobin Haberkorn1-0/+9
when not in string-state, <CTL/U> is self inserting (unlike traditional TECO where it would clear your entire commandline)
2013-02-11fixup: word-rubout may rub out nothingRobin Haberkorn1-4/+3
2013-02-11States::is_string() to check whether current state is a string-stateRobin Haberkorn1-7/+8
2013-02-11support <CTRL/W> immediate editing command: depending on context, rub out ↵Robin Haberkorn1-0/+24
words or entire commands * when rubbing out words (in string params), use Scintilla's definition of a word
2013-02-11support <CNTRL/T> immediate editing command only in string parametersRobin Haberkorn1-31/+32
* fixes autocompletion at the beginning of string params * is also available in filename commands and would allow filename completion after string beginning * also did some editing command cleanup
2013-02-08reverse Execute::step() change: no need to pass parameters by referenceRobin Haberkorn1-1/+1
cmdline and cmdline_pos is no longer modified by code executed by step() instead it is modified at the outermost macro level (commandline macro level)
2013-02-08delegate commandline replacements ("}") to the cmdline macro levelRobin Haberkorn1-11/+34
allows commandline editing scripted by macros
2013-02-03first draft of commandline-editing commands ({ and } as in VideoTECO)Robin Haberkorn1-22/+11
* simplified traditional commandline editing. no need to extend cmdline string one character at a time when inserting multiple. instead there's a marker (cmdline_pos) specifying the macro length to execute in a "step" and also the anchor for generating undo tokens * implementation does not yet work in macro calls * while editing the commandline, other buffers/registers may not be edited (need push-down-list and auxiliary q-register)
2013-01-27fixed scintilla symbol autocompletionRobin Haberkorn1-3/+3
do not accidentally overwrite the Scintilla (SCI_...) message symbol set
2013-01-23cleaned up QRegister state interface (can pass register by reference)Robin Haberkorn1-3/+3