1
0
Fork 0
cl-sites/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node140.html

121 lines
6.8 KiB
HTML
Raw Normal View History

2023-10-25 11:23:21 +02:00
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>13.5. Character Control-Bit Functions</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Character Control-Bit Functions">
<meta name="keywords" value="clm">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<b>Common Lisp the Language, 2nd Edition</b>
<BR> <HR><A NAME=tex2html3272 HREF="node141.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3270 HREF="node135.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3266 HREF="node139.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3274 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3275 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3273 HREF="node141.html"> Sequences</A>
<B>Up:</B> <A NAME=tex2html3271 HREF="node135.html"> Characters</A>
<B> Previous:</B> <A NAME=tex2html3267 HREF="node139.html"> Character Conversions</A>
<HR> <P>
<H1><A NAME=SECTION001750000000000000000>13.5. Character Control-Bit Functions</A></H1>
<P>
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
Common Lisp provides explicit names for four bits of the bits attribute:
<i>Control</i>, <i>Meta</i>, <i>Hyper</i>, and <i>Super</i>. 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.
<P>
<BR><b>[Constant]</b><BR>
<tt>char-control-bit</tt> <tt><BR></tt><tt>char-meta-bit</tt> <tt><BR></tt><tt>char-super-bit</tt> <tt><BR></tt><tt>char-hyper-bit</tt><P>The values of these named constants are the ``weights'' (as integers) for
the four named control bits. The weight of the control bit is <tt>1</tt>;
of the meta bit, <tt>2</tt>; of the super bit, <tt>4</tt>; and of the hyper bit, <tt>8</tt>.
<P>
If a given implementation of Common Lisp does not support a particular bit,
then the corresponding constant is zero instead.
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=15068>&#160;</A>
to eliminate all four of the constants
<tt>char-control-bit</tt>, <tt>char-meta-bit</tt>, <tt>char-super-bit</tt>,
and <tt>char-hyper-bit</tt>.
<P>
<P>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.
<P>
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 <i>command</i> and <i>option</i> keys of Apple Macintosh keyboards have
had the connotations of <i>control</i> and <i>meta</i>. Macintosh II
extended keyboards also have keys marked <i>control</i> whose use
is analogous to that of <i>hyper</i> on the old M.I.T. keyboards.
IBM PC personal computer keyboards have <i>alt</i> keys that function
much like <i>meta</i> keys; similarly, keyboards on Sun workstations
have keys very much like <i>meta</i> keys but labelled <i>left</i> and <i>right</i>.
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
<BR><b>[Function]</b><BR>
<tt>char-bit <i>char</i> <i>name</i></tt><P><tt>char-bit</tt> takes a character object <i>char</i> and the name of a bit,
and returns non-<tt>nil</tt> if the bit of that name is set in <i>char</i>,
or <tt>nil</tt> if the bit is not set in <i>char</i>.
For example:
<P><pre>
(char-bit #\Control-X <tt>:control</tt>) => <i>true</i>
</pre><P>
Valid values for <i>name</i>
are implementation-dependent, but typically are <tt>:control</tt>,
<tt>:meta</tt>, <tt>:hyper</tt>, and <tt>:super</tt>.
It is an error to give <tt>char-bit</tt> the name of a bit not supported
by the implementation.
<P>
If the argument <i>char</i> is specified by a form that is a <i>place</i> form
acceptable to <tt>setf</tt>,
then <tt>setf</tt> may be used with <tt>char-bit</tt>
to modify a bit of the character stored in that
<i>place</i>.
The effect is to perform a <tt>set-char-bit</tt> operation
and then store the result back into the <i>place</i>.
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=15117>&#160;</A>
to eliminate <tt>char-bit</tt>.
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
<BR><b>[Function]</b><BR>
<tt>set-char-bit <i>char</i> <i>name</i> <i>newvalue</i></tt><P><tt>char-bit</tt> takes a character object <i>char</i>, the name of a bit,
and a flag. A character is returned that is just like <i>char</i>
except that the named bit is set or reset according to whether
<i>newvalue</i> is non-<tt>nil</tt> or <tt>nil</tt>.
Valid values for <i>name</i>
are implementation-dependent, but typically are <tt>:control</tt>,
<tt>:meta</tt>, <tt>:hyper</tt>, and <tt>:super</tt>.
For example:
<pre>
(set-char-bit #\X <tt>:control</tt> t) => #\Control-X
(set-char-bit #\Control-X <tt>:control</tt> t) => #\Control-X
(set-char-bit #\Control-X <tt>:control</tt> <tt>nil</tt>) => #\X
</pre>
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=15148>&#160;</A>
to eliminate <tt>set-char-bit</tt>.
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<P>
<BR> <HR><A NAME=tex2html3272 HREF="node141.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3270 HREF="node135.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3266 HREF="node139.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3274 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3275 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3273 HREF="node141.html"> Sequences</A>
<B>Up:</B> <A NAME=tex2html3271 HREF="node135.html"> Characters</A>
<B> Previous:</B> <A NAME=tex2html3267 HREF="node139.html"> Character Conversions</A>
<HR> <P>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>