メインページ   モジュール   クラス階層   アルファベット順一覧   構成   ファイル一覧   構成メンバ   ファイルメンバ   関連ページ  

TTerminalUserInterface.hh

解説を見る。
00001 // =====================================================================
00002 //  $Id: TTerminalUserInterface.hh,v 1.1.1.1 2003/06/27 02:56:42 goiwai Exp $
00003 //  $Name: CLDAQ-1-06-02 $
00004 // =====================================================================
00005 #ifndef __TTERMINALUSERINTERFACE_HH
00006 #define __TTERMINALUSERINTERFACE_HH
00007 
00008 #include "Tglobals.h"
00009 #include "TUserInterface.hh"
00010 
00011 class TTerminalUserInterface
00012   : public TUserInterface
00013 {
00014 
00015   private:
00016     Tint theCommandHistoryIndex;
00017     Tint theCursorPosition;
00018     Tstring thePrompt;
00019     Tstring theAcceptString;
00020     Tstring theStringBuffer;
00021     Tstring theCommandBuffer;
00022     struct termios theTerminal;
00023 
00024   public:
00025     TTerminalUserInterface( const Tstring& prompt = Tprompt, const Tstring& history = Tproject + ".last" );
00026     ~TTerminalUserInterface();
00027 
00028   public:
00029     Tbool AcceptCommand();
00030     const Tstring& GetInputCommand();
00031     Tvoid NotFoundCommand( const Tstring& commandname ) const;
00032 
00033   public:
00034     Tint GetCommandHistoryIndex() const;
00035     Tint GetCursorPosition() const;
00036     const Tstring& GetPrompt() const;
00037     const Tstring& GetAcceptString() const;
00038     const Tstring& GetStringBuffer() const;
00039     const Tstring& GetCommandBuffer() const;
00040     Tvoid SetCursorPosition( Tint position );
00041     Tvoid SetPrompt( const Tstring& prompt );
00042     Tvoid SetAcceptString( const Tstring& accept );
00043     Tvoid SetStringBuffer( const Tstring& buffer );
00044     Tvoid SetCommandBuffer( const Tstring& buffer );
00045     Tvoid SetCommandHistoryIndex( Tint index );
00046 
00047   protected:
00048     const Tstring& readLine();
00049     Tvoid initializeCommandLine();
00050     Tvoid insertCharacter( Tchar cc );
00051     Tvoid backspaceCharacter();
00052     Tvoid deleteCharacter();
00053     Tvoid clearLine();
00054     Tvoid clearScreen();
00055     Tvoid clearAfterCursor();
00056     Tvoid forwardCursor();
00057     Tvoid backwardCursor();
00058     Tvoid moveCursorTop();
00059     Tvoid moveCursorEnd();
00060     Tvoid nextCommand();
00061     Tvoid previousCommand();
00062     Tvoid completeCommand();
00063     Tvoid complete();
00064     Tvoid complete( const Tstring& input );
00065     Tvoid complete( const TstringList& inputs );
00066     Tvoid completeDirectory();
00067     Tvoid completeDirectory( const Tstring& input );
00068     Tvoid cutCharacter();
00069     Tvoid pasteCharacter();
00070     Tvoid suspendTerminal() const;
00071     Tvoid setTerminalInputMode();
00072     Tvoid resetTerminal();
00073     Tbool isCursorEnd() const;
00074     Tbool isCursorTop() const;
00075     TstringList divide( const Tstring& input ) const;
00076 
00077 };
00078 
00079 inline Tint TTerminalUserInterface::GetCommandHistoryIndex() const
00080 {
00081   return( theCommandHistoryIndex );
00082 }
00083 
00084 inline Tvoid TTerminalUserInterface::SetCommandHistoryIndex( Tint index )
00085 {
00086   theCommandHistoryIndex = index;
00087   return;
00088 }
00089 
00090 inline Tint TTerminalUserInterface::GetCursorPosition() const
00091 {
00092   return( theCursorPosition );
00093 }
00094 
00095 inline const Tstring& TTerminalUserInterface::GetPrompt() const
00096 {
00097   return( thePrompt );
00098 }
00099 
00100 inline const Tstring& TTerminalUserInterface::GetAcceptString() const
00101 {
00102   return( theAcceptString );
00103 }
00104 
00105 inline const Tstring& TTerminalUserInterface::GetStringBuffer() const
00106 {
00107   return( theStringBuffer );
00108 }
00109 
00110 inline const Tstring& TTerminalUserInterface::GetCommandBuffer() const
00111 {
00112   return( theCommandBuffer );
00113 }
00114 
00115 inline Tvoid TTerminalUserInterface::SetCursorPosition( Tint position )
00116 {
00117   theCursorPosition = position;
00118   return;
00119 }
00120 
00121 inline Tvoid TTerminalUserInterface::SetPrompt( const Tstring& prompt )
00122 {
00123   thePrompt = prompt;
00124   return;
00125 }
00126 
00127 inline Tvoid TTerminalUserInterface::SetAcceptString( const Tstring& accept )
00128 {
00129   theAcceptString = accept;
00130   return;
00131 }
00132 
00133 inline Tvoid TTerminalUserInterface::SetStringBuffer( const Tstring& buffer )
00134 {
00135   theStringBuffer = buffer;
00136   return;
00137 }
00138 
00139 inline Tvoid TTerminalUserInterface::SetCommandBuffer( const Tstring& buffer )
00140 {
00141   theCommandBuffer = buffer;
00142   return;
00143 }
00144 
00145 inline Tbool TTerminalUserInterface::isCursorEnd() const
00146 {
00147   return( ( theCursorPosition == (Tint)( theAcceptString.size() ) ) ? Ttrue : Tfalse );
00148 }
00149 
00150 inline Tbool TTerminalUserInterface::isCursorTop() const
00151 {
00152   return( ( theCursorPosition == 0 ) ? Ttrue : Tfalse );
00153 }
00154 
00155 #endif

CLDAQ - a Class Library for Data AcQuisition (Version 1.6.2)
Go IWAI <goiwai@users.sourceforge.jp>