|
|
1.1 root 1: /*********************************************************************
2: * COPYRIGHT NOTICE *
3: **********************************************************************
4: * This software is copyright (C) 1982 by Pavel Curtis *
5: * *
6: * Permission is granted to reproduce and distribute *
7: * this file by any means so long as no fee is charged *
8: * above a nominal handling fee and so long as this *
9: * notice is always included in the copies. *
10: * *
11: * Other rights are reserved except as explicitly granted *
12: * by written permission of the author. *
13: * Pavel Curtis *
14: * Computer Science Dept. *
15: * 405 Upson Hall *
16: * Cornell University *
17: * Ithaca, NY 14853 *
18: * *
19: * Ph- (607) 256-4934 *
20: * *
21: * Pavel.Cornell@Udel-Relay (ARPAnet) *
22: * decvax!cornell!pavel (UUCPnet) *
23: *********************************************************************/
24:
25: /*
26: * vidputs(newmode, outc)
27: *
28: * newmode is taken to be the logical 'or' of the symbols in curses.h
29: * representing graphic renditions. The teminal is set to be in all of
30: * the given modes, if possible.
31: *
32: * $Log: RCS/lib_vidattr.v $
33: * Revision 2.3 93/02/16 17:47:46 munk
34: * color attributes added
35: *
36: * Revision 2.2 91/02/12 14:29:50 munk
37: * New algorithm for every mix of attributes
38: *
39: * Revision 2.1 82/10/25 14:49:45 pavel
40: * Added Copyright Notice
41: *
42: * Revision 2.0 82/10/24 15:18:15 pavel
43: * Beta-one Test Release
44: *
45: * Revision 1.3 82/08/23 22:31:08 pavel
46: * The REAL Alpha-one Release Version
47: *
48: * Revision 1.2 82/08/19 19:11:46 pavel
49: * Alpha Test Release One
50: *
51: * Revision 1.1 82/08/12 18:48:23 pavel
52: * Initial revision
53: *
54: *
55: */
56:
57: #ifdef RCSHDR
58: static char RCSid[] =
59: "$Header: RCS/lib_vidattr.v Revision 2.3 93/02/16 17:47:46 munk Exp$";
60: #endif
61:
62: #include "curses.h"
63: #include "curses.priv.h"
64: #include "term.h"
65:
66:
67: vidputs(newmode, outc)
68: chtype newmode;
69: int (*outc)();
70: {
71: static chtype previous_attr = 0;
72: register chtype turn_off, turn_on;
73: char *tparm();
74:
75: #ifdef TRACE
76: if (_tracing)
77: _tracef("vidputs(%o,%o) called", newmode, outc);
78: #endif
79:
80: turn_off = ~newmode & previous_attr;
81:
82: if ((turn_off & A_ALTCHARSET) && exit_alt_charset_mode) {
83: tputs(exit_alt_charset_mode, 1, outc);
84: turn_off &= ~A_ALTCHARSET;
85: }
86:
87: if ((turn_off & A_UNDERLINE) && exit_underline_mode) {
88: tputs(exit_underline_mode, 1, outc);
89: turn_off &= ~A_UNDERLINE;
90: }
91:
92: if ((turn_off & A_STANDOUT) && exit_standout_mode) {
93: tputs(exit_standout_mode, 1, outc);
94: turn_off &= ~A_STANDOUT;
95: }
96:
97: if (turn_off && exit_attribute_mode) {
98: tputs(exit_attribute_mode, 1, outc);
99: turn_off = 0;
100: }
101:
102: turn_on = newmode & ~turn_off;
103:
104: if ((turn_on & A_ALTCHARSET) && enter_alt_charset_mode)
105: tputs(enter_alt_charset_mode, 1, outc);
106:
107: if ((turn_on & A_BLINK) && enter_blink_mode)
108: tputs(enter_blink_mode, 1, outc);
109:
110: if ((turn_on & A_BOLD) && enter_bold_mode)
111: tputs(enter_bold_mode, 1, outc);
112:
113: if ((turn_on & A_INVIS) && enter_secure_mode)
114: tputs(enter_secure_mode, 1, outc);
115:
116: if ((turn_on & A_DIM) && enter_dim_mode)
117: tputs(enter_dim_mode, 1, outc);
118:
119: if ((turn_on & A_PROTECT) && enter_protected_mode)
120: tputs(enter_protected_mode, 1, outc);
121:
122: if ((turn_on & A_REVERSE) && enter_reverse_mode)
123: tputs(enter_reverse_mode, 1, outc);
124:
125: if ((turn_on & A_STANDOUT) && enter_standout_mode)
126: tputs(enter_standout_mode, 1, outc);
127:
128: if ((turn_on & A_UNDERLINE) && enter_underline_mode)
129: tputs(enter_underline_mode, 1, outc);
130:
131: if (__color__) {
132: if ((newmode & A_COLOR) != (previous_attr & A_COLOR) || __pair_changed__) {
133: if (__pairs__[0][PAIR_NUMBER(newmode)] != -1) {
134: tputs(tparm(set_foreground, __pairs__[0][PAIR_NUMBER(newmode)]), 1, outc);
135: tputs(tparm(set_background, __pairs__[1][PAIR_NUMBER(newmode)]), 1, outc);
136: }
137: }
138: }
139:
140: previous_attr = newmode;
141: }
142:
143:
144: vidattr(newmode)
145: chtype newmode;
146: {
147: int _outc();
148:
149: #ifdef TRACE
150: if (_tracing)
151: _tracef("vidattr(%o) called", newmode);
152: #endif
153:
154: vidputs(newmode, _outc);
155: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.