Class for text input history. More...
#include <text_box.hpp>
Public Member Functions | |
text_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 text_history | get_history (const std::string &id, const bool enabled) |
Gets history that matches id. More... | |
Private Member Functions | |
text_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 36 of file text_box.hpp.
|
inline |
Definition at line 49 of file text_box.hpp.
|
inlineprivate |
Definition at line 106 of file text_box.hpp.
std::string gui2::text_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 78 of file text_box.cpp.
References enabled_, get_value(), history_, pos_, and push().
Referenced by gui2::multiline_text::history_down(), and gui2::text_box::history_down().
|
inline |
Definition at line 100 of file text_box.hpp.
References enabled_.
Referenced by gui2::multiline_text::history_down(), gui2::text_box::history_down(), gui2::multiline_text::history_up(), and gui2::text_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 40 of file text_box.cpp.
References prefs::get(), and prefs::get_history().
Referenced by gui2::multiline_text::set_history(), and gui2::text_box::set_history().
std::string gui2::text_history::get_value | ( | ) | const |
void gui2::text_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 47 of file text_box.cpp.
References enabled_, history_, and pos_.
Referenced by down(), gui2::multiline_text::save_to_history(), gui2::text_box::save_to_history(), and up().
|
inline |
Definition at line 96 of file text_box.hpp.
References enabled_.
std::string gui2::text_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 60 of file text_box.cpp.
References curr, enabled_, get_value(), history_, pos_, and push().
Referenced by gui2::multiline_text::history_up(), and gui2::text_box::history_up().
|
private |
Is the history enabled.
Definition at line 118 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 112 of file text_box.hpp.
Referenced by down(), get_value(), push(), and up().
|
private |
The current position in the history.
Definition at line 115 of file text_box.hpp.
Referenced by down(), get_value(), push(), and up().