diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-09-25 03:15:26 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-09-25 03:15:26 +0200 |
commit | 661d16e98c62dfff40f481177bf3f1a0c58c2124 (patch) | |
tree | a415866c4c94a0a0c53045a47220ca413ae9c5c9 /src/gui/widgets/textfield.h | |
parent | 758d80263b1647c712c0e0cdd3dfca9945a1bb7e (diff) | |
parent | 7d0738df0d139af3175fcc1fec5b9be4a467f4f4 (diff) | |
download | mana-661d16e98c62dfff40f481177bf3f1a0c58c2124.tar.gz mana-661d16e98c62dfff40f481177bf3f1a0c58c2124.tar.bz2 mana-661d16e98c62dfff40f481177bf3f1a0c58c2124.tar.xz mana-661d16e98c62dfff40f481177bf3f1a0c58c2124.zip |
Merge branch '1.0'
Conflicts:
src/actorspritemanager.h
src/beingmanager.cpp
src/game.cpp
src/gui/beingpopup.cpp
src/gui/chat.cpp
src/gui/chat.h
src/gui/inventorywindow.h
src/gui/itempopup.cpp
src/gui/socialwindow.cpp
src/gui/statuswindow.cpp
src/gui/widgets/chattab.cpp
src/gui/widgets/chattab.h
src/net/tmwa/inventoryhandler.cpp
src/net/tmwa/partyhandler.cpp
src/party.cpp
src/sound.cpp
src/utils/stringutils.cpp
src/utils/stringutils.h
Diffstat (limited to 'src/gui/widgets/textfield.h')
-rw-r--r-- | src/gui/widgets/textfield.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 58e37f5c..1963f9fa 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -24,9 +24,48 @@ #include <guichan/widgets/textfield.hpp> +#include <vector> + class ImageRect; class TextField; +typedef std::list<std::string> TextHistoryList; +typedef TextHistoryList::iterator TextHistoryIterator; + +struct TextHistory { + TextHistoryList history; /**< Command history. */ + TextHistoryIterator current; /**< History iterator. */ + + TextHistory() + { current = history.end(); } + + bool empty() const + { return history.empty(); } + + bool atBegining() const + { return current == history.begin(); } + + bool atEnd() const + { return current == history.end(); } + + void toBegining() + { current = history.begin(); } + + void toEnd() + { current = history.end(); } + + void addEntry(const std::string &text) + { history.push_back(text); } + + bool matchesLastEntry(const std::string &text) + { return history.back() == text; } +}; + +class AutoCompleteLister { +public: + virtual void getAutoCompleteList(std::vector<std::string>&) const {} +}; + /** * A text field. * @@ -90,7 +129,33 @@ class TextField : public gcn::TextField */ int getValue() const; + /** + * Sets the TextField's source of autocomplete. Passing null will + * disable autocomplete. + */ + void setAutoComplete(AutoCompleteLister *lister) + { mAutoComplete = lister; } + + /** + * Returns the TextField's source of autocomplete. + */ + AutoCompleteLister *getAutoComplete() const + { return mAutoComplete; } + + /** + * Sets the TextField's source of input history. + */ + void setHistory(TextHistory *history) + { mHistory = history; } + + /** + * Returns the TextField's source of input history. + */ + TextHistory *getHistory() const + { return mHistory; } + private: + void autoComplete(); void handlePaste(); static int instances; @@ -100,6 +165,10 @@ class TextField : public gcn::TextField int mMinimum; int mMaximum; bool mLoseFocusOnTab; + + AutoCompleteLister *mAutoComplete; + + TextHistory *mHistory; /**< Text history. */ }; #endif |