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-2022 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
698namespace fabgl {
699
700
701
702
706enum class FlowControl {
707 None,
708 Software,
709 Hardware,
710 Hardsoft,
711};
712
713
714// used by saveCursorState / restoreCursorState
715struct 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
728enum KeypadMode {
729 Application, // DECKPAM
730 Numeric, // DECKPNM
731};
732
733
745};
746
747
752 None,
755};
756
757
758struct 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
841struct 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
864struct Stream : public Print{
865};
866
867#endif // ifdef ARDUINO
868
869
870
953class Terminal : public Stream {
954
955public:
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
1035 void connectSerialPort(uint32_t baud, int dataLength, char parity, float stopBits, int rxPin, int txPin, FlowControl flowControl, bool inverted = false, int rtsPin = -1, int ctsPin = -1);
1036
1049 #ifdef ARDUINO
1050 void pollSerialPort();
1051 #endif
1052
1060 void disableSerialPortRX(bool value) { m_uartRXEnabled = !value; }
1061
1075 void connectLocally();
1076
1082 void disconnectLocally();
1083
1091 void localWrite(uint8_t c);
1092
1100 void localWrite(char const * str);
1101
1109 void localInsert(uint8_t c);
1110
1119 void unRead(uint8_t c) { localInsert(c); }
1120
1134 void setLogStream(Stream & stream) { m_logStream = &stream; }
1135
1136 void logFmt(const char * format, ...);
1137 void log(const char * txt);
1138 void log(char c);
1139
1150 void loadFont(FontInfo const * font);
1151
1165 void setBackgroundColor(Color color, bool setAsDefault = true);
1166
1180 void setForegroundColor(Color color, bool setAsDefault = true);
1181
1195 void clear(bool moveCursor = true);
1196
1203 void flush(bool waitVSync);
1204
1210 int getColumns() { return m_columns; }
1211
1217 int getRows() { return m_rows; }
1218
1224 void enableCursor(bool value);
1225
1231 int availableForWrite();
1232
1240 void setTerminalType(TermType value);
1241
1247 TermInfo const & terminalType() { return *m_termInfo; }
1248
1249
1252
1260 int available();
1261
1269 int read();
1270
1280 int read(int timeOutMS);
1281
1292 bool waitFor(int value, int timeOutMS = -1);
1293
1301 int peek();
1302
1308 void flush();
1309
1330 size_t write(const uint8_t * buffer, size_t size);
1331
1341 size_t write(uint8_t c);
1342
1343 using Print::write;
1344
1350 void send(uint8_t c);
1351
1357 void send(char const * str);
1358
1359
1365 Keyboard * keyboard() { return m_keyboard; }
1366
1372 Canvas * canvas() { return m_canvas; }
1373
1382 void activate(TerminalTransition transition = TerminalTransition::None);
1383
1387 void deactivate();
1388
1394 bool isActive() { return s_activeTerminal == this; }
1395
1407 void setColorForAttribute(CharStyle attribute, Color color, bool maintainStyle);
1408
1416 void setColorForAttribute(CharStyle attribute);
1417
1424
1430 bool XOFFStatus() { return m_sentXOFF; }
1431
1437 bool RTSStatus() { return m_RTSStatus; }
1438
1446 void setRTSStatus(bool value);
1447
1453 bool CTSStatus() { return m_ctsPin != GPIO_UNUSED ? gpio_get_level(m_ctsPin) == 0 : false; }
1454
1460 void flowControl(bool enableRX);
1461
1467 bool flowControl();
1468
1469
1471
1478 Delegate<VirtualKey *, bool> onVirtualKey;
1479
1480
1486 Delegate<VirtualKeyItem *> onVirtualKeyItem;
1487
1488
1496 Delegate<char const *> onUserSequence;
1497
1498
1499
1500 // statics (used for common default properties)
1501
1502
1510 static int inputQueueSize;
1511
1520
1529
1530
1531private:
1532
1533 void reset();
1534 void int_clear();
1535 void clearMap(uint32_t * map);
1536
1537 void freeFont();
1538 void freeTabStops();
1539 void freeGlyphsMap();
1540
1541 void set132ColumnMode(bool value);
1542
1543 bool moveUp();
1544 bool moveDown();
1545 void move(int offset);
1546 void setCursorPos(int X, int Y);
1547 int getAbsoluteRow(int Y);
1548
1549 void int_setBackgroundColor(Color color);
1550 void int_setForegroundColor(Color color);
1551
1552 void syncDisplayController();
1553
1554 // tab stops
1555 void nextTabStop();
1556 void setTabStop(int column, bool set);
1557 void resetTabStops();
1558
1559 // scroll control
1560 void scrollDown();
1561 void scrollDownAt(int startingRow);
1562 void scrollUp();
1563 void scrollUpAt(int startingRow);
1564 void setScrollingRegion(int top, int down, bool resetCursorPos = true);
1565 void updateCanvasScrollingRegion();
1566
1567 // multilevel save/restore cursor state
1568 void saveCursorState();
1569 void restoreCursorState();
1570 void clearSavedCursorStates();
1571
1572 void erase(int X1, int Y1, int X2, int Y2, uint8_t c, bool maintainDoubleWidth, bool selective);
1573
1574 void consumeInputQueue();
1575 void consumeESC();
1576 void consumeCSI();
1577 void consumeOSC();
1578 void consumeFabGLSeq();
1579 void consumeFabGLGraphicsSeq();
1580 void consumeCSIQUOT(int * params, int paramsCount);
1581 void consumeCSISPC(int * params, int paramsCount);
1582 uint8_t consumeParamsAndGetCode(int * params, int * paramsCount, bool * questionMarkFound);
1583 void consumeDECPrivateModes(int const * params, int paramsCount, uint8_t c);
1584 void consumeDCS();
1585 void execSGRParameters(int const * params, int paramsCount);
1586 void consumeESCVT52();
1587
1588 void execCtrlCode(uint8_t c);
1589
1590 static void charsConsumerTask(void * pvParameters);
1591 static void keyboardReaderTask(void * pvParameters);
1592
1593 static void blinkTimerFunc(TimerHandle_t xTimer);
1594 void blinkText();
1595 bool enableBlinkingText(bool value);
1596 void blinkCursor();
1597 bool int_enableCursor(bool value);
1598
1599 static void IRAM_ATTR uart_isr(void *arg);
1600
1601 uint8_t getNextCode(bool processCtrlCodes);
1602
1603 bool setChar(uint8_t c);
1604 GlyphOptions getGlyphOptionsAt(int X, int Y);
1605
1606 void insertAt(int column, int row, int count);
1607 void deleteAt(int column, int row, int count);
1608
1609 bool multilineInsertChar(int charsToMove);
1610 void multilineDeleteChar(int charsToMove);
1611
1612 void reverseVideo(bool value);
1613
1614 void refresh();
1615 void refresh(int X, int Y);
1616 void refresh(int X1, int Y1, int X2, int Y2);
1617
1618 void setLineDoubleWidth(int row, int value);
1619 int getCharWidthAt(int row);
1620 int getColumnsAt(int row);
1621
1622 void useAlternateScreenBuffer(bool value);
1623
1624 void sendCSI();
1625 void sendDCS();
1626 void sendSS3();
1627 void sendCursorKeyCode(uint8_t c);
1628 void sendKeypadCursorKeyCode(uint8_t applicationCode, const char * numericCode);
1629
1630 void ANSIDecodeVirtualKey(VirtualKeyItem const & item);
1631 void VT52DecodeVirtualKey(VirtualKeyItem const & item);
1632
1633 void convHandleTranslation(uint8_t c, bool fromISR);
1634 void convSendCtrl(ConvCtrl ctrl, bool fromISR);
1635 void convQueue(const char * str, bool fromISR);
1636 void TermDecodeVirtualKey(VirtualKeyItem const & item);
1637
1638 bool addToInputQueue(uint8_t c, bool fromISR);
1639 bool insertToInputQueue(uint8_t c, bool fromISR);
1640
1641 void write(uint8_t c, bool fromISR);
1642
1643 //static void uart_on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb, uint32_t new_apb);
1644
1645 void uartCheckInputQueueForFlowControl();
1646
1647 void enableFabGLSequences(bool value);
1648
1649 void int_setTerminalType(TermType value);
1650 void int_setTerminalType(TermInfo const * value);
1651
1652 void sound(int waveform, int frequency, int duration, int volume);
1653
1654 uint8_t extGetByteParam();
1655 int extGetIntParam();
1656 void extGetCmdParam(char * cmd);
1657
1658 void freeSprites();
1659
1660 uint32_t makeGlyphItem(uint8_t c, GlyphOptions * glyphOptions, Color * newForegroundColor);
1661
1662 // indicates which is the active terminal when there are multiple instances of Terminal
1663 static Terminal * s_activeTerminal;
1664
1665
1666 BaseDisplayController * m_displayController;
1667 Canvas * m_canvas;
1668 bool m_bitmappedDisplayController; // true = bitmapped, false = textual
1669
1670 Keyboard * m_keyboard;
1671
1672 Stream * m_logStream;
1673
1674 // characters, characters attributes and characters colors container
1675 // you may also call this the "text screen buffer"
1676 GlyphsBuffer m_glyphsBuffer;
1677
1678 // used to implement alternate screen buffer
1679 uint32_t * m_alternateMap;
1680
1681 // true when m_alternateMap and m_glyphBuffer.map has been swapped
1682 bool m_alternateScreenBuffer;
1683
1684 // just to restore some properties when swapping screens (alternate screen)
1685 int m_alternateCursorX;
1686 int m_alternateCursorY;
1687 int m_alternateScrollingRegionTop;
1688 int m_alternateScrollingRegionDown;
1689 bool m_alternateCursorBlinkingEnabled;
1690
1691 FontInfo m_font;
1692
1693 PaintOptions m_paintOptions;
1694 GlyphOptions m_glyphOptions;
1695
1696 EmuState m_emuState;
1697
1698 Color m_defaultForegroundColor;
1699 Color m_defaultBackgroundColor;
1700
1701 // states of cursor and blinking text before consumeInputQueue()
1702 bool m_prevCursorEnabled;
1703 bool m_prevBlinkingTextEnabled;
1704
1705 // task that reads and processes incoming characters
1706 TaskHandle_t m_charsConsumerTaskHandle;
1707
1708 // task that reads keyboard input and send ANSI/VT100 codes to serial port
1709 TaskHandle_t m_keyboardReaderTaskHandle;
1710
1711 // true = cursor in reverse state (visible), false = cursor invisible
1712 volatile bool m_cursorState;
1713
1714 // timer used to blink
1715 TimerHandle_t m_blinkTimer;
1716
1717 // main terminal mutex
1718 volatile SemaphoreHandle_t m_mutex;
1719
1720 volatile bool m_blinkingTextVisible; // true = blinking text is currently visible
1721 volatile bool m_blinkingTextEnabled;
1722
1723 volatile int m_columns;
1724 volatile int m_rows;
1725
1726 // checked in loadFont() to limit m_columns and m_rows (-1 = not checked)
1727 int m_maxColumns;
1728 int m_maxRows;
1729
1730 #ifdef ARDUINO
1731 // optional serial port
1732 // data from serial port is processed and displayed
1733 // keys from keyboard are processed and sent to serial port
1734 HardwareSerial * m_serialPort;
1735 #endif
1736
1737 // optional serial port (directly handled)
1738 // data from serial port is processed and displayed
1739 // keys from keyboard are processed and sent to serial port
1740 volatile bool m_uart;
1741
1742 // if false all inputs from UART are discarded
1743 volatile bool m_uartRXEnabled;
1744
1745 // contains characters to be processed (from write() calls)
1746 volatile QueueHandle_t m_inputQueue;
1747
1748 // contains characters received and decoded from keyboard (or as replyes from ANSI-VT queries)
1749 QueueHandle_t m_outputQueue;
1750
1751 // linked list that contains saved cursor states (first item is the last added)
1752 TerminalCursorState * m_savedCursorStateList;
1753
1754 // a reset has been requested
1755 bool m_resetRequested;
1756
1757 volatile FlowControl m_flowControl;
1758 volatile bool m_sentXOFF; // true if XOFF has been sent or RTS is disabled (high)
1759 volatile bool m_recvXOFF; // true if XOFF has been received
1760
1761 // hardware flow pins
1762 gpio_num_t m_rtsPin;
1763 gpio_num_t m_ctsPin;
1764 bool m_RTSStatus; // true = asserted (low)
1765
1766 // used to implement m_emuState.keyAutorepeat
1767 VirtualKey m_lastPressedKey;
1768
1769 uint8_t m_convMatchedCount;
1770 uint8_t m_convMatchedChars[EmuTerminalMaxChars];
1771 TermInfoVideoConv const * m_convMatchedItem;
1772 TermInfo const * m_termInfo;
1773
1774 // last char added with write()
1775 volatile uint8_t m_lastWrittenChar;
1776
1777 // when a FabGL sequence has been detected in write()
1778 volatile bool m_writeDetectedFabGLSeq;
1779
1780 // used by extGetIntParam(), extGetCmdParam(), extGetByteParam() to store next item (to avoid insertToInputQueue() which can cause dead-locks)
1781 int m_extNextCode; // -1 = no code
1782
1783 SoundGenerator * m_soundGenerator;
1784
1785 Sprite * m_sprites;
1786 int m_spritesCount;
1787
1788 bool m_coloredAttributesMaintainStyle;
1789 int m_coloredAttributesMask; // related bit 1 if enabled
1790 Color m_coloredAttributesColor[4];
1791
1792};
1793
1794
1795
1798// TerminalController
1799
1800
1815
1816public:
1817
1823 TerminalController(Terminal * terminal = nullptr);
1824
1826
1830 void clear();
1831
1837 void setTerminal(Terminal * terminal = nullptr);
1838
1844 void enableCursor(bool value);
1845
1852 void setCursorPos(int col, int row);
1853
1864 void getCursorPos(int * col, int * row);
1865
1873 void cursorLeft(int count);
1874
1882 void cursorRight(int count);
1883
1889 int getCursorCol();
1890
1896 int getCursorRow();
1897
1907 bool multilineInsertChar(int charsToMove);
1908
1916 void multilineDeleteChar(int charsToMove);
1917
1927 bool setChar(uint8_t c);
1928
1936 bool isVKDown(VirtualKey vk);
1937
1941 void disableFabGLSequences();
1942
1948 void setTerminalType(TermType value);
1949
1955 void setForegroundColor(Color value);
1956
1962 void setBackgroundColor(Color value);
1963
1970 void setCharStyle(CharStyle style, bool enabled);
1971
1972
1974
1983 Delegate<int *> onRead;
1984
1992 Delegate<int> onWrite;
1993
1994
1995private:
1996
1997 void waitFor(int value);
1998 void write(uint8_t c);
1999 void write(char const * str);
2000 int read();
2001
2002
2003 Terminal * m_terminal;
2004};
2005
2006
2007
2010// LineEditor
2011
2012
2017 CursorUp,
2018 CursorDown,
2019};
2020
2021
2044
2045public:
2046
2052 LineEditor(Terminal * terminal);
2053
2054 ~LineEditor();
2055
2072 void setText(char const * text, bool moveCursor = true);
2073
2084 void setText(char const * text, int length, bool moveCursor = true);
2085
2093 void typeText(char const * text);
2094
2104 char const * edit(int maxLength = 0);
2105
2111 char const * get() { return m_text; }
2112
2118 void setInsertMode(bool value) { m_insertMode = value; }
2119
2120
2121 // delegates
2122
2131 Delegate<int *> onRead;
2132
2140 Delegate<int> onWrite;
2141
2147 Delegate<int *> onChar;
2148
2158 Delegate<int *> onCarriageReturn;
2159
2165 Delegate<LineEditorSpecialChar> onSpecialChar;
2166
2167
2168private:
2169
2170 void beginInput();
2171 void endInput();
2172 void setLength(int newLength);
2173
2174 void write(uint8_t c);
2175 int read();
2176
2177 void performCursorUp();
2178 void performCursorDown();
2179 void performCursorLeft();
2180 void performCursorRight();
2181 void performCursorHome();
2182 void performCursorEnd();
2183 void performDeleteRight();
2184 void performDeleteLeft();
2185
2186
2187 Terminal * m_terminal;
2188 TerminalController m_termctrl;
2189 char * m_text;
2190 int m_textLength;
2191 int m_allocated;
2192 int16_t m_inputPos;
2193 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)
2194 int16_t m_homeCol;
2195 int16_t m_homeRow;
2196 bool m_insertMode;
2197 char * m_typeText;
2198 int m_typingIndex;
2199};
2200
2201
2202
2203} // end of namespace
2204
This file contains fabgl::Canvas definition.
Represents the base abstract class for all display controllers.
A class with a set of drawing methods.
Definition: canvas.h:70
The PS2 Keyboard controller class.
Definition: keyboard.h:77
char const * edit(int maxLength=0)
Reads user input and return the inserted line.
Definition: terminal.cpp:5390
Delegate< LineEditorSpecialChar > onSpecialChar
A delegate called whenever a special character has been pressed.
Definition: terminal.h:2165
void setInsertMode(bool value)
Sets insert mode state.
Definition: terminal.h:2118
void setText(char const *text, bool moveCursor=true)
Sets initial text.
Definition: terminal.cpp:5235
LineEditor(Terminal *terminal)
Object constructor.
Definition: terminal.cpp:5192
Delegate< int * > onChar
A delegate called whenever a character has been received.
Definition: terminal.h:2147
Delegate< int * > onRead
Read character delegate.
Definition: terminal.h:2131
void typeText(char const *text)
Simulates user typing.
Definition: terminal.cpp:5226
Delegate< int > onWrite
Write character delegate.
Definition: terminal.h:2140
Delegate< int * > onCarriageReturn
A delegate called whenever carriage return has been pressed.
Definition: terminal.h:2158
char const * get()
Gets current content.
Definition: terminal.h:2111
LineEditor is a single-line / multiple-rows editor which uses the Terminal object as input and output...
Definition: terminal.h:2043
SoundGenerator handles audio output.
Definition: soundgen.h:350
void connectLocally()
Permits using of terminal locally.
Definition: terminal.cpp:651
TermInfo const & terminalType()
Determines current terminal type.
Definition: terminal.h:1247
void setRTSStatus(bool value)
Sets RTS signal status.
Definition: terminal.cpp:501
void pollSerialPort()
Pools the serial port for incoming data.
Definition: terminal.cpp:1746
int getRows()
Returns the number of lines.
Definition: terminal.h:1217
bool waitFor(int value, int timeOutMS=-1)
Wait for a specific code from keyboard, discarding all previous codes.
Definition: terminal.cpp:1720
void clear(bool moveCursor=true)
Clears the screen.
Definition: terminal.cpp:1010
Delegate< VirtualKey *, bool > onVirtualKey
Delegate called whenever a new virtual key is received from keyboard.
Definition: terminal.h:1478
int available()
Gets the number of codes available in the keyboard queue.
Definition: terminal.cpp:1697
void setLogStream(Stream &stream)
Sets the stream where to output debugging logs.
Definition: terminal.h:1134
void disableSerialPortRX(bool value)
Disables/Enables serial port RX.
Definition: terminal.h:1060
bool RTSStatus()
Reports current RTS signal status.
Definition: terminal.h:1437
int getColumns()
Returns the number of columns.
Definition: terminal.h:1210
void loadFont(FontInfo const *font)
Sets the font to use.
Definition: terminal.cpp:806
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:1528
size_t write(const uint8_t *buffer, size_t size)
Sends specified number of codes to the display.
Definition: terminal.cpp:1958
void localInsert(uint8_t c)
Injects keys into the keyboard queue.
Definition: terminal.cpp:1667
void localWrite(uint8_t c)
Injects keys into the keyboard queue.
Definition: terminal.cpp:1674
Canvas * canvas()
Gets associated canvas object.
Definition: terminal.h:1372
void deactivate()
Deactivates this terminal.
Definition: terminal.cpp:290
Keyboard * keyboard()
Gets associated keyboard object.
Definition: terminal.h:1365
static int inputQueueSize
Number of characters the terminal can "write" without pause (increase if you have loss of characters ...
Definition: terminal.h:1510
int availableForWrite()
Determines number of codes that the display input queue can still accept.
Definition: terminal.cpp:1903
int peek()
Reads a code from the keyboard without advancing to the next one.
Definition: terminal.cpp:1733
void connectSerialPort(HardwareSerial &serialPort, bool autoXONXOFF=true)
Connects a remote host using the specified serial port.
Definition: terminal.cpp:441
bool isActive()
Determines if this terminal is active or not.
Definition: terminal.h:1394
void disconnectLocally()
Avoids using of terminal locally.
Definition: terminal.cpp:659
int read()
Reads codes from keyboard.
Definition: terminal.cpp:1703
void activate(TerminalTransition transition=TerminalTransition::None)
Activates this terminal for input and output.
Definition: terminal.cpp:215
void enableCursor(bool value)
Enables or disables cursor.
Definition: terminal.cpp:1115
static int inputConsumerTaskStackSize
Stack size of the task that processes Terminal input stream.
Definition: terminal.h:1519
void end()
Finalizes the terminal.
Definition: terminal.cpp:411
Delegate< VirtualKeyItem * > onVirtualKeyItem
Delegate called whenever a new virtual key is received from keyboard, including shift states.
Definition: terminal.h:1486
SoundGenerator * soundGenerator()
Gets embedded sound generator.
Definition: terminal.cpp:3549
void send(uint8_t c)
Like localWrite() but sends also to serial port if connected.
Definition: terminal.cpp:1824
bool CTSStatus()
Reports current CTS signal status.
Definition: terminal.h:1453
bool flowControl()
Checks whether host can receive data.
Definition: terminal.cpp:530
void flush()
Waits for all codes sent to the display has been processed.
Definition: terminal.cpp:1739
void setColorForAttribute(CharStyle attribute, Color color, bool maintainStyle)
Selects a color for the specified attribute.
Definition: terminal.cpp:977
void setTerminalType(TermType value)
Sets the terminal type to emulate.
Definition: terminal.cpp:1966
bool XOFFStatus()
Reports whether TX is active.
Definition: terminal.h:1430
void setBackgroundColor(Color color, bool setAsDefault=true)
Sets the background color.
Definition: terminal.cpp:920
bool begin(BaseDisplayController *displayController, int maxColumns=-1, int maxRows=-1, Keyboard *keyboard=nullptr)
Initializes the terminal.
Definition: terminal.cpp:323
Delegate< char const * > onUserSequence
Delegate called whenever a new user sequence has been received.
Definition: terminal.h:1496
void setForegroundColor(Color color, bool setAsDefault=true)
Sets the foreground color.
Definition: terminal.cpp:940
void unRead(uint8_t c)
Injects keys into the keyboard queue.
Definition: terminal.h:1119
void cursorRight(int count)
Moves cursor to the right.
Definition: terminal.cpp:5056
void disableFabGLSequences()
Disables FabGL specific sequences.
Definition: terminal.cpp:5141
void cursorLeft(int count)
Moves cursor to the left.
Definition: terminal.cpp:5046
void multilineDeleteChar(int charsToMove)
Deletes a character moving specified amount of characters to the left.
Definition: terminal.cpp:5109
bool isVKDown(VirtualKey vk)
Checks if a virtual key is currently down.
Definition: terminal.cpp:5130
bool multilineInsertChar(int charsToMove)
Inserts a blank character and move specified amount of characters to the right.
Definition: terminal.cpp:5097
int getCursorCol()
Gets current cursor column.
Definition: terminal.cpp:5077
bool setChar(uint8_t c)
Sets a raw character at current cursor position.
Definition: terminal.cpp:5119
void setTerminal(Terminal *terminal=nullptr)
Sets destination terminal.
Definition: terminal.cpp:4977
Delegate< int * > onRead
Read character delegate.
Definition: terminal.h:1983
int getCursorRow()
Gets current cursor row.
Definition: terminal.cpp:5087
Delegate< int > onWrite
Write character delegate.
Definition: terminal.h:1992
void getCursorPos(int *col, int *row)
Gets current cursor position.
Definition: terminal.cpp:5066
void enableCursor(bool value)
Enables/disables cursor.
Definition: terminal.cpp:5027
void setBackgroundColor(Color value)
Sets background color.
Definition: terminal.cpp:5167
TerminalController(Terminal *terminal=nullptr)
Object constructor.
Definition: terminal.cpp:4966
void clear()
Clears screen.
Definition: terminal.cpp:5019
void setCursorPos(int col, int row)
Sets current cursor position.
Definition: terminal.cpp:5036
void setTerminalType(TermType value)
Sets the terminal type to emulate.
Definition: terminal.cpp:5149
void setForegroundColor(Color value)
Sets foreground color.
Definition: terminal.cpp:5158
void setCharStyle(CharStyle style, bool enabled)
Enables or disables specified character style.
Definition: terminal.cpp:5176
TerminalController allows direct controlling of the Terminal object without using escape sequences.
Definition: terminal.h:1814
An ANSI-VT100 compatible display terminal.
Definition: terminal.h:953
GlyphOptions & Underline(bool value)
Helper method to set or reset underlined.
GlyphOptions & Italic(bool value)
Helper method to set or reset italic.
GlyphOptions & Bold(bool value)
Helper method to set or reset bold.
int16_t X
int16_t Y
GlyphOptions & Blank(uint8_t value)
Helper method to set or reset foreground and background swapping.
This file contains FabGL library configuration settings, like number of supported colors,...
int16_t X1
Definition: fabutils.h:0
int16_t Y2
Definition: fabutils.h:3
int16_t X2
Definition: fabutils.h:2
int16_t Y1
Definition: fabutils.h:1
TerminalTransition
This enum defines terminal transition effect.
Definition: terminal.h:751
CharStyle
This enum defines a character style.
Definition: terminal.h:737
@ ReducedLuminosity
Definition: terminal.h:739
@ Blink
Definition: terminal.h:742
@ Inverse
Definition: terminal.h:744
TermType
This enum defines supported terminals.
Definition: terminfo.h:110
LineEditorSpecialChar
Special character specified in on values from LineEditor::onSpecialChar delegate.
Definition: terminal.h:2016
Color
This enum defines named colors.
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:1097
FlowControl
This enum defines various serial port flow control methods.
Definition: terminal.h:706
This file contains fabgl::Keyboard definition.
This file contains all classes related to FabGL Sound System.
Specifies general paint options.
Represents a sprite.
A struct which contains a virtual key, key state and associated scan code.
Definition: fabutils.h:1381
This file contains terminal emulation definitions.
Specifies various glyph painting options.