graphics: Implement DispXY
command
The `DispXY` command on the HP50G takes a font ID that takes 2 values, 1 for small font and 2 for regular font. In order to implement this in a more easy way, reorder the font IDs so that they "match", except that 0 gives the even smaller help font and 3 gives the larger editor font. Fixes: #1146 Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -38,12 +38,12 @@ Note that unlike on the HP48, a complex value in DB48X can
|
|||
contain a based number.
|
||||
|
||||
|
||||
## ClearLCD (cllcd)
|
||||
## ClearLCD (CLLCD)
|
||||
|
||||
Clear the LCD display, and block updates of the header or menu areas.
|
||||
|
||||
|
||||
## DrawText (disp)
|
||||
## DrawText (DISP)
|
||||
|
||||
Draw the text or object in level 2 at the position indicated by level 1. A text
|
||||
is drawn without the surrounding quotation marks.
|
||||
|
@ -73,11 +73,31 @@ provide:
|
|||
* An *invert* flag (default false) which, if set, will swap the foreground and
|
||||
background patterns.
|
||||
|
||||
For example, `"Hello" { #0 #0 0 true true } DrawText` will draw `Hello` in the
|
||||
top-left corner (`#0 #0`) with the largest (editor) font (font identifier `0`),
|
||||
For example, `"Hello" { #0 #0 3 true true } DrawText` will draw `Hello` in the
|
||||
top-left corner (`#0 #0`) with the largest (editor) font (font identifier `3`),
|
||||
erasing the background (the first `true`), in reverse colors (the second
|
||||
`true`).
|
||||
|
||||
## DrawStyledText (DISPXY)
|
||||
|
||||
Draw the text or object in level 3 at the position indicated by level 2, using
|
||||
the font specified in level 1. This behaves like [DrawText](#drawtext), except
|
||||
for the additional parameter specifying the font size.
|
||||
|
||||
This command is compatible with the HP50G usage, where the position is specified
|
||||
by a list containing two decimal integer values. A font size of 1 displays with
|
||||
a small font, a font size of 2 displays with a regular font.
|
||||
|
||||
In addition to this HP50G-compatible usage, `DispXY` will also accept:
|
||||
|
||||
* A smaller font size, 0, for the help size, and other font sizes above 2, which
|
||||
are compatible with the values given to [StackFont](#stackfont).
|
||||
|
||||
* The position can accept the same values as [DrawText](#drawtext), including a
|
||||
single integer value indicating a line number, a fractional line position, or
|
||||
coordinates scaled according to [PlotParameters](#plotparameters).
|
||||
|
||||
|
||||
## Show
|
||||
|
||||
Display the first level of the stack using the entire screen, with a possible
|
||||
|
|
|
@ -6659,12 +6659,12 @@ Note that unlike on the HP48, a complex value in DB48X can
|
|||
contain a based number.
|
||||
|
||||
|
||||
## ClearLCD (cllcd)
|
||||
## ClearLCD (CLLCD)
|
||||
|
||||
Clear the LCD display, and block updates of the header or menu areas.
|
||||
|
||||
|
||||
## DrawText (disp)
|
||||
## DrawText (DISP)
|
||||
|
||||
Draw the text or object in level 2 at the position indicated by level 1. A text
|
||||
is drawn without the surrounding quotation marks.
|
||||
|
@ -6694,11 +6694,31 @@ provide:
|
|||
* An *invert* flag (default false) which, if set, will swap the foreground and
|
||||
background patterns.
|
||||
|
||||
For example, `"Hello" { #0 #0 0 true true } DrawText` will draw `Hello` in the
|
||||
top-left corner (`#0 #0`) with the largest (editor) font (font identifier `0`),
|
||||
For example, `"Hello" { #0 #0 3 true true } DrawText` will draw `Hello` in the
|
||||
top-left corner (`#0 #0`) with the largest (editor) font (font identifier `3`),
|
||||
erasing the background (the first `true`), in reverse colors (the second
|
||||
`true`).
|
||||
|
||||
## DrawStyledText (DISPXY)
|
||||
|
||||
Draw the text or object in level 3 at the position indicated by level 2, using
|
||||
the font specified in level 1. This behaves like [DrawText](#drawtext), except
|
||||
for the additional parameter specifying the font size.
|
||||
|
||||
This command is compatible with the HP50G usage, where the position is specified
|
||||
by a list containing two decimal integer values. A font size of 1 displays with
|
||||
a small font, a font size of 2 displays with a regular font.
|
||||
|
||||
In addition to this HP50G-compatible usage, `DispXY` will also accept:
|
||||
|
||||
* A smaller font size, 0, for the help size, and other font sizes above 2, which
|
||||
are compatible with the values given to [StackFont](#stackfont).
|
||||
|
||||
* The position can accept the same values as [DrawText](#drawtext), including a
|
||||
single integer value indicating a line number, a fractional line position, or
|
||||
coordinates scaled according to [PlotParameters](#plotparameters).
|
||||
|
||||
|
||||
## Show
|
||||
|
||||
Display the first level of the stack using the entire screen, with a possible
|
||||
|
|
|
@ -6659,12 +6659,12 @@ Note that unlike on the HP48, a complex value in DB50X can
|
|||
contain a based number.
|
||||
|
||||
|
||||
## ClearLCD (cllcd)
|
||||
## ClearLCD (CLLCD)
|
||||
|
||||
Clear the LCD display, and block updates of the header or menu areas.
|
||||
|
||||
|
||||
## DrawText (disp)
|
||||
## DrawText (DISP)
|
||||
|
||||
Draw the text or object in level 2 at the position indicated by level 1. A text
|
||||
is drawn without the surrounding quotation marks.
|
||||
|
@ -6694,11 +6694,31 @@ provide:
|
|||
* An *invert* flag (default false) which, if set, will swap the foreground and
|
||||
background patterns.
|
||||
|
||||
For example, `"Hello" { #0 #0 0 true true } DrawText` will draw `Hello` in the
|
||||
top-left corner (`#0 #0`) with the largest (editor) font (font identifier `0`),
|
||||
For example, `"Hello" { #0 #0 3 true true } DrawText` will draw `Hello` in the
|
||||
top-left corner (`#0 #0`) with the largest (editor) font (font identifier `3`),
|
||||
erasing the background (the first `true`), in reverse colors (the second
|
||||
`true`).
|
||||
|
||||
## DrawStyledText (DISPXY)
|
||||
|
||||
Draw the text or object in level 3 at the position indicated by level 2, using
|
||||
the font specified in level 1. This behaves like [DrawText](#drawtext), except
|
||||
for the additional parameter specifying the font size.
|
||||
|
||||
This command is compatible with the HP50G usage, where the position is specified
|
||||
by a list containing two decimal integer values. A font size of 1 displays with
|
||||
a small font, a font size of 2 displays with a regular font.
|
||||
|
||||
In addition to this HP50G-compatible usage, `DispXY` will also accept:
|
||||
|
||||
* A smaller font size, 0, for the help size, and other font sizes above 2, which
|
||||
are compatible with the values given to [StackFont](#stackfont).
|
||||
|
||||
* The position can accept the same values as [DrawText](#drawtext), including a
|
||||
single integer value indicating a line number, a fractional line position, or
|
||||
coordinates scaled according to [PlotParameters](#plotparameters).
|
||||
|
||||
|
||||
## Show
|
||||
|
||||
Display the first level of the stack using the entire screen, with a possible
|
||||
|
|
BIN
images/text-dispxy.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
|
@ -103,10 +103,10 @@ void font_defaults()
|
|||
extern byte name##_sparse_font_data[]; \
|
||||
name = (font_p) name##_sparse_font_data;
|
||||
|
||||
GENERATED_FONT(EditorFont);
|
||||
GENERATED_FONT(HelpFont);
|
||||
GENERATED_FONT(ReducedFont);
|
||||
GENERATED_FONT(StackFont);
|
||||
GENERATED_FONT(EditorFont);
|
||||
|
||||
HeaderFont = LibMonoFont10x17;
|
||||
CursorFont = LibMonoFont17x25;
|
||||
|
|
|
@ -492,7 +492,7 @@ COMMAND_BODY(Disp)
|
|||
PlotParametersAccess ppar;
|
||||
coord x = 0;
|
||||
coord y = 0;
|
||||
font_p font = settings::font(settings::STACK);
|
||||
font_p font = settings::font(Settings.StackFont());
|
||||
bool erase = true;
|
||||
bool invert = false;
|
||||
id ty = pos->type();
|
||||
|
@ -585,10 +585,25 @@ COMMAND_BODY(Disp)
|
|||
|
||||
COMMAND_BODY(DispXY)
|
||||
// ----------------------------------------------------------------------------
|
||||
// To be implemented
|
||||
// Temporarily change the font setting, otherwise same as Disp
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
rt.unimplemented_error();
|
||||
if (object_g fsize = rt.pop())
|
||||
{
|
||||
uint fsz = fsize->as_uint32(0, true);
|
||||
if (!rt.error())
|
||||
{
|
||||
settings::font_id fid = settings::font_id(fsz);
|
||||
settings::SaveStackFont ssf(fid);
|
||||
return Disp::evaluate();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Restore stack
|
||||
rt.push(fsize);
|
||||
}
|
||||
|
||||
}
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,11 +104,11 @@ public:
|
|||
// Selection of font size for the stack
|
||||
// ------------------------------------------------------------------------
|
||||
{
|
||||
EDITOR, STACK, REDUCED, HELP,
|
||||
HELP, REDUCED, STACK, EDITOR,
|
||||
LIB28, LIB25, LIB22, LIB20, LIB18, LIB17,
|
||||
SKR24, SKR18,
|
||||
FREE42,
|
||||
FIRST_FONT = EDITOR,
|
||||
FIRST_FONT = HELP,
|
||||
LAST_FONT = FREE42,
|
||||
NUM_FONTS
|
||||
};
|
||||
|
|
19
src/tests.cc
|
@ -165,12 +165,12 @@ void tests::run(uint onlyCurrent)
|
|||
RECORDER_TRACE(errors) = false;
|
||||
|
||||
// Reset to known settings state
|
||||
Settings = settings();
|
||||
reset_settings();
|
||||
if (onlyCurrent)
|
||||
{
|
||||
here().begin("Current");
|
||||
if (onlyCurrent & 1)
|
||||
stack_operations();
|
||||
graphic_commands();
|
||||
if (onlyCurrent & 2)
|
||||
demo_ui();
|
||||
if (onlyCurrent & 4)
|
||||
|
@ -180,7 +180,6 @@ void tests::run(uint onlyCurrent)
|
|||
}
|
||||
else
|
||||
{
|
||||
reset_settings();
|
||||
shift_logic();
|
||||
keyboard_entry();
|
||||
data_types();
|
||||
|
@ -9086,11 +9085,11 @@ void tests::graphic_commands()
|
|||
.noerror().image("text-pixxy").test(ENTER);
|
||||
|
||||
step("Displaying text, font ID");
|
||||
test(CLEAR, "\"Hello\" { 0 0 0 } DISP \"World\" { 0 1 2 } DISP ", ENTER)
|
||||
test(CLEAR, "\"Hello\" { 0 1 2 } DISP \"World\" { 0 -1 3 } DISP ", ENTER)
|
||||
.noerror().image("text-font").test(ENTER);
|
||||
|
||||
step("Displaying text, erase and invert");
|
||||
test(CLEAR, "\"Inverted\" { 0 0 0 true true } DISP", ENTER)
|
||||
test(CLEAR, "\"Inverted\" { 0 0 3 true true } DISP", ENTER)
|
||||
.noerror().image("text-invert").test(ENTER);
|
||||
|
||||
step("Displaying text, background and foreground");
|
||||
|
@ -9110,6 +9109,16 @@ void tests::graphic_commands()
|
|||
test(CLEAR, "\"Bad\" \"Hello\" DISP", ENTER)
|
||||
.error("Bad argument type");
|
||||
|
||||
step("Displaying styled text");
|
||||
test(CLEAR,
|
||||
"0 10 for i"
|
||||
" \"Hello\" { }"
|
||||
" i 135 * 321 mod 25 + R→B +"
|
||||
" i 51 * 200 mod 3 + R→B +"
|
||||
" i DISPXY "
|
||||
"next", ENTER)
|
||||
.noerror().image("text-dispxy");
|
||||
|
||||
step("Lines");
|
||||
test(CLEAR, "3 50 for i ⅈ i * exp i 2 + ⅈ * exp 5 * Line next", ENTER)
|
||||
.noerror().image("lines").test(ENTER);
|
||||
|
|