📄 e3.c
字号:
goto SCloop;SCtab: edx+= (TAB - edx % TAB); // spaces for Tab: if (edx<=ecx) goto SCloop; // this tab to far away right? noSCret: RETURN;//------KeyHome:CALL(CountToLineBegin,32); edi-=eax; RETURN;//------KeyEnd: CALL(CountToLineEnd,33); edi+=eax; // points to a 0ah char RETURN;//------KeyIns: insstat = !insstat; RETURN;//------KeyDell:CALL(KeyLeft,34); if (extra) goto KeyDell2;KeyDel: if ((unsigned long)edi>=(unsigned long)ebp) goto KeyLeftEnd; eax=1; // delete one @ cursor goto DeleteByte;KeyDell2:if ((unsigned long)edi<=(unsigned long)sot) goto KeyLeftEnd; --linenr; --edi; goto KeyCtrlT1;//------KeyLeft:if ((((unsigned char*)edi)[-1]) != NEWLINE) { --edi; extra=0; } else extra=1;KeyLeftEnd:RETURN;//------KeyRight:if (*(unsigned char*)edi != NEWLINE) { ++edi; extra=0; } else extra=1; RETURN;//------KeyCLeft3:if ((unsigned long)edi<=(unsigned long)(sot)) goto KeyCLEnd; --edi;KeyCtrlLeft:CALL(KeyLeft,35); if (extra) goto KeyCLeft3; if (*(unsigned char*)edi <= 0x2f) goto KeyCtrlLeft; if (((unsigned char*)edi)[-1] > 0x2f) goto KeyCtrlLeft;KeyCLEnd:RETURN;//------KeyCRight3:CALL(CheckEof,36); if (extra) goto KeyCREnd; ++edi;KeyCtrlRight:CALL(KeyRight,37); if (extra) goto KeyCRight3; if (*(unsigned char*)edi <= 0x2f) goto KeyCtrlRight; if (((unsigned char*)edi)[-1] > 0x2f) goto KeyCtrlRight;KeyCREnd:RETURN;//---------------------------------------------------------------------//// processing special keys from the Ctrl-Q menu//KeyCtrlQE:CALL(LookPgBegin,38); // goto top left on screen CALL(KursorFirstLine,39); goto CQFNum;//------KeyCtrlQX:CALL(LookPgEnd,40); // 1st goto last line on screen CALL(KeyEnd,41); // 2nd goto line end CALL(KursorLastLine,42); goto CQFNum;//------KeyCtrlQV:if (!bereitsges) goto CtrlQFEnd; // goto last ^QA,^QF pos edi = oldQFpos; goto CQFNum;//------KeyCtrlQA:bereitsges = 2; CALL(AskForReplace,43); if (extra) goto CtrlQFEnd;CQACtrlL:PUSH(edi); CALL(FindText,44); if (!extra) goto CtrlQFNotFound; eax = suchlaenge; CALL(DeleteByte,45); eax = repllaenge; CALL(InsertByte,46); esi = (long)&replacetext; CALL(MoveBlock,47); goto CQFFound;//------KeyCtrlQF:bereitsges = 1; CALL(AskForFind,48); if (extra) goto CtrlQFEnd;CQFCtrlL:PUSH(edi); CALL(FindText,49); if (!extra) goto CtrlQFNotFound;CQFFound:oldQFpos = edi; POP(esi); // dummyCQFNum: numeriere = 1; RETURN;CtrlQFNotFound:POP(edi);CtrlQFEnd:RETURN;//------KeyCtrlQC:edi = (long)ebp; goto CQFNum;//------KeyCtrlQR:edi = (long)sot; goto CQFNum;//------KeyCtrlQP:ecx = veryold; if ((unsigned long)ecx>(unsigned long)ebp) goto SimpleRet4; edi=ecx;//------KeyCtrlL:if (bereitsges==2) goto CQACtrlL; if (bereitsges==1) goto CQFCtrlL;SimpleRet4:RETURN;//------KeyCtrlQB:eax=edi; edi = blockbegin;CtrlQB2:if (edi) goto CQFNum; edi=eax; // exit if no marker set RETURN;//------KeyCtrlQK:eax=edi; edi = blockende; goto CtrlQB2;//------KeyCtrlQI:CALL(GetAsciiToInteger,50); if (!ecx) goto SimpleRet4; edi = (long)sot; CALL(LookPD2,51);JmpCQFN:goto CQFNum;//------KeyCtrlQDel:CALL(KeyLeft,52); // delete all left of cursor CALL(CountToLineBegin,53); edi-=eax; CALL(DeleteByteCheckMarker,54); goto KeyCtrlT1;//------KeyCtrlQY:CALL(CountToLineEnd,55); goto CtrlTEnd1;//------KeyCtrlY:CALL(CountToLineBegin,56); edi-=eax; // edi at begin CALL(CountToLineEnd,57); CALL(DeleteByteCheckMarker,58); goto KeyCtrlT1;//------KeyCtrlT:CALL(CountToWordBegin,59); if (*(unsigned char*)edi != NEWLINE) goto CtrlTEnd1;KeyCtrlT1:CALL(CheckEof,60); if (extra) goto SimpleRet4; eax=1; // 1 for 0ahCtrlTEnd1:goto DeleteByteCheckMarker;//---------------------------------------------------------------------//// processing special Keys from Ctrl-K menu//KeyCtrlKY:CALL(CheckBlock,61); if (extra) goto SimpleRet3; // no block: no action eax = blockende; edi = esi; // esi is blockbegin (side effect in CheckBlock) eax-=esi; // block length CALL(DeleteByte,62); // out ecx:=0 blockende = ecx; // i.e. NO block valid now blockbegin = ecx; goto JmpCQFN;//------KeyCtrlKH:showblock^=1; // flip flopSimpleRet3:RETURN;//------KeyCtrlKK:blockende = edi; goto KCKB;//------KeyCtrlKW:CALL(CheckBlock,63); if (extra) goto SimpleRet2; // no action CALL(SaveBlock,64); goto CtrlKREnd;//------KeyCtrlKC:CALL(CopyBlock,65); if (extra) goto SimpleRet2;CtrlKC2:blockbegin = edi; blockende = eax+edi; RETURN;//------KeyCtrlKV:CALL(CopyBlock,66); if (extra) goto SimpleRet2; PUSH(edi); extra=0; if ((unsigned long)edi<(unsigned long)blockbegin) extra++; PUSH(extra); edi = blockbegin; CALL(DeleteByte,67); eax = -eax; // (for optimizing eax is negated there) POP(extra); POP(edi); if (extra) goto CtrlKC2; blockende = edi; edi-=eax;KeyCtrlKB:blockbegin = edi;KCKB: showblock = 1;SimpleRet2:RETURN;//------KeyCtrlKR:CALL(ReadBlock,68) if (extra) goto CtrlKREnd; CALL(KeyCtrlKB,69); ecx+=edi; blockende = ecx;CtrlKREnd:goto RestKursPos;//------KeyCtrlKS:CALL(SaveFile,70); // (called by ^kd) PUSH(extra); CALL(RestKursPos,71); POP(extra); if (extra) goto CtrlKSEnd; changed = UNCHANGED;CtrlKSEnd:RETURN;//------KeyCtrlKQ:if (changed==UNCHANGED) goto KCKXend; esi = (long)&asksave; CALL(DE1,72); CALL(RestKursPos,73); eax&=0xdf; if (eax !='Y') goto KCKXend; // Y for request SAVE changesKeyCtrlKX:CALL(KeyCtrlKS,74); if (extra) goto CtrlKSEnd;KCKXend:++endeedit;KeyKXend:RETURN;KeyCtrlKD:CALL(KeyCtrlKS,75); if (extra) goto CtrlKSEnd; endeedit = 2; RETURN;//--------------------------------------------------------------------//// the general PAGE DISPLAY function: called after any pressed key//// side effect: sets 'columne' for RestoreStatusLine function (displays columne)// variable kurspos: for placing the cursor at new position// register extra2 counts lines// register ebx counts columns visible on screen (w/o left scrolled)// register edx counts columns in text lines// register ecx screen line counter and helper for rep stos// register esi text index// register edi screen line buffer index//DispNewScreen:CALL(GetEditScreenSize,76); // check changed tty size isbold = 0; inverse = 0; zloffst = 0; columne = 0; fileptr = edi; // for seeking current cursor pos CALL(CountColToLineBeginVis,77);// i.e. expanding TABs ebx = columns; if (eax<ebx) goto DispShortLine; eax-=ebx; zloffst = eax+1;DispShortLine:CALL(LookPgBegin,78); // go on 1st char upper left on screen esi = edi; // esi for reading chars from text ecx = lines; extra2 = -1; // first line if (!ecx) goto KeyKXend; // window appears too smallDispNewLine:++extra2; // new line edi = (long)&screenline; // line display buffer edx=0; // reset char counter ebx = 0; // reset screen column to 0#ifdef LESSWRITEOPS CALL(SetColor2,79); // set initial character color per each line#endif DispCharLoop:if (esi != fileptr) goto DispCharL1;// display char @ cursor postion ? if (tabcnt) goto DispCharL1; kurspos = extra2<<8|ebx; columne = ebx+ zloffst; // chars scrolled left hidden#ifdef CURSORMGNT parm=1; CALL(SetInverseStatus,80); if (!extra) goto DispEndLine;#endif DispCharL1:CALL(SetColor,81); // set color if neccessary//------DispEndLine:if ((unsigned long)esi>(unsigned long)ebp) goto FillLine; // we have passed EOF, so now fill rest of screen if (!tabcnt) goto ELZ; --tabcnt; goto ELZ2;ELZ: if (esi != (long)ebp) goto ELZ6; ++esi; // set esi>ebp will later trigger "ja FillLine" goto ELZ2;ELZ6: eax=*(unsigned char*)esi++; if (eax != TABCHAR) goto ELZ3; tabcnt = TAB - edx % TAB - 1; // spaces for Tab and count out the tab char itselfELZ2: eax = SPACECHAR;ELZ3: if (eax==NEWLINE) goto FillLine; if (eax<SPACECHAR || eax== 0x7f) eax = '.'; // simply ignore chars like carriage_return etc. if (ebx>=columns) goto DispEndLine; // screen width ++edx; // also count hidden chars (left margin) if (edx<=zloffst) goto ELZ5; // load new char (but no display) *(unsigned char*)edi++=eax; #ifdef CURSORMGNT parm=0; CALL(SetInverseStatus,83);#endif ++ebx; // counts displayed chars onlyELZ5: goto DispCharLoop;//------FillLine:PUSH(ecx); // continue rest of line ecx = columns; // width ecx-=ebx; if (ecx) { if (inverse-1) goto FillLine1; // special cursor attribute? *(unsigned char*)edi++=SPACECHAR; // only 1st char with special attribute#ifdef CURSORMGNT parm=0; CALL(SetInverseStatus,84);#endif if (!--ecx) goto FillLine2; // one char lessFillLine1:do { *(unsigned char*)edi++=SPACECHAR; // store the rest blanks } while (--ecx); }FillLine2:POP(ecx); *(unsigned char*)edi = 0; CALL(ScreenLineShow,85); if (--ecx) goto DispNewLine; edi = fileptr; // restore text pointer goto RestKursPos;//---------------------------------------------------------------------// three helper subroutines called by DispNewScreen // dealing ESC sequences for character attributes// expecting parm 0|1// returning extra//SetInverseStatus:PUSH(ecx); // returns zero flag PUSH(esi); if (!parm) goto SIS1; if (insstat-1) { extra=1; goto SIS4; } inverse = 1; esi = (long)&reversevideoX; esi+=revvoff; // switch between esc seq for linux or Xterm goto SIS2;SIS1: if (inverse-1) goto SIS3; inverse = 0;SIS6: isbold = 0;SIS5: esi = (long)&bold0;SIS2: ecx = boldlen; do { *(unsigned char*)edi++=*(unsigned char*)esi++; } while (--ecx);SIS3: extra=0;SIS4: POP(esi); POP(ecx); RETURN;//------SetColor:PUSH(ecx); // expects extra-flag:bold else normal PUSH(esi); CALL(IsShowBlock,86); if (!extra) goto SCEsc1; if (isbold==1) goto SIS4; // never set bold if it is already bold isbold = 1;SCEsc2: esi = (long)&bold1; goto SIS2;SCEsc1: if (!isbold) goto SIS4; // ditto goto SIS6;//------#ifdef LESSWRITEOPSSetColor2:PUSH(ecx); PUSH(esi); CALL(IsShowBlock,87); if (!extra) goto SIS5; goto SCEsc2;#endif//------// a little helper for SetColor* functionsIsShowBlock:if (!showblock || !blockbegin || (unsigned long)blockbegin>(unsigned long)esi) goto SBlock; if ((unsigned long)esi<(unsigned long)blockende) goto SB_ret;SBlock: extra=0; RETURN;SB_ret: extra=1; RETURN;//------// this helper for DispNewScreen checks screen size before writing on screen// FIXME: adjusting edit screen resize works with xterm, but not with SVGATextMode//GetEditScreenSize: ecx = TIOCGWINSZ; edx = (long)&winsize; CALL(IOctlTerminal,88); eax = *(long*)edx; // each 16 bit lines,columns if (!eax) eax = 0x00500018; // i.e. (80<<16)+24 (assume 80x24) lines = (eax-1)&0xFF; // without status line#if 1 // this is not portable: maybe 32bit Linux plus some Un*x systems ? columns = eax >> 16; // columns > 255 are ignored...#else columns = 80;#endif RETURN;//---------------------------------------------------------------------//// LOWER LEVEL screen acces function (main +2 helpers)// this function does write the line buffer to screen i.e. terminal//// at first 2 special entry points:WriteTwo:*(long*)(&screenline) = ecx;StatusLineShow:ecx=0; // 0 for last lineScreenLineShow:PUSH(eax); PUSH(ecx); PUSH(edx); PUSH(ebx); PUSH((long)ebp); PUSH(esi); // expecting in ecx screen line counted from 0 PUSH(edi);#ifdef LESSWRITEOPS eax = (columns+32)*ecx; // estimated max ESC sequences extra bytes (i.e. boldlen*X) ebx = 0; // flag edi = eax+(long)screenbuffer;#endif edx=0; esi = (long)&screenline;sl3: eax=*(unsigned char*)esi++; ++edx; // count message length to write#ifdef LESSWRITEOPS if ((unsigned long)edi>=(unsigned long)(&screenbuffer_end)) goto sl5; // never read/write beyond buffer if (eax == *(unsigned char*)edi) goto sl4; *(unsigned char*)edi = eax;sl5: ++ebx; // set flag whether line need redrawingsl4: ++edi;#endif if (eax) goto sl3; --edx; // one too much#ifdef LESSWRITEOPS if (!ebx) goto NoWrite; // redraw ? ..no: quick exit#endif PUSH(edx); edx=(lines-ecx)<<8; CALL(sys_writeKP,89); // set cursor pos before writing the line POP(edx); PUSH(ecx); eax = (long)&screencolors1; // set bold yellow on blue CALL(sys_writeSLColors,90); // special for status line (ecx==0) ecx = (long)&screenline; // second argument: integer to message to write CALL(WriteFile0,91); POP(ecx);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -