diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-22 22:19:46 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-22 22:19:46 +0100 |
commit | 3e7ebb5d7b1e477df943cd01f469cf5d20f1509d (patch) | |
tree | 49693e93e1a1621aef29bb9d3de9bead3e21aa48 | |
parent | a6c13d77f2f5f504c7b99e66db5f7d52c1368b8a (diff) | |
download | sciteco-3e7ebb5d7b1e477df943cd01f469cf5d20f1509d.tar.gz |
added variant of the ^U command with string building: the EU command
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.
-rw-r--r-- | src/parser.cpp | 1 | ||||
-rw-r--r-- | src/qregisters.cpp | 36 | ||||
-rw-r--r-- | src/qregisters.h | 15 |
3 files changed, 45 insertions, 7 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 66b46c4..f9e6332 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1805,6 +1805,7 @@ StateECommand::StateECommand() : State() transitions['N'] = &States::glob; transitions['S'] = &States::scintilla_symbols; transitions['Q'] = &States::eqcommand; + transitions['U'] = &States::eucommand; transitions['W'] = &States::savefile; } diff --git a/src/qregisters.cpp b/src/qregisters.cpp index 846a5a4..d59686b 100644 --- a/src/qregisters.cpp +++ b/src/qregisters.cpp @@ -46,7 +46,9 @@ namespace States { StateEQCommand eqcommand; StateLoadQReg loadqreg; StateCtlUCommand ctlucommand; - StateSetQRegString setqregstring; + StateEUCommand eucommand; + StateSetQRegString setqregstring_nobuilding(false); + StateSetQRegString setqregstring_building(true); StateGetQRegString getqregstring; StateGetQRegInteger getqreginteger; StateSetQRegInteger setqreginteger; @@ -610,7 +612,7 @@ StateLoadQReg::done(const gchar *str) } /*$ - * [c1,c2,...]^Uq[string]$ -- Set or append to Q-Register string + * [c1,c2,...]^Uq[string]$ -- Set or append to Q-Register string without string building * [c1,c2,...]:^Uq[string]$ * * If not colon-modified, it first fills the Q-Register <q> @@ -627,14 +629,38 @@ StateLoadQReg::done(const gchar *str) * * If <q> is undefined, it will be defined. * - * String-building is by default \fBdisabled\fP for ^U commands. + * String-building characters are \fBdisabled\fP for ^U + * commands. + * Therefore they are especially well-suited for defining + * \*(ST macros, since string building characters in the + * desired Q-Register contents do not have to be escaped. + * The \fBEU\fP command may be used where string building + * is desired. */ State * StateCtlUCommand::got_register(QRegister ®) { - BEGIN_EXEC(&States::setqregstring); + BEGIN_EXEC(&States::setqregstring_nobuilding); register_argument = ® - return &States::setqregstring; + return &States::setqregstring_nobuilding; +} + +/*$ + * [c1,c2,...]EUq[string]$ -- Set or append to Q-Register string with string building characters + * [c1,c2,...]:EUq[string]$ + * + * This command sets or appends to the contents of + * Q-Register \fIq\fP. + * It is identical to the \fB^U\fP command, except + * that this form of the command has string building + * characters \fBenabled\fP. + */ +State * +StateEUCommand::got_register(QRegister ®) +{ + BEGIN_EXEC(&States::setqregstring_building); + register_argument = ® + return &States::setqregstring_building; } void diff --git a/src/qregisters.h b/src/qregisters.h index 9a7618b..80222f8 100644 --- a/src/qregisters.h +++ b/src/qregisters.h @@ -364,11 +364,20 @@ private: State *got_register(QRegister ®); }; +class StateEUCommand : public StateExpectQReg { +public: + StateEUCommand() : StateExpectQReg(true) {} + +private: + State *got_register(QRegister ®); +}; + class StateSetQRegString : public StateExpectString { bool text_added; public: - StateSetQRegString() : StateExpectString(false) {} + StateSetQRegString(bool building) + : StateExpectString(building) {} private: void initial(void); @@ -425,7 +434,9 @@ namespace States { extern StateEQCommand eqcommand; extern StateLoadQReg loadqreg; extern StateCtlUCommand ctlucommand; - extern StateSetQRegString setqregstring; + extern StateEUCommand eucommand; + extern StateSetQRegString setqregstring_nobuilding; + extern StateSetQRegString setqregstring_building; extern StateGetQRegString getqregstring; extern StateGetQRegInteger getqreginteger; extern StateSetQRegInteger setqreginteger; |