CLI  2.9
command_line_edition.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2006-2018, Alexis Royer, http://alexis.royer.free.fr/CLI
3 
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation
10  and/or other materials provided with the distribution.
11  * Neither the name of the CLI library project nor the names of its contributors may be used to endorse or promote products derived from this software
12  without specific prior written permission.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 
31 
32 #ifndef _CLI_CMD_LINE_EDITION_H_
33 #define _CLI_CMD_LINE_EDITION_H_
34 
35 #include "cli/namespace.h"
36 #include "cli/object.h"
37 #include "cli/tk.h"
38 #include "cli/io_device.h"
39 
40 
42 
43  // Forward declarations.
44  class OutputDevice;
45 
46 
48  class CmdLineEdition : public Object
49  {
50  public:
55 
57  explicit CmdLineEdition(void);
58 
60  virtual ~CmdLineEdition(void);
61 
62  public:
66 
69  void Set(
70  const tk::String& TK_Left,
71  const tk::String& TK_Right
72  );
73 
76  void Reset(void);
77 
78  public:
81  void SetInsertMode(
82  const bool B_InsertMode
83  );
84 
87  const bool GetInsertMode(void) const;
88 
89  public:
91  void Put(
92  const OutputDevice& CLI_OutputDevice,
93  const KEY E_Char
94  );
95 
97  void Put(
98  const OutputDevice& CLI_OutputDevice,
99  const tk::String& TK_String
100  );
101 
102  private:
104  void Put(
105  const OutputDevice& CLI_OutputDevice,
106  const tk::Queue<KEY>& TK_Keys
107  );
108 
109  public:
111  void CleanAll(
112  const OutputDevice& CLI_OutputDevice
113  );
114 
118  void Delete(
119  const OutputDevice& CLI_OutputDevice,
120  const int I_Count
121  );
124 
125  public:
128  void PrintCmdLine(
129  const OutputDevice& CLI_OutputDevice
130  ) const;
131 
135  void MoveCursor(
136  const OutputDevice& CLI_OutputDevice,
137  const int I_Count
138  );
141 
143  void NextLine(
144  const OutputDevice& CLI_OutputDevice
145  );
146 
148  void Home(
149  const OutputDevice& CLI_OutputDevice
150  );
151 
153  void End(
154  const OutputDevice& CLI_OutputDevice
155  );
156 
157  public:
160  const tk::String GetLine(void) const;
161 
164  const tk::String GetRight(void) const;
165 
168  const tk::String GetLeft(void) const;
169 
173  const tk::String GetNextWord(void) const;
174 
178  const tk::String GetPrevWord(void) const;
179 
180  private:
182  tk::Queue<KEY> m_tkLeft;
183 
185  tk::Queue<KEY> m_tkRight;
186 
188  bool m_bInsertMode;
189  };
190 
192 
193 #endif // _CLI_CMD_LINE_EDITION_H_
Generic object.
Definition: object.h:42
void NextLine(const OutputDevice &CLI_OutputDevice)
Moves the cursor to the next line.
Main namespace of the CLI library.
const tk::String GetLeft(void) const
Left part of the command line accessor.
const bool GetInsertMode(void) const
Insert mode retrieval.
virtual ~CmdLineEdition(void)
Destructor.
#define CLI_NS_END(__ns)
End a namespace definition.
Definition: namespace.h:45
void Set(const tk::String &TK_Left, const tk::String &TK_Right)
Set the object.
void MoveCursor(const OutputDevice &CLI_OutputDevice, const int I_Count)
Moves the cursor.
const tk::String GetLine(void) const
Current command line.
Namespace management.
void CleanAll(const OutputDevice &CLI_OutputDevice)
Line deletion.
const tk::String GetRight(void) const
Right part of the command line accessor.
Generic output device.
Definition: io_device.h:256
CmdLineEdition & operator=(const CmdLineEdition &)
Assignment operator.
void SetInsertMode(const bool B_InsertMode)
Insert mode setting.
CmdLineEdition(void)
Default constructor.
enum _KEY KEY
Input keys.
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
Definition: namespace.h:38
OutputDevice, IODevice and IOEndl classes defintion.
CLI toolkit definition.
void Put(const OutputDevice &CLI_OutputDevice, const KEY E_Char)
Character addition.
Object class definition.
void Home(const OutputDevice &CLI_OutputDevice)
Moves the cursor at the beginning of the line.
void Delete(const OutputDevice &CLI_OutputDevice, const int I_Count)
Character deletion.
Command line edition objet.
void PrintCmdLine(const OutputDevice &CLI_OutputDevice) const
Command line display.
const tk::String GetNextWord(void) const
Next word retrieval.
const tk::String GetPrevWord(void) const
Previous word retrieval.
void End(const OutputDevice &CLI_OutputDevice)
Moves the cursor at the end of the line.
void Reset(void)
Reset the object.