⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edmain.c

📁 VC嵌入式CLips专家系统,实现战场环境的目标识别
💻 C
📖 第 1 页 / 共 2 页
字号:
        if (c == ' ' && fillcol > 0 && n>=0 && getccol(FALSE) > fillcol)
                wrapword(theEnv);

        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(theEnv,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(
  void *theEnv,
  int f,
  int n)
  {
   if ((curbp->b_flag&BFCHG) != 0          /* Changed.             */
        && (curbp->b_flag&BFTEMP) == 0)         /* Real.                */
     filesave(theEnv,f, n);
   return(edquit(theEnv,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
#endif
globle int edquit(
  void *theEnv,
  int f,
  int n)
  {
        register int    s;

        if (f != FALSE                          /* Argument forces it.  */
        || anycb() == FALSE                     /* All buffers clean.   */
                                                /* User says it's OK.   */
        || (s=mlyesno(theEnv,"Modified Buffers! Quit")) == TRUE) {
                vttidy();
                full_cleanup(theEnv);
                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
#endif
globle int temp_quit(
  void *theEnv,
  int f,
  int 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
#endif
globle int ctlxlp(
  void *theEnv,
  int f,
  int 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
#endif
globle int ctlxrp(
  void *theEnv,
  int f,
  int 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
#endif
globle int ctlxe(
  void *theEnv,
  int f,
  int 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(theEnv,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
#endif
globle int ctrlg(
  void *theEnv,
  int f,
  int n)
  {
   (*term.t_beep)();
   if (kbdmip != NULL)
     {
      kbdm[0] = (CTLX|')');
      kbdmip  = NULL;
     }
   return (ABORT);
  }

globle void full_cleanup(
  void *theEnv)
{

/*   Clear all data structures */

   kill_all_buffers(theEnv,&bheadp);     /* Clear all existing buffers   */

   kill_all_windows(theEnv);           /* Clear all windows            */

   kill_video_buffers(theEnv);	 /* Kill special video buffers   */

   kill_cmp_router(theEnv);		 /* 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(
  void *theEnv,
  BUFFER **top_buf)
  {
   register BUFFER *bp;

   bp = *top_buf;
   while(bp != NULL) {
        spec_clear(theEnv,bp);                         /* Blow text away.      */

        genfree(theEnv,(void *) bp->b_linep,           /* And free pointer     */
	        (unsigned)  sizeof(LINE)+ bp->b_linep->l_size);

        *top_buf = bp->b_bufp;                       /* Find next buffer     */
        genfree(theEnv,(void *) bp, (unsigned) sizeof(BUFFER));   /* Release buffer block */
	bp = *top_buf;
        }

   return (TRUE);
}

globle int kill_all_windows(
  void *theEnv)
{
   register WINDOW *wp;
   register WINDOW *wp1;

   wp = wheadp;
   while(wp != NULL) {
        wp1 = wp->w_wndp;
        genfree(theEnv,(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(
  void *theEnv,
  BUFFER *bp)
{
        register LINE   *lp;

        bp->b_flag  &= ~BFCHG;                  /* Not changed          */
        while ((lp=lforw(bp->b_linep)) != bp->b_linep)
                lfree(theEnv,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(
  void *theEnv)
  {
   void (*redrawScreenFunction)(void *);
   void (*pauseEnvFunction)(void *);
   void (*continueEnvFunction)(void *,int);
      
   redrawScreenFunction = GetRedrawFunction(theEnv);
   pauseEnvFunction = GetPauseEnvFunction(theEnv);
   continueEnvFunction = GetContinueEnvFunction(theEnv);
   
   if (pauseEnvFunction != NULL) (*pauseEnvFunction)(theEnv) ;
   PerformEditCommand(theEnv);
   if (continueEnvFunction != NULL) (*continueEnvFunction)(theEnv,0) ;
   if (redrawScreenFunction != NULL) (*redrawScreenFunction)(theEnv) ;
  }

/*******************************************/
/* EditorFunctionDefinition:               */
/*******************************************/
globle void EditorFunctionDefinition(
  void *theEnv)
  {
   EnvDefineFunction2(theEnv,"edit",'v', PTIEF EditCommand,"EditCommand", "*1k");
  }

#else

globle void EditCommand(void *);
globle void EditorFunctionDefinition(void *);

globle void EditCommand(
  void *theEnv)
  {
   /* Empty Stub */
  }

globle void EditorFunctionDefinition(
  void *theEnv)
  {       
  }

#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -