16 for (
auto it = _dictionary.begin();
it != _dictionary.end(); ++
it)
18 it = find_if(
it, _dictionary.end(), [&](
string elemnt) ->
bool {
19 return (elemnt.compare(0, word.size(), word) == 0) ? true :
false;
22 if (
it != _dictionary.end())
24 if (
it->compare(word) == 0)
27 finds.push_back(
it->substr(word.size(),
it->size()));
39 : _dictionary(dictionary), _history_words_index(0), _num_of_chars2_in_line(0), _tab_index(0), _is_first_time_up_arrow(true), _bypass(bypass)
45 temp_chars2_queue.push_back(
'\0');
46 auto word =
string(temp_chars2_queue.data());
53 auto index = line.find_last_of(
' ');
54 if (
index > line.size())
57 return line.substr(
index + 1);
62 for (
auto i = 0;
i < num_of_backspaces; ++
i)
127 auto ch =
static_cast<char>(_getch_nolock());
130 vector<uint8_t> vec_ch = {
static_cast<uint8_t>(_getch_nolock())};
137 auto fd = fileno(stdin);
139 struct termios old_settings, new_settings;
140 tcgetattr(fd, &old_settings);
141 new_settings = old_settings;
142 new_settings.c_lflag &= (~ICANON & ~ECHO);
144 tcsetattr(fd, TCSANOW, &new_settings);
156 auto res = select(fd+1, &fds,
NULL,
NULL, &tv );
157 if((res > 0) && (FD_ISSET(fd, &fds)))
160 auto num_of_chars = read(fd, ch, 10 );
161 tcsetattr(fd, TCSAFLUSH, &old_settings );
162 if (num_of_chars == 1)
166 vector<uint8_t> vec_ch;
167 for (
auto i = 0;
i < num_of_chars; ++
i)
168 vec_ch.push_back(ch[
i]);
173 tcsetattr(fd, TCSAFLUSH, &old_settings );
186 std::getline(std::cin, res);
222 for (
auto c : vec_word)
260 else if (isprint(ch))
289 return std::string{};
std::vector< std::string > search(const std::string &word) const
std::string get_last_word(const std::string &line) const
GLsizei const GLchar *const * string
bool _is_first_time_up_arrow
auto_complete(std::set< std::string > dictionary, bool bypass=false)
static const textual_icon stop
std::vector< std::string > _history_words
void handle_special_key(const std::vector< uint8_t > &chars)
std::string get_line(std::function< bool()> to_stop=[]() {return false;})
std::vector< char > _chars2_queue
std::string chars2_queue_to_string() const
std::vector< std::string > _finds_vec
void backspace(const int num_of_backspaces)
unsigned _history_words_index
int _num_of_chars2_in_line
GLenum GLuint GLenum GLsizei length
char getch_nolock(std::function< bool()> stop=[](){return false;})