Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Utils / Console / LineEditor.hh
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief LineEditor public header */
25
26 #ifndef HH_SENF_Utils_Console_LineEditor_
27 #define HH_SENF_Utils_Console_LineEditor_ 1
28
29 // Custom includes
30 #include <boost/scoped_ptr.hpp>
31 #include <senf/Utils/Termlib/TelnetTerminal.hh>
32 #include <senf/Utils/Termlib/Editor.hh>
33 #include "Server.hh"
34
35 //#include "LineEditor.mpp"
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37
38 namespace senf {
39 namespace console {
40 namespace detail {
41
42     /** \brief Internal: Client reader switching between LineEditorClientReader or DumbClientReader
43
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
46         initialized if
47
48         \li The telnet client does not support necessary functionality
49         \li or the terminal type of the client is missing some functionality.
50      */
51     class LineEditorSwitcher
52         : public ClientReader
53     {
54     public:
55         explicit LineEditorSwitcher(Client & client);
56
57         void editorSetupFailed();
58
59     private:
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;
64
65         boost::scoped_ptr<ClientReader> reader_;
66     };
67
68     /** \brief Internal: ClientReader using senf::term::LineEditor for interactive input
69
70         This ClientReader implementation uses a senf::term::LineEditor for interactive input.
71      */
72     class LineEditorClientReader
73         : public ClientReader, public term::TelnetTerminal
74     {
75     public:
76         explicit LineEditorClientReader(Client & client, LineEditorSwitcher & switcher);
77
78     private:
79         // TelnetTerminal API implementation
80         virtual void v_setupFailed();
81         virtual void v_eof();
82
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;
88
89         // Editor callbacks
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);
94
95         term::LineEditor editor_;
96         LineEditorSwitcher * switcher_;
97         std::string default_;
98     };
99
100 }}}
101
102 //-/////////////////////////////////////////////////////////////////////////////////////////////////
103 //#include "LineEditor.cci"
104 //#include "LineEditor.ct"
105 //#include "LineEditor.cti"
106 #endif
107
108 \f
109 // Local Variables:
110 // mode: c++
111 // fill-column: 100
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"
117 // End: