4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief LineEditor public header */
26 #ifndef HH_SENF_Utils_Console_LineEditor_
27 #define HH_SENF_Utils_Console_LineEditor_ 1
30 #include <boost/scoped_ptr.hpp>
31 #include <senf/Utils/Termlib/TelnetTerminal.hh>
32 #include <senf/Utils/Termlib/Editor.hh>
35 //#include "LineEditor.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
42 /** \brief Internal: Client reader switching between LineEditorClientReader or DumbClientReader
44 This ClientReader implementation will try to initialize a LineEditorClientReader. If the
45 setup fails, a DumbClientReader is initialized instead. LineEditor support may fail to be
48 \li The telnet client does not support necessary functionality
49 \li or the terminal type of the client is missing some functionality.
51 class LineEditorSwitcher
55 explicit LineEditorSwitcher(Client & client);
57 void editorSetupFailed();
60 virtual void v_disablePrompt();
61 virtual void v_enablePrompt();
62 virtual void v_write(std::string const & data);
63 virtual unsigned v_width() const;
65 boost::scoped_ptr<ClientReader> reader_;
68 /** \brief Internal: ClientReader using senf::term::LineEditor for interactive input
70 This ClientReader implementation uses a senf::term::LineEditor for interactive input.
72 class LineEditorClientReader
73 : public ClientReader, public term::TelnetTerminal
76 explicit LineEditorClientReader(Client & client, LineEditorSwitcher & switcher);
79 // TelnetTerminal API implementation
80 virtual void v_setupFailed();
83 // ClientReader API implementation
84 virtual void v_disablePrompt();
85 virtual void v_enablePrompt();
86 virtual void v_write(std::string const & data);
87 virtual unsigned v_width() const;
90 void executeLine(std::string const & text);
91 void deleteCharOrExit(term::LineEditor & editor);
92 void completePath(term::LineEditor & editor, unsigned & b, unsigned & e,
93 std::string & prefix, std::vector<std::string> & completions);
95 term::LineEditor editor_;
96 LineEditorSwitcher * switcher_;
102 ///////////////////////////////hh.e////////////////////////////////////////
103 //#include "LineEditor.cci"
104 //#include "LineEditor.ct"
105 //#include "LineEditor.cti"
112 // comment-column: 40
113 // c-file-style: "senf"
114 // indent-tabs-mode: nil
115 // ispell-local-dictionary: "american"
116 // compile-command: "scons -u test"