Dmuse: Color and upper-ASCII codes

From CCARH Wiki
Revision as of 18:40, 6 October 2010 by Wbh (talk | contribs)
Jump to navigation Jump to search

The Representation of Color in Dmuse Text Files

The design of the Dmuse screen has its origins in the old PC screen. The old PC screen, which was character based, used two bytes to represent each character cell on the screen: one byte for the character, and one for the color attributes. The color attribute byte had two parts: color of the foreground -- the letters, themselves -- and the color of the background -- the field on which the letters appeared. The Dmuse screen also uses this system to represent characters and their color attributes.

The ability to use different color combinations for characters has proven quite useful. The eye is quick to distinguish color, and this makes it easy to flag or highlight certain areas of the screen. But there needs to be a mechanism for coding this information for storage in a file; otherwise, no advantage would be gained in using colors, since this information would simply go away when the window was saved. The most direct way to store window data would be to store each cell: character and attribute. But this has two very large disadvantages. One, it is very wasteful, since most text is written in a "default" combination, e.g., white on black. Second, it makes the file very difficult to read by other programs, since only every other byte contains a valid character. The alternative used by Dmuse is to insert an escape sequence each time the color attribute in a line changes. Since these changes do not happen very often, the extra bytes do not add up to a lot of extra storage. And since the escape sequences come in blocks, they do not interfere with the characters, at least not on a massive scale.

The escape sequences used by Dmuse actually derive from the escape sequences used by the old (c. 1965) HP 2640 Smart Terminal, on which the first Ibycus systems were based (see the History of Dmuse). Dmuse supports 16 different color combinations, which can be accessed by means of the four function keys, F5, F6, F7, F8, used with the four states: unaltered, Shft, Ctrl, and Ctrl+Shft. By convention, F5 is assigned the default combination, usually white on black. Here are the 16 escape codes used by Dmuse to flag these comgination changes in a file. <esc> here refers to the ASCII byte 27 (hex 0x1b).

Combination Escape Sequence
Character string Dmuse key command
Combination   0: <esc>&d@ F5
Combination   1: <esc>&dA F6
Combination   2: <esc>&dB F7
Combination   3: <esc>&dC F8
Combination   4: <esc>&dD Shft+F5
Combination   5: <esc>&dE Shft+F6
Combination   6: <esc>&dF Shft+F7
Combination   7: <esc>&dG Shft+F8
Combination   8: <esc>&dH Ctrl+F5
Combination   9: <esc>&dI Ctrl+F6
Combination 10: <esc>&dJ Ctrl+F7
Combination 11: <esc>&dK Ctrl+F8
Combination 12: <esc>&dL Ctrl+Shft+F5
Combination 13: <esc>&dM Ctrl+Shft+F6
Combination 14: <esc>&dN Ctrl+Shft+F7
Combination 15: <esc>&dO Ctrl+Shft+F8

In a plain ASCII text editor, a file created by Dmuse might display the following string (using ? to represent the escape byte, 0x1b):

  ?&dAThis combination is black on red.?&d@

which would be displayed in Dmuse as:

   This combination is black on red

with "?&dA" indicating color combination 1 (black letters on a red background), and "?&d@" indicating color combination 0 (return to default colors).

The Use of Non-standard ASCII Codes in Dmuse Files

Byte values range from 0 to 255. For purposes of representing text in Western European alphabets, only a subset of these values is agreed upon by everyone to have a standard meaning. For reasons now lost to most of us, this is called standard ASCII. The subset includes the values 32 to 126, and a few additional values such as 27 (= escape), 13 (= carriage return), 10 (= line-feed), and 9 (= Tab).

When text files are used to represent data that is meant to be read by multiple programs running on a variety of computer platforms, it is absolutely essential that ONLY standard ASCII be used. But it would be a shame to limit screen applications such as Dmuse to the 100 or so standard ASCII characters. Dmuse, for example, can display each of the letters, a,e,i,o,u, A,E,I,O,U, with the acute accent, the grave, the circumflex, and the umlaut or dieresis. Since Dmuse can put only one character in a cell, that's 10 x 4 = 40 additional screen characters. Another example: Dmuse can draw lines and boxes with both single and double lines. Tables and diagrams made with these characters have many useful applications. It takes 40 special characters to do this. So Dmuse does make use of almost all of the 256 byte values, even though only 100 of these values have a standard meaning.

This means that text files generated by Dmuse can have non-standard ASCII bytes in them. These bytes have a clear and sensible meaning to Dmuse, but other programs will interpret them differently with what may look like nonsensible results. There is no problem so long as files generated by Dmuse for general export (MuseData files, for example) contain bytes only from the standard ASCII set. Files intended for use by Dmuse alone are not subject to this limitation. Here is a list of the byte codes used by Dmuse.



Byte Code Character description Dmuse key command
Dec Hex
0 0x00 (no character) (none)
1 0x01 musical sharp () Ctrl+Shft+A
2 0x02 musical flat () Ctrl+Shft+B
3 0x03 musical natural () Ctrl+Shft+C
4 0x04 centered diamond (◊) Ctrl+Shft+D
5 0x05 top of the large open parenthesis Ctrl+Shft+E
6 0x06 bottom of the large open parenthesis Ctrl+Shft+F
7 0x07 large centered dot (•) Shft+Alt+9
8 0x08 top of the large close parenthesis Ctrl+Shft+G
9 0x09 vertical dotted line (the Tab character) Shft+Alt+0 (zero)
10 0x0a line-feed Shft+Alt+- (minus)
11 0x0b copyright (©) Ctrl+Shft+K
12 0x0c bottom of the large close parenthesis Ctrl+Shft+H
13 0x0d carriage return Ctrl+Shft+L
14 0x0e small arrow pointing right () Ctrl+Shft+M
15 0x0f sun burst (☼) Ctrl+Shft+O (letter)
16 0x10 large arrow head pointing right (→) Ctrl+Shft+P
17 0x11 large arrow head pointing left (←) Ctrl+Shft+Q
18 0x12 start of small square root character () Ctrl+Shft+R
19 0x13 top of square root character Ctrl+Shft+S
20 0x14 paragraph (¶) Ctrl+Shft+T
21 0x15 section (§) Ctrl+Shft+U
22 0x16 vertical part of large square root Ctrl+Shft+V
23 0x17 start of large square root (√) Ctrl+Shft+W
24 0x18 small arrow pointing up () Ctrl+Shft+X
25 0x19 small arrow pointing down () Ctrl+Shft+Y
26 0x1a plus or minus (±) Shft+Alt+=
27 0x1b (escape, no character) (none)
28 0x1c small arrow pointing left () Ctrl+Shft+N
29 0x1d arrow both ways (↔) (none)
30 0x1e large arrow head pointing up (↑) Ctrl+Shft+I (letter)
31 0x1f large arrow head pointing down (↓) Ctrl+Shft+J
32-126 (standard ASCII) Standard Keys
127 0x7f house (⌂) Ctrl+Shft+Z
128 0x80 C-cedilla (Ç) C then Alt+2
129 0x81 u-umlaut (ü) u then Alt+3
130 0x82 e-acute (é) e then Alt+7
131 0x83 a-circumflex (â) a then Alt+9
132 0x84 a-umlaut (ä) a then Alt+3
133 0x85 a-grave (à) a then Alt+8
134 0x86 a-circle (å) a then Alt+4
135 0x87 c-cedilla (ç) c then Alt+2
136 0x88 e-circumflex (ê) e then Alt+9
137 0x89 e-dieresis (ë) e then Alt+3
138 0x8a e-grave (è) e then Alt+8
139 0x8b i-dieresis (ï) i then Alt+3
140 0x8c i-circumflex (î) i then Alt+9
141 0x8d i-grave (ì) i then Alt+8
142 0x8e A-umlaut (Ä) A then Alt+3
143 0x8f A-circle (Å) A then Alt+4
144 0x90 E-acute (é) E then Alt+7
145 0x91 ae (æ) Shft+Alt+I
146 0x92 AE (Æ) Shft+Alt+O
147 0x93 o-circumflex (ô) o then Alt+9
148 0x94 o-umlaut (ö) o then Alt+3
149 0x95 o-grave (ò) o then Alt+8
150 0x96 u-circumflex (û) u then Alt+9
151 0x97 u-grave (ù) u then Alt+8
152 0x98 y-dieresis (ü) y then Alt+3
153 0x99 O-umlaut (Ö) O then Alt+3
154 0x9a U-umlaut (Ü) U then Alt+3
155 0x9b cent (¢) Shft+Alt+$
156 0x9c British pound (£) Shft+Alt+#
157 0x9d Japanese yen (¥) Shft+Alt+@
158 0x9e Pt (&Pt;) Shft+Alt+P
159 0x9f florin? (ƒ) Shft+Alt+%
160 0xa0 a-acute (á) a then Alt+7
161 0xa1 i-acute (í) ?
162 0xa2 o-acute (ó) ?
163 0xa3 u-acute (ú) ?
164 0xa4 n-tilde (ñ) ?
165 0xa5 N-tilde (Ñ) ?
166 0xa6 R-caron (Ř) ?
167 0xa7 r-caron (ř) ?
168 0xa8 inverted question (¿) ?
169 0xa9 right-angle up-left ?
170 0xaa right-angle up-right (¬) ?
171 0xab half (½) ?
172 0xac quarter (¼) ?
173 0xad inverted exclamation (¡) ?
174 0xae left angle quote («) ?
175 0xaf right angle quote (») ?
176 0xb0 full cell quarter shade (░) ?
177 0xb1 full cell half shade (▒) ?
178 0xb2 full cell 3/4 shade (▓) ?
179 0xb3 line drawing: single vertical line ?
180 0xb4 line drawing: single right-center ?
181 0xb5 line drawing: single/double right-center ?
182 0xb6 line drawing: double/single right-center ?
183 0xb7 line drawing: double/single upper-right ?
184 0xb8 line drawing: single/double upper-right ?
185 0xb9 line drawing: double right-center ?
186 0xba line drawing: double vertical line ?
187 0xbb line drawing: double upper-right ?
188 0xbc line drawing: double lower-right ?
189 0xbd line drawing: double/single lower-right ?
190 0xbe line drawing: single/double lower-right ?
191 0xbf line drawing: single upper-right ?
192 0xc0 line drawing: single lower-left ?
193 0xc1 line drawing: single lower-center ?
194 0xc2 line drawing: single upper-center ?
195 0xc3 line drawing: single left-center ?
196 0xc4 line drawing: single horizontal line ?
197 0xc5 line drawing: single center ?
198 0xc6 line drawing: single/double left-center ?
199 0xc7 line drawing: double/single left-center ?
200 0xc8 line drawing: double lower-left ?
201 0xc9 line drawing: double upper-left ?
202 0xca line drawing: double lower-center ?
203 0xcb line drawing: double upper-center ?
204 0xcc line drawing: double left-center ?
205 0xcd line drawing: double horizontal line ?
206 0xce line drawing: double center ?
207 0xcf line drawing: single/double lower-center ?
208 0xd0 line drawing: double/single lower-center ?
209 0xd1 line drawing: single/double upper-center ?
210 0xd2 line drawing: double/single upper-center ?
211 0xd3 line drawing: double/single lower-left ?
212 0xd4 line drawing: single/double lower-left ?
213 0xd5 line drawing: single/double upper-left ?
214 0xd6 line drawing: double-single upper-left ?
215 0xd7 line drawing: double/single center ?
216 0xd8 line drawing: single/double center ?
217 0xd9 line drawing: single lower-right ?
218 0xda line drawing: single upper-left ?
219 0xdb full cell full shade (█) ?
220 0xdc lower-half cell full shade (▄) ?
221 0xdd left-half cell full shade (▌) ?
222 0xde right-half cell full shade (▐) ?
223 0xdf upper-half cell full shade (▀) ?
224 0xe0 A-circumflex (Â) A then Alt+9
225 0xe1 A-grave (À) A then Alt+8
226 0xe2 A-acute (Á) A then Alt+7
227 0xe3 E-circumflex (Ê) E then Alt+9
228 0xe4 E-dieresis (Ë) E then Alt+3
229 0xe5 E-grave (È) E then Alt+8
230 0xe6 I-circumflex (Î} I then Alt+9
231 0xe7 I-grave (Ì) I then Alt+8
232 0xe8 I-acute (Í) I then Alt+7
233 0xe9 I-dieresis (Ï) I then Alt+3
234 0xea O-circumflex (Ô) O then Template:Keyperss
235 0xeb O-grave (Ò) O then Alt+8
236 0xec O-acute (Ó) O then Alt+7
237 0xed U-circumflex (Û) U then Alt+9
238 0xee U-grave (Ù) U then Alt+8
239 0xef U-acute (Ú) U then Alt+7
240 0xf0 Y-dieresis (Ÿ) Y then Alt+3
241 0xf1 y-acute (ý) y then Alt+7
242 0xf2 Y-acute (Ý) Y then Alt+7
243 0xf3 o-slash (ø) o then Alt+2
244 0xf4 O-slash (Ø) O then Alt+2
245 0xf5 o-tilde (õ) o then Alt+1
246 0xf6 O-tilde (Õ) O then Alt+1
247 0xf7 German ss (ß) s then Alt+2
248 0xf8 S-caron (Š) S then Alt+5
249 0xf9 s-caron (š) s then Alt+5
250 0xfa small centered dot (·) Shft+Alt+]
251 0xfb small omecron (none)
252 0xfc large omecrom (none)
253 0xfd degree (°) Shft+Alt+^
254 0xfe centered box Shft+Alt+[
255 0xff cursor (none)