From 6ffb747421de2a97cdeeb29961f0f8f1062ab834 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sun, 29 Jul 2018 21:58:18 +0300 Subject: Add tab-completion for usernames fixes #394 --- src/TextInputWidget.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/TextInputWidget.h') 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(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() { -- cgit 1.5.1