TTerminalUserInterface.hh Source File

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

# TTerminalUserInterface.hh

解説を見る。

    00001 // =====================================================================
    00021 // =====================================================================
    00022 #ifndef __TTERMINALUSERINTERFACE_HH
    00023 #define __TTERMINALUSERINTERFACE_HH
    00024
    00025 #include "Tglobals.h"
    00026 #include "TUserInterface.hh"
    00027
    00028
    00048 class TTerminalUserInterface
    00049   : public TUserInterface
    00050 {
    00051
    00052   private:
    00053     Tint theCommandHistoryIndex;
    00054     Tint theCursorPosition;
    00055     Tstring thePrompt;
    00056     Tstring theAcceptString;
    00057     Tstring theStringBuffer;
    00058     Tstring theCommandBuffer;
    00059     struct termios theTerminal;
    00060
    00061   public:
    00062     TTerminalUserInterface( const Tstring& prompt = Tprompt,
    00063                             const Tstring& history = Tproject + ".last" );
    00064     ~TTerminalUserInterface();
    00065
    00066   public:
    00067     Tbool AcceptCommand();
    00068     const Tstring& GetInputCommand();
    00069     Tvoid NotFoundCommand( const Tstring& commandname ) const;
    00070
    00071   public:
    00072     Tint GetCommandHistoryIndex() const;
    00073     Tint GetCursorPosition() const;
    00074     const Tstring& GetPrompt() const;
    00075     const Tstring& GetAcceptString() const;
    00076     const Tstring& GetStringBuffer() const;
    00077     const Tstring& GetCommandBuffer() const;
    00078     Tvoid SetCursorPosition( Tint position );
    00079     Tvoid SetPrompt( const Tstring& prompt );
    00080     Tvoid SetAcceptString( const Tstring& accept );
    00081     Tvoid SetStringBuffer( const Tstring& buffer );
    00082     Tvoid SetCommandBuffer( const Tstring& buffer );
    00083     Tvoid SetCommandHistoryIndex( Tint index );
    00084
    00085   protected:
    00086     const Tstring& readLine();
    00087     Tvoid initializeCommandLine();
    00088     Tvoid insertCharacter( Tchar cc );
    00089     Tvoid backspaceCharacter();
    00090     Tvoid deleteCharacter();
    00091     Tvoid clearLine();
    00092     Tvoid clearScreen();
    00093     Tvoid clearAfterCursor();
    00094     Tvoid forwardCursor();
    00095     Tvoid backwardCursor();
    00096     Tvoid moveCursorTop();
    00097     Tvoid moveCursorEnd();
    00098     Tvoid nextCommand();
    00099     Tvoid previousCommand();
    00100     Tvoid completeCommand();
    00101     Tvoid complete();
    00102     Tvoid complete( const Tstring& input );
    00103     Tvoid complete( const TstringList& inputs );
    00104     Tvoid completeDirectory();
    00105     Tvoid completeDirectory( const Tstring& input );
    00106     Tvoid cutCharacter();
    00107     Tvoid pasteCharacter();
    00108     Tvoid suspendTerminal() const;
    00109     Tvoid setTerminalInputMode();
    00110     Tvoid resetTerminal();
    00111     Tbool isCursorEnd() const;
    00112     Tbool isCursorTop() const;
    00113     TstringList divide( const Tstring& input ) const;
    00114
    00115 };
    00116
    00117 inline Tint TTerminalUserInterface::GetCommandHistoryIndex() const
    00118 {
    00119   return theCommandHistoryIndex;
    00120 }
    00121
    00122 inline Tvoid TTerminalUserInterface::SetCommandHistoryIndex( Tint index )
    00123 {
    00124   theCommandHistoryIndex = index;
    00125   return;
    00126 }
    00127
    00128 inline Tint TTerminalUserInterface::GetCursorPosition() const
    00129 {
    00130   return theCursorPosition;
    00131 }
    00132
    00133 inline const Tstring& TTerminalUserInterface::GetPrompt() const
    00134 {
    00135   return thePrompt;
    00136 }
    00137
    00138 inline const Tstring& TTerminalUserInterface::GetAcceptString() const
    00139 {
    00140   return theAcceptString;
    00141 }
    00142
    00143 inline const Tstring& TTerminalUserInterface::GetStringBuffer() const
    00144 {
    00145   return theStringBuffer;
    00146 }
    00147
    00148 inline const Tstring& TTerminalUserInterface::GetCommandBuffer() const
    00149 {
    00150   return theCommandBuffer;
    00151 }
    00152
    00153 inline Tvoid TTerminalUserInterface::SetCursorPosition( Tint position )
    00154 {
    00155   theCursorPosition = position;
    00156   return;
    00157 }
    00158
    00159 inline Tvoid TTerminalUserInterface::SetPrompt( const Tstring& prompt )
    00160 {
    00161   thePrompt = prompt;
    00162   return;
    00163 }
    00164
    00165 inline Tvoid TTerminalUserInterface::SetAcceptString( const Tstring& accept )
    00166 {
    00167   theAcceptString = accept;
    00168   return;
    00169 }
    00170
    00171 inline Tvoid TTerminalUserInterface::SetStringBuffer( const Tstring& buffer )
    00172 {
    00173   theStringBuffer = buffer;
    00174   return;
    00175 }
    00176
    00177 inline Tvoid TTerminalUserInterface::SetCommandBuffer( const Tstring& buffer )
    00178 {
    00179   theCommandBuffer = buffer;
    00180   return;
    00181 }
    00182
    00183 inline Tbool TTerminalUserInterface::isCursorEnd() const
    00184 {
    00185   return ( theCursorPosition == (Tint)( theAcceptString.size() ) ) ? Ttrue : Tfalse;
    00186 }
    00187
    00188 inline Tbool TTerminalUserInterface::isCursorTop() const
    00189 {
    00190   return ( theCursorPosition == 0 ) ? Ttrue : Tfalse;
    00191 }
    00192
    00193 #endif