VT100 Terminal App
Circle VT100 module documentation
Loading...
Searching...
No Matches
TSetup.h
1//------------------------------------------------------------------------------
2// Module: CTSetup
3// Description: Handles the VT100 setup dialog overlay.
4// Author: R. Zuehlsdorff, ralf.zuehlsdorff@t-online.de
5// Created: 2026-02-07
6// License: MIT License (https://opensource.org/license/mit/)
7//------------------------------------------------------------------------------
8
9#pragma once
10
11#include <circle/types.h>
12#include <circle/sched/task.h>
13#include <stddef.h>
14
15#include "TRenderer.h"
16#include "TKeyboard.h"
17
18class CTConfig;
19
20class CTSetup : public CTask
21{
22public:
24 static CTSetup *Get(void);
25
26 CTSetup();
27
28 bool Initialize(CTRenderer *renderer, CTConfig *config, CTKeyboard *keyboard);
29
30 void Toggle();
31 void Show();
32 void ShowModern();
33 void Hide();
34 bool IsVisible() const;
35
36 void Run(void) override;
37
38private:
39 enum TSetupPage
40 {
41 SetupPageA,
42 SetupPageB
43 };
44
45 enum TSetupBField
46 {
47 SetupBFieldToggle1,
48 SetupBFieldToggle2,
49 SetupBFieldToggle3,
50 SetupBFieldToggle4,
51 SetupBFieldTxSpeed,
52 SetupBFieldRxSpeed,
53 SetupBFieldCount
54 };
55
56 enum TDialogMode
57 {
58 DialogModeLegacy,
59 DialogModeModern
60 };
61
62 enum TModernField
63 {
64 ModernFieldLineEnding,
65 ModernFieldBaudRate,
66 ModernFieldSerialBits,
67 ModernFieldSerialParity,
68 ModernFieldCursorType,
69 ModernFieldCursorBlinking,
70 ModernFieldVTTest,
71 ModernFieldVT52Mode,
72 ModernFieldFontSelection,
73 ModernFieldTextColor,
74 ModernFieldBackgroundColor,
75 ModernFieldBuzzerVolume,
76 ModernFieldKeyClick,
77 ModernFieldKeyAutoRepeat,
78 ModernFieldRepeatDelay,
79 ModernFieldRepeatRate,
80 ModernFieldSwitchTxRx,
81 ModernFieldWlanHostAutoStart,
82 ModernFieldLogOutput,
83 ModernFieldLogFileName,
84 ModernFieldCount
85 };
86
87 struct TModernConfigState
88 {
89 unsigned int lineEnding;
90 unsigned int baudRate;
91 unsigned int serialBits;
92 unsigned int serialParity;
93 bool cursorBlock;
94 bool cursorBlinking;
95 bool vtTestEnabled;
96 bool vt52Mode;
97 EFontSelection fontSelection;
98 EColorSelection textColor;
99 EColorSelection backgroundColor;
100 unsigned int buzzerVolume;
101 bool keyClick;
102 bool keyAutoRepeat;
103 unsigned int repeatDelayMs;
104 unsigned int repeatRateCps;
105 bool switchTxRx;
106 unsigned int wlanModePolicy;
107 unsigned int logOutput;
108 char logFileName[64];
109 };
110
111 struct TModernLayoutState
112 {
113 unsigned rows;
114 unsigned cols;
115 unsigned top;
116 unsigned left;
117 unsigned width;
118 unsigned bottom;
119 unsigned innerWidth;
120 unsigned dataStartRow;
121 unsigned footerRow;
122 unsigned availableRows;
123 unsigned startIndex;
124 };
125
126 void Render();
127 void RenderPageA();
128 void RenderPageB();
129 void RenderHeader(const char *pTitle, unsigned topRow);
130 void InitializeSetupBFromConfig();
131 void ApplySetupBToConfig();
132 void MoveSetupBFieldLeft();
133 void MoveSetupBFieldRight();
134 void ToggleSetupBFieldBit(bool setOne);
135 void ChangeSetupBSpeed(bool increase);
136 void GetSetupBSpeedFieldPosition(TSetupBField field, unsigned &row, unsigned &col) const;
137 void UpdateTabCursor();
138 void UpdateTabCell();
139 void InitializeModernFromConfig();
140 void ApplyModernToConfig();
141 void RenderModernDialog();
142 bool ComputeModernLayout(TModernLayoutState &layout) const;
143 void RenderModernFieldRow(const TModernLayoutState &layout, unsigned fieldIndex, bool selected, const TRendererColor &fgColor, const TRendererColor &bgColor);
144 void RenderModernFieldRows(const TModernLayoutState &layout, const TRendererColor &fgColor, const TRendererColor &bgColor);
145 bool RenderModernSelectionDelta(TModernField previousSelected, unsigned previousStartIndex);
146 bool RenderModernValueDelta();
147 void HandleModernKeyPress(const char *pString);
148 void MoveModernSelection(int delta);
149 void ChangeModernValue(int delta);
150 void FormatModernValue(TModernField field, char *pBuffer, size_t bufferSize) const;
151
152 static void KeyPressedHandler(const char *pString);
153 static void KeyStatusHandlerRaw(unsigned char ucModifiers, const unsigned char RawKeys[6]);
154
155 void OnKeyPressed(const char *pString);
156 void OnRawKeyStatus(unsigned char ucModifiers, const unsigned char RawKeys[6]);
157
158private:
159 CTRenderer *m_pRenderer;
160 CTConfig *m_pConfig;
161 CTKeyboard *m_pKeyboard;
162 CTKeyboard::TKeyPressedHandler m_pPrevKeyPressed;
163 CTKeyboard::TKeyStatusHandlerRaw m_pPrevKeyStatusRaw;
164 struct TSetupSnapshot
165 {
166 u8 *buffer;
167 size_t size;
168 bool valid;
169 bool stateValid;
170 CTRenderer::TRendererState rendererState;
171 };
172 TSetupSnapshot m_Snapshot;
173 bool m_Visible;
174 bool m_ExitRequested;
175 bool m_SaveRequested;
176 bool m_KeyPending;
177 bool m_F12Down;
178 bool m_F11Down;
179 char m_KeyBuffer[32];
180 TDialogMode m_DialogMode;
181 TSetupPage m_Page;
182 unsigned m_SetupBToggle[4];
183 unsigned m_SetupBTxSpeed;
184 unsigned m_SetupBRxSpeed;
185 TSetupBField m_SetupBField;
186 unsigned m_SetupBBitIndex;
187 unsigned m_TabRow;
188 unsigned m_TabCols;
189 unsigned m_TabEditCol;
190 TModernField m_ModernSelected;
191 TModernConfigState m_ModernConfig;
192 bool m_ModernLayoutValid;
193 TModernLayoutState m_ModernLayout;
194
195};
Declares the USB keyboard task and input processing helpers.
Declares the VT100 renderer combining device and task interfaces.
Cooperative task responsible for configuration persistence and lookup.
Definition TConfig.h:54
Cooperative task managing keyboard devices and event translation.
Definition TKeyboard.h:46
Combines Circle framebuffer access with a VT100-aware state machine.
Definition TRenderer.h:51
Definition TSetup.h:21
static CTSetup * Get(void)
Access the singleton setup dialog instance.
Definition TSetup.cpp:172
Definition TRenderer.h:61