Dmuse: Color and upper-ASCII codes

From CCARH Wiki
Revision as of 20:29, 17 December 2010 by Craig (talk | contribs) (→‎Conversion from Dmuse text files to HTML files)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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. Below is a list of the byte codes used by Dmuse.

Dmuse byte code character mappings

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

Dmuse ASCII Artwork