/* ** WizTerm - Terminal program for BL ** ** C. Smotricz, 22 Aug 93 */ /*====================*/ /*===== Includes =====*/ /*====================*/ #include #include #include #include #include #include #include #include "wt.h" #include "wtbuf.h" #include "wtcfg.h" #include "wtclk.h" #include "wtcom.h" #include "wtkbd.h" #include "wtlog.h" #include "wtppn.h" #include "wtsta.h" #include "wtwin.h" /*=====================*/ /*===== Variables =====*/ /*=====================*/ char *progname = PROGVERS; /* Program name & version */ int com_idle = 0; int quitting = 0; int watching = 0; int winsplit = 0; /***************************/ /* */ /* Beep: sound the speaker */ /* */ /***************************/ void beep(void) { #ifdef __TURBOC__ sound(1000); delay(250); nosound(); #else putch('\a'); #endif } /* end beep() */ /********************************************/ /* */ /* ctrl_c(): handle (ignore) control-break */ /* */ /********************************************/ #ifdef __TURBOC__ int ctrl_c(void) { return 1; } /* end ctrl_c() */ #endif /*************************************/ /* */ /* display(): show recent chars. */ /* */ /*************************************/ void display(char *txt, int cr) { static int after_cr = 1; static int watch_wdo = WIN_LEFT; if (after_cr && txt[0] == '|') { watch_wdo = WIN_RITE; } win_select(watch_wdo); win_puts(txt); if (cr) { win_puts("\r\n"); } win_select(WIN_MAIN); win_puts(txt); if (cr) { win_puts("\r\n"); after_cr = 1; watch_wdo = WIN_LEFT; } else { after_cr = 0; } log_write(txt, cr); buf_write(txt, cr); } /* end display() */ /**********************************************/ /* set_winsplit(): Set the winsplit on or off */ /**********************************************/ void set_winsplit(int on_off) { if (on_off != winsplit) { if (on_off) { win_select(WIN_LEFT); win_show(); win_select(WIN_RITE); win_show(); } else { win_select(WIN_LEFT); win_hide(); win_select(WIN_RITE); win_hide(); } winsplit = on_off; } } /* end set_winsplit() */ /***********************************************/ /* set_watching(): Set WATCHING mode on or off */ /***********************************************/ void set_watching(int on_off) { /*** -1 --> toggle watch state ***/ if (on_off == -1) { on_off = 1 - watching; } /*** if state change, swap windows ***/ if (!watching && on_off) { set_winsplit(1); watching = 1; } else if (watching && !on_off) { set_winsplit(0); watching = 0; } } /* end set_watching() */ /****************************/ /* ===== Main Routine ===== */ /****************************/ int main( /* int argc, char *argv[] */ ) { int jw; /* --- Initialize windows --- */ (void) win_init(); /* --- Default window setup --- */ win_open(WIN_STAT, 0, 0, DPY_COLS, 1, MK_ATT(BLACK,MAGENTA)); win_clear(); win_show(); win_open(WIN_FKEY, 0, DPY_ROWS-2, DPY_COLS, 2, MK_ATT(WHITE,BLACK)); win_clear(); win_show(); win_open(WIN_INPT, 0, DPY_ROWS-3, DPY_COLS, 1, MK_ATT(WHITE,BLUE)); win_cursor(1); win_clear(); win_show(); win_open(WIN_MAIN, 0, 1, DPY_COLS, DPY_ROWS-4, MK_ATT(BLACK,CYAN)); win_clear(); win_puts(PROGVERS); win_show(); win_open(WIN_LEFT, 0, 1, DPY_COLS/2, DPY_ROWS-4, MK_ATT(BLACK,CYAN)); win_clear(); win_open(WIN_RITE, DPY_COLS/2, 1, DPY_COLS/2, DPY_ROWS-4, MK_ATT(BLACK,LIGHTGRAY)); win_clear(); win_open(WIN_BACK, 0, 1, DPY_COLS, 10, MK_ATT(WHITE,BLACK)); win_clear(); buf_setheight(10); win_open(WIN_PPNS, DPY_COLS-42, 1, 42, DPY_ROWS-4, MK_ATT(PPN_FG,PPN_BG)); win_clear(); /* --- Initialize buffer --- */ buf_init(); /* --- Read configuration file --- */ display("", 1); display("Configuration:", 1); display("--------------", 1); cfg_load("WTSTART.WTS"); display("--------------", 1); /* --- Set up serial interface --- */ com_init(); /* --- install ctrl_c handler --- */ #ifdef __TURBOC__ ctrlbrk(ctrl_c); #endif /* --- Initialize clock --- */ clk_init(); /* --- Initialize status --- */ sta_init(); /* --- Initialize keyboard --- */ kbd_init(); /* --- Open log file --- */ log_init(); /* --- Initialize PPN manager --- */ ppn_init(); /* ===== Main processing loop ===== */ com_idle = 0; while (! quitting) { /* --- Check for modem input --- */ if (com_update()) { com_idle = 0; continue; } /* --- Check for user input --- */ kbd_update(); /* --- Check for timer update --- */ com_idle += clk_update(); } /* end while 1 */ /* --- Close buffers --- */ (void) buf_term(); /* --- Save configuration --- */ (void) cfg_save(); /* --- Close windows --- */ for (jw=WIN_NUMB-1; jw>WIN_DOSW; jw--) { win_select(jw); win_hide(); } /* --- Close PPN file --- */ ppn_exi(); /* --- Close log file --- */ /* Since 3.03, this has the side effect of SYSTEM()'ing WIZPPN */ log_term(); return 0; } /* end main() */