Added FNTHLPT and FONTHELP commands (->FNTHLPT and ->FNTHELP)

This commit is contained in:
claudiol 2021-08-04 17:06:41 -04:00
parent ff5d37f6a8
commit 8c3870659e
5 changed files with 170 additions and 30 deletions

View file

@ -688,6 +688,15 @@ void halUpdateFontArray(WORDPTR const ** fontarray)
if(ISFONT(*var[1]))
fontarray[FONT_PLOT] = var + 1;
}
else if(rplCompareIDENT(var[0], rplGetFontRomPtrTableAddress()[FONT_IDENTS_ROMPTR_INDEX + FONT_HLPTEXT])) {
if(ISFONT(*var[1]))
fontarray[FONT_HLPTEXT] = var + 1;
}
else if(rplCompareIDENT(var[0], rplGetFontRomPtrTableAddress()[FONT_IDENTS_ROMPTR_INDEX + FONT_HLPTITLE])) {
if(ISFONT(*var[1]))
fontarray[FONT_HLPTITLE] = var + 1;
}
var = rplFindNext(var);
}
@ -720,7 +729,13 @@ void halUpdateFontArray(WORDPTR const ** fontarray)
fontarray[FONT_FORMS] =
halGetSystemFontbyHeight(DEF_FNTFORM_HEIGHT);
}
if (fontarray[FONT_HLPTEXT] == 0) {
fontarray[FONT_HLPTEXT] =
halGetSystemFontbyHeight(DEF_FNTHELP_HEIGHT);
} if (fontarray[FONT_HLPTITLE] == 0) {
fontarray[FONT_HLPTITLE] =
halGetSystemFontbyHeight(DEF_FNTHLPT_HEIGHT);
}
return;
}
@ -954,15 +969,15 @@ void halRedrawHelp(DRAWSURFACE * scr)
BINT namew =
StringWidthN((char *)(var[0] + 1),
((char *)(var[0] + 1)) + rplGetIdentLength(var[0]),
*halScreen.FontArray[FONT_STATUS]);
*halScreen.FontArray[FONT_HLPTITLE]);
// SHOW THE NAME OF THE VARIABLE
DrawTextN(3, ytop + 2, (char *)(var[0] + 1),
((char *)(var[0] + 1)) + rplGetIdentLength(var[0]),
*halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT), scr);
DrawText(3 + namew, ytop + 2, ": ", *halScreen.FontArray[FONT_STATUS],
*halScreen.FontArray[FONT_HLPTITLE], cgl_mkcolor(PAL_HLPTEXT), scr);
DrawText(3 + namew, ytop + 2, ": ", *halScreen.FontArray[FONT_HLPTITLE],
cgl_mkcolor(PAL_HLPTEXT), scr);
namew += 3 + StringWidth(": ", *halScreen.FontArray[FONT_STATUS]);
namew += 3 + StringWidth(": ", *halScreen.FontArray[FONT_HLPTITLE]);
int xend;
BYTEPTR basetext = (BYTEPTR) (helptext + 1);
@ -973,7 +988,7 @@ void halRedrawHelp(DRAWSURFACE * scr)
xend = SCREEN_WIDTH - 1 - namew;
endofline =
(BYTEPTR) StringCoordToPointer((char *)basetext,
(char *)endoftext, *halScreen.FontArray[FONT_STATUS],
(char *)endoftext, *halScreen.FontArray[FONT_HLPTEXT],
&xend);
if(endofline < endoftext) {
// BACK UP TO THE NEXT WHITE CHARACTER
@ -992,10 +1007,10 @@ void halRedrawHelp(DRAWSURFACE * scr)
// DRAW THE TEXT
DrawTextN(namew,
ytop + 2 +
k * (*halScreen.FontArray[FONT_STATUS])->BitmapHeight,
ytop + 2 + (*halScreen.FontArray[FONT_HLPTITLE])->BitmapHeight +
(k-1) * (*halScreen.FontArray[FONT_HLPTEXT])->BitmapHeight,
(char *)basetext, (char *)endofline,
*halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT), scr);
*halScreen.FontArray[FONT_HLPTEXT], cgl_mkcolor(PAL_HLPTEXT), scr);
basetext = nextline;
namew = 3;
}
@ -1023,9 +1038,9 @@ void halRedrawHelp(DRAWSURFACE * scr)
nextline = rplStrSize(helptext);
}
DrawTextN(3,
ytop + 2 + (*halScreen.FontArray[FONT_MENU])->BitmapHeight + k * (*halScreen.FontArray[FONT_STATUS])->BitmapHeight,
ytop + 2 + (*halScreen.FontArray[FONT_HLPTITLE])->BitmapHeight + k * (*halScreen.FontArray[FONT_HLPTEXT])->BitmapHeight,
(char *)basetext + currentline, (char *)basetext + nextline,
*halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT), scr);
*halScreen.FontArray[FONT_HLPTEXT], cgl_mkcolor(PAL_HLPTEXT), scr);
currentline = nextline;
}
@ -1035,7 +1050,7 @@ void halRedrawHelp(DRAWSURFACE * scr)
scr->clipy = ytop + 1;
scr->clipy2 =
ytop + 1 + (*halScreen.FontArray[FONT_MENU])->BitmapHeight;
ytop + 1 + (*halScreen.FontArray[FONT_HLPTITLE])->BitmapHeight;
uiDrawMenuItem(item, PAL_HLPTEXT, scr);
@ -2098,6 +2113,10 @@ void halUpdateFonts()
case FONT_FORMS:
halScreen.DirtyFlag |= FORM_DIRTY;
break;
case FONT_HLPTITLE:
case FONT_HLPTEXT:
break;
}
}
@ -2123,8 +2142,18 @@ void halPrepareBuffer(DRAWSURFACE *scr)
scr->y=0;
// Copy current screen data to the new buffer
//cgl_bitblt(&altbuffer,scr,SCREEN_WIDTH,SCREEN_HEIGHT);
// Avoid background processes from writing to the buffer while we copy it
halScreen.DirtyFlag|=BUFFER_LOCK;
memmovew(altbuffer.addr,scr->addr,(SCREEN_WIDTH*SCREEN_HEIGHT)/PIXELS_PER_WORD);
// Let background processes know to use the alternative buffer
halScreen.DirtyFlag|=BUFFER_ALT;
// Remove the lock
halScreen.DirtyFlag&=~BUFFER_LOCK;
scr->addr=altbuffer.addr;
scr->actbuffer^=1;
@ -2133,7 +2162,15 @@ void halPrepareBuffer(DRAWSURFACE *scr)
void halSwapBuffer(DRAWSURFACE *scr)
{
// Show new buffer on the screen
// Avoid background processes from writing to the buffer while we copy it
halScreen.DirtyFlag|=BUFFER_LOCK;
lcd_setactivebuffer(scr->actbuffer);
halScreen.DirtyFlag&=~BUFFER_ALT;
// Remove the lock
halScreen.DirtyFlag&=~BUFFER_LOCK;
halScreenUpdated();
}
@ -2198,6 +2235,8 @@ void status_popup_handler()
halSetMenu2Height(0);
}
else {
halScreen.DirtyFlag|=STAREA_DIRTY|MENU1_DIRTY|MENU2_DIRTY;
/*
DRAWSURFACE scr;
cgl_initscr(&scr);
halPrepareBuffer(&scr);
@ -2205,6 +2244,8 @@ void status_popup_handler()
halRedrawMenu2(&scr);
halRedrawStatus(&scr);
halSwapBuffer(&scr);
halScreenUpdated();
*/
}
halScreen.SAreaTimer = 0;
}
@ -2320,7 +2361,7 @@ void halShowErrorMsg()
cgl_mkcolor(PAL_HLPBACKGND));
// DO SOME DECORATIVE ELEMENTS
cgl_cliphline(&scr,
ytop + (*halScreen.FontArray[FONT_STATUS])->BitmapHeight + 1, 0,
ytop + (*halScreen.FontArray[FONT_HLPTITLE])->BitmapHeight + 1, 0,
SCREEN_WIDTH - 1, cgl_mkcolor(PAL_HLPLINES));
//ggl_cliphline(&scr,ytop+halScreen.Menu2-1,0,SCREEN_WIDTH-1,ggl_mkcolor(8));
cgl_cliprect(&scr, 0, ytop, 4, ybot , cgl_mkcolor(PAL_HLPLINES));
@ -2342,15 +2383,15 @@ void halShowErrorMsg()
xstart +=
StringWidthN((char *)start, (char *)end,
*halScreen.FontArray[FONT_STATUS]);
*halScreen.FontArray[FONT_HLPTITLE]);
DrawTextN(scr.clipx + 6, scr.clipy + 1, (char *)start,
(char *)end, *halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT),
(char *)end, *halScreen.FontArray[FONT_HLPTITLE], cgl_mkcolor(PAL_HLPTEXT),
&scr);
xstart += 4;
}
}
DrawText(xstart, scr.clipy + 1, "Exception:",
*halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT), &scr);
*halScreen.FontArray[FONT_HLPTITLE], cgl_mkcolor(PAL_HLPTEXT), &scr);
BINT ecode;
for(errbit = 0; errbit < 8; ++errbit) // THERE'S ONLY A FEW EXCEPTIONS IN THE NEW ERROR MODEL
@ -2366,9 +2407,9 @@ void halShowErrorMsg()
DrawTextN(scr.clipx + 6,
scr.clipy + 3 +
(*halScreen.FontArray[FONT_STATUS])->BitmapHeight,
(*halScreen.FontArray[FONT_HLPTEXT])->BitmapHeight,
(char *)msgstart, (char *)msgend,
*halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT), &scr);
*halScreen.FontArray[FONT_HLPTEXT], cgl_mkcolor(PAL_HLPTEXT), &scr);
}
break;
}
@ -2386,15 +2427,15 @@ void halShowErrorMsg()
xstart +=
StringWidthN((char *)start, (char *)end,
*halScreen.FontArray[FONT_STATUS]);
*halScreen.FontArray[FONT_HLPTITLE]);
DrawTextN(scr.clipx + 6, scr.clipy + 1, (char *)start,
(char *)end, *halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT),
(char *)end, *halScreen.FontArray[FONT_HLPTITLE], cgl_mkcolor(PAL_HLPTEXT),
&scr);
xstart += 4;
}
}
DrawText(xstart, scr.clipy + 1, "Error:",
*halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT), &scr);
*halScreen.FontArray[FONT_HLPTITLE], cgl_mkcolor(PAL_HLPTEXT), &scr);
// GET NEW TRANSLATABLE MESSAGES
WORDPTR message = uiGetLibMsg(ErrorCode);
@ -2406,9 +2447,9 @@ void halShowErrorMsg()
DrawTextN(scr.clipx + 6,
scr.clipy + 3 +
(*halScreen.FontArray[FONT_STATUS])->BitmapHeight,
(*halScreen.FontArray[FONT_HLPTITLE])->BitmapHeight,
(char *)msgstart, (char *)msgend,
*halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT), &scr);
*halScreen.FontArray[FONT_HLPTEXT], cgl_mkcolor(PAL_HLPTEXT), &scr);
}
}
@ -2448,7 +2489,7 @@ void halShowMsgN(char *Text, char *End)
// SHOW MESSAGE
DrawTextN(3, ytop + 3, Text, End, *halScreen.FontArray[FONT_STATUS], cgl_mkcolor(PAL_HLPTEXT),
DrawTextN(3, ytop + 3, Text, End, *halScreen.FontArray[FONT_HLPTEXT], cgl_mkcolor(PAL_HLPTEXT),
&scr);
}

