static void update_eff(void) { udat effects = Effects; hwcol fg = COLFG(ColText), bg = COLBG(ColText); if (effects & EFF_UNDERLINE) fg = COLFG(Underline); else if (effects & EFF_HALFINTENS) fg = COLFG(HalfInten); if (!!(effects & EFF_REVERSE) != !!(*Flags & TTY_INVERTSCR)) { hwcol tmp = COL(bg & ~HIGH, fg & ~HIGH) | COL(fg & HIGH, bg & HIGH); fg = COLFG(tmp); bg = COLBG(tmp); } if (effects & EFF_INTENSITY) fg ^= HIGH; if (effects & EFF_BLINK) bg ^= HIGH; Color = COL(fg, bg); }
static void invert_screen(void) { hwattr a, *p = Start; ldat count; dirty_tty(0, 0, SizeX-1, SizeY-1); count = SizeX * SizeY; while (count--) { a = *p; *p++ = (a & ~HWATTR(TW_MAXWCOL, 0)) | HWATTR(COL(COLBG(HWCOL(a)), COLFG(HWCOL(a))), 0); if (p == Split) p = Base; } }
INLINE void csi_m(void) { dat i; udat effects = Effects; hwcol fg = COLFG(ColText), bg = COLBG(ColText); for (i=0; i<=nPar; i++) switch (Par[i]) { case 0: /* all attributes off */ fg = COLFG(DefColor); bg = COLBG(DefColor); effects = 0; break; case 1: effects &= ~EFF_HALFINTENS; effects |= EFF_INTENSITY; break; case 2: effects &= ~EFF_INTENSITY; effects |= EFF_HALFINTENS; break; case 4: effects |= EFF_UNDERLINE; break; case 5: effects |= EFF_BLINK; break; case 7: effects |= EFF_REVERSE; break; case 10: /* ANSI X3.64-1979 (SCO-ish?) * Select primary font, don't display * control chars if defined, don't set * bit 8 on output. */ setCharset(G ? G1 : G0); *Flags &= ~(TTY_DISPCTRL | TTY_SETMETA); break; case 11: /* ANSI X3.64-1979 (SCO-ish?) * Select first alternate font, lets * chars < 32 be displayed as ROM chars. */ setCharset(IBMPC_MAP); *Flags |= TTY_DISPCTRL; *Flags &= ~TTY_SETMETA; break; case 12: /* ANSI X3.64-1979 (SCO-ish?) * Select second alternate font, toggle * high bit before displaying as ROM char. */ setCharset(IBMPC_MAP); *Flags |= TTY_DISPCTRL | TTY_SETMETA; break; case 21: case 22: effects &= ~(EFF_HALFINTENS|EFF_INTENSITY); break; case 24: effects &= ~EFF_UNDERLINE; break; case 25: effects &= ~EFF_BLINK; break; case 27: effects &= ~EFF_REVERSE; break; case 38: /* ANSI X3.64-1979 (SCO-ish?) * Enables underscore, white foreground * with white underscore * (Linux - use default foreground). */ fg = COLFG(DefColor); effects |= EFF_UNDERLINE; break; case 39: /* ANSI X3.64-1979 (SCO-ish?) * Disable underline option. * Reset colour to default? It did this * before... */ fg = COLFG(DefColor); effects &= ~EFF_UNDERLINE; break; case 49: /* restore default bg */ bg = COLBG(DefColor); break; default: if (Par[i] >= 30 && Par[i] <= 37) Par[i] -= 30, fg = ANSI2VGA(Par[i]); else if (Par[i] >= 40 && Par[i] <= 47) Par[i] -= 40, bg = ANSI2VGA(Par[i]); break; } Effects = effects; ColText = COL(fg, bg); update_eff(); }
/* Scroll back */ static void scrollback(void) { int y,c; WIN *b_us, *b_st; ELM *tmp_e; int case_matters=0; /* fmg: case-importance, needed for 'N' */ static wchar_t look_for[MAX_SEARCH]; /* fmg: last used search pattern */ wchar_t tmp_line[MAXCOLS]; int citemode = 0; int cite_ystart = 1000000, cite_yend = -1, cite_y = 0; int inverse; int loop = 1; char hline0[128], hline1[128], *hline; static int hit=0; /* Find out how big a window we must open. */ y = us->y2; if (st == (WIN *)0 || (st && tempst)) y--; /* Open a window. */ b_us = mc_wopen(0, 0, us->x2, y, 0, us->attr, COLFG(us->color), COLBG(us->color), 0, 0, 0); mc_wcursor(b_us, CNONE); /* Open a help line window. */ b_st = mc_wopen(0, y+1, us->x2, y+1, 0, st_attr, sfcolor, sbcolor, 0, 0, 1); b_st->doscroll = 0; b_st->wrap = 0; /* Make sure help line is as wide as window. */ /* * fmg 8/20/97 * added /=Srch, \=CaseLess, and N=Next and changed rest of line... * Hope you like it :-) */ strcpy(hline0, _("HISTORY: U=Up D=Down F=PgDn B=PgUp s=Srch S=CaseLess N=Next C=Cite ESC=Exit ")); if (b_st->xs < 127) hline0[b_st->xs] = 0; hline = hline0; mc_wprintf(b_st, "%s", hline); mc_wredraw(b_st, 1); mc_wflush(); /* And do the job. */ y = us->histlines; /* fmg 8/20/97 * Needed for N)extSearch, keeps track of line on which current "hit" * is... we advance it to 'N'ext hit in find_next(). We start at "top" * of history stack */ hit = 0; drawhist(b_us, y, 0); while (loop) { c = wxgetch(); switch (c) { /* * fmg 8/22/97 * Take care of the search key: Caseless */ case '\\': case 'S': case_matters = 0; /* case-importance, ie. none :-) */ /* * fmg 8/22/97 * Take care of the search key: Exact Match */ case '/': case 's': if (!us->histlines) { mc_wbell(); werror(_("History buffer Disabled!")); break; } if (!us->histline) { mc_wbell(); werror(_("History buffer empty!")); break; } if (citemode) break; /* we need this for the case-importance-toggle to work.. */ if (c == '/' || c == 's') case_matters=1; /* case-importance, ie. DOES */ /* open up new search window... */ searchhist(b_us, look_for); /* must redraw status line... */ mc_wlocate(b_st, 0, 0); /* move back to column 0! */ mc_wprintf(b_st, "%s", hline); /* and show the above-defined hline */ mc_wredraw(b_st, 1); /* again... */ /* highlight any matches */ if (wcslen(look_for) > 1) { hit = find_next(us, b_us, y, look_for, case_matters); if (hit == -1) { mc_wbell(); mc_wflush(); hit = 0; break; } drawhist_look(b_us, hit, 1, look_for, case_matters); y = hit; } else { mc_wbell(); break; } mc_wflush(); break; /* * fmg 8/22/97 * Take care of the Next Hit key... * Popup an error window if no previous... why not start a new * search? How do we know which case-importance they wanted? */ case 'n': case 'N': /* highlight NEXT match */ if (citemode) break; if (wcslen(look_for) > 1) { hit = find_next(us, b_us, y, look_for, case_matters); if (hit == -1) { mc_wbell(); mc_wflush(); hit = 0; break; } drawhist_look(b_us, hit, 1, look_for, case_matters); y = hit; } else { /* no search pattern... */ mc_wbell(); werror(_("No previous search!\n Please 's' or 'S' first!")); } mc_wflush(); break; case 'u': case 'U': case K_UP: if (citemode && cite_y) { cite_y--; if (cite_ystart != 1000000) { cite_yend = y + cite_y; drawcite(b_us, cite_y+1, y, cite_ystart, cite_yend); drawcite(b_us, cite_y, y, cite_ystart, cite_yend); } mc_wlocate(b_us, 0, cite_y); break; } if (y <= 0) break; y--; if (cite_ystart != 1000000) cite_yend = y + cite_y; mc_wscroll(b_us, S_DOWN); /* * fmg 8/20/97 * This is needed so that the movement in window will HIGHLIGHT * the lines that have the pattern we wanted... it's just nice. * This almost beggs for a function :-) */ if (citemode) { inverse = (y+cite_y >= cite_ystart && y+cite_y <= cite_yend); } else { tmp_e = mc_getline(b_us, y); if (wcslen(look_for) > 1) { /* quick scan for pattern match */ mc_wdrawelm_var(b_us, tmp_e, tmp_line); inverse = (wcslen(tmp_line)>1 && StrStr(tmp_line, look_for, case_matters)); } else inverse = 0; } if (inverse) mc_wdrawelm_inverse(b_us, 0, mc_getline(b_us, y)); else mc_wdrawelm(b_us, 0, mc_getline(b_us, y)); if (citemode) mc_wlocate(b_us, 0, cite_y); mc_wflush(); break; case 'd': case 'D': case K_DN: if (citemode && cite_y < b_us->ys-1) { cite_y++; if (cite_ystart != 1000000) { cite_yend = y + cite_y; drawcite(b_us, cite_y-1, y, cite_ystart, cite_yend); drawcite(b_us, cite_y, y, cite_ystart, cite_yend); } mc_wlocate(b_us, 0, cite_y); break; } if (y >= us->histlines) break; y++; if (cite_ystart != 1000000) cite_yend = y + cite_y; mc_wscroll(b_us, S_UP); /* * fmg 8/20/97 * This is needed so that the movement in window will HIGHLIGHT * the lines that have the pattern we wanted... it's just nice. * This almost beggs for a function :-) */ if (citemode) { inverse = (y+cite_y >= cite_ystart && y+cite_y <= cite_yend); } else { tmp_e = mc_getline(b_us, y + b_us->ys - 1); if (wcslen(look_for) > 1) { /* quick scan for pattern match */ mc_wdrawelm_var(b_us, tmp_e, tmp_line); inverse = (wcslen(tmp_line)>1 && StrStr(tmp_line, look_for, case_matters)); } else inverse = 0; } if (inverse) mc_wdrawelm_inverse(b_us, b_us->ys - 1, mc_getline(b_us, y + b_us->ys - 1)); else mc_wdrawelm(b_us, b_us->ys - 1, mc_getline(b_us, y + b_us->ys - 1)); if (citemode) mc_wlocate(b_us, 0, cite_y); mc_wflush(); break; case 'b': case 'B': case K_PGUP: if (y <= 0) break; y -= b_us->ys; if (y < 0) y = 0; if (cite_ystart != 1000000) cite_yend = y + cite_y; /* * fmg 8/20/97 * This is needed so that the movement in window will HIGHLIGHT * the lines that have the pattern we wanted... it's just nice. * Highlight any matches */ if (wcslen(look_for) > 1 && us->histline) drawhist_look(b_us, y, 1, look_for, case_matters); else drawhist(b_us, y, 1); if (citemode) mc_wlocate(b_us, 0, cite_y); break; case 'f': case 'F': case ' ': /* filipg: space bar will go page-down... pager-like */ case K_PGDN: if (y >= us->histlines) break; y += b_us->ys; if (y > us->histlines) y=us->histlines; if (cite_ystart != 1000000) cite_yend = y + cite_y; /* * fmg 8/20/97 * This is needed so that the movement in window will HIGHLIGHT * the lines that have the pattern we wanted... it's just nice. * Highlight any matches */ if (wcslen(look_for) > 1 && us->histline) drawhist_look(b_us, y, 1, look_for, case_matters); else drawhist(b_us, y, 1); if (citemode) mc_wlocate(b_us, 0, cite_y); break; case 'C': case 'c': /* start citation mode */ if (citemode ^= 1) { cite_y = 0; cite_ystart = 1000000; cite_yend = -1; strcpy(hline1, _(" CITATION: ENTER=select start line ESC=exit ")); if (b_st->xs < 127) hline1[b_st->xs]=0; hline = hline1; } else { hline = hline0; } mc_wlocate(b_st, 0, 0); mc_wprintf(b_st, "%s", hline); mc_wredraw(b_st, 1); if (citemode) mc_wlocate(b_us, 0, cite_y); break; case 10: case 13: if (!citemode) break; if (cite_ystart == 1000000) { cite_yend = cite_ystart = y + cite_y; strcpy(hline1, _(" CITATION: ENTER=select end line ESC=exit ")); if (b_st->xs < 127) hline1[b_st->xs]=0; } else { if (cite_ystart > cite_yend) break; drawcite_whole(b_us, y, 1000000, -1); loop = 0; break; } mc_wlocate(b_st, 0, 0); mc_wprintf(b_st, "%s", hline); mc_wredraw(b_st, 1); mc_wdrawelm_inverse(b_us, cite_y, mc_getline(b_us, cite_ystart)); mc_wlocate(b_us, 0, cite_y); break; case K_ESC: if (!citemode) { loop = 0; break; } if (cite_ystart == 1000000) { citemode = 0; hline = hline0; } else { cite_ystart = 1000000; strcpy(hline1, _(" CITATION: ENTER=select start line ESC=exit ")); } drawcite_whole(b_us, y, cite_ystart, cite_yend); mc_wlocate(b_st, 0, 0); mc_wprintf(b_st, "%s", hline); mc_wredraw(b_st, 1); if (citemode) mc_wlocate(b_us, 0, cite_y); break; } } /* Cleanup. */ if (citemode) do_cite(b_us, cite_ystart, cite_yend); mc_wclose(b_us, y == us->histlines ? 0 : 1); mc_wclose(b_st, 1); mc_wlocate(us, us->curx, us->cury); mc_wflush(); mc_wredraw(us, 1); }