1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

Compare commits

...

3 Commits

27 changed files with 196 additions and 339 deletions

View File

@ -13,11 +13,6 @@ else
endif endif
export E Q export E Q
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
# for windows based target, insure we strip the variant part
# CYGWIN_NT-6.1, CYGWIN_NT-6.1-WOW, CYGWIN_NT-6.1-WOW64, MSYS_NT-10.0-19042
uname_S := $(shell sh -c 'echo $(uname_S) | sed s/_.*$$//')
PROGRAM=ue PROGRAM=ue
CC=gcc CC=gcc
@ -25,18 +20,7 @@ WARNINGS=-pedantic -Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
CFLAGS=-O2 $(WARNINGS) CFLAGS=-O2 $(WARNINGS)
LDFLAGS=-s LDFLAGS=-s
LIBS=-lcurses LIBS=-lcurses
DEFINES=-DAUTOCONF -DPROGRAM=$(PROGRAM) # -DNDEBUG DEFINES=-DPROGRAM=$(PROGRAM) -D_GNU_SOURCE # -DNDEBUG
ifeq ($(uname_S),Linux)
DEFINES += -DPOSIX -DUSG
else ifeq ($(uname_S),CYGWIN)
DEFINES += -DCYGWIN -DSYSV
else ifeq ($(uname_S),MSYS)
DEFINES += -DCYGWIN -DSYSV
else ifeq ($(uname_S),NetBSD)
DEFINES += -DPOSIX -DBSD=1
else
$(error $(uname_S) needs configuration)
endif
BINDIR=/usr/bin BINDIR=/usr/bin
LIBDIR=/usr/lib LIBDIR=/usr/lib

View File

@ -1,8 +1,9 @@
/* buffer.c -- implements buffer.h */ /* buffer.c -- implements buffer.h */
#include "buffer.h" #include "buffer.h"
/* Buffer management. Some of the functions are internal, and some are actually attached to /* Buffer management. Some of the functions are internal, and some are
user keys. Like everyone else, they set hints for the display system. actually attached to user keys. Like everyone else, they set hints for
the display system.
modified by Petri Kutvonen modified by Petri Kutvonen
*/ */
@ -11,7 +12,6 @@
#include <string.h> #include <string.h>
#include "defines.h" #include "defines.h"
#include "estruct.h"
#include "file.h" #include "file.h"
#include "input.h" #include "input.h"
#include "mlout.h" #include "mlout.h"

View File

@ -1,17 +1,64 @@
/* defines.h -- */ /* defines.h -- customization based on gcc predefined macroes */
#ifndef __DEFINES_H__ #ifndef __DEFINES_H__
#define __DEFINES_H__ #define __DEFINES_H__
/* Must define one of #if __unix__
USG | BSD # define UNIX 1
*/ # if __NetBSD__
#define USG 1 # define BSD 1
# define POSIX 1
#define PKCODE 1 # elsif __linux__
#define SCROLLCODE 1 /* scrolling code P.K. */ # define USG 1
#define ENVFUNC 1 # define SVR4 1 /* locks */
# define POSIX 1
# else /* __CYGWIN__ */
# define USG 1
//# define POSIX 1
# endif
#else
# error Missing gcc predefined __unix__
#endif
#define NSTRING 128 /* # of bytes, string buffers */ #define NSTRING 128 /* # of bytes, string buffers */
#define TERMCAP 1 /* UNIX */
#define XONXOFF 1 /* UNIX */
#define VISMAC 0 /* update display during keyboard macros */
#define MSDOS 0
#define IBMPC MSDOS
#define COLOR MSDOS
#define MEMMAP IBMPC
#define FILOCK (SVR4 | BSD)
#define ENVFUNC 1 /* only two types so far (USG | BSD) */
#define PKCODE 1 /* include P.K. extensions, define always */
#define SCROLLCODE 1 /* scrolling code P.K. */
/* Dynamic RAM tracking and reporting redefinitions */
#define RAMSIZE 0 /* dynamic RAM memory usage tracking */
#if RAMSIZE
# define RAMSHOW 1 /* auto dynamic RAM reporting */
# include <stdlib.h>
void *allocate( size_t size) ;
void release( void *ptr) ;
# define malloc allocate
# define free release
#endif #endif
/* end of defines.h */
/* De-allocate memory always on exit (if the operating system or main
program can not
*/
#define CLEAN 0 /* de-alloc memory on exit */
#if CLEAN
# define exit(a) cexit(a)
void cexit( int status) ;
#endif
#endif
/* end of predefs.h */

