Public Access
Fn+p saves the screen as it is to /screenshots, as the Shell's `screenshot` does, from anywhere: text fields, dialogs and the help panel included. The key never reaches an App. It refuses on Settings > Debug Console, which shows the token: a picture of that page is a copy of the token in a file (App::showsSecret). `key shot` presses it over the consoles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
66 lines
2.1 KiB
C++
66 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
#include "key_event.h"
|
|
#include "key_help.h"
|
|
|
|
namespace roro {
|
|
|
|
class Canvas; // provided by the widget kit
|
|
|
|
// A foreground, user-facing program (see CONTEXT.md). Exactly one App is on screen at a time.
|
|
class App {
|
|
public:
|
|
virtual ~App() = default;
|
|
|
|
virtual void onEnter() {}
|
|
virtual void onExit() {}
|
|
|
|
// Return true if the key was consumed. An unconsumed Back leaves the App.
|
|
virtual bool onKey(const KeyEvent& event) {
|
|
(void)event;
|
|
return false;
|
|
}
|
|
|
|
// True while the App is editing text: the arrow keys then type ; . , / and need Fn to move.
|
|
virtual bool textEntryActive() const { return false; }
|
|
|
|
// The keys that work right now, for the help panel (Fn+h): the App's own, in the state it's
|
|
// in. Back, Home and the arrows are added for it. No screen names keys any other way.
|
|
virtual void help(std::vector<KeyHelp>& out) const { (void)out; }
|
|
// What the panel is titled with, when the App's name isn't enough ("Notes: editor").
|
|
virtual const char* helpTitle() const { return nullptr; }
|
|
|
|
// Called every main-loop pass while in the foreground (e.g. to refresh live values).
|
|
virtual void update(uint32_t nowMs) { (void)nowMs; }
|
|
|
|
virtual void draw(Canvas& canvas) = 0;
|
|
|
|
// True while the screen shows something a picture of it shouldn't hold: the screenshot key
|
|
// (Fn+p, issue #83) then refuses, and says so.
|
|
virtual bool showsSecret() const { return false; }
|
|
|
|
// An App whose screen is costly to draw again (a picture decoded from the card, issue #45) can
|
|
// keep what it drew: while this is true its part of the screen isn't cleared before draw(),
|
|
// which then draws only what changed. contentLost() says that it was cleared after all, or
|
|
// that something drawn over it has gone: everything has to be drawn again.
|
|
virtual bool retainsContent() const { return false; }
|
|
virtual void contentLost() {}
|
|
|
|
void requestRedraw() { redraw_ = true; }
|
|
|
|
bool consumeRedraw() {
|
|
bool r = redraw_;
|
|
redraw_ = false;
|
|
return r;
|
|
}
|
|
|
|
private:
|
|
bool redraw_ = false;
|
|
};
|
|
|
|
} // namespace roro
|