LineEditor.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_Console_LineEditor_
18 #define HH_SENF_Utils_Console_LineEditor_ 1
19 
20 // Custom includes
21 #include <boost/scoped_ptr.hpp>
24 #include "Server.hh"
25 
26 //#include "LineEditor.mpp"
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 
29 namespace senf {
30 namespace console {
31 namespace detail {
32 
43  : public ClientReader
44  {
45  public:
46  explicit LineEditorSwitcher(Client & client);
47 
48  void editorSetupFailed();
49 
50  private:
51  virtual void v_disablePrompt();
52  virtual void v_enablePrompt();
53  virtual void v_write(std::string const & data);
54  virtual unsigned v_width() const;
55 
56  boost::scoped_ptr<ClientReader> reader_;
57  };
58 
64  : public ClientReader, public term::TelnetTerminal
65  {
66  public:
67  explicit LineEditorClientReader(Client & client, LineEditorSwitcher & switcher);
68 
69  private:
70  // TelnetTerminal API implementation
71  virtual void v_setupFailed();
72  virtual void v_eof();
73 
74  // ClientReader API implementation
75  virtual void v_disablePrompt();
76  virtual void v_enablePrompt();
77  virtual void v_write(std::string const & data);
78  virtual unsigned v_width() const;
79 
80  // Editor callbacks
81  void executeLine(std::string const & text);
82  void deleteCharOrExit(term::LineEditor & editor);
83  void completePath(term::LineEditor & editor, unsigned & b, unsigned & e,
84  std::string & prefix, std::vector<std::string> & completions);
85 
86  term::LineEditor editor_;
87  LineEditorSwitcher * switcher_;
88  std::string default_;
89  };
90 
91 }}}
92 
93 //-/////////////////////////////////////////////////////////////////////////////////////////////////
94 //#include "LineEditor.cci"
95 //#include "LineEditor.ct"
96 //#include "LineEditor.cti"
97 #endif
98 
99 
100 // Local Variables:
101 // mode: c++
102 // fill-column: 100
103 // comment-column: 40
104 // c-file-style: "senf"
105 // indent-tabs-mode: nil
106 // ispell-local-dictionary: "american"
107 // compile-command: "scons -u test"
108 // End:
u8 data[SPECTRAL_HT20_NUM_BINS]
Server public header.
Definition: Config.hh:28
Server client instance.
Definition: Server.hh:143
Internal: ClientReader using senf::term::LineEditor for interactive input.
Definition: LineEditor.hh:63
Internal: Client reader switching between LineEditorClientReader or DumbClientReader.
Definition: LineEditor.hh:42