📄 termout.c
字号:
} else { \ standend(); \ } \ if (IsNonDisplayAttr(a)) { \ a = 0; /* zero == don't display */ \ } \ if (!FormattedScreen()) { \ a = 1; /* one ==> do display on unformatted */\ } ScreenImage *p, *upper; int fieldattr; /* spends most of its time == 0 or 1 *//* OK. We want to do this a quickly as possible. So, we assume we * only need to go from Lowest to Highest. However, if we find a * field in the middle, we do the whole screen. * * In particular, we separate out the two cases from the beginning. */ if ((Highest != HighestScreen()) || (Lowest != LowestScreen())) { register int columnsleft; move(ScreenLine(Lowest), ScreenLineOffset(Lowest)); p = &Host[Lowest];#if !defined(MSDOS) if (Highest == HighestScreen()) { Highest = ScreenDec(Highest); }#endif /* !defined(MSDOS) */ upper = &Host[Highest]; fieldattr = FieldAttributes(Lowest); DoAttribute(fieldattr); /* Set standout, non-display status */ columnsleft = NumberColumns-ScreenLineOffset(p-Host); while (p <= upper) { if (IsStartFieldPointer(p)) { /* New field? */ Highest = HighestScreen(); Lowest = LowestScreen(); FastScreen(); /* Recurse */ return; } else if (fieldattr) { /* Should we display? */ /* Display translated data */ addch((char)disp_asc[GetTerminalPointer(p)]); } else { addch(' '); /* Display a blank */ } /* If the physical screen is larger than what we * are using, we need to make sure that each line * starts at the beginning of the line. Otherwise, * we will just string all the lines together. */ p++; if (--columnsleft == 0) { int i = p-Host; move(ScreenLine(i), 0); columnsleft = NumberColumns; } } } else { /* Going from Lowest to Highest */ unsigned char tmpbuf[MAXNUMBERCOLUMNS+1]; ScreenImage *End = &Host[ScreenSize]-1-SaveCorner; register unsigned char *tmp = tmpbuf, *tmpend = tmpbuf+NumberColumns; *tmpend = 0; /* terminate from the beginning */ move(0,0); p = Host; fieldattr = FieldAttributes(LowestScreen()); DoAttribute(fieldattr); /* Set standout, non-display status */ while (p <= End) { if (IsStartFieldPointer(p)) { /* New field? */ if (tmp != tmpbuf) { *tmp++ = 0; /* close out */ addstr((char *)tmpbuf); tmp = tmpbuf; tmpend = tmpbuf+NumberColumns-ScreenLineOffset(p-Host)-1; } standend(); addch(' '); fieldattr = FieldAttributesPointer(p); /* Get attributes */ DoAttribute(fieldattr); /* Set standout, non-display */ } else { if (fieldattr) { /* Should we display? */ /* Display translated data */ *tmp++ = disp_asc[GetTerminalPointer(p)]; } else { *tmp++ = ' '; } } /* If the physical screen is larger than what we * are using, we need to make sure that each line * starts at the beginning of the line. Otherwise, * we will just string all the lines together. */ p++; if (tmp == tmpend) { int i = p-Host; /* Be sure the "p++" happened first! */ *tmp++ = 0; addstr((char *)tmpbuf); tmp = tmpbuf; move(ScreenLine(i), 0); tmpend = tmpbuf + NumberColumns; } } if (tmp != tmpbuf) { *tmp++ = 0; addstr((char *)tmpbuf); tmp = tmpbuf; } } Lowest = HighestScreen()+1; Highest = LowestScreen()-1; terminalCursorAddress = CorrectTerminalCursor(); if (ERR == move(ScreenLine(terminalCursorAddress), ScreenLineOffset(terminalCursorAddress))) { GoAway("move", terminalCursorAddress); } DoARefresh(); if (needToRing) { StringToTerminal(bellSequence); needToRing = 0; } EmptyTerminal(); /* move data along */ return;}/* TryToSend - send data out to user's terminal */#if defined(NOT43)int#else /* defined(NOT43) */void#endif /* defined(NOT43) */ (*TryToSend)() = FastScreen;/*ARGSUSED*/voidScreenOIA(oia)OIA *oia;{}/* InitTerminal - called to initialize the screen, etc. */voidInitTerminal(){#if defined(unix) struct sgttyb ourttyb; static int speeds[] = { 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600 };#endif extern void InitMapping(); InitMapping(); /* Go do mapping file (MAP3270) first */ if (!screenInitd) { /* not initialized */#if defined(unix) char KSEbuffer[2050]; char *lotsofspace = KSEbuffer; extern void abort(); extern char *tgetstr();#endif /* defined(unix) */ if (initscr() == ERR) { /* Initialize curses to get line size */ ExitString("InitTerminal: Error initializing curses", 1); /*NOTREACHED*/ } MaxNumberLines = LINES; MaxNumberColumns = COLS; ClearArray(Terminal); terminalCursorAddress = SetBufferAddress(0,0);#if defined(unix) signal(SIGHUP, abort);#endif TryToSend = FastScreen;#if defined(unix) ioctl(1, TIOCGETP, (char *) &ourttyb); if ((ourttyb.sg_ospeed < 0) || (ourttyb.sg_ospeed > B9600)) { max_changes_before_poll = 1920; } else { max_changes_before_poll = speeds[ourttyb.sg_ospeed]/10; if (max_changes_before_poll < 40) { max_changes_before_poll = 40; } TryToSend = SlowScreen; HaveInput = 1; /* get signals going */ }#endif /* defined(unix) */ setcommandmode(); /* * By now, initscr() (in curses) has been called (from telnet.c), * and the screen has been initialized. */#if defined(unix) nonl(); /* the problem is that curses catches SIGTSTP to * be nice, but it messes us up. */ signal(SIGTSTP, SIG_DFL); if ((myKS = tgetstr("ks", &lotsofspace)) != 0) { myKS = strsave(myKS); StringToTerminal(myKS); } if ((myKE = tgetstr("ke", &lotsofspace)) != 0) { myKE = strsave(myKE); } if (tgetstr("md", &lotsofspace) && tgetstr("me", &lotsofspace)) { SO = strsave(tgetstr("md", &lotsofspace)); SE = strsave(tgetstr("me", &lotsofspace)); }#endif DoARefresh(); setconnmode(); if (VB && *VB) { bellSequence = VB; /* use visual bell */ } screenInitd = 1; screenStopped = 0; /* Not stopped */ }}/* StopScreen - called when we are going away... */voidStopScreen(doNewLine)int doNewLine;{ if (screenInitd && !screenStopped) { move(NumberLines-1, 1); standend(); inHighlightMode = 0; DoARefresh(); setcommandmode(); endwin(); setconnmode();#if defined(unix) if (myKE) { StringToTerminal(myKE); }#endif /* defined(unix) */ if (doNewLine) { StringToTerminal("\r\n"); } EmptyTerminal(); screenStopped = 1; /* This is stopped */ }}/* RefreshScreen - called to cause the screen to be refreshed */voidRefreshScreen(){ clearok(curscr, TRUE); (*TryToSend)();}/* ConnectScreen - called to reconnect to the screen */voidConnectScreen(){ if (screenInitd) {#if defined(unix) if (myKS) { StringToTerminal(myKS); }#endif /* defined(unix) */ RefreshScreen(); (*TryToSend)(); screenStopped = 0; }}/* LocalClearScreen() - clear the whole ball of wax, cheaply */voidLocalClearScreen(){ extern void Clear3270(); outputPurge(); /* flush all data to terminal */ clear(); /* clear in curses */ ClearArray(Terminal); Clear3270(); Lowest = HighestScreen()+1; /* everything in sync... */ Highest = LowestScreen()+1;}voidBellOff(){ if (bellwinup) { delwin(bellwin); bellwin = 0; bellwinup = 0; touchwin(stdscr); DoARefresh(); }}voidRingBell(s)char *s;{ needToRing = 1; if (s) { int len = strlen(s); if (len > COLS-2) { len = COLS-2; } if ((bellwin = newwin(3, len+2, LINES/2, 0)) == NULL) { OurExitString("Error from newwin in RingBell", 1); } werase(bellwin); wstandout(bellwin); box(bellwin, '|', '-'); if (wmove(bellwin, 1, 1) == ERR) { OurExitString("Error from wmove in RingBell", 1); } while (len--) { if (waddch(bellwin, *s++) == ERR) { OurExitString("Error from waddch in RingBell", 1); } } wstandend(bellwin); if (wrefresh(bellwin) == ERR) { OurExitString("Error from wrefresh in RingBell", 1); } bellwinup = 1; }}/* returns a 1 if no more output available (so, go ahead and block), or a 0 if there is more output available (so, just poll the other sources/destinations, don't block). */intDoTerminalOutput(){ /* called just before a select to conserve IO to terminal */ if (!(screenInitd||screenStopped)) { return 1; /* No output if not initialized */ } if ((Lowest <= Highest) || needToRing || (terminalCursorAddress != CorrectTerminalCursor())) { (*TryToSend)(); } if (Lowest > Highest) { return 1; /* no more output now */ } else { return 0; /* more output for future */ }}/* * The following are defined to handle transparent data. */voidTransStop(){#if defined(unix) if (tcflag == 0) { tcflag = -1; (void) signal(SIGCHLD, SIG_DFL); } else if (tcflag > 0) { setcommandmode(); (void) close(tin); (void) close(tout); tin = savefd[0]; tout = savefd[1]; setconnmode(); tcflag = -1; (void) signal(SIGCHLD, SIG_DFL); }#endif /* defined(unix) */ RefreshScreen();}voidTransOut(buffer, count, kind, control)unsigned char *buffer;int count;int kind; /* 0 or 5 */int control; /* To see if we are done */{#if defined(unix) extern char *transcom; int inpipefd[2], outpipefd[2]; static void aborttc();#endif /* defined(unix) */ while (DoTerminalOutput() == 0) {#if defined(unix) HaveInput = 0;#endif /* defined(unix) */ }#if defined(unix) if (transcom && tcflag == -1) { while (1) { /* go thru once */ if (pipe(outpipefd) < 0) { break; } if (pipe(inpipefd) < 0) { break; } if ((tcflag = fork()) == 0) { (void) close(outpipefd[1]); (void) close(0); if (dup(outpipefd[0]) < 0) { exit(1); } (void) close(outpipefd[0]); (void) close(inpipefd[0]); (void) close(1); if (dup(inpipefd[1]) < 0) { exit(1); } (void) close(inpipefd[1]); if (execl("/bin/csh", "csh", "-c", transcom, (char *) 0)) { exit(1); } } (void) close(inpipefd[1]); (void) close(outpipefd[0]); savefd[0] = tin; savefd[1] = tout; setcommandmode(); tin = inpipefd[0]; tout = outpipefd[1]; (void) signal(SIGCHLD, aborttc); setconnmode(); tcflag = 1; break; } if (tcflag < 1) { tcflag = 0; } }#endif /* defined(unix) */ (void) DataToTerminal((char *)buffer, count); if (control && (kind == 0)) { /* Send in AID byte */ SendToIBM(); } else { extern void TransInput(); TransInput(1, kind); /* Go get some data */ }}#if defined(unix)static voidaborttc(signo) int signo;{ setcommandmode(); (void) close(tin); (void) close(tout); tin = savefd[0]; tout = savefd[1]; setconnmode(); tcflag = 0;}#endif /* defined(unix) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -