COPT = -O2
OBJS = ue.rel
+LIBS = term-ansi.c term-fuzix.c term.c
-all: ue
+all: ue.fuzix ue.ansi ue
-ue: $(OBJS)
- $(CC) -o $@ --nostdio $(OBJS)
+$(OBJS): ue.h
+$(LIBS): ue.h
.c.rel:
$(CC) $(COPT) $(CFLAGS) $(DEFS) -c $< -o $@
+ue.fuzix: $(OBJS) term-fuzix.rel
+ $(CC) -o $@ --nostdio $(OBJS) term-fuzix.rel
+
+ue.ansi: $(OBJS) term-ansi.rel
+ $(CC) -o $@ $(OBJS) term-ansi.rel
+
+ue: $(OBJS) term.rel
+ $(CC) -o $@ --nostdio $(OBJS) term.rel -ltermcap
+
clean realclean clobber:
rm -f *.rel ue *~
.SUFFIXES: .c .o
+APPS = ue.fuzix ue.ansi ue
-SRCS = ue.c
+SRCS = ue.c term-fuzix.c term-ansi.c term.c
OBJS = $(SRCS:.c=.o)
-APPS = $(OBJS:.o=)
-
all: $(APPS) size.report
-$(APPS): $(CRT0NS)
+$(APPS): ue.h
+
+ue.fuzix: ue.o term-fuzix.o
+ $(LINKER) -o $@ $(LINKER_OPT) $(CRT0NS) ue.o term-fuzix.o
+
+ue.ansi: ue.o term-ansi.o
+ $(LINKER) -o $@ $(LINKER_OPT) $(CRT0) ue.o term-ansi.o
-$(APPS): %: %.o
- $(LINKER) -o $@ $(LINKER_OPT) $^
+ue: ue.o term.o
+ $(LINKER) -o $@ $(LINKER_OPT) $(CRT0NS) ue.o term.o -ltermcap6809
size.report: $(APPS)
ls -l $< > $@
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "ue.h"
+
+char str[MAXCOLS]; /* used by gotoxy and clrtoeol */
+
+void gotoxy(int x, int y)
+{
+ sprintf(str,"%c[%03d;%03dH",0x1b,y,x);
+ write(1, (void*)&str, 10);
+ outxy.Y=y;outxy.X=x;
+}
+
+void clrtoeol(void)
+{
+ if (COLS-outxy.X > 0) {
+ memset(str, ' ', COLS-outxy.X);
+ write(1, str, COLS-outxy.X);
+ }
+ gotoxy(outxy.X,outxy.Y);
+}
+
+
+void clrtoeos(void)
+{
+ int i = outxy.Y;
+ while(i++ <= ROWS){
+ clrtoeol();
+ gotoxy(1,i);
+ }
+}
+
+void tty_init(void)
+{
+}
--- /dev/null
+#include <unistd.h>
+#include "ue.h"
+
+static char str[4] = "\x1bY";
+
+void gotoxy(int x, int y){
+ str[2] = y + 31;
+ str[3] = x + 31;
+ write(1, (void*)&str, 4);
+ outxy.Y=y;outxy.X=x;
+}
+
+void clrtoeol(void)
+{
+ write(1, "\x1b" "K", 2);
+ gotoxy(outxy.X,outxy.Y);
+}
+
+void clrtoeos(void)
+{
+ write(1, "\x1b" "J", 2); /* clear to end of screen */
+}
+
+void tty_init(void)
+{
+}
+++ /dev/null
-/* temporary replacement for a working <sys/tty.h> */
-
-struct winsize {
- unsigned short ws_row;
- unsigned short ws_col;
- unsigned short ws_xpixel;
- unsigned short ws_ypixel;
-};
-#define TIOCGWINSZ 10
-#define VTSIZE 0x22
-
#include <ctype.h>
#include <string.h>
#include <termios.h>
-#ifdef ANSIEMU
-# include <stdio.h>
-#endif
#include <unistd.h>
+#include "ue.h"
-#define BUF 4096*6
-#define UBUF 768
-#define MODE 0666
-#define TABSZ 4
-#define TABM TABSZ-1
-
-#define MAXCOLS 96
-
-int MAXLINES = 25;
+COORD outxy;
+int ROWS = MAXROWS;
int COLS = MAXCOLS;
int LINES = 1;
int done;
int row, col;
-char str[MAXCOLS]; // used by gotoxy and clrtoeol
char prompt[]="Look for: ";
char sstring[MAXCOLS]; // search string, used by look()
char ubuf[UBUF]; // undo buffer
U_REC* undop = (U_REC*)&ubuf;
-typedef struct {
- int X;
- int Y;
-} COORD;
-
-COORD outxy;
-
struct termios termios, orig;
// edit key function prototypes
tcsetattr(0, TCSANOW, termiop);
}
-void
-gotoxy(int x, int y){
-#ifdef ANSIEMU
- sprintf(str,"%c[%03d;%03dH",0x1b,y,x);
- write(1, (void*)&str, 10);
-#else
- str[0] = '\x1b';
- str[1] = 'Y';
- str[2] = y + 31;
- str[3] = x + 31;
- write(1, (void*)&str, 4);
-#endif
- outxy.Y=y;outxy.X=x;
-}
-
char
getch()
{
if(c == '\n'){outxy.X=0;outxy.Y++;};
}
-void
-clrtoeol(void)
-{
-#ifdef ANSIEMU
- int i=0;
- while(i < COLS-outxy.X)
- str[i++]=' ';
- write(1, (void*)&str, COLS-outxy.X > 0 ? COLS-outxy.X : 0);
-#else
- write(1, "\x1b" "K", 2);
-#endif
- gotoxy(outxy.X,outxy.Y);
-}
// end of I/O
char *prevline(char *p)
void
pgup(void)
{
- int i = MAXLINES;
+ int i = ROWS;
while (0 < --i) {
page = prevline(page-1);
up();
page = prevline(curp);
if (epage <= curp) {
page = curp;
- i = MAXLINES;
+ i = ROWS;
while (1 < i--)
page = prevline(page-1);
}
row = i;
col = j;
}
- if (i >= MAXLINES || LINES <= i || etxt <= epage)
+ if (i >= ROWS || LINES <= i || etxt <= epage)
break;
if (*epage == '\n' || COLS <= j) {
++i;
}
++epage;
}
-#ifdef ANSIEMU
- i = outxy.Y;
- while(i++ <= MAXLINES){
- clrtoeol();
- gotoxy(1,i);
- }
-#else
- write(1, "\x1b" "J", 2); /* clear to end of screen */
-#endif
+ clrtoeos();
gotoxy(col+1, row+1);
}
#ifdef VTSIZE
vtsize = ioctl(0, VTSIZE, 0);
if (vtsize != -1) {
- MAXLINES = vtsize >> 8;
+ ROWS = vtsize >> 8;
COLS = vtsize & 0xFF;
}
#endif
#ifdef TIOCGWINSZ
if (ioctl(0, TIOCGWINSZ, &w) != -1) {
if (w.ws_row != 0)
- MAXLINES = w.ws_row;
+ ROWS = w.ws_row;
if (w.ws_col != 0)
COLS = w.ws_col;
}
#endif
+ tty_init();
+
if (0 < (i = open(filename = *++argv, 0))) {
etxt += read(i, buf, BUF);
if (etxt < buf)
}
}
}
- gotoxy(1,MAXLINES+1);
+ gotoxy(1,ROWS+1);
GetSetTerm(1);
return (0);
}
--- /dev/null
+typedef struct {
+ int X;
+ int Y;
+} COORD;
+
+extern COORD outxy;
+
+extern void clrtoeol(void);
+extern void clrtoeos(void);
+extern void gotoxy(int, int);
+extern void tty_init(void);
+
+#define BUF 4096*6
+#define UBUF 768
+#define MODE 0666
+#define TABSZ 4
+#define TABM TABSZ-1
+
+#define MAXCOLS 132
+#define MAXROWS 32
+
+extern int ROWS;
+extern int COLS;