View file

@ -117,6 +117,8 @@ enum halFonts
FONT_STATUS,
FONT_PLOT,
FONT_FORMS,
FONT_HLPTEXT,
FONT_HLPTITLE,
FONTS_NUM
};
@ -129,7 +131,8 @@ enum halFonts
#define MENU1_DIRTY 32
#define MENU2_DIRTY 64
#define STAREA_DIRTY 128
#define BUFFER_LOCK 16384
#define BUFFER_ALT 32768
// NUMBER OF ENTRIES IN THE RENDER CACHE

View file

@ -259,6 +259,8 @@
#define DEF_FNTPLOT_HEIGHT DEF_FNTSTK_HEIGHT
#define DEF_FNTMENU_HEIGHT (SCREEN_HEIGHT/13)
#define DEF_FNTSTAT_HEIGHT DEF_FNTMENU_HEIGHT
#define DEF_FNTHELP_HEIGHT DEF_FNTMENU_HEIGHT
#define DEF_FNTHLPT_HEIGHT DEF_FNTMENU_HEIGHT
// COMMAND LINE

View file

@ -47,7 +47,12 @@
ECMD(STOFNTCMDL,"→FNTCMDL",MKTOKENINFO(8,TITYPE_NOTALLOWED,1,2)), \
ECMD(STOFNTSTAT,"→FNTSTAT",MKTOKENINFO(8,TITYPE_NOTALLOWED,1,2)), \
ECMD(STOFNTPLOT,"→FNTPLOT",MKTOKENINFO(8,TITYPE_NOTALLOWED,1,2)), \
ECMD(STOFNTFORM,"→FNTFORM",MKTOKENINFO(8,TITYPE_NOTALLOWED,1,2))
ECMD(STOFNTFORM,"→FNTFORM",MKTOKENINFO(8,TITYPE_NOTALLOWED,1,2)), \
CMD(FNTHELP,MKTOKENINFO(7,TITYPE_NOTALLOWED,1,2)), \
CMD(FNTHLPT,MKTOKENINFO(7,TITYPE_NOTALLOWED,1,2)), \
ECMD(STOFNTHELP,"→FNTHELP",MKTOKENINFO(8,TITYPE_NOTALLOWED,1,2)), \
ECMD(STOFNTHLPT,"→FNTHLPT",MKTOKENINFO(8,TITYPE_NOTALLOWED,1,2))
// ADD MORE OPCODES HERE
@ -168,6 +173,18 @@ ROMOBJECT fontform_ident[] = {
TEXT2WORD('F', 'o', 'n', 't')
};
ROMOBJECT fonthelptitle_ident[] = {
MKPROLOG(DOIDENT, 2),
TEXT2WORD('H', 'l', 'p', 'T'),
TEXT2WORD('F', 'o', 'n', 't')
};
ROMOBJECT fonthelp_ident[] = {
MKPROLOG(DOIDENT, 2),
TEXT2WORD('H', 'e', 'l', 'p'),
TEXT2WORD('F', 'o', 'n', 't')
};
ROMOBJECT fontcmdline_ident[] = {
MKPROLOG(DOIDENT, 2),
TEXT2WORD('C', 'm', 'd', 'l'),
@ -220,8 +237,8 @@ const WORDPTR const ROMPTR_TABLE[] = {
(WORDPTR) fontstarea_ident,
(WORDPTR) fontplot_ident,
(WORDPTR) fontform_ident,
(WORDPTR) zero_bint,
(WORDPTR) zero_bint,
(WORDPTR) fonthelp_ident,
(WORDPTR) fonthelptitle_ident,
(WORDPTR) zero_bint,
(WORDPTR) zero_bint,
(WORDPTR) zero_bint,
@ -346,7 +363,9 @@ void rplFontsNewList(WORDPTR oldlist, WORDPTR newlist)
(WORDPTR) fontmenu_ident,
(WORDPTR) fontstarea_ident,
(WORDPTR) fontplot_ident,
(WORDPTR) fontform_ident
(WORDPTR) fontform_ident,
(WORDPTR) fonthelp_ident,
(WORDPTR) fonthelptitle_ident
};
int k;
@ -605,6 +624,13 @@ void rplSetCurrentFont(BINT area, WORDPTR ident)
case FONT_FORMS:
fntid = (WORDPTR) fontform_ident;
break;
case FONT_HLPTEXT:
fntid = (WORDPTR) fonthelp_ident;
break;
case FONT_HLPTITLE:
fntid = (WORDPTR) fonthelptitle_ident;
break;
default:
return;
}
@ -638,6 +664,12 @@ WORDPTR rplGetCurrentFont(BINT area)
case FONT_FORMS:
fntid = (WORDPTR) fontform_ident;
break;
case FONT_HLPTEXT:
fntid = (WORDPTR) fonthelp_ident;
break;
case FONT_HLPTITLE:
fntid = (WORDPTR) fonthelptitle_ident;
break;
default:
return 0;
}
@ -1004,6 +1036,67 @@ void LIB_HANDLER()
return;
}
case FNTHELP:
{
//@SHORT_DESC=Recall name of current font for help
//@NEW
WORDPTR fntid = rplGetCurrentFont(FONT_HLPTEXT);
if(fntid)
rplPushData(fntid);
return;
}
case FNTHLPT:
{
//@SHORT_DESC=Recall name of current font for help title
//@NEW
WORDPTR fntid = rplGetCurrentFont(FONT_HLPTITLE);
if(fntid)
rplPushData(fntid);
return;
}
case STOFNTHELP:
// CHANGE CURRENT FONT
{
//@SHORT_DESC=Change current font for help text
//@NEW
if(rplDepthData() < 1) {
rplError(ERR_BADARGCOUNT);
return;
}
rplStripTagStack(1);
if(!ISIDENT(*rplPeekData(1))) {
rplError(ERR_IDENTEXPECTED);
return;
}
rplSetCurrentFont(FONT_HLPTEXT, rplPeekData(1));
rplDropData(1);
return;
}
case STOFNTHLPT:
// CHANGE CURRENT FONT
{
//@SHORT_DESC=Change current font for help title
//@NEW
if(rplDepthData() < 1) {
rplError(ERR_BADARGCOUNT);
return;
}
rplStripTagStack(1);
if(!ISIDENT(*rplPeekData(1))) {
rplError(ERR_IDENTEXPECTED);
return;
}
rplSetCurrentFont(FONT_HLPTITLE, rplPeekData(1));
rplDropData(1);
return;
}
// STANDARIZED OPCODES:
// --------------------
// LIBRARIES ARE FORCED TO ALWAYS HANDLE THE STANDARD OPCODES

View file

@ -620,7 +620,8 @@ void USBSelector::on_updateFirmware_clicked()
// CHECK IF SELECTED FIRMWARE IS VALID FOR THE TARGET
if( ((calcidx>0) && (strncmp(preamblestring,preamble_strings[calcidx],bytelen)!=0)) // DEVICES USING NEW FIRMWARES, FROM NOW ON
|| ((calcidx==0) && (strncmp(preamblestring,preamble_strings[2],bytelen)!=0) &&
|| ((calcidx==0) && (strncmp(preamblestring,preamble_strings[1],bytelen)!=0) &&
(strncmp(preamblestring,preamble_strings[2],bytelen)!=0) &&
(strncmp(preamblestring,preamble_strings[3],bytelen)!=0) &&
(strncmp(preamblestring,preamble_strings[4],bytelen)!=0)) ) // HANDLE SPECIAL CASE OF OLD FIRMWARES USING "newRPL Calc" FOR ALL DEVICES
{