1 /* Public Domain Curses */
2 
3 #include <curspriv.h>
4 
5 /*man-start**************************************************************
6 
7 termattr
8 --------
9 
10 ### Synopsis
11 
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
28 
29    baudrate() is supposed to return the output speed of the
30    terminal. In PDCurses, it simply returns INT_MAX.
31 
32    has_ic and has_il() return TRUE. These functions have meaning in
33    some other implementations of curses.
34 
35    erasechar() and killchar() return ^H and ^U, respectively -- the
36    ERASE and KILL characters. In other curses implementations,
37    these may vary by terminal type. erasewchar() and killwchar()
38    are the wide-character versions; they take a pointer to a
39    location in which to store the character, and return OK or ERR.
40 
41    longname() returns a pointer to a static area containing a
42    verbose description of the current terminal. The maximum length
43    of the string is 128 characters.  It is defined only after the
44    call to initscr() or newterm().
45 
46    termname() returns a pointer to a static area containing a
47    short description of the current terminal (14 characters).
48 
49    termattrs() returns a logical OR of all video attributes
50    supported by the terminal.
51 
52    wordchar() is a PDCurses extension of the concept behind the
53    functions erasechar() and killchar(), returning the "delete
54    word" character, ^W.
55 
56 ### Portability
57                              X/Open    BSD    SYS V
58     baudrate                    Y       Y       Y
59     erasechar                   Y       Y       Y
60     has_ic                      Y       Y       Y
61     has_il                      Y       Y       Y
62     killchar                    Y       Y       Y
63     longname                    Y       Y       Y
64     termattrs                   Y       Y       Y
65     termname                    Y       Y       Y
66     erasewchar                  Y
67     killwchar                   Y
68     term_attrs                  Y
69     wordchar                    -       -       -
70 
71 **man-end****************************************************************/
72 
73 #include <string.h>
74 #include <limits.h>
75 
baudrate(void)76 int baudrate(void)
77 {
78     PDC_LOG(("baudrate() - called\n"));
79 
80     return INT_MAX;
81 }
82 
erasechar(void)83 char erasechar(void)
84 {
85     PDC_LOG(("erasechar() - called\n"));
86 
87     return _ECHAR;      /* character delete char (^H) */
88 }
89 
has_ic(void)90 bool has_ic(void)
91 {
92     PDC_LOG(("has_ic() - called\n"));
93 
94     return TRUE;
95 }
96 
has_il(void)97 bool has_il(void)
98 {
99     PDC_LOG(("has_il() - called\n"));
100 
101     return TRUE;
102 }
103 
killchar(void)104 char killchar(void)
105 {
106     PDC_LOG(("killchar() - called\n"));
107 
108     return _DLCHAR;     /* line delete char (^U) */
109 }
110 
longname(void)111 char *longname(void)
112 {
113     PDC_LOG(("longname() - called\n"));
114 
115     return ttytype + 9; /* skip "pdcurses|" */
116 }
117 
termattrs(void)118 chtype termattrs(void)
119 {
120     PDC_LOG(("termattrs() - called\n"));
121 
122     return SP->termattrs;
123 }
124 
term_attrs(void)125 attr_t term_attrs(void)
126 {
127     PDC_LOG(("term_attrs() - called\n"));
128 
129     return SP->termattrs;
130 }
131 
termname(void)132 char *termname(void)
133 {
134     static char _termname[14] = "pdcurses";
135 
136     PDC_LOG(("termname() - called\n"));
137 
138     return _termname;
139 }
140 
wordchar(void)141 char wordchar(void)
142 {
143     PDC_LOG(("wordchar() - called\n"));
144 
145     return _DWCHAR;         /* word delete char */
146 }
147 
148 #ifdef PDC_WIDE
erasewchar(wchar_t * ch)149 int erasewchar(wchar_t *ch)
150 {
151     PDC_LOG(("erasewchar() - called\n"));
152 
153     if (!ch)
154         return ERR;
155 
156     *ch = (wchar_t)_ECHAR;
157 
158     return OK;
159 }
160 
killwchar(wchar_t * ch)161 int killwchar(wchar_t *ch)
162 {
163     PDC_LOG(("killwchar() - called\n"));
164 
165     if (!ch)
166         return ERR;
167 
168     *ch = (wchar_t)_DLCHAR;
169 
170     return OK;
171 }
172 #endif
173