Consolix
Loading...
Searching...
No Matches
consolix::TitleComponent Class Reference

Handles setting and retrieving the console window title. More...

#include <TitleComponent.hpp>

Inheritance diagram for consolix::TitleComponent:
consolix::IAppComponent

Public Member Functions

 TitleComponent (const std::string &title=std::string())
 Constructs the component and optionally sets the console title.
 
virtual ~TitleComponent () override=default
 Virtual destructor.
 
void set_title (const std::string &title)
 Sets the console window title.
 
std::string get_title () const
 Gets the last set console title.
 
bool initialize () override
 Initializes the component (no-op).
 
bool is_initialized () const override
 Checks if the component is initialized.
 
void process () override
 Executes the component (no-op).
 
- Public Member Functions inherited from consolix::IAppComponent
virtual ~IAppComponent ()=default
 Virtual destructor for polymorphic usage.
 

Static Public Member Functions

static std::string get_executable_name ()
 Retrieves the executable name.
 

Private Attributes

std::string m_title
 Stores the last set title.
 

Detailed Description

Handles setting and retrieving the console window title.

This component provides a platform-independent way to change the console title.

  • On Windows, it uses SetConsoleTitleW().
  • On Linux/macOS, it prints an ANSI escape sequence \033]0;TITLE\007.
  • The title is also stored internally and can be retrieved later.

Definition at line 20 of file TitleComponent.hpp.

Constructor & Destructor Documentation

◆ TitleComponent()

consolix::TitleComponent::TitleComponent ( const std::string & title = std::string())
inlineexplicit

Constructs the component and optionally sets the console title.

Parameters
titleThe title to set for the console window.

Definition at line 24 of file TitleComponent.hpp.

◆ ~TitleComponent()

virtual consolix::TitleComponent::~TitleComponent ( )
overridevirtualdefault

Virtual destructor.

Member Function Documentation

◆ get_executable_name()

static std::string consolix::TitleComponent::get_executable_name ( )
inlinestatic

Retrieves the executable name.

Returns
The executable filename (without path).

Definition at line 53 of file TitleComponent.hpp.

◆ get_title()

std::string consolix::TitleComponent::get_title ( ) const
inline

Gets the last set console title.

Returns
The current console title.

Definition at line 47 of file TitleComponent.hpp.

◆ initialize()

bool consolix::TitleComponent::initialize ( )
inlineoverridevirtual

Initializes the component (no-op).

Implements consolix::IAppComponent.

Definition at line 58 of file TitleComponent.hpp.

◆ is_initialized()

bool consolix::TitleComponent::is_initialized ( ) const
inlineoverridevirtual

Checks if the component is initialized.

Implements consolix::IAppComponent.

Definition at line 63 of file TitleComponent.hpp.

◆ process()

void consolix::TitleComponent::process ( )
inlineoverridevirtual

Executes the component (no-op).

Implements consolix::IAppComponent.

Definition at line 68 of file TitleComponent.hpp.

◆ set_title()

void consolix::TitleComponent::set_title ( const std::string & title)
inline

Sets the console window title.

Parameters
titleThe new console title.

Definition at line 35 of file TitleComponent.hpp.

Member Data Documentation

◆ m_title

std::string consolix::TitleComponent::m_title
private

Stores the last set title.

Definition at line 71 of file TitleComponent.hpp.


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