From 84ab1698e63170a94cfa1c5d99b7316cf3c2b584 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 19 Nov 2016 23:59:52 +0100 Subject: auto-completion of Q-Register names, goto labels and help topics * 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. --- src/parser.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/parser.h') diff --git a/src/parser.h b/src/parser.h index b18e13c..f5dcba5 100644 --- a/src/parser.h +++ b/src/parser.h @@ -120,8 +120,6 @@ public: class QRegSpecMachine; class StringBuildingMachine : public MicroStateMachine { - QRegSpecMachine *qregspec_machine; - enum Mode { MODE_NORMAL, MODE_UPPER, @@ -131,9 +129,11 @@ class StringBuildingMachine : public MicroStateMachine { bool toctl; public: + QRegSpecMachine *qregspec_machine; + StringBuildingMachine() : MicroStateMachine(), - qregspec_machine(NULL), - mode(MODE_NORMAL), toctl(false) {} + mode(MODE_NORMAL), toctl(false), + qregspec_machine(NULL) {} ~StringBuildingMachine(); void reset(void); @@ -147,7 +147,6 @@ public: * string building commands and accumulation into a string */ class StateExpectString : public State { - StringBuildingMachine machine; gsize insert_len; gint nesting; @@ -156,6 +155,13 @@ class StateExpectString : public State { bool last; public: + /* + * FIXME: Only public as long as cmdline.cpp + * needs to access it. + * Can be avoided one process_edit_cmd() is in State. + */ + StringBuildingMachine machine; + StateExpectString(bool _building = true, bool _last = true) : insert_len(0), nesting(1), string_building(_building), last(_last) {} -- cgit v1.2.3