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);
38  std::string chars2_queue_to_string() const;
39  std::string get_last_word(const std::string& line) const;
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 };
std::vector< std::string > search(const std::string &word) const
std::string get_last_word(const std::string &line) const
std::set< std::string > _dictionary
Definition: auto-complete.h:42
bool _is_first_time_up_arrow
Definition: auto-complete.h:49
auto_complete(std::set< std::string > dictionary, bool bypass=false)
static const textual_icon stop
Definition: model-views.h:226
std::vector< std::string > _history_words
Definition: auto-complete.h:43
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
Definition: auto-complete.h:45
std::string chars2_queue_to_string() const
std::vector< std::string > _finds_vec
Definition: auto-complete.h:48
void backspace(const int num_of_backspaces)
unsigned _history_words_index
Definition: auto-complete.h:44
int _num_of_chars2_in_line
Definition: auto-complete.h:46
unsigned _tab_index
Definition: auto-complete.h:47
char getch_nolock(std::function< bool()> stop=[](){return false;})


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:41:42