auto-complete.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 #include <set>
6 #include <string>
7 #include <vector>
8 #include <functional>
9 #include <stdint.h>
10 
11 #if defined(_WIN32)
12  #include <conio.h>
13  #define NEW_LINE '\r'
14  #define BACKSPACE '\b'
15  #define BACKSLASH_ZERO '\0'
16  #define UP_ARROW_KEY {72}
17  #define DOWN_ARROW_KEY {80}
18 #else
19  #include <unistd.h>
20  #include <termios.h>
21  #define NEW_LINE '\n'
22  #define BACKSPACE 127
23  #define BACKSLASH_ZERO ' '
24  #define UP_ARROW_KEY {27, 91, 65}
25  #define DOWN_ARROW_KEY {27, 91, 66}
26 #endif
27 
29 {
30 public:
31  explicit auto_complete(std::set<std::string> dictionary, bool bypass = false);
32  std::string get_line(std::function<bool()> to_stop = []() {return false;}); // to_stop predicate can be used to stop waiting for input if the camera disconnected
33 
34 private:
35  void handle_special_key(const std::vector<uint8_t>& chars);
36  char getch_nolock(std::function <bool()> stop = [](){return false;});
37  void backspace(const int num_of_backspaces);
40  std::vector<std::string> search(const std::string& word) const;
41 
42  std::set<std::string> _dictionary;
43  std::vector<std::string> _history_words;
45  std::vector<char> _chars2_queue;
47  unsigned _tab_index;
48  std::vector<std::string> _finds_vec;
50  bool _bypass;
51 };
auto_complete::chars2_queue_to_string
std::string chars2_queue_to_string() const
Definition: auto-complete.cpp:42
string
GLsizei const GLchar *const * string
Definition: glad/glad/glad.h:2861
auto_complete::_history_words_index
unsigned _history_words_index
Definition: auto-complete.h:44
auto_complete::get_line
std::string get_line(std::function< bool()> to_stop=[]() {return false;})
Definition: auto-complete.cpp:181
auto_complete::backspace
void backspace(const int num_of_backspaces)
Definition: auto-complete.cpp:60
auto_complete::_finds_vec
std::vector< std::string > _finds_vec
Definition: auto-complete.h:48
auto_complete::get_last_word
std::string get_last_word(const std::string &line) const
Definition: auto-complete.cpp:51
auto_complete::_dictionary
std::set< std::string > _dictionary
Definition: auto-complete.h:42
rs2::textual_icons::stop
static const textual_icon stop
Definition: device-model.h:193
auto_complete::_tab_index
unsigned _tab_index
Definition: auto-complete.h:47
auto_complete::_num_of_chars2_in_line
int _num_of_chars2_in_line
Definition: auto-complete.h:46
auto_complete::_bypass
bool _bypass
Definition: auto-complete.h:50
stdint.h
python-tutorial-1-depth.line
string line
Definition: python-tutorial-1-depth.py:38
auto_complete::search
std::vector< std::string > search(const std::string &word) const
Definition: auto-complete.cpp:12
auto_complete::_history_words
std::vector< std::string > _history_words
Definition: auto-complete.h:43
auto_complete::getch_nolock
char getch_nolock(std::function< bool()> stop=[](){return false;})
Definition: auto-complete.cpp:124
auto_complete
Definition: auto-complete.h:28
auto_complete::handle_special_key
void handle_special_key(const std::vector< uint8_t > &chars)
Definition: auto-complete.cpp:81
auto_complete::_is_first_time_up_arrow
bool _is_first_time_up_arrow
Definition: auto-complete.h:49
auto_complete::auto_complete
auto_complete(std::set< std::string > dictionary, bool bypass=false)
Definition: auto-complete.cpp:38
auto_complete::_chars2_queue
std::vector< char > _chars2_queue
Definition: auto-complete.h:45


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Mon Apr 22 2024 02:12:55