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

📄 edterm.c

📁 VC嵌入式CLips专家系统,实现战场环境的目标识别
💻 C
📖 第 1 页 / 共 2 页
字号:
   /*******************************************************/
   /*      "C" Language Integrated Production System      */
   /*                                                     */
   /*              CLIPS Version 6.24  06/05/06           */
   /*                                                     */
   /*                                                     */
   /*******************************************************/
   
/*************************************************************/
/* Purpose:                                                  */
/*                                                           */
/* Principal Programmer(s):                                  */
/*                                                           */
/* Contributing Programmer(s):                               */
/*                                                           */
/* Revision History:                                         */
/*                                                           */
/*      6.24: Corrected code generating compilation          */
/*            warnings.                                      */
/*                                                           */
/*************************************************************/

#include "setup.h"

#if   EMACS_EDITOR && ! RUN_TIME

#define _EDTERM_SOURCE_
#include "ed.h"

#include <stdlib.h>

#if ANSI
static void ansimove(int,int);
static void ansieeol(void);
static void ansieeop(void);
static void ansibeep(void);
static void ansiparm(int);
static void ansiopen(void);
#endif

#if VT52
static void vt52move(int,int);
static void vt52eeol(void);
static void vt52eeop(void);
static void vt52beep(void);
static void vt52parm(int);
static void vt52open(void);
#endif

#if IBM_PC
static void pc_open(void);
static int scinit(int);
static int getboard(void);
static int pc_getc(void);
static void pc_putc(int);
static void pc_move(int,int);
static void pc_eeol(void);
static void pc_eeop(void);
static void pc_beep(void);
#endif

#if TERMCAP
#include <termcap.h>
/*
extern int tgetent(char *,char *);
extern char *tgoto(char *,int,int);
extern int tputs(register char *,int,int (*)(int));
extern char *tgetstr(char *,char **);
*/
static void tcapmove(int,int);
static void tcapeeol(void);
static void tcapeeop(void);
static void tcapbeep(void);
static void tcapopen(void);
static void putpad(char *);
#endif

/* ==========================================================================
 *                              ANSI Terminal
 * ==========================================================================
 */

#if     ANSI

/*
 * The routines in this section provide support for ANSI style terminals
 * over a serial line. The serial I/O services are provided by routines in
 * "termio.c". It compiles into nothing if not an ANSI device.
 */

#define NROW    23                      /* Screen size.                 */
#define NCOL    77                      /* Edit if you want to.         */
#define BEL     0x07                    /* BEL character.               */
#define ESC     0x1B                    /* ESC character.               */

/*
 * Standard terminal interface dispatch table. Most of the fields point into
 * "termio" code.
 */
TERM    term    = {
        NROW-1,
        NCOL,
        ansiopen,
        ttclose,
        ttgetc,
        ttputc,
        ttflush,
        ansimove,
        ansieeol,
        ansieeop,
        ansibeep
};

static void ansimove(
int row,
int col)
{
        ttputc(ESC);
        ttputc('[');
        ansiparm(row+1);
        ttputc(';');
        ansiparm(col+1);
        ttputc('H');
}

static void ansieeol()
{
        ttputc(ESC);
        ttputc('[');
        ttputc('K');
}

static void ansieeop()
{
        ttputc(ESC);
        ttputc('[');
        ttputc('J');
}

static void ansibeep()
{
        ttputc(BEL);
        ttflush();
}

static void ansiparm(
int    n)
{
        register int    q;

        q = n/10;
        if (q != 0)
                ansiparm(q);
        ttputc((n%10) + '0');
}

static void ansiopen()
{
#if     UNIX_7 || UNIX_V
        register char *cp;

        if ((cp = getenv("TERM")) == NULL) {
                puts("Shell variable TERM not defined!");
                exit(1);
        }
        if (strcmp(cp, "vt100") != 0) {
                puts("Terminal type not 'vt100'!");
                exit(1);
        }
#endif
        ttopen();
}

#endif

/* ==========================================================================
 *                              VT52 Terminal
 * ==========================================================================
 */

#if     VT52

