home *** CD-ROM | disk | FTP | other *** search
- /* -*- JOKE -*-
- *
- ** hemacs.c: simple emacs like japanese file viewer or editor
- *
- * Author: HIRANO Satoshi
- *
- * (C) 1986 Halca Computer Science Laboratory UEC TM
- * University of Electro Communications
- * University of Tokyo
- *
- *
- * Edition history:
- * 1.1 90/07/01 Halca.Hirano converted from hterm
- */
-
- static char version[] = "$Header: hemacs.cv 1.1 90/07/04 00:50:40 hirano Exp $";
-
- #include "option.h"
- #include <stdio.h>
- #include <ctype.h>
- #include <time.h>
- #include <string.h>
- #include <stdlib.h>
- #define MAIN 1
- #include "config.h"
- #include "hterm.h"
- #include "default.h"
- #include "global.h"
- #include "version.h"
-
- /*
- ** messages
- */
- char *helpmsg = "\
- Function: Japanese file viewer\n\
- Syntax: hemacs [options] file\n\
- Options:\n\
- -f[fontfile] specify font file\n\
- ";
-
- char *targetFile = 0;
-
- void initialize(void );
- void termination(void );
- void endAll(void );
- void options(int argc,char * *argv);
- void cant(void );
-
- /*
- ** main()
- *
- * hterm main loop
- */
- main(argc, argv)
- char **argv;
- {
- FILE *fp;
-
- hemacs = YES;
- optAsckey = -1;
- options(argc, argv); /* get option flags */
- if (targetFile == 0) {
- cant();
- exit(1);
- }
- if ((fp = fopen(targetFile, "r")) == NULL) {
- cant();
- fprintf(stderr, "can't open file %s\n", targetFile);
- exit(1);
- }
-
- initialize();
-
- #ifndef SOFT_FONT
- conPrint("Soft font not configured.\r\n");
- conPrint("Remake hterm with soft font.\r\n");
- #endif
-
- loadFile(fp);
- fclose(fp);
-
- /*
- * call editor
- */
- historyEditor();
-
- termination();
- }
-
- static void initialize()
- {
- char *path, *diag2 = 0;
-
- /*
- * now we are in communication mode
- */
- mode = M_COMM;
- /*
- * DON'T USE BEEP(), BELL()
- */
- editInit(); /* iniz copy&paste, history */
- consoleInit(); /* iniz console */
- fontInit(); /* iniz soft font */
- ansiInit();
- saverInit();
-
- /*
- * Now, we can't leave without termination()!
- */
-
- /*
- * We can use beep(), bell()
- */
- keyInit(); /* iniz keyboard mode */
-
- /*
- * search hterm help file hterm.db
- */
- if ((path = searchPath(HELP_FILE)) == NULL)
- strcpy(helpFileName, HELP_FILE);
- else
- strcpy(helpFileName, path);
-
-
- /*
- * set overridden option
- */
- #ifdef SOFT_FONT
- softFont = YES;
- #endif
- if (optAsckey != -1)
- asckey = optAsckey;
-
- #ifdef SOFT_FONT
- fprintf(stderr, "\nloading font %s ...", fontName); fflush(stderr);
- diag2 = fontLoad(fontName); /* load soft font */
- if (diag2) {
- endAll();
- fprintf(stderr, diag2);
- exit(1);
- }
- #endif
-
- consoleSetup(); /* setup console */
- keySetup(); /* setup keyboard mode */
- fileSetup(); /* setup file utils */
- ansiSetup();
-
- }
-
- void termination()
- {
- endAll();
- printf("\nhemacs end\n");
- exit(0);
- }
-
- void endAll()
- {
- fileEnd();
- consoleEnd();
- keyEnd();
- editEnd();
- fontEnd();
- saverEnd();
- }
-
- /*
- ** static void options(int argc, char **argv)
- *
- * parse command line options
- */
- void options(argc, argv)
- char **argv;
- {
- register char *p;
-
- nextopt:
- while (--argc > 0)
- if (*(p = *++argv) == '-')
- for (++p; *p; p++)
- switch(tolower(*p)) {
- #ifdef PC98
- case 'a': optAsckey = YES; break;
- case 'p': optAsckey = NO; break;
- #endif /* PC98 */
- case 'f':
- if (*++p)
- strcpy(fontName, p);
- goto nextopt;
- case 'h':
- case '?': cant(); exit(0);
- default: cant();
- fprintf(stderr, "unknown option '%c'.\n", *p);
- exit(1);
- }
- else {
- targetFile = *argv;
- }
- }
-
- /*
- ** cant()
- *
- * print version string and invocation options
- */
- static void cant()
- {
- fprintf(stderr, helpmsg);
- }
-
- /*
- ** u_short SJIStoJIS(byte_1, byte_2)
- *
- * convert SJIS to JIS
- */
- u_short SJIStoJIS(byte_1, byte_2)
- register u_short byte_1, byte_2;
- {
- u_short c;
-
- byte_1 -= (byte_1 >= 0xa0) ? 0xc1 : 0x81;
- if (byte_2 >= 0x9f) {
- c = (byte_1 << 9) + 0x2200;
- c |= byte_2 - 0x7e;
- } else {
- c = (byte_1 << 9) + 0x2100;
- c |= byte_2 - ((byte_2 <= 0x7e) ? 0x1f : 0x20);
- }
- return(c);
- }
-
- /*
- ** u_short JIStoSJIS(h, l)
- *
- * convert JIS to SJIS
- */
- u_short JIStoSJIS(h, l)
- register u_char h, l;
- {
- if (!(h & 1)) l += (0x7f - 0x21);
- l += (0x40 - 0x21);
- if (l >= 0x7f) ++l;
- h -= 0x21;
- h >>= 1; /* h /= 2; */
- h += 0x81;
- if (h > 0x9f) h += (0xe0 - 0xa0);
- return((h<<8)|l);
- }
-
- /*
- * stabs
- */
- void outPrinter(u_short c){}
- void plot_space(){}
- void plot_point(){}
- void plot_cont(){}
- void plot_move(){}
- void plot_label(){}
- void plot_erase(){}
- void plot_colormod(){}
- void plot_linemod(){}
- void plot_circle(){}
- void plot_arc(){}
- void plot_boxfill(){}
- void plot_box(){}
- void plot_line(){}
- void outESC(char *str){}
- void nullFunction(){}
- void sendBreak(int shortLong){}
- void icoSaver(){}
- void portSetup(){}
- void portReInit(){}
- void portEnd(){}
- void printOn(){}
-
- short portAddress;
- char offMask;
- char onMask;
-