11 #include <RADCore/RADLicenseGate.h>
20 #include <string_view>
88 void consume(
unsigned char byte);
89 void consumeNormal(
unsigned char byte);
90 void consumeEscape(
unsigned char byte);
91 void consumeCsi(
unsigned char byte);
92 std::vector<int> csiParams(
int defaultValue = 0)
const;
93 bool csiPrivateMode()
const;
94 int csiParam(
size_t index,
int defaultValue = 0)
const;
96 void putChar(
char ch);
98 void carriageReturn();
100 void cursorUp(
size_t count);
101 void cursorDown(
size_t count);
102 void cursorForward(
size_t count);
103 void cursorBack(
size_t count);
104 void setCursor(
size_t row,
size_t column);
105 void eraseInDisplay(
int mode);
106 void eraseInLine(
int mode);
107 void setScrollRegion(
size_t top,
size_t bottom);
108 void resetScrollRegion();
109 void scrollRegionUp(
size_t top,
size_t bottom,
size_t count = 1);
110 void scrollRegionDown(
size_t top,
size_t bottom,
size_t count = 1);
111 void insertLines(
size_t count);
112 void deleteLines(
size_t count);
113 void insertChars(
size_t count);
114 void deleteChars(
size_t count);
115 void eraseChars(
size_t count);
116 void setPrivateMode(
int mode,
bool enabled);
117 void enterAlternateScreen();
118 void leaveAlternateScreen();
119 void ensureCursorLine();
122 mutable std::mutex mutex_;
124 std::vector<TerminalLine> savedLines_;
125 TerminalColor currentForeground_{230, 237, 242};
126 TerminalColor currentBackground_{16, 20, 24};
128 bool reverse_ =
false;
129 bool alternateScreen_ =
false;
130 bool cursorVisible_ =
true;
131 size_t cursorColumn_ = 0;
132 size_t cursorRow_ = 0;
133 size_t savedCursorColumn_ = 0;
134 size_t savedCursorRow_ = 0;
135 size_t screenRows_ = 30;
136 size_t screenColumns_ = 120;
137 size_t scrollTop_ = 0;
138 size_t scrollBottom_ = 29;
139 State state_ = State::Normal;
157 bool start(
const std::string& shell = {}, uint16_t rows = 30, uint16_t columns = 120);
163 bool resize(uint16_t rows, uint16_t columns);
179 std::atomic<bool> running_{
false};
182 std::function<void()> changed_;
183 std::unique_ptr<RADCore::RADPtyProcess> process_;
188 bool shift =
false,
bool meta =
false);
191 bool shift =
false,
bool meta =
false);
PTY-backed terminal session that feeds output into TerminalBuffer.
Definition: RADTerminal.h:144
bool start(const std::string &shell={}, uint16_t rows=30, uint16_t columns=120)
Starts shell in a PTY sized rows by columns.
bool isRunning() const
Returns true while the PTY session is active.
TerminalCursor cursor() const
Returns current terminal cursor state.
std::string plainText() const
Returns visible terminal text without color metadata.
PtyTerminalSession(std::function< void()> changed={})
Creates a terminal session and optional change callback.
void writeInput(std::string_view input)
Writes user input bytes to the PTY.
PtyTerminalSession & operator=(const PtyTerminalSession &)=delete
Terminal sessions own a PTY and are not copied.
void stop()
Stops the child process and reader thread.
PtyTerminalSession(const PtyTerminalSession &)=delete
Terminal sessions own a PTY and are not copied.
std::vector< TerminalLine > snapshot() const
Returns a copy of visible terminal lines.
bool resize(uint16_t rows, uint16_t columns)
Resizes the PTY and terminal buffer.
bool isAlternateScreen() const
Returns true when the terminal is using its alternate screen.
~PtyTerminalSession()
Stops the session and joins the reader thread.
ANSI/VT-style terminal screen buffer and parser.
Definition: RADTerminal.h:62
std::string plainText() const
Returns visible terminal text without color metadata.
TerminalCursor cursor() const
Returns current cursor state.
void setScreenSize(size_t rows, size_t columns)
Sets visible terminal dimensions.
void append(std::string_view bytes)
Appends raw terminal output bytes and updates screen state.
void clear()
Clears terminal contents and parser state.
bool isAlternateScreen() const
Returns true when the alternate screen buffer is active.
std::vector< TerminalLine > snapshot() const
Returns a copy of visible terminal lines.
Definition: RADAppKit.h:20
std::string terminalSpecialKeySequence(std::string_view key, bool alt=false, bool control=false, bool shift=false, bool meta=false)
Converts named special keys and modifiers to terminal escape sequences.
std::string terminalInputSequence(std::string_view text, bool alt=false, bool control=false, bool shift=false, bool meta=false)
Converts printable text and modifiers to bytes suitable for a terminal PTY.
RGB terminal color used for a rendered line.
Definition: RADTerminal.h:32
uint8_t g
Green component.
Definition: RADTerminal.h:36
uint8_t b
Blue component.
Definition: RADTerminal.h:38
uint8_t r
Red component.
Definition: RADTerminal.h:34
Terminal cursor location and visibility.
Definition: RADTerminal.h:52
bool visible
Whether the application requested a visible cursor.
Definition: RADTerminal.h:58
size_t row
Zero-based visible row.
Definition: RADTerminal.h:54
size_t column
Zero-based visible column.
Definition: RADTerminal.h:56
One logical terminal line with text and colors.
Definition: RADTerminal.h:42
TerminalColor foreground
Foreground color.
Definition: RADTerminal.h:46
TerminalColor background
Background color.
Definition: RADTerminal.h:48
std::string text
UTF-8/text bytes for the line.
Definition: RADTerminal.h:44