Skip to content

Commit 9aa074c

Browse files
committed
Support C0 cursor movement in console
1 parent 86c7f96 commit 9aa074c

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

ext/firmware

src/ui/ui_console.cc

+35
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,41 @@ void ui_console_draw(ui_console_t* win) {
160160
rb_put(win->rx, '\r'); // CR
161161
rb_put(win->rx, '\n'); // LF
162162
}
163+
if (ImGui::IsKeyPressed(ImGuiKey::ImGuiKey_Delete)) {
164+
rb_put(win->rx, 0x7F);
165+
}
166+
167+
// C0
168+
if (ImGui::IsKeyPressed(ImGuiKey::ImGuiKey_Backspace)) {
169+
rb_put(win->rx, '\b');
170+
}
171+
if (ImGui::IsKeyPressed(ImGuiKey::ImGuiKey_Tab)) {
172+
rb_put(win->rx, '\t');
173+
}
174+
if (ImGui::IsKeyPressed(ImGuiKey::ImGuiKey_Escape)) {
175+
rb_put(win->rx, 0x1B);
176+
}
177+
// CSI
178+
if (ImGui::IsKeyPressed(ImGuiKey::ImGuiKey_UpArrow)) {
179+
rb_put(win->rx, 0x1B); // ESC
180+
rb_put(win->rx, '[');
181+
rb_put(win->rx, 'A');
182+
}
183+
if (ImGui::IsKeyPressed(ImGuiKey::ImGuiKey_DownArrow)) {
184+
rb_put(win->rx, 0x1B); // ESC
185+
rb_put(win->rx, '[');
186+
rb_put(win->rx, 'B');
187+
}
188+
if (ImGui::IsKeyPressed(ImGuiKey::ImGuiKey_RightArrow)) {
189+
rb_put(win->rx, 0x1B); // ESC
190+
rb_put(win->rx, '[');
191+
rb_put(win->rx, 'C');
192+
}
193+
if (ImGui::IsKeyPressed(ImGuiKey::ImGuiKey_LeftArrow)) {
194+
rb_put(win->rx, 0x1B); // ESC
195+
rb_put(win->rx, '[');
196+
rb_put(win->rx, 'D');
197+
}
163198
}
164199

165200
ImGui::End();

0 commit comments

Comments
 (0)