mirror of
https://git.code.sf.net/p/newrpl/sources
synced 2024-11-16 19:51:25 +01:00
Added more keys behavior
This commit is contained in:
parent
f458a73343
commit
48e834deda
7 changed files with 129 additions and 18 deletions
|
@ -339,18 +339,16 @@ void waitforspeed_handler()
|
||||||
// ID N*8 WITH N<100 ARE RESERVED FOR THE SYSTEM APPLICATIONS (SOLVER, ETC)
|
// ID N*8 WITH N<100 ARE RESERVED FOR THE SYSTEM APPLICATIONS (SOLVER, ETC)
|
||||||
// ID= N*8 --> USER CONTEXTS FROM N=100 AND UP TO 16250 ARE FREE TO USE
|
// ID= N*8 --> USER CONTEXTS FROM N=100 AND UP TO 16250 ARE FREE TO USE
|
||||||
|
|
||||||
BINT __keycontext __attribute__ ((section (".system_globals")));
|
|
||||||
|
|
||||||
// SET THE KEYBOARD CONTEXT
|
// SET THE KEYBOARD CONTEXT
|
||||||
void halSetContext(BINT KeyContext)
|
void halSetContext(BINT KeyContext)
|
||||||
{
|
{
|
||||||
__keycontext=KeyContext;
|
halScreen.KeyContext=KeyContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AND RETRIEVE
|
// AND RETRIEVE
|
||||||
BINT halGetContext()
|
BINT halGetContext()
|
||||||
{
|
{
|
||||||
return __keycontext;
|
return halScreen.KeyContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -391,15 +389,6 @@ void testKeyHandler(BINT keymsg)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
|
||||||
CONTEXT_ANY=0,
|
|
||||||
CONTEXT_INEDITOR=1,
|
|
||||||
CONTEXT_STACK=8,
|
|
||||||
CONTEXT_PICT=16
|
|
||||||
// ADD MORE SYSTEM CONTEXTS HERE
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// ******************* DEFAULT KEY HANDLERS **************************
|
// ******************* DEFAULT KEY HANDLERS **************************
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
@ -459,8 +448,74 @@ void dotKeyHandler(BINT keymsg)
|
||||||
uiOpenCmdLine();
|
uiOpenCmdLine();
|
||||||
}
|
}
|
||||||
uiInsertCharacters(".",1);
|
uiInsertCharacters(".",1);
|
||||||
halScreen.DirtyFlag|=CMDLINE_DIRTY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enterKeyHandler(BINT keymsg)
|
||||||
|
{
|
||||||
|
if(!(halGetContext()&CONTEXT_INEDITOR)) {
|
||||||
|
// PERFORM DUP
|
||||||
|
if(halGetContext()==CONTEXT_STACK) {
|
||||||
|
// PERFORM DUP ONLY IF THERE'S DATA ON THE STACK
|
||||||
|
// DON'T ERROR IF STACK IS EMPTY
|
||||||
|
if(rplDepthData()>0) rplPushData(rplPeekData(1));
|
||||||
|
halScreen.DirtyFlag|=STACK_DIRTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
WORDPTR text=uiGetCmdLineText();
|
||||||
|
if(!text) {
|
||||||
|
throw_dbgexception("No memory for command line",__EX_CONT|__EX_WARM|__EX_RESET);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BINT len=rplStrLen(text);
|
||||||
|
WORDPTR newobject;
|
||||||
|
if(len) {
|
||||||
|
newobject=rplCompile((BYTEPTR)(text+1),len,1);
|
||||||
|
if(Exceptions || (!newobject)) {
|
||||||
|
// TODO: SHOW ERROR MESSAGE AND SELECT THE WORD THAT CAUSED THE ERROR
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// RUN THE OBJECT
|
||||||
|
rplSetEntryPoint(newobject);
|
||||||
|
rplRun();
|
||||||
|
if(Exceptions) {
|
||||||
|
// TODO: SHOW ERROR MESSAGE
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// EVERYTHING WENT FINE, CLOSE THE COMMAND LINE
|
||||||
|
uiCloseCmdLine();
|
||||||
|
halSetCmdLineHeight(0);
|
||||||
|
halSetContext(halGetContext()& (~CONTEXT_INEDITOR));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void backspKeyHandler(BINT keymsg)
|
||||||
|
{
|
||||||
|
if(!(halGetContext()&CONTEXT_INEDITOR)) {
|
||||||
|
// DO DROP
|
||||||
|
if(halGetContext()==CONTEXT_STACK) {
|
||||||
|
// PERFORM DROP ONLY IF THERE'S DATA ON THE STACK
|
||||||
|
// DON'T ERROR IF STACK IS EMPTY
|
||||||
|
if(rplDepthData()>0) rplDropData(1);
|
||||||
|
halScreen.DirtyFlag|=STACK_DIRTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// REMOVE CHARACTERS FROM THE COMMAND LINE
|
||||||
|
// TODO: IMPLEMENT THIS!
|
||||||
|
uiInsertCharacters("**",2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// ******************* END OF DEFAULT KEY HANDLERS **************************
|
// ******************* END OF DEFAULT KEY HANDLERS **************************
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
@ -490,6 +545,9 @@ struct keyhandler_t __keydefaulthandlers[]= {
|
||||||
{ KM_PRESS|KB_9, CONTEXT_ANY,&numberKeyHandler },
|
{ KM_PRESS|KB_9, CONTEXT_ANY,&numberKeyHandler },
|
||||||
{ KM_PRESS|KB_0, CONTEXT_ANY,&numberKeyHandler },
|
{ KM_PRESS|KB_0, CONTEXT_ANY,&numberKeyHandler },
|
||||||
{ KM_PRESS|KB_DOT, CONTEXT_ANY,&dotKeyHandler },
|
{ KM_PRESS|KB_DOT, CONTEXT_ANY,&dotKeyHandler },
|
||||||
|
{ KM_PRESS|KB_ENT, CONTEXT_ANY,&enterKeyHandler },
|
||||||
|
{ KM_PRESS|KB_BKS, CONTEXT_ANY,&backspKeyHandler },
|
||||||
|
|
||||||
{ 0 , 0 , 0 }
|
{ 0 , 0 , 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -523,7 +581,7 @@ struct keyhandler_t *ptr=__keydefaulthandlers;
|
||||||
while(ptr->action) {
|
while(ptr->action) {
|
||||||
if(ptr->message==keymsg) {
|
if(ptr->message==keymsg) {
|
||||||
// CHECK IF CONTEXT MATCHES
|
// CHECK IF CONTEXT MATCHES
|
||||||
if((!ptr->context) || (ptr->context==__keycontext)) {
|
if((!ptr->context) || (ptr->context==halScreen.KeyContext)) {
|
||||||
// IT'S A MATCH, EXECUTE THE ACTION;
|
// IT'S A MATCH, EXECUTE THE ACTION;
|
||||||
(ptr->action)(keymsg);
|
(ptr->action)(keymsg);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -275,6 +275,7 @@ halSetFormHeight(0);
|
||||||
halScreen.DirtyFlag=STACK_DIRTY|MENU1_DIRTY|MENU2_DIRTY;
|
halScreen.DirtyFlag=STACK_DIRTY|MENU1_DIRTY|MENU2_DIRTY;
|
||||||
halScreen.SAreaTimer=0;
|
halScreen.SAreaTimer=0;
|
||||||
halScreen.CursorTimer=0;
|
halScreen.CursorTimer=0;
|
||||||
|
halScreen.KeyContext=CONTEXT_STACK;
|
||||||
halScreen.FormFont=halScreen.StackFont=halScreen.Stack1Font=(FONTDATA *)System7Font;
|
halScreen.FormFont=halScreen.StackFont=halScreen.Stack1Font=(FONTDATA *)System7Font;
|
||||||
halScreen.MenuFont=(FONTDATA *)System5Font;
|
halScreen.MenuFont=(FONTDATA *)System5Font;
|
||||||
halScreen.StAreaFont=(FONTDATA *)MiniFont;
|
halScreen.StAreaFont=(FONTDATA *)MiniFont;
|
||||||
|
|
|
@ -131,11 +131,21 @@ typedef struct {
|
||||||
int CursorPosition; // OFFSET FROM START OF CURRENT LINE
|
int CursorPosition; // OFFSET FROM START OF CURRENT LINE
|
||||||
int CursorX,XVisible;
|
int CursorX,XVisible;
|
||||||
int SelectionStart,SelectionEnd;
|
int SelectionStart,SelectionEnd;
|
||||||
|
// VARIABLES FOR USER INTERFACE
|
||||||
|
int KeyContext;
|
||||||
} HALSCREEN;
|
} HALSCREEN;
|
||||||
|
|
||||||
|
|
||||||
extern HALSCREEN halScreen;
|
extern HALSCREEN halScreen;
|
||||||
|
|
||||||
|
// CALCULATOR CONTEXT IDENTIFIERS
|
||||||
|
enum {
|
||||||
|
CONTEXT_ANY=0,
|
||||||
|
CONTEXT_INEDITOR=1,
|
||||||
|
CONTEXT_STACK=8,
|
||||||
|
CONTEXT_PICT=16
|
||||||
|
// ADD MORE SYSTEM CONTEXTS HERE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//! Type definition for interrupt handler functions
|
//! Type definition for interrupt handler functions
|
||||||
|
|
|
@ -412,7 +412,7 @@ __keynumber=0;
|
||||||
__kmat=0LL;
|
__kmat=0LL;
|
||||||
__keyb_repeattime=80/KEYB_SCANSPEED;
|
__keyb_repeattime=80/KEYB_SCANSPEED;
|
||||||
__keyb_longpresstime=1000/KEYB_SCANSPEED;
|
__keyb_longpresstime=1000/KEYB_SCANSPEED;
|
||||||
__keyb_debounce=20/KEYB_SCANSPEED;
|
__keyb_debounce=0; //20/KEYB_SCANSPEED;
|
||||||
__keyb_lock=0;
|
__keyb_lock=0;
|
||||||
__pckeymatrix=0;
|
__pckeymatrix=0;
|
||||||
// INITIALIZE TIMER EVENT 0
|
// INITIALIZE TIMER EVENT 0
|
||||||
|
|
|
@ -32,6 +32,13 @@ void uiSetCmdLineText(WORDPTR text)
|
||||||
halScreen.DirtyFlag|=CMDLINE_ALLDIRTY;
|
halScreen.DirtyFlag|=CMDLINE_ALLDIRTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WORDPTR uiGetCmdLineText()
|
||||||
|
{
|
||||||
|
if(halScreen.LineIsModified>0) uiModifyLine();
|
||||||
|
if(Exceptions) return NULL;
|
||||||
|
return CmdLineText;
|
||||||
|
}
|
||||||
|
|
||||||
// SCROLL UP/DOWN AND LEFT/RIGHT TO KEEP CURSOR ON SCREEN
|
// SCROLL UP/DOWN AND LEFT/RIGHT TO KEEP CURSOR ON SCREEN
|
||||||
void uiEnsureCursorVisible()
|
void uiEnsureCursorVisible()
|
||||||
{
|
{
|
||||||
|
@ -97,6 +104,26 @@ void uiOpenCmdLine()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OPEN AN EMPTY COMMAND LINE
|
||||||
|
void uiCloseCmdLine()
|
||||||
|
{
|
||||||
|
tmr_eventkill(halScreen.CursorTimer);
|
||||||
|
|
||||||
|
CmdLineText=empty_string;
|
||||||
|
CmdLineCurrentLine=empty_string;
|
||||||
|
CmdLineUndoList=empty_list;
|
||||||
|
halScreen.LineCurrent=1;
|
||||||
|
halScreen.LineIsModified=-1;
|
||||||
|
halScreen.LineVisible=1;
|
||||||
|
halScreen.NumLinesVisible=1;
|
||||||
|
halScreen.CursorX=0;
|
||||||
|
halScreen.CursorPosition=0;
|
||||||
|
halScreen.CursorState=0;
|
||||||
|
halScreen.XVisible=0;
|
||||||
|
halScreen.DirtyFlag|=CMDLINE_ALLDIRTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void uiSetCurrentLine(BINT line)
|
void uiSetCurrentLine(BINT line)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -259,6 +286,7 @@ halScreen.CursorState&=~0x4000;
|
||||||
void uiModifyLine()
|
void uiModifyLine()
|
||||||
{
|
{
|
||||||
WORDPTR newobj;
|
WORDPTR newobj;
|
||||||
|
BINT newsize;
|
||||||
|
|
||||||
// GET A NEW OBJECT WITH ROOM FOR THE ENTIRE TEXT
|
// GET A NEW OBJECT WITH ROOM FOR THE ENTIRE TEXT
|
||||||
newobj=rplAllocTempOb( (rplStrLen(CmdLineText)+rplStrLen(CmdLineCurrentLine)+1+ 3)>>2);
|
newobj=rplAllocTempOb( (rplStrLen(CmdLineText)+rplStrLen(CmdLineCurrentLine)+1+ 3)>>2);
|
||||||
|
@ -289,6 +317,8 @@ void uiModifyLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
// COPY ALL PREVIOUS LINES TO NEW OBJECT
|
// COPY ALL PREVIOUS LINES TO NEW OBJECT
|
||||||
|
newsize=startline-src+rplStrLen(CmdLineCurrentLine);
|
||||||
|
|
||||||
memmove(dest,src,startline-src);
|
memmove(dest,src,startline-src);
|
||||||
// COPY THE NEW LINE TO THE OBJECT
|
// COPY THE NEW LINE TO THE OBJECT
|
||||||
memmove(dest+(startline-src),(WORDPTR)(CmdLineCurrentLine+1),rplStrLen(CmdLineCurrentLine));
|
memmove(dest+(startline-src),(WORDPTR)(CmdLineCurrentLine+1),rplStrLen(CmdLineCurrentLine));
|
||||||
|
@ -297,9 +327,12 @@ void uiModifyLine()
|
||||||
// APPEND A NEWLINE AND KEEP GOING
|
// APPEND A NEWLINE AND KEEP GOING
|
||||||
dest+=startline-src+rplStrLen(CmdLineCurrentLine);
|
dest+=startline-src+rplStrLen(CmdLineCurrentLine);
|
||||||
*dest++='\n';
|
*dest++='\n';
|
||||||
|
newsize+=((BYTEPTR)rplSkipOb(CmdLineText))-endline+1;
|
||||||
memmove(dest,endline,((BYTEPTR)rplSkipOb(CmdLineText))-endline);
|
memmove(dest,endline,((BYTEPTR)rplSkipOb(CmdLineText))-endline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rplSetStringLength(newobj,newsize);
|
||||||
|
|
||||||
CmdLineText=newobj;
|
CmdLineText=newobj;
|
||||||
halScreen.LineIsModified=0;
|
halScreen.LineIsModified=0;
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,7 @@ const int keyMap[] = {
|
||||||
Qt::Key_Asterisk, 4,
|
Qt::Key_Asterisk, 4,
|
||||||
Qt::Key_Minus, 5,
|
Qt::Key_Minus, 5,
|
||||||
Qt::Key_Plus, 6,
|
Qt::Key_Plus, 6,
|
||||||
|
Qt::Key_Return, 7,
|
||||||
Qt::Key_Enter, 7,
|
Qt::Key_Enter, 7,
|
||||||
Qt::Key_P, 9,
|
Qt::Key_P, 9,
|
||||||
Qt::Key_T, 10,
|
Qt::Key_T, 10,
|
||||||
|
@ -154,11 +155,17 @@ const int keyMap[] = {
|
||||||
Qt::Key_Q, 34,
|
Qt::Key_Q, 34,
|
||||||
Qt::Key_V, 35,
|
Qt::Key_V, 35,
|
||||||
Qt::Key_A, 41,
|
Qt::Key_A, 41,
|
||||||
|
Qt::Key_F1, 41,
|
||||||
Qt::Key_B, 42,
|
Qt::Key_B, 42,
|
||||||
|
Qt::Key_F2, 42,
|
||||||
Qt::Key_C, 43,
|
Qt::Key_C, 43,
|
||||||
|
Qt::Key_F3, 43,
|
||||||
Qt::Key_D, 44,
|
Qt::Key_D, 44,
|
||||||
|
Qt::Key_F4, 44,
|
||||||
Qt::Key_E, 45,
|
Qt::Key_E, 45,
|
||||||
|
Qt::Key_F5, 45,
|
||||||
Qt::Key_F, 46,
|
Qt::Key_F, 46,
|
||||||
|
Qt::Key_F6, 46,
|
||||||
Qt::Key_G, 47,
|
Qt::Key_G, 47,
|
||||||
Qt::Key_Up, 49,
|
Qt::Key_Up, 49,
|
||||||
Qt::Key_Left, 50,
|
Qt::Key_Left, 50,
|
||||||
|
|
|
@ -144,6 +144,10 @@ WORDPTR rplCompile(BYTEPTR string,BINT length, BINT addwrapper)
|
||||||
infixmode=0;
|
infixmode=0;
|
||||||
previous_tokeninfo=0;
|
previous_tokeninfo=0;
|
||||||
|
|
||||||
|
|
||||||
|
NextTokenStart=(WORDPTR)string;
|
||||||
|
CompileStringEnd=(WORDPTR)(string+length);
|
||||||
|
|
||||||
if(addwrapper) {
|
if(addwrapper) {
|
||||||
rplCompileAppend(MKPROLOG(DOCOL,0));
|
rplCompileAppend(MKPROLOG(DOCOL,0));
|
||||||
if(RStkSize<=(ValidateTop-RStk)) growRStk(ValidateTop-RStk+RSTKSLACK);
|
if(RStkSize<=(ValidateTop-RStk)) growRStk(ValidateTop-RStk+RSTKSLACK);
|
||||||
|
@ -151,8 +155,6 @@ WORDPTR rplCompile(BYTEPTR string,BINT length, BINT addwrapper)
|
||||||
*ValidateTop++=CompileEnd-1; // POINTER TO THE WORD OF THE COMPOSITE, NEEDED TO STORE THE SIZE
|
*ValidateTop++=CompileEnd-1; // POINTER TO THE WORD OF THE COMPOSITE, NEEDED TO STORE THE SIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
NextTokenStart=(WORDPTR)string;
|
|
||||||
CompileStringEnd=(WORDPTR)(string+length);
|
|
||||||
|
|
||||||
|
|
||||||
// FIND THE START OF NEXT TOKEN
|
// FIND THE START OF NEXT TOKEN
|
||||||
|
|
Loading…
Reference in a new issue