Skip to content

Commit 0a48355

Browse files
committed
Turned ACS_vars into templates, since acs_map cannot be known at compile time,
I wanted the syntax to be as similar as possible. ACS_VAR() is as close to ACS_VAR as we are going to get, I believe.
1 parent f332f15 commit 0a48355

File tree

1 file changed

+107
-60
lines changed

1 file changed

+107
-60
lines changed

curses.d

Lines changed: 107 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module curses;
4343
import std.c.stddef;
4444
import std.c.stdio;
4545
import std.c.stdarg;
46-
public import unctrl;
46+
//public import unctrl;
4747

4848
//TODO check if needed... I don't have a windows machine...
4949
version(Win32)
@@ -106,65 +106,112 @@ immutable enum :chtype
106106

107107

108108
/* acs symbols */
109-
immutable enum ACS
110-
{
111-
/* VT100 symbols begin here */
112-
ULCORNER = 'l',
113-
LLCORNER = 'm',
114-
URCORNER = 'k',
115-
LRCORNER = 'j',
116-
LTEE = 't',
117-
RTEE = 'u',
118-
BTEE = 'v',
119-
TTEE = 'w',
120-
HLINE = 'q',
121-
VLINE = 'x',
122-
PLUS = 'n',
123-
S1 = 'o',
124-
S9 = 's',
125-
DIAMOND = '`',
126-
CKBOARD = 'a',
127-
DEGREE = 'f',
128-
PLMINUS = 'g',
129-
BULLET = '~',
130-
/* Teletype 5410v1 symbols begin here */
131-
LARROW = ',',
132-
RARROW = '+',
133-
DARROW = '.',
134-
UARROW = '-',
135-
BOARD = 'h',
136-
LANTERN = 'i',
137-
BLOCK = '0',
138-
/*
139-
* These aren't documented, but a lot of System Vs have them anyway
140-
* (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
141-
* The ACS_names may not match AT&T's, our source didn't know them.
142-
*/
143-
S3 = 'p',
144-
S7 = 'r',
145-
LEQUAL = 'y',
146-
GEQUAL = 'z',
147-
PI = '{',
148-
NEQUAL = '|',
149-
STERLING = '}',
150-
/*
151-
* Line drawing ACS names are of the form ACS_trbl, where t is the top, r
152-
* is the right, b is the bottom, and l is the left. t, r, b, and l might
153-
* be B (blank), S (single), D (double), or T (thick). The subset defined
154-
* here only uses B and S.
155-
*/
156-
BSSB = ULCORNER,
157-
SSBB = LLCORNER,
158-
BBSS = URCORNER,
159-
SBBS = LRCORNER,
160-
SBSS = RTEE,
161-
SSSB = LTEE,
162-
SSBS = BTEE,
163-
BSSS = TTEE,
164-
BSBS = HLINE,
165-
SBSB = VLINE,
166-
SSSS = PLUS
167-
}
109+
///I couldn't make it perfect, this is the best that I have come up with...
110+
///Instead of calling ACS_VAR, you use ACS_VAR().
111+
///Close enough for now??
112+
/* VT100 symbols begin here */
113+
auto ACS_ULCORNER()()
114+
{ return acs_map[cast(ubyte)'l']; }
115+
auto ACS_LLCORNER()()
116+
{ return acs_map[cast(ubyte)'m']; }
117+
auto ACS_URCORNER()()
118+
{ return acs_map[cast(ubyte)'k']; }
119+
auto ACS_LRCORNER()()
120+
{ return acs_map[cast(ubyte)'j']; }
121+
auto ACS_LTEE()()
122+
{ return acs_map[cast(ubyte)'t']; }
123+
auto ACS_RTEE()()
124+
{ return acs_map[cast(ubyte)'u']; }
125+
auto ACS_BTEE()()
126+
{ return acs_map[cast(ubyte)'v']; }
127+
auto ACS_TTEE()()
128+
{ return acs_map[cast(ubyte)'w']; }
129+
auto ACS_HLINE()()
130+
{ return acs_map[cast(ubyte)'q']; }
131+
auto ACS_VLINE()()
132+
{ return acs_map[cast(ubyte)'x']; }
133+
auto ACS_PLUS()()
134+
{ return acs_map[cast(ubyte)'n']; }
135+
auto ACS_S1()()
136+
{ return acs_map[cast(ubyte)'o']; }
137+
auto ACS_S9()()
138+
{ return acs_map[cast(ubyte)'s']; }
139+
auto ACS_DIAMOND()()
140+
{ return acs_map[cast(ubyte)'`']; }
141+
auto ACS_CKBOARD()()
142+
{ return acs_map[cast(ubyte)'a']; }
143+
auto ACS_DEGREE()()
144+
{ return acs_map[cast(ubyte)'f']; }
145+
auto ACS_PLMINUS()()
146+
{ return acs_map[cast(ubyte)'g']; }
147+
auto ACS_BULLET()()
148+
{ return acs_map[cast(ubyte)'~']; }
149+
150+
/* Teletype 5410v1 symbols begin here */
151+
auto ACS_LARROW()()
152+
{ return acs_map[cast(ubyte)',']; }
153+
auto ACS_RARROW()()
154+
{ return acs_map[cast(ubyte)'+'];}
155+
auto ACS_DARROW()()
156+
{ return acs_map[cast(ubyte)'.']; }
157+
auto ACS_UARROW()()
158+
{ return acs_map[cast(ubyte)'-']; }
159+
auto ACS_BOARD()()
160+
{ return acs_map[cast(ubyte)'h']; }
161+
auto ACS_LANTERN()()
162+
{ return acs_map[cast(ubyte)'i']; }
163+
auto ACS_BLOCK()()
164+
{ return acs_map[cast(ubyte)'0']; }
165+
166+
/*
167+
* These aren't documented, but a lot of System Vs have them anyway
168+
* (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
169+
* The ACS_names may not match AT&T's, our source didn't know them.
170+
*/
171+
auto ACS_S3()()
172+
{ return acs_map[cast(ubyte)'p']; }
173+
auto ACS_S7()()
174+
{ return acs_map[cast(ubyte)'r']; }
175+
auto ACS_LEQUAL()()
176+
{ return acs_map[cast(ubyte)'y']; }
177+
auto ACS_GEQUAL()()
178+
{ return acs_map[cast(ubyte)'z']; }
179+
auto ACS_PI()()
180+
{ return acs_map[cast(ubyte)'{']; }
181+
auto ACS_NEQUAL()()
182+
{ return acs_map[cast(ubyte)'|']; }
183+
auto ACS_STERLING()()
184+
{ return acs_map[cast(ubyte)'}']; }
185+
186+
/*
187+
* Line drawing ACS names are of the form ACS_trbl, where t is the top, r
188+
* is the right, b is the bottom, and l is the left. t, r, b, and l might
189+
* be B (blank), S (single), D (double), or T (thick). The subset defined
190+
* here only uses B and S.
191+
*/
192+
auto ACS_BSSB()()
193+
{ return ACS_ULCORNER(); }
194+
auto ACS_SSBB()()
195+
{ return ACS_LLCORNER(); }
196+
auto ACS_BBSS()()
197+
{ return ACS_URCORNER(); }
198+
auto ACS_SBBS()()
199+
{ return ACS_LRCORNER(); }
200+
auto ACS_SBSS()()
201+
{ return ACS_RTEE(); }
202+
auto ACS_SSSB()()
203+
{ return ACS_LTEE(); }
204+
auto ACS_SSBS()()
205+
{ return ACS_BTEE(); }
206+
auto ACS_BSSS()()
207+
{ return ACS_TTEE(); }
208+
auto ACS_BSBS()()
209+
{ return ACS_HLINE(); }
210+
auto ACS_SBSB()()
211+
{ return ACS_VLINE(); }
212+
auto ACS_SSSS()()
213+
{ return ACS_PLUS(); }
214+
168215

169216
/* error codes */
170217
immutable enum

0 commit comments

Comments
 (0)