42 #include "freertos/FreeRTOS.h" 43 #include "freertos/task.h" 44 #include "freertos/timers.h" 45 #include "freertos/semphr.h" 709 struct TerminalCursorState {
710 TerminalCursorState * next;
714 bool cursorPastLastCol;
716 GlyphOptions glyphOptions;
717 uint8_t characterSetIndex;
718 uint8_t characterSet[4];
755 uint8_t characterSetIndex;
758 uint8_t characterSet[4];
760 Color foregroundColor;
761 Color backgroundColor;
767 bool cursorPastLastCol;
774 int scrollingRegionTop;
775 int scrollingRegionDown;
780 bool cursorBlinkingEnabled;
802 KeypadMode keypadMode;
808 int conformanceLevel;
815 bool allow132ColumnMode;
817 bool reverseWraparoundMode;
820 bool backarrowKeyMode;
826 bool VT52GraphicsMode;
829 int allowFabGLSequences;
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) {
841 return write((
const uint8_t *)str, strlen(str));
843 void printf(
const char * format, ...) {
845 va_start(ap, format);
846 int size = vsnprintf(
nullptr, 0, format, ap) + 1;
849 va_start(ap, format);
851 auto l = vsnprintf(buf, size, format, ap);
852 write((uint8_t*)buf, l);
858 struct Stream :
public Print{
861 #endif // ifdef ARDUINO 1126 void logFmt(
const char * format, ...);
1127 void log(
const char * txt);
1140 void loadFont(FontInfo
const * font);
1185 void clear(
bool moveCursor =
true);
1193 void flush(
bool waitVSync);
1270 int read(
int timeOutMS);
1282 bool waitFor(
int value,
int timeOutMS = -1);
1320 size_t write(
const uint8_t * buffer,
size_t size);
1331 size_t write(uint8_t c);
1340 void send(uint8_t c);
1347 void send(
char const * str);
1444 void clearMap(uint32_t * map);
1447 void freeTabStops();
1448 void freeGlyphsMap();
1450 void set132ColumnMode(
bool value);
1454 void move(
int offset);
1455 void setCursorPos(
int X,
int Y);
1456 int getAbsoluteRow(
int Y);
1458 void int_setBackgroundColor(
Color color);
1459 void int_setForegroundColor(
Color color);
1461 void syncDisplayController();
1465 void setTabStop(
int column,
bool set);
1466 void resetTabStops();
1470 void scrollDownAt(
int startingRow);
1472 void scrollUpAt(
int startingRow);
1473 void setScrollingRegion(
int top,
int down,
bool resetCursorPos =
true);
1474 void updateCanvasScrollingRegion();
1477 void saveCursorState();
1478 void restoreCursorState();
1479 void clearSavedCursorStates();
1481 void erase(
int X1,
int Y1,
int X2,
int Y2, uint8_t c,
bool maintainDoubleWidth,
bool selective);
1483 void consumeInputQueue();
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);
1494 void execSGRParameters(
int const * params,
int paramsCount);
1495 void consumeESCVT52();
1497 void execCtrlCode(uint8_t c);
1499 static void charsConsumerTask(
void * pvParameters);
1500 static void keyboardReaderTask(
void * pvParameters);
1502 static void blinkTimerFunc(TimerHandle_t xTimer);
1504 bool enableBlinkingText(
bool value);
1506 bool int_enableCursor(
bool value);
1508 static void IRAM_ATTR uart_isr(
void *arg);
1510 uint8_t getNextCode(
bool processCtrlCodes);
1512 bool setChar(uint8_t c);
1515 void insertAt(
int column,
int row,
int count);
1516 void deleteAt(
int column,
int row,
int count);
1518 bool multilineInsertChar(
int charsToMove);
1519 void multilineDeleteChar(
int charsToMove);
1521 void reverseVideo(
bool value);
1524 void refresh(
int X,
int Y);
1525 void refresh(
int X1,
int Y1,
int X2,
int Y2);
1527 void setLineDoubleWidth(
int row,
int value);
1528 int getCharWidthAt(
int row);
1529 int getColumnsAt(
int row);
1531 void useAlternateScreenBuffer(
bool value);
1536 void sendCursorKeyCode(uint8_t c);
1537 void sendKeypadCursorKeyCode(uint8_t applicationCode,
const char * numericCode);
1542 void convHandleTranslation(uint8_t c,
bool fromISR);
1543 void convSendCtrl(ConvCtrl ctrl,
bool fromISR);
1544 void convQueue(
const char * str,
bool fromISR);
1547 bool addToInputQueue(uint8_t c,
bool fromISR);
1548 bool insertToInputQueue(uint8_t c,
bool fromISR);
1550 void write(uint8_t c,
bool fromISR);
1554 void uartCheckInputQueueForFlowControl();
1556 void enableFabGLSequences(
bool value);
1558 void int_setTerminalType(
TermType value);
1559 void int_setTerminalType(TermInfo
const * value);
1561 void sound(
int waveform,
int frequency,
int duration,
int volume);
1563 uint8_t extGetByteParam();
1564 int extGetIntParam();
1565 void extGetCmdParam(
char * cmd);
1570 static Terminal * s_activeTerminal;
1575 bool m_bitmappedDisplayController;
1579 Stream * m_logStream;
1583 GlyphsBuffer m_glyphsBuffer;
1586 uint32_t * m_alternateMap;
1589 bool m_alternateScreenBuffer;
1592 int m_alternateCursorX;
1593 int m_alternateCursorY;
1594 int m_alternateScrollingRegionTop;
1595 int m_alternateScrollingRegionDown;
1596 bool m_alternateCursorBlinkingEnabled;
1603 EmuState m_emuState;
1605 Color m_defaultForegroundColor;
1606 Color m_defaultBackgroundColor;
1609 bool m_prevCursorEnabled;
1610 bool m_prevBlinkingTextEnabled;
1613 TaskHandle_t m_charsConsumerTaskHandle;
1616 TaskHandle_t m_keyboardReaderTaskHandle;
1619 volatile bool m_cursorState;
1622 TimerHandle_t m_blinkTimer;
1625 volatile SemaphoreHandle_t m_mutex;
1627 volatile bool m_blinkingTextVisible;
1628 volatile bool m_blinkingTextEnabled;
1630 volatile int m_columns;
1631 volatile int m_rows;
1641 HardwareSerial * m_serialPort;
1647 volatile bool m_uart;
1650 volatile bool m_uartRXEnabled;
1653 volatile QueueHandle_t m_inputQueue;
1656 QueueHandle_t m_outputQueue;
1659 TerminalCursorState * m_savedCursorStateList;
1662 bool m_resetRequested;
1664 volatile bool m_autoXONOFF;
1665 volatile bool m_XOFF;
1670 uint8_t m_convMatchedCount;
1671 uint8_t m_convMatchedChars[EmuTerminalMaxChars];
1672 TermInfoVideoConv
const * m_convMatchedItem;
1673 TermInfo
const * m_termInfo;
1676 volatile uint8_t m_lastWrittenChar;
1679 volatile bool m_writeDetectedFabGLSeq;
1894 void waitFor(
int value);
1895 void write(uint8_t c);
1896 void write(
char const * str);
1969 void setText(
char const * text,
bool moveCursor =
true);
1981 void setText(
char const * text,
int length,
bool moveCursor =
true);
2001 char const *
edit(
int maxLength = 0);
2008 char const *
get() {
return m_text; }
2069 void setLength(
int newLength);
2071 void write(uint8_t c);
2074 void performCursorUp();
2075 void performCursorDown();
2076 void performCursorLeft();
2077 void performCursorRight();
2078 void performCursorHome();
2079 void performCursorEnd();
2080 void performDeleteRight();
2081 void performDeleteLeft();
Delegate< int > onWrite
Write character delegate.
GlyphOptions & Bold(bool value)
Helper method to set or reset bold.
void flush()
Waits for all codes sent to the display has been processed.
Delegate< int * > onCarriageReturn
A delegate called whenever carriage return has been pressed.
void end()
Finalizes the terminal.
void disconnectLocally()
Avoids using of terminal locally.
A class with a set of drawing methods.
void activate(TerminalTransition transition=TerminalTransition::None)
Activates this terminal for input and output.
void setForegroundColor(Color value)
Sets foreground color.
void disableSerialPortRX(bool value)
Disables/Enables serial port RX.
TerminalController(Terminal *terminal=nullptr)
Object constructor.
char const * edit(int maxLength=0)
Reads user input and return the inserted line.
void connectLocally()
Permits using of terminal locally.
bool waitFor(int value, int timeOutMS=-1)
Wait for a specific code from keyboard, discarding all previous codes.
void setCursorPos(int col, int row)
Sets current cursor position.
Delegate< int * > onRead
Read character delegate.
void typeText(char const *text)
Simulates user typing.
This file contains terminal emulation definitions.
int getColumns()
Returns the number of columns.
void setLogStream(Stream &stream)
Sets the stream where to output debugging logs.
GlyphOptions & Italic(bool value)
Helper method to set or reset italic.
This file contains fabgl::Keyboard definition.
FlowControl
This enum defines various serial port flow control methods.
void setForegroundColor(Color color, bool setAsDefault=true)
Sets the foreground color.
static int inputQueueSize
Number of characters the terminal can "write" without pause (increase if you have loss of characters ...
bool multilineInsertChar(int charsToMove)
Inserts a blank character and move specified amount of characters to the right.
TerminalTransition
This enum defines terminal transition effect.
void enableCursor(bool value)
Enables or disables cursor.
Color
This enum defines named colors.
The PS2 Keyboard controller class.
CharStyle
This enum defines a character style.
This file contains fabgl::Canvas definition.
void getCursorPos(int *col, int *row)
Gets current cursor position.
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
void pollSerialPort()
Pools the serial port for incoming data.
void setInsertMode(bool value)
Sets insert mode state.
int getRows()
Returns the number of lines.
void setCharStyle(CharStyle style, bool enabled)
Enables or disables specified character style.
size_t write(const uint8_t *buffer, size_t size)
Sends specified number of codes to the display.
static int keyboardReaderTaskStackSize
Stack size of the task that reads keys from keyboard and send ANSI/VT codes to output stream in Termi...
Delegate< char const * > onUserSequence
Delegate called whenever a new user sequence has been received.
int read()
Reads codes from keyboard.
Delegate< int * > onRead
Read character delegate.
TerminalController allows direct controlling of the Terminal object without using escape sequences...
GlyphOptions & Underline(bool value)
Helper method to set or reset underlined.
LineEditorSpecialChar
Special character specified in on values from LineEditor::onSpecialChar delegate. ...
bool begin(BaseDisplayController *displayController, int maxColumns=-1, int maxRows=-1, Keyboard *keyboard=nullptr)
Initializes the terminal.
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...
void multilineDeleteChar(int charsToMove)
Deletes a character moving specified amount of characters to the left.
int getCursorRow()
Gets current cursor row.
Specifies various glyph painting options.
static int inputConsumerTaskStackSize
Stack size of the task that processes Terminal input stream.
int available()
Gets the number of codes available in the keyboard queue.
LineEditor(Terminal *terminal)
Object constructor.
int peek()
Reads a code from the keyboard without advancing to the next one.
SoundGenerator handles audio output.
void setBackgroundColor(Color value)
Sets background color.
bool setChar(uint8_t c)
Sets a raw character at current cursor position.
int availableForWrite()
Determines number of codes that the display input queue can still accept.
This file contains FabGL library configuration settings, like number of supported colors...
This file contains all classes related to FabGL Sound System.
void setText(char const *text, bool moveCursor=true)
Sets initial text.
void cursorRight(int count)
Moves cursor to the right.
void setBackgroundColor(Color color, bool setAsDefault=true)
Sets the background color.
An ANSI-VT100 compatible display terminal.
void setTerminal(Terminal *terminal=nullptr)
Sets destination terminal.
int getCursorCol()
Gets current cursor column.
void clear(bool moveCursor=true)
Clears the screen.
TermType
This enum defines supported terminals.
void setTerminalType(TermType value)
Sets the terminal type to emulate.
bool isVKDown(VirtualKey vk)
Checks if a virtual key is currently down.
TermInfo const & terminalType()
Determines current terminal type.
void clear()
Clears screen.
void connectSerialPort(HardwareSerial &serialPort, bool autoXONXOFF=true)
Connects a remote host using the specified serial port.
Delegate< int > onWrite
Write character delegate.
void cursorLeft(int count)
Moves cursor to the left.
Represents the base abstract class for all display controllers.
Delegate< int * > onChar
A delegate called whenever a character has been received.
void send(uint8_t c)
Like localWrite() but sends also to serial port if connected.
void disableFabGLSequences()
Disables FabGL specific sequences.
Delegate< VirtualKey *, bool > onVirtualKey
Delegate called whenever a new virtual key is received from keyboard.
void setTerminalType(TermType value)
Sets the terminal type to emulate.
void loadFont(FontInfo const *font)
Sets the font to use.
void unRead(uint8_t c)
Injects keys into the keyboard queue.
void deactivate()
Deactivates this terminal.
void localInsert(uint8_t c)
Injects keys into the keyboard queue.
Canvas * canvas()
Gets associated canvas object.
Keyboard * keyboard()
Gets associated keyboard object.
Specifies general paint options.
Delegate< LineEditorSpecialChar > onSpecialChar
A delegate called whenever a special character has been pressed.
bool isActive()
Determines if this terminal is active or not.
void enableCursor(bool value)
Enables/disables cursor.
void localWrite(uint8_t c)
Injects keys into the keyboard queue.