From 9780b4ce16f1b59636a732fbfef38ecdbf57d8b6 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 25 Sep 2013 21:45:05 +0800 Subject: [PATCH] Extract Struct terminal from estruct to terminal.h implemented by tcap. --- Makefile | 39 +++++++++++++++++------------ basic.c | 1 + bindable.c | 1 + display.c | 1 + edef.h | 5 ---- estruct.h | 60 -------------------------------------------- eval.c | 1 + execute.c | 1 + globals.c | 2 -- input.c | 1 + isearch.c | 1 + main.c | 1 + random.c | 1 + search.c | 1 + spawn.c | 1 + tcap.c | 5 ++-- terminal.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ termio.c | 12 ++++++--- termio.h | 3 +++ window.c | 1 + 20 files changed, 123 insertions(+), 88 deletions(-) create mode 100644 terminal.h diff --git a/Makefile b/Makefile index 5f7c659..ef6b11f 100644 --- a/Makefile +++ b/Makefile @@ -128,28 +128,31 @@ depend: ${SRC} ansi.o: ansi.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \ - estruct.h retcode.h edef.h input.h random.h window.h defines.h + estruct.h retcode.h edef.h input.h random.h terminal.h defines.h \ + window.h bind.o: bind.c bind.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h bindable.h display.h ebind.h exec.h file.h flook.h input.h \ names.h window.h defines.h bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \ - utf8.h display.h edef.h estruct.h retcode.h file.h input.h lock.h + utf8.h display.h edef.h estruct.h retcode.h file.h input.h lock.h \ + terminal.h buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \ edef.h estruct.h retcode.h file.h input.h window.h crypt.o: crypt.c crypt.h display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h edef.h termio.h version.h wrapper.h window.h defines.h + retcode.h edef.h termio.h terminal.h defines.h version.h wrapper.h \ + window.h ebind.o: ebind.c ebind.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h eval.h exec.h file.h isearch.h \ random.h region.h search.h spawn.h window.h defines.h word.h eval.o: eval.c eval.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h display.h exec.h flook.h input.h random.h \ - search.h termio.h version.h window.h defines.h + search.h terminal.h defines.h termio.h version.h window.h exec.o: exec.c exec.h buffer.h crypt.h line.h utf8.h bind.h edef.h \ estruct.h retcode.h display.h eval.h file.h flook.h input.h window.h \ defines.h execute.o: execute.c edef.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h bind.h random.h display.h file.h window.h defines.h + retcode.h bind.h random.h display.h file.h terminal.h defines.h window.h file.o: file.c file.h crypt.h retcode.h buffer.h line.h utf8.h defines.h \ estruct.h edef.h execute.h fileio.h input.h lock.h log.h window.h fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h @@ -159,9 +162,11 @@ globals.o: globals.c crypt.h defines.h edef.h buffer.h line.h utf8.h \ ibmpc.o: ibmpc.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h input.o: input.c input.h edef.h buffer.h crypt.h line.h utf8.h estruct.h \ - retcode.h bind.h bindable.h display.h exec.h names.h wrapper.h + retcode.h bind.h bindable.h display.h exec.h names.h terminal.h \ + defines.h wrapper.h isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \ - display.h estruct.h retcode.h edef.h input.h search.h window.h defines.h + display.h estruct.h retcode.h edef.h input.h search.h terminal.h \ + defines.h window.h line.o: line.c line.h utf8.h buffer.h crypt.h edef.h estruct.h retcode.h \ log.h window.h defines.h lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ @@ -169,7 +174,8 @@ lock.o: lock.c lock.h estruct.h retcode.h display.h edef.h buffer.h \ log.o: log.c log.h retcode.h main.o: main.c basic.h bind.h edef.h buffer.h crypt.h line.h utf8.h \ estruct.h retcode.h bindable.h display.h eval.h execute.h file.h input.h \ - lock.h log.h random.h search.h termio.h version.h window.h defines.h + lock.h log.h random.h search.h terminal.h defines.h termio.h version.h \ + window.h names.o: names.c names.h basic.h bind.h edef.h buffer.h crypt.h line.h \ utf8.h estruct.h retcode.h bindable.h display.h eval.h exec.h file.h \ isearch.h region.h random.h search.h spawn.h window.h defines.h word.h @@ -178,24 +184,25 @@ pklock.o: pklock.c pklock.h estruct.h retcode.h edef.h buffer.h crypt.h \ posix.o: posix.c termio.h random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h execute.h input.h log.h search.h \ - window.h defines.h + terminal.h defines.h window.h region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \ retcode.h edef.h log.h window.h defines.h search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \ - display.h edef.h estruct.h retcode.h input.h log.h window.h defines.h + display.h edef.h estruct.h retcode.h input.h log.h terminal.h defines.h \ + window.h spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \ display.h estruct.h retcode.h edef.h file.h flook.h input.h log.h \ - window.h -tcap.o: tcap.c display.h estruct.h retcode.h edef.h buffer.h crypt.h \ - line.h utf8.h termio.h -termio.o: termio.c termio.h estruct.h retcode.h edef.h buffer.h crypt.h \ - line.h utf8.h + terminal.h window.h +tcap.o: tcap.c terminal.h defines.h display.h estruct.h retcode.h edef.h \ + buffer.h crypt.h line.h utf8.h termio.h +termio.o: termio.c termio.h estruct.h retcode.h utf8.h utf8.o: utf8.c utf8.h vmsvt.o: vmsvt.c estruct.h retcode.h edef.h buffer.h crypt.h line.h \ utf8.h vt52.o: vt52.c estruct.h retcode.h edef.h buffer.h crypt.h line.h utf8.h window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \ - basic.h display.h edef.h estruct.h retcode.h execute.h wrapper.h + basic.h display.h edef.h estruct.h retcode.h execute.h terminal.h \ + wrapper.h word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \ retcode.h edef.h log.h random.h region.h window.h defines.h wrapper.o: wrapper.c wrapper.h diff --git a/basic.c b/basic.c index bb97d9d..0b5a1af 100644 --- a/basic.c +++ b/basic.c @@ -22,6 +22,7 @@ #include "input.h" #include "line.h" #include "random.h" +#include "terminal.h" #include "utf8.h" #include "window.h" diff --git a/bindable.c b/bindable.c index 8ae843c..ffd9116 100644 --- a/bindable.c +++ b/bindable.c @@ -8,6 +8,7 @@ #include "file.h" #include "input.h" #include "lock.h" +#include "terminal.h" #if VMS #include diff --git a/display.c b/display.c index d318504..6255287 100644 --- a/display.c +++ b/display.c @@ -22,6 +22,7 @@ #include "edef.h" #include "line.h" #include "termio.h" +#include "terminal.h" #include "version.h" #include "wrapper.h" #include "utf8.h" diff --git a/edef.h b/edef.h index 26d8909..a8d2160 100644 --- a/edef.h +++ b/edef.h @@ -49,8 +49,6 @@ extern int disinp; /* display input characters */ extern struct buffer *bstore; /* buffer to store macro text to */ extern int vtrow; /* Row location of SW cursor */ extern int vtcol; /* Column location of SW cursor */ -extern int ttrow; /* Row location of HW cursor */ -extern int ttcol; /* Column location of HW cursor */ extern int lbound; /* leftmost column of current line being displayed */ extern int taboff; /* tab offset for display */ @@ -125,7 +123,4 @@ extern int matchoff; extern char outline[]; /* Global string to hold debug line text. */ #endif -/* Terminal table defined only in term.c */ -extern struct terminal term; - #endif /* EDEF_H_ */ diff --git a/estruct.h b/estruct.h index a5e6a22..023e149 100644 --- a/estruct.h +++ b/estruct.h @@ -349,64 +349,4 @@ int cexit( int status) ; #endif -/* - * The editor communicates with the display using a high level interface. A - * "TERM" structure holds useful variables, and indirect pointers to routines - * that do useful operations. The low level get and put routines are here too. - * This lets a terminal, in addition to having non standard commands, have - * funny get and put character code too. The calls might get changed to - * "termp->t_field" style in the future, to make it possible to run more than - * one terminal type. - */ -struct terminal { - short t_mrow; /* max number of rows allowable */ - short t_nrow; /* current number of rows used */ - short t_mcol; /* max Number of columns. */ - short t_ncol; /* current Number of columns. */ - short t_margin; /* min margin for extended lines */ - short t_scrsiz; /* size of scroll region " */ - int t_pause; /* # times thru update to pause */ - void (*t_open)(void); /* Open terminal at the start. */ - void (*t_close)(void); /* Close terminal at end. */ - void (*t_kopen)(void); /* Open keyboard */ - void (*t_kclose)(void); /* close keyboard */ - int (*t_getchar)(void); /* Get character from keyboard. */ - int (*t_putchar)(int); /* Put character to display. */ - void (*t_flush) (void); /* Flush output buffers. */ - void (*t_move)(int, int);/* Move the cursor, origin 0. */ - void (*t_eeol)(void); /* Erase to end of line. */ - void (*t_eeop)(void); /* Erase to end of page. */ - void (*t_beep)(void); /* Beep. */ - void (*t_rev)(int); /* set reverse video state */ - int (*t_rez)(char *); /* change screen resolution */ -#if COLOR - int (*t_setfor) (); /* set forground color */ - int (*t_setback) (); /* set background color */ -#endif -#if SCROLLCODE - void (*t_scroll)(int, int,int); /* scroll a region of the screen */ -#endif -}; - -/* TEMPORARY macros for terminal I/O (to be placed in a machine - dependant place later) */ - -#define TTopen (*term.t_open) -#define TTclose (*term.t_close) -#define TTkopen (*term.t_kopen) -#define TTkclose (*term.t_kclose) -#define TTgetc (*term.t_getchar) -#define TTputc (*term.t_putchar) -#define TTflush (*term.t_flush) -#define TTmove (*term.t_move) -#define TTeeol (*term.t_eeol) -#define TTeeop (*term.t_eeop) -#define TTbeep (*term.t_beep) -#define TTrev (*term.t_rev) -#define TTrez (*term.t_rez) -#if COLOR -#define TTforg (*term.t_setfor) -#define TTbacg (*term.t_setback) -#endif - #endif diff --git a/eval.c b/eval.c index b0165fb..6848eca 100644 --- a/eval.c +++ b/eval.c @@ -23,6 +23,7 @@ #include "line.h" #include "random.h" #include "search.h" +#include "terminal.h" #include "termio.h" #include "version.h" #include "window.h" diff --git a/execute.c b/execute.c index 184893b..0afd8a3 100644 --- a/execute.c +++ b/execute.c @@ -3,6 +3,7 @@ #include "random.h" #include "display.h" #include "file.h" +#include "terminal.h" #include "window.h" /* diff --git a/globals.c b/globals.c index f082ab7..f51bdbd 100644 --- a/globals.c +++ b/globals.c @@ -57,8 +57,6 @@ int disinp = TRUE; /* display input characters */ struct buffer *bstore = NULL; /* buffer to store macro text to */ int vtrow = 0; /* Row location of SW cursor */ int vtcol = 0; /* Column location of SW cursor */ -int ttrow = HUGE; /* Row location of HW cursor */ -int ttcol = HUGE; /* Column location of HW cursor */ int lbound = 0; /* leftmost column of current line being displayed */ int taboff = 0; /* tab offset for display */ diff --git a/input.c b/input.c index 0cc3b72..5cd4685 100644 --- a/input.c +++ b/input.c @@ -18,6 +18,7 @@ #include "display.h" #include "exec.h" #include "names.h" +#include "terminal.h" #include "wrapper.h" #if PKCODE diff --git a/isearch.c b/isearch.c index 0425aaf..461b044 100644 --- a/isearch.c +++ b/isearch.c @@ -34,6 +34,7 @@ #include "input.h" #include "line.h" #include "search.h" +#include "terminal.h" #include "window.h" /* diff --git a/main.c b/main.c index 840ecfb..6a71426 100644 --- a/main.c +++ b/main.c @@ -72,6 +72,7 @@ #include "log.h" #include "random.h" #include "search.h" +#include "terminal.h" #include "termio.h" #include "version.h" #include "window.h" diff --git a/random.c b/random.c index 2bcbcc1..c5dd248 100644 --- a/random.c +++ b/random.c @@ -21,6 +21,7 @@ #include "line.h" #include "log.h" #include "search.h" +#include "terminal.h" #include "window.h" int tabsize; /* Tab size (0: use real tabs) */ diff --git a/search.c b/search.c index ea6f718..c7deea9 100644 --- a/search.c +++ b/search.c @@ -69,6 +69,7 @@ #include "input.h" #include "line.h" #include "log.h" +#include "terminal.h" #include "window.h" #if defined(MAGIC) diff --git a/spawn.c b/spawn.c index abe9cce..422fe62 100644 --- a/spawn.c +++ b/spawn.c @@ -21,6 +21,7 @@ #include "flook.h" #include "input.h" #include "log.h" +#include "terminal.h" #include "window.h" #if VMS diff --git a/tcap.c b/tcap.c index 57e73a5..45e3d4d 100644 --- a/tcap.c +++ b/tcap.c @@ -1,3 +1,6 @@ +/* tcap.c -- implements terminal.h */ +#include "terminal.h" + /* tcap.c * * Unix V7 SysV and BS4 Termcap video driver @@ -21,8 +24,6 @@ #include #endif -#include - #include "display.h" #include "estruct.h" #include "edef.h" diff --git a/terminal.h b/terminal.h new file mode 100644 index 0000000..2e4701f --- /dev/null +++ b/terminal.h @@ -0,0 +1,73 @@ +#ifndef __TERMINAL_H__ +#define __TERMINAL_H__ + + +#include "defines.h" /* COLOR, SCROLLCODE */ + +/* + * The editor communicates with the display using a high level interface. A + * "TERM" structure holds useful variables, and indirect pointers to routines + * that do useful operations. The low level get and put routines are here too. + * This lets a terminal, in addition to having non standard commands, have + * funny get and put character code too. The calls might get changed to + * "termp->t_field" style in the future, to make it possible to run more than + * one terminal type. + */ +struct terminal { + short t_mrow; /* max number of rows allowable */ + short t_nrow; /* current number of rows used */ + short t_mcol; /* max Number of columns. */ + short t_ncol; /* current Number of columns. */ + short t_margin; /* min margin for extended lines */ + short t_scrsiz; /* size of scroll region " */ + int t_pause; /* # times thru update to pause */ + void (*t_open)(void); /* Open terminal at the start. */ + void (*t_close)(void); /* Close terminal at end. */ + void (*t_kopen)(void); /* Open keyboard */ + void (*t_kclose)(void); /* close keyboard */ + int (*t_getchar)(void); /* Get character from keyboard. */ + int (*t_putchar)(int); /* Put character to display. */ + void (*t_flush) (void); /* Flush output buffers. */ + void (*t_move)(int, int);/* Move the cursor, origin 0. */ + void (*t_eeol)(void); /* Erase to end of line. */ + void (*t_eeop)(void); /* Erase to end of page. */ + void (*t_beep)(void); /* Beep. */ + void (*t_rev)(int); /* set reverse video state */ + int (*t_rez)(char *); /* change screen resolution */ +#if COLOR + int (*t_setfor) (); /* set forground color */ + int (*t_setback) (); /* set background color */ +#endif +#if SCROLLCODE + void (*t_scroll)(int, int,int); /* scroll a region of the screen */ +#endif +}; + +/* TEMPORARY macros for terminal I/O (to be placed in a machine + dependant place later) */ + +#define TTopen (*term.t_open) +#define TTclose (*term.t_close) +#define TTkopen (*term.t_kopen) +#define TTkclose (*term.t_kclose) +#define TTgetc (*term.t_getchar) +#define TTputc (*term.t_putchar) +#define TTflush (*term.t_flush) +#define TTmove (*term.t_move) +#define TTeeol (*term.t_eeol) +#define TTeeop (*term.t_eeop) +#define TTbeep (*term.t_beep) +#define TTrev (*term.t_rev) +#define TTrez (*term.t_rez) +#if COLOR +#define TTforg (*term.t_setfor) +#define TTbacg (*term.t_setback) +#endif + +/* Terminal table defined only in term.c */ +extern struct terminal term ; + +extern int ttrow ; /* Row location of HW cursor */ +extern int ttcol ; /* Column location of HW cursor */ + +#endif diff --git a/termio.c b/termio.c index cc02ec6..43d78fa 100644 --- a/termio.c +++ b/termio.c @@ -11,14 +11,20 @@ #ifndef POSIX -#include -#include "estruct.h" -#include "edef.h" +#include +#include + +#include "estruct.h" +#include "utf8.h" + /* rfi */ #include #include +int ttrow = HUGE ; /* Row location of HW cursor */ +int ttcol = HUGE ; /* Column location of HW cursor */ + #if VMS #include #include diff --git a/termio.h b/termio.h index 5f41f92..5b057aa 100644 --- a/termio.h +++ b/termio.h @@ -1,6 +1,9 @@ #ifndef _TERMIO_H_ #define _TERMIO_H_ +extern int ttrow ; /* Row location of HW cursor */ +extern int ttcol ; /* Column location of HW cursor */ + void ttopen( void) ; void ttclose( void) ; int ttputc( int c) ; diff --git a/window.c b/window.c index f9cf8bf..f31ee5a 100644 --- a/window.c +++ b/window.c @@ -18,6 +18,7 @@ #include "edef.h" #include "execute.h" #include "line.h" +#include "terminal.h" #include "wrapper.h" /*