/* Copyright (c) 1982, 1983, 1986 by Manx Software Systems */ /* Copyright (c) 1982, 1983, 1986 by Jim Goodnow II */ /* Changes by Jerry Davis for CP/M and VT100 terminals */ #include "vi.h" #include "sgtty.h" init() { struct sgttyb ss; char *malloc(); if (Tabwidth == 0) Tabwidth = 4; Max_mem = 32000; while ((Mem_buf = malloc(Max_mem)) == 0) Max_mem -= 2000; free(Mem_buf); Max_mem -= 1024; Mem_buf = malloc(Max_mem); setmem (Mem_buf, Max_mem, 0); Width = SCR_WID; Lwidth = Width + 1; clr_scrn(); ioctl(0, TIOCGETP, &ss); ss.sg_flags = CBREAK | RAW; ioctl (0, TIOCSETP, &ss); } quit() { mv_curs(0, 0); scr_clear(); exit(0); } /* * Move the cursor to the appropriate position. */ mv_curs(x, y) register int x, y; { char buf[4]; if (x >= Width) { y += x / Width; x = x % Width; } scr_curs(y,x); } /* * This routine beeps. */ beep() { scr_beep(); } /* * This routine puts a message on the status line. */ mesg(str) char *str; { mv_curs(0, STATUS); write(1, str, strlen(str)); clr_eol(); } /* * This routine scrolls up the display and moves * cursor to the last line. */ up_scrl(n) int n; { scr_scrlup(); mv_curs(0, SCR_BOT); while (n--) write(1,"\n\r", 2); fix_msg(); } /* * This routine clears from the current cursor position to the end of the line. */ clr_eol() { scr_eol(); } /* * This routine clears the entire screen. */ clr_scrn() { scr_clear(); } /* * This routine scrolls down the display and moves * cursor to top of screen. */ dn_scrl() { mv_curs(0,SCR_BOT-1); scr_eol(); mv_curs(0,STATUS+1); scr_linsert(); } /* * Wrapper for read routine. Needed because getchar * is set to RAW. */ getchar() { char c; read(0, &c, 1); return(c); }