Added vars menu

This commit is contained in:
claudiol 2015-08-25 12:36:32 -04:00
parent 82c91360e6
commit 77d399aef7
9 changed files with 393 additions and 232 deletions

View file

@ -15,11 +15,5 @@ HEVENT halBusyEvent __SYSTEM_GLOBAL__;
// KEYBOARD DRIVER, HIGH LEVEL
// NOT CONST, THIS IS ACTUALLY A GLOBAL VARIABLE TAKING PERMANENT SPACE
// ONLY TO BE USED BY THE KEYBOARD HANDLER
WORD cmdKeySeco[4] __SYSTEM_GLOBAL__;
// COMMAND LINE EDITOR

View file

@ -4,217 +4,6 @@
#include <libraries.h>
// DEBUG ONLY
const BYTEPTR testprogram=(const BYTEPTR) "<< 8 0 0 0 { } -> R S X Y A "
" << "
" 1 R START 0 NEXT R ->LIST 'A' STO "
" DO "
" 'A' 'X' INCR R PUT "
" DO "
" 'S' INCR DROP "
" X 'Y' STO "
" WHILE Y 1 > REPEAT "
" A X GET A 'Y' DECR GET - "
" IF DUP 0 == SWAP ABS X Y - == OR THEN "
" 0 'Y' STO "
" 'A' X A X GET 1 - PUT "
" WHILE A X GET 0 == REPEAT "
" 'A' 'X' DECR A X GET 1 - PUT "
" END "
" END "
" END "
" UNTIL Y 1 == END "
" UNTIL X R == END "
" "
" S A "
" >> "
" >> "
" 'PRO' STO "
" 1 10 START PRO NEXT "
;
const BYTEPTR nq_stk=(const BYTEPTR) "<< 8 0 0 0 -> R S X Y "
"<< 1 R "
" START 0 "
" NEXT DO R 'X' INCR UNPICK "
" DO 'S' INCR DROP X 'Y' STO "
" WHILE Y 1 > REPEAT X PICK 'Y' DECR 1 + PICK - "
" IF DUP 0 == SWAP ABS X Y - == OR "
" THEN 0 'Y' STO X PICK 1 - X UNPICK "
" WHILE X PICK 0 == "
" REPEAT 'X' DECR PICK 1 - X UNPICK "
" END "
" END "
" END "
" UNTIL Y 1 == "
" END "
" UNTIL X R == "
" END 8 ->LIST S "
" >> "
" >> "
" 'NQ.STK' STO 1 10 START NQ.STK NEXT "
;
const BYTEPTR nq_idx=(const BYTEPTR) "<< 8 0 0 0 -> R S X Y "
"<< 1 R START 0 NEXT "
" DO R 'X' INCR UNPICK "
" DO 'S' INCR DROP X 'Y' STO "
" WHILE Y 1 > "
" REPEAT X PICK 'Y' DECR 1 + PICK - "
" IF DUP 0 == SWAP ABS X Y - == OR "
" THEN 0 'Y' STO X PICK 1 - X UNPICK "
" WHILE X PICK 0 == "
" REPEAT 'X' DECR PICK 1 - X UNPICK "
" END "
" END "
" END "
" UNTIL Y 1 == "
" END "
" UNTIL X R == "
" END 8 ->LIST S "
" >> "
" >> "
" 'NQ.IDX' STO 1 10 START NQ.IDX NEXT "
;
const BYTEPTR nq_istk=(const BYTEPTR) "<< 8 0 0 0 0 -> R S X Y Ax "
" << 1 R START 0 NEXT "
" DO 'X' INCR DROP R 'Ax' STO "
" DO 'S' INCR DROP X 'Y' STO "
" WHILE Y 1 > "
" REPEAT Ax Y PICK - 'Y' DECR DROP "
" IF DUP 0 == SWAP ABS X Y - == OR "
" THEN 0 'Y' STO 'Ax' DECR DROP "
" WHILE Ax 0 == "
" REPEAT 'X' DECR PICK 1 - 'Ax' STO "
" END "
" END "
" END "
" UNTIL Y 1 == "
" END Ax X UNPICK "
" UNTIL X R == "
" END 8 ->LIST S "
" >> "
" >> "
" 'NQ.ISTK' STO 1 10 START NQ.ISTK NEXT "
;
const BYTEPTR nq_new=(const BYTEPTR) "<< 1 -> X RES << "
" IF X 1 > THEN "
" X PICK 1 X 1 - FOR I "
" DUP I 2 + PICK - ABS X I - ABS "
" IF == THEN "
" 0 'RES' STO X 'I' STO "
" END "
" NEXT "
" DROP RES "
" ELSE "
" 1 "
" END "
" >> "
" >> "
" 'CHECKQUEEN' STO "
" << 9 OVER - -> X LIMIT "
" << "
" 1 8 START LIMIT 8 + ROLLD NEXT "
" LIMIT DUPN 1 8 START LIMIT LIMIT 8 + + ROLL NEXT "
" DO 9 ROLL X UNPICK "
" IF X CHECKQUEEN "
" THEN X 1 + DUP "
" IF 8 <= THEN IF DOLEVEL THEN 0 9 ROLLD 0 'LIMIT' STO ELSE X PICK 17 X - ROLLD END "
" ELSE 9 ROLLD 0 'LIMIT' STO END "
" ELSE X PICK 17 X - ROLLD "
" END 'LIMIT' DECR "
" UNTIL 0 <= "
" END "
" 1 9 X - START 9 ROLL DROP NEXT "
" IF LIMIT 0 == "
" THEN 0 ELSE 1 END "
" >> "
" >> "
" 'DOLEVEL' STO "
" << "
" 1 2 3 4 5 6 7 8 "
" 0 0 0 0 0 0 0 0 "
" 1 DOLEVEL DROP "
" 1 8 START 9 ROLL DROP NEXT "
" 8 ->LIST "
" >> "
" 'NEW.RUN' STO 1 10 START NEW.RUN NEXT "
;
const BYTEPTR nq_werner=(const BYTEPTR) "<< "
" 0 "
" DO "
" 8 SWAP 1 + "
" WHILE "
" DUP2 "
" DO 1 - "
" UNTIL "
" DUP2 5 + PICK - ABS "
" DUP2 - * NOT "
" END "
" REPEAT "
" DROP "
" WHILE SWAP DUP 1 SAME "
" REPEAT - "
" END "
" 1 - SWAP "
" END "
" DROP "
" UNTIL DUP 8 SAME "
" END "
" ->LIST "
" >> "
" 'NQ.W' STO 1 10 START NQ.W NEXT "
;
const BYTEPTR sincostest=(const BYTEPTR) "108 SETPREC -1 ACOS DUP 6 / SIN ";
const BYTEPTR realtest1008=(const BYTEPTR) "1008 SETPREC << 0. 1000. 0.1 FOR n "
"0.02 n DUP 0.1 + * / + "
"-0.1 STEP "
">> EVAL " ;
const BYTEPTR realtest108=(const BYTEPTR) "108 SETPREC << 0. 1000. 0.1 FOR n "
"0.02 n DUP 0.1 + * / + "
"-0.1 STEP "
">> EVAL " ;
const BYTEPTR realtest36=(const BYTEPTR) "36 SETPREC << 0. 1000. 0.1 FOR n "
"0.02 n DUP 0.1 + * / + "
"-0.1 STEP "
">> EVAL " ;
/*
void PrintObj(int x,int y,WORDPTR obj,DRAWSURFACE *scr)
{
WORDPTR string;
BINT nchars;
BYTEPTR charptr;
string=rplDecompile(obj,0);
if(string) {
// NOW PRINT THE STRING OBJECT
nchars=rplStrSize(string);
charptr=(BYTEPTR) (string+1);
DrawTextN(x,y,(char *)charptr,nchars,(UNIFONT *)&System7Font,15,scr);
}
}
*/
// WAITS FOR A KEY TO BE PRESSED IN SLOW MODE
BINT halWaitForKey()
@ -517,17 +306,18 @@ extern WORD cmdKeySeco[4];
void cmdRun(WORD Opcode)
{
cmdKeySeco[0]=MKPROLOG(DOCOL,2),
cmdKeySeco[1]=Opcode;
cmdKeySeco[2]=CMD_SEMI;
cmdKeySeco[3]=CMD_EXITRPL;
rplSetEntryPoint(cmdKeySeco);
WORDPTR obj=rplAllocTempOb(1);
if(obj) {
obj[0]=Opcode;
obj[1]=CMD_EXITRPL;
rplSetEntryPoint(obj);
rplRun();
}
}
// TYPICAL COMMAND KEY HANDLER.
// EXECUTES Opcode IN DIRECT MODE
// INSERTS Progmode AS TEXT IN THE COMMEND LINE WHEN IN PROGRAMMING MODE
// INSERTS Progmode AS TEXT IN THE COMMAND LINE WHEN IN PROGRAMMING MODE
// IF IsFunc == 0 --> IN ALG MODE INSERT THE SAME TEXT AS IN PROG. MODE
// IsFunc == 1 --> IN ALG MODE INSERT THE SAME TEXT AS IN PROG, WITH FUNCTION PARENTHESIS
// IsFunc < 0 --> NOT ALLOWED IN SYMBOLIC (ALG) MODE, DO NOTHING
@ -594,6 +384,182 @@ void cmdKeyHandler(WORD Opcode,BYTEPTR Progmode,BINT IsFunc)
}
}
void varsKeyHandler(BINT keymsg,BINT varnum)
{
if(!(halGetContext()&CONTEXT_INEDITOR)) {
if(halGetContext()==CONTEXT_STACK) {
// ACTION WHEN IN THE STACK
BINT nvars=rplGetVarCount();
BINT idx=halScreen.Menu2Page+varnum;
if((nvars>6)&&(varnum==5)) {
// THIS IS THE NXT KEY
if( (KM_SHIFTPLANE(keymsg)==SHIFT_LS)||(KM_SHIFTPLANE(keymsg)==SHIFT_LSHOLD)) halScreen.Menu2Page-=5;
else halScreen.Menu2Page+=5;
if(halScreen.Menu2Page>=nvars) halScreen.Menu2Page=0;
if(halScreen.Menu2Page<0) halScreen.Menu2Page=0;
halScreen.DirtyFlag|=MENU1_DIRTY|MENU2_DIRTY;
return;
}
// THIS IS A REGULAR VAR KEY
WORD Opcode;
WORDPTR *var=rplFindGlobalByIndex(idx);
if(!var) return; // EMPTY SLOT, NOTHING TO DO
if( (KM_SHIFTPLANE(keymsg)==SHIFT_LS)||(KM_SHIFTPLANE(keymsg)==SHIFT_LSHOLD)) {
// USER IS TRYING TO 'STO' INTO THE VARIABLE
rplPushData(var[0]); // PUSH THE NAME ON THE STACK
Opcode=CMD_STO;
} else {
if( (KM_SHIFTPLANE(keymsg)==SHIFT_RS)||(KM_SHIFTPLANE(keymsg)==SHIFT_RSHOLD)) {
// USER IS TRYING TO 'RCL' THE VARIABLE
rplPushData(var[1]); // PUSH THE CONTENT ON THE STACK
Opcode=0;
}
else {
// NORMAL EXECUTION IS BY DOING XEQ ON ITS CONTENTS
rplPushData(var[1]); // PUSH THE CONTENT ON THE STACK
Opcode=CMD_XEQ;
}
}
if(Opcode) cmdRun(Opcode);
if(Exceptions) {
// TODO: SHOW ERROR MESSAGE
halShowErrorMsg();
Exceptions=0;
} else halScreen.DirtyFlag|=MENU1_DIRTY|MENU2_DIRTY;
halScreen.DirtyFlag|=STACK_DIRTY;
}
}
else {
// ACTION INSIDE THE EDITOR
BINT nvars=rplGetVarCount();
BINT idx=halScreen.Menu2Page+varnum;
if((nvars>6)&&(varnum==5)) {
// THIS IS THE NXT KEY
if( (KM_SHIFTPLANE(keymsg)==SHIFT_LS)||(KM_SHIFTPLANE(keymsg)==SHIFT_LSHOLD)) halScreen.Menu2Page-=5;
else halScreen.Menu2Page+=5;
if(halScreen.Menu2Page>=nvars) halScreen.Menu2Page=0;
if(halScreen.Menu2Page<0) halScreen.Menu2Page=0;
halScreen.DirtyFlag|=MENU1_DIRTY|MENU2_DIRTY;
return;
}
// THIS IS A REGULAR VAR KEY
WORD Opcode;
WORDPTR *var=rplFindGlobalByIndex(idx);
if(!var) return; // EMPTY SLOT, NOTHING TO DO
if( (KM_SHIFTPLANE(keymsg)==SHIFT_LS)||(KM_SHIFTPLANE(keymsg)==SHIFT_LSHOLD)) {
switch(halScreen.CursorState&0xff)
{
case 'D':
case 'A':
if(endCmdLineAndCompile()) {
// FIND THE VARIABLE AGAIN, IT MIGHT'VE MOVED DUR TO GC
var=rplFindGlobalByIndex(idx);
// USER IS TRYING TO 'STO' INTO THE VARIABLE
rplPushData(var[0]); // PUSH THE NAME ON THE STACK
cmdRun(CMD_STO);
if(Exceptions) {
// TODO: SHOW ERROR MESSAGE
halShowErrorMsg();
Exceptions=0;
} else halScreen.DirtyFlag|=MENU1_DIRTY|MENU2_DIRTY;
halScreen.DirtyFlag|=STACK_DIRTY;
return;
}
break;
case 'P':
// USER IS TRYING TO 'STO' INTO THE VARIABLE
uiSeparateToken();
uiInsertCharacters("'");
uiInsertCharactersN((BYTEPTR)(*var+1),(BYTEPTR)(*var+1)+rplGetIdentLength(*var));
uiInsertCharacters("' STO");
uiSeparateToken();
break;
}
} else {
if( (KM_SHIFTPLANE(keymsg)==SHIFT_RS)||(KM_SHIFTPLANE(keymsg)==SHIFT_RSHOLD)) {
// USER IS TRYING TO RCL THE VARIABLE
switch(halScreen.CursorState&0xff)
{
case 'D':
case 'A':
if(endCmdLineAndCompile()) {
// FIND THE VARIABLE AGAIN, IT MIGHT'VE MOVED DUR TO GC
var=rplFindGlobalByIndex(idx);
// USER IS TRYING TO 'RCL' INTO THE VARIABLE
rplPushData(var[1]); // PUSH THE CONTENTS ON THE STACK
if(Exceptions) {
// TODO: SHOW ERROR MESSAGE
halShowErrorMsg();
Exceptions=0;
} else halScreen.DirtyFlag|=MENU1_DIRTY|MENU2_DIRTY;
halScreen.DirtyFlag|=STACK_DIRTY;
return;
}
break;
case 'P':
uiSeparateToken();
uiInsertCharacters("'");
uiInsertCharactersN((BYTEPTR)(*var+1),(BYTEPTR)(*var+1)+rplGetIdentLength(*var));
uiInsertCharacters("' RCL");
uiSeparateToken();
break;
}
} else {
// NORMAL EXECUTION - XEQ THE CONTENTS OR INSER THE NAME IN THE COMMAND LINE
switch(halScreen.CursorState&0xff)
{
case 'D':
if(endCmdLineAndCompile()) {
// FIND THE VARIABLE AGAIN, IT MIGHT'VE MOVED DUR TO GC
var=rplFindGlobalByIndex(idx);
rplPushData(var[1]); // XEQ THE CONTENTS
cmdRun(CMD_XEQ);
if(Exceptions) {
// TODO: SHOW ERROR MESSAGE
halShowErrorMsg();
Exceptions=0;
} else halScreen.DirtyFlag|=MENU1_DIRTY|MENU2_DIRTY;
halScreen.DirtyFlag|=STACK_DIRTY;
return;
}
break;
case 'A':
{
// JUST INSERT THE NAME
uiInsertCharactersN((BYTEPTR)(*var+1),(BYTEPTR)(*var+1)+rplGetIdentLength(*var));
break;
}
case 'P':
{
// INSERT THE NAME WITH SEPARATORS
uiSeparateToken();
uiInsertCharactersN((BYTEPTR)(*var+1),(BYTEPTR)(*var+1)+rplGetIdentLength(*var));
uiSeparateToken();
break;
}
}
}
}
}
}
void symbolKeyHandler(BINT keymsg,BYTEPTR symbol,BINT separate)
{
if(!(halGetContext()&CONTEXT_INEDITOR)) {
@ -650,7 +616,11 @@ void enterKeyHandler(BINT keymsg)
}
else{
endCmdLineAndCompile();
if(endCmdLineAndCompile()) {
halScreen.DirtyFlag|=STACK_DIRTY|MENU1_DIRTY|MENU2_DIRTY|STAREA_DIRTY;
}
}
}
@ -1204,6 +1174,10 @@ void shiftedalphaKeyHandler(BINT keymsg)
}
#define DECLARE_VARKEYHANDLER(name,idx) void name##KeyHandler(BINT keymsg) \
{ \
varsKeyHandler(keymsg,(BINT)(idx)); \
}
@ -1265,6 +1239,12 @@ DECLARE_SYMBKEYHANDLER(angle,"∡",0)
DECLARE_SYMBKEYHANDLER(degree,"°",0)
DECLARE_VARKEYHANDLER(var1,0)
DECLARE_VARKEYHANDLER(var2,1)
DECLARE_VARKEYHANDLER(var3,2)
DECLARE_VARKEYHANDLER(var4,3)
DECLARE_VARKEYHANDLER(var5,4)
DECLARE_VARKEYHANDLER(var6,5)
@ -1328,6 +1308,8 @@ struct keyhandler_t {
// LIST OF HANDLERS, END WITH action=NULL
const struct keyhandler_t const __keydefaulthandlers[]= {
// BASIC NUMBERS
{ KM_PRESS|KB_1, CONTEXT_ANY,&numberKeyHandler },
{ KM_PRESS|KB_2, CONTEXT_ANY,&numberKeyHandler },
{ KM_PRESS|KB_3, CONTEXT_ANY,&numberKeyHandler },
@ -1362,12 +1344,13 @@ const struct keyhandler_t const __keydefaulthandlers[]= {
{ KM_PRESS|KB_0|SHIFT_ALPHA, CONTEXT_ANY,&numberKeyHandler },
{ KM_PRESS|KB_DOT|SHIFT_ALPHA, CONTEXT_ANY,&dotKeyHandler },
// BASIC ON AND SHIFTS
{ KM_KEYDN|KB_ON, CONTEXT_ANY,&cancelKeyHandler },
{ KM_PRESS|KB_ALPHA|SHIFT_RS, CONTEXT_ANY,&shiftedalphaKeyHandler },
{ KM_PRESS|KB_ALPHA|SHIFT_RSHOLD, CONTEXT_ANY,&shiftedalphaKeyHandler },
// TEXT EDITING KEYS
{ KM_PRESS|KB_ENT, CONTEXT_ANY,&enterKeyHandler },
{ KM_PRESS|KB_ENT|SHIFT_ALPHA, CONTEXT_ANY,&enterKeyHandler },
{ KM_PRESS|KB_ENT|SHIFT_ALPHAHOLD, CONTEXT_ANY,&enterKeyHandler },
@ -1393,6 +1376,7 @@ const struct keyhandler_t const __keydefaulthandlers[]= {
{ KM_PRESS|KB_DN, CONTEXT_ANY,&downKeyHandler },
{ KM_PRESS|KB_DN|SHIFT_ALPHA, CONTEXT_ANY,&downKeyHandler },
// BASIC OPERATORS
{ KM_PRESS|KB_ADD, CONTEXT_ANY,&addKeyHandler },
{ KM_PRESS|KB_SUB, CONTEXT_ANY,&subKeyHandler },
{ KM_PRESS|KB_DIV, CONTEXT_ANY,&divKeyHandler },
@ -1403,6 +1387,51 @@ const struct keyhandler_t const __keydefaulthandlers[]= {
{ KM_PRESS|KB_DIV|SHIFT_ALPHA|SHIFT_RSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(sdiv) },
{ KM_PRESS|KB_MUL|SHIFT_ALPHA, CONTEXT_ANY,KEYHANDLER_NAME(smul) },
// VARS MENU KEYS
{ KM_PRESS|KB_G, CONTEXT_ANY,KEYHANDLER_NAME(var1)},
{ KM_PRESS|KB_G|SHIFT_LS, CONTEXT_ANY,KEYHANDLER_NAME(var1)},
{ KM_PRESS|KB_G|SHIFT_LSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var1)},
{ KM_PRESS|KB_G|SHIFT_RS, CONTEXT_ANY,KEYHANDLER_NAME(var1)},
{ KM_PRESS|KB_G|SHIFT_RSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var1)},
//{ KM_LPRESS|KB_G, CONTEXT_ANY,KEYHANDLER_NAME(apps)},
{ KM_PRESS|KB_H, CONTEXT_ANY,KEYHANDLER_NAME(var2)},
{ KM_PRESS|KB_H|SHIFT_LS, CONTEXT_ANY,KEYHANDLER_NAME(var2)},
{ KM_PRESS|KB_H|SHIFT_LSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var2)},
{ KM_PRESS|KB_H|SHIFT_RS, CONTEXT_ANY,KEYHANDLER_NAME(var2)},
{ KM_PRESS|KB_H|SHIFT_RSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var2)},
//{ KM_LPRESS|KB_H, CONTEXT_ANY,KEYHANDLER_NAME(mode)},
{ KM_PRESS|KB_I, CONTEXT_ANY,KEYHANDLER_NAME(var3)},
{ KM_PRESS|KB_I|SHIFT_LS, CONTEXT_ANY,KEYHANDLER_NAME(var3)},
{ KM_PRESS|KB_I|SHIFT_LSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var3)},
{ KM_PRESS|KB_I|SHIFT_RS, CONTEXT_ANY,KEYHANDLER_NAME(var3)},
{ KM_PRESS|KB_I|SHIFT_RSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var3)},
//{ KM_LPRESS|KB_I, CONTEXT_ANY,KEYHANDLER_NAME(tool)},
{ KM_PRESS|KB_J, CONTEXT_ANY,KEYHANDLER_NAME(var4)},
{ KM_PRESS|KB_J|SHIFT_LS, CONTEXT_ANY,KEYHANDLER_NAME(var4)},
{ KM_PRESS|KB_J|SHIFT_LSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var4)},
{ KM_PRESS|KB_J|SHIFT_RS, CONTEXT_ANY,KEYHANDLER_NAME(var4)},
{ KM_PRESS|KB_J|SHIFT_RSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var4)},
//{ KM_LPRESS|KB_J, CONTEXT_ANY,KEYHANDLER_NAME(varsmenu)},
{ KM_PRESS|KB_K, CONTEXT_ANY,KEYHANDLER_NAME(var5)},
{ KM_PRESS|KB_K|SHIFT_LS, CONTEXT_ANY,KEYHANDLER_NAME(var5)},
{ KM_PRESS|KB_K|SHIFT_LSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var5)},
{ KM_PRESS|KB_K|SHIFT_RS, CONTEXT_ANY,KEYHANDLER_NAME(var5)},
{ KM_PRESS|KB_K|SHIFT_RSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var5)},
//{ KM_LPRESS|KB_K, CONTEXT_ANY,KEYHANDLER_NAME(oldsto)},
{ KM_PRESS|KB_L, CONTEXT_ANY,KEYHANDLER_NAME(var6)},
{ KM_PRESS|KB_L|SHIFT_LS, CONTEXT_ANY,KEYHANDLER_NAME(var6)},
{ KM_PRESS|KB_L|SHIFT_LSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var6)},
{ KM_PRESS|KB_L|SHIFT_RS, CONTEXT_ANY,KEYHANDLER_NAME(var6)},
{ KM_PRESS|KB_L|SHIFT_RSHOLD, CONTEXT_ANY,KEYHANDLER_NAME(var6)},
//{ KM_LPRESS|KB_L, CONTEXT_ANY,KEYHANDLER_NAME(nxt)},
{ KM_PRESS|KB_Y, CONTEXT_ANY,&invKeyHandler },
{ KM_PRESS|KB_SPC, CONTEXT_ANY,&spcKeyHandler },
{ KM_REPEAT|KB_SPC, CONTEXT_ANY,&spcKeyHandler },

View file

@ -283,6 +283,8 @@ halScreen.FormFont=halScreen.StackFont=halScreen.Stack1Font=(UNIFONT *)Font_8C;
halScreen.MenuFont=(UNIFONT *)Font_6A;
halScreen.StAreaFont=(UNIFONT *)Font_6A;
halScreen.CmdLineFont=(UNIFONT *)Font_8C;
halScreen.Menu1List=0;
halScreen.Menu2Dir=0;
halScreen.Menu1Page=halScreen.Menu2Page=0;
halSetNotification(N_LEFTSHIFT,0);
halSetNotification(N_RIGHTSHIFT,0);
@ -328,7 +330,7 @@ void halRedrawMenu2(DRAWSURFACE *scr)
halScreen.DirtyFlag&=~MENU2_DIRTY;
return;
}
// TODO: EVERYTHING, SHOW EMPTY MENU FOR NOW
int ytop,ybottom;
int oldclipx,oldclipx2,oldclipy,oldclipy2;
@ -350,10 +352,21 @@ void halRedrawMenu2(DRAWSURFACE *scr)
oldclipy=scr->clipy;
oldclipy2=scr->clipy2;
// BASIC CHECK FOR CHANGE OF DIRECTORY
if(halScreen.Menu2Dir!=CurrentDir) {
halScreen.Menu2Dir=CurrentDir;
halScreen.Menu2Page=0;
}
BINT nvars=rplGetVarCount();
BINT k;
WORDPTR *var;
// BASIC CHECK OF VALIDITY - COMMANDS MAY HAVE RENDERED THE PAGE NUMBER INVALID
// FOR EXAMPLE BY PURGING VARIABLES
if((halScreen.Menu2Page>=nvars)||(halScreen.Menu2Page<0)) halScreen.Menu2Page=0;
// FIRST ROW
scr->clipy=ytop;
@ -365,11 +378,55 @@ void halRedrawMenu2(DRAWSURFACE *scr)
var=rplFindGlobalByIndex(halScreen.Menu2Page+k);
if(var) {
if(ISIDENT(**var)) {
DrawTextN(scr->clipx,ytop,(char *)(*var+1),(char *)(*var+1)+rplGetIdentLength(*var),halScreen.MenuFont,0xF,scr);
BINT w=StringWidthN((char *)(*var+1),(char *)(*var+1)+rplGetIdentLength(*var),halScreen.MenuFont);
if(w>=scr->clipx2-scr->clipx+1) w=scr->clipx;
else w=(scr->clipx2+scr->clipx-w)>>1;
DrawTextN(w,scr->clipy,(char *)(*var+1),(char *)(*var+1)+rplGetIdentLength(*var),halScreen.MenuFont,0xF,scr);
}
}
}
// SECOND ROW
scr->clipy=ytop+7;
scr->clipy2=ybottom;
for(k=0;k<2;++k) {
scr->clipx=22*k;
scr->clipx2=22*k+20;
var=rplFindGlobalByIndex(halScreen.Menu2Page+3+k);
if(var) {
if(ISIDENT(**var)) {
BINT w=StringWidthN((char *)(*var+1),(char *)(*var+1)+rplGetIdentLength(*var),halScreen.MenuFont);
if(w>=scr->clipx2-scr->clipx+1) w=scr->clipx;
else w=(scr->clipx2+scr->clipx-w)>>1;
DrawTextN(w,scr->clipy,(char *)(*var+1),(char *)(*var+1)+rplGetIdentLength(*var),halScreen.MenuFont,0xF,scr);
}
}
}
// NOW DO THE NXT KEY
scr->clipx=22*k;
scr->clipx2=22*k+20;
if(nvars==6) {
var=rplFindGlobalByIndex(halScreen.Menu2Page+3+k);
if(var) {
if(ISIDENT(**var)) {
BINT w=StringWidthN((char *)(*var+1),(char *)(*var+1)+rplGetIdentLength(*var),halScreen.MenuFont);
if(w>=scr->clipx2-scr->clipx+1) w=scr->clipx;
else w=(scr->clipx2+scr->clipx-w)>>1;
DrawTextN(w,scr->clipy,(char *)(*var+1),(char *)(*var+1)+rplGetIdentLength(*var),halScreen.MenuFont,0xF,scr);
}
}
} else {
if(nvars>6) {
DrawText(scr->clipx,scr->clipy,"NXT...",halScreen.MenuFont,0xF,scr);
}
}
scr->clipx=oldclipx;
@ -474,8 +531,11 @@ void halRedrawAll(DRAWSURFACE *scr)
if(halScreen.DirtyFlag&STACK_DIRTY) halRedrawStack(scr);
if(halScreen.DirtyFlag&CMDLINE_ALLDIRTY) halRedrawCmdLine(scr);
if(halScreen.DirtyFlag&MENU1_DIRTY) halRedrawMenu1(scr);
if(!halScreen.SAreaTimer) {
// ONLY REDRAW IF THERE'S NO POPUP MESSAGES
if(halScreen.DirtyFlag&MENU2_DIRTY) halRedrawMenu2(scr);
if(halScreen.DirtyFlag&STAREA_DIRTY) halRedrawStatus(scr);
}
}
void status_popup_handler()
@ -508,10 +568,10 @@ void halErrorPopup()
if(halScreen.SAreaTimer) {
tmr_eventkill(halScreen.SAreaTimer);
//tmr_eventpause(halScreen.SAreaTimer);
//tmr_eventresume(halScreen.SAreaTimer); // PAUSE/RESUME WILL RESTART THE 5 SECOND COUNT
//tmr_eventresume(halScreen.SAreaTimer); // PAUSE/RESUME WILL RESTART THE 3 SECOND COUNT
//return;
}
halScreen.SAreaTimer=tmr_eventcreate(&status_popup_handler,5000,0);
halScreen.SAreaTimer=tmr_eventcreate(&status_popup_handler,3000,0);
}

