Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

LineEditor.hh

Go to the documentation of this file.
00001 // $Id: LineEditor.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2009
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_Utils_Console_LineEditor_
00027 #define HH_SENF_Utils_Console_LineEditor_ 1
00028 
00029 // Custom includes
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 //#include "LineEditor.mpp"
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         // TelnetTerminal API implementation
00080         virtual void v_setupFailed();
00081         virtual void v_eof();
00082 
00083         // ClientReader API implementation
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         // Editor callbacks
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 //#include "LineEditor.cci"
00104 //#include "LineEditor.ct"
00105 //#include "LineEditor.cti"
00106 #endif
00107 
00108 
00109 // Local Variables:
00110 // mode: c++
00111 // fill-column: 100
00112 // comment-column: 40
00113 // c-file-style: "senf"
00114 // indent-tabs-mode: nil
00115 // ispell-local-dictionary: "american"
00116 // compile-command: "scons -u test"
00117 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research