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

TTerminalUserInterface.hh

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

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