home *** CD-ROM | disk | FTP | other *** search
- /*
- * utils.c: hterm utilities (regident or not regident)
- *
- * Author: HIRANO Satoshi
- * (C) 1990 Halca Computer Science Laboratory TM
- * University of Tokyo
- *
- * 1.1 90/03/29 Halca.Hirano derived from half of setup.c
- * 1.2 90/06/17 Halca.Hirano support filename completion in emacs()
- *
- * $Header: utils.cv 1.5 90/07/05 08:37:26 hirano Exp $
- */
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <string.h>
- #include <io.h>
- #include <stdlib.h>
- #if !defined(__TURBOC__) || __TURBOC__ >= 0x0200
- #include <sys/types.h>
- #endif
- #include <sys/stat.h>
- #include "config.h"
- #include "hterm.h"
- #include "option.h"
- #include "default.h"
- #include "global.h"
- #include "version.h"
- #include "indexer.h"
-
- static char buf[60];
-
- int emacsPutBuf(int c);
-
- /*
- ** void putStatus(char *s)
- *
- * display message on status line
- */
- void putStatus(s)
- char *s;
- {
- int attrSave2 = attrib;
- u_short xSave = cursorX, ySave = cursorY;
-
- clearStatus();
- attrib = eraseAttr;
- locate(0, realBottomLine);
- while (*s)
- conWrite(*s++);
- attrib = attrSave2;
- locate(xSave, ySave);
- }
-
- /*
- ** void clearStatus()
- *
- * clear status line
- */
- void clearStatus()
- {
- u_short attrSave = attrib;
- u_short xSave = cursorX, ySave = cursorY;
-
- attrib = eraseAttr;
- clearLine(realBottomLine, realBottomLine);
- attrib = attrSave;
- locate(xSave, ySave);
- }
-
- /*
- ** void clearCopyright()
- *
- * clear copyright lines
- */
- void clearCopyright()
- {
- u_short origX = cursorX;
- u_short origY = cursorY;
- u_short attrSave = attrib;
-
- attrib = eraseAttr;
- clearLine(0, SETUP_LINE-1);
- attrib = attrSave;
- locate(origX, origY);
- }
-
- /*
- ** void flushComment(char *s)
- *
- * display comment in short term on the status line
- */
- void flushComment(s)
- char *s;
- {
- putStatus(s);
- kermitTimer = TICK_SEC/3;
- while (kermitTimer > 0)
- nullFunction();
- clearStatus();
- }
-
- /*
- ** void putComment(char *msg, char *msg2)
- *
- * display "hterm: hello world" string
- */
- void putComment(msg, msg2)
- char *msg, *msg2;
- {
- conPrint("hterm: ");
- conPrint(msg); conPrint(msg2);
- conPrint("\n\r");
- }
-
- /*
- ** char *versionString()
- *
- * return hterm version string
- */
- char *versionString()
- {
- sprintf(tmpBuf, "hterm %u.%u.%d.%d %s %s\n\r", VERSION,
- REVISION, EDITION, LOCAL_EDITION, MACHINE, RELDATE);
- tmpBuf[39] = '\0'; /* ensure lenght 40 chars for setup file */
- return(tmpBuf); /* please take attention! use immedeatly */
- }
-
- /*
- ** int checkEvent()
- *
- * return non 0 if key or serial data is available
- */
- int checkEvent()
- {
- return(checkKey() || checkSerial());
- }
-
- /*
- ** void showPage1()
- * save page0 context, show page1
- */
- void showPage1()
- {
- savePage(page0Save);
- curXSave = cursorX; curYSave = cursorY;
- attrSave = attrib;
- lowScrRgSave = lowScrRegion;
- printMSave = printMode;
- intConSave = intControl;
- kfirstSave = kfirst; kstateSave = kstate;
- lineModeSave = lineMode;
- loggingSave = logging;
- upLoadSave = upLoading;
- cursorSave = cursor;
- kanjiSave = kanjiCode;
- wrapPendingSave = wrapPending;
-
- logging = cursor = printMode = NO;
- cursorOnOff(NO);
- kfirst = kstate = 0;
- intControl = YES;
-
- attrib = eraseAttr;
- kanjiCode = SJIS; /* for help system */
-
- setLineMode(LINE_MODE_25);
- initPage();
- lowScrRegion = bottomLine;
- locate(0, 0);
- }
-
-
- /*
- ** void showPage0()
- *
- * restore page1 context, show page0
- */
- void showPage0()
- {
- setLineMode(lineMode);
- lowScrRegion = lowScrRgSave;
- restorePage(page0Save);
- cursor = cursorSave;
- cursorOnOff(cursor);
- kfirst = kfirstSave; kstate = kstateSave;
- attrib = attrSave;
- cursorX = curXSave; cursorY = curYSave;
- kanjiCode = kanjiSave;
- awMode(autoWrap);
- locate(cursorX, cursorY);
- printMode = printMSave;
- intControl = intConSave;
- logging = loggingSave;
- upLoading = upLoadSave;
- wrapPending = wrapPendingSave; /* this must be after locate() */
- }
-
- /*
- ** void callOS()
- *
- * call local operating system user interface
- */
- void callOS()
- {
- char *p;
- extern char *getenv();
- int oldMode = mode;
- int eraseAttrSave = eraseAttr;
- int softFontSave = softFont;
- int cursorSave = cursor;
- int attrSave = attrib;
- static char commandLine[MAX_FILE_NAME] = "";
-
- mode = M_SETUP;
- if (emacs("Program: ", commandLine, MAX_FILE_NAME, E_HELP) != ERR) {
- if (commandLine[0] != '\0')
- p = commandLine;
- else if (defaultCommandLine[0] != '\0')
- p = defaultCommandLine;
- else if ((p = getenv("COMSPEC")) == NULL)
- p = "command.com";
- mode = M_OS;
- restoreCRTMode();
- mouseEnd();
- restoreCritHandler(); /* restore critical error handler */
- keyEnd(); /* restore keyboard handler */
- portEnd(); /* restore port handler */
- saverEnd(); /* restore timer handler */
-
- printf("\x1b[1;1f"); fflush(stdout); /* move cursor to (0, 0) */
- system(p);
- printf("\nHit Any Key"); fflush(stdout);
-
- saverReInit(); /* reinitialize timer handler */
- keyReInit(); /* reinitialize keyboard handler */
- portReInit(); /* reinstall port handler */
- portSetup(); /* initialize port handler */
- setCritHandler(); /* set critical error handler */
- while (keyin() == -1)
- ;
- eraseAttr = eraseAttrSave;
- attrib = attrSave;
- softFont = softFontSave;
- cursor = cursorSave;
- consoleSetup();
- mouseInit();
- }
- mode = oldMode;
- }
-
-
- /*
- ** char *helpSystem(char *key)
- *
- * print help message for key from hterm database
- */
- char *helpSystem(key)
- char *key;
- {
- static char nextKey[KEY_LEN];
- char buf[100];
-
- if (openIndex(helpFileName) == ERR) {
- sprintf(buf, msg_cantOpen, helpFileName);
- putStatus(buf);
- return((char *)NULL);
- }
- if (getKey(key, nextKey) == ERR) {
- sprintf(buf, "Sorry, help info '%s' is not found.", key);
- putStatus(buf);
- return((char *)NULL);
- }
- clearCopyright();
- locate(0, 0);
- while (getRecord(buf, sizeof(buf)) != ERR) {
- conPrint(buf); conPrint("\r");
- }
- showHelp = YES;
- return(nextKey);
- }
-
- /*
- ** int emacs(char *prompt, char *buf, int limit, int help)
- *
- * 'emacs mini-buffer'
- *
- * put the prompt, input a string into buf (size 'limit')
- * buf should be \0 terminated.
- * If help is YES, display emacs help message to copyright screen
- *
- */
- int emacs(prompt, buf, limit, help)
- char *prompt, *buf;
- int limit;
- int help;
- {
- int disp; /* display pointer */
- int dispTop; /* display top of line position */
- int dispEnd; /* display end of line position */
- int at; /* buffer pointer */
- int max; /* buffer max pointer */
- int end = NO; /* edit end flag */
- int size; /* temporary char size */
- u_short c;
- u_short attrSave2 = attrib;
- u_short origX = cursorX;
- u_short origY = cursorY;
- int cursorSave = cursor;
- char *p;
- char fileNameBuf[100], *buf2, *fileName;
- int fx;
- int first;
-
- if (help & E_HELP)
- helpSystem("emacs");
- cursor = YES;
- cursorOnOff(YES);
- redraw:
- at = max = strlen(buf);
- locate(0, realBottomLine);
- clearStatus();
- disp = 0;
-
- /* put prompt */
- for (p = prompt; *p; p++)
- disp += emacsPutBuf(*p);
- dispTop = disp; /* display top of line */
-
- /* put default buffer string */
- locate(dispTop, realBottomLine);
- for (p = buf; *p; p++) {
- disp += emacsPutBuf(*p);
- if (disp >= LAST_COLUMN-2)
- break;
- }
- dispEnd = disp;
-
- while (end == NO) {
- while ((int)(c = keyin()) == -1)
- ;
- if (c == CR) {
- end = YES;
- } else if (c == ESC || c == bindTab[C_ABORT]) {
- end = ERR; /* abort */
- } else if (c == HOME_KEY || c == bindTab[C_TOL]) {
- at = 0; /* top of line */
- locate(dispTop, realBottomLine);
- disp = dispTop;
- } else if (c == END_KEY || c == bindTab[C_EOL]) {
- at = max; /* end of line */
- locate(dispEnd, realBottomLine);
- disp = dispEnd;
- } else if (c == LEFT_KEY || c == bindTab[C_LEFT]) { /* backward */
- if (--at < 0)
- at = 0;
- else {
- size = charSize((u_char FAR *)buf, at);
- moveCursor(LEFT, size);
- disp -= size;
- }
- } else if (c == RIGHT_KEY || c == bindTab[C_RIGHT]) { /* forward */
- if (++at > max)
- at = max;
- else {
- size = charSize((u_char FAR *)buf, at-1);
- moveCursor(RIGHT, size);
- disp += size;
- }
- } else if (c == bindTab[C_KILLEND]) {
- max = at; /* kill to end of line */
- if (dispEnd-disp > 0)
- deleteChar(disp, dispEnd-disp);
- dispEnd = disp;
- } else if (c == bindTab[C_KILLTOP]) { /* kill to the top of line */
- dispEnd -= disp-dispTop;
- deleteChar(dispTop, disp-dispTop);
- disp = dispTop;
- locate(disp, realBottomLine);
- memcpy(buf, &buf[at], max-at);
- max -= at;
- at = 0;
- } else if (c == DEL || c == bindTab[C_BDEL]) { /* BS, DEL */
- if (at <= 0)
- at = 0;
- else {
- --at;
- size = charSize((u_char FAR *)buf, at);
- dispEnd -= size;
- disp -= size;
- moveCursor(LEFT, size);
- deleteChar(disp, size);
- memcpy(&buf[at], &buf[at+1], max-at);
- --max;
- }
- } else if (c == bindTab[C_DEL]) { /* delete char */
- if (at < max) {
- memcpy(&buf[at], &buf[at+1], max-at-1);
- --max;
- size = charSize((u_char FAR *)buf, at);
- deleteChar(disp, size);
- dispEnd -= size;
- }
- } else if ((help & E_FILE) && c == TAB) { /* file name completion */
- int x = cursorX, y = cursorY, count = 0;
- int lowScrRegionSave = lowScrRegion;
- buf[max] = '\0';
- strcpy(fileNameBuf, buf);
- toSlash(fileNameBuf);
- if (!(p = strrchr(fileNameBuf, '/')))
- p = fileNameBuf;
- if (strchr(p, '.'))
- strcat(fileNameBuf, "*");
- else
- strcat(fileNameBuf, "*.*");
- clearCopyright();
- first = YES;
- buf2 = fileNameBuf;
- lowScrRegion = SETUP_LINE-2;
- locate(0, 0);
- for (fx = 0; getNextFileName(first, &buf2, &fileName, YES);) {
- if (fx + strlen(fileName) + 4 > MAX_COLUMN) {
- fx = 0; conPrint("\n\r");
- }
- conPrint(fileName); conPrint(" ");
- fx += strlen(fileName) + 4;
- count++;
- first = NO;
- }
- if (first) { /* not found */
- conPrint(fileNameBuf); conPrint(" not found");
- }
- lowScrRegion = lowScrRegionSave;
- locate(x, y);
- if (count == 1) { /* just match */
- strcpy(buf, fileName);
- goto redraw;
- }
- } else if (c == bindTab[C_QUOTE]) { /* control char input */
- if (max >= limit-1) bell();
- else {
- while ((c = keyin()) == -1);
- goto force;
- }
- } else if (c == UP_KEY || c == DOWN_KEY) {
- ; /* ignore */
- } else {
- if (' ' <= c && c <= 0x7e)
- force: if (max >= limit-1) {
- max = limit-1; bell();
- } else {
- int j;
- for (j = max-at; j > 0; --j)
- buf[at+j] = buf[at+j-1];
- buf[at] = c;
- size = charSize((u_char FAR *)buf, at);
- insertChar(disp, size);
- dispEnd += size;
- disp += size;
- (void)emacsPutBuf(c);
- at++;
- max++;
- }
- }
- }
- buf[max] = '\0';
- attrib = attrSave2;
- clearStatus();
- cursorOnOff(cursor = cursorSave);
- locate(origX, origY);
- if (end == ERR) {
- putStatus("Abort"); bell();
- }
- if (help)
- clearCopyright();
- return(end == ERR ? ERR : OK);
- }
-
- /*
- ** static int emacsPutBuf(int c)
- *
- * print a char for mini-mini emacs
- */
- static int emacsPutBuf(c)
- int c;
- {
- if (' ' <= c && c <= 0x7e) {
- conWrite(c);
- return(1);
- } else {
- conWrite('^');
- conWrite(c == 0x7f ? '?' : (c+0x40));
- return(2);
- }
- }
-
- /*
- ** int charSize(u_char FAR *buf, int at)
- *
- * return character size at buf[at]
- */
- int charSize(buf, at)
- u_char FAR *buf;
- int at;
- {
- int c = buf[at];
-
- if (' ' <= c && c <= 0x7e)
- return(1);
- else /* control code like '^A' or kanji */
- return(2);
- }
-
- #ifdef SETUP
- /*
- ** void editKeyTable(char *name[], u_char table[][], int num, int keyLen, int nameLen)
- *
- * edit key table
- *
- * called from keypc.c, key98.c
- */
- void editKeyTable(name, table, num, keyLen, nameLen)
- char *name[];
- u_char table[][MAX_FUNKEY];
- int num; /* number of keys */
- int keyLen; /* key body length */
- int nameLen; /* key name length */
- {
- int end = 0;
- int i, j, newi;
- u_short key;
- u_char buf[40], keybuf[MAX_FUNKEY+2];
- char *junk;
- u_char *shortKeyTab;
- #define NUM_LINE 14
-
- showKeyTable(name, table, num, keyLen, nameLen);
- if (keyLen <= 1) /* for single char table */
- shortKeyTab = (u_char *)table;
- i = newi = 0;
- while (!end) {
- clearStatus();
- strcpy(buf, name[i]);
- for (j = strlen(name[i]); j < nameLen; j++)
- buf[j] = SPACE;
- buf[j] = '\0';
- locate((i/NUM_LINE)*(nameLen+keyLen+8), i%NUM_LINE);
- reverseMode();
- conPrint(buf);
- normalMode();
- while ((int)(key = keyin()) == (-1))
- ;
- if ((key & 0xff) == 0x0d) {
- if (keyLen <= 1) { /* single char */
- if (' ' < shortKeyTab[i] && shortKeyTab[i] <= 0x7e) {
- keybuf[0] = (char)shortKeyTab[i];
- keybuf[1] = '\0';
- } else {
- sprintf(keybuf, "$%02x", shortKeyTab[i]);
- }
- if (emacs(msg_newString, keybuf, 6, E_NO_HELP) != ERR) {
- /* "New string (ESC for abort): " */
- if (keybuf[0] == '$')
- if (keybuf[1] == '\0')
- shortKeyTab[i] = '$';
- else
- shortKeyTab[i] = (u_char)strtol((char *)&keybuf[1], &junk, 16);
- else
- shortKeyTab[i] = keybuf[0];
- }
- } else { /* string */
- strcpy(keybuf, table[i]);
- if (emacs(msg_newString, keybuf, keyLen, E_NO_HELP) != ERR) {
- /* "New string (ESC for abort): " */
- strcpy(table[i], keybuf);
- }
- }
- showKeyTable(name, table, num, keyLen, nameLen);
- continue;
- }
- if (key == UP_KEY || key == bindTab[C_UP]) {
- if (i > 0) newi = i - 1;
- } else if (key == DOWN_KEY || key == bindTab[C_DOWN]) {
- if (i < num -1) newi = i + 1;
- } else if (key == bindTab[C_ESC]) {
- end = 1;
- } else if (key == RIGHT_KEY || key == LEFT_KEY) {
- ; /* ignore */
- } else {
- bell();
- }
- locate((i/NUM_LINE)*(nameLen+keyLen+8), i%NUM_LINE);
- normalMode();
- conPrint(buf);
- i = newi;
- }
- clearCopyright();
- }
-
- /*
- ** static void showKeyTable(char *name[], char table[][], int num, int keyLen, int nameLen)
- *
- * display key table;
- * called by editKeyTable()
- */
- static void showKeyTable(name, table, num, keyLen, nameLen)
- char *name[];
- u_char table[][MAX_FUNKEY];
- int num;
- int keyLen;
- int nameLen;
- {
- int i;
- char *p;
- u_char *shortKeyTab, key;
- char buf[6]; /* $0000+1 */
-
- if (keyLen <= 1) /* for single char table */
- shortKeyTab = (u_char *)table;
- for (i = 0; i < num; i++) {
- locate((i/NUM_LINE)*(nameLen+keyLen+8), i%NUM_LINE);
- conPrint("\x1b[0K");
- conPrint(name[i]);
- locate((i/NUM_LINE)*(nameLen+keyLen+8)+nameLen+1, i%NUM_LINE);
- if (keyLen <= 1) { /* single char */
- key = shortKeyTab[i];
- if (' ' < key && key <= 0x7e)
- decodeAnsi(key);
- else {
- sprintf(buf, "$%02x", key);
- conPrint(buf);
- }
- } else { /* string */
- for (p = table[i]; *p; p++) {
- if (' ' <= *p && *p <= 0x7e)
- decodeAnsi(*p);
- else {
- decodeAnsi('^');
- decodeAnsi(*p == 0x7f ? '?' : (*p+0x40));
- }
- }
- }
- conPrint("\x1b[0K");
- }
- locate(40, 13);
- conPrint("Caution! Effects immediately");
- locate(40, 14);
- conPrint("Select by UP/DOWN key");
- locate(40, 15);
- conPrint("ESC for end, ENTER to edit");
- }
- #else
- void editKeyTable(){}
- #endif /* SETUP */
-
- /*
- ** char *loadSetup(char *path, int *flag)
- *
- * load setup file then re-initialize variables
- */
- char *loadSetup(path, flag)
- char *path;
- int *flag;
- {
- int fd;
- char *msg;
- struct setups *setups = (struct setups *)XFerBuffer;
-
- *flag = NO; /* as default, setup file will not be loaded */
- msg = (char *)NULL;
- if ((fd = open(path, O_RDONLY|O_BINARY)) < 0) {
- sprintf(buf, msg_cantOpen, path);
- return(buf);
- }
- if (read(fd, (char *)setups, sizeof(struct setups)) != sizeof(struct setups) ||
- strcmp(setups->ids, msg_setupID)) {
- close(fd);
- sprintf(buf, "'%s' is not hterm set-up.", path);
- return(buf);
- }
- if (setups->version != VERSION || setups->revision != REVISION || setups->edition != EDITION) {
- sprintf(buf, "set-up '%s' version mismatch", path);
- if (setups->version *1000 + setups->revision *100 +setups->edition*10 <
- 2530) {
- return(buf); /* incompatible set-up file */
- }
- *flag = YES; /* override flag, be careful! */
- msg = buf;
- }
-
- strcpy(phone, setups->phone);
- memcpy(tabTable, setups->tab, MAX_COLUMN);
- strcpy(defaultCommandLine, setups->defaultCommandLine);
- strcpy(fontName, setups->fontName);
-
- originMode = setups->val[ 0];
- formfeed = setups->val[ 1];
- if (mode == M_SETUP)
- cursorSave = setups->val[ 2];
- else
- cursor = setups->val[ 2];
- blinkCursor = setups->val[ 3];
- autoWrap = setups->val[ 4];
- if (mode == M_SETUP)
- intConSave = setups->val[ 5];
- else
- intControl = setups->val[ 5];
- echoMode = setups->val[ 6];
- #if 0
- statline = setups->val[ 7];
- #endif
- softFont = setups->val[ 8];
- clickFlag = setups->val[ 9];
- applKeypad = setups->val[10];
- newline = setups->val[11];
- asckey = setups->val[12];
- if (mode == M_SETUP)
- printMSave = setups->val[13];
- else
- printMode = setups->val[13];
- spacing = setups->val[14];
- online = setups->val[15];
- baudrate = setups->val[16];
- baud = setups->val[17];
- parity = setups->val[18];
- paritybit = setups->val[19];
- stopbit = setups->val[20];
- /* = setups->val[21]; */
- /* = setups->val[22]; */
- backQuote = setups->val[23];
- if (mode == M_SETUP)
- kanjiSave = setups->val[24];
- else
- kanjiCode = setups->val[24];
- blockCursor = setups->val[25];
- if (mode == M_SETUP)
- lineModeSave = setups->val[26];
- else
- lineMode = setups->val[26];
- xonXoff = setups->val[27];
- spaceTab = setups->val[28];
- saver = setups->val[29];
- bsDel = setups->val[30];
- dialStartup = setups->val[31];
- visibleBell = setups->val[32];
- applCursor = setups->val[33];
- shiftLock = setups->val[34];
- fepInvoke = setups->val[35];
- portNo = setups->val[36];
- mouseSpeed = setups->val[37];
- saverType = setups->val[38];
- loggingType = setups->val[39];
- upLoadType = setups->val[40];
- xmodemMode = setups->val[41];
- xmodemType = setups->val[42];
- xmodemLongP = setups->val[43];
- upLoadDelay = setups->val[44];
- bsKeyRatio = setups->val[45];
- dropER = setups->val[46];
- eraseAttr = setups->val[47];
- border = setups->val[48];
- attrib = setups->val[49];
-
- loadKey(fd);
- close(fd);
- return(msg);
- }
-
- #ifdef SETUP
- /*
- ** char *saveSetup(char *path)
- *
- * save variables in setup file
- */
- char *saveSetup(path)
- char *path;
- {
- int fd, i;
-
- struct setups *setups = (struct setups *)XFerBuffer;
-
- if ((fd = open(path, O_WRONLY|O_BINARY|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE)) < 0) {
- sprintf(buf, msg_cantOpen, path);
- return(buf);
- }
- sprintf(setups->hello, "hterm %d.%d.%d.%d setup", VERSION, REVISION, EDITION, LOCAL_EDITION);
- for (i = 0; i < 20; i++)
- setups->ids[i] = 0;
- strcpy(setups->ids, msg_setupID);
- setups->version = VERSION;
- setups->revision = REVISION;
- setups->edition = EDITION;
-
- strcpy(setups->phone, phone);
- memcpy(setups->tab, tabTable, MAX_COLUMN);
- strcpy(setups->defaultCommandLine, defaultCommandLine);
- strcpy(setups->fontName, fontName);
-
- for (i = 0; i < NUM_VALUE; i++)
- setups->val[i] = 0;
- setups->val[ 0] = originMode;
- setups->val[ 1] = formfeed;
- setups->val[ 2] = cursorSave;
- setups->val[ 3] = blinkCursor;
- setups->val[ 4] = autoWrap;
- setups->val[ 5] = intConSave;
- setups->val[ 6] = echoMode;
- setups->val[ 7] = 0; /* statline; */
- setups->val[ 8] = softFont;
- setups->val[ 9] = clickFlag;
- setups->val[10] = applKeypad;
- setups->val[11] = newline;
- setups->val[12] = asckey;
- setups->val[13] = printMSave;
- setups->val[14] = spacing;
- setups->val[15] = online;
- setups->val[16] = baudrate;
- setups->val[17] = baud;
- setups->val[18] = parity;
- setups->val[19] = paritybit;
- setups->val[20] = stopbit;
- setups->val[21] = 0;
- setups->val[22] = 0;
- setups->val[23] = backQuote;
- setups->val[24] = kanjiSave;
- setups->val[25] = blockCursor;
- setups->val[26] = lineMode;
- setups->val[27] = xonXoff;
- setups->val[28] = spaceTab;
- setups->val[29] = saver;
- setups->val[30] = bsDel;
- setups->val[31] = dialStartup;
- setups->val[32] = visibleBell;
- setups->val[33] = applCursor;
- setups->val[34] = shiftLock;
- setups->val[35] = fepInvoke;
- setups->val[36] = portNo;
- setups->val[37] = mouseSpeed;
- setups->val[38] = saverType;
- setups->val[39] = loggingType;
- setups->val[40] = upLoadType;
- setups->val[41] = xmodemMode;
- setups->val[42] = xmodemType;
- setups->val[43] = xmodemLongP;
- setups->val[44] = upLoadDelay;
- setups->val[45] = bsKeyRatio;
- setups->val[46] = dropER;
- setups->val[47] = eraseAttr;
- setups->val[48] = border;
- setups->val[49] = attrSave;
-
- if (write(fd, (char *)setups, sizeof(struct setups)) != sizeof(struct setups)) {
- close(fd);
- return("Warning: write fail");
- }
- saveKey(fd);
- close(fd);
- return(NULL);
- }
- #endif /* SETUP */
-
- /*
- ** void clearAllTabs()
- *
- * clear all tab stops
- */
- void clearAllTabs()
- {
- memset(tabTable, '\0', MAX_COLUMN);
- }
-
- /*
- ** void setTabs(int n)
- *
- * set 'n' tab stops
- */
- void setTabs(n)
- int n;
- {
- int i;
-
- clearAllTabs();
- for (i = n; i < MAX_COLUMN; i += n)
- tabTable[i] = 1;
- }
-
- #ifdef SETUP
- /*
- ** void editTabs()
- *
- * edit tab table
- */
- void editTabs()
- {
- int end = 0;
- u_short key;
- int x, y;
-
- helpSystem("edit tab");
- reverseMode();
- cursor = YES;
- cursorOnOff(YES);
- x = 0;
- y = SETUP_LINE+6;
- while (!end) {
- locate(x, y);
- while ((int)(key = keyin()) == (-1))
- ;
- if (key == TAB) {
- if (++x > LAST_COLUMN) {
- x = LAST_COLUMN;
- } else {
- while (x < LAST_COLUMN && !tabTable[x])
- x++;
- }
- } else if (key == RIGHT_KEY || key == bindTab[C_RIGHT] ||
- key == 'l' || key == CTRL('L')) {
- if (++x > LAST_COLUMN) x = LAST_COLUMN;
- } else if (key == LEFT_KEY || key == 'H' || key == bindTab[C_LEFT] ||
- key == BS || key == DEL) {
- if (--x < 0) x = 0;
- } else if (key == 't' || key == 'T' || key == CR) {
- conWrite('T');
- tabTable[x] = 1;
- if (++x > LAST_COLUMN) x = LAST_COLUMN;
- } else if (key == ' ') {
- conWrite(' ');
- tabTable[x] = 0;
- if (++x > LAST_COLUMN) x = LAST_COLUMN;
- } else if (key == bindTab[C_TOL] || key == HOME_KEY) {
- x = 0;
- } else if (key == bindTab[C_EOL] || key == END_KEY) {
- x = LAST_COLUMN;
- } else if (key == UP_KEY || key == DOWN_KEY) {; /* just ignore */
- } else if (key == ESC) {
- end = 1;
- } else {
- bell();
- }
- }
- clearCopyright();
- cursor = NO;
- cursorOnOff(NO);
- }
-
- /*
- ** void dispTabs()
- *
- * display tab stops
- */
- void dispTabs()
- {
- int i, j, attrSave2 = attrib;
- int rev = YES;
-
- normalMode(); /* reset attribute */
- reverseMode(); /* reverse attribute */
- locate(0, SETUP_LINE+7);
- for (i = MAX_COLUMN/10; i > 0; --i) {
- for (j = 1; j <= 10; j++)
- conWrite(j == 10 ? '0' : ('0'+j));
- rev = !rev;
- if (rev)
- reverseMode();
- else
- normalMode();
- }
- reverseMode();
- locate(0, SETUP_LINE+6);
- for (i = 0; i < MAX_COLUMN; i++)
- conWrite(tabTable[i] ? 'T' : SPACE);
- attrib = attrSave2;
- }
- #else
- void dispTabs(){}
- void editTabs(){}
- #endif /* SETUP */
- /*
- ** void toSlash()
- *
- * convert 'abc\def' pathlist to 'abc/def' pathlist
- *
- */
- void toSlash(p)
- register char *p;
- {
- for (; *p; p++)
- if (*p == '\\')
- *p = '/';
- }
-