CLI  2.9
ui_line.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_UI_LINE_H_
33 #define _CLI_UI_LINE_H_
34 
35 #include "cli/ui.h"
36 
37 
39 
40  // Forward declarations.
41  class CmdLineEdition;
42 
43 
44  CLI_NS_BEGIN(ui)
45 
46 
47  class Line : public UI
48  {
49  public:
51  explicit Line(
52  const tk::String& TK_DefaultLine,
53  const int I_MinLineLength,
54  const int I_MaxLineLength
55  );
56 
58  explicit Line(
59  ExecutionContext& CLI_ParentContext,
60  const tk::String& TK_DefaultLine,
61  const int I_MinLineLength,
62  const int I_MaxLineLength
63  );
64 
66  virtual ~Line(void);
67 
68  private:
70  explicit Line(void);
72  Line(const Line&);
74  Line& operator=(const Line&);
75 
76  public:
79  const tk::String GetLine(void) const;
80 
81  protected:
83  void SetLine(
84  const tk::String& TK_Line,
85  const bool B_NewLine,
86  const bool B_CleanOnTyping
87  );
88  protected:
89  // cli::ui::UI interface implementation.
90  virtual void Reset(void);
91  virtual void ResetToDefault(void);
92  public:
93  // Inherit doxygen comments from cli::ExecutionContext interface documentation.
94  virtual void OnKey(const KEY E_KeyCode);
95 
96  private:
97  const tk::String m_tkDefaultLine;
98  const int m_iMinLineLength;
99  const int m_iMaxLineLength;
100  CmdLineEdition& m_cliLine;
101  bool m_bResetOnTyping;
102  };
103 
104  CLI_NS_END(ui)
105 
107 
108 #endif // _CLI_UI_LINE_H_
Main namespace of the CLI library.
Simple line user interface object.
Definition: ui_line.h:47
#define CLI_NS_END(__ns)
End a namespace definition.
Definition: namespace.h:45
const tk::String GetLine(void) const
Current command line.
Execution context.
Definition: exec_context.h:149
UI class definition.
CmdLineEdition & operator=(const CmdLineEdition &)
Assignment operator.
enum _KEY KEY
Input keys.
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
Definition: namespace.h:38
Command line edition objet.
Generic user interface class.
Definition: ui.h:60
void Reset(void)
Reset the object.