FabGL
ESP32 Display Controller and Graphics Library
terminal.h
Go to the documentation of this file.
1 /*
2  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3  Copyright (c) 2019-2020 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6  This file is part of FabGL Library.
7 
8  FabGL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  FabGL is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #pragma once
24 
25 
26 
34 #ifdef ARDUINO
35  #include "Arduino.h"
36  #include "Stream.h"
37 #endif
38 
39 #include <ctype.h>
40 #include <string.h>
41 
42 #include "freertos/FreeRTOS.h"
43 #include "freertos/task.h"
44 #include "freertos/timers.h"
45 #include "freertos/semphr.h"
46 
47 #include "fabglconf.h"
48 #include "canvas.h"
49 #include "devdrivers/keyboard.h"
50 #include "terminfo.h"
51 #include "devdrivers/soundgen.h"
52 
53 
54 
694 namespace fabgl {
695 
696 
697 
698 
702 enum class FlowControl {
703  None,
704  Software,
705 };
706 
707 
708 // used by saveCursorState / restoreCursorState
709 struct TerminalCursorState {
710  TerminalCursorState * next;
711  int16_t cursorX;
712  int16_t cursorY;
713  uint8_t * tabStop;
714  bool cursorPastLastCol;
715  bool originMode;
716  GlyphOptions glyphOptions;
717  uint8_t characterSetIndex;
718  uint8_t characterSet[4];
719 };
720 
721 
722 enum KeypadMode {
723  Application, // DECKPAM
724  Numeric, // DECKPNM
725 };
726 
727 
731 enum CharStyle {
739 };
740 
741 
745 enum class TerminalTransition {
746  None,
747  LeftToRight,
748  RightToLeft,
749 };
750 
751 
752 struct EmuState {
753 
754  // Index of characterSet[], 0 = G0 (Standard) 1 = G1 (Alternate), 2 = G2, 3 = G3
755  uint8_t characterSetIndex;
756 
757  // 0 = DEC Special Character and Line Drawing 1 = United States (USASCII)
758  uint8_t characterSet[4];
759 
760  Color foregroundColor;
761  Color backgroundColor;
762 
763  // cursor position (topleft = 1,1)
764  int cursorX;
765  int cursorY;
766 
767  bool cursorPastLastCol;
768 
769  bool originMode;
770 
771  bool wraparound;
772 
773  // top and down scrolling regions (1 = first row)
774  int scrollingRegionTop;
775  int scrollingRegionDown;
776 
777  bool cursorEnabled;
778 
779  // true = blinking cursor, false = steady cursor
780  bool cursorBlinkingEnabled;
781 
782  // 0,1,2 = block 3,4 = underline 5,6 = bar
783  int cursorStyle;
784 
785  // column 1 at m_emuState.tabStop[0], column 2 at m_emuState.tabStop[1], etc... 0=no tab stop, 1 = tab stop
786  uint8_t * tabStop;
787 
788  // IRM (Insert Mode)
789  bool insertMode;
790 
791  // NLM (Automatic CR LF)
792  bool newLineMode;
793 
794  // DECSCLM (Smooth scroll)
795  // Smooth scroll is effective only when vertical sync refresh is enabled,
796  // hence must be BitmappedDisplayController.enableBackgroundPrimitiveExecution(true),
797  // that is the default.
798  bool smoothScroll;
799 
800  // DECKPAM (Keypad Application Mode)
801  // DECKPNM (Keypad Numeric Mode)
802  KeypadMode keypadMode;
803 
804  // DECCKM (Cursor Keys Mode)
805  bool cursorKeysMode;
806 
807  // DESSCL (1 = VT100 ... 5 = VT500)
808  int conformanceLevel;
809 
810  // two values allowed: 7 and 8
811  int ctrlBits;
812 
813  bool keyAutorepeat;
814 
815  bool allow132ColumnMode;
816 
817  bool reverseWraparoundMode;
818 
819  // DECBKM (false = BACKSPACE sends BS, false BACKSPACE sends DEL)
820  bool backarrowKeyMode;
821 
822  // DECANM (false = VT52 mode, true = ANSI mode)
823  bool ANSIMode;
824 
825  // VT52 Graphics Mode
826  bool VT52GraphicsMode;
827 
828  // Allow FabGL specific sequences (ESC FABGLEXT_STARTCODE .....)
829  int allowFabGLSequences; // >0 allow, 0 = don't allow
830 };
831 
832 
833 #ifndef ARDUINO
834 
835 struct Print {
836  virtual size_t write(uint8_t) = 0;
837  virtual size_t write(const uint8_t * buffer, size_t size);
838  size_t write(const char *str) {
839  if (str == NULL)
840  return 0;
841  return write((const uint8_t *)str, strlen(str));
842  }
843  void printf(const char * format, ...) {
844  va_list ap;
845  va_start(ap, format);
846  int size = vsnprintf(nullptr, 0, format, ap) + 1;
847  if (size > 0) {
848  va_end(ap);
849  va_start(ap, format);
850  char buf[size + 1];
851  auto l = vsnprintf(buf, size, format, ap);
852  write((uint8_t*)buf, l);
853  }
854  va_end(ap);
855  }
856 };
857 
858 struct Stream : public Print{
859 };
860 
861 #endif // ifdef ARDUINO
862 
863 
864 
947 class Terminal : public Stream {
948 
949 public:
950 
951  Terminal();
952 
953  ~Terminal();
954 
967  bool begin(BaseDisplayController * displayController, int maxColumns = -1, int maxRows = -1, Keyboard * keyboard = nullptr);
968 
974  void end();
975 
996  #ifdef ARDUINO
997  void connectSerialPort(HardwareSerial & serialPort, bool autoXONXOFF = true);
998  #endif
999 
1025  void connectSerialPort(uint32_t baud, uint32_t config, int rxPin, int txPin, FlowControl flowControl, bool inverted = false);
1026 
1039  #ifdef ARDUINO
1040  void pollSerialPort();
1041  #endif
1042 
1050  void disableSerialPortRX(bool value) { m_uartRXEnabled = !value; }
1051 
1065  void connectLocally();
1066 
1072  void disconnectLocally();
1073 
1081  void localWrite(uint8_t c);
1082 
1090  void localWrite(char const * str);
1091 
1099  void localInsert(uint8_t c);
1100 
1109  void unRead(uint8_t c) { localInsert(c); }
1110 
1124  void setLogStream(Stream & stream) { m_logStream = &stream; }
1125 
1126  void logFmt(const char * format, ...);
1127  void log(const char * txt);
1128  void log(char c);
1129 
1140  void loadFont(FontInfo const * font);
1141 
1155  void setBackgroundColor(Color color, bool setAsDefault = true);
1156 
1170  void setForegroundColor(Color color, bool setAsDefault = true);
1171 
1185  void clear(bool moveCursor = true);
1186 
1193  void flush(bool waitVSync);
1194 
1200  int getColumns() { return m_columns; }
1201 
1207  int getRows() { return m_rows; }
1208 
1214  void enableCursor(bool value);
1215 
1221  int availableForWrite();
1222 
1230  void setTerminalType(TermType value);
1231 
1237  TermInfo const & terminalType() { return *m_termInfo; }
1238 
1239 
1242 
1250  int available();
1251 
1259  int read();
1260 
1270  int read(int timeOutMS);
1271 
1282  bool waitFor(int value, int timeOutMS = -1);
1283 
1291  int peek();
1292 
1298  void flush();
1299 
1320  size_t write(const uint8_t * buffer, size_t size);
1321 
1331  size_t write(uint8_t c);
1332 
1333  using Print::write;
1334 
1340  void send(uint8_t c);
1341 
1347  void send(char const * str);
1348 
1349 
1355  Keyboard * keyboard() { return m_keyboard; }
1356 
1362  Canvas * canvas() { return m_canvas; }
1363 
1373 
1377  void deactivate();
1378 
1384  bool isActive() { return s_activeTerminal == this; }
1385 
1386 
1388 
1395  Delegate<VirtualKey *, bool> onVirtualKey;
1396 
1397 
1405  Delegate<char const *> onUserSequence;
1406 
1407 
1408 
1409  // statics (used for common default properties)
1410 
1411 
1419  static int inputQueueSize;
1420 
1429 
1438 
1439 
1440 private:
1441 
1442  void reset();
1443  void int_clear();
1444  void clearMap(uint32_t * map);
1445 
1446  void freeFont();
1447  void freeTabStops();
1448  void freeGlyphsMap();
1449 
1450  void set132ColumnMode(bool value);
1451 
1452  bool moveUp();
1453  bool moveDown();
1454  void move(int offset);
1455  void setCursorPos(int X, int Y);
1456  int getAbsoluteRow(int Y);
1457 
1458  void int_setBackgroundColor(Color color);
1459  void int_setForegroundColor(Color color);
1460 
1461  void syncDisplayController();
1462 
1463  // tab stops
1464  void nextTabStop();
1465  void setTabStop(int column, bool set);
1466  void resetTabStops();
1467 
1468  // scroll control
1469  void scrollDown();
1470  void scrollDownAt(int startingRow);
1471  void scrollUp();
1472  void scrollUpAt(int startingRow);
1473  void setScrollingRegion(int top, int down, bool resetCursorPos = true);
1474  void updateCanvasScrollingRegion();
1475 
1476  // multilevel save/restore cursor state
1477  void saveCursorState();
1478  void restoreCursorState();
1479  void clearSavedCursorStates();
1480 
1481  void erase(int X1, int Y1, int X2, int Y2, uint8_t c, bool maintainDoubleWidth, bool selective);
1482 
1483  void consumeInputQueue();
1484  void consumeESC();
1485  void consumeCSI();
1486  void consumeOSC();
1487  void consumeFabGLSeq();
1488  void consumeFabGLGraphicsSeq();
1489  void consumeCSIQUOT(int * params, int paramsCount);
1490  void consumeCSISPC(int * params, int paramsCount);
1491  uint8_t consumeParamsAndGetCode(int * params, int * paramsCount, bool * questionMarkFound);
1492  void consumeDECPrivateModes(int const * params, int paramsCount, uint8_t c);
1493  void consumeDCS();
1494  void execSGRParameters(int const * params, int paramsCount);
1495  void consumeESCVT52();
1496 
1497  void execCtrlCode(uint8_t c);
1498 
1499  static void charsConsumerTask(void * pvParameters);
1500  static void keyboardReaderTask(void * pvParameters);
1501 
1502  static void blinkTimerFunc(TimerHandle_t xTimer);
1503  void blinkText();
1504  bool enableBlinkingText(bool value);
1505  void blinkCursor();
1506  bool int_enableCursor(bool value);
1507 
1508  static void IRAM_ATTR uart_isr(void *arg);
1509 
1510  uint8_t getNextCode(bool processCtrlCodes);
1511 
1512  bool setChar(uint8_t c);
1513  GlyphOptions getGlyphOptionsAt(int X, int Y);
1514 
1515  void insertAt(int column, int row, int count);
1516  void deleteAt(int column, int row, int count);
1517 
1518  bool multilineInsertChar(int charsToMove);
1519  void multilineDeleteChar(int charsToMove);
1520 
1521  void reverseVideo(bool value);
1522 
1523  void refresh();
1524  void refresh(int X, int Y);
1525  void refresh(int X1, int Y1, int X2, int Y2);
1526 
1527  void setLineDoubleWidth(int row, int value);
1528  int getCharWidthAt(int row);
1529  int getColumnsAt(int row);
1530 
1531  void useAlternateScreenBuffer(bool value);
1532 
1533  void sendCSI();
1534  void sendDCS();
1535  void sendSS3();
1536  void sendCursorKeyCode(uint8_t c);
1537  void sendKeypadCursorKeyCode(uint8_t applicationCode, const char * numericCode);
1538 
1539  void ANSIDecodeVirtualKey(VirtualKey vk);
1540  void VT52DecodeVirtualKey(VirtualKey vk);
1541 
1542  void convHandleTranslation(uint8_t c, bool fromISR);
1543  void convSendCtrl(ConvCtrl ctrl, bool fromISR);
1544  void convQueue(const char * str, bool fromISR);
1545  void TermDecodeVirtualKey(VirtualKey vk);
1546 
1547  bool addToInputQueue(uint8_t c, bool fromISR);
1548  bool insertToInputQueue(uint8_t c, bool fromISR);
1549 
1550  void write(uint8_t c, bool fromISR);
1551 
1552  //static void uart_on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb, uint32_t new_apb);
1553 
1554  void uartCheckInputQueueForFlowControl();
1555 
1556  void enableFabGLSequences(bool value);
1557 
1558  void int_setTerminalType(TermType value);
1559  void int_setTerminalType(TermInfo const * value);
1560 
1561  void sound(int waveform, int frequency, int duration, int volume);
1562 
1563  uint8_t extGetByteParam();
1564  int extGetIntParam();
1565  void extGetCmdParam(char * cmd);
1566 
1567  void freeSprites();
1568 
1569  // indicates which is the active terminal when there are multiple instances of Terminal
1570  static Terminal * s_activeTerminal;
1571 
1572 
1573  BaseDisplayController * m_displayController;
1574  Canvas * m_canvas;
1575  bool m_bitmappedDisplayController; // true = bitmapped, false = textual
1576 
1577  Keyboard * m_keyboard;
1578 
1579  Stream * m_logStream;
1580 
1581  // characters, characters attributes and characters colors container
1582  // you may also call this the "text screen buffer"
1583  GlyphsBuffer m_glyphsBuffer;
1584 
1585  // used to implement alternate screen buffer
1586  uint32_t * m_alternateMap;
1587 
1588  // true when m_alternateMap and m_glyphBuffer.map has been swapped
1589  bool m_alternateScreenBuffer;
1590 
1591  // just to restore some properties when swapping screens (alternate screen)
1592  int m_alternateCursorX;
1593  int m_alternateCursorY;
1594  int m_alternateScrollingRegionTop;
1595  int m_alternateScrollingRegionDown;
1596  bool m_alternateCursorBlinkingEnabled;
1597 
1598  FontInfo m_font;
1599 
1600  PaintOptions m_paintOptions;
1601  GlyphOptions m_glyphOptions;
1602 
1603  EmuState m_emuState;
1604 
1605  Color m_defaultForegroundColor;
1606  Color m_defaultBackgroundColor;
1607 
1608  // states of cursor and blinking text before consumeInputQueue()
1609  bool m_prevCursorEnabled;
1610  bool m_prevBlinkingTextEnabled;
1611 
1612  // task that reads and processes incoming characters
1613  TaskHandle_t m_charsConsumerTaskHandle;
1614 
1615  // task that reads keyboard input and send ANSI/VT100 codes to serial port
1616  TaskHandle_t m_keyboardReaderTaskHandle;
1617 
1618  // true = cursor in reverse state (visible), false = cursor invisible
1619  volatile bool m_cursorState;
1620 
1621  // timer used to blink
1622  TimerHandle_t m_blinkTimer;
1623 
1624  // main terminal mutex
1625  volatile SemaphoreHandle_t m_mutex;
1626 
1627  volatile bool m_blinkingTextVisible; // true = blinking text is currently visible
1628  volatile bool m_blinkingTextEnabled;
1629 
1630  volatile int m_columns;
1631  volatile int m_rows;
1632 
1633  // checked in loadFont() to limit m_columns and m_rows (-1 = not checked)
1634  int m_maxColumns;
1635  int m_maxRows;
1636 
1637  #ifdef ARDUINO
1638  // optional serial port
1639  // data from serial port is processed and displayed
1640  // keys from keyboard are processed and sent to serial port
1641  HardwareSerial * m_serialPort;
1642  #endif
1643 
1644  // optional serial port (directly handled)
1645  // data from serial port is processed and displayed
1646  // keys from keyboard are processed and sent to serial port
1647  volatile bool m_uart;
1648 
1649  // if false all inputs from UART are discarded
1650  volatile bool m_uartRXEnabled;
1651 
1652  // contains characters to be processed (from write() calls)
1653  volatile QueueHandle_t m_inputQueue;
1654 
1655  // contains characters received and decoded from keyboard (or as replyes from ANSI-VT queries)
1656  QueueHandle_t m_outputQueue;
1657 
1658  // linked list that contains saved cursor states (first item is the last added)
1659  TerminalCursorState * m_savedCursorStateList;
1660 
1661  // a reset has been requested
1662  bool m_resetRequested;
1663 
1664  volatile bool m_autoXONOFF;
1665  volatile bool m_XOFF; // true = XOFF sent
1666 
1667  // used to implement m_emuState.keyAutorepeat
1668  VirtualKey m_lastPressedKey;
1669 
1670  uint8_t m_convMatchedCount;
1671  uint8_t m_convMatchedChars[EmuTerminalMaxChars];
1672  TermInfoVideoConv const * m_convMatchedItem;
1673  TermInfo const * m_termInfo;
1674 
1675  // last char added with write()
1676  volatile uint8_t m_lastWrittenChar;
1677 
1678  // when a FabGL sequence has been detected in write()
1679  volatile bool m_writeDetectedFabGLSeq;
1680 
1681  // used by extGetIntParam(), extGetCmdParam(), extGetByteParam() to store next item (to avoid insertToInputQueue() which can cause dead-locks)
1682  int m_extNextCode; // -1 = no code
1683 
1684  SoundGenerator * m_soundGenerator;
1685 
1686  Sprite * m_sprites;
1687  int m_spritesCount;
1688 
1689 };
1690 
1691 
1692 
1695 // TerminalController
1696 
1697 
1712 
1713 public:
1714 
1720  TerminalController(Terminal * terminal = nullptr);
1721 
1722  ~TerminalController();
1723 
1727  void clear();
1728 
1734  void setTerminal(Terminal * terminal = nullptr);
1735 
1741  void enableCursor(bool value);
1742 
1749  void setCursorPos(int col, int row);
1750 
1761  void getCursorPos(int * col, int * row);
1762 
1770  void cursorLeft(int count);
1771 
1779  void cursorRight(int count);
1780 
1786  int getCursorCol();
1787 
1793  int getCursorRow();
1794 
1804  bool multilineInsertChar(int charsToMove);
1805 
1813  void multilineDeleteChar(int charsToMove);
1814 
1824  bool setChar(uint8_t c);
1825 
1833  bool isVKDown(VirtualKey vk);
1834 
1838  void disableFabGLSequences();
1839 
1845  void setTerminalType(TermType value);
1846 
1852  void setForegroundColor(Color value);
1853 
1859  void setBackgroundColor(Color value);
1860 
1867  void setCharStyle(CharStyle style, bool enabled);
1868 
1869 
1871 
1880  Delegate<int *> onRead;
1881 
1889  Delegate<int> onWrite;
1890 
1891 
1892 private:
1893 
1894  void waitFor(int value);
1895  void write(uint8_t c);
1896  void write(char const * str);
1897  int read();
1898 
1899 
1900  Terminal * m_terminal;
1901 };
1902 
1903 
1904 
1907 // LineEditor
1908 
1909 
1914  CursorUp,
1915  CursorDown,
1916 };
1917 
1918 
1940 class LineEditor {
1941 
1942 public:
1943 
1949  LineEditor(Terminal * terminal);
1950 
1951  ~LineEditor();
1952 
1969  void setText(char const * text, bool moveCursor = true);
1970 
1981  void setText(char const * text, int length, bool moveCursor = true);
1982 
1990  void typeText(char const * text);
1991 
2001  char const * edit(int maxLength = 0);
2002 
2008  char const * get() { return m_text; }
2009 
2015  void setInsertMode(bool value) { m_insertMode = value; }
2016 
2017 
2018  // delegates
2019 
2028  Delegate<int *> onRead;
2029 
2037  Delegate<int> onWrite;
2038 
2044  Delegate<int *> onChar;
2045 
2055  Delegate<int *> onCarriageReturn;
2056 
2062  Delegate<LineEditorSpecialChar> onSpecialChar;
2063 
2064 
2065 private:
2066 
2067  void beginInput();
2068  void endInput();
2069  void setLength(int newLength);
2070 
2071  void write(uint8_t c);
2072  int read();
2073 
2074  void performCursorUp();
2075  void performCursorDown();
2076  void performCursorLeft();
2077  void performCursorRight();
2078  void performCursorHome();
2079  void performCursorEnd();
2080  void performDeleteRight();
2081  void performDeleteLeft();
2082 
2083 
2084  Terminal * m_terminal;
2085  TerminalController m_termctrl;
2086  char * m_text;
2087  int m_textLength;
2088  int m_allocated;
2089  int16_t m_inputPos;
2090  int16_t m_state; // -1 = begin input, 0 = normal input, 1 = ESC, 2 = CTRL-Q, >=31 = CSI (actual value specifies the third char if present)
2091  int16_t m_homeCol;
2092  int16_t m_homeRow;
2093  bool m_insertMode;
2094  char * m_typeText;
2095  int m_typingIndex;
2096 };
2097 
2098 
2099 
2100 } // end of namespace
2101 
int16_t X2
Definition: fabutils.h:150
Delegate< int > onWrite
Write character delegate.
Definition: terminal.h:1889
GlyphOptions & Bold(bool value)
Helper method to set or reset bold.
void flush()
Waits for all codes sent to the display has been processed.
Definition: terminal.cpp:1614
Delegate< int * > onCarriageReturn
A delegate called whenever carriage return has been pressed.
Definition: terminal.h:2055
void end()
Finalizes the terminal.
Definition: terminal.cpp:394
void disconnectLocally()
Avoids using of terminal locally.
Definition: terminal.cpp:580
A class with a set of drawing methods.
Definition: canvas.h:66
void activate(TerminalTransition transition=TerminalTransition::None)
Activates this terminal for input and output.
Definition: terminal.cpp:203
Represents a sprite.
void setForegroundColor(Color value)
Sets foreground color.
Definition: terminal.cpp:4963
void disableSerialPortRX(bool value)
Disables/Enables serial port RX.
Definition: terminal.h:1050
TerminalController(Terminal *terminal=nullptr)
Object constructor.
Definition: terminal.cpp:4771
char const * edit(int maxLength=0)
Reads user input and return the inserted line.
Definition: terminal.cpp:5195
void connectLocally()
Permits using of terminal locally.
Definition: terminal.cpp:572
bool waitFor(int value, int timeOutMS=-1)
Wait for a specific code from keyboard, discarding all previous codes.
Definition: terminal.cpp:1595
void setCursorPos(int col, int row)
Sets current cursor position.
Definition: terminal.cpp:4841
Delegate< int * > onRead
Read character delegate.
Definition: terminal.h:2028
void typeText(char const *text)
Simulates user typing.
Definition: terminal.cpp:5031
This file contains terminal emulation definitions.
int16_t Y2
Definition: fabutils.h:151
int getColumns()
Returns the number of columns.
Definition: terminal.h:1200
void setLogStream(Stream &stream)
Sets the stream where to output debugging logs.
Definition: terminal.h:1124
GlyphOptions & Italic(bool value)
Helper method to set or reset italic.
int16_t Y1
Definition: fabutils.h:149
This file contains fabgl::Keyboard definition.
int16_t Y
FlowControl
This enum defines various serial port flow control methods.
Definition: terminal.h:702
void setForegroundColor(Color color, bool setAsDefault=true)
Sets the foreground color.
Definition: terminal.cpp:851
static int inputQueueSize
Number of characters the terminal can "write" without pause (increase if you have loss of characters ...
Definition: terminal.h:1419
bool multilineInsertChar(int charsToMove)
Inserts a blank character and move specified amount of characters to the right.
Definition: terminal.cpp:4902
TerminalTransition
This enum defines terminal transition effect.
Definition: terminal.h:745
void enableCursor(bool value)
Enables or disables cursor.
Definition: terminal.cpp:990
Color
This enum defines named colors.
The PS2 Keyboard controller class.
Definition: keyboard.h:166
CharStyle
This enum defines a character style.
Definition: terminal.h:731
This file contains fabgl::Canvas definition.
void getCursorPos(int *col, int *row)
Gets current cursor position.
Definition: terminal.cpp:4871
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:951
int16_t X1
Definition: fabutils.h:148
void pollSerialPort()
Pools the serial port for incoming data.
Definition: terminal.cpp:1621
void setInsertMode(bool value)
Sets insert mode state.
Definition: terminal.h:2015
int getRows()
Returns the number of lines.
Definition: terminal.h:1207
void setCharStyle(CharStyle style, bool enabled)
Enables or disables specified character style.
Definition: terminal.cpp:4981
size_t write(const uint8_t *buffer, size_t size)
Sends specified number of codes to the display.
Definition: terminal.cpp:1835
static int keyboardReaderTaskStackSize
Stack size of the task that reads keys from keyboard and send ANSI/VT codes to output stream in Termi...
Definition: terminal.h:1437
Delegate< char const * > onUserSequence
Delegate called whenever a new user sequence has been received.
Definition: terminal.h:1405
Definition: canvas.cpp:31
int read()
Reads codes from keyboard.
Definition: terminal.cpp:1578
Delegate< int * > onRead
Read character delegate.
Definition: terminal.h:1880
TerminalController allows direct controlling of the Terminal object without using escape sequences...
Definition: terminal.h:1711
GlyphOptions & Underline(bool value)
Helper method to set or reset underlined.
LineEditorSpecialChar
Special character specified in on values from LineEditor::onSpecialChar delegate. ...
Definition: terminal.h:1913
bool begin(BaseDisplayController *displayController, int maxColumns=-1, int maxRows=-1, Keyboard *keyboard=nullptr)
Initializes the terminal.
Definition: terminal.cpp:311
GlyphOptions & Blank(uint8_t value)
Helper method to set or reset foreground and background swapping.
LineEditor is a single-line / multiple-rows editor which uses the Terminal object as input and output...
Definition: terminal.h:1940
void multilineDeleteChar(int charsToMove)
Deletes a character moving specified amount of characters to the left.
Definition: terminal.cpp:4914
int getCursorRow()
Gets current cursor row.
Definition: terminal.cpp:4892
Specifies various glyph painting options.
static int inputConsumerTaskStackSize
Stack size of the task that processes Terminal input stream.
Definition: terminal.h:1428
int available()
Gets the number of codes available in the keyboard queue.
Definition: terminal.cpp:1572
LineEditor(Terminal *terminal)
Object constructor.
Definition: terminal.cpp:4997
int peek()
Reads a code from the keyboard without advancing to the next one.
Definition: terminal.cpp:1608
SoundGenerator handles audio output.
Definition: soundgen.h:337
void setBackgroundColor(Color value)
Sets background color.
Definition: terminal.cpp:4972
bool setChar(uint8_t c)
Sets a raw character at current cursor position.
Definition: terminal.cpp:4924
int availableForWrite()
Determines number of codes that the display input queue can still accept.
Definition: terminal.cpp:1781
This file contains FabGL library configuration settings, like number of supported colors...
This file contains all classes related to FabGL Sound System.
int16_t X
void setText(char const *text, bool moveCursor=true)
Sets initial text.
Definition: terminal.cpp:5040
void cursorRight(int count)
Moves cursor to the right.
Definition: terminal.cpp:4861
void setBackgroundColor(Color color, bool setAsDefault=true)
Sets the background color.
Definition: terminal.cpp:831
An ANSI-VT100 compatible display terminal.
Definition: terminal.h:947
void setTerminal(Terminal *terminal=nullptr)
Sets destination terminal.
Definition: terminal.cpp:4782
int getCursorCol()
Gets current cursor column.
Definition: terminal.cpp:4882
void clear(bool moveCursor=true)
Clears the screen.
Definition: terminal.cpp:885
TermType
This enum defines supported terminals.
Definition: terminfo.h:103
void setTerminalType(TermType value)
Sets the terminal type to emulate.
Definition: terminal.cpp:4954
bool isVKDown(VirtualKey vk)
Checks if a virtual key is currently down.
Definition: terminal.cpp:4935
TermInfo const & terminalType()
Determines current terminal type.
Definition: terminal.h:1237
void clear()
Clears screen.
Definition: terminal.cpp:4824
void connectSerialPort(HardwareSerial &serialPort, bool autoXONXOFF=true)
Connects a remote host using the specified serial port.
Definition: terminal.cpp:424
Delegate< int > onWrite
Write character delegate.
Definition: terminal.h:2037
void cursorLeft(int count)
Moves cursor to the left.
Definition: terminal.cpp:4851
Represents the base abstract class for all display controllers.
Delegate< int * > onChar
A delegate called whenever a character has been received.
Definition: terminal.h:2044
void send(uint8_t c)
Like localWrite() but sends also to serial port if connected.
Definition: terminal.cpp:1706
void disableFabGLSequences()
Disables FabGL specific sequences.
Definition: terminal.cpp:4946
Delegate< VirtualKey *, bool > onVirtualKey
Delegate called whenever a new virtual key is received from keyboard.
Definition: terminal.h:1395
void setTerminalType(TermType value)
Sets the terminal type to emulate.
Definition: terminal.cpp:1843
void loadFont(FontInfo const *font)
Sets the font to use.
Definition: terminal.cpp:727
void unRead(uint8_t c)
Injects keys into the keyboard queue.
Definition: terminal.h:1109
void deactivate()
Deactivates this terminal.
Definition: terminal.cpp:278
void localInsert(uint8_t c)
Injects keys into the keyboard queue.
Definition: terminal.cpp:1542
Canvas * canvas()
Gets associated canvas object.
Definition: terminal.h:1362
Keyboard * keyboard()
Gets associated keyboard object.
Definition: terminal.h:1355
Specifies general paint options.
Delegate< LineEditorSpecialChar > onSpecialChar
A delegate called whenever a special character has been pressed.
Definition: terminal.h:2062
bool isActive()
Determines if this terminal is active or not.
Definition: terminal.h:1384
void enableCursor(bool value)
Enables/disables cursor.
Definition: terminal.cpp:4832
void localWrite(uint8_t c)
Injects keys into the keyboard queue.
Definition: terminal.cpp:1549