View file

@ -123,6 +123,8 @@ typedef struct {
UNIFONT *MenuFont;
UNIFONT *CmdLineFont;
UNIFONT *StAreaFont;
WORDPTR Menu1List;
WORDPTR *Menu2Dir;
int Menu1Page;
int Menu2Page;
// VARIABLES FOR THE TEXT EDITOR / COMMAND LINE

View file

@ -43,6 +43,32 @@ void growDirs(WORD newtotalsize)
DirSize=newtotalsize;
}
// CHECK IF AN IDENT IS QUOTED, IF NOT THEN
// CREATE A NEW QUOTED OBJECT AND RETURN IT
// MAY CAUSE GARBAGE COLLECTION
WORDPTR rplMakeIdentQuoted(WORDPTR ident)
{
if(!ISHIDDENIDENT(*ident)) return ident;
ident=rplMakeNewCopy(ident);
// CHANGE FROM A IDENTEVAL TO A REGULAR IDENT
ident[0]-=MKOPCODE(DOIDENTEVAL-DOIDENT,0);
return ident;
}
// DIRECTORY STRUCTURE:
@ -82,8 +108,9 @@ void rplCreateGlobalInDir(WORDPTR nameobj,WORDPTR value,WORDPTR *parentdir)
// FIX THE CURRENT DIR IN CASE IT MOVED
if(CurrentDir>=direntry) CurrentDir+=2;
if(DirSize<=DirsTop-Directories+DIRSLACK) growDirs((WORD)(DirsTop-Directories+DIRSLACK+1024));
if(Exceptions) return;
}
@ -272,6 +299,30 @@ BINT rplGetVarCount()
return *(CurrentDir[1]+1);
}
// GET TOTAL NUMBER OF VISIBLE VARIABLES IN THE DIRECTORY
// SKIPS ANY VARIABLES WHERE THE KEY IS NOT A NUMBER OR
// ANY IDENTS THAT ARE MARKED AS HIDDEN (BY PROLOG DOIDENTEVAL...)
BINT rplGetVisibleVarCountInDir(WORDPTR *directory)
{
BINT n=0;
WORDPTR *dirptr=directory+4;
while(*dirptr!=dir_end_bint) {
if(ISIDENT(**dirptr) && !ISHIDDENIDENT(**dirptr)) ++n;
dirptr+=2;
}
return n;
}
BINT rplGetVisibleVarCount()
{
return rplGetVisibleVarCountInDir(CurrentDir);
}
// RCL A GLOBAL, RETURN POINTER TO ITS VALUE
// LOOKS IN CURRENT DIR AND PARENT DIRECTORIES
WORDPTR rplGetGlobal(WORDPTR nameobj)