View File

@ -12,12 +12,13 @@
*/ */
#include <errno.h> #include <errno.h>
#include <locale.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "buffer.h" #include "buffer.h"
#include "estruct.h" #include "defines.h"
#include "input.h" #include "input.h"
#include "line.h" #include "line.h"
#include "termio.h" #include "termio.h"
@ -50,16 +51,16 @@ static video_p *pscreen ; /* Physical screen. */
#endif #endif
static int displaying = TRUE ; static int displaying = TRUE ;
#if UNIX
# include <signal.h>
#endif
#ifdef SIGWINCH #ifdef SIGWINCH
# include <sys/ioctl.h> # include <sys/ioctl.h>
/* for window size changes */ /* for window size changes */
int chg_width, chg_height ; int chg_width, chg_height ;
static void sizesignal( int signr) ;
#endif #endif
static int currow ; /* Cursor row */ static int currow ; /* Cursor row */
static int curcol ; /* Cursor column */ static int curcol ; /* Cursor column */
static int vtrow = 0 ; /* Row location of SW cursor */ static int vtrow = 0 ; /* Row location of SW cursor */
@ -105,6 +106,11 @@ static int newscreensize( int h, int w) ;
completely redrawn on the first call to "update". completely redrawn on the first call to "update".
*/ */
void vtinit( void) { void vtinit( void) {
#ifdef SIGWINCH
signal( SIGWINCH, sizesignal) ;
#endif
setlocale( LC_CTYPE, "") ; /* expects $LANG like en_GB.UTF-8 */
TTopen() ; /* open the screen */ TTopen() ; /* open the screen */
TTkopen() ; /* open the keyboard */ TTkopen() ; /* open the keyboard */
TTrev( FALSE) ; TTrev( FALSE) ;
@ -1404,7 +1410,7 @@ void getscreensize( int *widthp, int *heightp) {
} }
#ifdef SIGWINCH #ifdef SIGWINCH
void sizesignal( int signr) { static void sizesignal( int signr) {
int w, h ; int w, h ;
int old_errno = errno ; int old_errno = errno ;

View File

@ -4,7 +4,7 @@
#include <stdarg.h> #include <stdarg.h>
#include "estruct.h" #include "defines.h" /* UNIX */
#include "names.h" /* BINDABLE() */ #include "names.h" /* BINDABLE() */
#include "utf8.h" /* unicode_t */ #include "utf8.h" /* unicode_t */
@ -40,8 +40,6 @@ void getscreensize( int *widthp, int *heightp) ;
# include <signal.h> # include <signal.h>
# ifdef SIGWINCH # ifdef SIGWINCH
extern int chg_width, chg_height ; extern int chg_width, chg_height ;
void sizesignal( int signr) ;
# endif # endif
#endif #endif

135
estruct.h
View File

@ -1,135 +0,0 @@
/* estruct.h -- */
#ifndef _ESTRUCT_H_
#define _ESTRUCT_H_
/* Structure and preprocessor defines
*
* written by Dave G. Conroy
* modified by Steve Wilhite, George Jones
* substantially modified by Daniel Lawrence
* modified by Petri Kutvonen
*/
#ifdef MSDOS
# undef MSDOS
#endif
/* Machine/OS definitions. */
#if defined(AUTOCONF) || defined(BSD) || defined(SYSV)
/* Make an intelligent guess about the target system. */
# if defined(BSD) || defined(sun) || defined(ultrix) || defined(__osf__)
# ifndef BSD
# define BSD 1 /* Berkeley UNIX */
# endif
# else
# define BSD 0
# endif
# if defined(SVR4) || defined(__linux__) /* ex. SunOS 5.3 */
# define SVR4 1
# define SYSV 1
# undef BSD
# endif
# if defined(SYSV) || defined(u3b2) || defined(_AIX) || (defined(i386) && defined(unix)) || defined( __unix__)
# define USG 1 /* System V UNIX */
# else
# define USG 0
# endif
#else
# define BSD 0 /* UNIX BSD 4.2 and ULTRIX */
# define USG 1 /* UNIX system V */
#endif /*autoconf || BSD || SYSV */
#define MSDOS 0 /* MS-DOS */
/* Compiler definitions */
#ifndef AUTOCONF
# define UNIX 1 /* a random UNIX compiler */
#else
# define UNIX (BSD | USG)
#endif /*autoconf */
/* Debugging options */
#define RAMSIZE 0 /* dynamic RAM memory usage tracking */
#if RAMSIZE
# define RAMSHOW 1 /* auto dynamic RAM reporting */
#endif
#ifndef AUTOCONF
/* Terminal Output definitions */
# define TERMCAP 0 /* Use TERMCAP */
# define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */
#else
# define TERMCAP UNIX
# define IBMPC MSDOS
#endif /* Autoconf. */
/* Configuration options */
#define VISMAC 0 /* update display during keyboard macros */
#ifndef AUTOCONF
# define COLOR 1 /* color commands and windows */
# define FILOCK 0 /* file locking under unix BSD 4.2 */
#else
# define COLOR MSDOS
# ifdef SVR4
# define FILOCK 1
# else
# define FILOCK BSD
# endif
#endif /* Autoconf. */
#define CLEAN 0 /* de-alloc memory on exit */
#ifndef AUTOCONF
# define XONXOFF 0 /* don't disable XON-XOFF flow control P.K. */
#else
# define XONXOFF UNIX
#endif /* Autoconf. */
#define PKCODE 1 /* include my extensions P.K., define always */
#define SCROLLCODE 1 /* scrolling code P.K. */
/* Define some ability flags. */
#if IBMPC
# define MEMMAP 1
#else
# define MEMMAP 0
#endif
#if USG | BSD
# define ENVFUNC 1
#else
# define ENVFUNC 0
#endif
/* Dynamic RAM tracking and reporting redefinitions */
#if RAMSIZE
# include <stdlib.h>
void *allocate( size_t size) ;
void release( void *ptr) ;
# define malloc allocate
# define free release
#endif
/* De-allocate memory always on exit (if the operating system or
main program can not
*/
#if CLEAN
# define exit(a) cexit(a)
void cexit( int status) ;
#endif
#endif
/* end of estruct.h */

2
eval.c
View File

@ -15,8 +15,8 @@
#include "basic.h" #include "basic.h"
#include "bind.h" #include "bind.h"
#include "buffer.h" #include "buffer.h"
#include "defines.h"
#include "display.h" #include "display.h"
#include "estruct.h"
#include "exec.h" #include "exec.h"
#include "execute.h" #include "execute.h"
#include "flook.h" #include "flook.h"

View File

@ -7,12 +7,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "estruct.h" #include "defines.h"
#include "random.h"
#include "display.h" #include "display.h"
#include "file.h" #include "file.h"
#include "input.h" #include "input.h"
#include "mlout.h" #include "mlout.h"
#include "random.h"
#include "search.h" #include "search.h"
#include "terminal.h" #include "terminal.h"
#include "window.h" #include "window.h"

1
file.c
View File

@ -17,7 +17,6 @@
#include "buffer.h" #include "buffer.h"
#include "defines.h" #include "defines.h"
#include "display.h" #include "display.h"
#include "estruct.h"
#include "execute.h" #include "execute.h"
#include "fileio.h" #include "fileio.h"
#include "input.h" #include "input.h"

View File

@ -13,8 +13,8 @@
#include <unistd.h> #include <unistd.h>
#include "bind.h" #include "bind.h"
#include "estruct.h"
#include "bindable.h" #include "bindable.h"
#include "defines.h"
#include "display.h" /* rubout(), echos(), echoc(), update() */ #include "display.h" /* rubout(), echos(), echoc(), update() */
#include "exec.h" #include "exec.h"
#include "isa.h" #include "isa.h"

View File

@ -27,8 +27,8 @@
#include "basic.h" #include "basic.h"
#include "buffer.h" #include "buffer.h"
#include "defines.h"
#include "display.h" #include "display.h"
#include "estruct.h"
#include "exec.h" #include "exec.h"
#include "input.h" #include "input.h"
#include "line.h" #include "line.h"

2
line.c
View File

@ -20,7 +20,7 @@
#include <string.h> #include <string.h>
#include "buffer.h" #include "buffer.h"
#include "estruct.h" #include "defines.h"
#include "mlout.h" #include "mlout.h"
#include "utf8.h" #include "utf8.h"
#include "window.h" #include "window.h"

2
lock.h
View File

@ -2,7 +2,7 @@
#ifndef _LOCK_H_ #ifndef _LOCK_H_
#define _LOCK_H_ #define _LOCK_H_
#include "estruct.h" #include "defines.h" /* BSD, SVR4 */
#if BSD | SVR4 #if BSD | SVR4
int lockchk( const char *fname) ; int lockchk( const char *fname) ;

72
main.c
View File

@ -62,14 +62,13 @@
* *
*/ */
#include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "estruct.h" /* Global structures and defines. */ #include "defines.h" /* OS specific customization */
#if UNIX #if UNIX
#include <signal.h> # include <signal.h>
#endif #endif
#include "basic.h" #include "basic.h"
@ -91,9 +90,8 @@
#include "window.h" #include "window.h"
#if UNIX #if UNIX
static void emergencyexit(int signr) static void emergencyexit( int signr) {
{ quickexit( FALSE, 0) ;
quickexit(FALSE, 0);
quit( TRUE, 0) ; /* If quickexit fails (to save changes), do a force quit */ quit( TRUE, 0) ; /* If quickexit fails (to save changes), do a force quit */
} }
#endif #endif
@ -124,13 +122,12 @@ static void usage( void) {
} }
int main(int argc, char **argv) int main( int argc, char *argv[]) {
{ buffer_p bp; /* temp buffer pointer */
struct buffer *bp; /* temp buffer pointer */
int firstfile; /* first file flag */ int firstfile; /* first file flag */
int carg; /* current arg to scan */ int carg; /* current arg to scan */
int startflag; /* startup executed flag */ int startflag; /* startup executed flag */
struct buffer *firstbp = NULL; /* ptr to first buffer in cmd line */ buffer_p firstbp = NULL; /* ptr to first buffer in cmd line */
int viewflag; /* are we starting in view mode? */ int viewflag; /* are we starting in view mode? */
int gotoflag; /* do we need to goto a line at start? */ int gotoflag; /* do we need to goto a line at start? */
int gline = 0; /* if so, what line? */ int gline = 0; /* if so, what line? */
@ -138,17 +135,10 @@ int main(int argc, char **argv)
int errflag; /* C error processing? */ int errflag; /* C error processing? */
bname_t bname ; /* buffer name of file to read */ bname_t bname ; /* buffer name of file to read */
setlocale( LC_CTYPE, "") ; /* expects $LANG like en_GB.UTF-8 */
#if PKCODE & BSD #if PKCODE & BSD
sleep(1); /* Time for window manager. */ sleep(1); /* Time for window manager. */
#endif #endif
#if UNIX
#ifdef SIGWINCH
signal(SIGWINCH, sizesignal);
#endif
#endif
if( argc == 2) { if( argc == 2) {
if( strcmp( argv[ 1], "--help") == 0) { if( strcmp( argv[ 1], "--help") == 0) {
usage() ; usage() ;
@ -325,7 +315,7 @@ int main(int argc, char **argv)
*/ */
static void edinit( char *bname) { static void edinit( char *bname) {
buffer_p bp; buffer_p bp;
struct window *wp; window_p wp;
if( !init_bindings() /* initialize mapping of function to name and key */ if( !init_bindings() /* initialize mapping of function to name and key */
|| NULL == (bp = bfind( bname, TRUE, 0)) /* First buffer */ || NULL == (bp = bfind( bname, TRUE, 0)) /* First buffer */
@ -442,42 +432,36 @@ static void dspram( void)
#if CLEAN #if CLEAN
/* /* cexit()
* cexit()
* *
* int status; return status of emacs * int status; return status of emacs
*/ */
void cexit( int status) { void cexit( int status) {
struct buffer *bp; /* buffer list pointer */ /* first clean up the windows */
struct window *wp; /* window list pointer */ window_p wp = wheadp ;
struct window *tp; /* temporary window pointer */ while( wp) {
window_p tp = wp->w_wndp ;
/* first clean up the windows */ free( wp) ;
wp = wheadp; wp = tp ;
while (wp) {
tp = wp->w_wndp;
free(wp);
wp = tp;
} }
wheadp = NULL;
wheadp = NULL ;
/* then the buffers */ /* then the buffers */
bp = bheadp; buffer_p bp ;
while (bp) { while( (bp = bheadp) != NULL) {
bp->b_nwnd = 0; bp->b_nwnd = 0 ;
bp->b_flag = 0; /* don't say anything about a changed buffer! */ bp->b_flag = 0 ; /* don't say anything about a changed buffer! */
zotbuf(bp); zotbuf( bp) ;
bp = bheadp;
} }
/* and the kill buffer */ /* and the kill buffer */
kdelete(); kdelete() ;
/* and the video buffers */ /* and the video buffers */
vtfree(); vtfree() ;
#undef exit (exit)( status) ;
exit(status);
} }
#endif #endif

View File

@ -2,7 +2,7 @@
#ifndef _PKLOCK_H_ #ifndef _PKLOCK_H_
#define _PKLOCK_H_ #define _PKLOCK_H_
#include "estruct.h" #include "defines.h" /* FILOCK, BSD, SVR4 */
#if (FILOCK && BSD) || SVR4 #if (FILOCK && BSD) || SVR4
char *dolock( const char *fname) ; char *dolock( const char *fname) ;

45
posix.c
View File

@ -1,18 +1,17 @@
/* posix.c -- posix implementation of termio.h */ /* posix.c -- posix implementation of termio.h */
#ifdef POSIX
#include "termio.h" #include "termio.h"
/* posix.c #include "defines.h" /* POSIX */
* #ifdef POSIX
* The functions in this file negotiate with the operating system for
* characters, and write characters in a barely buffered fashion on the /* The functions in this file negotiate with the operating system for
* display. All operating systems. characters, and write characters in a barely buffered fashion on the
* display. All operating systems.
* modified by Petri Kutvonen
* modified by Petri Kutvonen
* based on termio.c, with all the old cruft removed, and
* fixed for termios rather than the old termio.. Linus Torvalds based on termio.c, with all the old cruft removed, and
fixed for termios rather than the old termio.. Linus Torvalds
*/ */
#include <errno.h> #include <errno.h>
@ -24,21 +23,19 @@
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include "estruct.h"
#include "retcode.h" #include "retcode.h"
#include "utf8.h" #include "utf8.h"
int ttrow = HUGE ; /* Row location of HW cursor */ int ttrow = -1 ; /* Row location of HW cursor */
int ttcol = HUGE ; /* Column location of HW cursor */ int ttcol = -1 ; /* Column location of HW cursor */
/* Since Mac OS X's termios.h doesn't have the following 2 macros, define them. /* Define missing macroes for BSD and CYGWIN environment */
*/ #if BSD
#if BSD || defined(SYSV) && (defined(_DARWIN_C_SOURCE) || defined(_FREEBSD_C_SOURCE))
#define OLCUC 0000002 #define OLCUC 0000002
#define XCASE 0000004 #define XCASE 0000004
#endif #endif
#ifdef CYGWIN #ifdef __CYGWIN__ /* gcc predefined (see cpp -dM) */
#define XCASE 0 #define XCASE 0
#define ECHOPRT 0 #define ECHOPRT 0
#define PENDIN 0 #define PENDIN 0
@ -96,10 +93,8 @@ void ttopen(void)
kbdflgs = fcntl(0, F_GETFL, 0); kbdflgs = fcntl(0, F_GETFL, 0);
kbdpoll = FALSE; kbdpoll = FALSE;
/* on all screens we are not sure of the initial position /* on all screens we are not sure of the initial position of the cursor */
of the cursor */ ttrow = ttcol = -1 ;
ttrow = 999;
ttcol = 999;
} }
/* /*
@ -247,8 +242,6 @@ int typahead(void)
return x; return x;
} }
#else #endif
typedef void _pedantic_empty_translation_unit ;
#endif /* not POSIX */
/* end of posix.c */ /* end of posix.c */

View File

@ -14,8 +14,8 @@
#include "basic.h" #include "basic.h"
#include "buffer.h" #include "buffer.h"
#include "defines.h"
#include "display.h" #include "display.h"
#include "estruct.h"
#include "execute.h" #include "execute.h"
#include "input.h" #include "input.h"
#include "line.h" #include "line.h"

View File

@ -12,7 +12,7 @@
#include <stddef.h> #include <stddef.h>
#include "buffer.h" #include "buffer.h"
#include "estruct.h" #include "defines.h"
#include "line.h" #include "line.h"
#include "mlout.h" #include "mlout.h"
#include "random.h" #include "random.h"

View File

@ -65,8 +65,8 @@
#include "basic.h" #include "basic.h"
#include "buffer.h" #include "buffer.h"
#include "defines.h"
#include "display.h" #include "display.h"
#include "estruct.h"
#include "input.h" #include "input.h"
#include "isa.h" #include "isa.h"
#include "line.h" #include "line.h"

View File

@ -12,11 +12,9 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "defines.h"
#include "buffer.h" #include "buffer.h"
#include "defines.h"
#include "display.h" #include "display.h"
#include "estruct.h"
#include "exec.h" #include "exec.h"
#include "file.h" #include "file.h"
#include "flook.h" #include "flook.h"
@ -27,8 +25,6 @@
#if USG | BSD #if USG | BSD
#include <signal.h> #include <signal.h>
#ifdef SIGWINCH
#endif
#endif #endif

18
tcap.c
View File

@ -20,8 +20,8 @@
#include <curses.h> #include <curses.h>
#include <term.h> #include <term.h>
#include "defines.h"
#include "display.h" #include "display.h"
#include "estruct.h"
#include "termio.h" #include "termio.h"
#if TERMCAP #if TERMCAP
@ -83,7 +83,7 @@ static char *_UP, _PC, *CM, *CE, *CL, *SO, *SE;
static char *CS, *DL, *AL, *SF, *SR; static char *CS, *DL, *AL, *SF, *SR;
# endif # endif
struct terminal term = { terminal_t term = {
480, /* actual 479 on 2560x1440 landscape terminal window */ 480, /* actual 479 on 2560x1440 landscape terminal window */
2550, /* actual 2541 */ 2550, /* actual 2541 */
0, /* These four values are set dynamically at open time. */ 0, /* These four values are set dynamically at open time. */
@ -231,16 +231,14 @@ static void tcapclose(void)
} }
# endif # endif
static void tcapkopen(void) static void tcapkopen( void) {
{
# if PKCODE # if PKCODE
putpad(TI); putpad( TI) ;
ttflush(); ttflush() ;
ttrow = 999; ttrow = ttcol = -1 ;
ttcol = 999; sgarbf = TRUE ;
sgarbf = TRUE;
# endif # endif
strcpy(sres, "NORMAL"); strcpy(sres, "NORMAL") ;
} }
static void tcapkclose(void) static void tcapkclose(void)

View File

@ -6,45 +6,45 @@
#include "retcode.h" #include "retcode.h"
#include "utf8.h" #include "utf8.h"
/* The editor communicates with the display using a high level interface. A /* The editor communicates with the display using a high level interface.
* "TERM" structure holds useful variables, and indirect pointers to routines A "TERM" structure holds useful variables, and indirect pointers to
* that do useful operations. The low level get and put routines are here too. routines that do useful operations. The low level get and put routines
* This lets a terminal, in addition to having non standard commands, have are here too. This lets a terminal, in addition to having non standard
* funny get and put character code too. The calls might get changed to commands, have funny get and put character code too. The calls might
* "termp->t_field" style in the future, to make it possible to run more than get changed to "termp->t_field" style in the future, to make it possible
* one terminal type. to run more than one terminal type.
*/ */
struct terminal { typedef struct {
const short t_maxrow ; /* max number of rows allowable */ const short t_maxrow ; /* max number of rows allowable */
const short t_maxcol ; /* max number of columns allowable */ const short t_maxcol ; /* max number of columns allowable */
short t_mrow ; /* max number of rows displayable */ short t_mrow ; /* max number of rows displayable */
short t_nrow ; /* current number of rows displayed */ short t_nrow ; /* current number of rows displayed */
short t_mcol ; /* max number of rows displayable */ short t_mcol ; /* max number of rows displayable */
short t_ncol ; /* current number of columns displayed */ short t_ncol ; /* current number of columns displayed */
short t_margin; /* min margin for extended lines */ short t_margin ; /* min margin for extended lines */
short t_scrsiz; /* size of scroll region " */ short t_scrsiz ; /* size of scroll region */
int t_pause; /* # times thru update to pause */ int t_pause ; /* # times thru update to pause */
void (*t_open)(void); /* Open terminal at the start. */ void (*t_open)( void) ; /* Open terminal at the start */
void (*t_close)(void); /* Close terminal at end. */ void (*t_close)( void) ; /* Close terminal at end. */
void (*t_kopen)(void); /* Open keyboard */ void (*t_kopen)( void) ; /* Open keyboard */
void (*t_kclose)(void); /* close keyboard */ void (*t_kclose)( void) ; /* close keyboard */
int (*t_getchar)(void); /* Get character from keyboard. */ int (*t_getchar)( void) ; /* Get character from keyboard */
int (*t_putchar)( unicode_t) ; /* Put character to display. */ int (*t_putchar)( unicode_t) ; /* Put character to display */
void (*t_flush) (void); /* Flush output buffers. */ void (*t_flush) (void) ; /* Flush output buffers */
void (*t_move)(int, int);/* Move the cursor, origin 0. */ void (*t_move)( int, int) ; /* Move the cursor, origin 0 */
void (*t_eeol)(void); /* Erase to end of line. */ void (*t_eeol)( void) ; /* Erase to end of line */
void (*t_eeop)(void); /* Erase to end of page. */ void (*t_eeop)( void) ; /* Erase to end of page */
void (*t_beep)(void); /* Beep. */ void (*t_beep)( void) ; /* Beep */
void (*t_rev)(int); /* set reverse video state */ void (*t_rev)( int) ; /* set reverse video state */
int (*t_rez)(char *); /* change screen resolution */ int (*t_rez)( char *) ; /* change screen resolution */
#if COLOR #if COLOR
int (*t_setfor) (); /* set forground color */ int (*t_setfor)() ; /* set forground color */
int (*t_setback) (); /* set background color */ int (*t_setback)() ; /* set background color */
#endif #endif
#if SCROLLCODE #if SCROLLCODE
void (*t_scroll)(int, int,int); /* scroll a region of the screen */ void (*t_scroll)( int, int,int) ; /* scroll a region of the screen */
#endif #endif
}; } terminal_t ;
/* TEMPORARY macros for terminal I/O (to be placed in a machine dependant /* TEMPORARY macros for terminal I/O (to be placed in a machine dependant
place later) place later)
@ -68,11 +68,8 @@ struct terminal {
#define TTbacg (*term.t_setback) #define TTbacg (*term.t_setback)
#endif #endif
/* Terminal table defined only in term.c */ /* Terminal table defined only in tcap.c */
extern struct terminal term ; extern terminal_t term ;
extern int ttrow ; /* Row location of HW cursor */
extern int ttcol ; /* Column location of HW cursor */
extern boolean eolexist ; /* does clear to EOL exist? */ extern boolean eolexist ; /* does clear to EOL exist? */
extern boolean revexist ; /* does reverse video exist? */ extern boolean revexist ; /* does reverse video exist? */

View File

@ -1,21 +1,19 @@
/* termio.c -- implements termio.h */ /* termio.c -- implements termio.h */
#if !defined( POSIX)
#include "termio.h" #include "termio.h"
/* TERMIO.C #include "defines.h" /* POSIX */
* #ifndef POSIX
* The functions in this file negotiate with the operating system for
* characters, and write characters in a barely buffered fashion on the display. /* The functions in this file negotiate with the operating system for
* All operating systems. characters, and write characters in a barely buffered fashion on the
* display. All operating systems.
* modified by Petri Kutvonen
modified by Petri Kutvonen
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "estruct.h"
#include "retcode.h" #include "retcode.h"
#include "utf8.h" #include "utf8.h"
@ -23,8 +21,8 @@
#include <unistd.h> #include <unistd.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
int ttrow = HUGE ; /* Row location of HW cursor */ int ttrow = -1 ; /* Row location of HW cursor */
int ttcol = HUGE ; /* Column location of HW cursor */ int ttcol = -1 ; /* Column location of HW cursor */
#if USG /* System V */ #if USG /* System V */
@ -141,8 +139,7 @@ void ttopen(void)
/* on all screens we are not sure of the initial position /* on all screens we are not sure of the initial position
of the cursor */ of the cursor */
ttrow = 999; ttrow = ttcol = -1 ;
ttcol = 999;
} }
/* /*
@ -258,14 +255,12 @@ int typahead( void)
return kbdqp; return kbdqp;
#endif #endif
#if !UNIX # if !UNIX
return FALSE; return FALSE;
#endif # endif
} }
#endif # endif
#else
typedef void _pedantic_empty_translation_unit ;
#endif /* not POSIX */ #endif /* not POSIX */
/* end of termio.c */ /* end of termio.c */

View File

@ -6,8 +6,6 @@
#define TYPEAH 1 /* type ahead causes update to be skipped */ #define TYPEAH 1 /* type ahead causes update to be skipped */
#define HUGE 1000 /* Huge number (for row/col) */
extern int ttrow ; /* Row location of HW cursor */ extern int ttrow ; /* Row location of HW cursor */
extern int ttcol ; /* Column location of HW cursor */ extern int ttcol ; /* Column location of HW cursor */

7
utf8.c
View File

@ -1,16 +1,13 @@
/* utf8.c -- implements utf8.h, conversion between unicode and UTF-8 */ /* utf8.c -- implements utf8.h, conversion between unicode and UTF-8 */
#include "utf8.h" #include "utf8.h"
#define _XOPEN_SOURCE /* wcwidth in wchar.h */
#include <assert.h> #include <assert.h>
#include <wchar.h> #include <wchar.h> /* either _XOPEN_SOURCE or _GNU_SOURCE */
/* Display width of UTF-8 character */ /* Display width of UTF-8 character */
int _utf8_width( unicode_t c) { int _utf8_width( unicode_t c) {
#if CYGWIN #if __SIZEOF_WCHAR_T__ == 2 /* wcwidth only supports UTF-16 */
assert( sizeof( wchar_t) == 2) ; /* wcwidth only supports UTF-16 */
return (c < 0x10000) ? wcwidth( (wchar_t) c) : -1 ; return (c < 0x10000) ? wcwidth( (wchar_t) c) : -1 ;
#else #else
return wcwidth( (wchar_t) c) ; return wcwidth( (wchar_t) c) ;

View File

@ -9,8 +9,8 @@
#include "basic.h" #include "basic.h"
#include "buffer.h" #include "buffer.h"
#include "defines.h"
#include "display.h" /* upmode() */ #include "display.h" /* upmode() */
#include "estruct.h"
#include "execute.h" #include "execute.h"
#include "line.h" #include "line.h"
#include "mlout.h" #include "mlout.h"

2
word.c
View File

@ -14,7 +14,7 @@
#include "basic.h" #include "basic.h"
#include "buffer.h" #include "buffer.h"
#include "estruct.h" #include "defines.h"
#include "isa.h" #include "isa.h"
#include "line.h" #include "line.h"
#include "mlout.h" #include "mlout.h"