Help: Fn+h lists the keys of the screen you're on, and no screen names its keys any more (#69)
CI / build (pull_request) Successful in 7m22s
Site / build (pull_request) Successful in 14s

Fn+h on any screen, text fields included, and ? outside Text Entry, open a
panel over the content area: the screen's own keys, then the ones that work
everywhere. Every App declares its keys for the state it is in (pages,
viewers, dialogs and text fields answer for themselves); the App manager
opens the panel and takes every key while it is open.

About 30 hint lines are gone, from every App. What stays on a screen is
state. The first-start Setup keeps its hints and teaches the key; a device
set up before gets one Toast, once. The guide and the FAQ open with it.
`key help` over the consoles.

476 host tests (8 new). Checked on the device with key help and screenshots:
the Launcher, all nine Apps and several of their states. 8.5 KB of flash and
40 bytes of static RAM. Decisions Q196 to Q203 in docs/milestones/U1.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-07 01:29:51 +02:00
co-authored by Claude Opus 5.5
parent 1c6ae0e04f
commit 7fe8b3d22a
62 changed files with 855 additions and 81 deletions
+92
View File
@@ -0,0 +1,92 @@
#pragma once
#include <algorithm>
#include <string>
#include <vector>
#include "key_event.h"
// The help panel (issue #69, docs/milestones/U1.md): Fn+h on any screen lists the keys that work
// there. Every App says what its keys are in the state it's in; nothing on a screen names keys.
namespace roro {
// One line of the panel: a key (or keys) and what it does. A line with no action is a heading.
struct KeyHelp {
const char* keys;
const char* action;
};
namespace help {
// Lists that several screens share.
inline void list(std::vector<KeyHelp>& out, const char* enter = "open") {
out.push_back({"; .", "up, down"});
out.push_back({"Enter", enter});
}
inline void dialog(std::vector<KeyHelp>& out) {
out.push_back({", /", "the other answer"});
out.push_back({"Enter", "choose it"});
out.push_back({"`", "cancel"});
}
inline void textEntry(std::vector<KeyHelp>& out, const char* enter = "save") {
out.push_back({"Enter", enter});
out.push_back({"`", "cancel"});
out.push_back({"Del", "delete backwards"});
out.push_back({"Fn , /", "move the cursor"});
out.push_back({"opt ' e", "an accent: \xC3\xA9"});
}
// What works on every screen: the end of every panel.
inline void everywhere(std::vector<KeyHelp>& out) {
out.push_back({"Everywhere", nullptr});
out.push_back({"`", "back"});
out.push_back({"Fn `", "home, the Launcher"});
out.push_back({"; . , /", "arrows (Fn+ while typing)"});
out.push_back({"Fn h ?", "these keys (? not typing)"});
}
} // namespace help
// The panel itself: what it lists, and how far it's scrolled. The keys it takes while open are the
// arrows; any other key closes it, and none reaches the App.
class HelpModel {
public:
explicit HelpModel(int visibleRows = 8) : visible_(visibleRows) {}
void open(const std::string& title, std::vector<KeyHelp> rows) {
title_ = title;
rows_ = std::move(rows);
top_ = 0;
open_ = true;
}
void close() {
open_ = false;
rows_.clear();
rows_.shrink_to_fit(); // nothing is kept while it's closed
}
bool isOpen() const { return open_; }
void onKey(const KeyEvent& e) {
int last = std::max(0, static_cast<int>(rows_.size()) - visible_);
switch (e.key) {
case Key::Up: top_ = std::max(0, top_ - 1); break;
case Key::Down: top_ = std::min(last, top_ + 1); break;
case Key::Left: top_ = std::max(0, top_ - visible_); break;
case Key::Right: top_ = std::min(last, top_ + visible_); break;
default: close(); break;
}
}
const std::string& title() const { return title_; }
const std::vector<KeyHelp>& rows() const { return rows_; }
int top() const { return top_; }
int visibleRows() const { return visible_; }
private:
std::string title_;
std::vector<KeyHelp> rows_;
int top_ = 0;
int visible_;
bool open_ = false;
};
} // namespace roro