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-2021 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6 
7 * Please contact fdivitto2013@gmail.com if you need a commercial license.
8 
9 
10 * This library and related software is available under GPL v3.
11 
12  FabGL is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  FabGL is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 
27 #pragma once
28 
29 
30 
38 #ifdef ARDUINO
39  #include "Arduino.h"
40  #include "Stream.h"
41 #endif
42 
43 #include <ctype.h>
44 #include <string.h>
45 
46 #include "freertos/FreeRTOS.h"
47 #include "freertos/task.h"
48 #include "freertos/timers.h"
49 #include "freertos/semphr.h"
50 
51 #include "fabglconf.h"
52 #include "canvas.h"
53 #include "devdrivers/keyboard.h"
54 #include "terminfo.h"
55 #include "devdrivers/soundgen.h"
56 
57 
58 
698 namespace fabgl {
699 
700 
701 
702 
706 enum class FlowControl {
707  None,
708  Software,
709  Hardware,
710  Hardsoft,
711 };
712 
713 
714 // used by saveCursorState / restoreCursorState
715 struct TerminalCursorState {
716  TerminalCursorState * next;
717  int16_t cursorX;
718  int16_t cursorY;
719  uint8_t * tabStop;
720  bool cursorPastLastCol;
721  bool originMode;
722  GlyphOptions glyphOptions;
723  uint8_t characterSetIndex;
724  uint8_t characterSet[4];
725 };
726 
727 
728 enum KeypadMode {
729  Application, // DECKPAM
730  Numeric, // DECKPNM
731 };
732 
733 
737 enum CharStyle {
745 };
746 
747 
751 enum class TerminalTransition {
752  None,
753  LeftToRight,
754  RightToLeft,
755 };
756 
757 
758 struct EmuState {
759 
760  // Index of characterSet[], 0 = G0 (Standard) 1 = G1 (Alternate), 2 = G2, 3 = G3
761  uint8_t characterSetIndex;
762 
763  // 0 = DEC Special Character and Line Drawing 1 = United States (USASCII)
764  uint8_t characterSet[4];
765 
766  Color foregroundColor;
767  Color backgroundColor;
768 
769  // cursor position (topleft = 1,1)
770  int cursorX;
771  int cursorY;
772 
773  bool cursorPastLastCol;
774 
775  bool originMode;
776 
777  bool wraparound;
778 
779  // top and down scrolling regions (1 = first row)
780  int scrollingRegionTop;
781  int scrollingRegionDown;
782 
783  bool cursorEnabled;
784 
785  // true = blinking cursor, false = steady cursor
786  bool cursorBlinkingEnabled;
787 
788  // 0,1,2 = block 3,4 = underline 5,6 = bar
789  int cursorStyle;
790 
791  // column 1 at m_emuState.tabStop[0], column 2 at m_emuState.tabStop[1], etc... 0=no tab stop, 1 = tab stop
792  uint8_t * tabStop;
793 
794  // IRM (Insert Mode)
795  bool insertMode;
796 
797  // NLM (Automatic CR LF)
798  bool newLineMode;
799 
800  // DECSCLM (Smooth scroll)
801  // Smooth scroll is effective only when vertical sync refresh is enabled,
802  // hence must be BitmappedDisplayController.enableBackgroundPrimitiveExecution(true),
803  // that is the default.
804  bool smoothScroll;
805 
806  // DECKPAM (Keypad Application Mode)
807  // DECKPNM (Keypad Numeric Mode)
808  KeypadMode keypadMode;
809 
810  // DECCKM (Cursor Keys Mode)
811  bool cursorKeysMode;
812 
813  // DESSCL (1 = VT100 ... 5 = VT500)
814  int conformanceLevel;
815 
816  // two values allowed: 7 and 8
817  int ctrlBits;
818 
819  bool keyAutorepeat;
820 
821  bool allow132ColumnMode;
822 
823  bool reverseWraparoundMode;
824 
825  // DECBKM (false = BACKSPACE sends BS, false BACKSPACE sends DEL)
826  bool backarrowKeyMode;
827 
828  // DECANM (false = VT52 mode, true = ANSI mode)
829  bool ANSIMode;
830 
831  // VT52 Graphics Mode
832  bool VT52GraphicsMode;
833 
834  // Allow FabGL specific sequences (ESC FABGLEXT_STARTCODE .....)
835  int allowFabGLSequences; // >0 allow, 0 = don't allow
836 };
837 
838 
839 #ifndef ARDUINO
840 
841 struct Print {
842  virtual size_t write(uint8_t) = 0;
843  virtual size_t write(const uint8_t * buffer, size_t size);
844  size_t write(const char *str) {
845  if (str == NULL)
846  return 0;
847  return write((const uint8_t *)str, strlen(str));
848  }
849  void printf(const char * format, ...) {
850  va_list ap;
851  va_start(ap, format);
852  int size = vsnprintf(nullptr, 0, format, ap) + 1;
853  if (size > 0) {
854  va_end(ap);
855  va_start(ap, format);
856  char buf[size + 1];
857  auto l = vsnprintf(buf, size, format, ap);
858  write((uint8_t*)buf, l);
859  }
860  va_end(ap);
861  }
862 };
863 
864 struct Stream : public Print{
865 };
866 
867 #endif // ifdef ARDUINO
868 
869 
870 
953 class Terminal : public Stream {
954 
955 public:
956 
957  Terminal();
958 
959  ~Terminal();
960 
973  bool begin(BaseDisplayController * displayController, int maxColumns = -1, int maxRows = -1, Keyboard * keyboard = nullptr);
974 
980  void end();
981 
1002  #ifdef ARDUINO
1003  void connectSerialPort(HardwareSerial & serialPort, bool autoXONXOFF = true);
1004  #endif
1005 
1033  void connectSerialPort(uint32_t baud, uint32_t config, int rxPin, int txPin, FlowControl flowControl, bool inverted = false, int rtsPin = -1, int ctsPin = -1);
1034 
1047  #ifdef ARDUINO
1048  void pollSerialPort();
1049  #endif
1050 
1058  void disableSerialPortRX(bool value) { m_uartRXEnabled = !value; }
1059 
1073  void connectLocally();
1074 
1080  void disconnectLocally();
1081 
1089  void localWrite(uint8_t c);
1090 
1098  void localWrite(char const * str);
1099 
1107  void localInsert(uint8_t c);
1108 
1117  void unRead(uint8_t c) { localInsert(c); }
1118 
1132  void setLogStream(Stream & stream) { m_logStream = &stream; }
1133 
1134  void logFmt(const char * format, ...);
1135  void log(const char * txt);
1136  void log(char c);
1137 
1148  void loadFont(FontInfo const * font);
1149 
1163  void setBackgroundColor(Color color, bool setAsDefault = true);
1164 
1178  void setForegroundColor(Color color, bool setAsDefault = true);
1179 
1193  void clear(bool moveCursor = true);
1194 
1201  void flush(bool waitVSync);
1202 
1208  int getColumns() { return m_columns; }
1209 
1215  int getRows() { return m_rows; }
1216 
1222  void enableCursor(bool value);
1223 
1229  int availableForWrite();
1230 
1238  void setTerminalType(TermType value);
1239 
1245  TermInfo const & terminalType() { return *m_termInfo; }
1246 
1247 
1250 
1258  int available();
1259 
1267  int read();
1268 
1278  int read(int timeOutMS);
1279 
1290  bool waitFor(int value, int timeOutMS = -1);
1291 
1299  int peek();
1300 
1306  void flush();
1307 
1328  size_t write(const uint8_t * buffer, size_t size);
1329 
1339  size_t write(uint8_t c);
1340 
1341  using Print::write;
1342 
1348  void send(uint8_t c);
1349 
1355  void send(char const * str);
1356 
1357 
1363  Keyboard * keyboard() { return m_keyboard; }
1364 
1370  Canvas * canvas() { return m_canvas; }
1371 
1380  void activate(TerminalTransition transition = TerminalTransition::None);
1381 
1385  void deactivate();
1386 
1392  bool isActive() { return s_activeTerminal == this; }
1393 
1405  void setColorForAttribute(CharStyle attribute, Color color, bool maintainStyle);
1406 
1414  void setColorForAttribute(CharStyle attribute);
1415 
1422 
1428  bool XOFFStatus() { return m_sentXOFF; }
1429 
1435  bool RTSStatus() { return m_RTSStatus; }
1436 
1444  void setRTSStatus(bool value);
1445 
1451  bool CTSStatus() { return m_ctsPin != GPIO_UNUSED ? gpio_get_level(m_ctsPin) == 0 : false; }
1452 
1458  void flowControl(bool enableRX);
1459 
1465  bool flowControl();
1466 
1467 
1469 
1476  Delegate<VirtualKey *, bool> onVirtualKey;
1477 
1478 
1484  Delegate<VirtualKeyItem *> onVirtualKeyItem;
1485 
1486 
1494  Delegate<char const *> onUserSequence;
1495 
1496 
1497 
1498  // statics (used for common default properties)
1499 
1500 
1508  static int inputQueueSize;
1509 
1518 
1527 
1528 
1529 private:
1530 
1531  void reset();
1532  void int_clear();
1533  void clearMap(uint32_t * map);
1534 
1535  void freeFont();
1536  void freeTabStops();
1537  void freeGlyphsMap();
1538 
1539  void set132ColumnMode(bool value);
1540 
1541  bool moveUp();
1542  bool moveDown();
1543  void move(int offset);
1544  void setCursorPos(int X, int Y);
1545  int getAbsoluteRow(int Y);
1546 
1547  void int_setBackgroundColor(Color color);
1548  void int_setForegroundColor(Color color);
1549 
1550  void syncDisplayController();
1551 
1552  // tab stops
1553  void nextTabStop();
1554  void setTabStop(int column, bool set);
1555  void resetTabStops();
1556 
1557  // scroll control
1558  void scrollDown();
1559  void scrollDownAt(int startingRow);
1560  void scrollUp();
1561  void scrollUpAt(int startingRow);
1562  void setScrollingRegion(int top, int down, bool resetCursorPos = true);
1563  void updateCanvasScrollingRegion();
1564 
1565  // multilevel save/restore cursor state
1566  void saveCursorState();
1567  void restoreCursorState();
1568  void clearSavedCursorStates();
1569 
1570  void erase(int X1, int Y1, int X2, int Y2, uint8_t c, bool maintainDoubleWidth, bool selective);
1571 
1572  void consumeInputQueue();
1573  void consumeESC();
1574  void consumeCSI();
1575  void consumeOSC();
1576  void consumeFabGLSeq();
1577  void consumeFabGLGraphicsSeq();
1578  void consumeCSIQUOT(int * params, int paramsCount);
1579  void consumeCSISPC(int * params, int paramsCount);
1580  uint8_t consumeParamsAndGetCode(int * params, int * paramsCount, bool * questionMarkFound);
1581  void consumeDECPrivateModes(int const * params, int paramsCount, uint8_t c);
1582  void consumeDCS();
1583  void execSGRParameters(int const * params, int paramsCount);
1584  void consumeESCVT52();
1585 
1586  void execCtrlCode(uint8_t c);
1587 
1588  static void charsConsumerTask(void * pvParameters);
1589  static void keyboardReaderTask(void * pvParameters);
1590 
1591  static void blinkTimerFunc(TimerHandle_t xTimer);
1592  void blinkText();
1593  bool enableBlinkingText(bool value);
1594  void blinkCursor();
1595  bool int_enableCursor(bool value);
1596 
1597  static void IRAM_ATTR uart_isr(void *arg);
1598 
1599  uint8_t getNextCode(bool processCtrlCodes);
1600 
1601  bool setChar(uint8_t c);
1602  GlyphOptions getGlyphOptionsAt(int X, int Y);
1603 
1604  void insertAt(int column, int row, int count);
1605  void deleteAt(int column, int row, int count);
1606 
1607  bool multilineInsertChar(int charsToMove);
1608  void multilineDeleteChar(int charsToMove);
1609 
1610  void reverseVideo(bool value);
1611 
1612  void refresh();
1613  void refresh(int X, int Y);
1614  void refresh(int X1, int Y1, int X2, int Y2);
1615 
1616  void setLineDoubleWidth(int row, int value);
1617  int getCharWidthAt(int row);
1618  int getColumnsAt(int row);
1619 
1620  void useAlternateScreenBuffer(bool value);
1621 
1622  void sendCSI();
1623  void sendDCS();
1624  void sendSS3();
1625  void sendCursorKeyCode(uint8_t c);
1626  void sendKeypadCursorKeyCode(uint8_t applicationCode, const char * numericCode);
1627 
1628  void ANSIDecodeVirtualKey(VirtualKeyItem const & item);
1629  void VT52DecodeVirtualKey(VirtualKeyItem const & item);
1630 
1631  void convHandleTranslation(uint8_t c, bool fromISR);
1632  void convSendCtrl(ConvCtrl ctrl, bool fromISR);
1633  void convQueue(const char * str, bool fromISR);
1634  void TermDecodeVirtualKey(VirtualKeyItem const & item);
1635 
1636  bool addToInputQueue(uint8_t c, bool fromISR);
1637  bool insertToInputQueue(uint8_t c, bool fromISR);
1638 
1639  void write(uint8_t c, bool fromISR);
1640 
1641  //static void uart_on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb, uint32_t new_apb);
1642 
1643  void uartCheckInputQueueForFlowControl();
1644 
1645  void enableFabGLSequences(bool value);
1646 
1647  void int_setTerminalType(TermType value);
1648  void int_setTerminalType(TermInfo const * value);
1649 
1650  void sound(int waveform, int frequency, int duration, int volume);
1651 
1652  uint8_t extGetByteParam();
1653  int extGetIntParam();
1654  void extGetCmdParam(char * cmd);
1655 
1656  void freeSprites();
1657 
1658  uint32_t makeGlyphItem(uint8_t c, GlyphOptions * glyphOptions, Color * newForegroundColor);
1659 
1660  // indicates which is the active terminal when there are multiple instances of Terminal
1661  static Terminal * s_activeTerminal;
1662 
1663 
1664  BaseDisplayController * m_displayController;
1665  Canvas * m_canvas;
1666  bool m_bitmappedDisplayController; // true = bitmapped, false = textual
1667 
1668  Keyboard * m_keyboard;
1669 
1670  Stream * m_logStream;
1671 
1672  // characters, characters attributes and characters colors container
1673  // you may also call this the "text screen buffer"
1674  GlyphsBuffer m_glyphsBuffer;
1675 
1676  // used to implement alternate screen buffer
1677  uint32_t * m_alternateMap;
1678 
1679  // true when m_alternateMap and m_glyphBuffer.map has been swapped
1680  bool m_alternateScreenBuffer;
1681 
1682  // just to restore some properties when swapping screens (alternate screen)
1683  int m_alternateCursorX;
1684  int m_alternateCursorY;
1685  int m_alternateScrollingRegionTop;
1686  int m_alternateScrollingRegionDown;
1687  bool m_alternateCursorBlinkingEnabled;
1688 
1689  FontInfo m_font;
1690 
1691  PaintOptions m_paintOptions;
1692  GlyphOptions m_glyphOptions;
1693 
1694  EmuState m_emuState;
1695 
1696  Color m_defaultForegroundColor;
1697  Color m_defaultBackgroundColor;
1698 
1699  // states of cursor and blinking text before consumeInputQueue()
1700  bool m_prevCursorEnabled;
1701  bool m_prevBlinkingTextEnabled;
1702 
1703  // task that reads and processes incoming characters
1704  TaskHandle_t m_charsConsumerTaskHandle;
1705 
1706  // task that reads keyboard input and send ANSI/VT100 codes to serial port
1707  TaskHandle_t m_keyboardReaderTaskHandle;
1708 
1709  // true = cursor in reverse state (visible), false = cursor invisible
1710  volatile bool m_cursorState;
1711 
1712  // timer used to blink
1713  TimerHandle_t m_blinkTimer;
1714 
1715  // main terminal mutex
1716  volatile SemaphoreHandle_t m_mutex;
1717 
1718  volatile bool m_blinkingTextVisible; // true = blinking text is currently visible
1719  volatile bool m_blinkingTextEnabled;
1720 
1721  volatile int m_columns;
1722  volatile int m_rows;
1723 
1724  // checked in loadFont() to limit m_columns and m_rows (-1 = not checked)
1725  int m_maxColumns;
1726  int m_maxRows;
1727 
1728  #ifdef ARDUINO
1729  // optional serial port
1730  // data from serial port is processed and displayed
1731  // keys from keyboard are processed and sent to serial port
1732  HardwareSerial * m_serialPort;
1733  #endif
1734 
1735  // optional serial port (directly handled)
1736  // data from serial port is processed and displayed
1737  // keys from keyboard are processed and sent to serial port
1738  volatile bool m_uart;
1739 
1740  // if false all inputs from UART are discarded
1741  volatile bool m_uartRXEnabled;
1742 
1743  // contains characters to be processed (from write() calls)
1744  volatile QueueHandle_t m_inputQueue;
1745 
1746  // contains characters received and decoded from keyboard (or as replyes from ANSI-VT queries)
1747  QueueHandle_t m_outputQueue;
1748 
1749  // linked list that contains saved cursor states (first item is the last added)
1750  TerminalCursorState * m_savedCursorStateList;
1751 
1752  // a reset has been requested
1753  bool m_resetRequested;
1754 
1755  volatile FlowControl m_flowControl;
1756  volatile bool m_sentXOFF; // true if XOFF has been sent or RTS is disabled (high)
1757  volatile bool m_recvXOFF; // true if XOFF has been received
1758 
1759  // hardware flow pins
1760  gpio_num_t m_rtsPin;
1761  gpio_num_t m_ctsPin;
1762  bool m_RTSStatus; // true = asserted (low)
1763 
1764  // used to implement m_emuState.keyAutorepeat
1765  VirtualKey m_lastPressedKey;
1766 
1767  uint8_t m_convMatchedCount;
1768  uint8_t m_convMatchedChars[EmuTerminalMaxChars];
1769  TermInfoVideoConv const * m_convMatchedItem;
1770  TermInfo const * m_termInfo;
1771 
1772  // last char added with write()
1773  volatile uint8_t m_lastWrittenChar;
1774 
1775  // when a FabGL sequence has been detected in write()
1776  volatile bool m_writeDetectedFabGLSeq;
1777 
1778  // used by extGetIntParam(), extGetCmdParam(), extGetByteParam() to store next item (to avoid insertToInputQueue() which can cause dead-locks)
1779  int m_extNextCode; // -1 = no code
1780 
1781  SoundGenerator * m_soundGenerator;
1782 
1783  Sprite * m_sprites;
1784  int m_spritesCount;
1785 
1786  bool m_coloredAttributesMaintainStyle;
1787  int m_coloredAttributesMask; // related bit 1 if enabled
1788  Color m_coloredAttributesColor[4];
1789 
1790 };
1791 
1792 
1793 
1796 // TerminalController
1797 
1798 
1813 
1814 public:
1815 
1821  TerminalController(Terminal * terminal = nullptr);
1822 
1823  ~TerminalController();
1824 
1828  void clear();
1829 
1835  void setTerminal(Terminal * terminal = nullptr);
1836 
1842  void enableCursor(bool value);
1843 
1850  void setCursorPos(int col, int row);
1851 
1862  void getCursorPos(int * col, int * row);
1863 
1871  void cursorLeft(int count);
1872 
1880  void cursorRight(int count);
1881 
1887  int getCursorCol();
1888 
1894  int getCursorRow();
1895 
1905  bool multilineInsertChar(int charsToMove);
1906 
1914  void multilineDeleteChar(int charsToMove);
1915 
1925  bool setChar(uint8_t c);
1926 
1934  bool isVKDown(VirtualKey vk);
1935 
1939  void disableFabGLSequences();
1940 
1946  void setTerminalType(TermType value);
1947 
1953  void setForegroundColor(Color value);
1954 
1960  void setBackgroundColor(Color value);
1961 
1968  void setCharStyle(CharStyle style, bool enabled);
1969 
1970 
1972 
1981  Delegate<int *> onRead;
1982 
1990  Delegate<int> onWrite;
1991 
1992 
1993 private:
1994 
1995  void waitFor(int value);
1996  void write(uint8_t c);
1997  void write(char const * str);
1998  int read();
1999 
2000 
2001  Terminal * m_terminal;
2002 };
2003 
2004 
2005 
2008 // LineEditor
2009 
2010 
2015  CursorUp,
2016  CursorDown,
2017 };
2018 
2019 
2041 class LineEditor {
2042 
2043 public:
2044 
2050  LineEditor(Terminal * terminal);
2051 
2052  ~LineEditor();
2053 
2070  void setText(char const * text, bool moveCursor = true);
2071 
2082  void setText(char const * text, int length, bool moveCursor = true);
2083 
2091  void typeText(char const * text);
2092 
2102  char const * edit(int maxLength = 0);
2103 
2109  char const * get() { return m_text; }
2110 
2116  void setInsertMode(bool value) { m_insertMode = value; }
2117 
2118 
2119  // delegates
2120 
2129  Delegate<int *> onRead;
2130 
2138  Delegate<int> onWrite;
2139 
2145  Delegate<int *> onChar;
2146 
2156  Delegate<int *> onCarriageReturn;
2157 
2163  Delegate<LineEditorSpecialChar> onSpecialChar;
2164 
2165 
2166 private:
2167 
2168  void beginInput();
2169  void endInput();
2170  void setLength(int newLength);
2171 
2172  void write(uint8_t c);
2173  int read();
2174 
2175  void performCursorUp();
2176  void performCursorDown();
2177  void performCursorLeft();
2178  void performCursorRight();
2179  void performCursorHome();
2180  void performCursorEnd();
2181  void performDeleteRight();
2182  void performDeleteLeft();
2183 
2184 
2185  Terminal * m_terminal;
2186  TerminalController m_termctrl;
2187  char * m_text;
2188  int m_textLength;
2189  int m_allocated;
2190  int16_t m_inputPos;
2191  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)
2192  int16_t m_homeCol;
2193  int16_t m_homeRow;
2194  bool m_insertMode;
2195  char * m_typeText;
2196  int m_typingIndex;
2197 };
2198 
2199 
2200 
2201 } // end of namespace
2202 
int16_t X2
Definition: fabutils.h:180
Delegate< int > onWrite
Write character delegate.
Definition: terminal.h:1990
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:1730
Delegate< int * > onCarriageReturn
A delegate called whenever carriage return has been pressed.
Definition: terminal.h:2156
void end()
Finalizes the terminal.
Definition: terminal.cpp:411
void disconnectLocally()
Avoids using of terminal locally.
Definition: terminal.cpp:650
A class with a set of drawing methods.
Definition: canvas.h:70
void activate(TerminalTransition transition=TerminalTransition::None)
Activates this terminal for input and output.
Definition: terminal.cpp:215
Represents a sprite.
void setForegroundColor(Color value)
Sets foreground color.
Definition: terminal.cpp:5144
void disableSerialPortRX(bool value)
Disables/Enables serial port RX.
Definition: terminal.h:1058
TerminalController(Terminal *terminal=nullptr)
Object constructor.
Definition: terminal.cpp:4952
char const * edit(int maxLength=0)
Reads user input and return the inserted line.
Definition: terminal.cpp:5376
void connectLocally()
Permits using of terminal locally.
Definition: terminal.cpp:642
bool waitFor(int value, int timeOutMS=-1)
Wait for a specific code from keyboard, discarding all previous codes.
Definition: terminal.cpp:1711
void setCursorPos(int col, int row)
Sets current cursor position.
Definition: terminal.cpp:5022
Delegate< int * > onRead
Read character delegate.
Definition: terminal.h:2129
void typeText(char const *text)
Simulates user typing.
Definition: terminal.cpp:5212
This file contains terminal emulation definitions.
int16_t Y2
Definition: fabutils.h:181
int getColumns()
Returns the number of columns.
Definition: terminal.h:1208
void setLogStream(Stream &stream)
Sets the stream where to output debugging logs.
Definition: terminal.h:1132
GlyphOptions & Italic(bool value)
Helper method to set or reset italic.
int16_t Y1
Definition: fabutils.h:179
This file contains fabgl::Keyboard definition.
int16_t Y
bool CTSStatus()
Reports current CTS signal status.
Definition: terminal.h:1451
FlowControl
This enum defines various serial port flow control methods.
Definition: terminal.h:706
void setForegroundColor(Color color, bool setAsDefault=true)
Sets the foreground color.
Definition: terminal.cpp:931
static int inputQueueSize
Number of characters the terminal can "write" without pause (increase if you have loss of characters ...
Definition: terminal.h:1508
bool multilineInsertChar(int charsToMove)
Inserts a blank character and move specified amount of characters to the right.
Definition: terminal.cpp:5083
TerminalTransition
This enum defines terminal transition effect.
Definition: terminal.h:751
void enableCursor(bool value)
Enables or disables cursor.
Definition: terminal.cpp:1106
Color
This enum defines named colors.
void setRTSStatus(bool value)
Sets RTS signal status.
Definition: terminal.cpp:500
The PS2 Keyboard controller class.
Definition: keyboard.h:77
A struct which contains a virtual key, key state and associated scan code.
Definition: fabutils.h:1304
CharStyle
This enum defines a character style.
Definition: terminal.h:737
This file contains fabgl::Canvas definition.
void getCursorPos(int *col, int *row)
Gets current cursor position.
Definition: terminal.cpp:5052
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:1036
int16_t X1
Definition: fabutils.h:178
void pollSerialPort()
Pools the serial port for incoming data.
Definition: terminal.cpp:1737
void setInsertMode(bool value)
Sets insert mode state.
Definition: terminal.h:2116
int getRows()
Returns the number of lines.
Definition: terminal.h:1215
void setCharStyle(CharStyle style, bool enabled)
Enables or disables specified character style.
Definition: terminal.cpp:5162
size_t write(const uint8_t *buffer, size_t size)
Sends specified number of codes to the display.
Definition: terminal.cpp:1950
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:1526
Delegate< char const * > onUserSequence
Delegate called whenever a new user sequence has been received.
Definition: terminal.h:1494
Definition: canvas.cpp:36
int read()
Reads codes from keyboard.
Definition: terminal.cpp:1694
Delegate< int * > onRead
Read character delegate.
Definition: terminal.h:1981
bool XOFFStatus()
Reports whether TX is active.
Definition: terminal.h:1428
void setColorForAttribute(CharStyle attribute, Color color, bool maintainStyle)
Selects a color for the specified attribute.
Definition: terminal.cpp:968
TerminalController allows direct controlling of the Terminal object without using escape sequences...
Definition: terminal.h:1812
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:2014
bool begin(BaseDisplayController *displayController, int maxColumns=-1, int maxRows=-1, Keyboard *keyboard=nullptr)
Initializes the terminal.
Definition: terminal.cpp:323
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:2041
void multilineDeleteChar(int charsToMove)
Deletes a character moving specified amount of characters to the left.
Definition: terminal.cpp:5095
int getCursorRow()
Gets current cursor row.
Definition: terminal.cpp:5073
Specifies various glyph painting options.
static int inputConsumerTaskStackSize
Stack size of the task that processes Terminal input stream.
Definition: terminal.h:1517
int available()
Gets the number of codes available in the keyboard queue.
Definition: terminal.cpp:1688
LineEditor(Terminal *terminal)
Object constructor.
Definition: terminal.cpp:5178
int peek()
Reads a code from the keyboard without advancing to the next one.
Definition: terminal.cpp:1724
SoundGenerator handles audio output.
Definition: soundgen.h:344
SoundGenerator * soundGenerator()
Gets embedded sound generator.
Definition: terminal.cpp:3541
void setBackgroundColor(Color value)
Sets background color.
Definition: terminal.cpp:5153
bool setChar(uint8_t c)
Sets a raw character at current cursor position.
Definition: terminal.cpp:5105
int availableForWrite()
Determines number of codes that the display input queue can still accept.
Definition: terminal.cpp:1896
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:5221
void cursorRight(int count)
Moves cursor to the right.
Definition: terminal.cpp:5042
void setBackgroundColor(Color color, bool setAsDefault=true)
Sets the background color.
Definition: terminal.cpp:911
An ANSI-VT100 compatible display terminal.
Definition: terminal.h:953
void setTerminal(Terminal *terminal=nullptr)
Sets destination terminal.
Definition: terminal.cpp:4963
int getCursorCol()
Gets current cursor column.
Definition: terminal.cpp:5063
void clear(bool moveCursor=true)
Clears the screen.
Definition: terminal.cpp:1001
TermType
This enum defines supported terminals.
Definition: terminfo.h:110
bool RTSStatus()
Reports current RTS signal status.
Definition: terminal.h:1435
void setTerminalType(TermType value)
Sets the terminal type to emulate.
Definition: terminal.cpp:5135
bool isVKDown(VirtualKey vk)
Checks if a virtual key is currently down.
Definition: terminal.cpp:5116
bool flowControl()
Checks whether host can receive data.
Definition: terminal.cpp:531
TermInfo const & terminalType()
Determines current terminal type.
Definition: terminal.h:1245
void clear()
Clears screen.
Definition: terminal.cpp:5005
void connectSerialPort(HardwareSerial &serialPort, bool autoXONXOFF=true)
Connects a remote host using the specified serial port.
Definition: terminal.cpp:441
Delegate< int > onWrite
Write character delegate.
Definition: terminal.h:2138
void cursorLeft(int count)
Moves cursor to the left.
Definition: terminal.cpp:5032
Represents the base abstract class for all display controllers.
Delegate< int * > onChar
A delegate called whenever a character has been received.
Definition: terminal.h:2145
void send(uint8_t c)
Like localWrite() but sends also to serial port if connected.
Definition: terminal.cpp:1817
void disableFabGLSequences()
Disables FabGL specific sequences.
Definition: terminal.cpp:5127
Delegate< VirtualKey *, bool > onVirtualKey
Delegate called whenever a new virtual key is received from keyboard.
Definition: terminal.h:1476
void setTerminalType(TermType value)
Sets the terminal type to emulate.
Definition: terminal.cpp:1958
void loadFont(FontInfo const *font)
Sets the font to use.
Definition: terminal.cpp:797
void unRead(uint8_t c)
Injects keys into the keyboard queue.
Definition: terminal.h:1117
void deactivate()
Deactivates this terminal.
Definition: terminal.cpp:290
void localInsert(uint8_t c)
Injects keys into the keyboard queue.
Definition: terminal.cpp:1658
Canvas * canvas()
Gets associated canvas object.
Definition: terminal.h:1370
Keyboard * keyboard()
Gets associated keyboard object.
Definition: terminal.h:1363
Specifies general paint options.
Delegate< VirtualKeyItem * > onVirtualKeyItem
Delegate called whenever a new virtual key is received from keyboard, including shift states...
Definition: terminal.h:1484
Delegate< LineEditorSpecialChar > onSpecialChar
A delegate called whenever a special character has been pressed.
Definition: terminal.h:2163
bool isActive()
Determines if this terminal is active or not.
Definition: terminal.h:1392
void enableCursor(bool value)
Enables/disables cursor.
Definition: terminal.cpp:5013
void localWrite(uint8_t c)
Injects keys into the keyboard queue.
Definition: terminal.cpp:1665