|
|
1.1 root 1: /* @(#) vidputs.c: 1.1 10/15/83 (1.8 10/27/82) */
2: #include "curses.ext"
3:
4: static int oldmode = 0; /* This really should be in the struct term */
5: char *tparm();
6:
7: /* nooff: modes that don't have an explicit "turn me off" capability */
8: #define nooff (A_PROTECT|A_INVIS|A_BOLD|A_DIM|A_BLINK|A_REVERSE)
9: /* hilite: modes that could be faked with standout in a pinch. */
10: #define hilite (A_UNDERLINE|A_BOLD|A_DIM|A_BLINK|A_REVERSE)
11:
12: vidputs(newmode, outc)
13: int newmode;
14: int (*outc)();
15: {
16: int curmode = oldmode;
17:
18: #ifdef DEBUG
19: if (outf) fprintf(outf, "vidputs oldmode=%o, newmode=%o\n", oldmode, newmode);
20: #endif
21: if (newmode || !exit_attribute_mode) {
22: if (set_attributes) {
23: tputs(tparm(set_attributes,
24: newmode & A_STANDOUT,
25: newmode & A_UNDERLINE,
26: newmode & A_REVERSE,
27: newmode & A_BLINK,
28: newmode & A_DIM,
29: newmode & A_BOLD,
30: newmode & A_INVIS,
31: newmode & A_PROTECT,
32: newmode & A_ALTCHARSET),
33: 1, outc);
34: curmode = newmode;
35: } else {
36: if ((oldmode&nooff) > (newmode&nooff)) {
37: if (exit_attribute_mode) {
38: tputs(exit_attribute_mode, 1, outc);
39: } else if (oldmode == A_UNDERLINE && exit_underline_mode) {
40: tputs(exit_underline_mode, 1, outc);
41: } else if (exit_standout_mode) {
42: tputs(exit_standout_mode, 1, outc);
43: }
44: curmode = oldmode = 0;
45: }
46: if ((newmode&A_ALTCHARSET) && !(oldmode&A_ALTCHARSET)) {
47: tputs(enter_alt_charset_mode, 1, outc);
48: curmode |= A_ALTCHARSET;
49: }
50: if (!(newmode&A_ALTCHARSET) && (oldmode&A_ALTCHARSET)) {
51: tputs(exit_alt_charset_mode, 1, outc);
52: curmode &= ~A_ALTCHARSET;
53: }
54: if ((newmode&A_PROTECT) && !(oldmode&A_PROTECT)) {
55: tputs(enter_protected_mode, 1, outc);
56: curmode |= A_PROTECT;
57: }
58: if ((newmode&A_INVIS) && !(oldmode&A_INVIS)) {
59: tputs(enter_secure_mode, 1, outc);
60: curmode |= A_INVIS;
61: }
62: if ((newmode&A_BOLD) && !(oldmode&A_BOLD))
63: if (enter_bold_mode) {
64: curmode |= A_BOLD;
65: tputs(enter_bold_mode, 1, outc);
66: }
67: if ((newmode&A_DIM) && !(oldmode&A_DIM))
68: if (enter_dim_mode) {
69: curmode |= A_DIM;
70: tputs(enter_dim_mode, 1, outc);
71: }
72: if ((newmode&A_BLINK) && !(oldmode&A_BLINK))
73: if (enter_blink_mode) {
74: curmode |= A_BLINK;
75: tputs(enter_blink_mode, 1, outc);
76: }
77: if ((newmode&A_REVERSE) && !(oldmode&A_REVERSE))
78: if (enter_reverse_mode) {
79: curmode |= A_REVERSE;
80: tputs(enter_reverse_mode, 1, outc);
81: }
82: if ((newmode&A_UNDERLINE) && !(oldmode&A_UNDERLINE))
83: if (enter_underline_mode) {
84: curmode |= A_UNDERLINE;
85: tputs(enter_underline_mode,1,outc);
86: }
87: if (!(newmode&A_UNDERLINE) && (oldmode&A_UNDERLINE)) {
88: tputs(exit_underline_mode, 1, outc);
89: curmode &= ~A_UNDERLINE;
90: }
91: if ((newmode&A_STANDOUT) && !(oldmode&A_STANDOUT))
92: if (enter_standout_mode) {
93: curmode |= A_STANDOUT;
94: tputs(enter_standout_mode,1,outc);
95: }
96: if (!(newmode&A_STANDOUT) && (oldmode&A_STANDOUT)) {
97: tputs(exit_standout_mode, 1, outc);
98: curmode &= ~A_STANDOUT;
99: }
100: }
101: } else {
102: if (exit_attribute_mode)
103: tputs(exit_attribute_mode, 1, outc);
104: else if (oldmode == A_UNDERLINE && exit_underline_mode)
105: tputs(exit_underline_mode, 1, outc);
106: else if (exit_standout_mode)
107: tputs(exit_standout_mode, 1, outc);
108: curmode = 0;
109: }
110: /*
111: * If we asked for bold, say, on a terminal with only standout,
112: * and we aren't already in standout, we settle for standout.
113: */
114: if ((newmode&hilite) && curmode!=newmode && (curmode&A_STANDOUT)==0) {
115: tputs(enter_standout_mode, 1, outc);
116: curmode |= A_STANDOUT;
117: }
118: oldmode = curmode;
119: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.