A shell process and the screen it is drawing.
More...
#include <TerminalSession.hpp>
|
| | TerminalSession (std::string shell={}, std::string cwd={}) |
| | Prepare a session, without starting anything.
|
| |
| | ~TerminalSession () |
| |
| | TerminalSession (const TerminalSession &)=delete |
| |
| TerminalSession & | operator= (const TerminalSession &)=delete |
| |
| bool | start (int rows, int cols, std::string &error) |
| | Start the shell.
|
| |
| void | stop () |
| | End the shell, if it is still running.
|
| |
| bool | running () const |
| | Whether a shell is running on this session.
|
| |
| void | pump () |
| | Move what the shell has written into the screen.
|
| |
| void | sendText (const std::string &utf8) |
| | Send text, as if it had been typed.
|
| |
| void | sendKey (VTermKey key, VTermModifier mod) |
| | Send a key, letting the emulator encode it.
|
| |
| void | sendChar (uint32_t codepoint, VTermModifier mod) |
| | Send a character with modifiers held.
|
| |
| void | resize (int rows, int cols) |
| | Tell the shell and the emulator about a new size.
|
| |
| int | rows () const |
| |
| int | cols () const |
| |
| VTermPos | cursor () const |
| | The cursor, in viewport coordinates.
|
| |
| bool | cursorVisible () const |
| | Whether the cursor is to be drawn.
|
| |
| const std::vector< CellLine > & | viewport () const |
| | The lines to draw, top first.
|
| |
| int | scrollbackSize () const |
| | How many lines the shell has scrolled off the top.
|
| |
| int | scrollOffset () const |
| | How far the viewport is scrolled back, 0 being the live bottom.
|
| |
| void | scrollBy (int delta) |
| | Scroll the viewport.
|
| |
| std::string | selectionText (const Selection &selection) const |
| | The text a selection covers, in the direction it was made.
|
| |
| bool | exited () const |
| | Whether the shell has exited.
|
| |
| int | exitStatus () const |
| | The shell's exit status, once it has exited.
|
| |
| bool | consumeBell () |
| | Whether the shell rang the bell, clearing the flag.
|
| |
| const std::string & | title () const |
| | The title the shell set, empty when it has not set one.
|
| |
|
| static void | onOutput (const char *bytes, size_t len, void *user) |
| | The emulator hands the bytes a key produced to the pty.
|
| |
| static int | onScrollbackPush (int cols, const VTermScreenCell *cells, void *user) |
| | The emulator reports a line that has scrolled off the top.
|
| |
| static int | onBell (void *user) |
| |
| static int | onSetTermProp (VTermProp prop, VTermValue *value, void *user) |
| |
| static int | onMoveCursor (VTermPos pos, VTermPos oldpos, int visible, void *user) |
| |
|
| static const VTermScreenCallbacks | kCallbacks |
| | The callbacks the emulator is given, in the order it declares them.
|
| |
A shell process and the screen it is drawing.
◆ TerminalSession() [1/2]
| undoApp::Terminal::TerminalSession::TerminalSession |
( |
std::string |
shell = {}, |
|
|
std::string |
cwd = {} |
|
) |
| |
|
explicit |
Prepare a session, without starting anything.
- Parameters
-
| shell | Program to run, or empty for $SHELL |
| cwd | Directory to start in, or empty for the current one |
◆ ~TerminalSession()
| undoApp::Terminal::TerminalSession::~TerminalSession |
( |
| ) |
|
◆ TerminalSession() [2/2]
| undoApp::Terminal::TerminalSession::TerminalSession |
( |
const TerminalSession & |
| ) |
|
|
delete |
◆ cols()
| int undoApp::Terminal::TerminalSession::cols |
( |
| ) |
const |
|
inline |
◆ consumeBell()
| bool undoApp::Terminal::TerminalSession::consumeBell |
( |
| ) |
|
Whether the shell rang the bell, clearing the flag.
◆ cursor()
| VTermPos undoApp::Terminal::TerminalSession::cursor |
( |
| ) |
const |
|
inline |
The cursor, in viewport coordinates.
◆ cursorVisible()
| bool undoApp::Terminal::TerminalSession::cursorVisible |
( |
| ) |
const |
|
inline |
Whether the cursor is to be drawn.
◆ exited()
| bool undoApp::Terminal::TerminalSession::exited |
( |
| ) |
const |
|
inline |
Whether the shell has exited.
◆ exitStatus()
| int undoApp::Terminal::TerminalSession::exitStatus |
( |
| ) |
const |
|
inline |
The shell's exit status, once it has exited.
◆ onBell()
| static int undoApp::Terminal::TerminalSession::onBell |
( |
void * |
user | ) |
|
|
staticprivate |
◆ onMoveCursor()
| static int undoApp::Terminal::TerminalSession::onMoveCursor |
( |
VTermPos |
pos, |
|
|
VTermPos |
oldpos, |
|
|
int |
visible, |
|
|
void * |
user |
|
) |
| |
|
staticprivate |
◆ onOutput()
| static void undoApp::Terminal::TerminalSession::onOutput |
( |
const char * |
bytes, |
|
|
size_t |
len, |
|
|
void * |
user |
|
) |
| |
|
staticprivate |
The emulator hands the bytes a key produced to the pty.
◆ onScrollbackPush()
| static int undoApp::Terminal::TerminalSession::onScrollbackPush |
( |
int |
cols, |
|
|
const VTermScreenCell * |
cells, |
|
|
void * |
user |
|
) |
| |
|
staticprivate |
The emulator reports a line that has scrolled off the top.
◆ onSetTermProp()
| static int undoApp::Terminal::TerminalSession::onSetTermProp |
( |
VTermProp |
prop, |
|
|
VTermValue * |
value, |
|
|
void * |
user |
|
) |
| |
|
staticprivate |
◆ operator=()
◆ pump()
| void undoApp::Terminal::TerminalSession::pump |
( |
| ) |
|
Move what the shell has written into the screen.
Reads what is pending on the pty, feeds it to the emulator and collects the lines that scrolled off. Call this once per frame.
◆ reap()
| void undoApp::Terminal::TerminalSession::reap |
( |
| ) |
|
|
private |
◆ rebuildViewport()
| void undoApp::Terminal::TerminalSession::rebuildViewport |
( |
| ) |
|
|
private |
◆ resize()
| void undoApp::Terminal::TerminalSession::resize |
( |
int |
rows, |
|
|
int |
cols |
|
) |
| |
Tell the shell and the emulator about a new size.
- Parameters
-
| rows | New height in rows |
| cols | New width in columns |
◆ rows()
| int undoApp::Terminal::TerminalSession::rows |
( |
| ) |
const |
|
inline |
◆ running()
| bool undoApp::Terminal::TerminalSession::running |
( |
| ) |
const |
|
inline |
Whether a shell is running on this session.
◆ scrollbackSize()
| int undoApp::Terminal::TerminalSession::scrollbackSize |
( |
| ) |
const |
|
inline |
How many lines the shell has scrolled off the top.
◆ scrollBy()
| void undoApp::Terminal::TerminalSession::scrollBy |
( |
int |
delta | ) |
|
Scroll the viewport.
- Parameters
-
| delta | Lines to move, positive to look further back |
◆ scrollOffset()
| int undoApp::Terminal::TerminalSession::scrollOffset |
( |
| ) |
const |
|
inline |
How far the viewport is scrolled back, 0 being the live bottom.
◆ selectionText()
| std::string undoApp::Terminal::TerminalSession::selectionText |
( |
const Selection & |
selection | ) |
const |
The text a selection covers, in the direction it was made.
◆ sendChar()
| void undoApp::Terminal::TerminalSession::sendChar |
( |
uint32_t |
codepoint, |
|
|
VTermModifier |
mod |
|
) |
| |
Send a character with modifiers held.
- Parameters
-
| codepoint | The character, as a code point |
| mod | Modifiers held with it |
The way a letter is sent. Ctrl+C is this with 'c' and VTERM_MOD_CTRL, which the emulator turns into 0x03; a plain 'c' with the same modifier is the same interrupt.
◆ sendKey()
| void undoApp::Terminal::TerminalSession::sendKey |
( |
VTermKey |
key, |
|
|
VTermModifier |
mod |
|
) |
| |
Send a key, letting the emulator encode it.
- Parameters
-
| key | The key, in libvterm's vocabulary |
| mod | Modifiers held with it |
Going through the emulator is what makes an arrow an escape sequence and Ctrl+C a 0x03, rather than a character the shell has to be told about.
◆ sendText()
| void undoApp::Terminal::TerminalSession::sendText |
( |
const std::string & |
utf8 | ) |
|
Send text, as if it had been typed.
- Parameters
-
◆ start()
| bool undoApp::Terminal::TerminalSession::start |
( |
int |
rows, |
|
|
int |
cols, |
|
|
std::string & |
error |
|
) |
| |
Start the shell.
- Parameters
-
| rows | Initial height in rows |
| cols | Initial width in columns |
| error | Set to the reason when this returns false |
- Returns
- True when the shell is running
◆ stop()
| void undoApp::Terminal::TerminalSession::stop |
( |
| ) |
|
End the shell, if it is still running.
◆ title()
| const std::string & undoApp::Terminal::TerminalSession::title |
( |
| ) |
const |
|
inline |
The title the shell set, empty when it has not set one.
◆ viewport()
| const std::vector< CellLine > & undoApp::Terminal::TerminalSession::viewport |
( |
| ) |
const |
|
inline |
The lines to draw, top first.
- Returns
- rows() lines, taken from the scrollback and the screen
Scrolled back, the viewport starts in the scrollback and the live screen is its tail.
◆ writeToPty()
| void undoApp::Terminal::TerminalSession::writeToPty |
( |
const char * |
bytes, |
|
|
size_t |
len |
|
) |
| |
|
private |
◆ kCallbacks
| const VTermScreenCallbacks undoApp::Terminal::TerminalSession::kCallbacks |
|
staticprivate |
The callbacks the emulator is given, in the order it declares them.
◆ m_bell
| bool undoApp::Terminal::TerminalSession::m_bell = false |
|
private |
◆ m_cols
| int undoApp::Terminal::TerminalSession::m_cols = 80 |
|
private |
◆ m_cursor
| VTermPos undoApp::Terminal::TerminalSession::m_cursor {} |
|
private |
◆ m_cursorVisible
| bool undoApp::Terminal::TerminalSession::m_cursorVisible = true |
|
private |
◆ m_cwd
| std::string undoApp::Terminal::TerminalSession::m_cwd |
|
private |
◆ m_exited
| bool undoApp::Terminal::TerminalSession::m_exited = false |
|
private |
◆ m_exitStatus
| int undoApp::Terminal::TerminalSession::m_exitStatus = 0 |
|
private |
◆ m_master
| int undoApp::Terminal::TerminalSession::m_master = -1 |
|
private |
◆ m_pid
| int undoApp::Terminal::TerminalSession::m_pid = -1 |
|
private |
◆ m_rows
| int undoApp::Terminal::TerminalSession::m_rows = 24 |
|
private |
◆ m_screen
| VTermScreen* undoApp::Terminal::TerminalSession::m_screen = nullptr |
|
private |
◆ m_scrollback
| std::deque<CellLine> undoApp::Terminal::TerminalSession::m_scrollback |
|
private |
◆ m_scrollOffset
| int undoApp::Terminal::TerminalSession::m_scrollOffset = 0 |
|
private |
◆ m_shell
| std::string undoApp::Terminal::TerminalSession::m_shell |
|
private |
◆ m_title
| std::string undoApp::Terminal::TerminalSession::m_title |
|
private |
◆ m_viewport
| std::vector<CellLine> undoApp::Terminal::TerminalSession::m_viewport |
|
private |
◆ m_vterm
| VTerm* undoApp::Terminal::TerminalSession::m_vterm = nullptr |
|
private |
The documentation for this class was generated from the following file: