blob: 7e49047b7fdcb3be57dac6ba0d340748271cc71d [file] [log] [blame]
Patrick Georgi3b77b722011-07-07 15:41:53 +02001/* Public Domain Curses */
2
3#include <curspriv.h>
4
5RCSID("$Id: termattr.c,v 1.54 2008/07/13 16:08:18 wmcbrine Exp $")
6
7/*man-start**************************************************************
8
9 Name: termattr
10
11 Synopsis:
12 int baudrate(void);
13 char erasechar(void);
14 bool has_ic(void);
15 bool has_il(void);
16 char killchar(void);
17 char *longname(void);
18 chtype termattrs(void);
19 attr_t term_attrs(void);
20 char *termname(void);
21
22 int erasewchar(wchar_t *ch);
23 int killwchar(wchar_t *ch);
24
25 char wordchar(void);
26
27 Description:
Stefan Reinauere11835e2011-10-31 12:54:00 -070028 baudrate() is supposed to return the output speed of the
Patrick Georgi3b77b722011-07-07 15:41:53 +020029 terminal. In PDCurses, it simply returns INT_MAX.
30
Stefan Reinauere11835e2011-10-31 12:54:00 -070031 has_ic and has_il() return TRUE. These functions have meaning in
Patrick Georgi3b77b722011-07-07 15:41:53 +020032 some other implementations of curses.
33
Stefan Reinauere11835e2011-10-31 12:54:00 -070034 erasechar() and killchar() return ^H and ^U, respectively -- the
35 ERASE and KILL characters. In other curses implementations,
36 these may vary by terminal type. erasewchar() and killwchar()
37 are the wide-character versions; they take a pointer to a
Patrick Georgi3b77b722011-07-07 15:41:53 +020038 location in which to store the character, and return OK or ERR.
39
40 longname() returns a pointer to a static area containing a
41 verbose description of the current terminal. The maximum length
42 of the string is 128 characters. It is defined only after the
43 call to initscr() or newterm().
44
45 termname() returns a pointer to a static area containing a
46 short description of the current terminal (14 characters).
47
48 termattrs() returns a logical OR of all video attributes
49 supported by the terminal.
50
Stefan Reinauere11835e2011-10-31 12:54:00 -070051 wordchar() is a PDCurses extension of the concept behind the
52 functions erasechar() and killchar(), returning the "delete
Patrick Georgi3b77b722011-07-07 15:41:53 +020053 word" character, ^W.
54
55 Portability X/Open BSD SYS V
56 baudrate Y Y Y
57 erasechar Y Y Y
58 has_ic Y Y Y
59 has_il Y Y Y
60 killchar Y Y Y
61 longname Y Y Y
62 termattrs Y Y Y
63 termname Y Y Y
64 erasewchar Y
65 killwchar Y
66 term_attrs Y
67 wordchar - - -
68
69**man-end****************************************************************/
70
71#include <string.h>
72#include <limits.h>
73
74int baudrate(void)
75{
76 PDC_LOG(("baudrate() - called\n"));
77
78 return INT_MAX;
79}
80
81char erasechar(void)
82{
83 PDC_LOG(("erasechar() - called\n"));
84
85 return _ECHAR; /* character delete char (^H) */
86}
87
88bool has_ic(void)
89{
90 PDC_LOG(("has_ic() - called\n"));
91
92 return TRUE;
93}
94
95bool has_il(void)
96{
97 PDC_LOG(("has_il() - called\n"));
98
99 return TRUE;
100}
101
102char killchar(void)
103{
104 PDC_LOG(("killchar() - called\n"));
105
106 return _DLCHAR; /* line delete char (^U) */
107}
108
109char *longname(void)
110{
111 PDC_LOG(("longname() - called\n"));
112
113 return ttytype + 9; /* skip "pdcurses|" */
114}
115
116chtype termattrs(void)
117{
118 chtype temp = A_BLINK | A_BOLD | A_INVIS | A_REVERSE | A_UNDERLINE;
119
120 /* note: blink is bold background on some platforms */
121
122 PDC_LOG(("termattrs() - called\n"));
123
124 if (!SP->mono)
125 temp |= A_COLOR;
126
127 return temp;
128}
129
130attr_t term_attrs(void)
131{
132 PDC_LOG(("term_attrs() - called\n"));
133
Stefan Reinauere11835e2011-10-31 12:54:00 -0700134 return WA_BLINK | WA_BOLD | WA_INVIS | WA_LEFT | WA_REVERSE |
Patrick Georgi3b77b722011-07-07 15:41:53 +0200135 WA_RIGHT | WA_UNDERLINE;
136}
137
Stefan Reinauera6c495e2013-03-25 15:15:16 -0700138const char *termname(void)
Patrick Georgi3b77b722011-07-07 15:41:53 +0200139{
140 PDC_LOG(("termname() - called\n"));
141
142 return "pdcurses";
143}
144
145char wordchar(void)
146{
147 PDC_LOG(("wordchar() - called\n"));
148
149 return _DWCHAR; /* word delete char */
150}
151
152#ifdef PDC_WIDE
153int erasewchar(wchar_t *ch)
154{
155 PDC_LOG(("erasewchar() - called\n"));
156
157 if (!ch)
158 return ERR;
159
160 *ch = (wchar_t)_ECHAR;
161
162 return OK;
163}
164
165int killwchar(wchar_t *ch)
166{
167 PDC_LOG(("killwchar() - called\n"));
168
169 if (!ch)
170 return ERR;
171
172 *ch = (wchar_t)_DLCHAR;
173
174 return OK;
175}
176#endif