CPGen
C++ project generator
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Input Class Reference

A single-line text input component. More...

#include <Input.hpp>

Inheritance diagram for Input:
Inheritance graph
[legend]
Collaboration diagram for Input:
Collaboration graph
[legend]

Public Member Functions

 Input (std::string label, std::function< void(std::string)> on_change)
 Construct an Input with a label and a change callback.
 
std::string render () const override
 Render the input box as a multi-line ANSI string.
 
bool handleInput (Defs::Key key) override
 Handle a key event.
 
- Public Member Functions inherited from Component
 Component ()=default
 
virtual ~Component ()=default
 Virtual destructor — components are always owned via base-class pointer.
 
 Component (const Component &)=delete
 Non-copyable (unique ownership).
 
Componentoperator= (const Component &)=delete
 Non-copyable (unique ownership).
 
 Component (Component &&)=delete
 Non-movable.
 
Componentoperator= (Component &&)=delete
 Non-movable.
 
virtual void setFocused (bool focused)
 Change the focus state of this component.
 
bool isFocused () const
 Return whether this component currently has keyboard focus.
 

Additional Inherited Members

- Protected Attributes inherited from Component
bool m_is_focused
 Current focus state, managed by setFocused.
 

Detailed Description

A single-line text input component.

Renders a fixed-width bordered box containing a label on the left and the current value on the right. When focused, the box is highlighted with a distinct colour. The component accepts printable character input, handles Defs::Special::Backspace for deletion, and fires on_change on every modification.

Rendering example (focused, value = "CPGen")

╭─── Project Name ────────────╮
│ CPGen │
╰─────────────────────────────╯

Constructor & Destructor Documentation

◆ Input()

Input::Input ( std::string  label,
std::function< void(std::string)>  on_change 
)

Construct an Input with a label and a change callback.

Parameters
labelDescriptive text shown in the top border of the widget.
on_changeCallback invoked with the current full value string after every character is added or removed.

Member Function Documentation

◆ handleInput()

bool Input::handleInput ( Defs::Key  key)
overridevirtual

Handle a key event.

  • Printable char → appended to the current value.
  • Defs::Special::Backspace → removes the last character.
  • All other keys → ignored (returns false).
Parameters
keyThe key to process.
Returns
true if the key was consumed, false otherwise.

Implements Component.

◆ render()

std::string Input::render ( ) const
overridevirtual

Render the input box as a multi-line ANSI string.

Returns
Three-line string (top border, content, bottom border).

Implements Component.

Here is the call graph for this function:

The documentation for this class was generated from the following files: