📄 edmain.c
字号:
while (ktp < &keytab[NKEYTAB]) { if (ktp->k_code == c) { thisflag = 0; status = (*ktp->k_fp)(f, n); lastflag = thisflag; return (status); } ++ktp; } /* * If a space was typed, fill column is defined, the argument is non- * negative, and we are now past fill column, perform word wrap. */ if (c == ' ' && fillcol > 0 && n>=0 && getccol(FALSE) > fillcol) wrapword(); if ((c>=0x20 && c<=0x7E) /* Self inserting. */ || (c>=0xA0 && c<=0xFE)) { if (n <= 0) { /* Fenceposts. */ lastflag = 0; return (n<0 ? FALSE : TRUE); } thisflag = 0; /* For the future. */ status = linsert(n, c); lastflag = thisflag; return (status); } lastflag = 0; /* Fake last flags. */ return (FALSE);}/* * Read in a key. * Do the standard keyboard preprocessing. Convert the keys to the internal * character set. */globle int getkey(){ register int c; c = (*term.t_getchar)(); if ((c & META) == META) return(c);#if IBM_MSC || IBM_TBC || IBM_ZTC || IBM_ICB || IBM_SC || IBM_GCC if (c > 255) { switch (c) { case UP_ARROW : return (COTL | 'P'); case DOWN_ARROW : return (COTL | 'N'); case LEFT_ARROW : return (COTL | 'B'); case RIGHT_ARROW : return (COTL | 'F'); case PGUP_KEY : return (META | 'V'); case PGDN_KEY : return (COTL | 'V'); case HOME_KEY : return (META | '<'); case END_KEY : return (META | '>'); case COTL_LEFT_ARROW : return (META | 'B'); case COTL_RIGHT_ARROW : return (META | 'F'); case COTL_AT_SIGN : return (COTL | '@'); default : return (COTL | 'G'); } }#endif if (c == METACH) { /* Apply M- prefix */ c = getctl(); return (META | c); } if (c>=0x00 && c<=0x1F) /* C0 control -> C- */ c = COTL | (c+'@'); return (c);}/* * Get a key. * Apply control modifications to the read key. */globle int getctl(){ register int c; c = (*term.t_getchar)(); if (c>='a' && c<='z') /* Force to upper */ c -= 0x20; if (c>=0x00 && c<=0x1F) /* C0 control -> C- */ c = COTL | (c+'@'); return (c);}/* * Fancy quit command, as implemented by Norm. If the current buffer has * changed do a write current buffer and exit emacs, otherwise simply exit. */globle int quickexit(f, n)int f,n;{ if ((curbp->b_flag&BFCHG) != 0 /* Changed. */ && (curbp->b_flag&BFTEMP) == 0) /* Real. */ filesave(f, n); return(edquit(f, n)); /* conditionally quit */}/* * Quit command. If an argument, always quit. Otherwise confirm if a buffer * has been changed and not written out. Normally bound to "C-X C-C". */#if IBM_TBC#pragma argsused#endifgloble int edquit(f, n)int f,n;{ register int s; if (f != FALSE /* Argument forces it. */ || anycb() == FALSE /* All buffers clean. */ /* User says it's OK. */ || (s=mlyesno("Modified Buffers! Quit")) == TRUE) { vttidy(); full_cleanup(); return(EXIT); } return (s);}/* * Temporary exit from editor. Leave all data structures * intact, but tidy up video interface. * Connected to "C-X Q". */#if IBM_TBC#pragma argsused#endifgloble int temp_quit(f,n)int f,n;{ vttidy(); return(EXIT);}/* * Begin a keyboard macro. * Error if not at the top level in keyboard processing. Set up variables and * return. */#if IBM_TBC#pragma argsused#endifgloble int ctlxlp(f, n)int f,n;{ if (kbdmip!=NULL || kbdmop!=NULL) { mlwrite("Not now"); return (FALSE); } mlwrite("[Start macro]"); kbdmip = &kbdm[0]; return (TRUE);}/* * End keyboard macro. Check for the same limit conditions as the above * routine. Set up the variables and return to the caller. */#if IBM_TBC#pragma argsused#endifgloble int ctlxrp(f, n)int f,n;{ if (kbdmip == NULL) { mlwrite("Not now"); return (FALSE); } mlwrite("[End macro]"); kbdmip = NULL; return (TRUE);}/* * Execute a macro. * The command argument is the number of times to loop. Quit as soon as a * command gets an error. Return TRUE if all ok, else FALSE. */#if IBM_TBC#pragma argsused#endifgloble int ctlxe(f, n)int f,n;{ register int c; register int af; register int an; register int s; if (kbdmip!=NULL || kbdmop!=NULL) { mlwrite("Not now"); return (FALSE); } if (n <= 0) return (TRUE); do { kbdmop = &kbdm[0]; do { af = FALSE; an = 1; if ((c = *kbdmop++) == (COTL|'U')) { af = TRUE; an = *kbdmop++; c = *kbdmop++; } s = TRUE; } while (c!=(CTLX|')') && (s=execute(c, af, an))==TRUE); kbdmop = NULL; } while (s==TRUE && --n); return (s);}/* * Abort. * Beep the beeper. Kill off any keyboard macro, etc., that is in progress. * Sometimes called as a routine, to do general aborting of stuff. */#if IBM_TBC#pragma argsused#endifgloble int ctrlg(f, n)int f,n;{ (*term.t_beep)(); if (kbdmip != NULL) { kbdm[0] = (CTLX|')'); kbdmip = NULL; } return (ABORT);}globle VOID full_cleanup(){/* Clear all data structures */ kill_all_buffers(&bheadp); /* Clear all existing buffers */ kill_all_windows(); /* Clear all windows */ kill_video_buffers(); /* Kill special video buffers */ kill_cmp_router(); /* Get rid of special router *//* Clear all global pointers */ curwp = NULL; /* Current window */ curbp = NULL; /* Current buffer */ wheadp = NULL; /* Head of list of windows */ bheadp = NULL; /* Head of list of buffers */ blistp = NULL; /* Buffer for C-X C-B */ kbdmip = NULL; /* Input pointer for above */ kbdmop = NULL; /* Output pointer for above */ pat[0] = '\0'; /* Search pattern */ lastbufn[0] = '\0'; /* Name of Last buffer accessed */ CompileBufferp = NULL; /* CLIPS Compile Output Buffer */}/* * Dispose of all buffers. Clear the buffer (ask first * if the buffer has been changed). Then free the header * line and the buffer header. Called for full cleanup. */globle int kill_all_buffers(top_buf)BUFFER **top_buf;{ register BUFFER *bp; bp = *top_buf; while(bp != NULL) { spec_clear(bp); /* Blow text away. */ genfree((VOID *) bp->b_linep, /* And free pointer */ (unsigned) sizeof(LINE)+ bp->b_linep->l_size); *top_buf = bp->b_bufp; /* Find next buffer */ genfree((VOID *) bp, (unsigned) sizeof(BUFFER)); /* Release buffer block */ bp = *top_buf; } return (TRUE);}globle int kill_all_windows(){ register WINDOW *wp; register WINDOW *wp1; wp = wheadp; while(wp != NULL) { wp1 = wp->w_wndp; genfree((VOID *) wp, (unsigned) sizeof(WINDOW)); wp = wp1; } return (TRUE);}/* * This routine blows away all of the text in a * buffer. Does NOT care if text has been changed! */globle int spec_clear(bp)BUFFER *bp;{ register LINE *lp; bp->b_flag &= ~BFCHG; /* Not changed */ while ((lp=lforw(bp->b_linep)) != bp->b_linep) lfree(lp); bp->b_dotp = bp->b_linep; /* Fix "." */ bp->b_doto = 0; bp->b_markp = NULL; /* Invalidate "mark" */ bp->b_marko = 0; return (TRUE);}globle VOID EditCommand() { if (PauseEnvFunction != NULL) (*PauseEnvFunction)() ; PerformEditCommand(); if (ContinueEnvFunction != NULL) (*ContinueEnvFunction)(0) ; if (RedrawScreenFunction != NULL) (*RedrawScreenFunction)() ; }/*******************************************//* EditorFunctionDefinition: *//*******************************************/globle VOID EditorFunctionDefinition() { DefineFunction2("edit",'v', (int (*)(VOID_ARG)) EditCommand,"EditCommand", "*1k"); }#elsegloble VOID EditCommand() { /* Empty Stub */ }#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -