Segment 1 was back at 27 KB. Settings, Contacts, Channel, Home, Node, convos, messages, contacts, channels, rowlist and draw move to vmcode2: segment 1 is now 10.3 KB, segment 2 23.4 KB. tools/sect2.py adds the VM_SECT2 static declarations. Checked in the compiled code, the rules in sections.h were too cautious: literals in a vmcode2 function are emitted into vmcode2, a file's static const data and calls to unannotated functions go through the __text__ base, and taking a vmcode2 function's address (event handlers, callbacks) gives its real address. The real traps are shared extern const tables and -fwritable-strings (PC-relative into .data). tools/check_sections.py runs after every link and fails the build on any PC-relative reference from vmcode2 to outside it; python3 added to the toolchain image for it. Unicode: characters past Latin-1 all became '?', and Windows-1252 quotes and dashes had no glyph in the small font. Now arrows, check marks, stars, bullets and node-type marks map to the font's UI symbols, typographic quotes and dashes to ASCII, any emoji to a new smiley glyph, and variation selectors / zero-width joiners are dropped.
84 lines
3.0 KiB
C
84 lines
3.0 KiB
C
/*
|
|
* Font Preview (Options menu): sample screens in the small font, to judge how
|
|
* readable it is on the Visor's LCD before the real screens are built on it.
|
|
*/
|
|
#include <PalmOS.h>
|
|
#include "resources.h"
|
|
#include "ui/draw.h"
|
|
#include "preview_form.h"
|
|
|
|
/* In the second code segment: see sections.h for the rules. */
|
|
static void Row(Coord y, Char mark, const Char *name, const Char *badge, const Char *age, const Char *preview) VM_SECT2;
|
|
static void DrawPreview(void) VM_SECT2;
|
|
|
|
#define TOP 16
|
|
|
|
static void Row(Coord y, Char mark, const Char *name, const Char *badge, const Char *age, const Char *preview)
|
|
{
|
|
Coord ageX = 88, previewX = 106;
|
|
|
|
WinDrawChars(&mark, 1, 1, y);
|
|
DrawCut(name, 8, y, 52);
|
|
if (badge)
|
|
DrawRight(badge, 80, y);
|
|
if (age)
|
|
DrawRight(age, previewX - 3, y);
|
|
(void)ageX;
|
|
if (preview)
|
|
DrawCut(preview, previewX, y, 160 - previewX);
|
|
}
|
|
|
|
static void DrawPreview(void)
|
|
{
|
|
Char line[48];
|
|
Coord y = TOP;
|
|
FontID old = FntSetFont(vmSmallFont);
|
|
|
|
DrawSection("Channels", 0, y, 160); y += VM_ROW_H;
|
|
StrPrintF(line, "%c2", GLYPH_COMPANION);
|
|
Row(y, '@', "Public", line, "5m", "Steve: spare antenna?"); y += VM_ROW_H;
|
|
Row(y, '#', "phillymesh", NULL, "1h", "ok see you there"); y += VM_ROW_H;
|
|
DrawSection("Direct", 0, y, 160); y += VM_ROW_H;
|
|
StrPrintF(line, "%c", GLYPH_FAILED);
|
|
Row(y, GLYPH_COMPANION, "Rich K.", line, "23h", "test from the visor"); y += VM_ROW_H;
|
|
Row(y, GLYPH_REPEATER, "Hilltop Repeater", NULL, "2d", NULL); y += VM_ROW_H;
|
|
Row(y, GLYPH_ROOM, "Rittenhouse Room", NULL, "3d", NULL); y += VM_ROW_H;
|
|
Row(y, GLYPH_SENSOR, "Weather Sensor", NULL, NULL, NULL); y += VM_ROW_H;
|
|
|
|
DrawSection("Thu Nov 1", 0, y, 160); y += VM_ROW_H + 1;
|
|
DrawChip("Steve K.", 1, y); y += VM_CHIP_H + 1;
|
|
WinDrawChars("11:30", 5, 4, y);
|
|
WinDrawChars("I'll bring a spare antenna", 26, 26, y); y += VM_ROW_H;
|
|
WinDrawChars("for anyone who needs one +6dB", 29, 26, y); y += VM_ROW_H + 1;
|
|
StrPrintF(line, "%c VisorNeo", GLYPH_SELF);
|
|
DrawChip(line, 1, y); y += VM_CHIP_H + 1;
|
|
WinDrawChars("11:33", 5, 4, y);
|
|
StrPrintF(line, "on my way, caf%c at 3 %c", (Char)0xE9, GLYPH_ACKED);
|
|
WinDrawChars(line, StrLen(line), 26, y); y += VM_ROW_H + 2;
|
|
|
|
StrPrintF(line, "%c%c%c%c%c%c%c%c%c%c%c ABCxyz 0123 %c",
|
|
GLYPH_SELF, GLYPH_COMPANION, GLYPH_REPEATER, GLYPH_ROOM, GLYPH_SENSOR, GLYPH_UNKNOWN,
|
|
GLYPH_ACKED, GLYPH_FAILED, GLYPH_PENDING, GLYPH_LOCK, GLYPH_UP, GLYPH_BACK);
|
|
WinDrawChars(line, StrLen(line), 1, y);
|
|
FntSetFont(old);
|
|
}
|
|
|
|
Boolean FontPreviewFormHandleEvent(EventType *event)
|
|
{
|
|
switch (event->eType) {
|
|
case frmOpenEvent:
|
|
FrmDrawForm(FrmGetActiveForm());
|
|
DrawPreview();
|
|
return true;
|
|
case ctlSelectEvent:
|
|
if (event->data.ctlSelect.controlID == FontPreviewDoneButton) {
|
|
FrmGotoForm(MainForm);
|
|
return true;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return false;
|
|
}
|