void pico_toggle_color(int on) { if(on){ if(pico_hascolor()) _using_color = 1; } else{ _using_color = 0; if(_color_inited){ _color_inited = 0; if(!panicking()) free_color_table(&color_tbl); if(ANSI_COLOR()) putpad("\033[39;49m"); else{ if(_op) putpad(_op); if(_oc) putpad(_oc); } } } }
static void tcapclose(void) { putpad(tgoto(CM, 0, term.t_nrow)); putpad(TE); tioflush(); tiorestore(); }
/* * Start or end underline mode * * Result: escape sequence to go into or out of underline is output * * Arg state = ON set underline * OFF set normal */ void flip_ul(int state) { extern char *_setunderline, *_clearunderline; if((pulstate = state) == TRUE){ if(_setunderline != NULL) putpad(_setunderline); } else{ /* * Unfortunately, some termcap entries configure end underline to * be clear all attributes. */ if(_clearunderline != NULL){ if(!color_blasted_by_attrs) color_blasted_by_attrs = pico_get_cur_color(); _force_fg_color_change = _force_bg_color_change = 1; putpad(_clearunderline); pboldstate = (pboldstate == FALSE) ? pboldstate : A_UNKNOWN; pinvstate = (pinvstate == FALSE) ? pinvstate : A_UNKNOWN; rev_color_state = A_UNKNOWN; } } }
/* * Delete nchunk line(s) from "row", replacing the * bottom line on the screen with a blank line. * Unless we're using the scrolling region, this is * done with a crafty sequences of insert and delete * lines. The presence of the echo area makes a * boundry condition go away. */ ttdell(row, bot, nchunk) { register int i, nl; if (row == bot) { /* One line special case */ ttmove(row, 0); tteeol(); return; } if (CS) { /* scrolling region */ nl = bot - row; ttwindow(row, bot); ttmove(bot, 0); while (nchunk--) putpad(SF, nl); ttnowindow(); } else if(insdel) { ttmove(row, 0); /* Else use insert/delete line */ nl = nrow - ttrow; if (pDL) putpad(tgoto(pDL, 0, nchunk), nl); else for (i=0; i<nchunk; i++) /* For all lines in the chunk */ putpad(DL, nl); ttmove(1+bot-nchunk,0); nl = nrow - ttrow; /* ttmove() changes ttrow */ if (pAL) putpad(tgoto(pAL, 0, nchunk), nl); else for (i=0; i<nchunk; i++) /* For all lines in the chunk */ putpad(AL, nl); ttrow = HUGE; ttcol = HUGE; } else panic("ttdell: Can't insert/delete line"); }
/* * Insert nchunk blank line(s) onto the * screen, scrolling the last line on the * screen off the bottom. Use the scrolling * region if possible for a smoother display. * If no scrolling region, use a set * of insert and delete line sequences */ ttinsl(row, bot, nchunk) { register int i, nl; if (row == bot) { /* Case of one line insert is */ ttmove(row, 0); /* special */ tteeol(); return; } if (CS && SR) { /* Use scroll region and back index */ nl = bot - row; ttwindow(row,bot); ttmove(row, 0); while (nchunk--) putpad(SR, nl); ttnowindow(); return; } else if (insdel) { ttmove(1+bot-nchunk, 0); nl = nrow - ttrow; if (pDL) putpad(tgoto(pDL, 0, nchunk), nl); else for (i=0; i<nchunk; i++) /* For all lines in the chunk */ putpad(DL, nl); ttmove(row, 0); nl = nrow - ttrow; /* ttmove() changes ttrow */ if (pAL) putpad(tgoto(pAL, 0, nchunk), nl); else for (i=0; i<nchunk; i++) /* For all lines in the chunk */ putpad(AL, nl); ttrow = HUGE; ttcol = HUGE; } else panic("ttinsl: Can't insert/delete line"); }
/* actions associated with putting the terminal in open mode */ void tostart(void) { putpad(VS); putpad(KS); if (!value(MESG)) { if (ttynbuf[0] == 0) { register char *tn; if ((tn=ttyname(2)) == NULL && (tn=ttyname(1)) == NULL && (tn=ttyname(0)) == NULL) ttynbuf[0] = 1; else safecp(ttynbuf, tn, sizeof ttynbuf, "%s too long", tn); } if (ttynbuf[0] != 1) { struct stat sbuf; stat(ttynbuf, &sbuf); ttymesg = sbuf.st_mode & 0777; chmod(ttynbuf, #ifdef UCBV7 /* * This applies to the UCB V7 Pdp-11 system with the * -u write option only. */ 0611 /* 11 = urgent only allowed */ #else 0600 #endif ); } } }
/* * NOTE: * On Linux console, the 'me' termcap setting \E[m resets _all_ attributes, * including color. However, if we use 'se' instead, it doesn't clear the * boldface. To compensate, we reset the colors when we put out any "ending" * sequence, such as 'me'. * * In rxvt (2.12), setting _any_ attribute seems to clobber the color settings. */ static void tcapattr(int attr) { static const struct { char **start; char **end; int mask; } tbl[] = { { &SO, &SE, VASEL|VAREV }, { &US, &UE, VAUL }, { &US, &UE, VAITAL }, { &MD, &ME, VABOLD }, }; static int last; attr = VATTRIB(attr); /* FIXME: color? */ attr &= ~(VAML|VAMLFOC); if (attr != last) { register int n; register char *s; int diff = attr ^ last; int ends = FALSE; /* turn OFF old attributes */ for (n = 0; n < TABLESIZE(tbl); n++) { if ((tbl[n].mask & diff) != 0 && (tbl[n].mask & attr) == 0 && (s = *(tbl[n].end)) != 0) { putpad(s); #if OPT_COLOR reinitialize_colors(); #endif ends = TRUE; diff &= ~(tbl[n].mask); } } /* turn ON new attributes */ for (n = 0; n < TABLESIZE(tbl); n++) { if ((tbl[n].mask & diff) != 0 && (tbl[n].mask & attr) != 0 && (s = *(tbl[n].start)) != 0) { putpad(s); diff &= ~(tbl[n].mask); } } if (SO != 0 && SE != 0) { if (ends && (attr & (VAREV|VASEL))) { putpad(SO); } else if (diff) { /* we didn't find it */ putpad(SE); } } last = attr; } }
/* Actions associated with putting the terminal in the right mode. */ void tostop(void) { putpad(VE); putpad(KE); if (!value(MESG) && ttynbuf[0]>1) chmod(ttynbuf, ttymesg); }
static void tcaprev(int state) { if (state) { if (SO != NULL) putpad(SO); } else if (SE != NULL) putpad(SE); }
/* * restore terminal to normal mode (upon exit, for shell escapes). */ ttyrestore() { putpad(tgoto(CM, 0, LINES-1)); /* go to lower left corner */ putpad(KE); putpad(TE); ttybuf = ottybuf; ioctl(2, TIOCSETN, &ttybuf); }
void dingdong(void) { if (flash_screen && value(vi_FLASH)) putpad((unsigned char *)flash_screen); else if (value(vi_ERRORBELLS)) putpad((unsigned char *)bell); }
/* * Clean up the terminal, in anticipation of * a return to the command interpreter. This is a no-op * on the ANSI display. On the SCALD display, it sets the * window back to half screen scrolling. Perhaps it should * query the display for the increment, and put it * back to what it was. */ tttidy() { #ifndef TCCONIO if (TE && *TE) putpad(TE, 1); /* set the term back to normal mode */ putpad(tgoto(CM, 0, ttrow), 1); /* not nrow */ if (CE && *CE) putpad(CE, 1); /* erase one line */ # ifdef XKEYS ttykeymaptidy(); # endif #endif /* TCCONIO */ }
/* * tinfodelete - delete a character at the current character position. */ static void tinfodelete(void) { if(_startdelete == NULL && _enddelete == NULL) putpad(_deletechar); else{ putpad(_startdelete); putpad(_deletechar); putpad(_enddelete); } }
/* * tinfoinsert - insert a character at the current character position. * _insertchar takes precedence. */ static void tinfoinsert(UCS ch) { if(_insertchar != NULL){ putpad(_insertchar); ttputc(ch); } else{ putpad(_startinsert); ttputc(ch); putpad(_endinsert); } }
/* * put terminal into screen mode. */ ttyinit() { gtty(2, &ttybuf); UPPERCASE = (ttybuf.sg_flags & LCASE) != 0; HASTABS = (ttybuf.sg_flags & XTABS) != 0; NONL = (ttybuf.sg_flags & CRMOD) == 0; ottybuf = ttybuf; ttybuf.sg_flags &= ~(ECHO|CRMOD); ttybuf.sg_flags |= CBREAK; ioctl(2, TIOCSETN, &ttybuf); /* or stty */ putpad(TI); putpad(KS); /* only needed if you use keypad */ }
/* * Set the current writing color to the specified color. Watch for color * changes that are not going to do anything (the color is already right) * and don't send anything to the display. The rainbow version does this * in putline.s on a line by line basis, so don't bother sending out the * color shift. */ void ttcolor(int color) { if (color != tthue) { if (color == CTEXT) /* normal video */ putpad(exit_standout_mode, 1); else if (color == CMODE) /* reverse video */ putpad(enter_standout_mode, 1); /* save the color */ tthue = color; } }
/* * Erase to end of page. */ tteeop() { if(CD) putpad(CD, nrow - ttrow); else { putpad(CE, 1); if (insdel) ttdell(ttrow + 1, LI, LI - ttrow - 1); else { /* do it by hand */ register int line; for (line = ttrow + 1; line <= LI; ++line) { ttmove(line, 0); tteeol(); } } ttrow = ttcol = HUGE; } }
static void tcapkopen(void) { #if OPT_XTERM if (i_am_xterm && global_g_val(GMDXTERM_MOUSE)) putpad(XTERM_ENABLE_TRACKING); #endif if (!keyboard_open) { keyboard_open = TRUE; if (TI) putnpad(TI, (int)strlen(TI)); if (KS) putpad(KS); } (void)strcpy(sres, "NORMAL"); }
static void tcapkclose(void) { #if OPT_XTERM if (i_am_xterm && global_g_val(GMDXTERM_MOUSE)) putpad(XTERM_DISABLE_TRACKING); #endif if (keyboard_open) { keyboard_open = FALSE; if (TE) putnpad(TE, (int)strlen(TE)); if (KE) putpad(KE); } TTflush(); }
/* * Set the current writing color to the * specified color. Watch for color changes that are * not going to do anything (the color is already right) * and don't send anything to the display. * The rainbow version does this in putline.s on a * line by line basis, so don't bother sending * out the color shift. */ void ttcolor (int color) { if (color != tthue) { if (color == CTEXT) { /* Normal video. */ putpad (SE); } else if (color == CMODE) { /* Reverse video. */ putpad (SO); } tthue = color; /* Save the color. */ } }
static void tcaprev( /* change reverse video status */ int state) /* FALSE = normal video, TRUE = reverse video */ { static int revstate = -1; if (state == revstate) return; revstate = state; if (state) { if (SO != NULL) putpad(SO); } else { if (SE != NULL) putpad(SE); } }
/* * Erase to end of page. */ tteeop() { #ifdef TCCONIO ttflush(); clreol(); { register int line; for (line = ttrow + 1; line <= nrow; ++line) { gotoxy(1,line+1); clreol(); } ttrow = ttcol = HUGE; } #else if(CD) putpad(CD, nrow - ttrow); else { tteeol(); if (insdel) ttdell(ttrow + 1, LI, LI - ttrow - 1); else /* do it by hand */ { register int line; for (line = ttrow + 1; line <= LI; ++line) { ttmove(line, 0); tteeol(); } } ttrow = ttcol = HUGE; } #endif }
static void tcapkclose(void) { #if PKCODE putpad(TE); ttflush(); #endif }
static int tinfoeeop(void) { int i, starting_col, starting_row; /* * If the terminal doesn't have back color erase, then we have to * erase manually to preserve the background color. */ if(pico_usingcolor() && (!_bce || !_cleartoeos)){ extern int ttcol, ttrow; starting_col = ttcol; starting_row = ttrow; tinfoeeol(); /* rest of this line */ for(i = ttrow+1; i <= term.t_nrow; i++){ /* the remaining lines */ tinfomove(i, 0); tinfoeeol(); } tinfomove(starting_row, starting_col); } else if(_cleartoeos) putpad(_cleartoeos); /* return ignored */ return(0); }
static int tinfoeeol(void) { int c, starting_col, starting_line; char *last_bg_color; /* * If the terminal doesn't have back color erase, then we have to * erase manually to preserve the background color. */ if(pico_usingcolor() && (!_bce || !_cleartoeoln)){ extern int ttcol, ttrow; starting_col = ttcol; starting_line = ttrow; last_bg_color = pico_get_last_bg_color(); pico_set_nbg_color(); for(c = ttcol; c < term.t_ncol; c++) ttputc(' '); tinfomove(starting_line, starting_col); if(last_bg_color){ pico_set_bg_color(last_bg_color); free(last_bg_color); } } else if(_cleartoeoln) putpad(_cleartoeoln); /* return ignored */ return(0); }
/* * Erase to end of line. */ tteeol() { if(CE) putpad(CE, 1); else { register int i=ncol-ttcol; while(i--) ttputc(' '); ttrow = ttcol = HUGE; } }
static int tinfomove(int row, int col) { putpad(tgoto(_moveto, col, row)); /* return ignored */ return(0); }
static void tcapkopen(void) { putpad(TI); ttflush(); strcpy(sres, "NORMAL"); }
static void tcapkopen(void) { putpad(TI); tioflush(); ttrow = 999; ttcol = 999; sgarbf = TRUE; }
/* * Insert nchunk blank line(s) onto the screen, scrolling the last line on * the screen off the bottom. Use the scrolling region if possible for a * smoother display. If there is no scrolling region, use a set of insert * and delete line sequences. */ void ttinsl(int row, int bot, int nchunk) { int i, nl; /* Case of one line insert is special. */ if (row == bot) { ttmove(row, 0); tteeol(); return; } if (change_scroll_region && scroll_reverse) { /* Use scroll region and back index */ nl = bot - row; ttwindow(row, bot); ttmove(row, 0); while (nchunk--) putpad(scroll_reverse, nl); ttnowindow(); return; } else if (insdel) { ttmove(1 + bot - nchunk, 0); nl = nrow - ttrow; if (parm_delete_line) putpad(tgoto(parm_delete_line, 0, nchunk), nl); else /* For all lines in the chunk... */ for (i = 0; i < nchunk; i++) putpad(delete_line, nl); ttmove(row, 0); /* ttmove() changes ttrow */ nl = nrow - ttrow; if (parm_insert_line) putpad(tgoto(parm_insert_line, 0, nchunk), nl); else /* For all lines in the chunk */ for (i = 0; i < nchunk; i++) putpad(insert_line, nl); ttrow = HUGE; ttcol = HUGE; } else panic("ttinsl: Can't insert/delete line"); }