Dmuse: Color and upper-ASCII codes

From CCARH Wiki
Jump to navigation Jump to search

The Representation of Color in Dmuse Text Files

Example color codes rendered in Dmuse (.dm, .html).

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 those 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. The table on the right shows the 16 escape codes used by Dmuse to flag these combination changes in a file, along with standard color assignments. <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
char
HTML
Entity
Dmuse key command Character description
Dec Hex
0 0x00 &#0; no character
1 0x01 &#9839; Ctrl+Shft+A musical sharp
2 0x02 &#9837; Ctrl+Shft+B musical flat
3 0x03 &#9838; Ctrl+Shft+C musical natural
4 0x04 &diams; Ctrl+Shft+D centered diamond
5 0x05 &#9115; Ctrl+Shft+E top of the large open parenthesis
6 0x06 &#9117; Ctrl+Shft+F bottom of the large open parenthesis
7 0x07 &bull; Shft+Alt+9 large centered dot
8 0x08 &#9118; Ctrl+Shft+G top of the large close parenthesis
9 0x09 &#9482; Shft+Alt+0 (zero) vertical dotted line, also used to represent
Tab character
10 0x0a &#10; Shft+Alt+- (minus) line feed
11 0x0b © &copy; Ctrl+Shft+K copyright
12 0x0c &#9120; Ctrl+Shft+H bottom of the large close parenthesis
13 0x0d &#13; Ctrl+Shft+L carriage return
14 0x0e &rarr; Ctrl+Shft+M small arrow pointing right
15 0x0f &#9788; Ctrl+Shft+O (letter) sun burst
16 0x10 &#9658; Ctrl+Shft+P large arrow head pointing right
17 0x11 &#9668; Ctrl+Shft+Q large arrow head pointing left
18 0x12 &radic; Ctrl+Shft+R start of small square root character
19 0x13 &#9601; Ctrl+Shft+S top of square root character
20 0x14 &para; Ctrl+Shft+T paragraph
21 0x15 § &sect; Ctrl+Shft+U section
22 0x16 &#9585; Ctrl+Shft+V vertical part of large square root
23 0x17 &#9586; Ctrl+Shft+W start of large square root
24 0x18 &uarr; Ctrl+Shft+X small arrow pointing up
25 0x19 &darr; Ctrl+Shft+Y small arrow pointing down
26 0x1a ± &plusmn; Shft+Alt+= plus or minus
27 0x1b escape character
28 0x1c &larr; Ctrl+Shft+N small arrow pointing left
29 0x1d &harr; (none) arrow both ways
30 0x1e &#9650; Ctrl+Shft+I (letter) large arrow head pointing up
31 0x1f &#9660; Ctrl+Shft+J large arrow head pointing down
32-126 Standard keys Standard ASCII characters
127 0x7f &#8962; Ctrl+Shft+Z house
128 0x80 Ç &Ccedil; C then Alt+2 C-cedilla
129 0x81 ü &uuml; u then Alt+3 u-umlaut
130 0x82 é &eacute; e then Alt+7 e-acute
131 0x83 â &acirc; a then Alt+9 a-circumflex
132 0x84 ä &auml; a then Alt+3 a-umlaut
133 0x85 à &agrave; a then Alt+8 a-grave
134 0x86 å &aring; a then Alt+4 a-circle
135 0x87 ç &ccedil; c then Alt+2 c-cedilla
136 0x88 ê &ecirc; e then Alt+9 e-circumflex
137 0x89 ë &euml; e then Alt+3 e-dieresis
138 0x8a è &egrave; e then Alt+8 e-grave
139 0x8b ï &iuml; i then Alt+3 i-dieresis
140 0x8c î &icirc; i then Alt+9 i-circumflex
141 0x8d ì &igrave; i then Alt+8 i-grave
142 0x8e Ä &Auml; A then Alt+3 A-umlaut
143 0x8f Å &Aring; A then Alt+4 A-circle
144 0x90 é &eacute; E then Alt+7 E-acute
145 0x91 æ &aelig; Shft+Alt+I (letter) ae
146 0x92 Æ &AElig; Shft+Alt+O (letter) AE
147 0x93 ô &ocirc; o then Alt+9 o-circumflex
148 0x94 ö &ouml; o then Alt+3 o-umlaut
149 0x95 ò &ograve; o then Alt+8 o-grave
150 0x96 û &ucirc; u then Alt+9 u-circumflex
151 0x97 ù &ugrave; u then Alt+8 u-grave
152 0x98 ÿ &yuml; y then Alt+3 y-dieresis
153 0x99 Ö &Ouml; O then Alt+3 O-umlaut
154 0x9a Ü &Uuml; U then Alt+3 U-umlaut
155 0x9b ¢ &cent; Shft+Alt+$ cent
156 0x9c £ &pound; Shft+Alt+# British pound
157 0x9d ¥ &yen; Shft+Alt+@ Japanese yen
158 0x9e &#8359; Shft+Alt+P peseta
159 0x9f ƒ &fnof; Shft+Alt+% florin
160 0xa0 á &aacute; a then Alt+7 a-acute
161 0xa1 í &iacute; i then Alt+7 i-acute
162 0xa2 ó &oacute; o then Alt+7 o-acute
163 0xa3 ú &uacute; u then Alt+7 u-acute
164 0xa4 ñ &ntilde; n then Alt+1 n-tilde
165 0xa5 Ñ &Ntilde; N then Alt+1 N-tilde
166 0xa6 Ř &#344; R then Alt+5 R-caron
167 0xa7 ř &#345; r then Alt+5 r-caron
168 0xa8 ¿ &#0191; Shft+Alt+? inverted question
169 0xa9 &#8976; Alt+= right-angle up-left
170 0xaa ¬ &#172; Alt+- right-angle up-right
171 0xab ½ &frac12; Shft+Alt+* half
172 0xac ¼ &frac14; Shft+Alt+& quarter
173 0xad ¡ &iexcl; Shft+Alt+! inverted exclamation
174 0xae « &laquo; Shft+Alt+< left angle quote
175 0xaf » &raquo; Shft+Alt+> right angle quote
176 0xb0 &#9617; Alt+o full cell quarter shade
177 0xb1 &#9618; Alt+p full cell half shade
178 0xb2 &#9619; Alt+[ full cell 3/4 shade
179 0xb3 &#9474; Alt+f line drawing: single vertical line
180 0xb4 &#9508; Alt+d line drawing: single right-center
181 0xb5 &#9569; Shft+Alt+J line drawing: single/double right-center
182 0xb6 &#9570; Shft+Alt+D line drawing: double/single right-center
183 0xb7 &#9558; Shft+Alt+E line drawing: double/single upper-right
184 0xb8 &#9557; Shft+Alt+U line drawing: single/double upper-right
185 0xb9 &#9571; Alt+j line drawing: double right-center
186 0xba &#9553; Alt+k line drawing: double vertical line
187 0xbb &#9559; Alt+u line drawing: double upper-right
188 0xbc &#9565; Alt+m line drawing: double lower-right
189 0xbd &#9564; Shft+Alt+C line drawing: double/single lower-right
190 0xbe &#9563; Shft+Alt+M line drawing: single/double lower-right
191 0xbf &#9488; Alt+e line drawing: single upper-right
192 0xc0 &#9492; Alt+z line drawing: single lower-left
193 0xc1 &#9524; Alt+x line drawing: single lower-center
194 0xc2 &#9516; Alt+w line drawing: single upper-center
195 0xc3 &#9500; Alt+a line drawing: single left-center
196 0xc4 &#9472; Alt+r line drawing: single horizontal line
197 0xc5 &#9532; Alt+s line drawing: single center
198 0xc6 &#9566; Shft+Alt+G line drawing: single/double left-center
199 0xc7 &#9567; Shft+Alt+A line drawing: double/single left-center
200 0xc8 &#9562; Alt+b line drawing: double lower-left
201 0xc9 &#9556; Alt+t line drawing: double upper-left
202 0xca &#9577; Alt+n line drawing: double lower-center
203 0xcb &#9574; Alt+y line drawing: double upper-center
204 0xcc &#9568; Alt+g line drawing: double left-center
205 0xcd &#9552; Alt+i line drawing: double horizontal line
206 0xce &#9580; Alt+h line drawing: double center
207 0xcf &#9575; Shft+Alt+N line drawing: single/double lower-center
208 0xd0 &#9576; Shft+Alt+X line drawing: double/single lower-center
209 0xd1 &#9572; Shft+Alt+Y line drawing: single/double upper-center
210 0xd2 &#9573; Shft+Alt+W line drawing: double/single upper-center
211 0xd3 &#9561; Shft+Alt+Z line drawing: double/single lower-left
212 0xd4 &#9560; Shft+Alt+B line drawing: single/double lower-left
213 0xd5 &#9554; Shft+Alt+T line drawing: single/double upper-left
214 0xd6 &#9555; Shft+Alt+Q line drawing: double-single upper-left
215 0xd7 &#9579; Shft+Alt+S line drawing: double/single center
216 0xd8 &#9578; Shft+Alt+H line drawing: single/double center
217 0xd9 &#9496; Alt+c line drawing: single lower-right
218 0xda &#9484; Alt+q line drawing: single upper-left
219 0xdb &#9608; Alt+] full cell full shade
220 0xdc &#9604; Alt+; lower-half cell full shade
221 0xdd &#9612; Alt+, left-half cell full shade
222 0xde &#9616; Alt+. right-half cell full shade
223 0xdf &#9600; Alt+l upper-half cell full shade
224 0xe0 Â &Acirc; A then Alt+9 A-circumflex
225 0xe1 À &Agrave; A then Alt+8 A-grave
226 0xe2 Á &Aacute; A then Alt+7 A-acute
227 0xe3 Ê &Ecirc; E then Alt+9 E-circumflex
228 0xe4 Ë &Euml; E then Alt+3 E-dieresis
229 0xe5 È &Egrave; E then Alt+8 E-grave
230 0xe6 Î &Icirc; I then Alt+9 I-circumflex
231 0xe7 Ì &Igrave; I then Alt+8 I-grave
232 0xe8 Í &Iacute; I then Alt+7 I-acute
233 0xe9 Ï &Iuml; I then Alt+3 I-dieresis
234 0xea Ô &Ocirc; O then Alt+9 O-circumflex
235 0xeb Ò &Ograve; O then Alt+8 O-grave
236 0xec Ó &Oacute; O then Alt+7 O-acute
237 0xed Û &Ucirc; U then Alt+9 U-circumflex
238 0xee Ù &Ugrave; U then Alt+8 U-grave
239 0xef Ú &Uacute; U then Alt+7 U-acute
240 0xf0 Ÿ &Yuml; Y then Alt+3 Y-dieresis
241 0xf1 ý &yacute; y then Alt+7 y-acute
242 0xf2 Ý &Yacute; Y then Alt+7 Y-acute
243 0xf3 ø &oslash; o then Alt+2 o-slash
244 0xf4 Ø &Oslash; O then Alt+2 O-slash
245 0xf5 õ &otilde; o then Alt+1 o-tilde
246 0xf6 Õ &Otilde; O then Alt+1 O-tilde
247 0xf7 ß &szlig; s then Alt+2 German ss
248 0xf8 Š &#352; S then Alt+5 S-caron
249 0xf9 š &#353; s then Alt+5 s-caron
250 0xfa · &#183; Shft+Alt+] small centered dot
251 0xfb Φ &Phi; (none) small capital phi
252 0xfc Φ &Phi; (none) large capital phi
253 0xfd ° &deg; Shft+Alt+^ degree
254 0xfe &#9726; Shft+Alt+[ centered box
255 0xff &#9602; (none) cursor


The following screen shot of Dmuse show the contents of this .dm file (HTML conversion) which contains a list of each byte code as it is displayed in Dmuse (when the Dmuse fonts have been installed correctly for X11).

Dmuse-bytecodes.png

Conversion from Dmuse text files to HTML files

This PERL program can be used to convert files using Dmuse byte code representation and color escape codes into a visually similar HTML file. Not all of the Unicode characters which map into Dmuse characters have fixed-width forms, so there may be slight mis-alignment between characters in the same column. Here are example files and screenshots of the Dmuse and HTML files:

boxtest.dm as displayed in Dmuse.
boxtest.html as displayed in Firefox.

The program can be run from the command-line in a unix-style computer terminal like this:

    ./dmuse2html file.dm > file.html