45 void move(
size_t _pos,
size_t _line)
131 void move(
size_t _x,
size_t _y)
151 operator bool()
const
234 m_char = std::move(c.m_char);
235 m_style = std::move(c.m_style);
248 m_char = std::move(c.m_char);
249 m_style = std::move(c.m_style);
261 m_style |= (
unsigned char)flags << 12;
331 for (
size_t i = 0; i < sText.length(); i++)
332 emplace_back(sText[i]);
349 for (
size_t i = 0; i < size(); i++)
350 operator[](i).setFlags(flags);
362 vector<Character>::insert(end(), vect.begin(), vect.end());
377 return vector<Character>::operator[](i);
385 return vector<Character>::operator[](i);
393 return vector<Character>::front();
401 return vector<Character>::front();
409 return vector<Character>::back();
417 return vector<Character>::back();
424 for (
size_t i = 0; i < size(); i++)
425 sRet.append(1u,
operator[](i).m_char);
430 std::string
substr(
size_t pos,
size_t len = std::string::npos)
const
435 std::vector<unsigned short>
subcolors(
size_t pos,
size_t len = std::string::npos)
const
438 return std::vector<unsigned short>();
440 if (pos+len >= size())
443 std::vector<unsigned short> vect;
445 for (
size_t i = 0; i < len; i++)
446 vect.push_back(
operator[](pos+i).getColor());
457 iterator
insert(
size_t pos,
const std::string& sText,
short flags = 0)
465 return std::vector<Character>::insert(end(), vect.begin(), vect.end());
467 return std::vector<Character>::insert(begin() + pos, vect.begin(), vect.end());
472 append(std::string(n, c));
492 void insertInput(
const std::string& sLine,
size_t logicalpos = std::string::npos);
523 std::string
GetWordAt(
int y,
int x)
const;
530 unsigned short GetColor(
int y,
int x)
const;
542 bool Scroll(
int numLines,
bool scrollUp);
543 void Resize(
int width,
int height);
573 size_t findNextLinebreak(
const std::string& currentLine,
size_t currentLinebreak)
const;
This class resembles an extended string class, which contains the extended character class.
std::string toString() const
const Character & operator[](size_t i) const
void append(size_t n, char c)
CharacterVector(const std::string &sText, short flags)
iterator insert(size_t pos, const std::string &sText, short flags=0)
std::string substr(size_t pos, size_t len=std::string::npos) const
const Character & back() const
void append(const std::string &sText)
CharacterVector & operator+=(const CharacterVector &vect)
CharacterVector & operator=(const std::string &sText)
CharacterVector(const std::string &sText)
CharacterVector & operator+=(const std::string &sText)
Character & operator[](size_t i)
void assign(const std::string &sText)
iterator insert(size_t pos, const CharacterVector &vect)
const Character & front() const
std::vector< unsigned short > subcolors(size_t pos, size_t len=std::string::npos) const
An implementation of a generic terminal, which has to be specialized in the child classes.
This class manages the actual text by storing it in an internal buffer. During an update the TextMana...
bool clearRange(const ViewCursor &cursor1, const ViewCursor &cursor2)
Clears the range between two view cursors.
std::string getSelectedText() const
This member function returns the selected text.
void synchronizeRenderedBlock(int linesToDelete)
Removes parts of the already rendered block.
bool IsUserText(int y, int x) const
Determines, whether the character at (x,y) is a user text.
int AdjustIndex(int index) const
void printOutput(const std::string &sLine)
This is the read-only print function.
std::deque< CharacterVector > m_managedText
unsigned short GetColorAdjusted(int y, int x) const
std::string getRenderedString(size_t viewLine) const
Return the rendered line for the current viewport setting.
std::string operator[](int index)
void SetColorAdjusted(int y, int x, unsigned short value)
size_t tab()
Insert a tab character at the current position.
void renderLayout()
This function renders the layout.
void insertInput(const std::string &sLine, size_t logicalpos=std::string::npos)
This is the user input function.
bool Scroll(int numLines, bool scrollUp)
void newLine()
Adds a new line to the current managed text.
int calc_color(int fg, int bg, int flags)
Helper function for converting the colors into a single int.
void backspace(const LogicalCursor &logCursor)
Performs a backspace operation.
ViewCursor toViewCursor(const LogicalCursor &logCursor) const
Convert a logical cursor to a view cursor.
std::string getPreviousLine() const
This member function returns the contents of the line before the current input line.
size_t findNextLinebreak(const std::string ¤tLine, size_t currentLinebreak) const
Find the next linebreak position.
TextManager(GenericTerminal *parent=nullptr, int width=80, int height=24, int maxWidth=160, int maxHeight=300)
void Resize(int width, int height)
std::vector< unsigned short > getRenderedColors(size_t viewLine) const
Return the rendered colors for the selected viewport line.
void updateColors(bool isErrorLine=false)
Update the colors for the current line.
~TextManager()
Destructor will reset the internal buffer.
char GetCharAdjusted(int y, int x) const
bool IsEditableLogical(const LogicalCursor &logCursor) const
Determines, whether the character at the logical position is editable text.
char GetCharLogical(const LogicalCursor &cursor) const
Returns the character at the logical position.
std::string GetInputHistory(bool vcursorup=true)
Get the next history line.
void selectText(const ViewCursor &viewCursor, bool bSelect=true)
Selects the text at the view cursor position.
void SetMaxSize(int newSize)
void eraseLine()
Erase the current line.
ViewCursor getCurrentViewPos() const
Returns the current cursor position as view cursor.
bool IsEditable(int y, int x) const
Determines, whether the character at (x,y) is editable text.
std::string GetTextRange(int y, int x0, int x1) const
Extracts the text between the positions.
void ResetVirtualCursorLine()
bool isSelected(const ViewCursor &viewCursor) const
Determines, whether the pointed character is selected.
std::string GetWordStartAt(int y, int x) const
Returns the word start at the passed position.
void ChangeEditableState()
Removes the editable flag from the managed text.
LogicalCursor toLogicalCursor(const ViewCursor &viewCursor) const
Convert a view cursor into a logical cursor.
unsigned short GetColor(int y, int x) const
LogicalCursor getCurrentLogicalPos() const
Returns the current cursor position as logical cursor.
int GetLinesReceived() const
std::string getCurrentInputLine() const
Returns the contents of the input line.
void unselectAll()
This member function unselects the whole text at once.
int GetNumLinesScrolled() const
GenericTerminal * m_parent
std::string GetWordAt(int y, int x) const
Returns the word at the passed position.
std::deque< RenderedLine > m_renderedBlock
bool isSelectedLogical(const LogicalCursor &cursor) const
Determines, whether the pointed character is selected.
int GetMaxSize() const
Returns the buffer size of the terminal.
This structure combines the character information needed in the terminal: the character itself,...
Character & operator=(Character &&c)
void setFlags(short flags)
Character & operator=(const Character &c)
Character(const Character &c)
Character(char c, unsigned char flags)
Character & operator=(char &&c)
Cursor, which is used in the TextManager to identify the actual line and position in the m_text varia...
bool operator<=(const LogicalCursor &cursor) const
void move(size_t _pos, size_t _line)
bool operator!=(const LogicalCursor &cursor) const
bool operator>=(const LogicalCursor &cursor) const
bool operator==(const LogicalCursor &cursor) const
LogicalCursor(size_t nPos, size_t nLine)
bool operator<(const LogicalCursor &cursor) const
LogicalCursor & operator++(int)
LogicalCursor operator+(int n)
LogicalCursor operator-(int n)
bool operator>(const LogicalCursor &cursor) const
This structure combines the rendered line with its colors and its coordinates.
std::vector< unsigned short > colors
std::vector< LogicalCursor > coords
Cursor, which is used in the terminal. The TextManager is able to convert this cursor into a LogicalC...
ViewCursor & operator++(int)
bool operator>(const ViewCursor &cursor) const
bool operator==(const ViewCursor &cursor) const
bool operator>=(const ViewCursor &cursor) const
bool operator!=(const ViewCursor &cursor) const
bool operator<(const ViewCursor &cursor) const
ViewCursor(size_t _x, size_t _y)
bool operator<=(const ViewCursor &cursor) const
void move(size_t _x, size_t _y)