bool Chp82143A::init(void) { Cprinter::init(); charTable = new QImage(P_RES(":/ext/ce126ptable.bmp")); charsize = 1; pCONNECTOR = new Cconnector(this,64,0,Cconnector::hp41,"hp41 Module",true,QPoint(631,468)); publish(pCONNECTOR); if(pKEYB) pKEYB->init(); if(pTIMER) pTIMER->init(); // Create Paper Image // The final paper image is 207 x 149 at (277,0) for the ce125 printerbuf = new QImage(QSize(paperWidth, 3000),QImage::Format_ARGB32); printerdisplay= new QImage(QSize(paperWidth, 250),QImage::Format_ARGB32); paperWidget = new CpaperWidget(PaperPos(),printerbuf,this); paperWidget->hide(); // paperWidget->show(); // paperWidget->hide(); // Fill it blank clearPaper(); settop(10); setposX(0); isready = true; return true; }
void Interpret(char expr[]) { SetIntSignal(True); if(commandline(expr)) ; else if(seterror()==0) { initstack(); restoretemplates(); CloseAllIOFiles(); interrupted = False; if(parseinput(expr)) checkexpression(top(), True); else { checkexpression(top(), False); settop(modify_expression(top())); starttiming(); toplevel(); stoptiming(); } } SetIntSignal(False); initstack(); restoretemplates(); CloseAllIOFiles(); interrupted = False; Write("\n"); }
Cpc2021::Cpc2021(CPObject *parent):Cprinter(parent) { //[constructor] setfrequency( 0); pc2021buf = 0; pc2021display= 0; //bells = 0; charTable = 0; margin = 25; ToDestroy = false; BackGroundFname = P_RES(":/ext/pc-2021.png"); setcfgfname("pc2021"); settop(10); setposX(0); pTIMER = new Ctimer(this); KeyMap = KeyMappc2021; KeyMapLenght= KeyMappc2021Lenght; pKEYB->setMap("pc2021.map"); setDXmm(108); setDYmm(130); setDZmm(43); setDX(386); setDY(464); setPaperPos(QRect(70,-3,275,149)); ctrl_char = false; t = 0; c = 0; rmtSwitch = false; internal_device_code = 0x0f; }
bool LuaWrapper::callLuaFunc(const char* szTableName, const char* szFuncName, const char* sig, ...) { int nIndexTop = gettop(); va_list vl; va_start(vl, sig); bool bRet = true; if (!loadTable(szTableName)) { luaL_error(m_luaState, "load table[%s] failed.", szTableName); bRet = false; } lua_pushstring(m_luaState, szFuncName); lua_gettable(m_luaState, -2);// key从栈弹出,并获取 table[key] 的值压入栈 if (!lua_isfunction(m_luaState, -1)) { luaL_error(m_luaState, "table [%s] field [ %s ] isn't an function.", szTableName, szFuncName); bRet = false; } else { bRet = doCallFunction(sig, vl); } va_end(vl); settop(nIndexTop); return bRet; }
bool parseinput(char s[]) { bool result = False; setchecktypevariables(NOCHECK); openinput(s); checkmemlarge(); storefunctionname(""); tokenoffside = 0; gettoken(); if(tokentype == empty) { push(template_nil); return result; } parseexpression(MAXPRIO); if(tokentype == WHERE) { gettoken(); parsewhereclause(); } if(tokentype == COLONS) result = True; else if(tokentype != empty) parseerror(19); closeinput(); initrename(""); settop(renamerec(EXP, top())); return result; }
void Chp82143A::clearPaper(void) { // Fill it blank printerbuf->fill(PaperColor.rgba()); printerdisplay->fill(QColor(255,255,255,0).rgba()); settop(10); setposX(0); // empty TextBuffer TextBuffer.clear(); paperWidget->updated = true; }
/*--------------------------------------------------------------*/ void main() { int a; s s1; clrscr(); settop(&s1); push(&s1,a); push(&s1,a); push(&s1,a); push(&s1,a); push(&s1,a); display(&s1); pop(&s1); pop(&s1); pop(&s1); display(&s1); push(&s1,a); gettop(&s1); display(&s1); getch(); }
PROC zdraw(char code) { int nl = ERR, np = (count>0)?to_index(count):curr; if (movemap[code] == CR_FWD) nl = 0; else if (movemap[code] == CR_BACK) nl = LINES-1; else if (code == '.') nl = LINES / 2; if (nl >= 0) { curr = np; yp = settop(nl); redisplay(TRUE); mvcur(yp,xp); } else error(); }
Cce126::Cce126(CPObject *parent):Cprinter(parent) { //[constructor] Q_UNUSED(parent) setfrequency( 0); ce126buf = 0; ce126display= 0; //bells = 0; charTable = 0; margin = 25; ToDestroy = false; BackGroundFname = P_RES(":/ext/ce-126p.png"); setcfgfname("ce126p"); settop(10); setposX(0); pTIMER = new Ctimer(this); KeyMap = KeyMapce126; KeyMapLenght= KeyMapce126Lenght; pKEYB->setMap("ce126.map"); setDX(620); setDY(488); setDXmm(116); setDYmm(140); setDZmm(23); setPaperPos(QRect(150,-3,207,149)); ctrl_char = false; t = 0; c = 0; rmtSwitch = false; internal_device_code = 0x0f; }
exec_type PROC editcore(void) { cmdtype cmd; extern bool s_wrapped; /* rcb[0] = 0; rcp = rcb; */ if (diddled) { setpos(skipws(curr)); /* set cursor x position.. */ yp = settop(LINES / 2); /* Y position */ } if (diddled || zotscreen) /* redisplay? */ redisplay(FALSE); mvcur(yp, xp); /* and move the cursor */ for (;;) { s_wrapped = 0; ch = readchar(); /* get a char */ gcount(); /* ... a possible count */ switch (cmd = movemap[ch]) { case FILE_C: wr_stat(); /* write file stats */ mvcur(yp, xp); break; case WINDOW_UP: case WINDOW_DOWN: scroll(cmd==WINDOW_UP); /* scroll the window */ break; case REDRAW_C: /* redraw the window */ redisplay(TRUE); mvcur(yp, xp); break; case MARKER_C: /* set a marker */ ch = tolower(readchar()); if (ch >= 'a' && ch <= 'z') contexts[ch-'`'] = curr; else if (ch != ESC) error(); break; case REDO_C: if (rcb[0] != 0) { zerostack(&undo); insertmacro(rcb, 1); redoing = TRUE; } break; case REWINDOW: zdraw(readchar()); /* shift the window */ break; case DEBUG_C: /* debugging stuff -- unused */ break; case ZZ_C: /* shortcut for :xit */ ch = readchar(); if (ch == 'Z') insertmacro(":x\r", 1); else if (ch != ESC) error(); break; case EDIT_C: /* drop into line mode */ return E_EDIT; case COLIN_C: /* do one exec mode command */ return E_VISUAL; case HARDMACRO: macrocommand(); /* 'hard-wired' macros */ break; case SOFTMACRO: exmacro(); /* run a macro */ break; case INSMACRO: /* macro for insert mode */ case BAD_COMMAND: error(); break; default: if (cmd < DELETE_C) movearound(cmd); else /*if (cmd < HARDMACRO)*/ docommand(cmd); break; } lastexec = 0; } /* never exits here */ }
PROC docommand(cmdtype cmd) { cmdtype movecmd; /* movement command for y, d, c */ char cmdch; int oldc; /* old count */ int endp; /* end position before change */ extern bool s_wrapped; resetX(); /* un-derange the cursor */ oldc = newc = -1; endY = yp; newend = disp = curr; ok = TRUE; /* so far everything is working */ cmdch = ch; if (cmd != UNDO_C && cmd != YANK_C) { if (macro<0) zerostack(&undo); if (redoing != TRUE) { rcp = rcb; /* point at start of redo buffer */ if (count > 1) { /* put in a count? */ numtoa(rcb,count); rcp += strlen(rcb); } *rcp++ = cmdch; /* the command char goes in... */ xerox = TRUE; /* hoist the magical flags */ } } if (cmd <= YANK_C) { readchar(); if (ch >= '0' && ch <= '9') { oldc = count; gcount(); /* get a new count */ if (cmd == ADJUST_C) /* special for >>,<< wierdness */ swap(&count, &oldc); /* reverse sw & count */ else count = count*max(oldc,1); /* combine them */ } if (ch == cmdch) { /* diddle lines */ yank.lines = TRUE; endp = nextline(TRUE, curr, count); curr = bseekeol(curr); disp = curr; } else { /* diddle 'things' */ yank.lines = FALSE; movecmd = movemap[ch]; if (ok = (findCP(curr,&endp,movecmd) == LEGALMOVE)) { if (curr > endp) { swap(&curr,&endp); ok = (cmd != CHANGE_C); } if (adjcurr[movecmd]) curr++; if (adjendp[movecmd]) endp++; } if (!ok) { if (ch != ESC) error(); goto killredo; } } endY = setY(endp); newend = curr; disp = curr; switch (cmd) { case DELETE_C: ok = deletion(curr, endp); break; case ADJUST_C: adjuster((cmdch == '<'), endp-1, oldc); break; case CHANGE_C: if (endp <= pend+1) { mvcur(setY(endp-1), setX(endp-1)); printch('$'); mvcur(yp, xp); } if (deletion(curr, endp)) ok = ((newend = insertion(1, 0, &disp, &endY, TRUE)) >= 0); else ok = FALSE; break; case YANK_C: if (!doyank(curr, endp)) error(); return 0; /* xerox will not be true, nor will redoing */ } } else { endp = curr; endY = yp; switch (cmd) { case I_AT_NONWHITE: case A_AT_END: case APPEND_C: case INSERT_C: /* variations on insert */ if (cmd != INSERT_C) { if (cmd == APPEND_C) curr = min(curr+1, lend); else if (cmd == A_AT_END) curr = lend; else /* if (cmd == I_AT_NONWHITE) */ curr = skipws(lstart); xp = setX(curr); mvcur(yp,xp); } newend = insertion(count, 0, &disp, &endY, TRUE); ok = (newend >= 0); break; case OPEN_C: case OPENUP_C: newend = insertion(1,setstep[ (cmd==OPENUP_C)&1 ], &disp,&endY,TRUE)-1; ok = (newend >= 0); break; case REPLACE_C: case TWIDDLE_C: if (cmd == REPLACE_C) { if ((cmdch = readchar()) == ESC) goto killredo; } if (findCP(curr, &endp, GO_RIGHT) == LEGALMOVE) squiggle(endp-1, cmdch, (cmd==REPLACE_C)); break; case PUT_BEFORE: case PUT_AFTER: ok = put(cmd==PUT_AFTER); break; case BIG_REPL_C: bigreplace(); break; case RESUBST_C: ok = FALSE; if (dst[0] != 0) { newend = chop(curr, &lend, TRUE, &ok); if (newend >= 0) { endY = setY(newend+strlen(dst)); ok = TRUE; } } break; case JOIN_C: join(count); /* join lines */ break; case UNDO_C: /* undo last modification */ ok = fixcore(&newend) >= 0; disp = newend; endY = MAGICNUMBER; break; } } if (ok) { setpos((newc<0)?newend:newc); setend(); if (curr < ptop || curr > pend) { yp = settop(12); redisplay(TRUE); } else { yp = setY(curr); if (endY != setY(newend)) /* shuffled lines */ refresh(setY(disp), setX(disp), disp, pend, TRUE); else /* refresh to end position */ refresh(setY(disp), setX(disp), disp, newend, FALSE); } if (curr >= bufmax && bufmax > 0) { /* adjust off end of buffer */ setpos(bufmax-1); yp = setY(curr); } if (s_wrapped) { prompt(FALSE, "search wrapped around end of buffer"); s_wrapped = 0; } else clrprompt(); modified = TRUE; } else { error(); killredo: rcb[0] = 0; } mvcur(yp, xp); if (xerox) *rcp = 0; /* terminate the redo */ redoing = FALSE; xerox = FALSE; core[bufmax] = EOL; }