View file

@ -163,7 +163,8 @@ void LIB_HANDLER()
}
else {
*(newdir+3)=*(CurrentDir+1);
rplCreateGlobal(rplPeekData(1),*(newdir+1));
WORDPTR name=rplMakeIdentQuoted(rplPeekData(1));
rplCreateGlobal(name,*(newdir+1));
}
rplDropData(2);
return;
@ -178,7 +179,8 @@ void LIB_HANDLER()
}
else {
// CREATE A NEW GLOBAL VARIABLE
rplCreateGlobal(rplPeekData(1),rplPeekData(2));
WORDPTR name=rplMakeIdentQuoted(rplPeekData(1));
rplCreateGlobal(name,rplPeekData(2));
}
rplDropData(2);
}

View file

@ -153,6 +153,7 @@ extern void libGetPTRFromID(WORDPTR *table,WORD id);
// USEFUL MACROS FOR TYPE IDENTIFICATION
#define ISIDENT(prolog) ( ISPROLOG(prolog) && ((LIBNUM(prolog)>=DOIDENT)&&(LIBNUM(prolog)<=DOIDENTEVALAPP)) )
#define ISHIDDENIDENT(prolog) ( ISPROLOG(prolog) && ((LIBNUM(prolog)>=DOIDENTEVAL)&&(LIBNUM(prolog)<=DOIDENTEVALAPP)) )
#define ISBINT(prolog) ( ((OPCODE(prolog)<0x400000) || ISPROLOG(prolog)) && (((LIBNUM(prolog)&~APPROX_BIT)>=BINBINT) && ((LIBNUM(prolog)&~APPROX_BIT)<=HEXBINT)))
#define ISLIST(prolog) ( ISPROLOG(prolog) && (LIBNUM(prolog)==DOLIST))
#define ISREAL(prolog) ( ISPROLOG(prolog) && (((LIBNUM(prolog)&~APPROX_BIT)==DOREAL)))
@ -341,6 +342,7 @@ extern const WORD empty_list[];
#define CMD_TAN MKOPCODE(66,2)
#define CMD_SQRT MKOPCODE(66,18)
#define CMD_STO MKOPCODE(28,0)
#define CMD_XEQ MKOPCODE(LIB_OVERLOADABLE,OVR_XEQ)
#define CMD_RCL MKOPCODE(28,1)
#define CMD_PURGE MKOPCODE(28,4)
#define CMD_CLEAR MKOPCODE(72,1)

