Class for text input history. More...
#include <text_box.hpp>
Public Member Functions | |
ttext_history () | |
void | push (const std::string &text) |
Push string into the history. More... | |
std::string | up (const std::string &text="") |
One step up in the history. More... | |
std::string | down (const std::string &text="") |
One step down in the history. More... | |
std::string | get_value () const |
Gets the current history value. More... | |
void | set_enabled (bool enabled=true) |
bool | get_enabled () const |
Static Public Member Functions | |
static ttext_history | get_history (const std::string &id, const bool enabled) |
Gets history that matches id. More... | |
Private Member Functions | |
ttext_history (std::vector< std::string > *history, const bool enabled) | |
Private Attributes | |
std::vector< std::string > * | history_ |
The items in the history. More... | |
unsigned | pos_ |
The current position in the history. More... | |
bool | enabled_ |
Is the history enabled. More... | |
Class for text input history.
The history of text items can be stored in the preferences. This class handles that. Every item needs an id by which the history is loaded and saved.
Definition at line 32 of file text_box.hpp.
|
inline |
Definition at line 45 of file text_box.hpp.
|
inlineprivate |
Definition at line 102 of file text_box.hpp.
std::string gui2::ttext_history::down | ( | const std::string & | text = "" | ) |
One step down in the history.
Pushes text to the history if at the end.
text | The text to push in the history. |
Definition at line 76 of file text_box.cpp.
References enabled_, get_value(), history_, pos_, and push().
Referenced by gui2::ttext_box::history_down().
|
inline |
Definition at line 96 of file text_box.hpp.
References enabled_.
Referenced by gui2::ttext_box::history_down(), and gui2::ttext_box::history_up().
|
static |
Gets history that matches id.
id | The id of the history to look for. |
enabled | The enabled state of the history. |
Definition at line 38 of file text_box.cpp.
References preferences::get_history().
Referenced by gui2::ttext_box::set_history().
std::string gui2::ttext_history::get_value | ( | ) | const |
void gui2::ttext_history::push | ( | const std::string & | text | ) |
Push string into the history.
If the string is empty or the same as the last item in the history this function is a nop.
text | The text to push in the history. |
Definition at line 45 of file text_box.cpp.
References enabled_, history_, and pos_.
Referenced by down(), gui2::ttext_box::save_to_history(), and up().
|
inline |
Definition at line 92 of file text_box.hpp.
References enabled_.
std::string gui2::ttext_history::up | ( | const std::string & | text = "" | ) |
One step up in the history.
Pushes text to the history if at the end.
text | The text to push in the history. |
Definition at line 58 of file text_box.cpp.
References curr, enabled_, get_value(), history_, pos_, and push().
Referenced by gui2::ttext_box::history_up().
|
private |
Is the history enabled.
Definition at line 114 of file text_box.hpp.
Referenced by down(), get_enabled(), get_value(), push(), set_enabled(), and up().
|
private |
The items in the history.
Definition at line 108 of file text_box.hpp.
Referenced by down(), get_value(), push(), and up().
|
private |
The current position in the history.
Definition at line 111 of file text_box.hpp.
Referenced by down(), get_value(), push(), and up().