Common Lisp the Language, 2nd Edition


next up previous contents index
Next: Sequences Up: Characters Previous: Character Conversions

13.5. Character Control-Bit Functions

old_change_begin
Common Lisp provides explicit names for four bits of the bits attribute: Control, Meta, Hyper, and Super. The following definitions are provided for manipulating these. Each Common Lisp implementation provides these functions for compatibility, even if it does not support any or all of the bits named below.


[Constant]
char-control-bit
char-meta-bit
char-super-bit
char-hyper-bit

The values of these named constants are the ``weights'' (as integers) for the four named control bits. The weight of the control bit is 1; of the meta bit, 2; of the super bit, 4; and of the hyper bit, 8.

If a given implementation of Common Lisp does not support a particular bit, then the corresponding constant is zero instead.
old_change_end

change_begin
X3J13 voted in March 1989 (CHARACTER-PROPOSAL)   to eliminate all four of the constants char-control-bit, char-meta-bit, char-super-bit, and char-hyper-bit.

When Common Lisp was first designed, keyboards with ``extra bits'' were relatively rare. The bits attribute was originally designed to support input from keyboards in use at Stanford and M.I.T. circa 1981.

Since that time such extended keyboards have come into wider use. Notable here are the keyboards associated with certain personal computers and workstations. For example, in some specific applications the command and option keys of Apple Macintosh keyboards have had the connotations of control and meta. Macintosh II extended keyboards also have keys marked control whose use is analogous to that of hyper on the old M.I.T. keyboards. IBM PC personal computer keyboards have alt keys that function much like meta keys; similarly, keyboards on Sun workstations have keys very much like meta keys but labelled left and right.
change_end

old_change_begin

[Function]
char-bit char name

char-bit takes a character object char and the name of a bit, and returns non-nil if the bit of that name is set in char, or nil if the bit is not set in char. For example:

(char-bit #\Control-X :control) => true

Valid values for name are implementation-dependent, but typically are :control, :meta, :hyper, and :super. It is an error to give char-bit the name of a bit not supported by the implementation.

If the argument char is specified by a form that is a place form acceptable to setf, then setf may be used with char-bit to modify a bit of the character stored in that place. The effect is to perform a set-char-bit operation and then store the result back into the place.
old_change_end

change_begin
X3J13 voted in March 1989 (CHARACTER-PROPOSAL)   to eliminate char-bit.
change_end

old_change_begin

[Function]
set-char-bit char name newvalue

char-bit takes a character object char, the name of a bit, and a flag. A character is returned that is just like char except that the named bit is set or reset according to whether newvalue is non-nil or nil. Valid values for name are implementation-dependent, but typically are :control, :meta, :hyper, and :super. For example:

(set-char-bit #\X :control t) => #\Control-X 
(set-char-bit #\Control-X :control t) => #\Control-X 
(set-char-bit #\Control-X :control nil) => #\X

old_change_end

change_begin
X3J13 voted in March 1989 (CHARACTER-PROPOSAL)   to eliminate set-char-bit.
change_end



next up previous contents index
Next: Sequences Up: Characters Previous: Character Conversions


AI.Repository@cs.cmu.edu