mirror of
https://gitlab.com/c3d/db48x.git
synced 2024-09-29 05:36:58 +02:00
Add markdown-based on-line help
This is distantly derived from the help system I implemented for newRPL, but the low-memory condition on the DM42 means we try to do everything without allocating any memory. Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
parent
0bc61ae6bc
commit
a2cc082db9
5 changed files with 999 additions and 100 deletions
9
Makefile
9
Makefile
|
@ -25,9 +25,10 @@ EJECT=hdiutil eject $(MOUNTPOINT)
|
|||
|
||||
# default action: build all
|
||||
all: $(TARGET).pgm help/$(TARGET).html
|
||||
install: all
|
||||
(tar cf - $(TARGET).pgm help/$(TARGET).html | (cd $(MOUNTPOINT) && tar xvf -)) && $(EJECT)
|
||||
sim: sim/simulator.mak recorder/config.h .ALWAYS
|
||||
install: all help/$(TARGET).md
|
||||
(tar cf - $(TARGET).pgm help/$(TARGET).html help/$(TARGET).md | \
|
||||
(cd $(MOUNTPOINT) && tar xvf -)) && $(EJECT)
|
||||
sim: sim/simulator.mak recorder/config.h help/$(TARGET).md .ALWAYS
|
||||
cd sim; make -f $(<F)
|
||||
sim/simulator.mak: sim/simulator.pro
|
||||
cd sim; qmake $(<F) -o $(@F) CONFIG+=$(OPT)
|
||||
|
@ -40,6 +41,8 @@ fonts/EditorFont.cc: ttf2font $(C43S_FONT)
|
|||
tools/ttf2font/ttf2font -s 60 EditorFont $(C43S_FONT) $@
|
||||
fonts/StackFont.cc: ttf2font $(C43S_FONT)
|
||||
tools/ttf2font/ttf2font -s 40 StackFont $(C43S_FONT) $@
|
||||
help/$(TARGET).md: $(wildcard doc/calc-help/*.md doc/commands/*.md)
|
||||
cat $^ > $@
|
||||
|
||||
debug-%:
|
||||
$(MAKE) $* OPT=debug
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
s# Main menus in newRPL
|
||||
# Negate
|
||||
|
||||
Here are the main menus in newRPL, in alphabetical order.
|
||||
## Main menus in DB48X
|
||||
|
||||
Here are the main menus in DB48X, in alphabetical order.
|
||||
|
||||
|
||||
## Main menu
|
||||
|
@ -15,6 +17,11 @@ by cathegory. It includes the following submenus:
|
|||
* Prog: Programming
|
||||
* Vars: User variables
|
||||
|
||||
The [Math menu](#math-menu) is the most useful one.
|
||||
Another [good menu](#arithmetic-menu).
|
||||
|
||||
If you are looking for [Swap](#swap), click [Here](#stkdrop)
|
||||
|
||||
|
||||
## Math menu
|
||||
|
||||
|
@ -31,7 +38,7 @@ calculator. It includes the following submenus:
|
|||
|
||||
## Arithmetic menu
|
||||
|
||||
THe *Arithmetic menu* gives access to arithmetic functions in your
|
||||
The *Arithmetic menu* gives access to arithmetic functions in your
|
||||
calculator. It includes the following submenus:
|
||||
|
||||
* Real: Operations on real numbers
|
||||
|
|
924
src/input.cc
924
src/input.cc
File diff suppressed because it is too large
Load diff
96
src/input.h
96
src/input.h
|
@ -29,9 +29,13 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// ****************************************************************************
|
||||
|
||||
#include "types.h"
|
||||
#include "object.h"
|
||||
#include "graphics.h"
|
||||
#include "object.h"
|
||||
#include "types.h"
|
||||
#include "dmcp.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct runtime;
|
||||
|
||||
|
@ -79,14 +83,18 @@ struct input
|
|||
void draw_editor();
|
||||
int draw_cursor();
|
||||
void draw_error();
|
||||
int stack_screen_bottom() { return stack; }
|
||||
|
||||
bool draw_help();
|
||||
void draw_command();
|
||||
int stack_screen_bottom() { return stack; }
|
||||
bool showingHelp() { return help + 1 != 0; }
|
||||
|
||||
protected:
|
||||
bool end_edit();
|
||||
void clear_editor();
|
||||
void load_help(utf8 topic);
|
||||
|
||||
bool handle_shifts(int key);
|
||||
bool handle_help(int &key);
|
||||
bool handle_editing(int key);
|
||||
bool handle_alpha(int key);
|
||||
bool handle_functions(int key);
|
||||
|
@ -95,38 +103,74 @@ protected:
|
|||
bool handle_enter(int key);
|
||||
bool handle_backspace(int key);
|
||||
|
||||
uint shift_plane() { return xshift ? 2 : shift ? 1 : 0; }
|
||||
uint shift_plane() { return xshift ? 2 : shift ? 1 : 0; }
|
||||
|
||||
void clear_help();
|
||||
object_p object_for_key(int key);
|
||||
|
||||
protected:
|
||||
typedef graphics::coord coord;
|
||||
typedef graphics::size size;
|
||||
typedef graphics::coord coord;
|
||||
typedef graphics::size size;
|
||||
|
||||
uint cursor; // Cursor position in buffer
|
||||
coord xoffset; // Offset of the cursor
|
||||
modes mode; // Current editing mode
|
||||
int last; // Last key
|
||||
int stack; // Vertical bottom of the stack
|
||||
coord cx, cy; // Cursor position on screen
|
||||
utf8code cchar; // Character under the cursor
|
||||
bool shift : 1; // Normal shift active
|
||||
bool xshift : 1; // Extended shift active (simulate Right)
|
||||
bool alpha : 1; // Alpha mode active
|
||||
bool lowercase : 1; // Lowercase
|
||||
bool hideMenu : 1; // Hide the menu
|
||||
bool down : 1; // Move one line down
|
||||
bool up : 1; // Move one line up
|
||||
bool repeat : 1; // Repeat the key
|
||||
bool longpress : 1; // We had a long press of the key
|
||||
bool blink : 1; // Cursor blink indicator
|
||||
protected:
|
||||
utf8 command; // Command being executed
|
||||
uint help; // Offset of help being displayed in help file
|
||||
uint line; // Line offset in the help display
|
||||
uint topic; // Offset of topic being highlighted
|
||||
uint history; // History depth
|
||||
uint topics[8]; // Topics history
|
||||
uint cursor; // Cursor position in buffer
|
||||
coord xoffset; // Offset of the cursor
|
||||
modes mode; // Current editing mode
|
||||
int last; // Last key
|
||||
int stack; // Vertical bottom of the stack
|
||||
coord cx, cy; // Cursor position on screen
|
||||
utf8code cchar; // Character under the cursor
|
||||
bool shift : 1; // Normal shift active
|
||||
bool xshift : 1; // Extended shift active (simulate Right)
|
||||
bool alpha : 1; // Alpha mode active
|
||||
bool lowercase : 1; // Lowercase
|
||||
bool hideMenu : 1; // Hide the menu
|
||||
bool down : 1; // Move one line down
|
||||
bool up : 1; // Move one line up
|
||||
bool repeat : 1; // Repeat the key
|
||||
bool longpress : 1; // We had a long press of the key
|
||||
bool blink : 1; // Cursor blink indicator
|
||||
bool follow : 1; // Follow a help topic
|
||||
|
||||
protected:
|
||||
// Key mappings
|
||||
object_p function[NUM_PLANES][NUM_KEYS];
|
||||
char menu_label[NUM_PLANES][NUM_SOFTKEYS][NUM_LABEL_CHARS];
|
||||
object_p function[NUM_PLANES][NUM_KEYS];
|
||||
char menu_label[NUM_PLANES][NUM_SOFTKEYS][NUM_LABEL_CHARS];
|
||||
static runtime &RT;
|
||||
friend struct tests;
|
||||
friend struct runtime;
|
||||
|
||||
protected:
|
||||
struct file
|
||||
// ------------------------------------------------------------------------
|
||||
// Direct access to the help file
|
||||
// ------------------------------------------------------------------------
|
||||
{
|
||||
file(cstring path);
|
||||
~file();
|
||||
|
||||
bool valid();
|
||||
utf8code get();
|
||||
utf8code get(uint offset);
|
||||
void seek(uint offset);
|
||||
utf8code peek();
|
||||
uint position();
|
||||
uint find(utf8code cp);
|
||||
uint rfind(utf8code cp);
|
||||
|
||||
protected:
|
||||
#ifdef SIMULATOR
|
||||
FILE *data;
|
||||
#else
|
||||
FIL data;
|
||||
#endif
|
||||
} helpfile;
|
||||
};
|
||||
|
||||
|
||||
|
|
57
src/main.cc
57
src/main.cc
|
@ -33,10 +33,10 @@
|
|||
#include "graphics.h"
|
||||
#include "input.h"
|
||||
#include "integer.h"
|
||||
#include "rplstring.h"
|
||||
#include "menu.h"
|
||||
#include "num.h"
|
||||
#include "rpl.h"
|
||||
#include "rplstring.h"
|
||||
#include "settings.h"
|
||||
#include "stack.h"
|
||||
#include "target.h"
|
||||
|
@ -50,10 +50,10 @@
|
|||
#include <cstring>
|
||||
#include <dmcp.h>
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::min;
|
||||
|
||||
static int fontnr = 0;
|
||||
static int fontnr = 0;
|
||||
|
||||
|
||||
static void redraw_lcd()
|
||||
|
@ -68,10 +68,14 @@ static void redraw_lcd()
|
|||
// Draw the various components handled by input
|
||||
Input.draw_annunciators();
|
||||
Input.draw_menus();
|
||||
Input.draw_editor();
|
||||
Input.draw_cursor();
|
||||
Stack.draw_stack();
|
||||
Input.draw_error();
|
||||
if (!Input.draw_help())
|
||||
{
|
||||
Input.draw_editor();
|
||||
Input.draw_cursor();
|
||||
Stack.draw_stack();
|
||||
Input.draw_command();
|
||||
Input.draw_error();
|
||||
}
|
||||
|
||||
// Refres the screen
|
||||
lcd_refresh_lines(0, LCD_H);
|
||||
|
@ -119,11 +123,22 @@ void program_init()
|
|||
byte *memory = (byte *) malloc(size);
|
||||
runtime::RT.memory(memory, size);
|
||||
|
||||
// Fake test menu
|
||||
cstring labels[input::NUM_MENUS] = {
|
||||
"Short", "A bit long", "Very long", "Super Duper long",
|
||||
"X1", "X2", "A", "B",
|
||||
"C", "D", "E", "F",
|
||||
"X", "Y", "Z", "T",
|
||||
"U", "V",
|
||||
};
|
||||
object_p functions[input::NUM_MENUS] = { MenuFont };
|
||||
Input.menus(labels, functions);
|
||||
|
||||
// The following is just to link the same set of functions as DM42
|
||||
if (memory == (byte *) program_init)
|
||||
{
|
||||
double d = *memory;
|
||||
BID_UINT64 a;
|
||||
double d = *memory;
|
||||
BID_UINT64 a;
|
||||
BID_UINT128 res;
|
||||
binary64_to_bid64(&a, &d);
|
||||
bid64_to_bid128(&res, &a);
|
||||
|
@ -166,7 +181,7 @@ extern "C" void program_main()
|
|||
redraw_lcd();
|
||||
|
||||
// Main loop
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
// Already in off mode and suspended
|
||||
if ((ST(STAT_PGM_END) && ST(STAT_SUSPENDED)) ||
|
||||
|
@ -220,7 +235,7 @@ extern "C" void program_main()
|
|||
if (!key_empty())
|
||||
{
|
||||
reset_auto_off();
|
||||
key = key_pop();
|
||||
key = key_pop();
|
||||
hadKey = true;
|
||||
}
|
||||
if (sys_timer_timeout(TIMER0))
|
||||
|
@ -242,20 +257,24 @@ extern "C" void program_main()
|
|||
lcd_switchFont(fReg, fontnr);
|
||||
rt.push(integer::make(fontnr));
|
||||
rt.push(rt.make<string>(object::ID_string,
|
||||
utf8(fReg->f->name), strlen(fReg->f->name)));
|
||||
utf8(fReg->f->name),
|
||||
strlen(fReg->f->name)));
|
||||
key = 0;
|
||||
}
|
||||
if (key == KEY_F3)
|
||||
{
|
||||
byte fnr = fontnr < 0 ? byte(10 - fontnr) : byte(fontnr);
|
||||
byte fontRPL[] = { object::ID_dmcp_font, fnr };
|
||||
dmcp_font *font = (dmcp_font *) fontRPL;
|
||||
byte fnr = fontnr < 0 ? byte(10 - fontnr) : byte(fontnr);
|
||||
byte fontRPL[] = { object::ID_dmcp_font, fnr };
|
||||
dmcp_font *font = (dmcp_font *) fontRPL;
|
||||
|
||||
uint32_t start = sys_current_ms();
|
||||
uint32_t start = sys_current_ms();
|
||||
for (uint i = 0; i < 100; i++)
|
||||
Screen.text(30 + i % 20, 50 + i % 23, utf8("Hello World"), font);
|
||||
Screen.text(30 + i % 20,
|
||||
50 + i % 23,
|
||||
utf8("Hello World"),
|
||||
font);
|
||||
uint32_t end = sys_current_ms();
|
||||
runtime &rt = runtime::RT;
|
||||
runtime &rt = runtime::RT;
|
||||
rt.push(integer::make(end - start));
|
||||
lcd_refresh_lines(50, 100);
|
||||
continue;
|
||||
|
@ -273,7 +292,7 @@ extern "C" void program_main()
|
|||
lcd_writeText(fReg, "Hello World");
|
||||
}
|
||||
uint32_t end = sys_current_ms();
|
||||
runtime &rt = runtime::RT;
|
||||
runtime &rt = runtime::RT;
|
||||
rt.push(integer::make(end - start));
|
||||
lcd_refresh();
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue