summary refs log tree commit diff
path: root/src/TextInputWidget.h
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-29 21:58:18 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-29 21:58:18 +0300
commit6ffb747421de2a97cdeeb29961f0f8f1062ab834 (patch)
tree28b3de0a13807f7804e4fba23e547bd9cbf15ec9 /src/TextInputWidget.h
parentv0.5.2 (diff)
downloadnheko-6ffb747421de2a97cdeeb29961f0f8f1062ab834.tar.xz
Add tab-completion for usernames
fixes #394
Diffstat (limited to 'src/TextInputWidget.h')
-rw-r--r--src/TextInputWidget.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/TextInputWidget.h b/src/TextInputWidget.h
index e7d5f948..37d73fbb 100644
--- a/src/TextInputWidget.h
+++ b/src/TextInputWidget.h
@@ -94,8 +94,23 @@ private:
 
         SuggestionsPopup popup_;
 
+        enum class AnchorType
+        {
+                Tab   = 0,
+                Sigil = 1,
+        };
+
+        AnchorType anchorType_ = AnchorType::Sigil;
+
+        int anchorWidth(AnchorType anchor) { return static_cast<int>(anchor); }
+
         void closeSuggestions() { popup_.hide(); }
         void resetAnchor() { atTriggerPosition_ = -1; }
+        bool isAnchorValid() { return atTriggerPosition_ != -1; }
+        bool hasAnchor(int pos, AnchorType anchor)
+        {
+                return pos == atTriggerPosition_ + anchorWidth(anchor);
+        }
 
         QString query()
         {