View file

@ -270,6 +270,7 @@ extern BINT rplLAMCount(WORDPTR *LAMEnvironment);
// GLOBAL VARIABLES AND DIRECTORY FUNCTIONS
extern void growDirs(WORD newtotalsize);
extern WORDPTR rplMakeIdentQuoted(WORDPTR ident);
extern void rplCreateGlobalInDir(WORDPTR nameobj,WORDPTR value,WORDPTR *parentdir);
extern void rplCreateGlobal(WORDPTR nameobj,WORDPTR value);
extern WORDPTR *rplFindDirbyHandle(WORDPTR handle);
@ -304,6 +305,8 @@ extern WORDPTR rplGetSettingsbyName(BYTEPTR name,BINT namelen);
extern void rplCallOvrOperator(WORD op);
extern void rplCallOperator(WORD op);
extern void rplCopyObject(WORDPTR dest, WORDPTR src);
extern WORDPTR rplMakeNewCopy(WORDPTR object);
// BINT FUNCTIONS
extern WORDPTR rplNewSINT(int num,int base);

View file

@ -269,6 +269,24 @@ inline WORD rplObjSize(WORDPTR ip)
return 1+((ISPROLOG(*ip))? OBJSIZE(*ip):0);
}
// ALLOCATES MEMORY AND MAKES AN EXACT DUPLICATE OF object
// USES ONE SCRATCH POINTER
// RETURNS NULL IF ERROR
WORDPTR rplMakeNewCopy(WORDPTR object)
{
WORD prolog=*object;
BINT size=0;
if(ISPROLOG(prolog)) size=OBJSIZE(prolog);
ScratchPointer1=object;
WORDPTR newobj=rplAllocTempOb(size);
if(!newobj) return 0;
memmovew((void *)newobj,(void *)ScratchPointer1,1+size);
return newobj;
}
// COPIES AN OBJECT FROM src TO dest
// SAFE EVEN IF OBJECTS OVERLAP