/*
 * The routines in this section
 * provide support for VT52 style terminals
 * over a serial line. The serial I/O services are
 * provided by routines in "termio.c". It compiles
 * into nothing if not a VT52 style device. The
 * bell on the VT52 is terrible, so the "beep"
 * routine is conditionalized on defining BEL.
 */

#define NROW    24                      /* Screen size.                 */
#define NCOL    80                      /* Edit if you want to.         */
#define BIAS    0x20                    /* Origin 0 coordinate bias.    */
#define ESC     0x1B                    /* ESC character.               */
#define BEL     0x07                    /* ascii bell character         */

/*
 * Dispatch table. All the
 * hard fields just point into the
 * terminal I/O code.
 */
globle TERM    term    = {
        NROW-1,
        NCOL,
        vt52open,
        ttclose,
        ttgetc,
        ttputc,
        ttflush,
        vt52move,
        vt52eeol,
        vt52eeop,
        vt52beep
};

static void vt52move(
int row,
int col)
{
        ttputc(ESC);
        ttputc('Y');
        ttputc(row+BIAS);
        ttputc(col+BIAS);
}

static void vt52eeol()
{
        ttputc(ESC);
        ttputc('K');
}

static void vt52eeop()
{
        ttputc(ESC);
        ttputc('J');
}

static void vt52beep()
{
#ifdef  BEL
        ttputc(BEL);
        ttflush();
#endif
}

static void vt52open()
{
#if     UNIX_7 || UNIX_V
        register char *cp;

        if ((cp = getenv("TERM")) == NULL) {
                puts("Shell variable TERM not defined!");
                exit(1);
        }
        if (strcmp(cp, "vt52") != 0 && strcmp(cp, "z19") != 0) {
                puts("Terminal type not 'vt52'or 'z19' !");
                exit(1);
        }
#endif
        ttopen();
}

#endif

/* ==========================================================================
 *                              IBM PC Code
 * ==========================================================================
 */

#if   IBM_PC                                    /* Should be an IBM PC using    */
                                                /* the Microsoft C compiler     */
                                                /* or the Turbo C compiler      */
                                                /* or the Zortech C compiler    */
                                                /* or the Intel C Code builder  */
#if   IBM_MSC || IBM_TBC || IBM_ZTC || IBM_ICB || IBM_GCC
#include        <dos.h>

#if IBM_MSC || IBM_ICB || IBM_GCC
#include    <conio.h>
#endif

#if IBM_ZTC
#include    <disp.h>
#endif

#define NROW    25                      /* Screen size. rows            */
#define NCOL    80                      /* Columns                      */
#define BEL     0x07                    /* BEL character.               */
#define ESC     0x1B                    /* ESC character.               */
#define SPACE   32

#if IBM_ICB
#define	SCADC	0xb8000         /* CGA address of screen RAM	*/
#define	SCADM	0xb0000         /* MONO address of screen RAM	*/
#else
#define	SCADC	0xb8000000L     /* CGA address of screen RAM	*/
#define	SCADM	0xb0000000L     /* MONO address of screen RAM	*/
#endif

#define MONOCRSR 0x0B0D			/* monochrome cursor	    */
#define CGACRSR 0x0607			/* CGA cursor		    */

#define	CDCGA	0			/* color graphics card		*/
#define	CDMONO	1			/* monochrome text card		*/
#define	CDSENSE	9			/* detect the card type		*/

#define NDRIVE	3			/* number of screen drivers	*/

/*
 * Standard terminal interface dispatch table. Most of the fields point into
 * "termio" code.
 */

globle TERM    term    = {
        NROW-1,
        NCOL,
        pc_open,
        ttclose,
        pc_getc,
        pc_putc,
        ttflush,
        pc_move,
        pc_eeol,
        pc_eeop,
        pc_beep
};

static int dtype = -1;		/* current display type		*/

#if IBM_ICB
static int scadd;		/* address of screen ram	*/
static short *scptr[NROW];	/* pointer to screen lines	*/
static unsigned short sline[NCOL];/* screen line image		*/
#else
static long scadd;		/* address of screen ram	*/
static int *scptr[NROW];	/* pointer to screen lines	*/
static unsigned int sline[NCOL];/* screen line image		*/

⌨️ 快捷键说明

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