Dmuse: Color and upper-ASCII codes

From CCARH Wiki
Revision as of 03:55, 6 October 2010 by Craig (talk | contribs) (added keypress symbols)
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 Access by Keyboard
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
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
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 (Ç) ?
129 0x81 u-umlaut (ü) ?
130 0x82 e-acute (é) ?
131 0x83 a-circumflex (â) ?
132 0x84 a-umlaut (ä) ?