From 02d414b3ab447e637fef776e387aa5a07293738a Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 2 Jun 2015 15:38:00 +0200 Subject: added command and special Q-Register "$" to set and get the current 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) --- src/qregisters.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/qregisters.h') diff --git a/src/qregisters.h b/src/qregisters.h index b2d856d..1ef0564 100644 --- a/src/qregisters.h +++ b/src/qregisters.h @@ -119,10 +119,16 @@ public: virtual gsize get_string_size(void); virtual gint get_character(gint position); + virtual void + exchange_string(QRegisterData ®) + { + string.exchange(reg.string); + } + virtual void undo_exchange_string(QRegisterData ®); + /* - * The QRegisterStack must currently access the - * integer and string fields directly to exchange - * data efficiently. + * The QRegisterStack must currently still access the + * string fields directly to exchange data efficiently. */ friend class QRegisterStack; }; @@ -183,6 +189,25 @@ public: void edit(void); }; +class QRegisterWorkingDir : public QRegister { +public: + QRegisterWorkingDir() : QRegister("$") {} + + void set_string(const gchar *str, gsize len); + void undo_set_string(void); + void append_string(const gchar *str, gsize len) {} + void undo_append_string(void) {} + + gchar *get_string(void); + gsize get_string_size(void); + gint get_character(gint pos); + + void edit(void); + + void exchange_string(QRegisterData ®); + void undo_exchange_string(QRegisterData ®); +}; + class QRegisterTable : private RBTree { class UndoTokenRemove : public UndoTokenWithSize { QRegisterTable *table; -- cgit v1.2.3