00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_Utils_Console_LineEditor_
00027 #define HH_SENF_Utils_Console_LineEditor_ 1
00028
00029
00030 #include <boost/scoped_ptr.hpp>
00031 #include <senf/Utils/Termlib/TelnetTerminal.hh>
00032 #include <senf/Utils/Termlib/Editor.hh>
00033 #include "Server.hh"
00034
00035
00036
00037
00038 namespace senf {
00039 namespace console {
00040 namespace detail {
00041
00051 class LineEditorSwitcher
00052 : public ClientReader
00053 {
00054 public:
00055 explicit LineEditorSwitcher(Client & client);
00056
00057 void editorSetupFailed();
00058
00059 private:
00060 virtual void v_disablePrompt();
00061 virtual void v_enablePrompt();
00062 virtual void v_write(std::string const & data);
00063 virtual unsigned v_width() const;
00064
00065 boost::scoped_ptr<ClientReader> reader_;
00066 };
00067
00072 class LineEditorClientReader
00073 : public ClientReader, public term::TelnetTerminal
00074 {
00075 public:
00076 explicit LineEditorClientReader(Client & client, LineEditorSwitcher & switcher);
00077
00078 private:
00079
00080 virtual void v_setupFailed();
00081 virtual void v_eof();
00082
00083
00084 virtual void v_disablePrompt();
00085 virtual void v_enablePrompt();
00086 virtual void v_write(std::string const & data);
00087 virtual unsigned v_width() const;
00088
00089
00090 void executeLine(std::string const & text);
00091 void deleteCharOrExit(term::LineEditor & editor);
00092 void completePath(term::LineEditor & editor, unsigned & b, unsigned & e,
00093 std::string & prefix, std::vector<std::string> & completions);
00094
00095 term::LineEditor editor_;
00096 LineEditorSwitcher * switcher_;
00097 std::string default_;
00098 };
00099
00100 }}}
00101
00102
00103
00104
00105
00106 #endif
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117