id
int64 0
45.1k
| file_name
stringlengths 4
68
| file_path
stringlengths 14
193
| content
stringlengths 32
9.62M
| size
int64 32
9.62M
| language
stringclasses 1
value | extension
stringclasses 6
values | total_lines
int64 1
136k
| avg_line_length
float64 3
903k
| max_line_length
int64 3
4.51M
| alphanum_fraction
float64 0
1
| repo_name
stringclasses 779
values | repo_stars
int64 0
882
| repo_forks
int64 0
108
| repo_open_issues
int64 0
90
| repo_license
stringclasses 8
values | repo_extraction_date
stringclasses 146
values | sha
stringlengths 64
64
| __index_level_0__
int64 0
45.1k
| exdup_ids_cmlisp_stkv2
sequencelengths 1
47
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
21,991 | index.html | rheaplex_minara/lib/cl-utilities/doc/index.html | <html>
<head>
<title>cl-utilities manual</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<h1>cl-utilities manual</h1>
<p>Everybody writes some utilities because they're not part of the
standard but they're so broadly useful. This results in a lot of wheel
reinvention, and most reinventions are not as good as they should
be. The cl-utilities project is an actively maintained collection of
some of these utilities, with high-quality public-domain
implementations and decent documentation.
<h2>Table of contents:</h2>
<ul style="list-style-type: none;">
<li><a href="split-sequence.html">SPLIT-SEQUENCE, SPLIT-SEQUENCE-IF,
SPLIT-SEQUENCE-IF-NOT</a>. Used for splitting sequences.</li>
<li><a href="extremum.html">EXTREMUM, EXTREMA,
N-MOST-EXTREME</a>: Finding extreme values in sequences based on
user-defined criteria.</li>
<li><a href="read-delimited.html">READ-DELIMITED</a> reads from a
sequence delimited somehow, in a somewhat inconvenient but hopefully
efficient way.</li>
<li><a href="expt-mod.html">EXPT-MOD</a>, an interface for calculating
<tt>(mod (expt n e) m)</tt> efficiently across implementations.</li>
<li><a href="with-unique-names.html">WITH-UNIQUE-NAMES, née
WITH-GENSYMS</a>. A classic macro-writing macro for preventing
variable capture.</li>
<li><a href="collecting.html">COLLECTING, WITH-COLLECTORS</a>. Some
macros for clearly and efficiently collecting items into lists.</li>
<li><a href="once-only.html">ONCE-ONLY</a>, a classic macro-writing
macro for preventing multiple evaluation.</li>
<li><a href="rotate-byte.html">ROTATE-BYTE</a> rotates bits in a byte</li>
<li><a href="copy-array.html">COPY-ARRAY</a> shallow copies arrays.</li>
<li><a href="compose.html">COMPOSE</a>. Composes functions.</li>
</ul>
<p><hr>Public domain, maintained by <a
href="mailto:[email protected]">Peter Scott</a>. For more information, see
the <a href="http://common-lisp.net/project/cl-utilities/">home page</a>.
</body>
</html> | 2,004 | Common Lisp | .l | 41 | 47.390244 | 76 | 0.760657 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 7073244946929267a68cc86c88400d2bfb9d5a840ddbb6010c4b2ee3179f9131 | 21,991 | [
-1
] |
22,010 | Makefile | rheaplex_minara/lib/babel/doc/Makefile | # -*- Mode: Makefile; tab-width: 4; indent-tabs-mode: t -*-
MANUAL := "babel"
SYSTEM := "babel"
PACKAGES := babel babel-encodings
TITLE := "Babel Manual"
CSS := "default"
export LISP ?= sbcl
export SBCL_OPTIONS ?= --noinform
.PHONY: all clean html pdf upload
all:
mkmanual all $(SYSTEM) $(MANUAL) $(TITLE) $(CSS) $(PACKAGES)
pdf:
mkmanual pdf $(SYSTEM) $(MANUAL) $(TITLE) $(CSS) $(PACKAGES)
html:
mkmanual html $(SYSTEM) $(MANUAL) $(TITLE) $(CSS) $(PACKAGES)
upload:
# rsync -av --delete -e ssh manual common-lisp.net:/project/FOO/public_html/
# scp -r manual common-lisp.net:/project/cffi/public_html/
clean:
find . \( -name "*.pdf" -o -name "*.html" -o -name "*.info" -o -name "*.aux" -o -name "*.cp" -o -name "*.fn" -o -name "*.fns" -o -name "*.ky" -o -name "*.log" -o -name "*.pg" -o -name "*.toc" -o -name "*.tp" -o -name "*.vr" -o -name "*.dvi" -o -name "*.cps" -o -name "*.vrs" \) -exec rm {} \;
rm -rf include manual
# vim: ft=make ts=4 noet
| 964 | Common Lisp | .l | 22 | 42.181818 | 293 | 0.622722 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | f69be63459bd4b6c67e013b300a9194bd3bbc52d383175b0c59edd3daf2692f7 | 22,010 | [
-1
] |
22,024 | Makefile | rheaplex_minara/lib/flexichain/Doc/Makefile | NAME=flexichain
TEXFILES=$(NAME).tex $(shell ./tex-dependencies $(NAME).tex)
PSTEX_T=$(shell ./strip-dependence inputfig $(TEXFILES))
VERBATIM=$(shell ./strip-dependence verbatimtabinput $(TEXFILES))
PSTEX=$(subst .pstex_t,.pstex,$(PSTEX_T))
all : $(NAME).ps
%.pstex: %.fig
fig2dev -Lpstex -m 0.75 $< $@
%.pstex_t: %.fig %.pstex
fig2dev -Lpstex_t -m 0.75 -p $(basename $<).pstex $< $@
$(NAME).dvi: $(TEXFILES) $(PSTEX_T) $(VERBATIM)
latex $<
makeindex $(NAME)
latex $<
$(NAME).ps: $(NAME).dvi $(PSTEX)
dvips $< -o
view: $(NAME).ps
gv -antialias -scale 1 $<
clean:
rm -f *.aux *.log *~
spotless:
make clean
rm -f *.ps *.dvi *.pstex *.pstex_t *.toc *.idx *.ilg *.ind *.fig.bak
| 696 | Common Lisp | .l | 23 | 28.391304 | 69 | 0.645551 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 6e7674f66dfe6ba81c6c81bfa482e8ba3e2d86e54bf0b04d409389caf9309164 | 22,024 | [
-1
] |
22,025 | circular.fig | rheaplex_minara/lib/flexichain/Doc/circular.fig | #FIG 3.2
Landscape
Center
Inches
Letter
100.00
Single
-2
1200 2
1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 1800 1200 900 300 1800 1200 2700 1500
1 1 0 1 0 7 50 0 -1 0.000 1 0.0000 1800 1500 900 300 1800 1500 2700 1800
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2
900 1200 900 1500
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2
2700 1200 2700 1500
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2
900 2400 900 2700
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2
945 1300 945 1600
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2
1020 1360 1020 1660
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2
980 1075 980 1375
2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2
1060 1040 1060 1340
| 631 | Common Lisp | .l | 25 | 23.6 | 72 | 0.648515 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | ce67191a0a4b4b4d6f71b5b10db6bba652370b974c0f7bdf9f5b97c117b20bb3 | 22,025 | [
-1
] |
22,026 | flexichain.tex | rheaplex_minara/lib/flexichain/Doc/flexichain.tex | \documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{alltt}
\usepackage{moreverb}
\usepackage{epsfig}
\usepackage{makeidx}
\usepackage{changebar}
\setlength{\parskip}{0.3cm}
\setlength{\parindent}{0cm}
\def\inputfig#1{\input #1}
\def\inputtex#1{\input #1}
\input spec-macros.tex
\makeindex
\begin{document}
\section{The \texttt{flexichain} protocol}
In this section, we describe the \texttt{flexichain} protocol,
allowing client code to dynamically add elements to, and delete
elements from a sequence (or chain) of such elements.
\subsection{The concept of a position}
A flexichain uses the concept of a ``position'', which has two
different meanings in different contexts.
The first meaning is the position at which an element is located in
the chain. In this context, the position must have a value between 0
and $l-1$, where $l$ is the length of the chain. This meaning is used
when an element is to be deleted or when an element is accessed or
replaced.
The second meaning is the position \textit{between two
elements} (or at one of the extreme ends of the chain).
In this context, the position may have a value between 0 and the
length of the chain inclusive. The position 0 means the beginning of
the chain (before the first element, if any), and the
position equal to the length means the end of the chain
(after the last element if any). This meaning is used when an element
is to be inserted.
\subsection{Performance}
Accessing and replacing an element are constant-time operations.
We guarantee linear average complexity of a sequence of insert and
delete operations provided that the position of two successive
operations in the sequence is bounded.
More specifically, the average complexity of an operation is
proportional to the difference between the position of the operation
and the position of the previous operation.
Here we actually consider distance modulo the length of the chain so
that the distance between the last position and the first is $1$.
In particular, the longest possible distance between to operations is
half of the number of elements in the chain.
The implementation will allocate more space than is necessary.
Whenever space runs out, we allocate a bigger chunk of memory to hold
the elements. The new chunk size will be $lk$, were $l$ again is the
length of the chain and $k$ is a \textit{constant factor}. We
multiply rather than add, because we want to guarantee the linear
average complexity of a sequence of insert and delete
operations. Typically, $k$ is somewhere between $1.5$ and $2$. The
default value is $k=1.5$.
We shrink the space whenever the length of the chain (the number of
elements) is significantly smaller than the available space. By
default, the definition of ``significantly'' is that the ratio of
length to size must be less than $1/k^2$ in order for the space to be
shrunk. Again, the new chunk size will be $lk$.
Using the default value of $k$, this means that the amount of wasted
space can be as large as the length of the chain in the worst case,
but for a sequence of insert operations, the average wasted space is
only 25\%.
Applications that store a number of elements that does not vary much,
can choose a small value for the $k$ to waste less space. Such
applications will have to resize the space relatively rarely so
performance will not be affected by small values of $k$.
The space will not shrink below a minimum size (default $5$
elements). The reason for this is to avoid to many resize operations
for small chains. It is probably not reasonable to use a value below
around $5$, since the bookkeeping information takes up at least this
much space. This value is also used for the initial size of the
chain. Applications that will typically store a large number of
elements can choose a greater value for the minimum size. Doing so
also improves performance since fewer resize operations will have to
be executed.
\subsection{Protocol classes and functions}
Many names of operations in this section have a terminatin
``\texttt{*}'' which is meant to suggest a \emph{spread} version of
the operation. Later (in the \texttt{flexicursor} section) we give
\emph{nospread} versions of the operations.
\Defprotoclass {flexichain}
The protocol class for flexichains.
\definitarg {:initial-contents}
\definitarg {:element-type}
\definitarg {:fill-element}
\definitarg {:expand-factor}
\Definitarg {:min-size}
All instantiable subclasses of \cl{flexichain} accept these
initargs.
The \cl{:initial-contents} initarg is a sequence (list, vector,
string) of objects to be stored in the \cl{flexichain} from the start.
The \cl{:element-type} initarg determines the type of the elements of
the \cl{flexichain} (default is \cl{t}).
The \cl{:fill-element} initarg should be an object that is compatible
with the \cl{:element-type} initarg and will be used to fill
unoccupied space in the chain (to help the garbage
collector). The default value for this initarg will be supplied by
the implementation according to the element-type given. The
implementation will test \cl{nil}, \cl{0}, and \cl{\#$\backslash$a}.
If none of these values will work, the client must supply a value that
is compatible with \cl{:element-type}.
The \cl{:expand-factor} initarg is used to determine the factor by
which the available space will be multiplied whenever the space for
the chain is full. Default value is $1.5$.
The \cl{:min-size} initarg determines the smallest space allocated to
hold elements of the chain. Default value is $5$. It is not
reasonable to supply values smaller than $5$.
The instance created by make-instance will have a length which is that
of the sequence given by \cl{:initial-contents} or $0$ if no
\cl{:initial-contents} was given.
\Defclass {standard-flexichain}
The standard instantiable subclass of \cl{flexichain}.
\Defgeneric {nb-elements} {chain}
Return the number of elements in the flexichain \arg{chain}.
\Deferror {flexi-error}
The base condition for all conditions that may be signaled by the
operations on flexichains.
\Deferror {flexi-position}
This condition will be signaled by operations that require a position
argument whenever that argument is out of range.
\defgeneric {insert*} {chain position object}
Insert an object at \arg{position} of the flexichain. If
\arg{position} is out of range (less than $0$ or greater than the
length of \arg{chain}), the \cl{flexi-position} condition will be
signaled.
\Defgeneric {delete*} {chain position}
Delete an element at \arg{position} of the flexichain. If
\arg{position} is out of range (less than $0$ or greater than or equal
to the length of \arg{chain}), the \cl{flexi-position} condition will be
signaled.
\Defgeneric {element*} {chain position}
Return the element at \arg{position} of the \arg{chain}. If
\arg{position} is out of range (less than $0$ or greater than or equal
to the length of \arg{chain}), the \cl{flexi-position} condition will be
signaled.
\Defgeneric {(setf element*)} {object chain position}
Replace the element at \arg{position} of \arg{chain} by \arg{object}.
If \arg{position} is out of range (less than $0$ or greater than or
equal to the length of \arg{chain}), the \cl{flexi-position} condition
will be signaled.
\subsection{Stack and queue operations}
A \texttt{flexichain} can be used as a stack or as a queue with very good
performance. In this section, we suggest a set of operations to
facilitate such use.
\Defgeneric {push-start} {chain object}
Insert an object at the beginning of the chain.
\Defgeneric {push-end} {chain object}
Insert an object at the end of the chain.
\Defgeneric {pop-start} {chain}
Pop and return the element at the beginning of the \texttt{chain}
\Defgeneric {pop-end} {chain}
Pop and return the element at the end of the \texttt{chain}
\Defgeneric {rotate} {chain \optional (n 1)}
Rotate the elements of the \texttt{chain} so that the element that used
to be at position $n$ now is at position $0$. With a negative value
of $n$ rotate the elements so that the element that used to be at
position $0$ now is at position $n$. When the magnitude of $n$ is
greater than the length of the \texttt{chain}, the operation wraps
around so that it becomes equivalent to the same operation with a
value of $n$ modulo the length. When the length of the \texttt{chain}
is less than $2$, this function does nothing.
\section{Implementation of the \texttt{flexichain} protocol}
\subsection{Representation}
We keep elements in a vector treated as a circular gap buffer with two
sentinel elements, one before the first element of the chain (with a
position of $-1$), and one after the last element of the chain (with a
position equal to the length of the chain). We use the word
\textit{position} to refer to the abstract position of an element in a
flexichain, and the word \textit{index} when we talk about indexes of
the gap buffer used in the implementation. We say that an index $i$
is \emph{valid} if $0 \le i < l$ where $l$ is the size of the vector
(the vector is never of size $0$, so it is always the case that $l >
0$).
We use the term \emph{extended element} to mean a user element or a
sentinel.
We say that the vector is \textit{full} when it contains as many
extended elements as its length (i.e., the gap has a size of $0$), and
\textit{empty} when it contains no user elements (and thus only the
sentinels) (i.e., the gap is the size as the vector minus
2).
There are three different possible configurations of the gap with
respect to the data. Figure \ref{fig-both-contiguous} shows the case
where both the gap and the data are contiguous. Figure
\ref{fig-data-not-contiguous} shows the case where the data is not
contiguous. Finally, figure \ref{fig-gap-not-contiguous} shows the
case where the gap is not contiguous.
\begin{figure}
\begin{center}
\inputfig{gap1.pstex_t}
\end{center}
\caption{\label{fig-both-contiguous} Gap and data are both contiguous}
\end{figure}
\begin{figure}
\begin{center}
\inputfig{gap2.pstex_t}
\end{center}
\caption{\label{fig-data-not-contiguous} Data is not contiguous}
\end{figure}
\begin{figure}
\begin{center}
\inputfig{gap3.pstex_t}
\end{center}
\caption{\label{fig-gap-not-contiguous} Gap is not contiguous}
\end{figure}
The implementation of a flexichain allows for the first element (i.e.,
the first sentinel with a position of $-1$) to be located at any valid
index of the vector. For that reason, we need an index (called
\texttt{data-start}) which always indicates the index of the first
sentinel i.e.. \texttt{data-start} is always a valid index
A \textit{positional index} is an index in the vector that corresponds
to a position in the flexichain, and so is an index either of a user
object or the index of the last sentinel.
We introduce two different indexes (always valid as well),
\texttt{gap-start} and \texttt{gap-end}. The \texttt{gap-start} index
is the first index of the gap. When the vector is not full, the
\texttt{gap-start} is always an index containing no extended element,
such that the previous index does contain an extended element. The
\texttt{gap-end} index is the first index beyond the gap and is always
the index of an extended element. When the vector is not full, the
previous index does not contain an extended element. Notice that for
certain configurations \texttt{gap-start} is smaller than
\texttt{gap-end} and for certain other configurations, the reverse is
true.
When the vector is full, \texttt{gap-start} and \texttt{gap-end} are
always equal.
\subsection{Computing and index from a position}
Step one in inserting or deleting an element is to determine an index
corresponding to the position. Here is how it is done: we compute a
value $s$ which is equal to \texttt{gap-start} if \texttt{gap-start}
is greater than \texttt{data-start}. Otherwise $s$ is equal to
\texttt{gap-start} plus the size of the vector. The position is added
to \texttt{data-start}, giving the value $i$. If $i$ is greater than
or equal to $s$, the size of the gap is added to $i$. Finally, if $i$
is greater than or equal to the length of the vector, the length of
the vector is subtracted from $i$ (prove that the result is always a
positional index). Call this final value of $i$ the \textit{hot
spot}.
\subsection{Moving the gap to the right place}
After determining the index from a position, we need to determine
whether the gap is in the right place. This is the case if and only
if the hot spot is equal to \texttt{gap-end}. If that is not the
case, we need to move the gap.
There is a case when it is particularly simple to move the gap, namely
when the vector is full. In that case, we can just assign both
\texttt{gap-start} and \texttt{gap-end} to the value of the hot spot.
There are two ways of getting \texttt{gap-end} to be equal to the hot
spot either move everything to the left of the hot spot even further
left, or everything to the right of the hot spot (including the hot
spot itself) even further right. We always do the one that requires
the fewest elements to be moved. One solution will require fewer than
half the elements to be moved and the other one at least half.
Moving to the right will require that a number of elements equal to
the difference between \texttt{gap-start} and the hot spot to be
moved, provided that \texttt{gap-start} is greater than the hot spot.
If \texttt{gap-start} is smaller than the hot spot, it is that
difference plus the size of the vector. We check whether that value is
smaller than half of \texttt{nb-elements}.
Moving the elements requires one, two, or three calls to \cl{replace}.
\subsubsection{Moving elements to the left}
Let us first consider the case of moving elements to the left.
Case 1: If the entire contiguous gap is to the left of the hot spot
(as in the upper half of figure \ref{fig-both-contiguous} or as in
figure \ref{fig-data-not-contiguous} with the hot spot to the right of
the gap), a single call is required.
Case 2:A single call is also required if the highest valid index is
inside the gap (as in the lower part of figure
\ref{fig-both-contiguous} and in figure \ref{fig-gap-not-contiguous})
provided that the number of elements to be moved is no greater than
the part of the gap that is flush right in the vector.
Case 3: Two calls are needed if the highest valid index is inside the
gap (as in the lower part of figure \ref{fig-both-contiguous} and in
figure \ref{fig-gap-not-contiguous}), but the number of elements to be
moved is greater than the part of the gap that is flush right in the
vector. The first call will fill the part of the gap that is flush
right in the vector, giving the situation of the upper half of figure
\ref{fig-both-contiguous}. The second call will be as in case 1
above.
Case 4: Two calls are also needed if the data is not contiguous (as in
figure \ref{fig-data-not-contiguous}) and the entire contiguous gap is
to the right of the hot spot, but the number of elements to the left
of the hot spot (i.e., the index of the hot spot before the move) is
no greater than the size of the gap. The first call will move
everything to the right of the gap so that the gap will be flush right
as in case 2 above. The second call will move the remaining
elements.
Case 5: Three calls are needed if the data is not contiguous (as in
figure \ref{fig-data-not-contiguous}) and the entire contiguous gap is
to the right of the hot spot, but the number of elements to the left
of the hot spot (i.e., the index of the hot spot before the move) is
greater than the size of the gap. The first call will move the gap
flush right, creating the situation of case 3 above (which then
requires another two calls).
\subsubsection{Moving elements to the right}
Let us now consider moving elements to the right.
Case 1: If the entire contiguous gap is to the right of the hot spot
(as in the lower half of figure \ref{fig-both-contiguous} or as in
figure \ref{fig-data-not-contiguous} with the hot spot to the left of
the gap), a single call is required.
Case 2:A single call is also required if the index 0 is
inside the gap (as in the higher part of figure
\ref{fig-both-contiguous} and in figure \ref{fig-gap-not-contiguous})
provided that the number of elements to be moved is no greater than
the part of the gap that is flush left in the vector.
Case 3: Two calls are needed if index 0 is inside the gap (as in the
lower part of figure \ref{fig-both-contiguous} and in figure
\ref{fig-gap-not-contiguous}), but the number of elements to be moved
is greater than the part of the gap that is flush left in the vector.
The first call will fill the part of the gap that is flush left in
the vector, giving the situation of the lower half of figure
\ref{fig-both-contiguous}. The second call will be as in case 1
above.
Case 4: Two calls are also needed if the data is not contiguous (as in
figure \ref{fig-data-not-contiguous}) and the entire contiguous gap is
to the left of the hot spot, but the number of elements to the right
of the hot spot (i.e., the index of the hot spot before the move) is
no greater than the size of the gap. The first call will move
everything to the left of the gap so that the gap will be flush left
as in case 2 above. The second call will move the remaining
elements.
Case 5: Three calls are needed if the data is not contiguous (as in
figure \ref{fig-data-not-contiguous}) and the entire contiguous gap is
to the left of the hot spot, but the number of elements to the right
of the hot spot is greater than the size of the gap. The first call
will move the gap flush left, creating the situation of case 3 above
(which then requires another two calls).
\subsection{Increasing the size of the vector}
We increase the size of the vector whenever it is full and another
element needs to be added.
When this call is made, \texttt{gap-start} and \texttt{gap-end} have
the same value. We must preserve the position of the gap in the new
vector.
A new vector with the size of the number of required elements
multiplied by \texttt{size-multiplier} is first allocated.
Next, we copy (using a single call to \cl{replace}) all elements
before the gap to the start of the new vector. Then we copy (using
another single call to \cl{replace}) all elements after the gap to the
end of the new vector. The value of \texttt{gap-end} is incremented by
the difference in size of the two vectors, as is \texttt{data-start}
if it was greater than or equal to \texttt{gap-end}.
\subsection{Decreasing the size of the vector}
Again, a new vector with the size of the number of required elements
multiplied by \texttt{size-multiplier} is first allocated.
Next, we copy (using a single call to \cl{replace}) all elements
before the gap to the start of the new vector. Then we copy (using
another single call to \cl{replace}) all elements after the gap to the
end of the new vector. The value of \texttt{gap-end} is decremented by
the difference in size of the two vectors, as is \texttt{data-start}
if it was greater than or equal to \texttt{gap-end}.
\subsection{Inserting an object}
The insertion operation is given a position. The semantics of the
insertion operation require that all elements having a position
greater than or equal to the one given as argument to the insertion
operation be ``moved to the right'' i.e., that they have their
positions incremented by one.
After moving the hot spot to the right place, the value of
\texttt{gap-end} is the index corresponding to the position supplied
by the call. It should be noted that the same index will result from
a position of $0$ and from a position equal to the current length of
the chain.
But first, we need to make sure the vector is not full. If it is, we
call the function to increase its size.
We place the object to be inserted at the index of \texttt{gap-start}
and then increment \texttt{gap-start}. If this operation gives a
\texttt{gap-start} equal to the size of the vector, then it is set to
$0$.
\subsection{Deleting an element}
After moving the hot spot to the right place, we need to delete the
element at \texttt{gap-end}. We do this by replacing it by the
\texttt{fill-element} so as to avoid holding on to it in case it is no
longer referenced. Then we increment \texttt{gap-end}.
Finally, we check whether the size of the vector should be decreased.
\subsection{Stack and queue operations}
The stack and queue operations are implemented very efficiently. The
\texttt{push} and \texttt{pop} operations simply call the
corresponding \texttt{insert} and \texttt{delete} operations.
The \texttt{rotate} operation deletes from one end of the chain and
inserts on the other.
\section{The \texttt{flexicursor} protocol}
A \textit{cursorchain} is like a flexichain, but it also keeps around
a bunch of ``flexicursors''.
\subsection{The concept of a flexicursor}
A flexicursor is an object that corresponds to a position between two
elements of the chain. There are two types of flexicursors,
\emph{left-sticky} and \emph{right-sticky}. The difference between
the two is the way they behave when an object is inserted at
corresponding position. When an object is inserted at the position
corresponding to a left-sticky flexicursor, this cursor will be
positioned \emph{before} the newly inserted object, i.e., the cursor
``sticks'' to the element on its left. When an object is inserted at
the position corresponding to a right-sticky flexicursor, this cursor
will be positioned \emph{after} the newly inserted object, i.e., the
cursor ``sticks'' to the element on its right.
Whenever an object is inserted before the position of a
cursor, the position of the cursor will be incremented. Conversely,
whenever an element is deleted from a position below that of a cursor,
the position of the cursor is decremented.
\subsection{Mixing \texttt{flexicursor} and \texttt{flexichain} operations}
The user can freely mix editing operations from the
\texttt{flexicursor} and the \texttt{flexichain} protocol. When an
editing operation from the \texttt{flexichain} protocol is used on an
\texttt{cursorchain} object, the cursors of the \texttt{cursorchain}
object are updated accordingly.
\subsection{Performance}
There can be a very large number of cursors in a chain without any
negative impact on performance. In particular, a sequence of insert
operations is not affected by the number of cursors of the chain.
For insert operations, we maintain the complexity proportional to the
distance between two consecutive positions.
A delete operation takes time proportional to the number of
left-sticky cursors to the right of the element to delete plus the
number of right-sticky cursors to the left of it.
The only bad case is thus a delete operation of an element with an
unbounded number of cursors sticking to it.
\subsection{Protocol classes and functions}
\Defprotoclass {cursorchain}
This is a subclass of \cl{flexichain}.
\Defclass {standard-cursorchain}
The standard instantiable subclass of \cl{cursorchain}.
\Defprotoclass {flexicursor}
The protocol class for all flexicursors.
\Definitarg {chain}
This initarg determines the cursorchain with which the cursor is associated.
\Defclass {standard-flexicursor}
The standard instantiable subclass of \cl{flexicursor}.
\Defclass {left-sticky-flexicursor}
The standard instantiable class for left-sticky flexicursors. It is a
subclass of standard-flexicursor.
\Defclass {right-sticky-flexicursor}
The standard instantiable class for right-sticky flexicursors. It is a
subclass of standard-flexicursor.
\Defgeneric {chain} {cursor}
Return the underlying cursorchain of the flexicursor given
as argument.
\Defgeneric {clone-cursor} {cursor}
Create a cursor that is initially at the same location as the one
given as argument.
\Deferror {flexi-position-error}
This condition is signaled whenever an attempt is made to use position
outside of the range of valid positions.
\Defgeneric {cursor-pos} {cursor}
Return the position of the cursor.
\Defgeneric {(setf cursor-pos)} {position cursor}
Set the position of the cursor. If the new position of the cursor is
before the first position or after the last position of the chain, the
condition \cl{flexi-position-error} is signaled.
\Defgeneric {at-beginning-p} {cursor}
Return true if the cursor is at the beginning of the chain (i.e., if
it has a position of 0). This operation is guaranteed to be executed
in O(1) time.
\Deferror {at-beginning}
This condition is signaled whenever an attempt is made to move a
cursor beyond the beginning of the chain.
\Defgeneric {at-end-p} {cursor}
Return true if the cursor is at the end of the chain (i.e., if it has
a position equal to the length of the chain). This operation is
guaranteed to be executed in O(1) time.
\Deferror {at-end}
This condition is signaled whenever an attempt is made to move a
cursor beyond the end of the chain.
\Deferror {incompatible-object-type}
This condition is signaled whenever an attempt is made to insert an
object of an incompatible type into an chain.
\Defgeneric {insert} {cursor object}
Insert an object at the position corresponding to that of the cursor.
All cursors located at positions greater than the one corresponding to
the cursor given as argument, as well as left-sticky cursors (possibly
including the one given as argument) located at the same position as
the one given as argument will have their positions incremented by
one. Other cursors are unaffected.
If the type of the object does not match the type accepted by the
underlying chain, the \cl{incompatible-object-type} condition is
signaled.
\Defgeneric {insert-sequence} {cursor sequence}
The effect is the same as if each object of the sequence were
inserted using the \texttt{insert} generic function.
\Defgeneric {delete<} {cursor \optional (n 1)}
Delete n elements before the cursor.
\Defgeneric {delete>} {cursor \optional (n 1)}
Delete n elements after the cursor. ...
A sequence of insert and delete operations is guaranteed to be
efficient if the positions of successive operations are not too far
apart as measured by the shortest distance of the chain viewed as a
circular list. Thus, the beginning and the end of the chain are
considered close.
\Defmacro {with-editing-operations} {cursor \body body}
This macro can be used to group a bunch of editing operations (insert,
delete) into a body. The sequence remains locked for the duration of
invocation. Other cursors of the underlying chain are updated only
after the last operation has been completed, thus making it more
efficient to use this macro than to use individual editing operations.
\Defgeneric {element<} {cursor}
Return the element immediately before the cursor. If the cursor is
at the beginning, an at-beginning condition will be signaled.
\Defgeneric {(setf element<)} {object cursor}
Replace the element immediately before the cursor by the object given
as argument. If the cursor is at the beginning, an at-beginning
condition will be signaled.
\Defgeneric {element>} {cursor}
Return the element immediately after the cursor. If the cursor is
at the end, an at-end condition will be signaled.
\Defgeneric {(setf element>)} {object cursor}
Replace the element immediately after the cursor by the object given
as argument. If the cursor is at the end, an at-end condition will be
signaled.
\section{Implementation of the \texttt{flexicursor} protocol}
Cursors are stored as lists of weak references so that they can be
recycled when no longer referenced by client code. A vector that
parallels the one holding elements of the flexichain holds per-element
lists of cursors that stick to that element.
A cursor contains its \textit{index in the vector} as opposed to its
\textit{position in the sequence}. This method avoids most updates of
cursors at each insert and delete operation. Most cursors need only
be updated whenever the gap moves. For left-sticky cursors, we store
the index of $p-1$, where $p$ is the position of the cursor. For
right-sticky cursors, we store $p$ itself.
After a delete operation, cursors with indexes equal to the old value
of \texttt{gap-end} need to be updated. Right-sticky cursors will be
attached to the index corresponding to the new value of
\texttt{gap-end}, whereas left-sticky cursors get attached to the
position immediately preceding \texttt{gap-start}.
Insert operations do not affect cursors at all.
Mixing of \texttt{flexicursor} and \texttt{flexichain} editing
operations is possible thanks to an internal protocol for moving the
gap. The \texttt{flexicursor} code uses :before, :after, and :around
methods on the \texttt{flexichain} editing operations as well as on
the code for moving the gap to update the cursors accordingly. This
way, a \texttt{flexicursor} editing operation translates directly to a
\texttt{flexichain} editing operation with no extra code.
\end{document} | 29,033 | Common Lisp | .l | 530 | 53.309434 | 77 | 0.790966 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 5bde86305f09549257e0665909372f912ca86e7edf650f22c44fe88b78e720be | 22,026 | [
-1
] |
22,034 | cl-cairo2-mac.i | rheaplex_minara/lib/cl-cairo2/cl-cairo2-mac.i | %module "cl-cairo2-mac-swig"
%include "common.i"
%include "cairo-features.h"
%include "cairo-ft.h"
%include "cairo-xlib-xrender.h"
%include "cairo-quartz.h"
| 159 | Common Lisp | .l | 6 | 25.166667 | 31 | 0.754967 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | c9c64155351654f09601060ba9eaff2f6abc59e3d4505d392855bf5beb02d6a1 | 22,034 | [
-1
] |
22,039 | Makefile | rheaplex_minara/lib/cl-cairo2/Makefile | ifndef CAIRO_INCLUDE_DIR
CAIRO_INCLUDE_DIR=/usr/include/cairo
endif
CAIRO_INCLUDE_FILES=$(wildcard $(CAIRO_INCLUDE_DIR)/*.h)
cl-cairo2-swig.lisp: cl-cairo2.i common.i $(CAIRO_INCLUDE_FILES)
swig -cffi -I$(CAIRO_INCLUDE_DIR) -DCOMMON cl-cairo2.i
cl-cairo2-x11-swig.lisp: cl-cairo2-x11.i common.i $(CAIRO_INCLUDE_FILES)
swig -cffi -I$(CAIRO_INCLUDE_DIR) cl-cairo2-x11.i
cl-cairo2-mac-swig.lisp: cl-cairo2-mac.i common.i $(CAIRO_INCLUDE_FILES)
swig -cffi -I$(CAIRO_INCLUDE_DIR) cl-cairo2-mac.i
cl-cairo2-win-swig.lisp: cl-cairo2-win.i common.i $(CAIRO_INCLUDE_FILES)
swig -cffi -I$(CAIRO_INCLUDE_DIR) cl-cairo2-win.i
sed 's/^M//' $@ >[email protected]; mv -f [email protected] $@
# test-swig.lisp: test.i
# swig -cffi -generate-typedef test.i
# asdf:
# rm -Rf /tmp/cl-cairo2-latest
# mkdir /tmp/cl-cairo2-latest
# cp * -R /tmp/cl-cairo2-latest
# tar -cvzf /tmp/cl-cairo2-latest.tar.gz -C /tmp cl-cairo2-latest
# gpg -b -a /tmp/cl-cairo2-latest.tar.gz
| 944 | Common Lisp | .l | 21 | 43.380952 | 72 | 0.719432 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 6f9db4d898e3971cabe8e08db7fce5d118aeaa9c4c07c750f41086e60bd00867 | 22,039 | [
-1
] |
22,042 | cl-cairo2.i | rheaplex_minara/lib/cl-cairo2/cl-cairo2.i | %module "cl-cairo2-swig"
%include "common.i"
%include "cairo-features.h"
%include "cairo-deprecated.h"
%include "cairo.h"
%include "cairo-ps.h"
%include "cairo-pdf.h"
%include "cairo-svg.h"
| 192 | Common Lisp | .l | 8 | 22.75 | 29 | 0.747253 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 22143198260b0d57ae1db452793673976dbd066677cb43e9b4b74e757c146d00 | 22,042 | [
-1
] |
22,048 | cl-cairo2-x11.i | rheaplex_minara/lib/cl-cairo2/cl-cairo2-x11.i | %module "cl-cairo2-x11-swig"
%include "common.i"
%include "cairo-features.h"
%include "cairo-ft.h"
%include "cairo-xlib-xrender.h"
| 133 | Common Lisp | .l | 5 | 25.2 | 31 | 0.753968 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | df50f0416d2445c956b0ea5ebb092f446728bc82c0a5a17050ca7f9feab27b3d | 22,048 | [
-1
] |
22,059 | Makefile | rheaplex_minara/lib/cl-cairo2/tutorial/Makefile | EXAMPLEFILES=hearts.png lissajous.eps text.eps example.eps pattern.eps
RAWEXAMPLEFILES=hearts.png lissajous.pdf text.pdf example.pdf pattern.pdf
LISP=sbcl
tutorial.pdf: tutorial.dvi
dvipdfm tutorial
tutorial.dvi: tutorial.tex $(EXAMPLEFILES)
latex tutorial.tex
$(RAWEXAMPLEFILES): example.lisp
$(LISP) --eval '(progn (load "example.lisp") (quit))'
%.eps: %.pdf
pdf2ps $< $@
| 382 | Common Lisp | .l | 11 | 33 | 73 | 0.784741 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 6986a9082282f3d785fb7f489b07be43112d5ccc3886ccd0228d30020ba9dc51 | 22,059 | [
-1
] |
22,063 | tutorial.tex | rheaplex_minara/lib/cl-cairo2/tutorial/tutorial.tex | \documentclass[12pt,letterpaper,dvipdfm]{article}
% \usepackage{amsmath}
% \usepackage{amsfonts}
\usepackage[letterpaper,hmargin=1in]{geometry}
%\usepackage[letterpaper,left=2cm,right=8cm,bottom=3cm,top=3cm,marginparwidth=4cm]{geometry}
%\usepackage{natbib}
\usepackage{graphicx}
\usepackage{url}
\usepackage{natbib}
\usepackage{color}
\usepackage{paralist} % compactitem
\definecolor{red}{rgb}{1,0,0}
\newcommand{\FIXME}[1]{{\color{red}\{FIXME: #1\}}}
\usepackage{hyperref}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{cl-cairo2 tutorial} \rhead{Tam\'as K Papp}
\cfoot{\thepage}
\renewcommand\floatpagefraction{.9}
\renewcommand\topfraction{.9}
\renewcommand\bottomfraction{.9}
\renewcommand\textfraction{.1}
\usepackage{listings}
\lstset{
language=Lisp,
extendedchars=true,
basicstyle=\ttfamily,
stringstyle=\ttfamily\slshape,
commentstyle=\slshape,
% numbers=left,
% stepnumber=5,
% numbersep=6pt,
% numberstyle=\footnotesize,
breaklines=true,
% frame=single,
columns=fullflexible,
literate={-}{}{0\discretionary{-}{}{-}},
}
\begin{document}
\title{Tutorial for the cl-cairo2 package}
\author{Tam\'as K Papp}
\date{\today}
\maketitle
\section{Introduction}
\label{sec:introduction}
\href{http://cairographics.org/}{Cairo} is a 2D graphics library with
support for multiple output devices. The \lstinline!cl-cairo2!
package provides Common Lisp bindings for the Cairo API.\footnote{Alternatives
are \href{http://www.cliki.net/cl-cairo}{cl-cairo}, written by Lars
Nostdal and others (this project appears to be dormant), and Christian
Haselbach's \href{http://www.cliki.net/cffi-cairo}{cffi-cairo}.}
\lstinline!cl-cairo2! is written with the following principles in mind:
\begin{description}
\item[CFFI bindings are generated by SWIG.] This ensures that API
changes are caught easily and makes it easier to follow them.
The bindings to C functions are not exported directly.
\item[It attempts to make the interface more Lisp-like.] The Cairo
API is written in C, which has no garbage collection or condition
handling, and has little support for sophisticated dynamic data
structures. However, the Lisp user should not worry about reference
counting and pointer arithmetic. Instead of merely providing the C
wrappers, cl-cairo2 aims to provide an interface conforming to the
style of Lisp better.
\item[Condition handling.] In the Cairo API, an error is signaled by
changing the state of the object, which the user is supposed to
query periodically. The functions in cl-cairo2 do this
automatically, and use Common Lisp's powerful condition facility to
signal errors.\footnote{This feature is not fully developed yet:
currently a warning is signalled for all errors. The framework is
in place, I just need to decide which errors require user
intervention, etc.}
\end{description}
This tutorial introduces cl-cairo2, but is not an introduction to
Cairo itself. If you are not familiar with Cairo, it is recommended
that your read the
\href{http://www.tortall.net/mu/wiki/CairoTutorial}{Cairo Tutorial for
Python (and other) Programmers}.
\section{Installation and loading}
\label{sec:installation-loading}
cl-cairo2 uses ASDF. Please refer to the
\href{http://www.cliki.net/asdf}{ASDF} and
\href{http://www.cliki.net/ASDF-Install}{ASDF-Install} manuals on how
to install packages. You need to have the latest Cairo API installed.
On Debian systems, you just need to install the \verb!libcairo2!
package. You don't need the header files or SWIG unless you plan to
regenate the SWIG bindings.
Once installed, you can load cl-cairo2 with
\begin{lstlisting}
(asdf:operate 'asdf:load-op :cl-cairo2)
\end{lstlisting}
\section{Getting started}
\label{sec:getting-started}
Most Cairo drawing operations are performed on a \emph{context}.
Think of the context as a combination of a canvas which remembers pen
strokes (the current path), color, line width, line style, and other,
more complicated settings that determine what gets drawn where. When
you build a path (which you want to fill with a color/pattern, stroke
with a given line style, or even save), all of this happens in a
context.
All \verb!cl-cairo2! functions that use a context take it as
their last optional argument. If not given, these functions use
\lstinline!*context*!, a special variable that stores the default
context.
Contexts are created from \emph{surfaces} --- which, at this point,
should be thought of as the bare canvas itself (think of PDF,
PostScript, of PNG files). All
Cairo objects, including contexts and surfaces, are implemented in
CLOS wrappers, and can be closed (\emph{destroyed}) with
\lstinline!destroy!.
When the context is created from a surface, the reference count (in
the internals of Cairo) of the latter is incremented. You can
immediately destroy the surface: it will not be destroyed (ie the file
will not be closed) until you destroy the context.\footnote{The file
will also be closed if the wrapper object is garbage collected.
However, you should not rely on this, as calling the garbage
collector is not portable.} The following code draws a white
diagonal line on a blue background, using a Postscript file -- the
result is shown in Figure~\ref{fig:example}.
\lstinputlisting[firstline=13,lastline=27]{example.lisp}
\begin{figure}[htbp]
\centering
\includegraphics{example.eps}
\caption{white diagonal line on a blue background}
\label{fig:example}
\end{figure}
Unless you need the surface itself for something else, you should use
the \lstinline!create-*-context! convenience commands provided by
cl-cairo2. For example, the first three lines of the code above would
be replaced by
\begin{lstlisting}
(setf *context* (create-ps-context "example.ps" 200 100))
\end{lstlisting}
Unlike the original Cairo API, surfaces and contexts in
\lstinline!cl-cairo2! remember their width and height. Use the
generic functions \lstinline!get-width! and \lstinline!get-height! to
extract these.
When you want to write the output into a bitmap file (for example, in
PNG format), you first need to create an \emph{image surface}, then
write this to the bitmap file when you are done. The macro
\lstinline!with-png-file! will take care of these details: use it like
\begin{lstlisting}
(with-png-file ("example.png" :rgb24 200 100)
;; drawing commands
...)
\end{lstlisting}
This example above highlights another feature of cl-cairo2: constants
(such as the format specifier \lstinline!rgb24!) are exported as
simple names from the cl-cairo2 package. Internal functions in the
package map these to the enum constants used by Cairo. cl-cairo2 uses
lookup tables (assoc lists) for this purpose, which are defined in
\verb!tables.lisp!. Cairo constants
\texttt{CAIRO\_\textsl{PROPERTY}\_\textsl{SOMETHING}} usually map to
the Lisp symbol \lstinline!property-something!, and can only be used
in setting or querying \texttt{PROPERTY}. For example,
\verb!CAIRO_FORMAT_RGB24! is mapped to \lstinline!format-rgb24!, and
using it for some other property will create an error.
Likewise, names of the Lisp function are easy to deduce from the name
of the C function in the Cairo API: just drop the \verb!cairo_! prefix
and convert all underscores (\verb!_!) to dashes (\lstinline!-!). The
exceptions to this rule (and the explanations) are given in
Table~\ref{tab:naming}.
\begin{table}[htbp]
\centering
\begin{tabular}{p{11cm}|c}
Cairo API name (explanation) & cl-cairo2 name\\\hline
\verb!cairo_fill! (would conflict with \lstinline!cl:fill!)
& \lstinline!fill-path! \\
\verb!cairo_identity_matrix! (would
conflict with matrix algebra packages)& \lstinline!reset-trans-matrix! \\
\verb!cairo_matrix_init_identity! & use \lstinline!(make-trans-matrix)!\\
\verb!cairo_matrix_transform_distance!
& \lstinline!transform-distance!\\
\verb!cairo_matrix_transform_point! &
\lstinline!transform-point!\\
\verb!cairo_matrix_*! & \lstinline!trans-matrix-*!
\end{tabular}
% \caption{Function names different from the Cairo API}
\label{tab:naming}
\end{table}
\section{Implementation notes}
\label{sec:implementation-notes}
\subsection{General}
\label{sec:general}
The package contains some helper functions, most notably
\lstinline{deg-to-rad}, which converts degrees to radians. Cairo
functions use the latter.
\subsection{Surfaces}
\label{sec:surfaces}
See the beginning of \verb!surface.lisp! for helper macros used
internally to define wrappers for the SWIG-generated CFFI interface
(neither the interface not these macros are exported).
\lstinline!with-alive-surface! checks if the pointer for a surface
object is nil, and \lstinline!check-surface-pointer-status! queries
the status of the surface after executing \lstinline!body!.
\lstinline!with-surface! is a combination of the two, and
\lstinline!new-surface-with-check! makes a new surface object from a
pointer, checking its status first.
Currently, only Postscript, PDF, SVG and image surfaces (which can be
written to PNG files) are supported.
Drawing in X11 windows is implemented using the
\lstinline!x11-context! class --- see Section~\ref{sec:xlib-context}
for more information. You need to load the \lstinline!cl-cairo2-x11!
package for that.
\subsection{Contexts}
\label{sec:contexts}
Contexts are represented as the class \lstinline!context!, which
currently only has one slot, a pointer to the context. When contexts
are destroyed, this is set to \lstinline!nil!. As mentioned above,
the default context is \lstinline!*context*!, and it is the default
for the last (optional) argument of each function.
The macro \lstinline!with-context! is similar to
\lstinline!with-surface! above (it executes the body with pointer
pointing to the object and then checks error status). The functions
\lstinline!define-with-default-context! defines a function acting on a
context given a list of arguments and exports this function.
\lstinline!define-flexible! is similar, but allows a more flexible
function body.
Functions that are not implemented yet include
\begin{compactitem}
\item \lstinline!cairo-get-target!
\item \lstinline!push-group-with-content!
\item \lstinline!get-group-target!
\item \lstinline!set-source!, \lstinline!set-source-surface!,
\lstinline!get-source!
\item \lstinline!mask!, \lstinline!mask-surface!
\end{compactitem}
I doubt that Lisp users need \lstinline!get/set-user-data! or
\lstinline!get-reference-count!. Let me know if you do.
Since version 0.2.3, you can use colors from
\href{http://www.cliki.net/cl-colors}{cl-colors} with the generic
function \lstinline!set-source-color!, for example,
\begin{lstlisting}
(set-source-color +darkolivegreen+)
\end{lstlisting}
\subsection{Paths}
\label{sec:paths}
Almost all drawing operations of Cairo rely on the construction of
paths. While basic paths can be constucted in a context, paths can be
saved, modified and reused independently. At the moment, cl-cairo2
does not support these path operations:
\begin{compactitem}
\item\lstinline!copy-path!
\item\lstinline!copy-path-flat!
\item\lstinline!path-destroy!
\item\lstinline!append-path!
\end{compactitem}
This is because I decided to follow the recommendation of
\href{http://www.cairographics.org/manual/bindings-path.html}{relevant
section} of the Cairo API Manual, and implement paths and related
manipulators in a way that doesn't require the user to traverse
structures of C pointers. This is not done yet.
\lstinline!glyph-path! (see Section~\ref{sec:text} for discussion
about glyphs) is not implemented either.
\subsection{Text}
\label{sec:text}
Text operations are very basic at the moment (refer to
\verb!text.lisp! for an enumeration of what is missing). You can
select font face and size using commands like
\begin{lstlisting}
(select-font-face "Arial" :italic :bold)
(select-font-size 12)
\end{lstlisting}
and use \lstinline!(show-text "hello world")! to draw it. You can
control text placement by using \lstinline!text-extents! and
recalculating the position --- see \verb!example.lisp! for examples
(in Section~\ref{sec:examples}). Note that Cairo functions accept
text in UTF-8 format: you should convert your strings to UTF-8 if you
plan to use non-ASCII characters.
The long-term goal is to use CLOS for font selection, following the
recommendations
\href{http://www.cairographics.org/manual/bindings-fonts.html}{here}.
Also, proper handling of glyphs would be a nice thing, but would
require other libraries (eg \href{http://www.pango.org/}{Pango}) for
converting text to glyphs.
\subsection{Transformations}
\label{sec:transformations}
cl-cairo2 defines the structure \lstinline!trans-matrix! with the
slots \lstinline!xx!, \lstinline!yx!, \lstinline!xy!, \lstinline!yy!,
\lstinline!x0!, \lstinline!y0!. The defaults for these slots give you
the identity matrix.
All the functions that use transformation matrices use this structure.
Consequently, \verb!cairo_matrix_init! has no corresponding function
in cl-cairo2: you can construct a translation matrix using
\lstinline!make-trans-matrix!.
Some functions are renamed, see Table~\ref{tab:naming}. Generally,
functions which manipulate \lstinline!trans-matrix! stuctures start
with \lstinline!trans-matrix-!, and other a few other functions have
been renamed to avoid conflicts with linear algebra packages.
\subsection{Xlib Contexts}
\label{sec:xlib-context}
The xlib context is not part of cairo -- it is a bit of glue code that
uses cairo's X11 surface on a pixmap, and displays this pixmap when
needed (when X11 asks for the window contents to be redrawn or when
cairo draws on the pixmap). The X11 specific code is in a separate
package, so make sure that you load \lstinline!cl-cairo2-x11!.
Please remember that the X11 code provided is a proof of concept, only
for displaying the results of Cairo commands interactively in windows.
If you would like to use Cairo in your --- possibly more complex ---
applications, you need to do things differently (for example, you need
you own event loop).
Two contexts are implemented, one uses double-buffered pixmaps, and
can be created by \lstinline!create-xlib-context!, the other Xlib
image surfaces, and you can create such a context by
\lstinline!create-xlib-image-context!. I suggest that you use the
latter.
In cl-cairo2, each window maps to a context. The surface is not
exposed to the user, who is only allowed to see the context. This
makes memory management and proper cleanup easier. For example, you
can create an \lstinline!xlib-image-context! with
\begin{lstlisting}
(setf *context* (create-xlib-image-context 500 400
:display-name "localhost:0"
:window-name "my pretty drawing"))
\end{lstlisting}
If you give \lstinline!nil! for \lstinline!display-name!, Xlib fill
probably figure out a reasonable default, usually from your
\verb!$DISPLAY! environment variable. You can also specify the
background color.
The X11 event loop runs in a separate thread, so you need a Lisp
implementation that supports threads.
When the context \lstinline!destroy!ed, the window is closed. This
works the other way too: when the window is closed, the context is
destroyed. The implementation precludes the resizing of the window.
The current implementation is not optimized for speed (the whole
window is redrawn all the time) but it is fast enough. If you draw a
lot of objects at the same time, it is suggested that you suspend
synchronizing with the X-window server using
\lstinline!(sync-lock context)!. When you are done, you can call
\lstinline!(sync-unlock context)!, which will automatically sync the
buffer and the window.
You can nest calls to \lstinline!sync-lock! and
\lstinline!sync-unlock!, and if you want to restore syncing
unconditionally, use \lstinline!sync-reset!, which also performs
syncing too. These are generic functions which do nothing for other
contexts.
\subsection{MS-Windows contexts}
\label{sec:ms-windows-contexts}
Kei Suzuki contributed code for interfacing Cairo to MS-Windows.
Please see \verb!package-win.lisp!, you need to load the
\lstinline!cl-cairo2-win! library to use this code.
\subsection{To Do}
\label{sec:todo}
The list below reflects my priorities. If you need something, please
let me know.
\begin{itemize}
\item CLOS integration for fonts (as suggested
\href{http://www.cairographics.org/manual/bindings-fonts.html}{here})
\end{itemize}
Things I don't plan on doing, but will be happy to incorporate if
somebody does it:
\begin{itemize}
\item Pango and/or glyph handling
\end{itemize}
\section{Examples}
\label{sec:examples}
Below is an extended example, which can be found in
\texttt{example.lisp}. Figures~\ref{fig:text}--\ref{fig:hearts} show
the results.
\lstinputlisting{example.lisp}
\begin{figure}[htbp]
\centering
\includegraphics[height=8cm]{text.eps}
\caption{text.ps}
\label{fig:text}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[height=8cm]{lissajous.eps}
\caption{lissajous.ps}
\label{fig:lissajous}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[natwidth=12cm, natheight=9cm]{hearts.png}
\caption{hearts.png}
\label{fig:hearts}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[height=4cm]{pattern.eps}
\caption{pattern.ps}
\label{fig:pattern}
\end{figure}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
| 17,528 | Common Lisp | .l | 388 | 43.260309 | 92 | 0.785396 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 18ea0e02d19923094cea544454426a08410d6e5d91c5e721b22469af87f32a13 | 22,063 | [
-1
] |
22,066 | tutorial.aux | rheaplex_minara/lib/cl-cairo2/tutorial/tutorial.aux | \relax
\ifx\hyper@anchor\@undefined
\global \let \oldcontentsline\contentsline
\gdef \contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}}
\global \let \oldnewlabel\newlabel
\gdef \newlabel#1#2{\newlabelxx{#1}#2}
\gdef \newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}
\AtEndDocument{\let \contentsline\oldcontentsline
\let \newlabel\oldnewlabel}
\else
\global \let \hyper@last\relax
\fi
\providecommand*\HyPL@Entry[1]{}
\HyPL@Entry{0 << /S /D >> }
\@writefile{toc}{\contentsline {section}{\numberline {1}Introduction}{1}{section.1}}
\newlabel{sec:introduction}{{1}{1}{Introduction\relax }{section.1}{}}
\@writefile{toc}{\contentsline {section}{\numberline {2}Installation and loading}{2}{section.2}}
\newlabel{sec:installation-loading}{{2}{2}{Installation and loading\relax }{section.2}{}}
\@writefile{toc}{\contentsline {section}{\numberline {3}Getting started}{2}{section.3}}
\newlabel{sec:getting-started}{{3}{2}{Getting started\relax }{section.3}{}}
\@writefile{lol}{\contentsline {lstlisting}{example.lisp}{2}{lstlisting.-2}}
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces white diagonal line on a blue background}}{3}{figure.1}}
\newlabel{fig:example}{{1}{3}{white diagonal line on a blue background\relax }{figure.1}{}}
\newlabel{tab:naming}{{3}{4}{Getting started\relax }{lstnumber.-4.3}{}}
\@writefile{toc}{\contentsline {section}{\numberline {4}Implementation notes}{4}{section.4}}
\newlabel{sec:implementation-notes}{{4}{4}{Implementation notes\relax }{section.4}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.1}General}{4}{subsection.4.1}}
\newlabel{sec:general}{{4.1}{4}{General\relax }{subsection.4.1}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.2}Surfaces}{4}{subsection.4.2}}
\newlabel{sec:surfaces}{{4.2}{4}{Surfaces\relax }{subsection.4.2}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.3}Contexts}{5}{subsection.4.3}}
\newlabel{sec:contexts}{{4.3}{5}{Contexts\relax }{subsection.4.3}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.4}Paths}{5}{subsection.4.4}}
\newlabel{sec:paths}{{4.4}{5}{Paths\relax }{subsection.4.4}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.5}Text}{6}{subsection.4.5}}
\newlabel{sec:text}{{4.5}{6}{Text\relax }{subsection.4.5}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.6}Transformations}{6}{subsection.4.6}}
\newlabel{sec:transformations}{{4.6}{6}{Transformations\relax }{subsection.4.6}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.7}Xlib Contexts}{6}{subsection.4.7}}
\newlabel{sec:xlib-context}{{4.7}{6}{Xlib Contexts\relax }{subsection.4.7}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.8}MS-Windows contexts}{7}{subsection.4.8}}
\newlabel{sec:ms-windows-contexts}{{4.8}{7}{MS-Windows contexts\relax }{subsection.4.8}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.9}To Do}{7}{subsection.4.9}}
\newlabel{sec:todo}{{4.9}{7}{To Do\relax }{subsection.4.9}{}}
\@writefile{toc}{\contentsline {section}{\numberline {5}Examples}{8}{section.5}}
\newlabel{sec:examples}{{5}{8}{Examples\relax }{section.5}{}}
\@writefile{lol}{\contentsline {lstlisting}{example.lisp}{8}{lstlisting.-8}}
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces text.ps}}{15}{figure.2}}
\newlabel{fig:text}{{2}{15}{text.ps\relax }{figure.2}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces lissajous.ps}}{16}{figure.3}}
\newlabel{fig:lissajous}{{3}{16}{lissajous.ps\relax }{figure.3}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces hearts.png}}{16}{figure.4}}
\newlabel{fig:hearts}{{4}{16}{hearts.png\relax }{figure.4}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces pattern.ps}}{17}{figure.5}}
\newlabel{fig:pattern}{{5}{17}{pattern.ps\relax }{figure.5}{}}
| 3,839 | Common Lisp | .l | 55 | 68.745455 | 126 | 0.726408 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 4d3a738f73e96646574c86e2edeb1168eaa7800b256e7896ad4973955b0fae6b | 22,066 | [
-1
] |
22,068 | tutorial.tex.svn-base | rheaplex_minara/lib/cl-cairo2/tutorial/.svn/text-base/tutorial.tex.svn-base | \documentclass[12pt,letterpaper,dvipdfm]{article}
% \usepackage{amsmath}
% \usepackage{amsfonts}
\usepackage[letterpaper,hmargin=1in]{geometry}
%\usepackage[letterpaper,left=2cm,right=8cm,bottom=3cm,top=3cm,marginparwidth=4cm]{geometry}
%\usepackage{natbib}
\usepackage{graphicx}
\usepackage{url}
\usepackage{natbib}
\usepackage{color}
\usepackage{paralist} % compactitem
\definecolor{red}{rgb}{1,0,0}
\newcommand{\FIXME}[1]{{\color{red}\{FIXME: #1\}}}
\usepackage{hyperref}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{cl-cairo2 tutorial} \rhead{Tam\'as K Papp}
\cfoot{\thepage}
\renewcommand\floatpagefraction{.9}
\renewcommand\topfraction{.9}
\renewcommand\bottomfraction{.9}
\renewcommand\textfraction{.1}
\usepackage{listings}
\lstset{
language=Lisp,
extendedchars=true,
basicstyle=\ttfamily,
stringstyle=\ttfamily\slshape,
commentstyle=\slshape,
% numbers=left,
% stepnumber=5,
% numbersep=6pt,
% numberstyle=\footnotesize,
breaklines=true,
% frame=single,
columns=fullflexible,
literate={-}{}{0\discretionary{-}{}{-}},
}
\begin{document}
\title{Tutorial for the cl-cairo2 package}
\author{Tam\'as K Papp}
\date{\today}
\maketitle
\section{Introduction}
\label{sec:introduction}
\href{http://cairographics.org/}{Cairo} is a 2D graphics library with
support for multiple output devices. The \lstinline!cl-cairo2!
package provides Common Lisp bindings for the Cairo API.\footnote{Alternatives
are \href{http://www.cliki.net/cl-cairo}{cl-cairo}, written by Lars
Nostdal and others (this project appears to be dormant), and Christian
Haselbach's \href{http://www.cliki.net/cffi-cairo}{cffi-cairo}.}
\lstinline!cl-cairo2! is written with the following principles in mind:
\begin{description}
\item[CFFI bindings are generated by SWIG.] This ensures that API
changes are caught easily and makes it easier to follow them.
The bindings to C functions are not exported directly.
\item[It attempts to make the interface more Lisp-like.] The Cairo
API is written in C, which has no garbage collection or condition
handling, and has little support for sophisticated dynamic data
structures. However, the Lisp user should not worry about reference
counting and pointer arithmetic. Instead of merely providing the C
wrappers, cl-cairo2 aims to provide an interface conforming to the
style of Lisp better.
\item[Condition handling.] In the Cairo API, an error is signaled by
changing the state of the object, which the user is supposed to
query periodically. The functions in cl-cairo2 do this
automatically, and use Common Lisp's powerful condition facility to
signal errors.\footnote{This feature is not fully developed yet:
currently a warning is signalled for all errors. The framework is
in place, I just need to decide which errors require user
intervention, etc.}
\end{description}
This tutorial introduces cl-cairo2, but is not an introduction to
Cairo itself. If you are not familiar with Cairo, it is recommended
that your read the
\href{http://www.tortall.net/mu/wiki/CairoTutorial}{Cairo Tutorial for
Python (and other) Programmers}.
\section{Installation and loading}
\label{sec:installation-loading}
cl-cairo2 uses ASDF. Please refer to the
\href{http://www.cliki.net/asdf}{ASDF} and
\href{http://www.cliki.net/ASDF-Install}{ASDF-Install} manuals on how
to install packages. You need to have the latest Cairo API installed.
On Debian systems, you just need to install the \verb!libcairo2!
package. You don't need the header files or SWIG unless you plan to
regenate the SWIG bindings.
Once installed, you can load cl-cairo2 with
\begin{lstlisting}
(asdf:operate 'asdf:load-op :cl-cairo2)
\end{lstlisting}
\section{Getting started}
\label{sec:getting-started}
Most Cairo drawing operations are performed on a \emph{context}.
Think of the context as a combination of a canvas which remembers pen
strokes (the current path), color, line width, line style, and other,
more complicated settings that determine what gets drawn where. When
you build a path (which you want to fill with a color/pattern, stroke
with a given line style, or even save), all of this happens in a
context.
All \verb!cl-cairo2! functions that use a context take it as
their last optional argument. If not given, these functions use
\lstinline!*context*!, a special variable that stores the default
context.
Contexts are created from \emph{surfaces} --- which, at this point,
should be thought of as the bare canvas itself (think of PDF,
PostScript, of PNG files). Contexts are created from surfaces. All
Cairo objects, including contexts and surfaces, are implemented in
CLOS wrappers, and can be closed (\emph{destroyed}) with
\lstinline!destroy!.
When the context is created from a surface, the reference count (in
the internals of Cairo) of the latter is incremented. You can
immediately destroy the surface: it will not be destroyed (ie the file
will not be closed) until you destroy the context.\footnote{The file
will also be closed if the wrapper object is garbage collected.
However, you should not rely on this, as calling the garbage
collector is not portable.} The following code draws a white
diagonal line on a blue background, using a Postscript file -- the
result is shown in Figure~\ref{fig:example}.
\lstinputlisting[firstline=13,lastline=27]{example.lisp}
\begin{figure}[htbp]
\centering
\includegraphics{example.epsi}
\caption{white diagonal line on a blue background}
\label{fig:example}
\end{figure}
Unless you need the surface itself for something else, you should use
the \lstinline!create-*-context! convenience commands provided by
cl-cairo2. For example, the first three lines of the code above would
be replaced by
\begin{lstlisting}
(setf *context* (create-ps-context "example.ps" 200 100))
\end{lstlisting}
Unlike the original Cairo API, surfaces and contexts in
\lstinline!cl-cairo2! remember their width and height. Use the
generic functions \lstinline!get-width! and \lstinline!get-height! to
extract these.
When you want to write the output into a bitmap file (for example, in
PNG format), you first need to create an \emph{image surface}, then
write this to the bitmap file when you are done. The macro
\lstinline!with-png-file! will take care of these details: use it like
\begin{lstlisting}
(with-png-file ("example.png" 'format-rgb24 200 100)
;; drawing commands
...)
\end{lstlisting}
This example above highlights another feature of cl-cairo2: constants
(such as the format specifier \lstinline!rgb24!) are exported as
simple names from the cl-cairo2 package. Internal functions in the
package map these to the enum constants used by Cairo. cl-cairo2 uses
lookup tables (assoc lists) for this purpose, which are defined in
\verb!tables.lisp!. Cairo constants
\texttt{CAIRO\_\textsl{PROPERTY}\_\textsl{SOMETHING}} usually map to
the Lisp symbol \lstinline!property-something!, and can only be used
in setting or querying \texttt{PROPERTY}. For example,
\verb!CAIRO_FORMAT_RGB24! is mapped to \lstinline!format-rgb24!, and
using it for some other property will create an error.
Likewise, names of the Lisp function are easy to deduce from the name
of the C function in the Cairo API: just drop the \verb!cairo_! prefix
and convert all underscores (\verb!_!) to dashes (\lstinline!-!). The
exceptions to this rule (and the explanations) are given in
Table~\ref{tab:naming}.
\begin{table}[htbp]
\centering
\begin{tabular}{p{11cm}|c}
Cairo API name (explanation) & cl-cairo2 name\\\hline
\verb!cairo_fill! (would conflict with \lstinline!cl:fill!)
& \lstinline!fill-path! \\
\verb!cairo_identity_matrix! (would
conflict with matrix algebra packages)& \lstinline!reset-trans-matrix! \\
\verb!cairo_matrix_init_identity! & use \lstinline!(make-trans-matrix)!\\
\verb!cairo_matrix_transform_distance!
& \lstinline!transform-distance!\\
\verb!cairo_matrix_transform_point! &
\lstinline!transform-point!\\
\verb!cairo_matrix_*! & \lstinline!trans-matrix-*!
\end{tabular}
% \caption{Function names different from the Cairo API}
\label{tab:naming}
\end{table}
\section{Implementation notes}
\label{sec:implementation-notes}
\subsection{General}
\label{sec:general}
The package contains some helper functions, most notably
\lstinline{deg-to-rad}, which converts degrees to radians. Cairo
functions use the latter.
\subsection{Surfaces}
\label{sec:surfaces}
See the beginning of \verb!surface.lisp! for helper macros used
internally to define wrappers for the SWIG-generated CFFI interface
(neither the interface not these macros are exported).
\lstinline!with-alive-surface! checks if the pointer for a surface
object is nil, and \lstinline!check-surface-pointer-status! queries
the status of the surface after executing \lstinline!body!.
\lstinline!with-surface! is a combination of the two, and
\lstinline!new-surface-with-check! makes a new surface object from a
pointer, checking its status first.
Currently, only Postscript, PDF, SVG and image surfaces (which can be
written to PNG files) are supported.
Drawing in X11 windows is implemented using the
\lstinline!x11-context! class --- see Section~\ref{sec:xlib-context}
for more information.
\subsection{Contexts}
\label{sec:contexts}
Contexts are represented as the class \lstinline!context!, which
currently only has one slot, a pointer to the context. When contexts
are destroyed, this is set to \lstinline!nil!. As mentioned above,
the default context is \lstinline!*context*!, and it is the default
for the last (optional) argument of each function.
The macro \lstinline!with-context! is similar to
\lstinline!with-surface! above (it executes the body with pointer
pointing to the object and then checks error status). The functions
\lstinline!define-with-default-context! defines a function acting on a
context given a list of arguments and exports this function.
\lstinline!define-flexible! is similar, but allows a more flexible
function body.
Functions that are not implemented yet include
\begin{compactitem}
\item \lstinline!cairo-get-target!
\item \lstinline!push-group-with-content!
\item \lstinline!get-group-target!
\item \lstinline!set-source!, \lstinline!set-source-surface!,
\lstinline!get-source!
\item \lstinline!mask!, \lstinline!mask-surface!
\end{compactitem}
I doubt that Lisp users need \lstinline!get/set-user-data! or
\lstinline!get-reference-count!. Let me know if you do.
Since version 0.2.3, you can use colors from
\href{http://www.cliki.net/cl-colors}{cl-colors} with the generic
function \lstinline!set-source-color!, for example,
\begin{lstlisting}
(set-source-color +darkolivegreen+)
\end{lstlisting}
\subsection{Paths}
\label{sec:paths}
Almost all drawing operations of Cairo rely on the construction of
paths. While basic paths can be constucted in a context, paths can be
saved, modified and reused independently. At the moment, cl-cairo2
does not support these path operations:
\begin{compactitem}
\item\lstinline!copy-path!
\item\lstinline!copy-path-flat!
\item\lstinline!path-destroy!
\item\lstinline!append-path!
\end{compactitem}
This is because I decided to follow the recommendation of
\href{http://www.cairographics.org/manual/bindings-path.html}{relevant
section} of the Cairo API Manual, and implement paths and related
manipulators in a way that doesn't require the user to traverse
structures of C pointers. This is not done yet.
\lstinline!glyph-path! (see Section~\ref{sec:text} for discussion
about glyphs) is not implemented either.
\subsection{Text}
\label{sec:text}
Text operations are very basic at the moment (refer to
\verb!text.lisp! for an enumeration of what is missing). You can
select font face and size using commands like
\begin{lstlisting}
(select-font-face "Arial" 'font-slant-italic 'font-weight-bold)
(select-font-size 12)
\end{lstlisting}
and use \lstinline!(show-text "hello world")! to draw it. You can
control text placement by using \lstinline!text-extents! and
recalculating the position --- see \verb!example.lisp! for examples
(in Section~\ref{sec:examples}). Note that Cairo functions accept
text in UTF-8 format: you should convert your strings to UTF-8 if you
plan to use non-ASCII characters.
The long-term goal is to use CLOS for font selection, following the
recommendations
\href{http://www.cairographics.org/manual/bindings-fonts.html}{here}.
Also, proper handling of glyphs would be a nice thing, but would
require other libraries (eg \href{http://www.pango.org/}{Pango}) for
converting text to glyphs.
\subsection{Transformations}
\label{sec:transformations}
cl-cairo2 defines the structure \lstinline!trans-matrix! with the
slots \lstinline!xx!, \lstinline!yx!, \lstinline!xy!, \lstinline!yy!,
\lstinline!x0!, \lstinline!y0!. The defaults for these slots give you
the identity matrix.
All the functions that use transformation matrices use this structure.
Consequently, \verb!cairo_matrix_init! has no corresponding function
in cl-cairo2: you can construct a translation matrix using
\lstinline!make-trans-matrix!.
Some functions are renamed, see Table~\ref{tab:naming}. Generally,
functions which manipulate \lstinline!trans-matrix! stuctures start
with \lstinline!trans-matrix-!, and other a few other functions have
been renamed to avoid conflicts with linear algebra packages.
\subsection{Xlib Contexts}
\label{sec:xlib-context}
The xlib context is not part of cairo -- it is a bit of glue code that
uses cairo's X11 surface on a pixmap, and displays this pixmap when
needed (when X11 asks for the window contents to be redrawn or when
cairo draws on the pixmap).
In cl-cairo2, each window maps to a context. The surface is not
exposed to the user, who is only allowed to see the context. This
makes memory management and proper cleanup easier. For example, you
can create an \lstinline!xlib-context! with
\begin{lstlisting}
(setf *context* (create-xlib-context 500 400
:display-name "localhost:0"
:window-name "my pretty drawing"))
\end{lstlisting}
If you give \lstinline!nil! for \lstinline!display-name!, Xlib fill
probably figure out a reasonable default, usually from your
\verb!$DISPLAY! environment variable.
The X11 event loop runs in a separate thread, so you need a Lisp
implementation that supports threads.
When the context \lstinline!destroy!ed, the window is closed. This
works the other way too: when the window is closed, the context is
destroyed. The windows are double-buffered using a pixmap on the X11
server, therefore redrawing exposed windows is fast. However, this
implementation precludes the resizing of the window.
Example code can be found in \verb!tutorial/x11-example.lisp!. The
current implementation is not optimized for speed (the whole window is
redrawn all the time) but it is fast enough. If you draw a lot of
objects at the same time, it is suggested that you suspend
synchronizing with the X-window server using
\lstinline!(sync-lock context)!.
When you are done, you can call \lstinline!(sync-unlock context)!, which will automatically sync the buffer and the window.
You can nest calls to \lstinline!sync-lock! and
\lstinline!sync-unlock!, and if you want to restore syncing
unconditionally, use \lstinline!sync-reset!, which also performs
syncing too. These are generic functions which do nothing for other
contexts.
\subsection{To Do}
\label{sec:todo}
The list below reflects my priorities. If you need something, please
let me know.
\begin{itemize}
\item patterns (should be easy)
\item Win32 surfaces (I can't do it, I don't use Windows)
\item CLOS integration for fonts (as suggested
\href{http://www.cairographics.org/manual/bindings-fonts.html}{here})
\end{itemize}
Things I don't plan on doing, but will be happy to incorporate if
somebody does it:
\begin{itemize}
\item Pango and/or glyph handling
\end{itemize}
\section{Examples}
\label{sec:examples}
Below is an extended example, which can be found in
\texttt{example.lisp}. Figures~\ref{fig:text}--\ref{fig:hearts} show
the results.
\lstinputlisting{example.lisp}
\begin{figure}[htbp]
\centering
\includegraphics[height=8cm]{text.epsi}
\caption{text.pdf}
\label{fig:text}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[height=8cm]{lissajous.epsi}
\caption{lissajous.pdf}
\label{fig:lissajous}
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[natwidth=12cm, natheight=9cm]{hearts.png}
\caption{hearts.png}
\label{fig:hearts}
\end{figure}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
| 16,710 | Common Lisp | .l | 368 | 43.467391 | 125 | 0.784805 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 6ea60bc8e93a521a4df47052553bba9464b44f2e34f793ae952dbcdcbc166ad6 | 22,068 | [
-1
] |
22,074 | Makefile.svn-base | rheaplex_minara/lib/cl-cairo2/tutorial/.svn/text-base/Makefile.svn-base | EXAMPLEFILES=hearts.png lissajous.epsi text.epsi example.epsi
RAWEXAMPLEFILES=hearts.png lissajous.ps text.ps example.ps
LISP=sbcl
tutorial.pdf: tutorial.dvi
dvipdfm tutorial
tutorial.dvi: tutorial.tex $(EXAMPLEFILES)
latex tutorial.tex
$(RAWEXAMPLEFILES): example.lisp
$(LISP) --eval '(progn (load "example.lisp") (quit))'
%.epsi: %.ps
ps2epsi $< $@
| 359 | Common Lisp | .l | 11 | 30.909091 | 61 | 0.781977 | rheaplex/minara | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 927f76b8f300e4d48c8cca1986ffe43f4e2cdde2d6b9d4e0067b0f30551da475 | 22,074 | [
-1
] |
22,119 | package.lisp | ghollisjr_cl-tab/package.lisp | (defpackage #:cl-tab
(:nicknames :tb)
(:use
:cl)
(:shadow :union)
(:export
;; control parameters
:*field-case-convert*
:*nil-order*
;; database connections
:database
:define-database
;; tables
:table
:make-table
:tab
:data
:table-ref
:tref ; short-hand for table-ref
:table-length
:tlength ; short-hand for table-length
:table-width
:twidth ; short-hand for table-width
:field-names
:table-map
:tmap ; shorthand for table-map
:filter
:table->list
:table->plist
:table->array
:table->sql
:add-field!
:del-field!
:insert!
:delete!
:update!
:join
:on
:on-keys
:union
:table-difference
:tdiff
:distinct
:top
:aggregate
:agg
:agg-function
:agg-min
:agg-max
:agg-sum
:agg-count
:agg-log-sum
:agg-mean
:with-aggregation
:with-agg
:hist-agg
:table-sort!
:tsort!
:order
:asc
:desc
:tlambda
:tlambda*
:fields
:field
:field-plist
;; CSV
:write-csv
:read-csv
;; org-mode
:table->org
;; SQL
:query
;; misc
:plist))
| 1,120 | Common Lisp | .lisp | 75 | 11.026667 | 41 | 0.61244 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 8208093fdc6203bf5eb586c25ec6358f40f5284726f28e99881bf8441cd0b019 | 22,119 | [
-1
] |
22,120 | database.lisp | ghollisjr_cl-tab/database.lisp | (in-package :tb)
(defstruct database
server
name
connection-spec
connection)
(defmacro define-database (symbol
properties
&body connection-body)
"Defines a new function bound to symbol which controls a smart database
connection object. The idea is to define a database connection, and
then call that function with a query whenever you want to run queries
against that database. However, unless the function is actually
called, no connections to the database are attempted.
properties is a let-like symbol-binding list for properties about the
database. Standard properties are :url, :name, :connection-string.
Lists of queries are also supported.
If :info is passed to the function, the connection information is
shown.
If :disconnect is passed to the function, the connection is closed.
However, if another query is attempted after calling for :disconnect,
the connection will be restarted."
(alexandria:with-gensyms (c cfn)
`(let ((,c nil)
(,cfn (lambda () ,@connection-body)))
,@(loop
for prop in properties
collect `(setf (get ',symbol ',(first prop)) ,(second prop)))
(defun ,symbol (query-or-op &optional (result-p t))
"Controls a smart database connection object. Call this function with
a query whenever you want to run queries against that database.
However, unless the function is actually called, no connections to the
database are attempted.
Lists of queries are also supported.
If :conn is passed to the function, the connection is made if needed
and the connection object is returned.
If :info is passed to the function, the connection information is
returned as a plist.
If :disconnect is passed to the function, the connection is closed.
However, if another query is attempted after calling for :disconnect,
the connection will be restarted."
(flet ((ensure-connection ()
(cond
((null ,c)
(setf ,c (funcall ,cfn)))
((not (clsql-sys:is-database-open ,c))
(setf ,c
(funcall ,cfn)))
(t nil))))
(typecase query-or-op
(null nil)
(symbol
(case query-or-op
(:conn
(ensure-connection)
,c)
(:info
(list :connection ,c
:name (when ,c (clsql:database-name ,c))
:type (when ,c (clsql:database-type ,c))))
(:disconnect
(when ,c
(clsql:disconnect :database ,c)
(setf ,c nil)))))
(t
(ensure-connection)
(query query-or-op
:result-p result-p
:database ,c))))))))
| 2,893 | Common Lisp | .lisp | 69 | 31.855072 | 79 | 0.609453 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 4da9e130d855603f67499404cad0d905f0d4ee250b7de938b9ca5df93a0961b9 | 22,120 | [
-1
] |
22,121 | csv.lisp | ghollisjr_cl-tab/csv.lisp | ;;;; CSV I/O
;;;;
;;;; General notes:
;;;;
;;;; * CSV I/O defaults to Lisp-friendly formatting. This means you
;;;; can naively save and load CSV files using Lisp code without any
;;;; issues. However, it also means that e.g. loading a CSV written
;;;; using this library with a tool like Excel or Libreoffice Calc
;;;; will have some blemishes, e.g. strings will include quotation
;;;; marks.
;;;;
;;;; * To generate data more useful for foreign tools, use the :lisp-p
;;;; argument and set it to NIL when running #'write-csv. This will
;;;; lead to default formatting for output as per the other
;;;; arguments passed through to the cl-csv functions, which usually
;;;; leads to useful interpretation by foreign tools.
;;;;
;;;; * Writing is low-memory use, but reading does lead to at least 2x
;;;; memory use for the table that is loaded until GC is called.
;;;; This could be improved in the future.
;;;;
;;;; * The functions here are ordinary functions since they rely on
;;;; generic table operations. This could be changed in the future.
(in-package :tb)
(defun write-csv (table
&key
stream
(lisp-p t)
(separator cl-csv:*separator*)
(field-names nil field-names-supplied-p)
(quote cl-csv:*quote*)
(escape cl-csv:*quote-escape*)
(always-quote cl-csv::*always-quote*)
(newline cl-csv::*write-newline*))
"Writes table as CSV to output stream using delimiter and either the
field-names from the table or those provided as a keyword argument.
If :field-names NIL is used, then no field names will be written and
only data will be written.
stream uses same semantics as cl-csv:write-csv, so NIL means return string.
If lisp-p is T (default), then fields are written so that they
can be read back as Lisp data through #'read. Otherwise, follows
cl-csv behavior for data.
quote and escape arguments are passed directly to
cl-csv:write-csv... functions, so they have the same usage."
(let ((cl-csv-keyargs
(list :quote quote
:escape escape
:always-quote always-quote
:newline newline))
(nil-stream (null stream))
(stream
(or stream
(make-string-output-stream)))
(field-names
(cond
;; Three usages:
;; 1. Just use table's field names
((null field-names-supplied-p)
(field-names table))
;; 2. Use custom field names that were supplied:
(field-names field-names)
;; 3. :field-names nil was supplied, don't write field names
((null field-names) nil))))
(when field-names
(apply #'cl-csv:write-csv-row
(field-names table)
:stream stream
:separator separator
cl-csv-keyargs))
(loop
for i below (tlength table)
for row = (tref table i :type 'list)
do
(apply #'cl-csv:write-csv-row
(map 'list
(if lisp-p
(lambda (f)
(format nil "~s" f))
#'identity)
row)
:stream stream
:separator separator
cl-csv-keyargs))
(when nil-stream
(get-output-stream-string stream))))
(defun read-csv (stream-or-string
&key
(lisp-p t)
(field-names nil field-names-supplied-p)
csv-reader row-fn map-fn data-map-fn sample skip-first-p
(separator cl-csv:*separator*)
(quote cl-csv:*quote*)
(escape cl-csv:*quote-escape*)
(unquoted-empty-string-is-nil cl-csv::*unquoted-empty-string-is-nil*)
(quoted-empty-string-is-nil cl-csv::*quoted-empty-string-is-nil*)
(trim-outer-whitespace cl-csv::*trim-outer-whitespace*)
(newline cl-csv::*read-newline*)
(escape-mode cl-csv::*escape-mode*))
"Read CSV file into a table from stream-or-string using cl-csv read
functions.
If lisp-p is T (default), then fields are assumed to be written
in a format that can be read by #'read. Otherwise, follows cl-csv
behavior."
(let ((cl-csv-keyargs
(list :CSV-READER CSV-READER
:ROW-FN ROW-FN
:MAP-FN MAP-FN
:DATA-MAP-FN DATA-MAP-FN
:SAMPLE SAMPLE
:SKIP-FIRST-P SKIP-FIRST-P
:SEPARATOR SEPARATOR
:QUOTE QUOTE
:ESCAPE ESCAPE
:UNQUOTED-EMPTY-STRING-IS-NIL UNQUOTED-EMPTY-STRING-IS-NIL
:QUOTED-EMPTY-STRING-IS-NIL QUOTED-EMPTY-STRING-IS-NIL
:TRIM-OUTER-WHITESPACE TRIM-OUTER-WHITESPACE
:NEWLINE NEWLINE
:ESCAPE-MODE ESCAPE-MODE)))
(destructuring-bind (read-field-names &rest data)
(apply #'cl-csv:read-csv
stream-or-string
cl-csv-keyargs)
(make-table (if lisp-p
(mapcar (lambda (row)
(mapcar (lambda (field)
(read-from-string field nil nil))
row))
data)
data)
:field-names
(cond
((null field-names-supplied-p)
read-field-names)
(field-names field-names)
((null field-names) nil))))))
;; cl-ana.makeres methods for saving tables as CSVs in project
(defmethod cl-ana.makeres:save-object ((tab table) path)
;; Write opener form to file:
(with-open-file (file path
:direction :output
:if-does-not-exist :create
:if-exists :supersede)
(write-csv tab :stream file)))
(defmethod cl-ana.makeres:load-object ((type (eql 'table)) path)
(with-open-file (file path
:direction :input)
(read-csv file)))
| 6,257 | Common Lisp | .lisp | 147 | 30.680272 | 88 | 0.555883 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 35d64a513d41955ed14898436109e5ad879182d23bdc96553b0f806548ccc643 | 22,121 | [
-1
] |
22,122 | tab.lisp | ghollisjr_cl-tab/tab.lisp | (declaim (optimize (speed 3)))
(in-package :tb)
;;;; Control Parameters
(defparameter *field-name-case-convert*
nil
"Controls how field names are converted to-from symbols.
* NIL Leave case untouched. Can lead to ugly symbols.
* T Up-case all field names. Bad for preserving field names.
* :invert All field name strings are down-cased, all symbols up-cased")
(defclass table ()
((data :initarg :data
:documentation "table data list of column arrays"
:accessor data
:type list)
(field-names :initarg :field-names
:documentation "list of table field names"
:reader field-names ; writer defined below
:type list)
(field-keywords :initarg :field-keywords
:documentation "list of table field name keyword symbols"
:reader field-keywords ; writer defined below
:type list)
(field-map :initarg :field-map
:initform (make-hash-table :test #'equal)
:documentation "hash table mapping from field name to column index"
:accessor field-map
:type hash-table)
(keyword-map :initarg :keyword-map
:initform (make-hash-table :test #'eq)
:documentation "hash table mapping from field keyword to column index"
:accessor keyword-map
:type hash-table)))
(defun %init-field-keyword-maps! (table)
"Setup field-map & keyword-map using field-names in table"
(clrhash (field-map table))
(loop
for f in (field-names table)
for k in (field-keywords table)
for i from 0
do (setf (gethash k (keyword-map table))
(setf (gethash f (field-map table)) i))))
(defmethod (setf field-names) (new (table table))
(setf new (proper-field-names new)
(slot-value table 'field-names) new)
(setf (slot-value table 'field-keywords)
(field-names->keywords new))
(%init-field-keyword-maps! table)
new)
(defmethod (setf field-keywords) (new (table table))
;; rely on (setf field-names) to handle everything
(setf (field-names table)
(mapcar #'string new))
(field-keywords table))
;;; Proper field names:
;;;
;;; Proper field names are a list of field names so that every name is
;;; unique and obeys the case convention set by
;;; *field-name-case-convert*.
(defun proper-field-names (field-names)
"Accepts a list of field names and modifies them to ensure that each
field is unique and adheres to the standard set by
*field-name-case-convert*.
Any field name that collides with a previous field name will have a
#\. character prepended, repeating until it no longer collides with
any other field names."
(let ((result (make-array (length field-names)
:initial-contents field-names)))
(flet ((collides-p (n &optional (end 0))
(find n result :test #'equal :end end)))
(loop
for n in field-names
for i from 0
do
(case *field-name-case-convert*
((T) (setf n (string-upcase n)))
(:invert (setf n (string-downcase n))))
(loop while (collides-p n i)
do (setf n (concatenate 'string "." n)))
(setf (aref result i) n)
finally (return (coerce result 'list))))))
(defun field-names->keywords (proper-field-names)
"Returns a list of keyword symbols from proper-field-names using the
convention set by *field-name-case-convert*"
(mapcar (lambda (s)
(case *field-name-case-convert*
(:invert (intern (string-upcase s) :keyword))
(t (intern s :keyword))))
proper-field-names))
(defmethod initialize-instance :after ((tab table) &rest init-args)
(declare (ignorable init-args))
;; First fix field names
(setf (slot-value tab 'field-names)
(proper-field-names (field-names tab)))
;; Then set field symbols:
(setf (slot-value tab 'field-keywords)
(field-names->keywords (field-names tab)))
;; Establish name->index map
(%init-field-keyword-maps! tab))
(defgeneric table-length (table)
(:documentation "Returns number of rows of table")
(:method ((table table))
(length (first (data table)))))
(setf (symbol-function 'tlength)
#'table-length)
(defgeneric table-width (table)
(:documentation "Returns number of fields/columns of table")
(:method ((table table))
(length (data table))))
(setf (symbol-function 'twidth)
#'table-width)
(defgeneric make-table (data &key field-names &allow-other-keys)
(:documentation
"Generic table creation function. Should have methods to e.g. create
from plists, alists, other tables, CSVs, SQL queries etc.")
;; basic method for tables:
(:method ((data table)
&key
field-names
empty-p)
(make-instance 'table
:data
(unless empty-p
(mapcar #'alexandria:copy-array
(data data)))
:field-names (mapcar #'string
(if field-names
field-names
(copy-list (field-names data)))))))
;; shorthands:
(defun table (data &optional field-names)
(make-table data :field-names field-names))
(setf (symbol-function 'tab) #'table)
;;; More on tables:
;;;
;;; A table's data is a list of column arrays.
;;;
;;; A table index is an alist mapping from column value to row number
;;; sorted by column value. Not sure if I'm keeping this or not,
;;; might not bother implementing until later.
;;;
;;; need method to get columns by name, index etc. can be generic,
;;; could get crazy with macros too to allow formulas of columns to be
;;; accessed and written without quotes. just a thought, but pandas
;;; has string formulas so it might be interesting to see what Lisp
;;; can do with macros and S-expressions to allow computational
;;; columns.
;;; make-table methods:
;; possibly most used: parse different types of lists to create table.
(defmethod make-table ((data list)
&key
field-names)
(declare (list field-names))
(setf field-names (mapcar #'string field-names))
(labels (;; list-of-lists-p
(lolp (x)
(and (car x)
(listp (car x))))
;; list of plists
(plistp (x)
(and (lolp x)
(caar x)
(symbolp (caar x)))))
(let (table-data table-length table-width)
(cond
((plistp data)
;; get field names from plists:
(let ((field-symbols
(mapcar #'first
(cl-ana.list-utils:group (first data) 2))))
(setf field-names (mapcar #'string field-symbols)
table-length (length data)
table-width (length field-symbols)
table-data
(loop
for i below table-width
collecting (make-array table-length
:adjustable t :fill-pointer t)))
(loop
for plist in data
for i from 0
do
(let ((values
(mapcar (lambda (f)
(getf plist f))
field-symbols)))
(map nil
(lambda (v a)
(setf (aref a i) v))
values table-data)))))
((lolp data)
;; can't get field names, leave for later
(setf table-length (length data)
table-width (length (car data))
table-data
(loop
for i below table-width
collecting (make-array table-length
:adjustable t :fill-pointer t)))
(loop
for list in data
for i from 0
do
(map nil
(lambda (v a)
(setf (aref a i)
v))
list table-data)))
;; default case: empty table, no columns, no names
(t nil))
(make-instance 'table
:data table-data
:field-names (if field-names
field-names
(loop
for x from 1 to (or table-width 0)
collecting
(format nil "x~a" x)))))))
;;; Table row access:
(defgeneric table-ref (table index &key type &allow-other-keys)
(:documentation "Return a row/column from the table as a sequence of data.
type controls type of sequence. If index is integer/list of integers,
return row(s). If index is string/list of strings, return
field/column(s).")
(:method ((table table) (index integer)
&key (type 'plist))
(case type
(plist
(mapcan (lambda (k v)
(list k v))
(field-keywords table)
(mapcar (lambda (column) (aref column index))
(data table))))
(t
(map type
(lambda (column)
(aref column index))
(data table)))))
(:method ((table table) (index string)
&key
(type 'list))
(let ((index (gethash index (field-map table))))
(when index
(coerce (elt (data table) index) type))))
(:method ((table table) (index symbol)
&key
(type 'list))
(table-ref table (string index) :type type))
(:method ((table table) (index list)
&key
(type 'plist)
(test #'equal))
(when index
(mapcar
(lambda (f) (table-ref table f
:test test
:type (if (and (stringp f)
(eq type 'plist))
'list
type)))
index))))
(setf (symbol-function 'tref) #'table-ref)
(defmethod (setf table-ref) (new (table table)
(index string)
&key &allow-other-keys)
"Sets a column in table named like index. New column value can be any
sequence, but should have same length as table. (Old values beyond
new column data length will remain unchanged.)"
(with-accessors ((data data)
(field-map field-map))
table
(let* ((c (elt data (gethash index field-map)))
(i -1))
(block set
(map nil (lambda (f)
(unless (< i (tlength table))
(return-from set))
(setf (aref c (incf i)) f))
new)))
new))
(defmethod (setf table-ref) (new (table table)
(index symbol)
&key &allow-other-keys)
"Sets a column in table named like index. New column value can be any
sequence, but should have same length as table. (Old values beyond
new column data length will remain unchanged.)"
(setf (table-ref table (string index)) new))
(defmethod (setf table-ref) (new (table table) (index integer) &key &allow-other-keys)
"Sets a row in table located at integer index. New row value can be
a plist, list, or vector."
(with-accessors ((data data)
(keyword-map keyword-map))
table
(typecase new
(vector
(loop
for c in data
for n across new
do (setf (aref c index) n)))
(list
(if (keywordp (car new))
;; plist
(do ((nnew new (cddr nnew)))
((null nnew))
(let* ((k (car nnew))
(v (cadr nnew))
(i (gethash k keyword-map)))
(setf (aref (elt data i) index)
v)))
;; list
(loop
for c in data
for n in new
do (setf (aref c index) n)))))
new))
(setf (fdefinition '(setf tref))
(function (setf table-ref)))
;;; Table mapping:
(defun table-map (row-fn table
&key
(type 'table)
(field-names nil field-names-supplied-p))
"Maps a function row-fn across table, supplying each field as a
distinct keyword argument to row-fn using the field-keywords from
table, and returning a new table with fields specified either by the
keyword symbols in the result list or explicitly by field-names.
row-fn should return a list of new field values as a plist, or as a
list of field values if field-names is supplied. (Not supplying
field-names but only supplying a list of results will result in
default field names being supplied, e.g. X1, X2....)
type can be one of NIL, 'table, 'array, 'list, or 'plist to yield
difference result types. For NIL, no result is returned. For array,
first index yields row, second yields field/column. For list, result
is a list of field-lists."
(let* ((length (table-length table))
(field-names (proper-field-names field-names))
(field-name-check-p t)
(field-keywords (field-names->keywords field-names)))
(flet ((row->plist (row)
;; on first call, check for field-names and set correctly
;; if needed
(when (and (not field-names-supplied-p)
field-name-check-p)
(setf field-name-check-p nil)
(when (keywordp (car row))
(setf field-names
(proper-field-names
(loop
for i from 0
for s in row
when (evenp i)
collect (string s)))))
(unless field-names
(setf field-names
(proper-field-names
(loop
for x from 1 to (length row)
collecting
(format nil "x~a" x)))))
(setf field-keywords
(field-names->keywords field-names)))
(typecase (car row)
(null nil)
(keyword row)
(t (mapcan (lambda (k v)
(list k v))
field-keywords
row))))
(row->list (row)
(typecase (car row)
(null nil)
(keyword (loop
for i from 0
for x in row
when (oddp i)
collect x))
(t row))))
(case type
((nil)
(loop
for i below length
do
(apply row-fn
(table-ref table i :type 'plist))))
(table
(make-table
;; code reuse
(apply #'table-map row-fn table
:type 'plist
(when field-names-supplied-p
(list :field-names field-names)))))
(array
(let* ((width (table-width table))
(result (make-array (list length width))))
(loop
for i below length
do
(let ((row
(row->list
(apply row-fn
(table-ref table i :type 'plist)))))
(loop
for j below width
for x in row
do (setf (aref result i j)
x))))
result))
(list
(loop
for i below length
collecting
(let ((r (apply row-fn
(table-ref table i :type 'plist))))
(cond
((and (eq type 'list)
(atom r))
r)
((null r) nil)
(t (row->list r))))))
(plist
(loop
for i below length
collecting
(row->plist
(apply row-fn
(table-ref table i :type 'plist)))))))))
(setf (symbol-function 'tmap) #'table-map)
;; Utilities using map:
(defun table->plist (table)
(table-map #'list table :type 'plist))
(defun table->list (table &optional flat-p)
(let ((r (table-map #'list table :type 'list)))
(if flat-p
(apply #'append r)
r)))
(defun table->array (table)
(table-map #'list table :type 'array))
;;; Column addition:
(defgeneric add-field! (table name
&optional value-or-function
&key
end-p
&allow-other-keys)
(:documentation "Adds a new column to table with name and either a fixed value, a list
of values, or a function which will be supplied the table's other
fields as distinct arguments and which should return a value to insert
as the new field value for each row. If value-or-function is NIL, NIL
will be inserted as new value of field. end-p controls whether to add
the column to the front of the columns list or the end.")
(:method ((table table) name &optional value-or-list-or-function
&key (end-p t)
&allow-other-keys)
(let* ((fn (typecase value-or-list-or-function
(null (constantly nil))
(list (let ((l value-or-list-or-function))
(lambda (&rest args)
(declare (ignore args))
(pop l))))
(function value-or-list-or-function)
(t (constantly value-or-list-or-function))))
(column
(make-array (tlength table)
:initial-contents (tmap fn table :type 'list)
:adjustable t
:fill-pointer t)))
(with-accessors ((field-names field-names)
(data data))
table
(if end-p
(setf data (nconc data (list column))
field-names (nconc field-names (list name)))
(setf data (cons column data)
field-names (cons name field-names)))))
table))
(defgeneric del-field! (table name-or-index)
(:documentation "Remove column from table specified by name or index.")
(:method ((table table) name-or-index)
(with-accessors ((field-names field-names)
(data data))
table
(let* ((index
(typecase name-or-index
(string (position name-or-index
field-names
:test #'string=))
(integer name-or-index))))
(setf field-names (loop
for i from 0
for fn in field-names
when (not (= i index))
collecting fn)
data (loop
for i from 0
for d in data
when (not (= i index))
collecting d))
table))))
(defgeneric insert! (table &rest rows)
(:documentation "Insert row into table. Rows should be plists or lists.")
(:method ((table table) &rest rows)
(with-accessors ((data data)) table
(flet ((insert (row)
(typecase (car row)
(keyword
(let ((row
(loop
for k in (field-keywords table)
collect
(getf row k))))
(map nil (lambda (col new-field)
(vector-push-extend new-field col))
data
row)))
(t
(map nil (lambda (col new-field)
(vector-push-extend new-field col))
data
row)))))
(map nil #'insert rows)
table))))
(defgeneric delete! (table condition &key &allow-other-keys)
(:documentation "Deletes rows indicated by condition. condition can be one of:
* integer index: delete specific row indicated by index.
* list of integer indices: delete rows indicated by indices.
* function: A boolean-valued function that accepts the row values as
distinct arguments and indicates when a row should be deleted by
returning T or NIL if not to be deleted.")
;; Backbone method:
;;
;; :sorted-p t -> no need to sort indices
(:method ((table table) (condition list) &key sorted-p &allow-other-keys)
(with-accessors ((data data))
table
(let ((table-length (table-length table))
(sorted (if sorted-p
(copy-list condition)
(sort (copy-list condition) #'<)))
(n 0))
(labels ((shift-array (array start end delta)
(loop
for i from start below end
when (and (not (minusp (+ i delta)))
(not (>= (+ i delta) table-length)))
do (setf (aref array (+ i delta))
(aref array i)))
array)
(shift (start end delta)
(map nil
(lambda (column) (shift-array column start end delta))
data)))
(do () ((null sorted))
(let ((i (pop sorted)))
(shift (1+ i)
(or (first sorted) table-length)
(- (incf n)))))
(map nil
(lambda (column)
(adjust-array column
(- table-length n)
:fill-pointer t))
data)
table))))
;; Single-index case:
(:method ((table table) (condition integer) &key &allow-other-keys)
(delete! table (list condition)))
;; Boolean function case:
(:method ((table table) (condition function) &key &allow-other-keys)
(let ((indices nil))
(loop
for i below (table-length table)
for row = (table-ref table i :type 'plist)
when (apply condition row)
do (push i indices))
(delete! table
(nreverse indices)
:sorted-p t))))
(defgeneric truncate! (table)
(:documentation "Truncates table (deletes all rows, preserves
structure).")
(:method ((table table))
(map nil (lambda (column) (adjust-array column 0 :fill-pointer t))
(data table))
table))
;;; Aggregations:
;;;
;;; This was a surprisingly difficult concept for me to find a
;;; suitable, beautiful, Lispy expression, but ultimately the answer
;;; was simple: Closures.
;;;
;;; - There is a main aggregation function: #'aggregate. This
;;; function processes a table to compute one aggregation via a
;;; supplied function argument. This might seem limited, however:
;;; This one aggregation is interpreted as a row of data, so that if
;;; the results of the aggregation are lists, then the elements of
;;; the list are interpreted as columns.
;;;
;;; - The aggregation function argument is actually a function which
;;; accepts a group argument and returns a function with a specific
;;; calling protocol: When called with no arguments, return the
;;; aggregation. When called with arguments, those arguments are
;;; the fields of a row of the table which must be aggregated.
;;;
;;; - Many simple aggregations have been defined for use,
;;; e.g. #'agg-sum or #'agg-mean, and there is a general purpose
;;; helper function #'agg which can create a new aggregator function
;;; using any associative function that could be used for computing
;;; a reduction. (NOTE: #'agg is not suitable for closures as the
;;; state is not correctly maintained per-group.)
;;;
;;; - The macro with-aggregation helps define a new aggregation using
;;; a set of existing aggregate functions (or functions created in
;;; the aggregate bindings, advanced usage) that can immediately be
;;; used to return an aggregate table using #'aggregate.
;; Some basic aggregate functions:
(defun agg-function (fn &optional (default-value 0) agg-all-p)
"Takes any function accepting at least 2 optional arguments and converts it to
an aggregate function. This works perfectly for functions that need
no state management, aka pure functions. It may work in other cases
on a case-by-case basis.
Use this as a reference implementation for your own aggregation functions: They must accept a context, and then optional arguments for the accumulation and new datum.
NOTE: If NIL is supplied, then nothing is aggregated."
(lambda (&optional group)
(declare (ignore group))
(let ((acc default-value))
(lambda (&optional
(datum nil datum-supplied-p))
(if (and datum-supplied-p
(or agg-all-p datum))
(setf acc (funcall fn acc datum))
acc)))))
;; Min/max aggregations
(declaim (function asc desc))
(setf (symbol-function 'agg-min)
(agg-function
(lambda (agg val)
(if (null agg)
val
(if (asc agg val)
agg
val)))
nil))
(setf (documentation #'agg-min 'function)
"Minimization aggregation for use with aggregate. See all aggregates
via (apropos \"agg-\")")
(setf (symbol-function 'agg-max)
(agg-function
(lambda (agg val)
(if (null agg)
val
(if (desc agg val)
agg
val)))
nil))
(setf (documentation #'agg-max 'function)
"Maximization aggregation for use with aggregate. See all aggregates
via (apropos \"agg-\")")
;; Count aggregation
(setf (symbol-function 'agg-count)
;; alert: this is sneaky
(agg-function (lambda (v x)
(declare (ignore x))
(1+ v))
0))
(setf (documentation #'agg-count 'function)
"Counting aggregation for use with aggregate. See all aggregates
via (apropos \"agg-\")")
;; Sum aggregation
(setf (symbol-function 'agg-sum)
(agg-function #'+ 0))
(setf (documentation #'agg-sum 'function)
"Sum aggregation for use with aggregate. See all aggregates
via (apropos \"agg-\")")
;; (Natural) Log-sum aggregration (log of product)
(setf (symbol-function 'agg-log-sum)
(agg-function (lambda (v x)
(+ v (log x)))
0))
(setf (documentation #'agg-log-sum 'function)
"Sum-of-logs or log-of-product aggregation for use with
aggregate. See all aggregates via (apropos \"agg-\")")
;; Mean aggregation
(defun agg-mean (&optional (type 'number))
"Mean aggregation function. See all aggregates via (apropos \"agg-\")"
(lambda (&optional group)
(declare (ignore group))
(let ((count (coerce 0 type))
(sum (coerce 0 type)))
(lambda (&optional datum)
(if datum
(setf count (1+ count)
sum (+ sum datum))
(cl-ana.gmath:protected-/ sum count))))))
(defun aggregate (aggregator table
&key
(group-fn (constantly t) group-fn-supplied-p)
(test 'equal)
field-names)
"Return the aggregation produced by
1. Grouping records by the group function group-fn, with distinction
given by the test-fn.
2. Calling row-reduce-fn on each row from each group as if by #'reduce, associating the accumulated result with its group.
3. Returning a table with rows given by the groups and columns given by the accumulated result of row-reduce-fn.
aggregator should accept all table fields as distinct input keyword
arguments and return a plist of values to be considered the fields for
the resulting aggregate table. If lists of values are returned, then
field-names should be supplied or default field names will be
generated.
group-fn can also be set by supplying a list (agg-fn group-fn) as the
aggregator argument. However, the group-fn keyword argument will
override the group function."
;; Handle list form of aggregator argument
(when (listp aggregator)
(unless group-fn-supplied-p
(setf group-fn (second aggregator)))
(setf aggregator (first aggregator)))
(let* ((agg-map (make-hash-table :test test)))
(loop
for i below (table-length table)
for row = (table-ref table i :type 'plist)
do
(let* ((group (apply group-fn row)))
(let (aggfn)
;; ensure agg is in agg-map and get it into aggfn
(unless (setf aggfn (gethash group agg-map))
(setf aggfn
(setf (gethash group agg-map)
(funcall aggregator group))))
;; Execute aggregation
(apply aggfn row))))
;; Form new table by a call to each aggfn in agg-map with not
;; argument:
(make-table
(loop
for key being the hash-keys in agg-map
for aggfn being the hash-values in agg-map
collecting (alexandria:ensure-list (funcall aggfn)))
:field-names field-names)))
(setf (symbol-function 'agg) #'aggregate)
;;; Filters
;;;
;;; I thought about using #'where to be more like SQL, but #'filter
;;; suits my taste better.
(defgeneric filter (function table &key &allow-other-keys)
(:documentation "Filters a table using boolean-valued function applied to each row
which receives fields as distinct arguments.")
(:method (fn (tab table) &key &allow-other-keys)
(make-table
(remove-if-not (lambda (row)
(apply fn row))
(table->plist tab))
:field-names (field-names tab))))
;;; Joins
;;;
;;; Joins are a place where some real benefits can be had through
;;; Lisp's flexible syntax and functional techniques.
;; Starting from simple approach: Binary join functions
(defun %join-loop (t1 t2 condition-fn
&key (type :inner)
field-names)
"Accepts
* Tables t1 and t2.
* Condition function which accepts a row from each table and returns T
or NIL when a join of the rows should be accepted or rejected.
* Type of join: :inner (default), :left, :right, or :full."
;; I'm using a bit-vector to indicate which rows from the right
;; table have been included in the result to support the case of the
;; full join. There might be other approaches that work better, but
;; this is easy to write and not that bad memory wise.
(let* (;; right index vector:
;; 1 if already included in result, 0 if not.
(ri (when (eq type :full)
(make-array (table-length t2)
:element-type 'bit
:initial-element 0)))
(lfns (field-names t1))
(rfns (field-names t2))
(field-names (if field-names
field-names
(proper-field-names
(append lfns rfns))))
(new-rfns (subseq field-names
(length lfns)))
(rfns-map (let ((ht (make-hash-table :test 'eq)))
(loop
for old in (field-names->keywords rfns)
for new in (field-names->keywords new-rfns)
do (setf (gethash old ht) new))
ht))
(field-names (or field-names
(append lfns
rfns)))
;; results pushed into list instead of table for efficiency
(result nil)
included-p)
(flet ((fix-right-fields (field-plist)
;; Fixes plist so that the fields coming from plist are
;; converted to match the new field names
(let ((result (copy-list field-plist)))
(loop
for c on result
for i from 0
when (evenp i)
do (setf (car c)
(gethash (car c) rfns-map))
finally (return result)))))
;; switching arguments for right join
(when (eq type :right)
(rotatef t1 t2))
(loop
for i1 below (tlength t1)
for r1 = (if (eq type :right)
(fix-right-fields (tref t1 i1))
(tref t1 i1))
do (setf included-p nil)
(loop
for i2 below (tlength t2)
for r2 = (if (not (eq type :right))
(fix-right-fields (tref t2 i2))
(tref t2 i2))
do
(let ((j (apply condition-fn (append r1 r2))))
(when j
(push (if (eq type :right)
(append r2 r1)
(append r1 r2))
result)
(when (and (not (eq type :inner))
(not included-p))
(setf included-p t))
(when (eq type :full)
(setf (elt ri i2) 1)))))
(when (and (not (eq type :inner))
(not included-p))
(push r1
result)))
;; fixing data & tables for right join:
(when (eq type :right)
(rotatef t1 t2))
;; post-processing missing right rows for full join:
(when (eq type :full)
(dotimes (i (table-length t2))
(when (zerop (elt ri i))
(push (fix-right-fields (table-ref t2 i))
result))))
(make-table (nreverse result) :field-names field-names))))
;; Binary hash equijoin function:
;;
;; Arbitrary hashes of rows are also supported by passing (lfn rfn) as
;; eqs instead of a list of equivalent field names/indices.
;;
;; NOTE: This function still supports the index joining, but I have
;; not used this in the general #'join front-end function, as the
;; explicit function is sufficient.
(defun %join-hash (t1 t2 eqs
&key
(test 'equal)
(type :inner)
field-names)
"Uses hash tables to match rows using lists of keys on which to join
the tables as specified in eqs.
eqs should be a list of equivalence lists or a list of two functions
that will be applied to the input rows (with fields supplied as
distinct arguments) to compute values to use as hash keys.
When using equivalence lists, each equivalence list should contain 2
elements:
* A field name or index from t1.
* A field name or index from t2.
These pairs of field specifiers indicate an equivalence relationship
between the fields specified, which in combination will be used to
perform the join.
test can be one of the supported tests for hash tables.
type can be one of :inner (default), :left, :right, or :full."
(let* (;; left index vector:
;; 1 if already included in result, 0 if not.
(li (when (or (eq type :full)
(eq type :left))
(make-array (table-length t1)
:element-type 'bit
:initial-element 0)))
;; right index vector:
;; 1 if already included in result, 0 if not.
(ri (when (or (eq type :full)
(eq type :right))
(make-array (table-length t2)
:element-type 'bit
:initial-element 0)))
(field-names (or field-names
(append (field-names t1)
(field-names t2))))
;; results pushed into list instead of table for efficiency
(result nil)
(lmap (make-hash-table :test test))
(rmap (make-hash-table :test test)))
(let* ((leq-p (not (functionp (first eqs))))
(req-p (not (functionp (second eqs))))
(lfspecs (when leq-p (mapcar #'second eqs)))
(rfspecs (when req-p (mapcar #'first eqs)))
(lfindices (when leq-p
(sort (loop
for f in lfspecs
collecting
(if (integerp f)
f
(position f
(the list (field-names t1))
:test #'equal)))
#'<)))
(rfindices (when req-p
(sort (loop
for f in rfspecs
collecting
(if (integerp f)
f
(position f
(the list (field-names t1))
:test #'equal)))
#'<))))
(labels (;; functions to grab keys for right and left tables
(getfields (row indices)
(do* ((r row (cdr r))
(f (car r) (car r))
(i 0 (1+ i))
(result nil)
(tail nil))
((or (null indices)
(null r))
result)
(declare (fixnum i))
(when (= i (the fixnum (car indices)))
(if result
(setf (cdr tail) (cons f nil)
tail (cdr tail))
(setf result
(setf tail (cons f nil))))
(setf indices (cdr indices)))))
(rfields (row)
(getfields row rfindices))
(lfields (row)
(getfields row lfindices)))
(let* ((lkey (if leq-p
#'lfields
(first eqs)))
(rkey (if req-p
#'rfields
(second eqs))))
;; setup maps
(loop
for i below (table-length t1)
for r1 = (table-ref t1 i :type 'plist)
do
(push i (gethash (apply lkey r1) lmap)))
(loop
for i below (table-length t2)
for r2 = (table-ref t2 i :type 'plist)
do
(push i (gethash (apply rkey r2) rmap))))
;; Push intersection results:
(loop
for k being the hash-keys in lmap
for lindices being the hash-values in lmap
do
(let ((rindices (gethash k rmap)))
;; mark rows as being inserted
(when (and lindices rindices)
(when li
(map nil
(lambda (i)
(when (zerop (elt li i))
(setf (elt li i) 1)))
lindices))
(when ri
(map nil
(lambda (i)
(when (zerop (elt ri i))
(setf (elt ri i) 1)))
rindices)))
;; insert intersection rows
(when rindices
(let ((r1s (mapcar (lambda (i)
(table-ref t1 i :type 'list))
lindices))
(r2s (mapcar (lambda (i)
(table-ref t2 i :type 'list))
rindices)))
(dolist (r1 r1s)
(dolist (r2 r2s)
(push (append r1 r2)
result)))))))
;; Handle left/right/full non-intersections:
(labels ((lins ()
(dotimes (i (length li))
(let ((present (plusp (elt li i))))
(unless present
(push (append (table-ref t1 i :type 'list)
(loop
repeat (table-width t2)
collect nil))
result)))))
(rins ()
(dotimes (i (length ri))
(let ((present (plusp (elt ri i))))
(unless present
(push (append (loop
repeat (table-width t1)
collect nil)
(table-ref t2 i :type 'list))
result))))))
(case type
(:full (lins) (rins))
(:left (lins))
(:right (rins))))
;; Return result:
(make-table (nreverse result)
:field-names field-names)))))
;; Now provide nice front-end to the two previous binary join
;; operations:
(defgeneric on (table condition &key type &allow-other-keys)
(:documentation "Returns a specification for a join condition that can be used by
#'join to compute the join using the best approach.")
(:method ((table table) (condition function)
&key (type :inner) &allow-other-keys)
(list :loop table condition type))
(:method ((table table) (condition list)
&key (type :inner) (test 'equal) &allow-other-keys)
(list :hash table condition type test)))
(defun join (table &rest joins)
"Performs a series of joins on table using the specified list of joins.
Each join is a join specification returned by the #'on function.
Example of joining 3 tables first using a primary & foreign
key (efficient, uses hash tables to join) followed by a more general
condition (inefficient, uses nested loop):
(join t1
;; key/hash join:
(on t2
;; List of functions to generate values to hash & compare,
;; one from left table(s), one from right table
(list (lambda (r1)
(let ((foreign-key (elt r1 1)))
foreign-key))
(lambda (r2)
(let ((primary-key (elt r2 0)))
primary-key)))
:type :inner)
;; general condition join:
(on t3 (lambda (r3 r2 r1) (evenp (+ (elt r3 0) (elt r2 1))))
:type :inner))
* Note that the arguments to the first condition in a key/hash join's
left function are the rows of the already-joined tables in reverse
order of the table occurrences. This is to make it convenient to
ignore arguments for tables that are unlikely to be involved in
future joins.
* Note that the arguments to the second join's condition function are
rows from the tables supplied in reverse order to the occurence of
tables in the join. This was chosen to make it convenient to ignore
arguments for tables that are unlikely to be involved in future
joins."
(let* ((result table))
(loop
for join in joins
for i from 0
for algo = (first join) ; e.g. :loop, :hash
for table = (second join)
for condition = (third join)
for type = (fourth join) ; e.g. :inner
for join-test = (fifth join)
do
(setf result
(case algo
(:loop
(%join-loop result table
(the function condition)
:type type))
(:hash
(%join-hash result table condition
:type type
:test join-test)))))
result))
(defun union (tables
&key
all-p
(test #'equal))
"Returns the union/union-all of the input tables using the test
function to compare rows of data. If all-p is T, then union-all is
used rather than union (i.e. all rows are included)."
(let* ((tables (remove nil tables))
(fns (when tables
(field-names (first tables)))))
(make-table
(if all-p
(apply #'append
(mapcar #'table->list
tables))
(let ((result nil))
(dolist (x (apply #'append
(mapcar #'table->list
tables))
(nreverse result))
(pushnew x result :test test))))
:field-names fns)))
(defun distinct (table &key
(row-fn #'list)
(test 'equal))
"Uses a hash-table to ensure that each row of the table is distinct
according to the values of row-fn applied to each row and using the
supplied hash test parameter."
(let ((ht (make-hash-table :test test))
(rows nil))
(dotimes (i (table-length table))
(let* ((row (table-ref table i))
(key (apply row-fn row)))
(unless (gethash key ht)
(setf (gethash key ht) t)
(push i rows))))
(make-table
(loop
for i in (nreverse rows)
collect (table-ref table i))
:field-names (field-names table))))
(defun table-difference (table1 table2
&key
(test #'equal)
symmetric-p)
"Returns rows from table1 that are not present in table2 according to
test function.
If symmetric-p is T, then any rows that are only in either table are
returned rather than rows only in table1."
(let ((result
(make-table
(set-difference (table->plist table1)
(table->plist table2)
:test test))))
(when symmetric-p
(setf result
(union (list result
(make-table
(set-difference (table->plist table2)
(table->plist table1)
:test test)))
:all-p t ; duplicates preserved
:test test)))
result))
(setf (symbol-function 'tdiff) #'table-difference)
(defun update! (table set-fn
&optional
(condition (constantly t))
&key (type 'plist))
"Updates table by applying set-fn to each row. set-fn should return a
new row of values to replace the current row.
condition can be
* a function receiving a row as a plist
* an index denoting a specific row to update
* a list of indices denoting rows to update
type can be one of 'plist, 'list, or 'vector denoting the type of
sequence returned by the set-fn."
(let ((indices
(typecase condition
(function
(loop
for i below (tlength table)
for row = (tref table i :type 'plist)
when (apply condition row)
collect i))
(integer (list condition))
(list condition))))
(loop
for i in indices
do (setf (tref table i :type type)
(apply set-fn
(tref table i :type 'plist))))
table))
(defparameter *nil-order* :before
"Controls how NIL is treated when compared to other data. These are
the following values:
- :before -> NIL is always listed first when data is sorted via #'asc/#'desc
- :after -> NIL is always listed last when data is sorted via #'asc/#'desc
- :greater -> NIL is considered greater than other data
- :less -> NIL is considered less than other data")
(defgeneric asc (x y)
(:documentation "Returns T if x precedes y (or equal). Works for a variety of types.")
(:method ((x number) (y number))
(<= x y))
(:method ((x character) (y character))
(char<= x y))
(:method ((x string) (y string))
(string<= x y))
(:method ((x symbol) (y symbol))
(or (eq x y)
(string<= (string x) (string y))))
(:method ((x sequence) (y sequence))
(map nil
(lambda (xx yy)
(unless (asc xx yy) (return-from asc NIL)))
x y)
T)
(:method ((x null) y)
(ecase *nil-order*
(:before t)
(:after nil)
(:greater nil)
(:less t)))
(:method (x (y null))
(ecase *nil-order*
(:before nil)
(:after t)
(:greater t)
(:less nil))))
(defgeneric desc (x y)
(:documentation "Returns T if y precedes x (or equal). Works for a variety of types.")
(:method ((x number) (y number))
(>= x y))
(:method ((x character) (y character))
(char>= x y))
(:method ((x string) (y string))
(string>= x y))
(:method ((x symbol) (y symbol))
(or (eq x y)
(string>= (string x) (string y))))
(:method ((x sequence) (y sequence))
(map nil
(lambda (xx yy)
(unless (desc xx yy) (return-from desc NIL)))
x y)
T)
(:method ((x null) y)
(ecase *nil-order*
(:before t)
(:after nil)
(:greater t)
(:less nil)))
(:method (x (y null))
(ecase *nil-order*
(:before nil)
(:after t)
(:greater nil)
(:less t))))
(defun table-sort! (table predicate)
"Sorts table using predicate. Use #'order to conveniently generate
predicate function.
predicate will be supplied a list of all fields from a table, but with
the value of each field being a list (left right) with the values of
the left and right rows being compared in an effective self-join.
predicate should return T when the left row comes before the right
row, NIL if right should come before left.
#'order provides a convenient SQL-like interface for the predicate."
(let ((indices
(loop
for i below (tlength table) collect i)))
(setf indices
(sort indices
(lambda (iL iR)
(let* ((rowL (tref table iL :type 'list))
(rowR (tref table iR :type 'list))
(row (mapcan (lambda (k L R)
(list k (list L R)))
(field-keywords table)
rowL
rowR)))
(apply predicate row)))))
(let ((d (make-array (tlength table) :adjustable t :fill-pointer t)))
(map nil
(lambda (col)
;; copy data to temp column
(dotimes (i (tlength table))
(setf (aref d i) (aref col i)))
;; copy rearranged data back to column
(map nil
(let ((index -1))
(lambda (i)
(setf (aref col (incf index))
(aref d i))))
indices))
(data table)))
table))
(setf (symbol-function 'tsort!) #'table-sort!)
(defun order (&rest order-specs)
"Returns a function useful for ordering rows of a table via #'tsort!.
Each order-spec should be be a list containing
* A tlambda function to produce values to compare between rows.
* A comparison function or specifier for that expression.
Note that the functions #'asc and #'desc are available to conveniently
specify ascending and descending sort for many different types. For
convenience, if :asc or :desc is used to specify the comparison, then
#'asc or #'desc will be used."
(tlambda ()
(block comp
(loop
for spec in order-specs
do
(destructuring-bind (vfn cfn) spec
(case cfn
(:asc (setf cfn #'asc))
(:desc (setf cfn #'desc)))
(let ((left
(loop
for i = 0 then (+ i 2)
for cons = fields then (cddr cons)
while cons
append (list (car cons) (caadr cons))))
(right
(loop
for i = 0 then (+ i 2)
for cons = fields then (cddr cons)
while cons
append (list (car cons) (cadadr cons)))))
(unless (funcall cfn
(apply vfn left)
(apply vfn right))
(return-from comp NIL)))))
T)))
(defun top (table &optional (n 1))
"Returns top row of table as p-list"
(when (plusp (tlength table))
(subseq (table->plist table) 0 n)))
| 52,796 | Common Lisp | .lisp | 1,312 | 28.032012 | 166 | 0.528354 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 3bda3590199d4f89b584b29c47e7496b2f611a9d743649cfbb06b6bab42f8070 | 22,122 | [
-1
] |
22,123 | macros.lisp | ghollisjr_cl-tab/macros.lisp | (in-package :tb)
(defmacro dotable ((vars table &optional result) &body body)
(alexandria:with-gensyms
(tab table-width table-length
row i data)
`(let ((,tab ,table))
(with-accessors ((,table-width table-width)
(,table-length table-length)
(,data data))
,tab
(do* ((,i 0 (1+ ,i)))
((>= ,i ,table-length) ,result)
(let ((,row (map 'list (lambda (d)
(aref d ,i))
,data)))
(symbol-macrolet
,(if (listp vars)
;; Two usages:
;; 1. vars is list of symbols:
(loop
for v in vars
for j from 0
collecting `(,v (aref ,row ,j)))
;; 2. vars is a symbol, so row vector should be
;; bound to vars
`((,vars ,row)))
,@body)))))))
;;; Compound aggregation:
(defmacro with-aggregation ((&optional group group-fn) agg-bindings
agg-result
table-field-lambda-list
&body agg-body)
"Macro that generates code to return a function that will create an
aggregation function using aggregate functions that are provided in
agg-bindings.
Each agg-binding must be of the form (fsym agg-form) where agg-form
evaluates to an aggregate closure. This function will be bound to
fsym as a callable function, e.g. (fsym ...) will work correclty as
will (funcall #'fsym ...). Simultaneously, for convenience, a
symbol-macrolet for that same symbol (e.g. fsym) will be bound to a
call to the closure with no arguments (e.g. (fsym)). This allows the
aggregation symbol to be used to access the value of the
aggregation, e.g. in the agg-result.
agg-result is a list of aggregate values to return per-group, and will
be treated as rows in the resulting aggregate table.
table-field-lambda-list will be treated as if supplied to tlambda, so
it should be a list of field arguments to be received by the function
being mapped across the table row plists.
This is useful for creating an aggregation to use with
aggregate.
If group is NIL, then the group argument will not be accessible nor
used in the aggregation (assumes single-group and therefore reasonable
group-fn, e.g. (constantly t)).
The first forms in agg-body can be declarations for the generated
aggregation function, i.e. they can declare things about the arguments
in the lambda list but not about the group (might fix in future)."
(alexandria:with-gensyms (args)
(let* ((group (or group (gensym "group")))
(aggs (loop
for b in agg-bindings collecting (gensym (string (first b)))))
(declarations
(remove-if-not (lambda (form) (and (listp form) (eq (first form) 'declare)))
agg-body))
(agg-body
(remove-if (lambda (form) (and (listp form) (eq (first form) 'declare)))
agg-body))
(agg-fn-form
`(lambda (,group)
(let (,@(loop
for a in aggs
for b in agg-bindings
collecting `(,a ,(second b))))
(labels ,(loop
for a in aggs
for b in agg-bindings
collecting
(destructuring-bind (fsym form) b
(declare (ignore form))
`(,fsym (&rest ,args)
(apply ,a ,args))))
(symbol-macrolet ,(loop
for b in agg-bindings
for fsym = (first b)
collecting
`(,fsym (,fsym)))
(tlambda (,@table-field-lambda-list)
,@declarations
(if fields
(progn ,@agg-body)
,agg-result))))))))
(if group-fn
`(list ,agg-fn-form ,group-fn)
agg-fn-form))))
(setf (macro-function 'with-agg) (macro-function 'with-aggregation))
(defmacro tlambda ((&rest fields) &body body)
"Generates a new lambda function which effectively transforms fields
into a lambda list of the form `(&key ,@fields &allow-other-keys) so
that any plist input can be parsed, and the fields that are desired by
the user are automatically assigned to a specific symbol.
fields is a variable bound to all fields in row as a plist.
Also provided in the body of the tlambda are macros and symbol macros
as follows:
* macro (field <string-or-keyword>): Returns field value from
row.
* symbol macros for any fields requested specifically in the
lambda-list.
Field arguments listed in the lambda-list, fields, and (field ...) are
all setf-able so that if desired, one can simply modify the fields in
a row and then return some function of that modified row. Useful for
simply changing values, adding/removing columns etc."
`(lambda (&rest fields)
(macrolet ((field (spec)
(typecase spec
(symbol `(getf fields ,(intern (string spec)
:keyword)))
(keyword `(getf fields ,spec))
(string `(getf fields
,(intern spec :keyword))))))
(symbol-macrolet (,@(loop
for field in fields
collect `(,field (field ,field))))
,@body))))
(defmacro tlambda* ((&rest fields) &body body)
"Variant of tlambda that automatically binds unbound variables to a
field with the keyword version of that symbol if available, or NIL if
not.
NOTE: If a dynamic/global variable has already been defined, then this
function will use that value even if a field named like that symbol
exists in the table."
(alexandria:with-gensyms (c)
`(tlambda (,@fields)
(handler-bind ((unbound-variable
(lambda (,c)
(use-value
(getf fields
(intern (string
(cell-error-name ,c))
:keyword))))))
,@body))))
(defmacro on-keys (table keys1
&rest args)
"Convenience macro for hash equijoin on key(s) for tables.
keys1 & keys2 can be lists of fields on which to equijoin, or just a
single field symbol denoting single-key equijoin.
If keys2 is not specified, then keys1 will be used from both tables.
Also supports key arguments:
* :type
* :test
type & test act just like they do for #'on.
Examples:
(on-keys tab x) ; join to tab on keys x from both tables
(on-keys tab x y) ; join to tab on keys x from left and y from right
(on-keys tab (x y) :type :full) ; full-join on x & y from both tables
(on-keys tab (x y) (y z) :type :left :test 'equalp) ; left join with test"
(let ((keys2 nil))
;; parse args
(unless (keywordp (car args))
(setf keys2 (pop args)))
(unless keys2 (setf keys2 keys1))
(destructuring-bind (&key test type) args
(unless type (setf type :inner))
(unless test (setf test ''equal))
(let ((keys1 (if (symbolp keys1) (list keys1) keys1))
(keys2 (if (symbolp keys2) (list keys2) keys2)))
`(on ,table
(list (tlambda ,keys1 (list ,@keys1))
(tlambda ,keys2 (list ,@keys2)))
:type ,type
:test ,test)))))
(defmacro field (symbol-or-symbols &optional (type 'plist))
"Returns a tlambda function that returns the field or a list of the
fields specified by the symbol or list of symbols that specify fields
from a table row. Especially useful for use with #'tsort!, #'order,
#'agg, and #'tmap when you want to use a subset of fields from a
table.
If type is NIL, the return value of the tlambda function is either a
field value if symbol-or-symbols is a symbol, or a list of fields if
it is a list.
If type is list, then a list is always returned.
If type is plist, then a plist of the fields is returned."
(let ((symbols (if (listp symbol-or-symbols)
symbol-or-symbols
(list symbol-or-symbols))))
`(tlambda (,@symbols)
,(case type
((nil)
(if (listp symbol-or-symbols)
`(list ,@symbols)
(car symbols)))
(list
`(list ,@symbols))
(plist
`(list ,@(mapcan (lambda (sym)
(list (intern (string sym) :keyword)
sym))
symbols)))))))
(defmacro hist-agg (&rest fields)
"Returns an aggregation function that bins the fields specified and
adds a |count| field to them."
(setf fields (mapcar (lambda (f) (intern (string f)))
fields))
(let ((keywords (mapcar (lambda (f) (intern (string f) :keyword))
fields)))
`(with-agg (g (field ,fields list))
((cnt (agg-count)))
(append (mapcan (lambda (f v)
(list f v))
',keywords g)
(list :|count| (cnt)))
()
(cnt 1))))
| 9,666 | Common Lisp | .lisp | 211 | 33.28436 | 89 | 0.554518 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 708a21f6f5e035cc27d94fadb093e87bd8108eb12cf215f2ac7adec552ef1543 | 22,123 | [
-1
] |
22,124 | misc.lisp | ghollisjr_cl-tab/misc.lisp | (in-package :tb)
;;;; Miscellaneous tools
(defun %center-pad (string width)
"Pads a string into a given width with space characters"
(let ((gap (- width (length string))))
(unless (plusp gap) ; bad args
(return-from %center-pad string))
(let* ((lgap (floor gap 2))
(rgap (- gap lgap)))
(concatenate 'string
(make-string lgap :initial-element #\Space)
string
(make-string rgap :initial-element #\Space)))))
;; Print an org-mode table:
(defun table->org (table &optional stream)
"Prints a table in org-mode syntax to stream. If stream is nil,
returns a string."
(let (null-stream)
(unless stream
(setf null-stream t))
(when null-stream
(setf stream (make-string-output-stream)))
(let ((widths
(mapcar (lambda (name col)
(+ 2
(reduce #'max
(map 'list
(lambda (c)
(length (format nil "~a" c)))
col)
:initial-value (length name))))
(field-names table)
(data table))))
;; header
(format stream
"|")
(loop
for n in (field-names table)
for w in widths
do (format stream "~a|"
(%center-pad n w)))
(terpri stream)
;; header-data divider line
(princ #\| stream)
(loop
for i from 0
for w in widths
do
(unless (zerop i)
(princ #\+ stream))
(princ (make-string w :initial-element #\-) stream))
(princ #\| stream)
(terpri stream)
;; data
(dotimes (i (tlength table))
(unless (zerop i) (terpri stream))
(let ((row (tref table i :type 'list)))
(format stream "|")
(loop
for c in row
for w in widths
do (format stream "~a|"
(%center-pad (format nil "~a" c)
w))))))
(when null-stream
(prog1 (get-output-stream-string stream)
(close stream)))))
| 2,261 | Common Lisp | .lisp | 67 | 21.791045 | 69 | 0.4733 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 8636b7c4770f6c1d3b388502e60c3fce895daa450879f4f5edf53e9ae49b0eed | 22,124 | [
-1
] |
22,125 | lsql.lisp | ghollisjr_cl-tab/lsql/lsql.lisp | ;;;; This is jibberish that I'm using to prototype a new Lisp-SQL
;;;; language. Let me show you its features!
;;;;
;;;; - Expression-based language: Everything is an expression,
;;;; including objects. Every expression has a value.
;;;;
;;;; Not true for SQL. E.g.:
;;;;
;;;; select * from tab;
;;;;
;;;; returns a table from a table. But:
;;;;
;;;; tab;
;;;;
;;;; returns an error since it is not a valid SQL query.
;;;;
;;;; - lsql is closed: Every lsql object can be an argument to another
;;;; lsql expression.
;;;;
;;;; Not true for SQL. E.g., given t1(x,y) and t2(x,z):
;;;;
;;;; select * from t1 join t2 on t1.x=t2.x
;;;;
;;;; returns a table with two columns named "x". This will be
;;;; returned to you as a "table" from the SQL client, but if you
;;;; try to use this in a CTE or insert the values into a table, the
;;;; SQL server will signal an error since columns must have
;;;; different names.
;;;;
;;;; - Multi-server: lsql expressions can refer to data located on any
;;;; system which has been defined, including the host system. lsql
;;;; expressions can be compiled to execute as SQL queries on SQL
;;;; servers or as Lisp code executed on the host system.
(ql:quickload :cl-tab)
(defpackage lsql
(:use :cl))
(in-package :lsql)
(defmacro defsys (&rest args) nil)
(defsys build1
(odbc "build1"
"QcDidSwDb001.ucsfmedicalcenter.org"
nil
:connection-string
"Driver={ODBC Driver 17 for SQL Server};Server=QcDidSwDb001.ucsfmedicalcenter.org;Database=home_gary;Trusted_Connection=Yes;"
:encoding :latin-1)
(*system* :ucsf)
(*db-conn* #'build1)
(clsql:*default-database* (funcall *db-conn* :conn))
(uffi:*default-foreign-encoding* :latin-1)
(*src-db-name* "CDW_SRC")
(*stage-db-name* "CDW_DEID_STAGE")
(*map-db-name* "CDW_DEID_MAP")
(*new-db-name* "CDW_NEW"))
(defclass field ()
((source
:initform nil
:initarg :source
:accessor field-source
:documentation "field source (table, object etc.)")
(symbol
:initform nil
:initarg :symbol
:accessor field-symbol
:documentation "field symbol (name)")))
(defun field (source symbol)
(setf symbol
(typecase symbol
(symbol symbol)
(string (intern symbol))))
(make-instance 'field
:source source
:symbol symbol))
(defmethod print-object ((f field) stream)
(format stream "@~s(~s)"
(field-source f)
(field-symbol f)))
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun field-reader (stream char)
(declare (ignore char))
(let ((source (read stream))
(symbols (read stream t nil t)))
(if (cdr symbols)
`(list ,@(mapcar (lambda (sym)
(typecase sym
(null nil)
(symbol `(field ,source ',sym))
(string `(field ,source ',(intern sym)))
(t (error "Field symbol must be NIL, symbol, or string"))))
symbols))
(let ((sym (first symbols)))
(typecase sym
(null nil)
(symbol `(field ,source ',sym))
(string `(field ,source ',(intern sym)))
(t (error "Field symbol must be NIL, symbol, or string"))))))))
(set-macro-character #\@ #'field-reader)
(defmacro sel (fields
&optional
from
where)
"Just a stub for now"
`'(sel ,fields ,from ,where))
;; example for a join query
(defun join-example (a b)
"
select a.x, a.y as \"y\",
b.y as \".y\", b.z
from a
left join b
on a.y = b.y
"
(sel (@a(x) @a(y) @b(y) @b(z)) ; sel shorthand for select
(join a
(to b ; to instead of on for grammatical reasons
(= @a(y) @b(y))
:left))))
#| The @tab(fields...) syntax is my proposed solution to the
table-field dereference problem. Examples:
@tab(f1 f2) => tab.f1, tab.f2
@tab((f1 field1) f2) => tab.f1 as field1, tab.f2
In lsql, fields are guaranteed to be unique in any given table, and
since all expressions that return tables must obey this guarantee, the
result is that sel must enforce field renaming if a collision occurs.
In the above example, none of the fields collide. However, if they do
collide then the automatic #\. prefix rule applies, e.g.:
(sel (@a(x y) @b(y z)) tab) =>
select a.x as x,
a.y as y,
b.y as ".y",
b.z as z
from tab
where the names are explicitly stated in the SQL query for clarity.
Any field with a nickname that is incompatible with the collision rule
will signal an error.
The system works by generating the query at runtime. There will be a
function which reads the query object and interprets the object
accordingly. This is necessary because the computations can involve
both local and remote systems. The computation specifications must be
examined to determine the necessary resources. If a computation can
be evaluated locally, a function can be compiled and then executed.
If a computation must be executed remotely, then it will be compiled
into SQL queries which will be sent to the servers as needed along
with necessary data transfer operations.
|#
(defun tab-example ()
(let ((tab (tb:table '((:x 1 :y 2)))))
@tab(x)))
| 5,387 | Common Lisp | .lisp | 147 | 31.29932 | 135 | 0.632235 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | bde27d99f4be3c598abddca683b155a946d58f3a6cf90565f7e98c5cd35716ae | 22,125 | [
-1
] |
22,126 | case.lisp | ghollisjr_cl-tab/example/case.lisp | (require 'cl-tab)
(in-package :tb)
;;;; Examples to show the use of *field-name-case-convert*
;;;;
;;;; There are currently 3 values for *field-name-case-convert*:
;;;;
;;;; * NIL => do not modify case. Symbols & strings match
;;;; and are case-sensitive.
;;;;
;;;; * T => Up-case strings & symbols. This is convenient
;;;; for the usual settings in the Lisp reader.
;;;;
;;;; * :invert => Down-case strings & up-case symbols. This is
;;;; similar to the inverted case setting in the
;;;; Lisp reader, and I happen to like the style.
(defun default-case-example ()
(let ((*field-name-case-convert* nil))
(tmap (tlambda (|x| |y|)
(list :|x| (+ |x| 2)
:|y| |y|))
(make-table '((1 2) (3 4)) :field-names '("x" "y")))))
(defun up-case-example ()
;; The lower case ("x" "y") field names will be automatically
;; up-cased when creating the table, and can thus be referenced with
;; :x & :y keyword symbols in a plist.
(let ((*field-name-case-convert* t))
(tmap (tlambda (x y)
(list :x (+ x 2)
:y y))
(make-table '((1 2) (3 4)) :field-names '("x" "y")))))
(defun invert-case-example ()
;; The lower case ("x" "y") field names will be retained, but can be
;; referenced with :x & :y keyword symbols in a plist since the
;; symbols are up-cased.
(let ((*field-name-case-convert* :invert))
(tmap (tlambda (x y)
(list :x (+ x 2)
:y y))
(make-table '((1 2) (3 4)) :field-names '("x" "y")))))
| 1,600 | Common Lisp | .lisp | 39 | 36.051282 | 70 | 0.552987 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 3d4e6504192939eaa6fb8cd9fe694a0cc47bcc0dc85c590ebb9ab623b66a31ad | 22,126 | [
-1
] |
22,127 | cheatsheet.lisp | ghollisjr_cl-tab/example/cheatsheet.lisp | ;;;; I thought it best to provide a cheat-sheet for those who are
;;;; familiar with SQL and want to know how to do what they already do
;;;; in SQL but using this Common Lisp library.
(in-package :tb)
;;; Selections: Without `where`, this is just a table object or a
;;; conversion of a table to some other data type:
;; select * from tab
tab ; as a table
(table->plist tab) ; as a plist
(table->list tab) ; as a list (WARNING: field names are not included)
(table->array tab) ; as a 2-d array (WARNING: field names are not included)
;; You can also select from a table to a list, e.g.:
(tmap (tlambda (x) x) tab :type 'list) ; => (X1 X2 ...)
;;; Selections with `where`: This needs #'filter
;; select * from tab where X > 0
(filter (tlambda (x) (> x 0)) tab) ; returns table, see above for type conversions
;;; Selections with `group by`: This is aggregation. Aggregation
;;; results are also tables and can be converted to different types as
;;; above.
;;;
;;; The with-aggregation (with-agg shorthand) macro returns a function
;;; that is expected by #'aggregate (agg shorthand). As part of
;;; aggregation, specific aggregation closures are needed. Various
;;; aggregation closures are already provided, e.g. #'agg-sum. These
;;; can be used in conjunction with #'agg and with-agg to perform
;;; grouped and non-grouped aggregations. Example grouped
;;; aggregation:
;; select x as "x", sum(y) as "sum(y)" from tab group by x
(agg (with-agg gx ; gx is bound to grouped value, x in this case
((ysum (agg-sum))) ; agg bindings
(list :|x| gx ; gx is bound to grouped value, x in this case
:|sum(y)| ysum) ; ysum from agg binding above, can also be (ysum)
(|y|) ; we want field y from each row
(ysum |y|)) ; now we sum y from each row
tab
:group-fn (tlambda (|x|) |x|)) ; group by x
;;; Aggregations without group-by: Simpler form of aggregation
;; select sum(y) as "sum(y)" from tab
(agg (with-agg () ; no need to group, singleton group
((ysum (agg-sum))) ; same agg binding as above
(list :|sum(y)| ysum) ; ysum from agg binding above
(|y|) ; we want field y from each row
(ysum |y|)) ; now we sum it each row
tab)
;;; Selections with different fields in result: This needs tmap
;; select x as "x", y as "y", x+y as "z" from tab
(tmap (tlambda (|x| |y|)
(list :|x| |x|
:|y| |y|
:|z| (+ |x| |y|)))
tab)
;; can also do this without copying all fields manually via fields & (field ...)
(tmap (tlambda ()
(append fields
(list :|z| (+ (field |x|) (field |y|)))))
tab)
;; select x as "x" from tab -- example of ignoring columns
(tmap (tlambda (|x|) (list :|x| |x|))
tab)
;;; Joins: There are two different joins supported, and they are
;;; specified using different arguments to the #'on function which
;;; produces join specifications for the #'join function. The two
;;; join types are
;;;
;;; loop join: General join. Requires nested loop over tables.
;;; hash equijoin: Equivalence join using hashed keys.
;;;
;;; (Merge equijoin might be added in future, but not a priority.)
;; select * from a
;; inner join b
;; on a.x = b.x
;; As a loop join:
(join a
(on b
;; Notice |.x| for second x field: This is a fundamental
;; part of how field names are handled. Field names must be
;; unique, so they are automatically prepended with a '.'
;; character to fields from the right table in a join if
;; they collide with a field name in a left table.
(tlambda (|x| |.x|)
(= |x| |.x|))
:type :inner)) ; :inner is default type
;; As a hash equijoin:
(join a
(on b
;; Instead of a single function, a list of two functions
;; which each return a key to be hashed and compared is
;; supplied as the join condition.
;;
;;
;; Notice no need for '.' prefix in either function this
;; time, as functions are applied to pre-joined table rows,
;; not post-joined table.
(list (tlambda (|x|) |x|)
(tlambda (|x|) |x|))
:type :inner))
;; More complex joins are handled by adding more #'on statements and
;; specifing different types, e.g.:
;; select * from a
;; left join b
;; on a.x = b.y
;; full join c
;; on b.z > c.z
(join a
(on b
(list (tlambda (|x|) |x|)
(tlambda (|y|) |y|))
:type :left)
(on c
(tlambda (|z| |.z|) ; z from b, .z from c
(> |z| |.z|))
:type :full))
;;; Unions: Unions are accomplished via #'union. tb:union shadows
;;; cl:union, so be aware if you use the :cl-tab or :tb package.
;;; Exclusive and inclusive unions are supported (e.g. `union` and
;;; `union all` in SQL).
;; Example:
;; select * from a
;; union
;; select * from b
(union (list a b))
;; Example:
;; select * from a
;; union all
;; select * from b
(union (list a b) :all-p t)
;;; select distinct...: This is supported via #'distinct.
;; Example:
;; select distinct * from tab
(distinct tab)
;; Example:
;; select distinct x, y from tab
(distinct tab
:row-fn
(tlambda (|x| |y|)
(list :|x| |x|
:|y| |y|)))
;;; Except: The `except` or table/set difference operation is
;;; supported by #'table-difference (shorthand #'tdiff).
;; Example:
;; select * from a
;; except
;; select * from b
(tdiff a b)
;;; Since symmetric differences are commonly used, these are supported
;;; directly in #'tdiff.
;; Example: Symmetric difference between tables
;; (select * from a except select * from b)
;; union all
;; (select * from b except select * from a)
(tdiff a b :symmetric-p t) ; note: duplicates are preserved
;;; Here is a more complex example of generating queries, executing,
;;; and collecting the results into a table using this library.
;; Example: We want distinct counts of values from all columns in a
;; table, and we don't mind querying table once per column. Then we
;; want all of the results unioned into a single table along with
;; table_name and column_name values.
;;
;; In SQL, we might do something like:
;; 1. Create a table to store count results.
;; 2. Create a cursor based on selecting (table_name,column_name) from information_schema.columns
;; 3. Generate queries to insert distinct column value counts into the table & execute the queries inside of a cursor loop.
;;
;; Using this library, we would do the following to get distinct value
;; counts for all columns in the Chinook customer datbase using a
;; PostgreSQL connection:
(union
;; assumes connection already made
(query
(tmap (tlambda (|table_name| |column_name|)
(concatenate 'string
"
select '"|table_name|"' as \"table_name\",
'"|column_name|"' as \"column_name\",
count(distinct "|column_name|") as \"count_distinct\"
from "|table_name|))
;; assumes connection already made
(query "
select table_name, column_name
from information_schema.columns
where table_name like 'customer'
and table_schema like 'public'")
:type 'list))
:all-p t) ; no dups 'cause good query
| 7,267 | Common Lisp | .lisp | 184 | 35.048913 | 123 | 0.640272 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | a5ae73fe1a6bc8e4adb265f8cfc6cae85bb4d697892e564677a317973fe9f79a | 22,127 | [
-1
] |
22,128 | database.lisp | ghollisjr_cl-tab/example/database.lisp | (in-package :tb)
;; Example database: local PostgreSQL server's Chinook database
;;
;; define-database defines a function that accepts a query/operation
;; and takes action acocrdingly. Argument behavior:
;;
;; * Query string => Returns table result if result-p is T
;; * List of query strings => Returns list of table results if result-p is T
;; * :disconnect => Disconnects database
;;
;; The connection is automatically activated if it is not available
;; and a query or list of queries is supplied.
(define-database psql
(clsql:connect '("localhost" "chinook" "user" "password")
:database-type :postgresql))
(defun example-database1 ()
;; chinook table names
(tref (psql "
select * from INFORMATION_SCHEMA.TABLES
where TABLE_SCHEMA like 'public'")
"table_name"))
(defun example-database2 ()
(join (psql "select * from customer")
(on (psql "select * from invoice")
;; hash equijoin on addresses (yes, customer_id is better,
;; but I was curious how realistic chinook's data is, as
;; real data will have spurious entries)
(list (tlambda ()
(list (field |address|)
(field |city|)
(field |state|)
(field |country|)
(field |postal_code|)))
(tlambda ()
(list (field |billing_address|)
(field |billing_city|)
(field |billing_state|)
(field |billing_country|)
(field |billing_postal_code|))))
:type :full)))
| 1,677 | Common Lisp | .lisp | 40 | 31.65 | 76 | 0.575275 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 7e9a205553c9d93566169e2a0f2139b424d3ea5230138f8381250ceb2bc508d5 | 22,128 | [
-1
] |
22,129 | sort.lisp | ghollisjr_cl-tab/example/sort.lisp | (require 'cl-tab)
(in-package :tb)
(defun example-sort ()
(tsort! (table '((1 2 3)
(4 8 9)
(4 5 6))
'(x y z))
(order (list (field x) #'asc)
(list (field y) #'desc))))
(defun example-filter-sort ()
(tsort! (filter (tlambda (x) (evenp x))
(table '((1 2 3)
(4 8 9)
(4 5 6))
'(x y z)))
(order (list (field x) :asc)
(list (field z) :desc))))
| 549 | Common Lisp | .lisp | 17 | 18.823529 | 43 | 0.356604 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | e903d179d09128eff5cb152c01733c03f039d590cf4bbd195b99182aa962ad93 | 22,129 | [
-1
] |
22,130 | mssql.lisp | ghollisjr_cl-tab/example/mssql.lisp | (require :cl-tab)
(in-package :tb)
(defun example1 ()
"Connect to DB, run query, iterate & print results"
;; NOTE: Change ODBC connection string to suit your liking
(clsql:connect '("MS-SQL ODBC Connection" "SA" nil
:connection-string
"Driver={ODBC Driver 17 for SQL Server};Server=SOMESERVER.COM;Database=master;Trusted_Connection=No;Encrypt=No;uid=SOMEUSER;Pwd=SOMEPASSWORD;")
:database-type :odbc)
;; Actual example: tb:query is a substitute for clsql:query that
;; returns a table of results. Should feel familiar for Python
;; Pandas users.
;;
;; Then the results can be processed in a loop via dotable,
;; analogous to dolist but with a list of bound symbols rather than
;; a single symbol.
(dotable ((x m) ; bind "x" to x, bind "message" to m
(query "select x, message from test")
'example-result-value)
(print (list x m))))
| 940 | Common Lisp | .lisp | 20 | 40.65 | 162 | 0.667756 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 41c9c85d0d08431e30e6ce5f871cd6cce0baa0580731e283e50bcb87a8318529 | 22,130 | [
-1
] |
22,131 | map.lisp | ghollisjr_cl-tab/example/map.lisp | (require 'cl-tab)
(in-package :tb)
(defun example-map ()
(tmap (tlambda (x) ; can mention select fields you want by namex
(setf (field y) 15) ; fields can be set
(append (list :new (* 2 x))
fields)) ; also all fields returned
(make-table '((1 2) (3 4))
:field-names '("X" "Y"))))
(defun example-map2 ()
;; This example shows an imperative/stateful way of using tmap to
;; manipulate a row of data. Notice that the (field ...) macro and
;; fields symbol macro allow setf. The value returned by the
;; mapping function is taken as the new row data for the new table,
;; and field names are automatically gleaned from the plist if
;; plists are returned.
(tmap (tlambda ()
;; double X
(setf (field x)
(* (field x) 2))
;; rename X to Z
(subst :z :x fields))
(make-table '((1 2) (3 4))
:field-names '("X" "Y"))))
| 978 | Common Lisp | .lisp | 24 | 32.75 | 69 | 0.568277 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 49cd3ff4cbb6c50af1c2e4833794a860fe08482ac2aa472f6719c86c69dff06b | 22,131 | [
-1
] |
22,132 | csv.lisp | ghollisjr_cl-tab/example/csv.lisp | (require :cl-tab)
(in-package :tb)
(defun example-write-csv ()
"Example writing CSV to a string with Lisp-formatted data and
Unix line endings."
(write-csv
(make-table '(("hello with space" 1)
("world" 2))
:field-names (list "message" "x"))
:newline (string #\newline)))
(defun example-read-csv ()
"Example reading CSV from a string with Lisp-formatted data."
(let ((csv-data (format nil "message,x~%\"\"\"hello, world!\"\"\",1.0d0~%")))
(format t "Example: Read CSV data~%")
(format t "Input CSV file:~%~c~%" #\page)
(format t "~a~c~%" csv-data #\page)
(read-csv csv-data)))
| 651 | Common Lisp | .lisp | 17 | 33.529412 | 79 | 0.601266 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | efd6a4aaa393c1d1e719b3194cd537c470d57f8ae7390bcf0f2c4720cfd2a3e7 | 22,132 | [
-1
] |
22,133 | aggregation.lisp | ghollisjr_cl-tab/example/aggregation.lisp | (require 'cl-tab)
(in-package :tb)
(defun example-aggregate ()
"Example aggregation: sum x grouped by y"
(let ((table (make-table '((1 2) (3 4) (5 4)) :field-names '("X" "Y"))))
(agg (with-agg (y (tlambda (y) y)) ; group by y
((sumx (agg-sum)))
(list y (sumx))
;; Could also do:
;; (list y sumx)
;; using the convenient symbol-macrolet
(x)
(sumx x))
table
:field-names '("Y" "SUM(X)"))))
(defun example-histogram ()
"Example of histogram aggregation"
(agg (hist-agg x y)
(table '((1 2 3) (3 2 1))
'(x y z))))
| 687 | Common Lisp | .lisp | 20 | 24.45 | 74 | 0.469173 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 4b7a96ee44ea31b038f317dd932663537c3ee7c4711062050e003db4d9929ad3 | 22,133 | [
-1
] |
22,134 | join.lisp | ghollisjr_cl-tab/example/join.lisp | (require 'cl-tab)
(in-package :tb)
(defun example-join1 ()
(let ((t1 (make-table '((1 2)
(3 4))
:field-names '("a" "b")))
(t2 (make-table '((1 2)
(3 4))
:field-names '("c" "d")))
(t3 (make-table '((1 2)
(3 4))
:field-names '("e" "f"))))
(join t1
(on t2 (tlambda (|b| |c|)
(< |b| |c|))
:type :left)
(on t3 (tlambda (|c| |e|)
;; note: need to check for NIL fields after prior
;; left-join above
;;
;; Another option in this case would be something
;; like:
;;
;; (unless (member nil fields)
;; (= |c| |e|))
;;
;; to check for any missing fields due to prior
;; failed join. But, each table's content is
;; different and can require different join
;; conditions; the above would assume no fields
;; should be NIL, whereas this does not.
(and |c| |e| (= |c| |e|)))
:type :left))))
(defun example-join2 ()
(let ((t1 (make-table '((1 2)
(3 4))
:field-names '("a" "b")))
(t2 (make-table '((1 2)
(3 4))
:field-names '("c" "d")))
(t3 (make-table '((1 2)
(3 4))
:field-names '("e" "f"))))
(join t1
(on t2
;; equijoin on t1.b = t2.d
(list (tlambda (b) b)
(tlambda (d) d))
:type :left)
(on t3
;; equijoin on t2.c = t3.e
(list (tlambda (c) c)
(tlambda (e) e))
:type :full))))
(defun example-join3 ()
(let ((t1 (make-table '((1 2)
(3 4))
:field-names '("a" "b")))
(t2 (make-table '((1 2)
(3 4))
:field-names '("c" "d"))))
(join t1
(on t2
;; equijoin on t1.a = t2.c and t1.b = t2.d
(list (tlambda (|a| |b|)
(list |a| |b|))
(tlambda (|c| |d|)
(list |c| |d|)))
:type :left))))
(defun loop-join-test ()
(join (make-table '((1 2) (3 4)) :field-names '("X" "Y"))
(on (make-table '((1 1) (2 2)) :field-names '("Y" "Z"))
;; note: for loop-join, field names are pre-converted, so
;; you accept field names as they are in the joined table.
(tlambda (x .y)
(equal x .y)))))
(defun hash-join-test ()
(join (make-table '((1 2) (3 4)) :field-names '("X" "Y"))
(on (make-table '((1 1) (2 2)) :field-names '("Y" "Z"))
(list (tlambda (x) x)
;; note: for hash-join, field names are not
;; pre-converted, so you accept the field names as
;; they are in the left and right tables pre-join.
(tlambda (y) y)))))
| 3,308 | Common Lisp | .lisp | 84 | 23.75 | 70 | 0.372787 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 92664901f5ab2496977336588a2faaf95a8f3ad1494fe0062c581648b305e690 | 22,134 | [
-1
] |
22,135 | postgresql.lisp | ghollisjr_cl-tab/example/postgresql.lisp | (require 'cl-tab)
(in-package :tb)
(defun example-psql ()
"Read table from PostgreSQL"
(clsql:connect '("localhost" "some_database" "user" "password")
:database-type :postgresql)
;; get table content:
(query "select * from some_table;"))
(defun example-psql2 ()
"Write table to PostgreSQL"
(clsql:connect '("localhost" "some_database" "user" "password")
:database-type :postgresql)
;; send table content to PostgreSQL server in a table:
(map nil
#'clsql:execute-command
(table->sql
(make-table '((1 2)
(3 4))
:field-names '("x" "y"))
"some_database.public.test"
:batch-size 10))
(clsql:disconnect))
| 733 | Common Lisp | .lisp | 22 | 26.227273 | 65 | 0.595205 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 965ad2c5e69c0bf443a25682099da92669cb6519c59f1e04d865e8f375a8141c | 22,135 | [
-1
] |
22,136 | union.lisp | ghollisjr_cl-tab/example/union.lisp | (require 'cl-tab)
(in-package :tb)
(defun example-union1 ()
"Example: union (no duplicates)"
(let ((t1 (make-table '((1 2)
(3 4))
:field-names '("x" "y")))
(t2 (make-table '((3 4)
(5 6))
:field-names '("a" "b"))))
(union (list t1 t2))))
(defun example-union2 ()
"Example: union (with duplicates)"
(let ((t1 (make-table '((1 2)
(3 4))
:field-names '("x" "y")))
(t2 (make-table '((3 4)
(5 6))
:field-names '("a" "b"))))
(union (list t1 t2) :all-p t)))
| 684 | Common Lisp | .lisp | 20 | 21.5 | 50 | 0.383686 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | d91777ddf6a35f5296f8659cafc0a8a059f7eb5d89b887a3fd5aeeb7745859e4 | 22,136 | [
-1
] |
22,137 | insertion-deletion.lisp | ghollisjr_cl-tab/example/insertion-deletion.lisp | (require :cl-tab)
(in-package :tb)
(defun insertion-example ()
(let ((table (make-table '(("hello" 1)
("world" 2))
:field-names
'("message" "index"))))
(insert! table
(list "this is" 3)
(list "more data" 4))
table))
(defun insertion-example2 ()
(let ((table (make-table '(("hello" 1)
("world" 2))
:field-names
'("message" "index"))))
(insert! table
;; also can use plists
(list :|message| "this is" :|index| 3)
(list :|message| "more data" :|index| 4))
table))
(defun deletion-example ()
(let ((table (make-table '(("hello" 1)
("world" 2)
("this is" 3)
("more data" 4)
("to ponder" 5))
:field-names
'("message" "index"))))
;; can delete a specific row by index
(delete! table 1) ; -> ("world" 2) is gone
;; or a list of rows by indices
(delete! table (list 2 3)) ; -> last 2 rows gone
;; or using a boolean function
(delete! table
(tlambda (|message| |index|)
(> |index| 2))))) ; -> only ("hello" 1) remaining
| 1,398 | Common Lisp | .lisp | 37 | 23.864865 | 64 | 0.416789 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | bc0154fa1d87b6da1c39ddaae14b07de9a2018e7901621aa71332e71da6335ab | 22,137 | [
-1
] |
22,138 | analysis.lisp | ghollisjr_cl-tab/example/analysis.lisp | ;;;; This is an example analysis where a Chinook database on a local
;;;; PostgreSQL server is analyzed using tools from both cl-tab and
;;;; cl-ana.
(require 'cl-tab)
(require 'cl-ana)
(defpackage #:ana
(:use :cl))
(in-package :ana)
(cl-ana.package-utils:use-package-group :cl-ana)
(shadowing-use-package :tb)
;; Convenience function:
(setf (symbol-function 'regex)
#'ppcre:all-matches-as-strings)
;; Setup cl-ana project
(defproject chinook "chinook-analysis"
(list #'macrotrans #'branchtrans #'progresstrans)
(fixed-cache 5))
;; Define server connection
(define-database psql
(clsql:connect '("localhost" "chinook" "user" "password")
:database-type :postgresql))
;;; At the start of any project, there is exploration, so here are
;;; examples of things I might do.
(defun chinook-tables ()
(psql "select * from information_schema.tables where table_schema like 'public'"))
(defun chinook-columns ()
(psql "select * from information_schema.columns where table_schema like 'public'"))
(defun chinook-column-hist ()
"histogram of columns. counts number of tables with given column
name. results ordered most common to least common column. might
suggest potential joins."
(tsort! (agg (hist-agg |column_name| |data_type|)
(chinook-columns))
(order (list (field |count|)
:desc))))
;; result: lots of names (likely different types) & update info, then
;; music info
(defun track-tables ()
"tables that have some kind of track column"
(tmap (field |table_name|)
(filter (tlambda (|column_name|)
(regex ".*track.*" |column_name|))
(chinook-columns))))
(defun price-tables ()
"tables that have some kind of price column"
(tmap (field |table_name|)
(filter (tlambda (|column_name|)
(regex ".*price.*" |column_name|))
(chinook-columns))))
;;; Now for some analysis
(defres (track length)
(tref (psql "select count(*) from track")
0 :type 'list))
(defres (composer distinct-count)
(car
(tref (psql "select count(distinct composer) from track")
0 :type 'list)))
(defres (composer hist)
;; histogram of composers in track list, i.e. number of tracks per
;; composer.
(agg (hist-agg |composer|)
(psql "select composer from track")))
;; Question: How much money does each composer make?
;;
;; Needed tables:
;; invoice_line: track_id, unit_price, quantity
;; track: track_id, composer
(defres (composer earnings)
(if nil
;; For comparison, SQL version:
(psql "
select composer,
cast(sum(cast(invoice_line.unit_price as money)*quantity) as float) as \"earnings\"
from track
join invoice_line
on track.track_id = invoice_line.track_id
group by composer
order by \"earnings\" desc")
(tsort!
(agg (with-agg (composer (field |composer|))
((earnings (agg-sum)))
(append composer
(list :|earnings| earnings))
(|unit_price| |quantity|)
(earnings (* (read-from-string |unit_price|)
|quantity|)))
(join (psql "select track_id, composer from track")
(on-keys
(psql "select track_id, unit_price, quantity from invoice_line")
|track_id|)))
(order (list (field |earnings|) :desc)))))
| 3,430 | Common Lisp | .lisp | 91 | 31.516484 | 85 | 0.638797 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | dfd937740903ca1f0d0b44573d78cf75f5afa38fa7468f1fd8a3216060a47cff | 22,138 | [
-1
] |
22,139 | cl-tab.asd | ghollisjr_cl-tab/cl-tab.asd | (asdf:defsystem #:cl-tab
:serial t
:author "Gary Hollis"
:description "Common Lisp tabular data analysis library & DSL"
:license "GPLv3"
:depends-on (:alexandria
:clsql
:cl-csv
:cl-ana)
:components ((:file "package")
(:file "macros")
(:file "database")
(:file "tab")
(:file "csv")
(:file "sql")
(:file "misc")))
| 459 | Common Lisp | .asd | 16 | 18.5 | 64 | 0.471783 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | ba981f0680bc03f99f1a0737d5144cc053e3b0d2c9a4f47ab0da02383daaafe0 | 22,139 | [
-1
] |
22,146 | emacs-settings.el | ghollisjr_cl-tab/emacs-settings.el | ;;;; These are settings you can enable in Emacs if desired:
;;; add macro highlighting:
(font-lock-add-keywords
'lisp-mode
'(("tlambda" . font-lock-keyword-face)
("tlambda*" . font-lock-keyword-face)))
;; add tlambda & tlambda* pretty symbols
(add-hook 'lisp-mode-hook
'(lambda ()
(push (cons "tlambda"
(list ?t '(Br . Bl) ?位))
prettify-symbols-alist)
(push (cons "tlambda*"
(list ?t '(Br . Bl) ?位 '(Br . Bl) ?*))
prettify-symbols-alist)))
;; same for slime repl
(add-hook 'slime-repl-mode-hook
'(lambda ()
(prettify-symbols-mode 1)
(push (cons "tlambda"
(list ?t '(Br . Bl) ?位))
prettify-symbols-alist)
(push (cons "tlambda*"
(list ?t '(Br . Bl) ?位 '(Br . Bl) ?*))
prettify-symbols-alist)))
| 964 | Common Lisp | .l | 25 | 26.68 | 63 | 0.484459 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 157edb2e6e38b2373358ca7e9eb8a308bedb7ffb59ebf7fbea978c9837e4afb6 | 22,146 | [
-1
] |
22,149 | DESIGN.html | ghollisjr_cl-tab/lsql/DESIGN.html | <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2024-08-16 Fri 01:37 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>‎</title>
<meta name="generator" content="Org Mode" />
<style>
#content { max-width: 60em; margin: auto; }
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #e6e6e6;
border-radius: 3px;
background-color: #f2f2f2;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: auto;
}
pre.src:before {
display: none;
position: absolute;
top: -8px;
right: 12px;
padding: 3px;
color: #555;
background-color: #f2f2f299;
}
pre.src:hover:before { display: inline; margin-top: 14px;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-authinfo::before { content: 'Authinfo'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { }
</style>
</head>
<body>
<div id="content" class="content">
<div id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#org675b527">1. Overview</a>
<ul>
<li><a href="#org95c549e">1.1. Examples of lsql expressions</a></li>
</ul>
</li>
<li><a href="#org0b3d259">2. Operators</a>
<ul>
<li><a href="#org5331b24">2.1. select (sel)</a></li>
<li><a href="#orgc238966">2.2. group</a></li>
<li><a href="#org1541d69">2.3. join, to</a></li>
<li><a href="#orgd783bd6">2.4. order, asc(end)(ing), desc(end)(ing)</a></li>
<li><a href="#org76e257d">2.5. mapt</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org675b527" class="outline-2">
<h2 id="org675b527"><span class="section-number-2">1.</span> Overview</h2>
<div class="outline-text-2" id="text-1">
<p>
lsql is a tool for multi-target, multi-system tabular data analysis
written as expressions (statements with return values). The core
design principles are
</p>
<ul class="org-ul">
<li><p>
Expression-based language: Everything is an expression,
including objects. Every expression has a value.
</p>
<p>
This is not true for SQL. E.g.:
</p>
<div class="org-src-container">
<pre class="src src-sql"> select * from tab;
</pre>
</div>
<p>
returns a table from a table. But:
</p>
<div class="org-src-container">
<pre class="src src-sql"> tab;
</pre>
</div>
<p>
returns an error since it is not a valid SQL query.
</p></li>
<li><p>
lsql is closed: Every lsql object can be an argument to another
lsql expression.
</p>
<p>
Not true for SQL. E.g., given t1(x,y) and t2(x,z):
</p>
<div class="org-src-container">
<pre class="src src-sql"> select * from t1 join t2 on t1.x=t2.x
</pre>
</div>
<p>
returns a table with two columns named "x". This will be returned
to you as a "table" from the SQL client, but if you try to use this
in a CTE or insert the values into a table, the SQL server will
signal an error since columns must have different names.
</p></li>
<li>Multi-server: lsql expressions can refer to data located on any
system which has been defined, including the host system. lsql
expressions can be compiled to execute as SQL queries on SQL servers
or as Lisp code executed on the host system.</li>
</ul>
<p>
The main goal of lsql is ease of data analysis and manipulation across
multiple systems without the need for explicit transfer code.
</p>
</div>
<div id="outline-container-org95c549e" class="outline-3">
<h3 id="org95c549e"><span class="section-number-3">1.1.</span> Examples of lsql expressions</h3>
<div class="outline-text-3" id="text-1-1">
<div class="org-src-container">
<pre class="src src-sql">-- SQL
select * from tab
</pre>
</div>
<p>
In lsql, tables can be returned directly:
</p>
<div class="org-src-container">
<pre class="src src-lisp">;; lsql
tab
</pre>
</div>
<div class="org-src-container">
<pre class="src src-sql">-- SQL
select a.x, b.y, c.z
from a
join b
on a.w = b.w
join c
on b.w = c.w
</pre>
</div>
<p>
The syntax <code>@<table>(<field1> [field2] [field3]...)</code> is used to denote
references to a field in a table. The fields are referenced via
symbols without evaluation. (An alternate form is available when
evaluation is needed to access the field symbol.)
</p>
<div class="org-src-container">
<pre class="src src-lisp">;; lsql
(sel (@a(x) @b(y) @c(z))
(join a
(to b (= @a(w) @b(w)))
(to c (= @b(w) @c(w)))))
</pre>
</div>
<p>
Some operators from SQL have new aliases for aesthetics:
</p>
<ul class="org-ul">
<li><code>like</code>: <code>~=</code>, <code>equalp</code></li>
<li><code>=</code>: <code>equal</code></li>
<li><code>asc</code>: <code><=</code>, <code>:asc</code></li>
<li><code>desc</code>: <code>>=</code>, <code>:desc</code></li>
</ul>
<p>
E.g.:
</p>
<div class="org-src-container">
<pre class="src src-sql">-- SQL
select *
from tab
where x like y
order by z asc
</pre>
</div>
<div class="org-src-container">
<pre class="src src-lisp">(sel *
;; could just return table without (sel * ...)
(order (filter tab (~= x y))
z :asc))
</pre>
</div>
<p>
The section <a href="#org0b3d259">Operators</a> has more detailed information on the specific
operators supported, their syntax and semantics.
</p>
</div>
</div>
</div>
<div id="outline-container-org0b3d259" class="outline-2">
<h2 id="org0b3d259"><span class="section-number-2">2.</span> Operators</h2>
<div class="outline-text-2" id="text-2">
<p>
Operators are the fundamental building block of lsql code.
</p>
<p>
Operators generally have a publicly exposed macro and some number of
private functions that provide the implementation of this operator in
different contexts.
</p>
</div>
<div id="outline-container-org5331b24" class="outline-3">
<h3 id="org5331b24"><span class="section-number-3">2.1.</span> select (sel)</h3>
<div class="outline-text-3" id="text-2-1">
<p>
<code>select</code> or <code>sel</code> functions much like in SQL where it is used to
construct tables from scalar values or computations applied to other
tables. E.g.
</p>
<div class="org-src-container">
<pre class="src src-lisp">;; select * from tab
(sel * tab)
</pre>
</div>
<p>
References to tables are facilitated via the <code>field</code> data type along
with a helpful reader syntax:
</p>
<div class="org-src-container">
<pre class="src src-lisp">;; select A.X, A.Y from ...
(sel (@A(X) @B(Y)) ...)
</pre>
</div>
<p>
Named fields use the syntax <code>(name value)</code> in the selection list
(similar to other Lisp binding operations):
</p>
<div class="org-src-container">
<pre class="src src-lisp">;; select A.X as "A_X", B.Y as "B_Y" from ...
(sel ((A_X @A(X))
(B_Y @B(Y)))
...)
</pre>
</div>
</div>
</div>
<div id="outline-container-orgc238966" class="outline-3">
<h3 id="orgc238966"><span class="section-number-3">2.2.</span> group</h3>
</div>
<div id="outline-container-org1541d69" class="outline-3">
<h3 id="org1541d69"><span class="section-number-3">2.3.</span> join, to</h3>
</div>
<div id="outline-container-orgd783bd6" class="outline-3">
<h3 id="orgd783bd6"><span class="section-number-3">2.4.</span> order, asc(end)(ing), desc(end)(ing)</h3>
</div>
<div id="outline-container-org76e257d" class="outline-3">
<h3 id="org76e257d"><span class="section-number-3">2.5.</span> mapt</h3>
<div class="outline-text-3" id="text-2-5">
<p>
<code>mapt</code> is the lsql table mapping operation. Mapping is not a SQL
operation, but it is extremely useful and something that is often
effectively performed through dynamically-generated SQL queries.
</p>
<p>
Ordinarily, mapping takes a list of objects, a function that
transforms each element, and returns a list which is the result of
calling the function on each object in the original list. However,
because SQL does not directly support nested tabular data, <code>map</code> in
lsql will perform a <code>union all</code> operation on the results of each
mapping operation.
</p>
<p>
Mapping in general programming would be of little use without the
ability to define an anonymous function, or λ function in
computer science parlance. To that end, the operator <code>lambda</code> has
been provided as a way to specify a function that accepts some number
of input arguments that will be used with map. If the type of
argument is a table, lsql will intelligently choose a way to achieve
the computation, be it with dynamic SQL or Lisp code.
</p>
<p>
Examples:
</p>
<div class="org-src-container">
<pre class="src src-lisp">;; trivial example
;;
;; equivalent to
;;
;; select a.x+b.x as "x",
;; a.y+b.y as "y"
;; from a join b on a.z = b.z
(mapt (sel ((x (+ @a(x) @b(x)))
(y (* @a(y) @b(y)))))
(join a (to b (= @a(z) @b(z)))))
</pre>
</div>
<div class="org-src-container">
<pre class="src src-lisp">;; dynamic SQL example
;;
;; This equivalent to generating queries of the form
;;
;; select '<table>' as "name", count(1) as "count"
;; from <table>
;;
;; with a value of <table> being a.name for each row in a, and then
;; performing a union all of the result row from each individual
;; selection query. This is a common operation in SQL that requires
;; dynamically-generated SQL queries using SQL itself or a
;; programmatical client like Python or Lisp via ODBC. lsql
;; eliminates the need for extra complexity:
(mapt (lambda (tab)
(sel ((name @tab(name))
(count (agg ((count (count 1)))
(sys1 @tab(name)))))
tab))
(sel (name)
(sys1 a)))
</pre>
</div>
<p>
Notice that <code>sys1</code> occurs as an operator. Systems that have been
defined can be used as operators that accept the name of a table as an
input argument and return a reference to the table. In this case,
<code>sys1</code> is used as a contrived example system.
</p>
<p>
For convenience, it is also possible to specify a default system in
which all queries should run unless stated otherwise.
</p>
<div class="org-src-container">
<pre class="src src-lisp">(on sys1
(mapt (lambda (tab)
(sel ((name @tab(name))
(count (agg ((count (count 1)))
@tab(name))))
tab))
(sel (name)
a)))
</pre>
</div>
<p>
In this case, there is no need to specify the system in the table
arguments since sys1 will be used by default. Operators that accept
table references as arguments are designed to automatically convert
symbol/string input values to table references in the default system.
</p>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="date">Created: 2024-08-16 Fri 01:37</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>
| 17,457 | Common Lisp | .l | 505 | 32.039604 | 104 | 0.676356 | ghollisjr/cl-tab | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | e01c6d6a06fc4f1a98337c23df0b0f9d00d212f618fb35aed9952c95b856c3c7 | 22,149 | [
-1
] |
22,180 | package.lisp | thijs_clfswm-old/src/package.lisp | ;;; --------------------------------------------------------------------------
;;; CLFSWM - FullScreen Window Manager
;;;
;;; --------------------------------------------------------------------------
;;; Documentation: Package definition
;;; --------------------------------------------------------------------------
;;;
;;; (C) 2005-2015 Philippe Brochard <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;;;
;;; --------------------------------------------------------------------------
(in-package :cl-user)
(defpackage clfswm
(:use :common-lisp :my-html :tools)
;; (:shadow :defun)
(:export :main
:reload-clfswm
:reset-clfswm
:exit-clfswm))
;;;;; Uncomment the line below if you want to see all ignored X errors
;;(pushnew :xlib-debug *features*)
;;;;; Uncomment the line below if you want to see all event debug messages
;;(pushnew :event-debug *features*)
(in-package :clfswm)
;;; CONFIG - Compress motion notify ?
;; This variable may be useful to speed up some slow version of CLX.
;; It is particulary useful with CLISP/MIT-CLX (and others).
(defconfig *have-to-compress-notify* t
nil "Compress event notify?
This variable may be useful to speed up some slow version of CLX.
It is particulary useful with CLISP/MIT-CLX.")
(defconfig *transparent-background* t
nil "Enable transparent background: one of nil, :pseudo, t (xcompmgr must be started)")
(defconfig *default-transparency* 0.8
nil "Default transparency for all windows when in xcompmgr transparency mode")
(defconfig *show-root-frame-p* nil
nil "Show the root frame information or not")
(defconfig *border-size* 1
nil "Windows and frames border size")
(defparameter *modifier-alias* '((:alt :mod-1) (:alt-l :mod-1)
(:numlock :mod-2)
(:super_l :mod-4)
(:alt-r :mod-5) (:alt-gr :mod-5)
(:capslock :lock))
"Syntax: (modifier-alias effective-modifier)")
(defparameter *display* nil)
(defparameter *screen* nil)
(defparameter *root* nil)
(defparameter *no-focus-window* nil)
(defparameter *sm-window* nil)
(defparameter *sm-font* nil)
(defparameter *sm-gc* nil)
(defparameter *background-image* nil)
(defparameter *background-gc* nil)
(defparameter *expose-child-list* nil)
(defconfig *loop-timeout* 1 nil
"Maximum time (in seconds) to wait before calling *loop-hook*")
(defparameter *pixmap-buffer* nil)
(defparameter *contrib-dir* "contrib/")
(defparameter *default-font* nil)
;;(defparameter *default-font-string* "9x15")
(defconfig *default-font-string* "fixed" nil
"The default font used in clfswm")
(defconfig *color-move-window* "DeepPink" 'Main-mode
"Color when moving or resizing a windows")
(defparameter *child-selection* nil)
;;; CONFIG - Default frame datas
(defconfig *default-frame-data*
(list '(:tile-size 0.8) '(:tile-space-size 0.1)
'(:fast-layout (tile-left-layout tile-layout))
'(:main-layout-windows nil))
nil
"Default slots set in frame date")
;;; CONFIG - Default managed window type for a frame
;;; type can be :all, :normal, :transient, :maxsize, :desktop, :dock, :toolbar, :menu, :utility, :splash, :dialog
(defconfig *default-managed-type* '(:normal) nil
"Default managed window types")
;;(defparameter *default-managed-type* '(:normal :maxsize :transient))
;;(defparameter *default-managed-type* '(:normal :transient :maxsize :desktop :dock :toolbar :menu :utility :splash :dialog))
;;(defparameter *default-managed-type* '())
;;(defparameter *default-managed-type* '(:all))
;;; CONFIG - Default focus policy
(defconfig *default-focus-policy* :click nil
"Default mouse focus policy. One of :click, :sloppy, :sloppy-strict, :sloppy-select or
:sloppy-select-window.")
(defconfig *show-hide-policy* #'<=
nil "'NIL': always display all children (better with transparency support).
'<': Hide only children less than children above.
'<=': Hide children less or equal to children above (better for performance on slow machine).")
(defconfig *show-hide-policy-type* '(:normal)
nil "Windows types which are optimized by the show hide policy")
(defstruct child-rect child parent selected-p x y w h)
(defstruct root child original current-child x y w h)
(defclass frame ()
((name :initarg :name :accessor frame-name :initform nil)
(number :initarg :number :accessor frame-number :initform 0)
;;; Float size between 0 and 1 - Manipulate only those variables and not real size
(x :initarg :x :accessor frame-x :initform 0.1)
(y :initarg :y :accessor frame-y :initform 0.1)
(w :initarg :w :accessor frame-w :initform 0.8)
(h :initarg :h :accessor frame-h :initform 0.8)
;;; Real size (integer) in screen size - Don't set directly those variables
;;; they may be recalculated by the layout manager.
(rx :initarg :rx :accessor frame-rx :initform 0)
(ry :initarg :ry :accessor frame-ry :initform 0)
(rw :initarg :rw :accessor frame-rw :initform 800)
(rh :initarg :rh :accessor frame-rh :initform 600)
;; (root :initarg :root :accessor frame-root :initform nil
;; :documentation "A list a physical coordinates (x y w h) if frame is a root frame. Nil otherwise")
(layout :initarg :layout :accessor frame-layout :initform nil
:documentation "Layout to display windows on a frame")
(nw-hook :initarg :nw-hook :accessor frame-nw-hook :initform nil
:documentation "Hook done by the frame when a new window is mapped")
(managed-type :initarg :managed-type :accessor frame-managed-type
:initform *default-managed-type*
:documentation "Managed window type")
(forced-managed-window :initarg :forced-managed-window
:accessor frame-forced-managed-window
:initform nil
:documentation "A list of forced managed windows (xlib:wm-name or window)")
(forced-unmanaged-window :initarg :forced-unmanaged-window
:accessor frame-forced-unmanaged-window
:initform nil
:documentation "A list of forced unmanaged windows (xlib:wm-name or window)")
(show-window-p :initarg :show-window-p :accessor frame-show-window-p :initform t)
(hidden-children :initarg :hidden-children :accessor frame-hidden-children :initform nil
:documentation "A list of hidden children")
(selected-pos :initarg :selected-pos :accessor frame-selected-pos :initform 0
:documentation "The position in the child list of the selected child")
(focus-policy :initarg :focus-policy :accessor frame-focus-policy
:initform *default-focus-policy*)
(window :initarg :window :accessor frame-window :initform nil)
(gc :initarg :gc :accessor frame-gc :initform nil)
(child :initarg :child :accessor frame-child :initform nil)
(data :initarg :data :accessor frame-data
:initform *default-frame-data*
:documentation "An assoc list to store additional data")))
(defparameter *root-frame* nil
"Root of the root - ie the root frame")
(defparameter *main-keys* nil)
(defparameter *main-mouse* nil)
(defparameter *second-keys* nil)
(defparameter *second-mouse* nil)
(defparameter *info-keys* nil)
(defparameter *info-mouse* nil)
(defparameter *query-keys* nil)
(defparameter *circulate-keys* nil)
(defparameter *circulate-keys-release* nil)
(defparameter *expose-keys* nil)
(defparameter *expose-mouse* nil)
(defparameter *other-window-manager* nil)
(defstruct menu name item doc)
(defstruct menu-item key value)
(defparameter *menu* (make-menu :name 'main :doc "Main menu"))
(defconfig *binding-hook* nil 'Hook
"Hook executed when keys/buttons are bounds")
(defconfig *loop-hook* nil 'Hook
"Hook executed on each event loop")
(defconfig *main-entrance-hook* nil 'Hook
"Hook executed on the main function entrance after
loading configuration file and before opening the display.")
(defconfig *root-size-change-hook* nil 'Hook
"Hook executed when the root size has changed for example when adding/removing a monitor")
(defparameter *in-second-mode* nil)
;;; Placement variables. A list of two absolute coordinates
;;; or a function: 'Y-X-placement' for absolute placement or
;;; 'Y-X-child-placement' for child relative placement or
;;; 'Y-X-root-placement' for root relative placement.
;;; Where Y-X are one of:
;;;
;;; top-left top-middle top-right
;;; middle-left middle-middle middle-right
;;; bottom-left bottom-middle bottom-right
;;;
(defconfig *banish-pointer-placement* 'bottom-right-root-placement
'Placement "Pointer banishment placement")
(defconfig *second-mode-placement* 'top-middle-root-placement
'Placement "Second mode window placement")
(defconfig *info-mode-placement* 'top-left-root-placement
'Placement "Info mode window placement")
(defconfig *query-mode-placement* 'top-left-root-placement
'Placement "Query mode window placement")
(defconfig *circulate-mode-placement* 'bottom-middle-root-placement
'Placement "Circulate mode window placement")
(defconfig *expose-mode-placement* 'top-left-child-placement
'Placement "Expose mode window placement (Selection keys position)")
(defconfig *expose-query-placement* 'bottom-left-root-placement
'Placement "Expose mode query window placement")
(defconfig *fastswitch-mode-placement* 'top-left-root-placement
'Placement "Fastswitch mode window placement")
(defconfig *notify-window-placement* 'bottom-right-root-placement
'Placement "Notify window placement")
(defconfig *ask-close/kill-placement* 'top-right-root-placement
'Placement "Ask close/kill window placement")
(defconfig *unmanaged-window-placement* 'middle-middle-root-placement
'Placement "Unmanager window placement")
(defparameter *in-process-existing-windows* nil)
;; For debug - redefine defun
;;(shadow :defun)
;;(defmacro defun (name args &body body)
;; `(progn
;; (format t "defun: ~A ~A~%" ',name ',args)
;; (force-output)
;; (cl:defun ,name ,args
;; (handler-case
;; (progn
;; ,@body)
;; (error (c)
;; (format t "New defun: Error in ~A : ~A~%" ',name c)
;; (format t "Root tree=~A~%All windows=~A~%"
;; (xlib:query-tree *root*) (get-all-windows))
;; (force-output))))))
(defmacro make-x-drawable (argname type)
"Drawable wrapper to prevent type error in some CLX versions.
Replace xlib:drawable-* functions with x-drawable-* equivalents"
(let ((fun-symbol (create-symbol 'x-drawable- argname))
(set-symbol (create-symbol 'set-x-drawable- argname))
(xlib-equiv-symbol (create-symbol-in-package :xlib 'drawable- argname)))
`(progn
(declaim (inline ,fun-symbol))
(defun ,fun-symbol (window)
(,xlib-equiv-symbol window))
(defun ,set-symbol (window ,argname)
(if (typep ,argname ',type)
(setf (,xlib-equiv-symbol window) ,argname)
(dbg
',(create-symbol 'drawable-type-error- argname) window ,argname (xlib:wm-name window))))
(defsetf ,fun-symbol ,set-symbol))))
(make-x-drawable x (signed-byte 16))
(make-x-drawable y (signed-byte 16))
(make-x-drawable width (unsigned-byte 16))
(make-x-drawable height (unsigned-byte 16))
(make-x-drawable border-width (unsigned-byte 16))
| 12,179 | Common Lisp | .lisp | 246 | 44.882114 | 125 | 0.684565 | thijs/clfswm-old | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | d437c5625f9653d08406355be0e1abf67d7790e9298cb10a04a0720444ed997b | 22,180 | [
-1
] |
22,183 | clfswm-nw-hooks.lisp | thijs_clfswm-old/src/clfswm-nw-hooks.lisp | ;;; --------------------------------------------------------------------------
;;; CLFSWM - FullScreen Window Manager
;;;
;;; --------------------------------------------------------------------------
;;; Documentation: New window Hooks
;;;
;;; Those hooks can be set for each frame to manage new window when they are
;;; mapped.
;;; --------------------------------------------------------------------------
;;;
;;; (C) 2005-2015 Philippe Brochard <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;;;
;;; --------------------------------------------------------------------------
(in-package :clfswm)
;;; CONFIG - New window menu
;;;
;;; To add a new window hook (nw-hook):
;;; 1- define your own nw-hook
;;; 2- Define a seter function for your new hook
;;; 3- Register your new hook with register-nw-hook.
(defparameter *nw-hook-current-key* (char-code #\a))
(defparameter *permanent-nw-hook-frames* nil)
(defun set-nw-hook (hook)
"Set the hook of the current child"
(let ((frame (if (xlib:window-p (current-child))
(find-parent-frame (current-child))
(current-child))))
(unless (or (child-member frame *permanent-nw-hook-frames*)
(child-original-root-p frame))
(setf (frame-nw-hook frame) hook)
(leave-second-mode))))
(defun register-nw-hook (hook)
(add-menu-key 'frame-nw-hook-menu (code-char *nw-hook-current-key*) hook)
(incf *nw-hook-current-key*))
(defun default-window-placement (frame window)
(if (managed-window-p window frame)
(adapt-child-to-parent window frame)
(place-window-from-hints window)))
(defun leave-if-not-frame (child)
"Leave the child if it's not a frame"
(unless (frame-p child)
(leave-frame)
(select-previous-level)))
(defun clear-nw-hook (frame)
"Clear the frame new window hook"
(unless (child-member frame *permanent-nw-hook-frames*)
(setf (frame-nw-hook frame) nil)))
(defun clear-all-nw-hooks ()
"Clear all new window hooks for all frames"
(with-all-frames (*root-frame* frame)
(clear-nw-hook frame)))
(defun make-permanent-nw-hook-frame (frame)
"Prevent to add or delete a new window hook for this frame"
(when (frame-p frame)
(push frame *permanent-nw-hook-frames*)))
;;; Default frame new window hook
(defun default-frame-nw-hook (frame window)
"Open the next window in the current frame"
(declare (ignore frame))
(leave-if-not-frame (current-child))
(when (frame-p (current-child))
(pushnew window (frame-child (current-child))))
(default-window-placement (current-child) window)
t)
(defun set-default-frame-nw-hook ()
"Open the next window in the current frame"
(set-nw-hook #'default-frame-nw-hook))
(register-nw-hook 'set-default-frame-nw-hook)
;;; Open new window in current root hook
(defun open-in-current-root-nw-hook (frame window)
"Open the next window in the current root"
(clear-nw-hook frame)
(leave-if-not-frame (find-current-root))
(let ((root (find-current-root)))
(pushnew window (frame-child root))
(setf (current-child) (frame-selected-child root))
(default-window-placement root window))
t)
(defun set-open-in-current-root-nw-hook ()
"Open the next window in the current root"
(set-nw-hook #'open-in-current-root-nw-hook))
(register-nw-hook 'set-open-in-current-root-nw-hook)
;;; Open new window in a new frame in the current root hook
(defun open-in-new-frame-in-current-root-nw-hook (frame window)
"Open the next window in a new frame in the current root"
(clear-nw-hook frame)
(leave-if-not-frame (find-current-root))
(let ((new-frame (create-frame))
(root (find-current-root)))
(pushnew new-frame (frame-child root))
(pushnew window (frame-child new-frame))
(setf (current-child) new-frame)
(default-window-placement new-frame window))
t)
(defun set-open-in-new-frame-in-current-root-nw-hook ()
"Open the next window in a new frame in the current root"
(set-nw-hook #'open-in-new-frame-in-current-root-nw-hook))
(register-nw-hook 'set-open-in-new-frame-in-current-root-nw-hook)
;;; Open new window in a new frame in the root frame hook
(defun open-in-new-frame-in-root-frame-nw-hook (frame window)
"Open the next window in a new frame in the root frame"
(clear-nw-hook frame)
(let ((new-frame (create-frame))
(root (find-current-root)))
(pushnew new-frame (frame-child root))
(pushnew window (frame-child new-frame))
(switch-to-root-frame :show-later t)
(setf (current-child) root)
(set-layout-once #'tile-space-layout)
(setf (current-child) new-frame)
(default-window-placement new-frame window))
t)
(defun set-open-in-new-frame-in-root-frame-nw-hook ()
"Open the next window in a new frame in the root frame"
(set-nw-hook #'open-in-new-frame-in-root-frame-nw-hook))
(register-nw-hook 'set-open-in-new-frame-in-root-frame-nw-hook)
;;; Open new window in a new frame in the parent frame hook
(defun open-in-new-frame-in-parent-frame-nw-hook (frame window)
"Open the next window in a new frame in the parent frame"
(clear-nw-hook frame)
(let ((new-frame (create-frame))
(parent (find-parent-frame frame)))
(when parent
(pushnew new-frame (frame-child parent))
(pushnew window (frame-child new-frame))
(change-root (find-root parent) parent)
(setf (current-child) parent)
(set-layout-once #'tile-space-layout)
(setf (current-child) new-frame)
(default-window-placement new-frame window)
(show-all-children t)
t)))
(defun set-open-in-new-frame-in-parent-frame-nw-hook ()
"Open the next window in a new frame in the parent frame"
(set-nw-hook #'open-in-new-frame-in-parent-frame-nw-hook))
(register-nw-hook 'set-open-in-new-frame-in-parent-frame-nw-hook)
;;; Open a new window but leave the focus on the current child
(defun leave-focus-frame-nw-hook (frame window)
"Open the next window in the current frame and leave the focus on the current child"
(clear-nw-hook frame)
(leave-if-not-frame (current-child))
(when (frame-p (current-child))
(with-slots (child) (current-child)
(pushnew window child)
(setf child (rotate-list child))))
(default-window-placement (current-child) window)
t)
(defun set-leave-focus-frame-nw-hook ()
"Open the next window in the current frame and leave the focus on the current child"
(set-nw-hook #'leave-focus-frame-nw-hook))
(register-nw-hook 'set-leave-focus-frame-nw-hook)
(defun nw-hook-open-in-frame (window frame)
(when (frame-p frame)
(pushnew window (frame-child frame))
(unless (find-child-in-all-root frame)
(change-root (find-root frame) frame))
(setf (current-child) frame)
(focus-all-children window frame)
(default-window-placement frame window)
(show-all-children t)
t))
;;; Open a new window in a named frame
(defun named-frame-nw-hook (frame window)
(clear-nw-hook frame)
(let* ((frame-name (ask-frame-name "Open the next window in frame named:"))
(new-frame (find-frame-by-name frame-name)))
(nw-hook-open-in-frame window new-frame))
t)
(defun set-named-frame-nw-hook ()
"Open the next window in a named frame"
(set-nw-hook #'named-frame-nw-hook))
(register-nw-hook 'set-named-frame-nw-hook)
;;; Open a new window in a numbered frame
(defun numbered-frame-nw-hook (frame window)
(clear-nw-hook frame)
(let ((new-frame (find-frame-by-number (query-number "Open a new frame in the group numbered:"))))
(nw-hook-open-in-frame window new-frame))
t)
(defun set-numbered-frame-nw-hook ()
"Open the next window in a numbered frame"
(set-nw-hook #'numbered-frame-nw-hook))
(register-nw-hook 'set-numbered-frame-nw-hook)
;;; Absorb window.
;;; The frame absorb the new window if it match the nw-absorb-test
;;; frame data slot.
(defun absorb-window-nw-hook (frame window)
(let ((absorb-nw-test (frame-data-slot frame :nw-absorb-test)))
(when (and absorb-nw-test
(funcall absorb-nw-test window))
(pushnew window (frame-child frame))
(unless *in-process-existing-windows*
(unless (find-child-in-all-root frame)
(change-root (find-root frame) frame))
(setf (current-child) frame)
(focus-all-children window frame)
(default-window-placement frame window)
(show-all-children t))
(throw 'nw-hook-loop t)))
nil)
(defun set-absorb-window-nw-hook ()
"Open the window in this frame if it match nw-absorb-test"
(set-nw-hook #'absorb-window-nw-hook))
(register-nw-hook 'set-absorb-window-nw-hook)
(defun nw-absorb-test-class (class-string)
(lambda (c)
(and (xlib:window-p c)
(string-equal (xlib:get-wm-class c) class-string))))
(defun nw-absorb-test-command (command-string)
(lambda (c)
(and (xlib:window-p c)
(string-equal (get-window-command-string c) command-string))))
(defun get-proc-command (pid)
(let ((proc (do-shell (format nil "ps -p ~a -o cmd=" pid) nil t))
(proc-list nil))
(loop for line = (read-line proc nil nil)
while line
do (push line proc-list))
(dbg proc-list)
(first proc-list)))
(defun get-window-command-string (window)
(when (xlib:window-p window)
(let ((window-pid (first (xlib:get-property window :_NET_WM_PID))))
(get-proc-command window-pid))))
| 10,056 | Common Lisp | .lisp | 237 | 38.561181 | 100 | 0.677945 | thijs/clfswm-old | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 0a2a508b56cbd8fd7c389bbd92cf80b0f42a177e461a7ba33e64d342f252efc0 | 22,183 | [
-1
] |
22,186 | clfswm-info.lisp | thijs_clfswm-old/src/clfswm-info.lisp | ;;; --------------------------------------------------------------------------
;;; CLFSWM - FullScreen Window Manager
;;;
;;; --------------------------------------------------------------------------
;;; Documentation: Info function (see the end of this file for user definition
;;; --------------------------------------------------------------------------
;;;
;;; (C) 2005-2015 Philippe Brochard <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;;;
;;; --------------------------------------------------------------------------
(in-package :clfswm)
(defstruct info window gc font list ilw ilh x y max-x max-y)
(defparameter *info-selected-item* nil)
(defun leave-info-mode (info)
"Leave the info mode"
(declare (ignore info))
(setf *info-selected-item* nil)
(throw 'exit-info-loop nil))
(defun leave-info-mode-and-valid (info)
"Leave the info mode and valid the selected item"
(declare (ignore info))
(throw 'exit-info-loop nil))
(defun mouse-leave-info-mode (window root-x root-y info)
"Leave the info mode"
(declare (ignore window root-x root-y info))
(setf *info-selected-item* nil)
(throw 'exit-info-loop nil))
(defun find-info-item-from-mouse (root-x root-y info)
(if (< (x-drawable-x (info-window info)) root-x
(+ (x-drawable-x (info-window info))
(x-drawable-width (info-window info))))
(truncate (/ (- (+ (- root-y (x-drawable-y (info-window info)))
(xlib:max-char-ascent (info-font info))
(info-y info)) (info-ilh info)) (info-ilh info)))
nil))
(defun set-info-item-form-mouse (root-x root-y info)
(setf *info-selected-item* (find-info-item-from-mouse root-x root-y info)))
(defun info-y-display-coords (info posy)
(- (+ (* (info-ilh info) posy) (info-ilh info)) (info-y info)))
(defun incf-info-selected-item (info n)
(setf *info-selected-item*
(min (if *info-selected-item*
(+ *info-selected-item* n)
0)
(1- (or (length (info-list info)) 1)))))
(defun decf-info-selected-item (info n)
(declare (ignore info))
(setf *info-selected-item*
(max (if *info-selected-item*
(- *info-selected-item* n)
0)
0)))
(defun draw-info-window (info)
(labels ((print-line (line posx posy &optional (color *info-foreground*))
(xlib:with-gcontext ((info-gc info) :foreground (get-color color)
:background (if (equal posy *info-selected-item*)
(get-color *info-selected-background*)
(get-color *info-background*)))
(funcall (if (equal posy *info-selected-item*)
#'xlib:draw-image-glyphs
#'xlib:draw-glyphs)
*pixmap-buffer* (info-gc info)
(- (+ (info-ilw info) (* posx (info-ilw info))) (info-x info))
(info-y-display-coords info posy)
(ensure-printable (format nil "~A" line))))
(+ posx (length line))))
(clear-pixmap-buffer (info-window info) (info-gc info))
(loop for line in (info-list info)
for y from 0
do (typecase line
(cons (typecase (first line)
(cons (let ((posx 0))
(dolist (l line)
(typecase l
(cons (setf posx (print-line (first l) posx y (second l))))
(t (setf posx (print-line l posx y)))))))
(t (print-line (first line) 0 y (second line)))))
(t (print-line line 0 y))))
(copy-pixmap-buffer (info-window info) (info-gc info))))
;;;,-----
;;;| Key binding
;;;`-----
(add-hook *binding-hook* 'init-*info-keys* 'init-*info-mouse*)
(defun set-default-info-keys ()
(define-info-key (#\q) 'leave-info-mode)
(define-info-key ("Return") 'leave-info-mode-and-valid)
(define-info-key ("KP_Enter" :mod-2) 'leave-info-mode-and-valid)
(define-info-key ("space") 'leave-info-mode-and-valid)
(define-info-key ("Escape") 'leave-info-mode)
(define-info-key ("g" :control) 'leave-info-mode)
(define-info-key ("twosuperior")
(defun info-banish-pointer (info)
"Move the pointer to the lower right corner of the screen"
(declare (ignore info))
(banish-pointer)))
(define-info-key ("Down")
(defun info-next-line (info)
"Move one line down"
(incf-info-selected-item info 1)
(when (> (info-y-display-coords info *info-selected-item*)
(+ (x-drawable-y (info-window info))
(x-drawable-height (info-window info))))
(setf (info-y info) (min (+ (info-y info) (info-ilh info)) (info-max-y info))))
(draw-info-window info)))
(define-info-key ("Up")
(defun info-previous-line (info)
"Move one line up"
(decf-info-selected-item info 1)
(when (< (info-y-display-coords info *info-selected-item*)
(+ (x-drawable-y (info-window info))
(info-ilh info)))
(setf (info-y info) (max (- (info-y info) (info-ilh info)) 0)))
(draw-info-window info)))
(define-info-key ("Left")
(defun info-previous-char (info)
"Move one char left"
(setf (info-x info) (max (- (info-x info) (info-ilw info)) 0))
(draw-info-window info)))
(define-info-key ("Right")
(defun info-next-char (info)
"Move one char right"
(setf (info-x info) (min (+ (info-x info) (info-ilw info)) (info-max-x info)))
(draw-info-window info)))
(define-info-key ("Home")
(defun info-first-line (info)
"Move to first line"
(setf (info-x info) 0
(info-y info) 0)
(setf *info-selected-item* 0)
(draw-info-window info)))
(define-info-key ("End")
(defun info-end-line (info)
"Move to last line"
(setf (info-x info) 0
(info-y info) (- (* (length (info-list info)) (info-ilh info)) (x-drawable-height (info-window info))))
(setf *info-selected-item* (1- (or (length (info-list info)) 1)))
(draw-info-window info)))
(define-info-key ("Page_Down")
(defun info-next-ten-lines (info)
"Move ten lines down"
(incf-info-selected-item info 10)
(when (> (info-y-display-coords info *info-selected-item*)
(+ (x-drawable-y (info-window info))
(x-drawable-height (info-window info))))
(setf (info-y info) (min (+ (info-y info) (* (info-ilh info) 10)) (info-max-y info))))
(draw-info-window info)))
(define-info-key ("Page_Up")
(defun info-previous-ten-lines (info)
"Move ten lines up"
(decf-info-selected-item info 10)
(when (< (info-y-display-coords info *info-selected-item*)
(+ (x-drawable-y (info-window info))
(info-ilh info)))
(setf (info-y info) (max (- (info-y info) (* (info-ilh info) 10)) 0)))
(draw-info-window info))))
(add-hook *binding-hook* 'set-default-info-keys)
(defparameter *info-start-grab-x* nil)
(defparameter *info-start-grab-y* nil)
(defun info-begin-grab (window root-x root-y info)
"Begin grab text"
(declare (ignore window))
(setf *info-start-grab-x* (min (max (+ root-x (info-x info)) 0) (info-max-x info))
*info-start-grab-y* (min (max (+ root-y (info-y info)) 0) (info-max-y info)))
(draw-info-window info))
(defun info-end-grab (window root-x root-y info)
"End grab"
(declare (ignore window))
(setf (info-x info) (min (max (- *info-start-grab-x* root-x) 0) (info-max-x info))
(info-y info) (min (max (- *info-start-grab-y* root-y) 0) (info-max-y info))
*info-start-grab-x* nil
*info-start-grab-y* nil)
(draw-info-window info))
(defun info-mouse-next-line (window root-x root-y info)
"Move one line down"
(declare (ignore window))
(setf (info-y info) (min (+ (info-y info) (info-ilh info)) (info-max-y info)))
(set-info-item-form-mouse root-x root-y info)
(draw-info-window info))
(defun info-mouse-previous-line (window root-x root-y info)
"Move one line up"
(declare (ignore window))
(setf (info-y info) (max (- (info-y info) (info-ilh info)) 0))
(set-info-item-form-mouse root-x root-y info)
(draw-info-window info))
(defun info-mouse-motion-drag (window root-x root-y info)
"Grab text"
(declare (ignore window))
(when (and *info-start-grab-x* *info-start-grab-y*)
(setf (info-x info) (min (max (- *info-start-grab-x* root-x) 0) (info-max-x info))
(info-y info) (min (max (- *info-start-grab-y* root-y) 0) (info-max-y info)))
(draw-info-window info)))
(defun info-mouse-select-item (window root-x root-y info)
(declare (ignore window))
(set-info-item-form-mouse root-x root-y info)
(leave-info-mode-and-valid info))
(defun info-mouse-motion-click (window root-x root-y info)
(declare (ignore window))
(let ((last *info-selected-item*))
(set-info-item-form-mouse root-x root-y info)
(unless (equal last *info-selected-item*)
(draw-info-window info))))
(defun set-default-info-mouse ()
(if *info-click-to-select*
(define-info-mouse (1) nil 'info-mouse-select-item)
(define-info-mouse (1) 'info-begin-grab 'info-end-grab))
(define-info-mouse (2) 'mouse-leave-info-mode)
(define-info-mouse (3) 'mouse-leave-info-mode)
(define-info-mouse (4) 'info-mouse-previous-line)
(define-info-mouse (5) 'info-mouse-next-line)
(if *info-click-to-select*
(define-info-mouse ('motion) 'info-mouse-motion-click nil)
(define-info-mouse ('motion) 'info-mouse-motion-drag nil)))
(add-hook *binding-hook* 'set-default-info-mouse)
(let (info)
(define-handler info-mode :key-press (code state)
(funcall-key-from-code *info-keys* code state info))
(define-handler info-mode :motion-notify (window root-x root-y)
(unless (compress-motion-notify)
(funcall-button-from-code *info-mouse* 'motion (modifiers->state *default-modifiers*)
window root-x root-y *fun-press* (list info))))
(define-handler info-mode :button-press (window root-x root-y code state)
(funcall-button-from-code *info-mouse* code state window root-x root-y *fun-press* (list info)))
(define-handler info-mode :button-release (window root-x root-y code state)
(funcall-button-from-code *info-mouse* code state window root-x root-y *fun-release* (list info)))
(defun info-mode (info-list &key (width nil) (height nil))
"Open the info mode. Info-list is a list of info: One string per line
Or for colored output: a list (line_string color)
Or ((1_word color) (2_word color) 3_word (4_word color)...)"
(when info-list
(setf *info-selected-item* 0)
(labels ((compute-size (line)
(typecase line
(cons (typecase (first line)
(cons (let ((val 0))
(dolist (l line val)
(incf val (typecase l
(cons (length (first l)))
(t (length l)))))))
(t (length (first line)))))
(t (length line)))))
(let* ((font (xlib:open-font *display* *info-font-string*))
(ilw (xlib:max-char-width font))
(ilh (+ (xlib:max-char-ascent font) (xlib:max-char-descent font) 1))
(width (or width
(min (* (+ (loop for l in info-list maximize (compute-size l)) 2) ilw)
(screen-width))))
(height (or height
(min (round (+ (* (length info-list) ilh) (/ ilh 2)))
(screen-height)))))
(with-placement (*info-mode-placement* x y width height)
(let* ((window (xlib:create-window :parent *root*
:x x :y y
:width width
:height height
:background (get-color *info-background*)
:colormap (xlib:screen-default-colormap *screen*)
:border-width *border-size*
:border (get-color *info-border*)
:event-mask '(:exposure)))
(gc (xlib:create-gcontext :drawable window
:foreground (get-color *info-foreground*)
:background (get-color *info-background*)
:font font
:line-style :solid)))
(setf info (make-info :window window :gc gc :x 0 :y 0 :list info-list
:font font :ilw ilw :ilh ilh
:max-x (* (loop for l in info-list maximize (compute-size l)) ilw)
:max-y (* (length info-list) ilh)))
(setf (window-transparency window) *info-transparency*)
(map-window window)
(draw-info-window info)
(wait-no-key-or-button-press)
(with-grab-keyboard-and-pointer (68 69 66 67)
(generic-mode 'info-mode 'exit-info-loop
:original-mode '(main-mode)))
(xlib:free-gcontext gc)
(xlib:destroy-window window)
(xlib:close-font font)
(xlib:display-finish-output *display*)
(display-all-frame-info)
(wait-no-key-or-button-press)
*info-selected-item*)))))))
(defun info-mode-menu (item-list &key (width nil) (height nil))
"Open an info help menu.
Item-list is: '((key function) separator (key function))
or with explicit docstring: '((key function \"documentation 1\") (key function \"bla bla\") (key function))
key is a character, a keycode or a keysym
Separator is a string or a symbol (all but a list)
Function can be a function or a list (function color) for colored output"
(let ((info-list nil)
(action nil)
(old-info-keys (copy-hash-table *info-keys*)))
(labels ((define-key (key function)
(define-info-key-fun (list key)
(lambda (&optional args)
(declare (ignore args))
(setf action function)
(leave-info-mode nil)))))
(dolist (item item-list)
(typecase item
(cons (destructuring-bind (key function explicit-doc) (ensure-n-elems item 3)
(typecase function
(cons (push (list (list (format nil "~A" key) *menu-color-menu-key*)
(list (format nil ": ~A" (or explicit-doc (documentation (first function) 'function)))
(second function)))
info-list)
(define-key key (first function)))
(t (push (list (list (format nil "~A" key) *menu-color-key*)
(format nil ": ~A" (or explicit-doc (documentation function 'function))))
info-list)
(define-key key function)))))
(t (push (list (format nil "-=- ~A -=-" item) *menu-color-comment*) info-list))))
(let ((selected-item (info-mode (nreverse info-list) :width width :height height)))
(setf *info-keys* old-info-keys)
(when selected-item
(awhen (nth selected-item item-list)
(when (consp it)
(destructuring-bind (key function explicit-doc) (ensure-n-elems it 3)
(declare (ignore key explicit-doc))
(typecase function
(cons (setf action (first function)))
(t (setf action function)))))))
(typecase action
(function (funcall action))
(symbol (when (fboundp action)
(funcall action))))))))
(defun keys-from-list (list)
"Produce a key menu based on list item"
(loop for l in list
for i from 0
collect (list (number->char i) l)))
;;;,-----
;;;| CONFIG - Info mode functions
;;;`-----
(defun key-binding-colorize-line (list)
(loop :for line :in list
:collect (cond ((search "* CLFSWM Keys *" line) (list line *info-color-title*))
((search "---" line) (list line *info-color-underline*))
((begin-with-2-spaces line)
(list (list (subseq line 0 22) *info-color-second*)
(list (subseq line 22 35) *info-color-first*)
(subseq line 35)))
(t line))))
(defun show-key-binding (&rest hash-table-key)
"Show the binding of each hash-table-key.
Pass the :no-producing-doc symbol to remove the producing doc"
(info-mode (key-binding-colorize-line
(split-string (append-newline-space
(with-output-to-string (stream)
(produce-doc (remove :no-producing-doc hash-table-key)
stream
(not (member :no-producing-doc hash-table-key)))))
#\Newline))))
(defun show-global-key-binding ()
"Show all key binding"
(show-key-binding *main-keys* *main-mouse* *second-keys* *second-mouse*
*info-keys* *info-mouse*))
(defun show-main-mode-key-binding ()
"Show the main mode binding"
(show-key-binding *main-keys* *main-mouse*))
(defun show-second-mode-key-binding ()
"Show the second mode key binding"
(show-key-binding *second-keys* *second-mouse*))
(defun show-circulate-mode-key-binding ()
"Show the circulate mode key binding"
(show-key-binding *circulate-keys*))
(defun show-expose-window-mode-key-binding ()
"Show the expose window mode key binding"
(show-key-binding *expose-keys* *expose-mouse*))
(defun show-first-aid-kit ()
"Show the first aid kit key binding"
(labels ((add-key (hash symbol &optional (hashkey *main-keys*))
(multiple-value-bind (k v)
(find-in-hash symbol hashkey)
(setf (gethash k hash) v))))
(let ((hash (make-hash-table :test #'equal))
(hash-second (make-hash-table :test #'equal)))
(setf (gethash 'name hash) "First aid kit - Main mode key binding"
(gethash 'name hash-second) "First aid kit - Second mode key binding")
(add-key hash 'select-next-child)
(add-key hash 'select-previous-child)
(add-key hash 'select-next-brother)
(add-key hash 'select-previous-brother)
(add-key hash 'select-previous-level)
(add-key hash 'select-next-level)
(add-key hash 'enter-frame)
(add-key hash 'leave-frame)
(add-key hash 'second-key-mode)
(add-key hash 'expose-windows-mode)
(add-key hash 'expose-all-windows-mode)
(add-key hash 'present-clfswm-terminal)
(add-key hash-second 'leave-second-mode *second-keys*)
(add-key hash-second 'open-menu *second-keys*)
(add-key hash-second 'run-program-from-query-string *second-keys*)
(add-key hash-second 'eval-from-query-string *second-keys*)
(add-key hash-second 'set-open-in-new-frame-in-parent-frame-nw-hook *second-keys*)
(add-key hash-second 'b-start-xterm *second-keys*)
(add-key hash-second 'b-start-emacs *second-keys*)
(show-key-binding hash hash-second :no-producing-doc))))
(defun corner-help-colorize-line (list)
(loop :for line :in list
:collect (cond ((search "CLFSWM:" line) (list line *info-color-title*))
((search "*:" line) (list line *info-color-underline*))
((begin-with-2-spaces line)
(let ((pos (position #\: line)))
(if pos
(list (list (subseq line 0 (1+ pos)) *info-color-first*)
(subseq line (1+ pos)))
line)))
(t line))))
(defun show-corner-help ()
"Help on clfswm corner"
(info-mode (corner-help-colorize-line
(split-string (append-newline-space
(with-output-to-string (stream)
(produce-corner-doc stream)))
#\Newline))))
(defun configuration-variable-colorize-line (list)
(loop :for line :in list
:collect (cond ((search "CLFSWM " line) (list line *info-color-title*))
((search "* =" line)
(let ((pos (position #\= line)))
(list (list (subseq line 0 (1+ pos)) *info-color-first*)
(list (subseq line (1+ pos)) *info-color-second*))))
((search "<=" line) (list line *info-color-underline*))
(t line))))
(defun show-config-variable ()
"Show all configurable variables"
(let ((result nil))
(labels ((rec ()
(setf result nil)
(info-mode-menu (loop :for group :in (config-all-groups)
:for i :from 0
:collect (list (number->char i)
(let ((group group))
(lambda ()
(setf result group)))
(config-group->string group))))
(when result
(info-mode (configuration-variable-colorize-line
(split-string (append-newline-space
(with-output-to-string (stream)
(produce-conf-var-doc stream result t nil)))
#\Newline)))
(rec))))
(rec))))
(defun show-date ()
"Show the current time and date"
(info-mode (list (list `("Current date:" ,*menu-color-comment*) (date-string)))))
(defun info-on-shell (msg program)
(let ((lines (do-shell program nil t)))
(info-mode (append (list (list msg *menu-color-comment*))
(loop for line = (read-line lines nil nil)
while line
collect (ensure-printable line))))))
(defun show-cpu-proc ()
"Show current processes sorted by CPU usage"
(info-on-shell "Current processes sorted by CPU usage:"
"ps --cols=1000 --sort='-%cpu,uid,pgid,ppid,pid' -e -o user,pid,stime,pcpu,pmem,args"))
(defun show-mem-proc ()
"Show current processes sorted by memory usage"
(info-on-shell "Current processes sorted by MEMORY usage:"
"ps --cols=1000 --sort='-vsz,uid,pgid,ppid,pid' -e -o user,pid,stime,pcpu,pmem,args"))
(defun show-cd-info ()
"Show the current CD track"
(info-on-shell "Current CD track:" "pcd i"))
(defun show-cd-playlist ()
"Show the current CD playlist"
(info-on-shell "Current CD playlist:" "pcd mi"))
(defun show-version ()
"Show the current CLFSWM version"
(info-mode (list *clfswm-version*)))
| 24,380 | Common Lisp | .lisp | 486 | 38.088477 | 124 | 0.549941 | thijs/clfswm-old | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | c2c8a1d53af6a7ccb7c2cbfef04869ed396d8e0bd42f391737699e102c91c81f | 22,186 | [
-1
] |
22,189 | clfswm-circulate-mode.lisp | thijs_clfswm-old/src/clfswm-circulate-mode.lisp | ;;; --------------------------------------------------------------------------
;;; CLFSWM - FullScreen Window Manager
;;;
;;; --------------------------------------------------------------------------
;;; Documentation: Main functions
;;; --------------------------------------------------------------------------
;;;
;;; (C) 2005-2015 Philippe Brochard <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;;;
;;; --------------------------------------------------------------------------
(in-package :clfswm)
(defparameter *circulate-window* nil)
(defparameter *circulate-font* nil)
(defparameter *circulate-gc* nil)
(defparameter *circulate-hit* 0)
(defparameter *circulate-orig* nil)
(defparameter *circulate-parent* nil)
(defun draw-circulate-mode-window ()
(raise-window *circulate-window*)
(clear-pixmap-buffer *circulate-window* *circulate-gc*)
(let* ((text (format nil "~A [~A]"
(limit-length (ensure-printable (child-name (xlib:input-focus *display*)))
*circulate-text-limite*)
(limit-length (ensure-printable (child-name (current-child)))
*circulate-text-limite*)))
(len (length text)))
(xlib:draw-glyphs *pixmap-buffer* *circulate-gc*
(truncate (/
(- *circulate-width* (* (xlib:max-char-width *circulate-font*) len))
2))
(truncate (/ (+ *circulate-height* (- (xlib:font-ascent *circulate-font*)
(xlib:font-descent *circulate-font*)))
2))
text))
(copy-pixmap-buffer *circulate-window* *circulate-gc*))
(defun leave-circulate-mode ()
"Leave the circulate mode"
(throw 'exit-circulate-loop nil))
(defun reset-circulate-child ()
(setf *circulate-hit* 0
*circulate-parent* nil
*circulate-orig* (frame-child (current-child))))
(defun reset-circulate-brother ()
(setf *circulate-parent* (find-parent-frame (current-child))
*circulate-hit* 0)
(when (frame-p *circulate-parent*)
(setf *circulate-orig* (frame-child *circulate-parent*))))
(defun reorder-child (direction)
(no-focus)
(with-slots (child selected-pos) (current-child)
(unless *circulate-orig*
(reset-circulate-child))
(let ((len (length *circulate-orig*)))
(when (plusp len)
(let ((elem (nth (mod (incf *circulate-hit* direction) len) *circulate-orig*)))
(setf child (cons elem (child-remove elem *circulate-orig*))
selected-pos 0)))
(show-all-children)
(draw-circulate-mode-window))))
(defun reorder-brother (direction)
(no-focus)
(let ((old-child (current-child)))
(select-current-frame nil)
(unless (and *circulate-orig* *circulate-parent*)
(reset-circulate-brother))
(let ((len (length *circulate-orig*)))
(when (plusp len)
(when (frame-p *circulate-parent*)
(let ((elem (nth (mod (incf *circulate-hit* direction) len) *circulate-orig*)))
(setf (frame-child *circulate-parent*) (cons elem (child-remove elem *circulate-orig*))
(frame-selected-pos *circulate-parent*) 0
(current-child) (frame-selected-child *circulate-parent*))))
(when (and (not (child-root-p (current-child)))
(child-root-p old-child))
(change-root (find-root old-child) (current-child)))))
(show-all-children t)
(draw-circulate-mode-window)))
(defun reorder-subchild (direction)
(declare (ignore direction))
(when (frame-p (current-child))
(let ((selected-child (frame-selected-child (current-child))))
(when (frame-p selected-child)
(no-focus)
(with-slots (child selected-pos) selected-child
(let ((elem (first (last child))))
(when elem
(setf child (cons elem (child-remove elem child))
selected-pos 0))
(show-all-children)
(draw-circulate-mode-window)))))))
(defun circulate-select-next-child ()
"Select the next child"
(when (frame-p (current-child))
(when *circulate-parent*
(reset-circulate-child))
(reorder-child +1)))
(defun circulate-select-previous-child ()
"Select the previous child"
(when (frame-p (current-child))
(when *circulate-parent*
(reset-circulate-child))
(reorder-child -1)))
(defun circulate-select-next-brother ()
"Select the next brother"
(unless *circulate-parent*
(reset-circulate-brother))
(reorder-brother +1))
(defun circulate-select-previous-brother ()
"Select the previous borther"
(unless *circulate-parent*
(reset-circulate-brother))
(reorder-brother -1))
(defun circulate-select-next-subchild ()
"Select the next subchild"
(reorder-subchild +1))
(add-hook *binding-hook* 'set-default-circulate-keys)
(defun set-default-circulate-keys ()
(define-circulate-key ("Escape") 'leave-circulate-mode)
(define-circulate-key ("g" :control) 'leave-circulate-mode)
(define-circulate-key ("Escape" :alt) 'leave-circulate-mode)
(define-circulate-key ("g" :control :alt) 'leave-circulate-mode)
(define-circulate-key ("Tab" :mod-1) 'circulate-select-next-child)
(define-circulate-key ("Tab" :mod-1 :control) 'circulate-select-next-subchild)
(define-circulate-key ("Tab" :mod-1 :shift) 'circulate-select-previous-child)
(define-circulate-key ("Iso_Left_Tab" :mod-1 :shift) 'circulate-select-previous-child)
(define-circulate-key ("Right" :mod-1) 'circulate-select-next-brother)
(define-circulate-key ("Left" :mod-1) 'circulate-select-previous-brother)
(define-circulate-release-key ("Alt_L" :alt) 'leave-circulate-mode)
(define-circulate-release-key ("Alt_L") 'leave-circulate-mode))
(defun circulate-leave-function ()
(when *circulate-gc*
(xlib:free-gcontext *circulate-gc*))
(when *circulate-window*
(xlib:destroy-window *circulate-window*))
(when *circulate-font*
(xlib:close-font *circulate-font*))
(setf *circulate-window* nil
*circulate-gc* nil
*circulate-font* nil)
(xlib:display-finish-output *display*))
(defun circulate-loop-function ()
(unless (is-a-key-pressed-p)
(leave-circulate-mode)))
(define-handler circulate-mode :key-press (code state)
(unless (funcall-key-from-code *circulate-keys* code state)
(setf *circulate-hit* 0
*circulate-orig* nil
*circulate-parent* nil)
(funcall-key-from-code *main-keys* code state)))
(define-handler circulate-mode :key-release (code state)
(funcall-key-from-code *circulate-keys-release* code state))
(defun circulate-mode (&key child-direction brother-direction subchild-direction)
(setf *circulate-hit* 0)
(with-placement (*circulate-mode-placement* x y *circulate-width* *circulate-height*)
(setf *circulate-font* (xlib:open-font *display* *circulate-font-string*)
*circulate-window* (xlib:create-window :parent *root*
:x x
:y y
:width *circulate-width*
:height *circulate-height*
:background (get-color *circulate-background*)
:border-width *border-size*
:border (get-color *circulate-border*)
:colormap (xlib:screen-default-colormap *screen*)
:event-mask '(:exposure :key-press))
*circulate-gc* (xlib:create-gcontext :drawable *circulate-window*
:foreground (get-color *circulate-foreground*)
:background (get-color *circulate-background*)
:font *circulate-font*
:line-style :solid))
(setf (window-transparency *circulate-window*) *circulate-transparency*)
(map-window *circulate-window*)
(draw-circulate-mode-window)
(when child-direction
(reorder-child child-direction))
(when brother-direction
(reorder-brother brother-direction))
(when subchild-direction
(reorder-subchild subchild-direction))
(with-grab-keyboard-and-pointer (92 93 66 67 t)
(generic-mode 'circulate-mode 'exit-circulate-loop
:loop-function #'circulate-loop-function
:leave-function #'circulate-leave-function
:original-mode '(main-mode))
(circulate-leave-function))))
(defun select-next-child ()
"Select the next child"
(when (frame-p (current-child))
(setf *circulate-orig* (frame-child (current-child))
*circulate-parent* nil)
(circulate-mode :child-direction +1)))
(defun select-previous-child ()
"Select the previous child"
(when (frame-p (current-child))
(setf *circulate-orig* (frame-child (current-child))
*circulate-parent* nil)
(circulate-mode :child-direction -1)))
(defun select-next-brother ()
"Select the next brother"
(setf *circulate-parent* (find-parent-frame (current-child)))
(when (frame-p *circulate-parent*)
(setf *circulate-orig* (frame-child *circulate-parent*)))
(circulate-mode :brother-direction +1))
(defun select-previous-brother ()
"Select the previous brother"
(setf *circulate-parent* (find-parent-frame (current-child)))
(when (frame-p *circulate-parent*)
(setf *circulate-orig* (frame-child *circulate-parent*)))
(circulate-mode :brother-direction -1))
(defmacro with-move-current-focused-window (() &body body)
`(with-current-window
,@body
(move-child-to window (if (frame-p (current-child))
(current-child)
(find-parent-frame (current-child) (find-current-root))))))
(defun select-next-brother-take-current ()
"Select the next brother and move the current focused child in it"
(with-move-current-focused-window ()
(select-next-brother)))
(defun select-previous-brother-take-current ()
"Select the previous brother and move the current focused child in it"
(with-move-current-focused-window ()
(select-previous-brother)))
(defun select-next-subchild ()
"Select the next subchild"
(when (and (frame-p (current-child))
(frame-p (frame-selected-child (current-child))))
(setf *circulate-orig* (frame-child (current-child))
*circulate-parent* nil)
(circulate-mode :subchild-direction +1)))
(defun select-next-child-simple ()
"Select the next child (do not enter in circulate mode)"
(when (frame-p (current-child))
(with-slots (child) (current-child)
(setf child (rotate-list child)))
(show-all-children)))
(defun select-previous-child-simple ()
"Select the previous child (do not enter circulate mode)"
(when (frame-p (current-child))
(with-slots (child) (current-child)
(setf child (anti-rotate-list child)))
(show-all-children)))
(defun reorder-brother-simple (reorder-fun)
(let ((is-root-p (child-root-p (current-child))))
(when is-root-p
(leave-frame)
(sleep *spatial-move-delay-before*))
(no-focus)
(select-current-frame nil)
(let ((parent-frame (find-parent-frame (current-child))))
(when (frame-p parent-frame)
(with-slots (child) parent-frame
(setf child (funcall reorder-fun child)
(current-child) (frame-selected-child parent-frame))))
(show-all-children t)
(when is-root-p
(sleep *spatial-move-delay-after*)
(enter-frame)))))
(defun select-next-brother-simple ()
"Select the next brother frame (do not enter in circulate mode)"
(reorder-brother-simple #'rotate-list))
(defun select-previous-brother-simple ()
"Select the previous brother frame (do not enter in circulate mode)"
(reorder-brother-simple #'anti-rotate-list))
;;; Spatial move functions
(defun select-brother-generic-spatial-move (fun-found)
"Select the nearest brother of the current child based on the fun-found function"
(let ((is-root-p (child-root-p (current-child))))
(when is-root-p
(leave-frame)
(sleep *spatial-move-delay-before*))
(no-focus)
(select-current-frame nil)
(let ((parent-frame (find-parent-frame (current-child))))
(when (frame-p parent-frame)
(with-slots (child selected-pos) parent-frame
(let ((found nil)
(found-dist nil))
(dolist (c child)
(let ((dist (funcall fun-found (current-child) c)))
(when (and dist
(not (child-equal-p (current-child) c))
(or (not found)
(and found-dist (< dist found-dist))))
(setf found c
found-dist dist))))
(when found
(setf (current-child) found
selected-pos 0
child (cons found (child-remove found child)))))))
(show-all-children t)
(when is-root-p
(sleep *spatial-move-delay-after*)
(enter-frame)))))
(defun select-brother-spatial-move-right ()
"Select spatially the nearest brother of the current child in the right direction"
(select-brother-generic-spatial-move #'(lambda (current child)
(when (> (child-x2 child) (child-x2 current))
(distance (child-x2 current) (middle-child-y current)
(child-x child) (middle-child-y child))))))
(defun select-brother-spatial-move-left ()
"Select spatially the nearest brother of the current child in the left direction"
(select-brother-generic-spatial-move #'(lambda (current child)
(when (< (child-x child) (child-x current))
(distance (child-x current) (middle-child-y current)
(child-x2 child) (middle-child-y child))))))
(defun select-brother-spatial-move-down ()
"Select spatially the nearest brother of the current child in the down direction"
(select-brother-generic-spatial-move #'(lambda (current child)
(when (> (child-y2 child) (child-y2 current))
(distance (middle-child-x current) (child-y2 current)
(middle-child-x child) (child-y child))))))
(defun select-brother-spatial-move-up ()
"Select spatially the nearest brother of the current child in the up direction"
(select-brother-generic-spatial-move #'(lambda (current child)
(when (< (child-y child) (child-y current))
(distance (middle-child-x current) (child-y current)
(middle-child-x child) (child-y2 child))))))
(defun select-brother-spatial-move-right-take-current ()
"Select spatially the nearest brother of the current child in the right direction
- move current focused child"
(with-move-current-focused-window ()
(select-brother-spatial-move-right)))
(defun select-brother-spatial-move-left-take-current ()
"Select spatially the nearest brother of the current child in the left direction
- move current focused child"
(with-move-current-focused-window ()
(select-brother-spatial-move-left)))
(defun select-brother-spatial-move-down-take-current ()
"Select spatially the nearest brother of the current child in the down direction
- move current focused child"
(with-move-current-focused-window ()
(select-brother-spatial-move-down)))
(defun select-brother-spatial-move-up-take-current ()
"Select spatially the nearest brother of the current child in the up direction
- move current focused child"
(with-move-current-focused-window ()
(select-brother-spatial-move-up)))
| 17,075 | Common Lisp | .lisp | 352 | 38.883523 | 101 | 0.611682 | thijs/clfswm-old | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 770e2e108ea1ed9d7fc8f5ba37893ede0418ca9bca6a314789b98488ddcc212f | 22,189 | [
-1
] |
22,201 | keysyms.lisp | thijs_clfswm-old/src/keysyms.lisp | ;; Copyright (C) 2006 Matthew Kennedy
;;
;; This file is part of stumpwm.
;;
;; stumpwm is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; stumpwm is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;; Commentary:
;;
;; Mapping a keysym to a name is a client side activity in X11. Some
;; of the code here was taken from the CMUCL Hemlocks code base. The
;; actual mappings were taken from Xorg's keysymdefs.h.
;;
;; Code:
(in-package :clfswm)
(defvar *keysym-name-translations* (make-hash-table))
(defvar *name-keysym-translations* (make-hash-table :test #'equal))
(defun cl-define-keysym (keysym name)
"Define a mapping from a keysym name to a keysym."
(setf (gethash keysym *keysym-name-translations*) name
(gethash name *name-keysym-translations*) keysym))
(defun keysym-name->keysym (name)
"Return the keysym corresponding to NAME."
(multiple-value-bind (value present-p)
(gethash name *name-keysym-translations*)
(declare (ignore present-p))
value))
(defun keysym->keysym-name (keysym)
"Return the name corresponding to KEYSYM."
(multiple-value-bind (value present-p)
(gethash keysym *keysym-name-translations*)
(declare (ignore present-p))
value))
(cl-define-keysym #xffffff "VoidSymbol") ;Void symbol
(cl-define-keysym #xff08 "BackSpace") ;Back space, back char
(cl-define-keysym #xff09 "Tab")
(cl-define-keysym #xff0a "Linefeed") ;Linefeed, LF
(cl-define-keysym #xff0b "Clear")
(cl-define-keysym #xff0d "Return") ;Return, enter
(cl-define-keysym #xff13 "Pause") ;Pause, hold
(cl-define-keysym #xff14 "Scroll_Lock")
(cl-define-keysym #xff15 "Sys_Req")
(cl-define-keysym #xff1b "Escape")
(cl-define-keysym #xffff "Delete") ;Delete, rubout
(cl-define-keysym #xff20 "Multi_key") ;Multi-key character compose
(cl-define-keysym #xff37 "Codeinput")
(cl-define-keysym #xff3c "SingleCandidate")
(cl-define-keysym #xff3d "MultipleCandidate")
(cl-define-keysym #xff3e "PreviousCandidate")
(cl-define-keysym #xff21 "Kanji") ;Kanji, Kanji convert
(cl-define-keysym #xff22 "Muhenkan") ;Cancel Conversion
(cl-define-keysym #xff23 "Henkan_Mode") ;Start/Stop Conversion
(cl-define-keysym #xff23 "Henkan") ;Alias for Henkan_Mode
(cl-define-keysym #xff24 "Romaji") ;to Romaji
(cl-define-keysym #xff25 "Hiragana") ;to Hiragana
(cl-define-keysym #xff26 "Katakana") ;to Katakana
(cl-define-keysym #xff27 "Hiragana_Katakana") ;Hiragana/Katakana toggle
(cl-define-keysym #xff28 "Zenkaku") ;to Zenkaku
(cl-define-keysym #xff29 "Hankaku") ;to Hankaku
(cl-define-keysym #xff2a "Zenkaku_Hankaku") ;Zenkaku/Hankaku toggle
(cl-define-keysym #xff2b "Touroku") ;Add to Dictionary
(cl-define-keysym #xff2c "Massyo") ;Delete from Dictionary
(cl-define-keysym #xff2d "Kana_Lock") ;Kana Lock
(cl-define-keysym #xff2e "Kana_Shift") ;Kana Shift
(cl-define-keysym #xff2f "Eisu_Shift") ;Alphanumeric Shift
(cl-define-keysym #xff30 "Eisu_toggle") ;Alphanumeric toggle
(cl-define-keysym #xff37 "Kanji_Bangou") ;Codeinput
(cl-define-keysym #xff3d "Zen_Koho") ;Multiple/All Candidate(s)
(cl-define-keysym #xff3e "Mae_Koho") ;Previous Candidate
(cl-define-keysym #xff50 "Home")
(cl-define-keysym #xff51 "Left") ;Move left, left arrow
(cl-define-keysym #xff52 "Up") ;Move up, up arrow
(cl-define-keysym #xff53 "Right") ;Move right, right arrow
(cl-define-keysym #xff54 "Down") ;Move down, down arrow
(cl-define-keysym #xff55 "Prior") ;Prior, previous
(cl-define-keysym #xff55 "Page_Up")
(cl-define-keysym #xff56 "Next") ;Next
(cl-define-keysym #xff56 "Page_Down")
(cl-define-keysym #xff57 "End") ;EOL
(cl-define-keysym #xff58 "Begin") ;BOL
(cl-define-keysym #xff60 "Select") ;Select, mark
(cl-define-keysym #xff61 "Print")
(cl-define-keysym #xff62 "Execute") ;Execute, run, do
(cl-define-keysym #xff63 "Insert") ;Insert, insert here
(cl-define-keysym #xff65 "Undo")
(cl-define-keysym #xff66 "Redo") ;Redo, again
(cl-define-keysym #xff67 "Menu")
(cl-define-keysym #xff68 "Find") ;Find, search
(cl-define-keysym #xff69 "Cancel") ;Cancel, stop, abort, exit
(cl-define-keysym #xff6a "Help") ;Help
(cl-define-keysym #xff6b "Break")
(cl-define-keysym #xff7e "Mode_switch") ;Character set switch
(cl-define-keysym #xff7e "script_switch") ;Alias for mode_switch
(cl-define-keysym #xff7f "Num_Lock")
(cl-define-keysym #xff80 "KP_Space") ;Space
(cl-define-keysym #xff89 "KP_Tab")
(cl-define-keysym #xff8d "KP_Enter") ;Enter
(cl-define-keysym #xff91 "KP_F1") ;PF1, KP_A, ...
(cl-define-keysym #xff92 "KP_F2")
(cl-define-keysym #xff93 "KP_F3")
(cl-define-keysym #xff94 "KP_F4")
(cl-define-keysym #xff95 "KP_Home")
(cl-define-keysym #xff96 "KP_Left")
(cl-define-keysym #xff97 "KP_Up")
(cl-define-keysym #xff98 "KP_Right")
(cl-define-keysym #xff99 "KP_Down")
(cl-define-keysym #xff9a "KP_Prior")
(cl-define-keysym #xff9a "KP_Page_Up")
(cl-define-keysym #xff9b "KP_Next")
(cl-define-keysym #xff9b "KP_Page_Down")
(cl-define-keysym #xff9c "KP_End")
(cl-define-keysym #xff9d "KP_Begin")
(cl-define-keysym #xff9e "KP_Insert")
(cl-define-keysym #xff9f "KP_Delete")
(cl-define-keysym #xffbd "KP_Equal") ;Equals
(cl-define-keysym #xffaa "KP_Multiply")
(cl-define-keysym #xffab "KP_Add")
(cl-define-keysym #xffac "KP_Separator") ;Separator, often comma
(cl-define-keysym #xffad "KP_Subtract")
(cl-define-keysym #xffae "KP_Decimal")
(cl-define-keysym #xffaf "KP_Divide")
(cl-define-keysym #xffb0 "KP_0")
(cl-define-keysym #xffb1 "KP_1")
(cl-define-keysym #xffb2 "KP_2")
(cl-define-keysym #xffb3 "KP_3")
(cl-define-keysym #xffb4 "KP_4")
(cl-define-keysym #xffb5 "KP_5")
(cl-define-keysym #xffb6 "KP_6")
(cl-define-keysym #xffb7 "KP_7")
(cl-define-keysym #xffb8 "KP_8")
(cl-define-keysym #xffb9 "KP_9")
(cl-define-keysym #xffbe "F1")
(cl-define-keysym #xffbf "F2")
(cl-define-keysym #xffc0 "F3")
(cl-define-keysym #xffc1 "F4")
(cl-define-keysym #xffc2 "F5")
(cl-define-keysym #xffc3 "F6")
(cl-define-keysym #xffc4 "F7")
(cl-define-keysym #xffc5 "F8")
(cl-define-keysym #xffc6 "F9")
(cl-define-keysym #xffc7 "F10")
(cl-define-keysym #xffc8 "F11")
(cl-define-keysym #xffc9 "F12")
(cl-define-keysym #xffca "F13")
(cl-define-keysym #xffcb "F14")
(cl-define-keysym #xffcc "F15")
(cl-define-keysym #xffcd "F16")
(cl-define-keysym #xffce "F17")
(cl-define-keysym #xffcf "F18")
(cl-define-keysym #xffd0 "F19")
(cl-define-keysym #xffd1 "F20")
(cl-define-keysym #xffd2 "F21")
(cl-define-keysym #xffd3 "F22")
(cl-define-keysym #xffd4 "F23")
(cl-define-keysym #xffd5 "F24")
(cl-define-keysym #xffd6 "F25")
(cl-define-keysym #xffd7 "F26")
(cl-define-keysym #xffd8 "F27")
(cl-define-keysym #xffd9 "F28")
(cl-define-keysym #xffda "F29")
(cl-define-keysym #xffdb "F30")
(cl-define-keysym #xffdc "F31")
(cl-define-keysym #xffdd "F32")
(cl-define-keysym #xffde "F33")
(cl-define-keysym #xffdf "F34")
(cl-define-keysym #xffe0 "F35")
(cl-define-keysym #xffe1 "Shift_L") ;Left shift
(cl-define-keysym #xffe2 "Shift_R") ;Right shift
(cl-define-keysym #xffe3 "Control_L") ;Left control
(cl-define-keysym #xffe4 "Control_R") ;Right control
(cl-define-keysym #xffe5 "Caps_Lock") ;Caps lock
(cl-define-keysym #xffe6 "Shift_Lock") ;Shift lock
(cl-define-keysym #xffe7 "Meta_L") ;Left meta
(cl-define-keysym #xffe8 "Meta_R") ;Right meta
(cl-define-keysym #xffe9 "Alt_L") ;Left alt
(cl-define-keysym #xffea "Alt_R") ;Right alt
(cl-define-keysym #xffeb "Super_L") ;Left super
(cl-define-keysym #xffec "Super_R") ;Right super
(cl-define-keysym #xffed "Hyper_L") ;Left hyper
(cl-define-keysym #xffee "Hyper_R") ;Right hyper
(cl-define-keysym #xfe01 "ISO_Lock")
(cl-define-keysym #xfe02 "ISO_Level2_Latch")
(cl-define-keysym #xfe03 "ISO_Level3_Shift")
(cl-define-keysym #xfe04 "ISO_Level3_Latch")
(cl-define-keysym #xfe05 "ISO_Level3_Lock")
(cl-define-keysym #xff7e "ISO_Group_Shift") ;Alias for mode_switch
(cl-define-keysym #xfe06 "ISO_Group_Latch")
(cl-define-keysym #xfe07 "ISO_Group_Lock")
(cl-define-keysym #xfe08 "ISO_Next_Group")
(cl-define-keysym #xfe09 "ISO_Next_Group_Lock")
(cl-define-keysym #xfe0a "ISO_Prev_Group")
(cl-define-keysym #xfe0b "ISO_Prev_Group_Lock")
(cl-define-keysym #xfe0c "ISO_First_Group")
(cl-define-keysym #xfe0d "ISO_First_Group_Lock")
(cl-define-keysym #xfe0e "ISO_Last_Group")
(cl-define-keysym #xfe0f "ISO_Last_Group_Lock")
(cl-define-keysym #xfe20 "ISO_Left_Tab")
(cl-define-keysym #xfe21 "ISO_Move_Line_Up")
(cl-define-keysym #xfe22 "ISO_Move_Line_Down")
(cl-define-keysym #xfe23 "ISO_Partial_Line_Up")
(cl-define-keysym #xfe24 "ISO_Partial_Line_Down")
(cl-define-keysym #xfe25 "ISO_Partial_Space_Left")
(cl-define-keysym #xfe26 "ISO_Partial_Space_Right")
(cl-define-keysym #xfe27 "ISO_Set_Margin_Left")
(cl-define-keysym #xfe28 "ISO_Set_Margin_Right")
(cl-define-keysym #xfe29 "ISO_Release_Margin_Left")
(cl-define-keysym #xfe2a "ISO_Release_Margin_Right")
(cl-define-keysym #xfe2b "ISO_Release_Both_Margins")
(cl-define-keysym #xfe2c "ISO_Fast_Cursor_Left")
(cl-define-keysym #xfe2d "ISO_Fast_Cursor_Right")
(cl-define-keysym #xfe2e "ISO_Fast_Cursor_Up")
(cl-define-keysym #xfe2f "ISO_Fast_Cursor_Down")
(cl-define-keysym #xfe30 "ISO_Continuous_Underline")
(cl-define-keysym #xfe31 "ISO_Discontinuous_Underline")
(cl-define-keysym #xfe32 "ISO_Emphasize")
(cl-define-keysym #xfe33 "ISO_Center_Object")
(cl-define-keysym #xfe34 "ISO_Enter")
(cl-define-keysym #xfe50 "dead_grave")
(cl-define-keysym #xfe51 "dead_acute")
(cl-define-keysym #xfe52 "dead_circumflex")
(cl-define-keysym #xfe53 "dead_tilde")
(cl-define-keysym #xfe54 "dead_macron")
(cl-define-keysym #xfe55 "dead_breve")
(cl-define-keysym #xfe56 "dead_abovedot")
(cl-define-keysym #xfe57 "dead_diaeresis")
(cl-define-keysym #xfe58 "dead_abovering")
(cl-define-keysym #xfe59 "dead_doubleacute")
(cl-define-keysym #xfe5a "dead_caron")
(cl-define-keysym #xfe5b "dead_cedilla")
(cl-define-keysym #xfe5c "dead_ogonek")
(cl-define-keysym #xfe5d "dead_iota")
(cl-define-keysym #xfe5e "dead_voiced_sound")
(cl-define-keysym #xfe5f "dead_semivoiced_sound")
(cl-define-keysym #xfe60 "dead_belowdot")
(cl-define-keysym #xfe61 "dead_hook")
(cl-define-keysym #xfe62 "dead_horn")
(cl-define-keysym #xfed0 "First_Virtual_Screen")
(cl-define-keysym #xfed1 "Prev_Virtual_Screen")
(cl-define-keysym #xfed2 "Next_Virtual_Screen")
(cl-define-keysym #xfed4 "Last_Virtual_Screen")
(cl-define-keysym #xfed5 "Terminate_Server")
(cl-define-keysym #xfe70 "AccessX_Enable")
(cl-define-keysym #xfe71 "AccessX_Feedback_Enable")
(cl-define-keysym #xfe72 "RepeatKeys_Enable")
(cl-define-keysym #xfe73 "SlowKeys_Enable")
(cl-define-keysym #xfe74 "BounceKeys_Enable")
(cl-define-keysym #xfe75 "StickyKeys_Enable")
(cl-define-keysym #xfe76 "MouseKeys_Enable")
(cl-define-keysym #xfe77 "MouseKeys_Accel_Enable")
(cl-define-keysym #xfe78 "Overlay1_Enable")
(cl-define-keysym #xfe79 "Overlay2_Enable")
(cl-define-keysym #xfe7a "AudibleBell_Enable")
(cl-define-keysym #xfee0 "Pointer_Left")
(cl-define-keysym #xfee1 "Pointer_Right")
(cl-define-keysym #xfee2 "Pointer_Up")
(cl-define-keysym #xfee3 "Pointer_Down")
(cl-define-keysym #xfee4 "Pointer_UpLeft")
(cl-define-keysym #xfee5 "Pointer_UpRight")
(cl-define-keysym #xfee6 "Pointer_DownLeft")
(cl-define-keysym #xfee7 "Pointer_DownRight")
(cl-define-keysym #xfee8 "Pointer_Button_Dflt")
(cl-define-keysym #xfee9 "Pointer_Button1")
(cl-define-keysym #xfeea "Pointer_Button2")
(cl-define-keysym #xfeeb "Pointer_Button3")
(cl-define-keysym #xfeec "Pointer_Button4")
(cl-define-keysym #xfeed "Pointer_Button5")
(cl-define-keysym #xfeee "Pointer_DblClick_Dflt")
(cl-define-keysym #xfeef "Pointer_DblClick1")
(cl-define-keysym #xfef0 "Pointer_DblClick2")
(cl-define-keysym #xfef1 "Pointer_DblClick3")
(cl-define-keysym #xfef2 "Pointer_DblClick4")
(cl-define-keysym #xfef3 "Pointer_DblClick5")
(cl-define-keysym #xfef4 "Pointer_Drag_Dflt")
(cl-define-keysym #xfef5 "Pointer_Drag1")
(cl-define-keysym #xfef6 "Pointer_Drag2")
(cl-define-keysym #xfef7 "Pointer_Drag3")
(cl-define-keysym #xfef8 "Pointer_Drag4")
(cl-define-keysym #xfefd "Pointer_Drag5")
(cl-define-keysym #xfef9 "Pointer_EnableKeys")
(cl-define-keysym #xfefa "Pointer_Accelerate")
(cl-define-keysym #xfefb "Pointer_DfltBtnNext")
(cl-define-keysym #xfefc "Pointer_DfltBtnPrev")
(cl-define-keysym #xfd01 "3270_Duplicate")
(cl-define-keysym #xfd02 "3270_FieldMark")
(cl-define-keysym #xfd03 "3270_Right2")
(cl-define-keysym #xfd04 "3270_Left2")
(cl-define-keysym #xfd05 "3270_BackTab")
(cl-define-keysym #xfd06 "3270_EraseEOF")
(cl-define-keysym #xfd07 "3270_EraseInput")
(cl-define-keysym #xfd08 "3270_Reset")
(cl-define-keysym #xfd09 "3270_Quit")
(cl-define-keysym #xfd0a "3270_PA1")
(cl-define-keysym #xfd0b "3270_PA2")
(cl-define-keysym #xfd0c "3270_PA3")
(cl-define-keysym #xfd0d "3270_Test")
(cl-define-keysym #xfd0e "3270_Attn")
(cl-define-keysym #xfd0f "3270_CursorBlink")
(cl-define-keysym #xfd10 "3270_AltCursor")
(cl-define-keysym #xfd11 "3270_KeyClick")
(cl-define-keysym #xfd12 "3270_Jump")
(cl-define-keysym #xfd13 "3270_Ident")
(cl-define-keysym #xfd14 "3270_Rule")
(cl-define-keysym #xfd15 "3270_Copy")
(cl-define-keysym #xfd16 "3270_Play")
(cl-define-keysym #xfd17 "3270_Setup")
(cl-define-keysym #xfd18 "3270_Record")
(cl-define-keysym #xfd19 "3270_ChangeScreen")
(cl-define-keysym #xfd1a "3270_DeleteWord")
(cl-define-keysym #xfd1b "3270_ExSelect")
(cl-define-keysym #xfd1c "3270_CursorSelect")
(cl-define-keysym #xfd1d "3270_PrintScreen")
(cl-define-keysym #xfd1e "3270_Enter")
(cl-define-keysym #x0020 "space") ;U+0020 SPACE
(cl-define-keysym #x0021 "exclam") ;U+0021 EXCLAMATION MARK
(cl-define-keysym #x0022 "quotedbl") ;U+0022 QUOTATION MARK
(cl-define-keysym #x0023 "numbersign") ;U+0023 NUMBER SIGN
(cl-define-keysym #x0024 "dollar") ;U+0024 DOLLAR SIGN
(cl-define-keysym #x0025 "percent") ;U+0025 PERCENT SIGN
(cl-define-keysym #x0026 "ampersand") ;U+0026 AMPERSAND
(cl-define-keysym #x0027 "apostrophe") ;U+0027 APOSTROPHE
(cl-define-keysym #x0027 "quoteright") ;deprecated
(cl-define-keysym #x0028 "parenleft") ;U+0028 LEFT PARENTHESIS
(cl-define-keysym #x0029 "parenright") ;U+0029 RIGHT PARENTHESIS
(cl-define-keysym #x002a "asterisk") ;U+002A ASTERISK
(cl-define-keysym #x002b "plus") ;U+002B PLUS SIGN
(cl-define-keysym #x002c "comma") ;U+002C COMMA
(cl-define-keysym #x002d "minus") ;U+002D HYPHEN-MINUS
(cl-define-keysym #x002e "period") ;U+002E FULL STOP
(cl-define-keysym #x002f "slash") ;U+002F SOLIDUS
(cl-define-keysym #x0030 "0") ;U+0030 DIGIT ZERO
(cl-define-keysym #x0031 "1") ;U+0031 DIGIT ONE
(cl-define-keysym #x0032 "2") ;U+0032 DIGIT TWO
(cl-define-keysym #x0033 "3") ;U+0033 DIGIT THREE
(cl-define-keysym #x0034 "4") ;U+0034 DIGIT FOUR
(cl-define-keysym #x0035 "5") ;U+0035 DIGIT FIVE
(cl-define-keysym #x0036 "6") ;U+0036 DIGIT SIX
(cl-define-keysym #x0037 "7") ;U+0037 DIGIT SEVEN
(cl-define-keysym #x0038 "8") ;U+0038 DIGIT EIGHT
(cl-define-keysym #x0039 "9") ;U+0039 DIGIT NINE
(cl-define-keysym #x003a "colon") ;U+003A COLON
(cl-define-keysym #x003b "semicolon") ;U+003B SEMICOLON
(cl-define-keysym #x003c "less") ;U+003C LESS-THAN SIGN
(cl-define-keysym #x003d "equal") ;U+003D EQUALS SIGN
(cl-define-keysym #x003e "greater") ;U+003E GREATER-THAN SIGN
(cl-define-keysym #x003f "question") ;U+003F QUESTION MARK
(cl-define-keysym #x0040 "at") ;U+0040 COMMERCIAL AT
(cl-define-keysym #x0041 "A") ;U+0041 LATIN CAPITAL LETTER A
(cl-define-keysym #x0042 "B") ;U+0042 LATIN CAPITAL LETTER B
(cl-define-keysym #x0043 "C") ;U+0043 LATIN CAPITAL LETTER C
(cl-define-keysym #x0044 "D") ;U+0044 LATIN CAPITAL LETTER D
(cl-define-keysym #x0045 "E") ;U+0045 LATIN CAPITAL LETTER E
(cl-define-keysym #x0046 "F") ;U+0046 LATIN CAPITAL LETTER F
(cl-define-keysym #x0047 "G") ;U+0047 LATIN CAPITAL LETTER G
(cl-define-keysym #x0048 "H") ;U+0048 LATIN CAPITAL LETTER H
(cl-define-keysym #x0049 "I") ;U+0049 LATIN CAPITAL LETTER I
(cl-define-keysym #x004a "J") ;U+004A LATIN CAPITAL LETTER J
(cl-define-keysym #x004b "K") ;U+004B LATIN CAPITAL LETTER K
(cl-define-keysym #x004c "L") ;U+004C LATIN CAPITAL LETTER L
(cl-define-keysym #x004d "M") ;U+004D LATIN CAPITAL LETTER M
(cl-define-keysym #x004e "N") ;U+004E LATIN CAPITAL LETTER N
(cl-define-keysym #x004f "O") ;U+004F LATIN CAPITAL LETTER O
(cl-define-keysym #x0050 "P") ;U+0050 LATIN CAPITAL LETTER P
(cl-define-keysym #x0051 "Q") ;U+0051 LATIN CAPITAL LETTER Q
(cl-define-keysym #x0052 "R") ;U+0052 LATIN CAPITAL LETTER R
(cl-define-keysym #x0053 "S") ;U+0053 LATIN CAPITAL LETTER S
(cl-define-keysym #x0054 "T") ;U+0054 LATIN CAPITAL LETTER T
(cl-define-keysym #x0055 "U") ;U+0055 LATIN CAPITAL LETTER U
(cl-define-keysym #x0056 "V") ;U+0056 LATIN CAPITAL LETTER V
(cl-define-keysym #x0057 "W") ;U+0057 LATIN CAPITAL LETTER W
(cl-define-keysym #x0058 "X") ;U+0058 LATIN CAPITAL LETTER X
(cl-define-keysym #x0059 "Y") ;U+0059 LATIN CAPITAL LETTER Y
(cl-define-keysym #x005a "Z") ;U+005A LATIN CAPITAL LETTER Z
(cl-define-keysym #x005b "bracketleft") ;U+005B LEFT SQUARE BRACKET
(cl-define-keysym #x005c "backslash") ;U+005C REVERSE SOLIDUS
(cl-define-keysym #x005d "bracketright") ;U+005D RIGHT SQUARE BRACKET
(cl-define-keysym #x005e "asciicircum") ;U+005E CIRCUMFLEX ACCENT
(cl-define-keysym #x005f "underscore") ;U+005F LOW LINE
(cl-define-keysym #x0060 "grave") ;U+0060 GRAVE ACCENT
(cl-define-keysym #x0060 "quoteleft") ;deprecated
(cl-define-keysym #x0061 "a") ;U+0061 LATIN SMALL LETTER A
(cl-define-keysym #x0062 "b") ;U+0062 LATIN SMALL LETTER B
(cl-define-keysym #x0063 "c") ;U+0063 LATIN SMALL LETTER C
(cl-define-keysym #x0064 "d") ;U+0064 LATIN SMALL LETTER D
(cl-define-keysym #x0065 "e") ;U+0065 LATIN SMALL LETTER E
(cl-define-keysym #x0066 "f") ;U+0066 LATIN SMALL LETTER F
(cl-define-keysym #x0067 "g") ;U+0067 LATIN SMALL LETTER G
(cl-define-keysym #x0068 "h") ;U+0068 LATIN SMALL LETTER H
(cl-define-keysym #x0069 "i") ;U+0069 LATIN SMALL LETTER I
(cl-define-keysym #x006a "j") ;U+006A LATIN SMALL LETTER J
(cl-define-keysym #x006b "k") ;U+006B LATIN SMALL LETTER K
(cl-define-keysym #x006c "l") ;U+006C LATIN SMALL LETTER L
(cl-define-keysym #x006d "m") ;U+006D LATIN SMALL LETTER M
(cl-define-keysym #x006e "n") ;U+006E LATIN SMALL LETTER N
(cl-define-keysym #x006f "o") ;U+006F LATIN SMALL LETTER O
(cl-define-keysym #x0070 "p") ;U+0070 LATIN SMALL LETTER P
(cl-define-keysym #x0071 "q") ;U+0071 LATIN SMALL LETTER Q
(cl-define-keysym #x0072 "r") ;U+0072 LATIN SMALL LETTER R
(cl-define-keysym #x0073 "s") ;U+0073 LATIN SMALL LETTER S
(cl-define-keysym #x0074 "t") ;U+0074 LATIN SMALL LETTER T
(cl-define-keysym #x0075 "u") ;U+0075 LATIN SMALL LETTER U
(cl-define-keysym #x0076 "v") ;U+0076 LATIN SMALL LETTER V
(cl-define-keysym #x0077 "w") ;U+0077 LATIN SMALL LETTER W
(cl-define-keysym #x0078 "x") ;U+0078 LATIN SMALL LETTER X
(cl-define-keysym #x0079 "y") ;U+0079 LATIN SMALL LETTER Y
(cl-define-keysym #x007a "z") ;U+007A LATIN SMALL LETTER Z
(cl-define-keysym #x007b "braceleft") ;U+007B LEFT CURLY BRACKET
(cl-define-keysym #x007c "bar") ;U+007C VERTICAL LINE
(cl-define-keysym #x007d "braceright") ;U+007D RIGHT CURLY BRACKET
(cl-define-keysym #x007e "asciitilde") ;U+007E TILDE
(cl-define-keysym #x00a0 "nobreakspace") ;U+00A0 NO-BREAK SPACE
(cl-define-keysym #x00a1 "exclamdown") ;U+00A1 INVERTED EXCLAMATION MARK
(cl-define-keysym #x00a2 "cent") ;U+00A2 CENT SIGN
(cl-define-keysym #x00a3 "sterling") ;U+00A3 POUND SIGN
(cl-define-keysym #x00a4 "currency") ;U+00A4 CURRENCY SIGN
(cl-define-keysym #x00a5 "yen") ;U+00A5 YEN SIGN
(cl-define-keysym #x00a6 "brokenbar") ;U+00A6 BROKEN BAR
(cl-define-keysym #x00a7 "section") ;U+00A7 SECTION SIGN
(cl-define-keysym #x00a8 "diaeresis") ;U+00A8 DIAERESIS
(cl-define-keysym #x00a9 "copyright") ;U+00A9 COPYRIGHT SIGN
(cl-define-keysym #x00aa "ordfeminine") ;U+00AA FEMININE ORDINAL INDICATOR
(cl-define-keysym #x00ab "guillemotleft") ;U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
(cl-define-keysym #x00ac "notsign") ;U+00AC NOT SIGN
(cl-define-keysym #x00ad "hyphen") ;U+00AD SOFT HYPHEN
(cl-define-keysym #x00ae "registered") ;U+00AE REGISTERED SIGN
(cl-define-keysym #x00af "macron") ;U+00AF MACRON
(cl-define-keysym #x00b0 "degree") ;U+00B0 DEGREE SIGN
(cl-define-keysym #x00b1 "plusminus") ;U+00B1 PLUS-MINUS SIGN
(cl-define-keysym #x00b2 "twosuperior") ;U+00B2 SUPERSCRIPT TWO
(cl-define-keysym #x00b3 "threesuperior") ;U+00B3 SUPERSCRIPT THREE
(cl-define-keysym #x00b4 "acute") ;U+00B4 ACUTE ACCENT
(cl-define-keysym #x00b5 "mu") ;U+00B5 MICRO SIGN
(cl-define-keysym #x00b6 "paragraph") ;U+00B6 PILCROW SIGN
(cl-define-keysym #x00b7 "periodcentered") ;U+00B7 MIDDLE DOT
(cl-define-keysym #x00b8 "cedilla") ;U+00B8 CEDILLA
(cl-define-keysym #x00b9 "onesuperior") ;U+00B9 SUPERSCRIPT ONE
(cl-define-keysym #x00ba "masculine") ;U+00BA MASCULINE ORDINAL INDICATOR
(cl-define-keysym #x00bb "guillemotright") ;U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
(cl-define-keysym #x00bc "onequarter") ;U+00BC VULGAR FRACTION ONE QUARTER
(cl-define-keysym #x00bd "onehalf") ;U+00BD VULGAR FRACTION ONE HALF
(cl-define-keysym #x00be "threequarters") ;U+00BE VULGAR FRACTION THREE QUARTERS
(cl-define-keysym #x00bf "questiondown") ;U+00BF INVERTED QUESTION MARK
(cl-define-keysym #x00c0 "Agrave") ;U+00C0 LATIN CAPITAL LETTER A WITH GRAVE
(cl-define-keysym #x00c1 "Aacute") ;U+00C1 LATIN CAPITAL LETTER A WITH ACUTE
(cl-define-keysym #x00c2 "Acircumflex") ;U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX
(cl-define-keysym #x00c3 "Atilde") ;U+00C3 LATIN CAPITAL LETTER A WITH TILDE
(cl-define-keysym #x00c4 "Adiaeresis") ;U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS
(cl-define-keysym #x00c5 "Aring") ;U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE
(cl-define-keysym #x00c6 "AE") ;U+00C6 LATIN CAPITAL LETTER AE
(cl-define-keysym #x00c7 "Ccedilla") ;U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA
(cl-define-keysym #x00c8 "Egrave") ;U+00C8 LATIN CAPITAL LETTER E WITH GRAVE
(cl-define-keysym #x00c9 "Eacute") ;U+00C9 LATIN CAPITAL LETTER E WITH ACUTE
(cl-define-keysym #x00ca "Ecircumflex") ;U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX
(cl-define-keysym #x00cb "Ediaeresis") ;U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS
(cl-define-keysym #x00cc "Igrave") ;U+00CC LATIN CAPITAL LETTER I WITH GRAVE
(cl-define-keysym #x00cd "Iacute") ;U+00CD LATIN CAPITAL LETTER I WITH ACUTE
(cl-define-keysym #x00ce "Icircumflex") ;U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX
(cl-define-keysym #x00cf "Idiaeresis") ;U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS
(cl-define-keysym #x00d0 "ETH") ;U+00D0 LATIN CAPITAL LETTER ETH
(cl-define-keysym #x00d0 "Eth") ;deprecated
(cl-define-keysym #x00d1 "Ntilde") ;U+00D1 LATIN CAPITAL LETTER N WITH TILDE
(cl-define-keysym #x00d2 "Ograve") ;U+00D2 LATIN CAPITAL LETTER O WITH GRAVE
(cl-define-keysym #x00d3 "Oacute") ;U+00D3 LATIN CAPITAL LETTER O WITH ACUTE
(cl-define-keysym #x00d4 "Ocircumflex") ;U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX
(cl-define-keysym #x00d5 "Otilde") ;U+00D5 LATIN CAPITAL LETTER O WITH TILDE
(cl-define-keysym #x00d6 "Odiaeresis") ;U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS
(cl-define-keysym #x00d7 "multiply") ;U+00D7 MULTIPLICATION SIGN
(cl-define-keysym #x00d8 "Oslash") ;U+00D8 LATIN CAPITAL LETTER O WITH STROKE
(cl-define-keysym #x00d8 "Ooblique") ;U+00D8 LATIN CAPITAL LETTER O WITH STROKE
(cl-define-keysym #x00d9 "Ugrave") ;U+00D9 LATIN CAPITAL LETTER U WITH GRAVE
(cl-define-keysym #x00da "Uacute") ;U+00DA LATIN CAPITAL LETTER U WITH ACUTE
(cl-define-keysym #x00db "Ucircumflex") ;U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX
(cl-define-keysym #x00dc "Udiaeresis") ;U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS
(cl-define-keysym #x00dd "Yacute") ;U+00DD LATIN CAPITAL LETTER Y WITH ACUTE
(cl-define-keysym #x00de "THORN") ;U+00DE LATIN CAPITAL LETTER THORN
(cl-define-keysym #x00de "Thorn") ;deprecated
(cl-define-keysym #x00df "ssharp") ;U+00DF LATIN SMALL LETTER SHARP S
(cl-define-keysym #x00e0 "agrave") ;U+00E0 LATIN SMALL LETTER A WITH GRAVE
(cl-define-keysym #x00e1 "aacute") ;U+00E1 LATIN SMALL LETTER A WITH ACUTE
(cl-define-keysym #x00e2 "acircumflex") ;U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX
(cl-define-keysym #x00e3 "atilde") ;U+00E3 LATIN SMALL LETTER A WITH TILDE
(cl-define-keysym #x00e4 "adiaeresis") ;U+00E4 LATIN SMALL LETTER A WITH DIAERESIS
(cl-define-keysym #x00e5 "aring") ;U+00E5 LATIN SMALL LETTER A WITH RING ABOVE
(cl-define-keysym #x00e6 "ae") ;U+00E6 LATIN SMALL LETTER AE
(cl-define-keysym #x00e7 "ccedilla") ;U+00E7 LATIN SMALL LETTER C WITH CEDILLA
(cl-define-keysym #x00e8 "egrave") ;U+00E8 LATIN SMALL LETTER E WITH GRAVE
(cl-define-keysym #x00e9 "eacute") ;U+00E9 LATIN SMALL LETTER E WITH ACUTE
(cl-define-keysym #x00ea "ecircumflex") ;U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX
(cl-define-keysym #x00eb "ediaeresis") ;U+00EB LATIN SMALL LETTER E WITH DIAERESIS
(cl-define-keysym #x00ec "igrave") ;U+00EC LATIN SMALL LETTER I WITH GRAVE
(cl-define-keysym #x00ed "iacute") ;U+00ED LATIN SMALL LETTER I WITH ACUTE
(cl-define-keysym #x00ee "icircumflex") ;U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX
(cl-define-keysym #x00ef "idiaeresis") ;U+00EF LATIN SMALL LETTER I WITH DIAERESIS
(cl-define-keysym #x00f0 "eth") ;U+00F0 LATIN SMALL LETTER ETH
(cl-define-keysym #x00f1 "ntilde") ;U+00F1 LATIN SMALL LETTER N WITH TILDE
(cl-define-keysym #x00f2 "ograve") ;U+00F2 LATIN SMALL LETTER O WITH GRAVE
(cl-define-keysym #x00f3 "oacute") ;U+00F3 LATIN SMALL LETTER O WITH ACUTE
(cl-define-keysym #x00f4 "ocircumflex") ;U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX
(cl-define-keysym #x00f5 "otilde") ;U+00F5 LATIN SMALL LETTER O WITH TILDE
(cl-define-keysym #x00f6 "odiaeresis") ;U+00F6 LATIN SMALL LETTER O WITH DIAERESIS
(cl-define-keysym #x00f7 "division") ;U+00F7 DIVISION SIGN
(cl-define-keysym #x00f8 "oslash") ;U+00F8 LATIN SMALL LETTER O WITH STROKE
(cl-define-keysym #x00f8 "ooblique") ;U+00F8 LATIN SMALL LETTER O WITH STROKE
(cl-define-keysym #x00f9 "ugrave") ;U+00F9 LATIN SMALL LETTER U WITH GRAVE
(cl-define-keysym #x00fa "uacute") ;U+00FA LATIN SMALL LETTER U WITH ACUTE
(cl-define-keysym #x00fb "ucircumflex") ;U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX
(cl-define-keysym #x00fc "udiaeresis") ;U+00FC LATIN SMALL LETTER U WITH DIAERESIS
(cl-define-keysym #x00fd "yacute") ;U+00FD LATIN SMALL LETTER Y WITH ACUTE
(cl-define-keysym #x00fe "thorn") ;U+00FE LATIN SMALL LETTER THORN
(cl-define-keysym #x00ff "ydiaeresis") ;U+00FF LATIN SMALL LETTER Y WITH DIAERESIS
(cl-define-keysym #x01a1 "Aogonek") ;U+0104 LATIN CAPITAL LETTER A WITH OGONEK
(cl-define-keysym #x01a2 "breve") ;U+02D8 BREVE
(cl-define-keysym #x01a3 "Lstroke") ;U+0141 LATIN CAPITAL LETTER L WITH STROKE
(cl-define-keysym #x01a5 "Lcaron") ;U+013D LATIN CAPITAL LETTER L WITH CARON
(cl-define-keysym #x01a6 "Sacute") ;U+015A LATIN CAPITAL LETTER S WITH ACUTE
(cl-define-keysym #x01a9 "Scaron") ;U+0160 LATIN CAPITAL LETTER S WITH CARON
(cl-define-keysym #x01aa "Scedilla") ;U+015E LATIN CAPITAL LETTER S WITH CEDILLA
(cl-define-keysym #x01ab "Tcaron") ;U+0164 LATIN CAPITAL LETTER T WITH CARON
(cl-define-keysym #x01ac "Zacute") ;U+0179 LATIN CAPITAL LETTER Z WITH ACUTE
(cl-define-keysym #x01ae "Zcaron") ;U+017D LATIN CAPITAL LETTER Z WITH CARON
(cl-define-keysym #x01af "Zabovedot") ;U+017B LATIN CAPITAL LETTER Z WITH DOT ABOVE
(cl-define-keysym #x01b1 "aogonek") ;U+0105 LATIN SMALL LETTER A WITH OGONEK
(cl-define-keysym #x01b2 "ogonek") ;U+02DB OGONEK
(cl-define-keysym #x01b3 "lstroke") ;U+0142 LATIN SMALL LETTER L WITH STROKE
(cl-define-keysym #x01b5 "lcaron") ;U+013E LATIN SMALL LETTER L WITH CARON
(cl-define-keysym #x01b6 "sacute") ;U+015B LATIN SMALL LETTER S WITH ACUTE
(cl-define-keysym #x01b7 "caron") ;U+02C7 CARON
(cl-define-keysym #x01b9 "scaron") ;U+0161 LATIN SMALL LETTER S WITH CARON
(cl-define-keysym #x01ba "scedilla") ;U+015F LATIN SMALL LETTER S WITH CEDILLA
(cl-define-keysym #x01bb "tcaron") ;U+0165 LATIN SMALL LETTER T WITH CARON
(cl-define-keysym #x01bc "zacute") ;U+017A LATIN SMALL LETTER Z WITH ACUTE
(cl-define-keysym #x01bd "doubleacute") ;U+02DD DOUBLE ACUTE ACCENT
(cl-define-keysym #x01be "zcaron") ;U+017E LATIN SMALL LETTER Z WITH CARON
(cl-define-keysym #x01bf "zabovedot") ;U+017C LATIN SMALL LETTER Z WITH DOT ABOVE
(cl-define-keysym #x01c0 "Racute") ;U+0154 LATIN CAPITAL LETTER R WITH ACUTE
(cl-define-keysym #x01c3 "Abreve") ;U+0102 LATIN CAPITAL LETTER A WITH BREVE
(cl-define-keysym #x01c5 "Lacute") ;U+0139 LATIN CAPITAL LETTER L WITH ACUTE
(cl-define-keysym #x01c6 "Cacute") ;U+0106 LATIN CAPITAL LETTER C WITH ACUTE
(cl-define-keysym #x01c8 "Ccaron") ;U+010C LATIN CAPITAL LETTER C WITH CARON
(cl-define-keysym #x01ca "Eogonek") ;U+0118 LATIN CAPITAL LETTER E WITH OGONEK
(cl-define-keysym #x01cc "Ecaron") ;U+011A LATIN CAPITAL LETTER E WITH CARON
(cl-define-keysym #x01cf "Dcaron") ;U+010E LATIN CAPITAL LETTER D WITH CARON
(cl-define-keysym #x01d0 "Dstroke") ;U+0110 LATIN CAPITAL LETTER D WITH STROKE
(cl-define-keysym #x01d1 "Nacute") ;U+0143 LATIN CAPITAL LETTER N WITH ACUTE
(cl-define-keysym #x01d2 "Ncaron") ;U+0147 LATIN CAPITAL LETTER N WITH CARON
(cl-define-keysym #x01d5 "Odoubleacute") ;U+0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
(cl-define-keysym #x01d8 "Rcaron") ;U+0158 LATIN CAPITAL LETTER R WITH CARON
(cl-define-keysym #x01d9 "Uring") ;U+016E LATIN CAPITAL LETTER U WITH RING ABOVE
(cl-define-keysym #x01db "Udoubleacute") ;U+0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
(cl-define-keysym #x01de "Tcedilla") ;U+0162 LATIN CAPITAL LETTER T WITH CEDILLA
(cl-define-keysym #x01e0 "racute") ;U+0155 LATIN SMALL LETTER R WITH ACUTE
(cl-define-keysym #x01e3 "abreve") ;U+0103 LATIN SMALL LETTER A WITH BREVE
(cl-define-keysym #x01e5 "lacute") ;U+013A LATIN SMALL LETTER L WITH ACUTE
(cl-define-keysym #x01e6 "cacute") ;U+0107 LATIN SMALL LETTER C WITH ACUTE
(cl-define-keysym #x01e8 "ccaron") ;U+010D LATIN SMALL LETTER C WITH CARON
(cl-define-keysym #x01ea "eogonek") ;U+0119 LATIN SMALL LETTER E WITH OGONEK
(cl-define-keysym #x01ec "ecaron") ;U+011B LATIN SMALL LETTER E WITH CARON
(cl-define-keysym #x01ef "dcaron") ;U+010F LATIN SMALL LETTER D WITH CARON
(cl-define-keysym #x01f0 "dstroke") ;U+0111 LATIN SMALL LETTER D WITH STROKE
(cl-define-keysym #x01f1 "nacute") ;U+0144 LATIN SMALL LETTER N WITH ACUTE
(cl-define-keysym #x01f2 "ncaron") ;U+0148 LATIN SMALL LETTER N WITH CARON
(cl-define-keysym #x01f5 "odoubleacute") ;U+0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE
(cl-define-keysym #x01fb "udoubleacute") ;U+0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE
(cl-define-keysym #x01f8 "rcaron") ;U+0159 LATIN SMALL LETTER R WITH CARON
(cl-define-keysym #x01f9 "uring") ;U+016F LATIN SMALL LETTER U WITH RING ABOVE
(cl-define-keysym #x01fe "tcedilla") ;U+0163 LATIN SMALL LETTER T WITH CEDILLA
(cl-define-keysym #x01ff "abovedot") ;U+02D9 DOT ABOVE
(cl-define-keysym #x02a1 "Hstroke") ;U+0126 LATIN CAPITAL LETTER H WITH STROKE
(cl-define-keysym #x02a6 "Hcircumflex") ;U+0124 LATIN CAPITAL LETTER H WITH CIRCUMFLEX
(cl-define-keysym #x02a9 "Iabovedot") ;U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE
(cl-define-keysym #x02ab "Gbreve") ;U+011E LATIN CAPITAL LETTER G WITH BREVE
(cl-define-keysym #x02ac "Jcircumflex") ;U+0134 LATIN CAPITAL LETTER J WITH CIRCUMFLEX
(cl-define-keysym #x02b1 "hstroke") ;U+0127 LATIN SMALL LETTER H WITH STROKE
(cl-define-keysym #x02b6 "hcircumflex") ;U+0125 LATIN SMALL LETTER H WITH CIRCUMFLEX
(cl-define-keysym #x02b9 "idotless") ;U+0131 LATIN SMALL LETTER DOTLESS I
(cl-define-keysym #x02bb "gbreve") ;U+011F LATIN SMALL LETTER G WITH BREVE
(cl-define-keysym #x02bc "jcircumflex") ;U+0135 LATIN SMALL LETTER J WITH CIRCUMFLEX
(cl-define-keysym #x02c5 "Cabovedot") ;U+010A LATIN CAPITAL LETTER C WITH DOT ABOVE
(cl-define-keysym #x02c6 "Ccircumflex") ;U+0108 LATIN CAPITAL LETTER C WITH CIRCUMFLEX
(cl-define-keysym #x02d5 "Gabovedot") ;U+0120 LATIN CAPITAL LETTER G WITH DOT ABOVE
(cl-define-keysym #x02d8 "Gcircumflex") ;U+011C LATIN CAPITAL LETTER G WITH CIRCUMFLEX
(cl-define-keysym #x02dd "Ubreve") ;U+016C LATIN CAPITAL LETTER U WITH BREVE
(cl-define-keysym #x02de "Scircumflex") ;U+015C LATIN CAPITAL LETTER S WITH CIRCUMFLEX
(cl-define-keysym #x02e5 "cabovedot") ;U+010B LATIN SMALL LETTER C WITH DOT ABOVE
(cl-define-keysym #x02e6 "ccircumflex") ;U+0109 LATIN SMALL LETTER C WITH CIRCUMFLEX
(cl-define-keysym #x02f5 "gabovedot") ;U+0121 LATIN SMALL LETTER G WITH DOT ABOVE
(cl-define-keysym #x02f8 "gcircumflex") ;U+011D LATIN SMALL LETTER G WITH CIRCUMFLEX
(cl-define-keysym #x02fd "ubreve") ;U+016D LATIN SMALL LETTER U WITH BREVE
(cl-define-keysym #x02fe "scircumflex") ;U+015D LATIN SMALL LETTER S WITH CIRCUMFLEX
(cl-define-keysym #x03a2 "kra") ;U+0138 LATIN SMALL LETTER KRA
(cl-define-keysym #x03a2 "kappa") ;deprecated
(cl-define-keysym #x03a3 "Rcedilla") ;U+0156 LATIN CAPITAL LETTER R WITH CEDILLA
(cl-define-keysym #x03a5 "Itilde") ;U+0128 LATIN CAPITAL LETTER I WITH TILDE
(cl-define-keysym #x03a6 "Lcedilla") ;U+013B LATIN CAPITAL LETTER L WITH CEDILLA
(cl-define-keysym #x03aa "Emacron") ;U+0112 LATIN CAPITAL LETTER E WITH MACRON
(cl-define-keysym #x03ab "Gcedilla") ;U+0122 LATIN CAPITAL LETTER G WITH CEDILLA
(cl-define-keysym #x03ac "Tslash") ;U+0166 LATIN CAPITAL LETTER T WITH STROKE
(cl-define-keysym #x03b3 "rcedilla") ;U+0157 LATIN SMALL LETTER R WITH CEDILLA
(cl-define-keysym #x03b5 "itilde") ;U+0129 LATIN SMALL LETTER I WITH TILDE
(cl-define-keysym #x03b6 "lcedilla") ;U+013C LATIN SMALL LETTER L WITH CEDILLA
(cl-define-keysym #x03ba "emacron") ;U+0113 LATIN SMALL LETTER E WITH MACRON
(cl-define-keysym #x03bb "gcedilla") ;U+0123 LATIN SMALL LETTER G WITH CEDILLA
(cl-define-keysym #x03bc "tslash") ;U+0167 LATIN SMALL LETTER T WITH STROKE
(cl-define-keysym #x03bd "ENG") ;U+014A LATIN CAPITAL LETTER ENG
(cl-define-keysym #x03bf "eng") ;U+014B LATIN SMALL LETTER ENG
(cl-define-keysym #x03c0 "Amacron") ;U+0100 LATIN CAPITAL LETTER A WITH MACRON
(cl-define-keysym #x03c7 "Iogonek") ;U+012E LATIN CAPITAL LETTER I WITH OGONEK
(cl-define-keysym #x03cc "Eabovedot") ;U+0116 LATIN CAPITAL LETTER E WITH DOT ABOVE
(cl-define-keysym #x03cf "Imacron") ;U+012A LATIN CAPITAL LETTER I WITH MACRON
(cl-define-keysym #x03d1 "Ncedilla") ;U+0145 LATIN CAPITAL LETTER N WITH CEDILLA
(cl-define-keysym #x03d2 "Omacron") ;U+014C LATIN CAPITAL LETTER O WITH MACRON
(cl-define-keysym #x03d3 "Kcedilla") ;U+0136 LATIN CAPITAL LETTER K WITH CEDILLA
(cl-define-keysym #x03d9 "Uogonek") ;U+0172 LATIN CAPITAL LETTER U WITH OGONEK
(cl-define-keysym #x03dd "Utilde") ;U+0168 LATIN CAPITAL LETTER U WITH TILDE
(cl-define-keysym #x03de "Umacron") ;U+016A LATIN CAPITAL LETTER U WITH MACRON
(cl-define-keysym #x03e0 "amacron") ;U+0101 LATIN SMALL LETTER A WITH MACRON
(cl-define-keysym #x03e7 "iogonek") ;U+012F LATIN SMALL LETTER I WITH OGONEK
(cl-define-keysym #x03ec "eabovedot") ;U+0117 LATIN SMALL LETTER E WITH DOT ABOVE
(cl-define-keysym #x03ef "imacron") ;U+012B LATIN SMALL LETTER I WITH MACRON
(cl-define-keysym #x03f1 "ncedilla") ;U+0146 LATIN SMALL LETTER N WITH CEDILLA
(cl-define-keysym #x03f2 "omacron") ;U+014D LATIN SMALL LETTER O WITH MACRON
(cl-define-keysym #x03f3 "kcedilla") ;U+0137 LATIN SMALL LETTER K WITH CEDILLA
(cl-define-keysym #x03f9 "uogonek") ;U+0173 LATIN SMALL LETTER U WITH OGONEK
(cl-define-keysym #x03fd "utilde") ;U+0169 LATIN SMALL LETTER U WITH TILDE
(cl-define-keysym #x03fe "umacron") ;U+016B LATIN SMALL LETTER U WITH MACRON
(cl-define-keysym #x1001e02 "Babovedot") ;U+1E02 LATIN CAPITAL LETTER B WITH DOT ABOVE
(cl-define-keysym #x1001e03 "babovedot") ;U+1E03 LATIN SMALL LETTER B WITH DOT ABOVE
(cl-define-keysym #x1001e0a "Dabovedot") ;U+1E0A LATIN CAPITAL LETTER D WITH DOT ABOVE
(cl-define-keysym #x1001e80 "Wgrave") ;U+1E80 LATIN CAPITAL LETTER W WITH GRAVE
(cl-define-keysym #x1001e82 "Wacute") ;U+1E82 LATIN CAPITAL LETTER W WITH ACUTE
(cl-define-keysym #x1001e0b "dabovedot") ;U+1E0B LATIN SMALL LETTER D WITH DOT ABOVE
(cl-define-keysym #x1001ef2 "Ygrave") ;U+1EF2 LATIN CAPITAL LETTER Y WITH GRAVE
(cl-define-keysym #x1001e1e "Fabovedot") ;U+1E1E LATIN CAPITAL LETTER F WITH DOT ABOVE
(cl-define-keysym #x1001e1f "fabovedot") ;U+1E1F LATIN SMALL LETTER F WITH DOT ABOVE
(cl-define-keysym #x1001e40 "Mabovedot") ;U+1E40 LATIN CAPITAL LETTER M WITH DOT ABOVE
(cl-define-keysym #x1001e41 "mabovedot") ;U+1E41 LATIN SMALL LETTER M WITH DOT ABOVE
(cl-define-keysym #x1001e56 "Pabovedot") ;U+1E56 LATIN CAPITAL LETTER P WITH DOT ABOVE
(cl-define-keysym #x1001e81 "wgrave") ;U+1E81 LATIN SMALL LETTER W WITH GRAVE
(cl-define-keysym #x1001e57 "pabovedot") ;U+1E57 LATIN SMALL LETTER P WITH DOT ABOVE
(cl-define-keysym #x1001e83 "wacute") ;U+1E83 LATIN SMALL LETTER W WITH ACUTE
(cl-define-keysym #x1001e60 "Sabovedot") ;U+1E60 LATIN CAPITAL LETTER S WITH DOT ABOVE
(cl-define-keysym #x1001ef3 "ygrave") ;U+1EF3 LATIN SMALL LETTER Y WITH GRAVE
(cl-define-keysym #x1001e84 "Wdiaeresis") ;U+1E84 LATIN CAPITAL LETTER W WITH DIAERESIS
(cl-define-keysym #x1001e85 "wdiaeresis") ;U+1E85 LATIN SMALL LETTER W WITH DIAERESIS
(cl-define-keysym #x1001e61 "sabovedot") ;U+1E61 LATIN SMALL LETTER S WITH DOT ABOVE
(cl-define-keysym #x1000174 "Wcircumflex") ;U+0174 LATIN CAPITAL LETTER W WITH CIRCUMFLEX
(cl-define-keysym #x1001e6a "Tabovedot") ;U+1E6A LATIN CAPITAL LETTER T WITH DOT ABOVE
(cl-define-keysym #x1000176 "Ycircumflex") ;U+0176 LATIN CAPITAL LETTER Y WITH CIRCUMFLEX
(cl-define-keysym #x1000175 "wcircumflex") ;U+0175 LATIN SMALL LETTER W WITH CIRCUMFLEX
(cl-define-keysym #x1001e6b "tabovedot") ;U+1E6B LATIN SMALL LETTER T WITH DOT ABOVE
(cl-define-keysym #x1000177 "ycircumflex") ;U+0177 LATIN SMALL LETTER Y WITH CIRCUMFLEX
(cl-define-keysym #x13bc "OE") ;U+0152 LATIN CAPITAL LIGATURE OE
(cl-define-keysym #x13bd "oe") ;U+0153 LATIN SMALL LIGATURE OE
(cl-define-keysym #x13be "Ydiaeresis") ;U+0178 LATIN CAPITAL LETTER Y WITH DIAERESIS
(cl-define-keysym #x047e "overline") ;U+203E OVERLINE
(cl-define-keysym #x04a1 "kana_fullstop") ;U+3002 IDEOGRAPHIC FULL STOP
(cl-define-keysym #x04a2 "kana_openingbracket") ;U+300C LEFT CORNER BRACKET
(cl-define-keysym #x04a3 "kana_closingbracket") ;U+300D RIGHT CORNER BRACKET
(cl-define-keysym #x04a4 "kana_comma") ;U+3001 IDEOGRAPHIC COMMA
(cl-define-keysym #x04a5 "kana_conjunctive") ;U+30FB KATAKANA MIDDLE DOT
(cl-define-keysym #x04a5 "kana_middledot") ;deprecated
(cl-define-keysym #x04a6 "kana_WO") ;U+30F2 KATAKANA LETTER WO
(cl-define-keysym #x04a7 "kana_a") ;U+30A1 KATAKANA LETTER SMALL A
(cl-define-keysym #x04a8 "kana_i") ;U+30A3 KATAKANA LETTER SMALL I
(cl-define-keysym #x04a9 "kana_u") ;U+30A5 KATAKANA LETTER SMALL U
(cl-define-keysym #x04aa "kana_e") ;U+30A7 KATAKANA LETTER SMALL E
(cl-define-keysym #x04ab "kana_o") ;U+30A9 KATAKANA LETTER SMALL O
(cl-define-keysym #x04ac "kana_ya") ;U+30E3 KATAKANA LETTER SMALL YA
(cl-define-keysym #x04ad "kana_yu") ;U+30E5 KATAKANA LETTER SMALL YU
(cl-define-keysym #x04ae "kana_yo") ;U+30E7 KATAKANA LETTER SMALL YO
(cl-define-keysym #x04af "kana_tsu") ;U+30C3 KATAKANA LETTER SMALL TU
(cl-define-keysym #x04af "kana_tu") ;deprecated
(cl-define-keysym #x04b0 "prolongedsound") ;U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK
(cl-define-keysym #x04b1 "kana_A") ;U+30A2 KATAKANA LETTER A
(cl-define-keysym #x04b2 "kana_I") ;U+30A4 KATAKANA LETTER I
(cl-define-keysym #x04b3 "kana_U") ;U+30A6 KATAKANA LETTER U
(cl-define-keysym #x04b4 "kana_E") ;U+30A8 KATAKANA LETTER E
(cl-define-keysym #x04b5 "kana_O") ;U+30AA KATAKANA LETTER O
(cl-define-keysym #x04b6 "kana_KA") ;U+30AB KATAKANA LETTER KA
(cl-define-keysym #x04b7 "kana_KI") ;U+30AD KATAKANA LETTER KI
(cl-define-keysym #x04b8 "kana_KU") ;U+30AF KATAKANA LETTER KU
(cl-define-keysym #x04b9 "kana_KE") ;U+30B1 KATAKANA LETTER KE
(cl-define-keysym #x04ba "kana_KO") ;U+30B3 KATAKANA LETTER KO
(cl-define-keysym #x04bb "kana_SA") ;U+30B5 KATAKANA LETTER SA
(cl-define-keysym #x04bc "kana_SHI") ;U+30B7 KATAKANA LETTER SI
(cl-define-keysym #x04bd "kana_SU") ;U+30B9 KATAKANA LETTER SU
(cl-define-keysym #x04be "kana_SE") ;U+30BB KATAKANA LETTER SE
(cl-define-keysym #x04bf "kana_SO") ;U+30BD KATAKANA LETTER SO
(cl-define-keysym #x04c0 "kana_TA") ;U+30BF KATAKANA LETTER TA
(cl-define-keysym #x04c1 "kana_CHI") ;U+30C1 KATAKANA LETTER TI
(cl-define-keysym #x04c1 "kana_TI") ;deprecated
(cl-define-keysym #x04c2 "kana_TSU") ;U+30C4 KATAKANA LETTER TU
(cl-define-keysym #x04c2 "kana_TU") ;deprecated
(cl-define-keysym #x04c3 "kana_TE") ;U+30C6 KATAKANA LETTER TE
(cl-define-keysym #x04c4 "kana_TO") ;U+30C8 KATAKANA LETTER TO
(cl-define-keysym #x04c5 "kana_NA") ;U+30CA KATAKANA LETTER NA
(cl-define-keysym #x04c6 "kana_NI") ;U+30CB KATAKANA LETTER NI
(cl-define-keysym #x04c7 "kana_NU") ;U+30CC KATAKANA LETTER NU
(cl-define-keysym #x04c8 "kana_NE") ;U+30CD KATAKANA LETTER NE
(cl-define-keysym #x04c9 "kana_NO") ;U+30CE KATAKANA LETTER NO
(cl-define-keysym #x04ca "kana_HA") ;U+30CF KATAKANA LETTER HA
(cl-define-keysym #x04cb "kana_HI") ;U+30D2 KATAKANA LETTER HI
(cl-define-keysym #x04cc "kana_FU") ;U+30D5 KATAKANA LETTER HU
(cl-define-keysym #x04cc "kana_HU") ;deprecated
(cl-define-keysym #x04cd "kana_HE") ;U+30D8 KATAKANA LETTER HE
(cl-define-keysym #x04ce "kana_HO") ;U+30DB KATAKANA LETTER HO
(cl-define-keysym #x04cf "kana_MA") ;U+30DE KATAKANA LETTER MA
(cl-define-keysym #x04d0 "kana_MI") ;U+30DF KATAKANA LETTER MI
(cl-define-keysym #x04d1 "kana_MU") ;U+30E0 KATAKANA LETTER MU
(cl-define-keysym #x04d2 "kana_ME") ;U+30E1 KATAKANA LETTER ME
(cl-define-keysym #x04d3 "kana_MO") ;U+30E2 KATAKANA LETTER MO
(cl-define-keysym #x04d4 "kana_YA") ;U+30E4 KATAKANA LETTER YA
(cl-define-keysym #x04d5 "kana_YU") ;U+30E6 KATAKANA LETTER YU
(cl-define-keysym #x04d6 "kana_YO") ;U+30E8 KATAKANA LETTER YO
(cl-define-keysym #x04d7 "kana_RA") ;U+30E9 KATAKANA LETTER RA
(cl-define-keysym #x04d8 "kana_RI") ;U+30EA KATAKANA LETTER RI
(cl-define-keysym #x04d9 "kana_RU") ;U+30EB KATAKANA LETTER RU
(cl-define-keysym #x04da "kana_RE") ;U+30EC KATAKANA LETTER RE
(cl-define-keysym #x04db "kana_RO") ;U+30ED KATAKANA LETTER RO
(cl-define-keysym #x04dc "kana_WA") ;U+30EF KATAKANA LETTER WA
(cl-define-keysym #x04dd "kana_N") ;U+30F3 KATAKANA LETTER N
(cl-define-keysym #x04de "voicedsound") ;U+309B KATAKANA-HIRAGANA VOICED SOUND MARK
(cl-define-keysym #x04df "semivoicedsound") ;U+309C KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
(cl-define-keysym #xff7e "kana_switch") ;Alias for mode_switch
(cl-define-keysym #x10006f0 "Farsi_0") ;U+06F0 EXTENDED ARABIC-INDIC DIGIT ZERO
(cl-define-keysym #x10006f1 "Farsi_1") ;U+06F1 EXTENDED ARABIC-INDIC DIGIT ONE
(cl-define-keysym #x10006f2 "Farsi_2") ;U+06F2 EXTENDED ARABIC-INDIC DIGIT TWO
(cl-define-keysym #x10006f3 "Farsi_3") ;U+06F3 EXTENDED ARABIC-INDIC DIGIT THREE
(cl-define-keysym #x10006f4 "Farsi_4") ;U+06F4 EXTENDED ARABIC-INDIC DIGIT FOUR
(cl-define-keysym #x10006f5 "Farsi_5") ;U+06F5 EXTENDED ARABIC-INDIC DIGIT FIVE
(cl-define-keysym #x10006f6 "Farsi_6") ;U+06F6 EXTENDED ARABIC-INDIC DIGIT SIX
(cl-define-keysym #x10006f7 "Farsi_7") ;U+06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN
(cl-define-keysym #x10006f8 "Farsi_8") ;U+06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT
(cl-define-keysym #x10006f9 "Farsi_9") ;U+06F9 EXTENDED ARABIC-INDIC DIGIT NINE
(cl-define-keysym #x100066a "Arabic_percent") ;U+066A ARABIC PERCENT SIGN
(cl-define-keysym #x1000670 "Arabic_superscript_alef") ;U+0670 ARABIC LETTER SUPERSCRIPT ALEF
(cl-define-keysym #x1000679 "Arabic_tteh") ;U+0679 ARABIC LETTER TTEH
(cl-define-keysym #x100067e "Arabic_peh") ;U+067E ARABIC LETTER PEH
(cl-define-keysym #x1000686 "Arabic_tcheh") ;U+0686 ARABIC LETTER TCHEH
(cl-define-keysym #x1000688 "Arabic_ddal") ;U+0688 ARABIC LETTER DDAL
(cl-define-keysym #x1000691 "Arabic_rreh") ;U+0691 ARABIC LETTER RREH
(cl-define-keysym #x05ac "Arabic_comma") ;U+060C ARABIC COMMA
(cl-define-keysym #x10006d4 "Arabic_fullstop") ;U+06D4 ARABIC FULL STOP
(cl-define-keysym #x1000660 "Arabic_0") ;U+0660 ARABIC-INDIC DIGIT ZERO
(cl-define-keysym #x1000661 "Arabic_1") ;U+0661 ARABIC-INDIC DIGIT ONE
(cl-define-keysym #x1000662 "Arabic_2") ;U+0662 ARABIC-INDIC DIGIT TWO
(cl-define-keysym #x1000663 "Arabic_3") ;U+0663 ARABIC-INDIC DIGIT THREE
(cl-define-keysym #x1000664 "Arabic_4") ;U+0664 ARABIC-INDIC DIGIT FOUR
(cl-define-keysym #x1000665 "Arabic_5") ;U+0665 ARABIC-INDIC DIGIT FIVE
(cl-define-keysym #x1000666 "Arabic_6") ;U+0666 ARABIC-INDIC DIGIT SIX
(cl-define-keysym #x1000667 "Arabic_7") ;U+0667 ARABIC-INDIC DIGIT SEVEN
(cl-define-keysym #x1000668 "Arabic_8") ;U+0668 ARABIC-INDIC DIGIT EIGHT
(cl-define-keysym #x1000669 "Arabic_9") ;U+0669 ARABIC-INDIC DIGIT NINE
(cl-define-keysym #x05bb "Arabic_semicolon") ;U+061B ARABIC SEMICOLON
(cl-define-keysym #x05bf "Arabic_question_mark") ;U+061F ARABIC QUESTION MARK
(cl-define-keysym #x05c1 "Arabic_hamza") ;U+0621 ARABIC LETTER HAMZA
(cl-define-keysym #x05c2 "Arabic_maddaonalef") ;U+0622 ARABIC LETTER ALEF WITH MADDA ABOVE
(cl-define-keysym #x05c3 "Arabic_hamzaonalef") ;U+0623 ARABIC LETTER ALEF WITH HAMZA ABOVE
(cl-define-keysym #x05c4 "Arabic_hamzaonwaw") ;U+0624 ARABIC LETTER WAW WITH HAMZA ABOVE
(cl-define-keysym #x05c5 "Arabic_hamzaunderalef") ;U+0625 ARABIC LETTER ALEF WITH HAMZA BELOW
(cl-define-keysym #x05c6 "Arabic_hamzaonyeh") ;U+0626 ARABIC LETTER YEH WITH HAMZA ABOVE
(cl-define-keysym #x05c7 "Arabic_alef") ;U+0627 ARABIC LETTER ALEF
(cl-define-keysym #x05c8 "Arabic_beh") ;U+0628 ARABIC LETTER BEH
(cl-define-keysym #x05c9 "Arabic_tehmarbuta") ;U+0629 ARABIC LETTER TEH MARBUTA
(cl-define-keysym #x05ca "Arabic_teh") ;U+062A ARABIC LETTER TEH
(cl-define-keysym #x05cb "Arabic_theh") ;U+062B ARABIC LETTER THEH
(cl-define-keysym #x05cc "Arabic_jeem") ;U+062C ARABIC LETTER JEEM
(cl-define-keysym #x05cd "Arabic_hah") ;U+062D ARABIC LETTER HAH
(cl-define-keysym #x05ce "Arabic_khah") ;U+062E ARABIC LETTER KHAH
(cl-define-keysym #x05cf "Arabic_dal") ;U+062F ARABIC LETTER DAL
(cl-define-keysym #x05d0 "Arabic_thal") ;U+0630 ARABIC LETTER THAL
(cl-define-keysym #x05d1 "Arabic_ra") ;U+0631 ARABIC LETTER REH
(cl-define-keysym #x05d2 "Arabic_zain") ;U+0632 ARABIC LETTER ZAIN
(cl-define-keysym #x05d3 "Arabic_seen") ;U+0633 ARABIC LETTER SEEN
(cl-define-keysym #x05d4 "Arabic_sheen") ;U+0634 ARABIC LETTER SHEEN
(cl-define-keysym #x05d5 "Arabic_sad") ;U+0635 ARABIC LETTER SAD
(cl-define-keysym #x05d6 "Arabic_dad") ;U+0636 ARABIC LETTER DAD
(cl-define-keysym #x05d7 "Arabic_tah") ;U+0637 ARABIC LETTER TAH
(cl-define-keysym #x05d8 "Arabic_zah") ;U+0638 ARABIC LETTER ZAH
(cl-define-keysym #x05d9 "Arabic_ain") ;U+0639 ARABIC LETTER AIN
(cl-define-keysym #x05da "Arabic_ghain") ;U+063A ARABIC LETTER GHAIN
(cl-define-keysym #x05e0 "Arabic_tatweel") ;U+0640 ARABIC TATWEEL
(cl-define-keysym #x05e1 "Arabic_feh") ;U+0641 ARABIC LETTER FEH
(cl-define-keysym #x05e2 "Arabic_qaf") ;U+0642 ARABIC LETTER QAF
(cl-define-keysym #x05e3 "Arabic_kaf") ;U+0643 ARABIC LETTER KAF
(cl-define-keysym #x05e4 "Arabic_lam") ;U+0644 ARABIC LETTER LAM
(cl-define-keysym #x05e5 "Arabic_meem") ;U+0645 ARABIC LETTER MEEM
(cl-define-keysym #x05e6 "Arabic_noon") ;U+0646 ARABIC LETTER NOON
(cl-define-keysym #x05e7 "Arabic_ha") ;U+0647 ARABIC LETTER HEH
(cl-define-keysym #x05e7 "Arabic_heh") ;deprecated
(cl-define-keysym #x05e8 "Arabic_waw") ;U+0648 ARABIC LETTER WAW
(cl-define-keysym #x05e9 "Arabic_alefmaksura") ;U+0649 ARABIC LETTER ALEF MAKSURA
(cl-define-keysym #x05ea "Arabic_yeh") ;U+064A ARABIC LETTER YEH
(cl-define-keysym #x05eb "Arabic_fathatan") ;U+064B ARABIC FATHATAN
(cl-define-keysym #x05ec "Arabic_dammatan") ;U+064C ARABIC DAMMATAN
(cl-define-keysym #x05ed "Arabic_kasratan") ;U+064D ARABIC KASRATAN
(cl-define-keysym #x05ee "Arabic_fatha") ;U+064E ARABIC FATHA
(cl-define-keysym #x05ef "Arabic_damma") ;U+064F ARABIC DAMMA
(cl-define-keysym #x05f0 "Arabic_kasra") ;U+0650 ARABIC KASRA
(cl-define-keysym #x05f1 "Arabic_shadda") ;U+0651 ARABIC SHADDA
(cl-define-keysym #x05f2 "Arabic_sukun") ;U+0652 ARABIC SUKUN
(cl-define-keysym #x1000653 "Arabic_madda_above") ;U+0653 ARABIC MADDAH ABOVE
(cl-define-keysym #x1000654 "Arabic_hamza_above") ;U+0654 ARABIC HAMZA ABOVE
(cl-define-keysym #x1000655 "Arabic_hamza_below") ;U+0655 ARABIC HAMZA BELOW
(cl-define-keysym #x1000698 "Arabic_jeh") ;U+0698 ARABIC LETTER JEH
(cl-define-keysym #x10006a4 "Arabic_veh") ;U+06A4 ARABIC LETTER VEH
(cl-define-keysym #x10006a9 "Arabic_keheh") ;U+06A9 ARABIC LETTER KEHEH
(cl-define-keysym #x10006af "Arabic_gaf") ;U+06AF ARABIC LETTER GAF
(cl-define-keysym #x10006ba "Arabic_noon_ghunna") ;U+06BA ARABIC LETTER NOON GHUNNA
(cl-define-keysym #x10006be "Arabic_heh_doachashmee") ;U+06BE ARABIC LETTER HEH DOACHASHMEE
(cl-define-keysym #x10006cc "Farsi_yeh") ;U+06CC ARABIC LETTER FARSI YEH
(cl-define-keysym #x10006cc "Arabic_farsi_yeh") ;U+06CC ARABIC LETTER FARSI YEH
(cl-define-keysym #x10006d2 "Arabic_yeh_baree") ;U+06D2 ARABIC LETTER YEH BARREE
(cl-define-keysym #x10006c1 "Arabic_heh_goal") ;U+06C1 ARABIC LETTER HEH GOAL
(cl-define-keysym #xff7e "Arabic_switch") ;Alias for mode_switch
(cl-define-keysym #x1000492 "Cyrillic_GHE_bar") ;U+0492 CYRILLIC CAPITAL LETTER GHE WITH STROKE
(cl-define-keysym #x1000493 "Cyrillic_ghe_bar") ;U+0493 CYRILLIC SMALL LETTER GHE WITH STROKE
(cl-define-keysym #x1000496 "Cyrillic_ZHE_descender") ;U+0496 CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER
(cl-define-keysym #x1000497 "Cyrillic_zhe_descender") ;U+0497 CYRILLIC SMALL LETTER ZHE WITH DESCENDER
(cl-define-keysym #x100049a "Cyrillic_KA_descender") ;U+049A CYRILLIC CAPITAL LETTER KA WITH DESCENDER
(cl-define-keysym #x100049b "Cyrillic_ka_descender") ;U+049B CYRILLIC SMALL LETTER KA WITH DESCENDER
(cl-define-keysym #x100049c "Cyrillic_KA_vertstroke") ;U+049C CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE
(cl-define-keysym #x100049d "Cyrillic_ka_vertstroke") ;U+049D CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE
(cl-define-keysym #x10004a2 "Cyrillic_EN_descender") ;U+04A2 CYRILLIC CAPITAL LETTER EN WITH DESCENDER
(cl-define-keysym #x10004a3 "Cyrillic_en_descender") ;U+04A3 CYRILLIC SMALL LETTER EN WITH DESCENDER
(cl-define-keysym #x10004ae "Cyrillic_U_straight") ;U+04AE CYRILLIC CAPITAL LETTER STRAIGHT U
(cl-define-keysym #x10004af "Cyrillic_u_straight") ;U+04AF CYRILLIC SMALL LETTER STRAIGHT U
(cl-define-keysym #x10004b0 "Cyrillic_U_straight_bar") ;U+04B0 CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE
(cl-define-keysym #x10004b1 "Cyrillic_u_straight_bar") ;U+04B1 CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE
(cl-define-keysym #x10004b2 "Cyrillic_HA_descender") ;U+04B2 CYRILLIC CAPITAL LETTER HA WITH DESCENDER
(cl-define-keysym #x10004b3 "Cyrillic_ha_descender") ;U+04B3 CYRILLIC SMALL LETTER HA WITH DESCENDER
(cl-define-keysym #x10004b6 "Cyrillic_CHE_descender") ;U+04B6 CYRILLIC CAPITAL LETTER CHE WITH DESCENDER
(cl-define-keysym #x10004b7 "Cyrillic_che_descender") ;U+04B7 CYRILLIC SMALL LETTER CHE WITH DESCENDER
(cl-define-keysym #x10004b8 "Cyrillic_CHE_vertstroke") ;U+04B8 CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE
(cl-define-keysym #x10004b9 "Cyrillic_che_vertstroke") ;U+04B9 CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE
(cl-define-keysym #x10004ba "Cyrillic_SHHA") ;U+04BA CYRILLIC CAPITAL LETTER SHHA
(cl-define-keysym #x10004bb "Cyrillic_shha") ;U+04BB CYRILLIC SMALL LETTER SHHA
(cl-define-keysym #x10004d8 "Cyrillic_SCHWA") ;U+04D8 CYRILLIC CAPITAL LETTER SCHWA
(cl-define-keysym #x10004d9 "Cyrillic_schwa") ;U+04D9 CYRILLIC SMALL LETTER SCHWA
(cl-define-keysym #x10004e2 "Cyrillic_I_macron") ;U+04E2 CYRILLIC CAPITAL LETTER I WITH MACRON
(cl-define-keysym #x10004e3 "Cyrillic_i_macron") ;U+04E3 CYRILLIC SMALL LETTER I WITH MACRON
(cl-define-keysym #x10004e8 "Cyrillic_O_bar") ;U+04E8 CYRILLIC CAPITAL LETTER BARRED O
(cl-define-keysym #x10004e9 "Cyrillic_o_bar") ;U+04E9 CYRILLIC SMALL LETTER BARRED O
(cl-define-keysym #x10004ee "Cyrillic_U_macron") ;U+04EE CYRILLIC CAPITAL LETTER U WITH MACRON
(cl-define-keysym #x10004ef "Cyrillic_u_macron") ;U+04EF CYRILLIC SMALL LETTER U WITH MACRON
(cl-define-keysym #x06a1 "Serbian_dje") ;U+0452 CYRILLIC SMALL LETTER DJE
(cl-define-keysym #x06a2 "Macedonia_gje") ;U+0453 CYRILLIC SMALL LETTER GJE
(cl-define-keysym #x06a3 "Cyrillic_io") ;U+0451 CYRILLIC SMALL LETTER IO
(cl-define-keysym #x06a4 "Ukrainian_ie") ;U+0454 CYRILLIC SMALL LETTER UKRAINIAN IE
(cl-define-keysym #x06a4 "Ukranian_je") ;deprecated
(cl-define-keysym #x06a5 "Macedonia_dse") ;U+0455 CYRILLIC SMALL LETTER DZE
(cl-define-keysym #x06a6 "Ukrainian_i") ;U+0456 CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
(cl-define-keysym #x06a6 "Ukranian_i") ;deprecated
(cl-define-keysym #x06a7 "Ukrainian_yi") ;U+0457 CYRILLIC SMALL LETTER YI
(cl-define-keysym #x06a7 "Ukranian_yi") ;deprecated
(cl-define-keysym #x06a8 "Cyrillic_je") ;U+0458 CYRILLIC SMALL LETTER JE
(cl-define-keysym #x06a8 "Serbian_je") ;deprecated
(cl-define-keysym #x06a9 "Cyrillic_lje") ;U+0459 CYRILLIC SMALL LETTER LJE
(cl-define-keysym #x06a9 "Serbian_lje") ;deprecated
(cl-define-keysym #x06aa "Cyrillic_nje") ;U+045A CYRILLIC SMALL LETTER NJE
(cl-define-keysym #x06aa "Serbian_nje") ;deprecated
(cl-define-keysym #x06ab "Serbian_tshe") ;U+045B CYRILLIC SMALL LETTER TSHE
(cl-define-keysym #x06ac "Macedonia_kje") ;U+045C CYRILLIC SMALL LETTER KJE
(cl-define-keysym #x06ad "Ukrainian_ghe_with_upturn") ;U+0491 CYRILLIC SMALL LETTER GHE WITH UPTURN
(cl-define-keysym #x06ae "Byelorussian_shortu") ;U+045E CYRILLIC SMALL LETTER SHORT U
(cl-define-keysym #x06af "Cyrillic_dzhe") ;U+045F CYRILLIC SMALL LETTER DZHE
(cl-define-keysym #x06af "Serbian_dze") ;deprecated
(cl-define-keysym #x06b0 "numerosign") ;U+2116 NUMERO SIGN
(cl-define-keysym #x06b1 "Serbian_DJE") ;U+0402 CYRILLIC CAPITAL LETTER DJE
(cl-define-keysym #x06b2 "Macedonia_GJE") ;U+0403 CYRILLIC CAPITAL LETTER GJE
(cl-define-keysym #x06b3 "Cyrillic_IO") ;U+0401 CYRILLIC CAPITAL LETTER IO
(cl-define-keysym #x06b4 "Ukrainian_IE") ;U+0404 CYRILLIC CAPITAL LETTER UKRAINIAN IE
(cl-define-keysym #x06b4 "Ukranian_JE") ;deprecated
(cl-define-keysym #x06b5 "Macedonia_DSE") ;U+0405 CYRILLIC CAPITAL LETTER DZE
(cl-define-keysym #x06b6 "Ukrainian_I") ;U+0406 CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
(cl-define-keysym #x06b6 "Ukranian_I") ;deprecated
(cl-define-keysym #x06b7 "Ukrainian_YI") ;U+0407 CYRILLIC CAPITAL LETTER YI
(cl-define-keysym #x06b7 "Ukranian_YI") ;deprecated
(cl-define-keysym #x06b8 "Cyrillic_JE") ;U+0408 CYRILLIC CAPITAL LETTER JE
(cl-define-keysym #x06b8 "Serbian_JE") ;deprecated
(cl-define-keysym #x06b9 "Cyrillic_LJE") ;U+0409 CYRILLIC CAPITAL LETTER LJE
(cl-define-keysym #x06b9 "Serbian_LJE") ;deprecated
(cl-define-keysym #x06ba "Cyrillic_NJE") ;U+040A CYRILLIC CAPITAL LETTER NJE
(cl-define-keysym #x06ba "Serbian_NJE") ;deprecated
(cl-define-keysym #x06bb "Serbian_TSHE") ;U+040B CYRILLIC CAPITAL LETTER TSHE
(cl-define-keysym #x06bc "Macedonia_KJE") ;U+040C CYRILLIC CAPITAL LETTER KJE
(cl-define-keysym #x06bd "Ukrainian_GHE_WITH_UPTURN") ;U+0490 CYRILLIC CAPITAL LETTER GHE WITH UPTURN
(cl-define-keysym #x06be "Byelorussian_SHORTU") ;U+040E CYRILLIC CAPITAL LETTER SHORT U
(cl-define-keysym #x06bf "Cyrillic_DZHE") ;U+040F CYRILLIC CAPITAL LETTER DZHE
(cl-define-keysym #x06bf "Serbian_DZE") ;deprecated
(cl-define-keysym #x06c0 "Cyrillic_yu") ;U+044E CYRILLIC SMALL LETTER YU
(cl-define-keysym #x06c1 "Cyrillic_a") ;U+0430 CYRILLIC SMALL LETTER A
(cl-define-keysym #x06c2 "Cyrillic_be") ;U+0431 CYRILLIC SMALL LETTER BE
(cl-define-keysym #x06c3 "Cyrillic_tse") ;U+0446 CYRILLIC SMALL LETTER TSE
(cl-define-keysym #x06c4 "Cyrillic_de") ;U+0434 CYRILLIC SMALL LETTER DE
(cl-define-keysym #x06c5 "Cyrillic_ie") ;U+0435 CYRILLIC SMALL LETTER IE
(cl-define-keysym #x06c6 "Cyrillic_ef") ;U+0444 CYRILLIC SMALL LETTER EF
(cl-define-keysym #x06c7 "Cyrillic_ghe") ;U+0433 CYRILLIC SMALL LETTER GHE
(cl-define-keysym #x06c8 "Cyrillic_ha") ;U+0445 CYRILLIC SMALL LETTER HA
(cl-define-keysym #x06c9 "Cyrillic_i") ;U+0438 CYRILLIC SMALL LETTER I
(cl-define-keysym #x06ca "Cyrillic_shorti") ;U+0439 CYRILLIC SMALL LETTER SHORT I
(cl-define-keysym #x06cb "Cyrillic_ka") ;U+043A CYRILLIC SMALL LETTER KA
(cl-define-keysym #x06cc "Cyrillic_el") ;U+043B CYRILLIC SMALL LETTER EL
(cl-define-keysym #x06cd "Cyrillic_em") ;U+043C CYRILLIC SMALL LETTER EM
(cl-define-keysym #x06ce "Cyrillic_en") ;U+043D CYRILLIC SMALL LETTER EN
(cl-define-keysym #x06cf "Cyrillic_o") ;U+043E CYRILLIC SMALL LETTER O
(cl-define-keysym #x06d0 "Cyrillic_pe") ;U+043F CYRILLIC SMALL LETTER PE
(cl-define-keysym #x06d1 "Cyrillic_ya") ;U+044F CYRILLIC SMALL LETTER YA
(cl-define-keysym #x06d2 "Cyrillic_er") ;U+0440 CYRILLIC SMALL LETTER ER
(cl-define-keysym #x06d3 "Cyrillic_es") ;U+0441 CYRILLIC SMALL LETTER ES
(cl-define-keysym #x06d4 "Cyrillic_te") ;U+0442 CYRILLIC SMALL LETTER TE
(cl-define-keysym #x06d5 "Cyrillic_u") ;U+0443 CYRILLIC SMALL LETTER U
(cl-define-keysym #x06d6 "Cyrillic_zhe") ;U+0436 CYRILLIC SMALL LETTER ZHE
(cl-define-keysym #x06d7 "Cyrillic_ve") ;U+0432 CYRILLIC SMALL LETTER VE
(cl-define-keysym #x06d8 "Cyrillic_softsign") ;U+044C CYRILLIC SMALL LETTER SOFT SIGN
(cl-define-keysym #x06d9 "Cyrillic_yeru") ;U+044B CYRILLIC SMALL LETTER YERU
(cl-define-keysym #x06da "Cyrillic_ze") ;U+0437 CYRILLIC SMALL LETTER ZE
(cl-define-keysym #x06db "Cyrillic_sha") ;U+0448 CYRILLIC SMALL LETTER SHA
(cl-define-keysym #x06dc "Cyrillic_e") ;U+044D CYRILLIC SMALL LETTER E
(cl-define-keysym #x06dd "Cyrillic_shcha") ;U+0449 CYRILLIC SMALL LETTER SHCHA
(cl-define-keysym #x06de "Cyrillic_che") ;U+0447 CYRILLIC SMALL LETTER CHE
(cl-define-keysym #x06df "Cyrillic_hardsign") ;U+044A CYRILLIC SMALL LETTER HARD SIGN
(cl-define-keysym #x06e0 "Cyrillic_YU") ;U+042E CYRILLIC CAPITAL LETTER YU
(cl-define-keysym #x06e1 "Cyrillic_A") ;U+0410 CYRILLIC CAPITAL LETTER A
(cl-define-keysym #x06e2 "Cyrillic_BE") ;U+0411 CYRILLIC CAPITAL LETTER BE
(cl-define-keysym #x06e3 "Cyrillic_TSE") ;U+0426 CYRILLIC CAPITAL LETTER TSE
(cl-define-keysym #x06e4 "Cyrillic_DE") ;U+0414 CYRILLIC CAPITAL LETTER DE
(cl-define-keysym #x06e5 "Cyrillic_IE") ;U+0415 CYRILLIC CAPITAL LETTER IE
(cl-define-keysym #x06e6 "Cyrillic_EF") ;U+0424 CYRILLIC CAPITAL LETTER EF
(cl-define-keysym #x06e7 "Cyrillic_GHE") ;U+0413 CYRILLIC CAPITAL LETTER GHE
(cl-define-keysym #x06e8 "Cyrillic_HA") ;U+0425 CYRILLIC CAPITAL LETTER HA
(cl-define-keysym #x06e9 "Cyrillic_I") ;U+0418 CYRILLIC CAPITAL LETTER I
(cl-define-keysym #x06ea "Cyrillic_SHORTI") ;U+0419 CYRILLIC CAPITAL LETTER SHORT I
(cl-define-keysym #x06eb "Cyrillic_KA") ;U+041A CYRILLIC CAPITAL LETTER KA
(cl-define-keysym #x06ec "Cyrillic_EL") ;U+041B CYRILLIC CAPITAL LETTER EL
(cl-define-keysym #x06ed "Cyrillic_EM") ;U+041C CYRILLIC CAPITAL LETTER EM
(cl-define-keysym #x06ee "Cyrillic_EN") ;U+041D CYRILLIC CAPITAL LETTER EN
(cl-define-keysym #x06ef "Cyrillic_O") ;U+041E CYRILLIC CAPITAL LETTER O
(cl-define-keysym #x06f0 "Cyrillic_PE") ;U+041F CYRILLIC CAPITAL LETTER PE
(cl-define-keysym #x06f1 "Cyrillic_YA") ;U+042F CYRILLIC CAPITAL LETTER YA
(cl-define-keysym #x06f2 "Cyrillic_ER") ;U+0420 CYRILLIC CAPITAL LETTER ER
(cl-define-keysym #x06f3 "Cyrillic_ES") ;U+0421 CYRILLIC CAPITAL LETTER ES
(cl-define-keysym #x06f4 "Cyrillic_TE") ;U+0422 CYRILLIC CAPITAL LETTER TE
(cl-define-keysym #x06f5 "Cyrillic_U") ;U+0423 CYRILLIC CAPITAL LETTER U
(cl-define-keysym #x06f6 "Cyrillic_ZHE") ;U+0416 CYRILLIC CAPITAL LETTER ZHE
(cl-define-keysym #x06f7 "Cyrillic_VE") ;U+0412 CYRILLIC CAPITAL LETTER VE
(cl-define-keysym #x06f8 "Cyrillic_SOFTSIGN") ;U+042C CYRILLIC CAPITAL LETTER SOFT SIGN
(cl-define-keysym #x06f9 "Cyrillic_YERU") ;U+042B CYRILLIC CAPITAL LETTER YERU
(cl-define-keysym #x06fa "Cyrillic_ZE") ;U+0417 CYRILLIC CAPITAL LETTER ZE
(cl-define-keysym #x06fb "Cyrillic_SHA") ;U+0428 CYRILLIC CAPITAL LETTER SHA
(cl-define-keysym #x06fc "Cyrillic_E") ;U+042D CYRILLIC CAPITAL LETTER E
(cl-define-keysym #x06fd "Cyrillic_SHCHA") ;U+0429 CYRILLIC CAPITAL LETTER SHCHA
(cl-define-keysym #x06fe "Cyrillic_CHE") ;U+0427 CYRILLIC CAPITAL LETTER CHE
(cl-define-keysym #x06ff "Cyrillic_HARDSIGN") ;U+042A CYRILLIC CAPITAL LETTER HARD SIGN
(cl-define-keysym #x07a1 "Greek_ALPHAaccent") ;U+0386 GREEK CAPITAL LETTER ALPHA WITH TONOS
(cl-define-keysym #x07a2 "Greek_EPSILONaccent") ;U+0388 GREEK CAPITAL LETTER EPSILON WITH TONOS
(cl-define-keysym #x07a3 "Greek_ETAaccent") ;U+0389 GREEK CAPITAL LETTER ETA WITH TONOS
(cl-define-keysym #x07a4 "Greek_IOTAaccent") ;U+038A GREEK CAPITAL LETTER IOTA WITH TONOS
(cl-define-keysym #x07a5 "Greek_IOTAdieresis") ;U+03AA GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
(cl-define-keysym #x07a5 "Greek_IOTAdiaeresis") ;old typo
(cl-define-keysym #x07a7 "Greek_OMICRONaccent") ;U+038C GREEK CAPITAL LETTER OMICRON WITH TONOS
(cl-define-keysym #x07a8 "Greek_UPSILONaccent") ;U+038E GREEK CAPITAL LETTER UPSILON WITH TONOS
(cl-define-keysym #x07a9 "Greek_UPSILONdieresis") ;U+03AB GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
(cl-define-keysym #x07ab "Greek_OMEGAaccent") ;U+038F GREEK CAPITAL LETTER OMEGA WITH TONOS
(cl-define-keysym #x07ae "Greek_accentdieresis") ;U+0385 GREEK DIALYTIKA TONOS
(cl-define-keysym #x07af "Greek_horizbar") ;U+2015 HORIZONTAL BAR
(cl-define-keysym #x07b1 "Greek_alphaaccent") ;U+03AC GREEK SMALL LETTER ALPHA WITH TONOS
(cl-define-keysym #x07b2 "Greek_epsilonaccent") ;U+03AD GREEK SMALL LETTER EPSILON WITH TONOS
(cl-define-keysym #x07b3 "Greek_etaaccent") ;U+03AE GREEK SMALL LETTER ETA WITH TONOS
(cl-define-keysym #x07b4 "Greek_iotaaccent") ;U+03AF GREEK SMALL LETTER IOTA WITH TONOS
(cl-define-keysym #x07b5 "Greek_iotadieresis") ;U+03CA GREEK SMALL LETTER IOTA WITH DIALYTIKA
(cl-define-keysym #x07b6 "Greek_iotaaccentdieresis") ;U+0390 GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
(cl-define-keysym #x07b7 "Greek_omicronaccent") ;U+03CC GREEK SMALL LETTER OMICRON WITH TONOS
(cl-define-keysym #x07b8 "Greek_upsilonaccent") ;U+03CD GREEK SMALL LETTER UPSILON WITH TONOS
(cl-define-keysym #x07b9 "Greek_upsilondieresis") ;U+03CB GREEK SMALL LETTER UPSILON WITH DIALYTIKA
(cl-define-keysym #x07ba "Greek_upsilonaccentdieresis") ;U+03B0 GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
(cl-define-keysym #x07bb "Greek_omegaaccent") ;U+03CE GREEK SMALL LETTER OMEGA WITH TONOS
(cl-define-keysym #x07c1 "Greek_ALPHA") ;U+0391 GREEK CAPITAL LETTER ALPHA
(cl-define-keysym #x07c2 "Greek_BETA") ;U+0392 GREEK CAPITAL LETTER BETA
(cl-define-keysym #x07c3 "Greek_GAMMA") ;U+0393 GREEK CAPITAL LETTER GAMMA
(cl-define-keysym #x07c4 "Greek_DELTA") ;U+0394 GREEK CAPITAL LETTER DELTA
(cl-define-keysym #x07c5 "Greek_EPSILON") ;U+0395 GREEK CAPITAL LETTER EPSILON
(cl-define-keysym #x07c6 "Greek_ZETA") ;U+0396 GREEK CAPITAL LETTER ZETA
(cl-define-keysym #x07c7 "Greek_ETA") ;U+0397 GREEK CAPITAL LETTER ETA
(cl-define-keysym #x07c8 "Greek_THETA") ;U+0398 GREEK CAPITAL LETTER THETA
(cl-define-keysym #x07c9 "Greek_IOTA") ;U+0399 GREEK CAPITAL LETTER IOTA
(cl-define-keysym #x07ca "Greek_KAPPA") ;U+039A GREEK CAPITAL LETTER KAPPA
(cl-define-keysym #x07cb "Greek_LAMDA") ;U+039B GREEK CAPITAL LETTER LAMDA
(cl-define-keysym #x07cb "Greek_LAMBDA") ;U+039B GREEK CAPITAL LETTER LAMDA
(cl-define-keysym #x07cc "Greek_MU") ;U+039C GREEK CAPITAL LETTER MU
(cl-define-keysym #x07cd "Greek_NU") ;U+039D GREEK CAPITAL LETTER NU
(cl-define-keysym #x07ce "Greek_XI") ;U+039E GREEK CAPITAL LETTER XI
(cl-define-keysym #x07cf "Greek_OMICRON") ;U+039F GREEK CAPITAL LETTER OMICRON
(cl-define-keysym #x07d0 "Greek_PI") ;U+03A0 GREEK CAPITAL LETTER PI
(cl-define-keysym #x07d1 "Greek_RHO") ;U+03A1 GREEK CAPITAL LETTER RHO
(cl-define-keysym #x07d2 "Greek_SIGMA") ;U+03A3 GREEK CAPITAL LETTER SIGMA
(cl-define-keysym #x07d4 "Greek_TAU") ;U+03A4 GREEK CAPITAL LETTER TAU
(cl-define-keysym #x07d5 "Greek_UPSILON") ;U+03A5 GREEK CAPITAL LETTER UPSILON
(cl-define-keysym #x07d6 "Greek_PHI") ;U+03A6 GREEK CAPITAL LETTER PHI
(cl-define-keysym #x07d7 "Greek_CHI") ;U+03A7 GREEK CAPITAL LETTER CHI
(cl-define-keysym #x07d8 "Greek_PSI") ;U+03A8 GREEK CAPITAL LETTER PSI
(cl-define-keysym #x07d9 "Greek_OMEGA") ;U+03A9 GREEK CAPITAL LETTER OMEGA
(cl-define-keysym #x07e1 "Greek_alpha") ;U+03B1 GREEK SMALL LETTER ALPHA
(cl-define-keysym #x07e2 "Greek_beta") ;U+03B2 GREEK SMALL LETTER BETA
(cl-define-keysym #x07e3 "Greek_gamma") ;U+03B3 GREEK SMALL LETTER GAMMA
(cl-define-keysym #x07e4 "Greek_delta") ;U+03B4 GREEK SMALL LETTER DELTA
(cl-define-keysym #x07e5 "Greek_epsilon") ;U+03B5 GREEK SMALL LETTER EPSILON
(cl-define-keysym #x07e6 "Greek_zeta") ;U+03B6 GREEK SMALL LETTER ZETA
(cl-define-keysym #x07e7 "Greek_eta") ;U+03B7 GREEK SMALL LETTER ETA
(cl-define-keysym #x07e8 "Greek_theta") ;U+03B8 GREEK SMALL LETTER THETA
(cl-define-keysym #x07e9 "Greek_iota") ;U+03B9 GREEK SMALL LETTER IOTA
(cl-define-keysym #x07ea "Greek_kappa") ;U+03BA GREEK SMALL LETTER KAPPA
(cl-define-keysym #x07eb "Greek_lamda") ;U+03BB GREEK SMALL LETTER LAMDA
(cl-define-keysym #x07eb "Greek_lambda") ;U+03BB GREEK SMALL LETTER LAMDA
(cl-define-keysym #x07ec "Greek_mu") ;U+03BC GREEK SMALL LETTER MU
(cl-define-keysym #x07ed "Greek_nu") ;U+03BD GREEK SMALL LETTER NU
(cl-define-keysym #x07ee "Greek_xi") ;U+03BE GREEK SMALL LETTER XI
(cl-define-keysym #x07ef "Greek_omicron") ;U+03BF GREEK SMALL LETTER OMICRON
(cl-define-keysym #x07f0 "Greek_pi") ;U+03C0 GREEK SMALL LETTER PI
(cl-define-keysym #x07f1 "Greek_rho") ;U+03C1 GREEK SMALL LETTER RHO
(cl-define-keysym #x07f2 "Greek_sigma") ;U+03C3 GREEK SMALL LETTER SIGMA
(cl-define-keysym #x07f3 "Greek_finalsmallsigma") ;U+03C2 GREEK SMALL LETTER FINAL SIGMA
(cl-define-keysym #x07f4 "Greek_tau") ;U+03C4 GREEK SMALL LETTER TAU
(cl-define-keysym #x07f5 "Greek_upsilon") ;U+03C5 GREEK SMALL LETTER UPSILON
(cl-define-keysym #x07f6 "Greek_phi") ;U+03C6 GREEK SMALL LETTER PHI
(cl-define-keysym #x07f7 "Greek_chi") ;U+03C7 GREEK SMALL LETTER CHI
(cl-define-keysym #x07f8 "Greek_psi") ;U+03C8 GREEK SMALL LETTER PSI
(cl-define-keysym #x07f9 "Greek_omega") ;U+03C9 GREEK SMALL LETTER OMEGA
(cl-define-keysym #xff7e "Greek_switch") ;Alias for mode_switch
(cl-define-keysym #x08a1 "leftradical") ;U+23B7 RADICAL SYMBOL BOTTOM
(cl-define-keysym #x08a2 "topleftradical") ;(U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT)
(cl-define-keysym #x08a3 "horizconnector") ;(U+2500 BOX DRAWINGS LIGHT HORIZONTAL)
(cl-define-keysym #x08a4 "topintegral") ;U+2320 TOP HALF INTEGRAL
(cl-define-keysym #x08a5 "botintegral") ;U+2321 BOTTOM HALF INTEGRAL
(cl-define-keysym #x08a6 "vertconnector") ;(U+2502 BOX DRAWINGS LIGHT VERTICAL)
(cl-define-keysym #x08a7 "topleftsqbracket") ;U+23A1 LEFT SQUARE BRACKET UPPER CORNER
(cl-define-keysym #x08a8 "botleftsqbracket") ;U+23A3 LEFT SQUARE BRACKET LOWER CORNER
(cl-define-keysym #x08a9 "toprightsqbracket") ;U+23A4 RIGHT SQUARE BRACKET UPPER CORNER
(cl-define-keysym #x08aa "botrightsqbracket") ;U+23A6 RIGHT SQUARE BRACKET LOWER CORNER
(cl-define-keysym #x08ab "topleftparens") ;U+239B LEFT PARENTHESIS UPPER HOOK
(cl-define-keysym #x08ac "botleftparens") ;U+239D LEFT PARENTHESIS LOWER HOOK
(cl-define-keysym #x08ad "toprightparens") ;U+239E RIGHT PARENTHESIS UPPER HOOK
(cl-define-keysym #x08ae "botrightparens") ;U+23A0 RIGHT PARENTHESIS LOWER HOOK
(cl-define-keysym #x08af "leftmiddlecurlybrace") ;U+23A8 LEFT CURLY BRACKET MIDDLE PIECE
(cl-define-keysym #x08b0 "rightmiddlecurlybrace") ;U+23AC RIGHT CURLY BRACKET MIDDLE PIECE
(cl-define-keysym #x08b1 "topleftsummation")
(cl-define-keysym #x08b2 "botleftsummation")
(cl-define-keysym #x08b3 "topvertsummationconnector")
(cl-define-keysym #x08b4 "botvertsummationconnector")
(cl-define-keysym #x08b5 "toprightsummation")
(cl-define-keysym #x08b6 "botrightsummation")
(cl-define-keysym #x08b7 "rightmiddlesummation")
(cl-define-keysym #x08bc "lessthanequal") ;U+2264 LESS-THAN OR EQUAL TO
(cl-define-keysym #x08bd "notequal") ;U+2260 NOT EQUAL TO
(cl-define-keysym #x08be "greaterthanequal") ;U+2265 GREATER-THAN OR EQUAL TO
(cl-define-keysym #x08bf "integral") ;U+222B INTEGRAL
(cl-define-keysym #x08c0 "therefore") ;U+2234 THEREFORE
(cl-define-keysym #x08c1 "variation") ;U+221D PROPORTIONAL TO
(cl-define-keysym #x08c2 "infinity") ;U+221E INFINITY
(cl-define-keysym #x08c5 "nabla") ;U+2207 NABLA
(cl-define-keysym #x08c8 "approximate") ;U+223C TILDE OPERATOR
(cl-define-keysym #x08c9 "similarequal") ;U+2243 ASYMPTOTICALLY EQUAL TO
(cl-define-keysym #x08cd "ifonlyif") ;U+21D4 LEFT RIGHT DOUBLE ARROW
(cl-define-keysym #x08ce "implies") ;U+21D2 RIGHTWARDS DOUBLE ARROW
(cl-define-keysym #x08cf "identical") ;U+2261 IDENTICAL TO
(cl-define-keysym #x08d6 "radical") ;U+221A SQUARE ROOT
(cl-define-keysym #x08da "includedin") ;U+2282 SUBSET OF
(cl-define-keysym #x08db "includes") ;U+2283 SUPERSET OF
(cl-define-keysym #x08dc "intersection") ;U+2229 INTERSECTION
(cl-define-keysym #x08dd "union") ;U+222A UNION
(cl-define-keysym #x08de "logicaland") ;U+2227 LOGICAL AND
(cl-define-keysym #x08df "logicalor") ;U+2228 LOGICAL OR
(cl-define-keysym #x08ef "partialderivative") ;U+2202 PARTIAL DIFFERENTIAL
(cl-define-keysym #x08f6 "function") ;U+0192 LATIN SMALL LETTER F WITH HOOK
(cl-define-keysym #x08fb "leftarrow") ;U+2190 LEFTWARDS ARROW
(cl-define-keysym #x08fc "uparrow") ;U+2191 UPWARDS ARROW
(cl-define-keysym #x08fd "rightarrow") ;U+2192 RIGHTWARDS ARROW
(cl-define-keysym #x08fe "downarrow") ;U+2193 DOWNWARDS ARROW
(cl-define-keysym #x09df "blank")
(cl-define-keysym #x09e0 "soliddiamond") ;U+25C6 BLACK DIAMOND
(cl-define-keysym #x09e1 "checkerboard") ;U+2592 MEDIUM SHADE
(cl-define-keysym #x09e2 "ht") ;U+2409 SYMBOL FOR HORIZONTAL TABULATION
(cl-define-keysym #x09e3 "ff") ;U+240C SYMBOL FOR FORM FEED
(cl-define-keysym #x09e4 "cr") ;U+240D SYMBOL FOR CARRIAGE RETURN
(cl-define-keysym #x09e5 "lf") ;U+240A SYMBOL FOR LINE FEED
(cl-define-keysym #x09e8 "nl") ;U+2424 SYMBOL FOR NEWLINE
(cl-define-keysym #x09e9 "vt") ;U+240B SYMBOL FOR VERTICAL TABULATION
(cl-define-keysym #x09ea "lowrightcorner") ;U+2518 BOX DRAWINGS LIGHT UP AND LEFT
(cl-define-keysym #x09eb "uprightcorner") ;U+2510 BOX DRAWINGS LIGHT DOWN AND LEFT
(cl-define-keysym #x09ec "upleftcorner") ;U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT
(cl-define-keysym #x09ed "lowleftcorner") ;U+2514 BOX DRAWINGS LIGHT UP AND RIGHT
(cl-define-keysym #x09ee "crossinglines") ;U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
(cl-define-keysym #x09ef "horizlinescan1") ;U+23BA HORIZONTAL SCAN LINE-1
(cl-define-keysym #x09f0 "horizlinescan3") ;U+23BB HORIZONTAL SCAN LINE-3
(cl-define-keysym #x09f1 "horizlinescan5") ;U+2500 BOX DRAWINGS LIGHT HORIZONTAL
(cl-define-keysym #x09f2 "horizlinescan7") ;U+23BC HORIZONTAL SCAN LINE-7
(cl-define-keysym #x09f3 "horizlinescan9") ;U+23BD HORIZONTAL SCAN LINE-9
(cl-define-keysym #x09f4 "leftt") ;U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT
(cl-define-keysym #x09f5 "rightt") ;U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT
(cl-define-keysym #x09f6 "bott") ;U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL
(cl-define-keysym #x09f7 "topt") ;U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
(cl-define-keysym #x09f8 "vertbar") ;U+2502 BOX DRAWINGS LIGHT VERTICAL
(cl-define-keysym #x0aa1 "emspace") ;U+2003 EM SPACE
(cl-define-keysym #x0aa2 "enspace") ;U+2002 EN SPACE
(cl-define-keysym #x0aa3 "em3space") ;U+2004 THREE-PER-EM SPACE
(cl-define-keysym #x0aa4 "em4space") ;U+2005 FOUR-PER-EM SPACE
(cl-define-keysym #x0aa5 "digitspace") ;U+2007 FIGURE SPACE
(cl-define-keysym #x0aa6 "punctspace") ;U+2008 PUNCTUATION SPACE
(cl-define-keysym #x0aa7 "thinspace") ;U+2009 THIN SPACE
(cl-define-keysym #x0aa8 "hairspace") ;U+200A HAIR SPACE
(cl-define-keysym #x0aa9 "emdash") ;U+2014 EM DASH
(cl-define-keysym #x0aaa "endash") ;U+2013 EN DASH
(cl-define-keysym #x0aac "signifblank") ;(U+2423 OPEN BOX)
(cl-define-keysym #x0aae "ellipsis") ;U+2026 HORIZONTAL ELLIPSIS
(cl-define-keysym #x0aaf "doubbaselinedot") ;U+2025 TWO DOT LEADER
(cl-define-keysym #x0ab0 "onethird") ;U+2153 VULGAR FRACTION ONE THIRD
(cl-define-keysym #x0ab1 "twothirds") ;U+2154 VULGAR FRACTION TWO THIRDS
(cl-define-keysym #x0ab2 "onefifth") ;U+2155 VULGAR FRACTION ONE FIFTH
(cl-define-keysym #x0ab3 "twofifths") ;U+2156 VULGAR FRACTION TWO FIFTHS
(cl-define-keysym #x0ab4 "threefifths") ;U+2157 VULGAR FRACTION THREE FIFTHS
(cl-define-keysym #x0ab5 "fourfifths") ;U+2158 VULGAR FRACTION FOUR FIFTHS
(cl-define-keysym #x0ab6 "onesixth") ;U+2159 VULGAR FRACTION ONE SIXTH
(cl-define-keysym #x0ab7 "fivesixths") ;U+215A VULGAR FRACTION FIVE SIXTHS
(cl-define-keysym #x0ab8 "careof") ;U+2105 CARE OF
(cl-define-keysym #x0abb "figdash") ;U+2012 FIGURE DASH
(cl-define-keysym #x0abc "leftanglebracket") ;(U+27E8 MATHEMATICAL LEFT ANGLE BRACKET)
(cl-define-keysym #x0abd "decimalpoint") ;(U+002E FULL STOP)
(cl-define-keysym #x0abe "rightanglebracket") ;(U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET)
(cl-define-keysym #x0abf "marker")
(cl-define-keysym #x0ac3 "oneeighth") ;U+215B VULGAR FRACTION ONE EIGHTH
(cl-define-keysym #x0ac4 "threeeighths") ;U+215C VULGAR FRACTION THREE EIGHTHS
(cl-define-keysym #x0ac5 "fiveeighths") ;U+215D VULGAR FRACTION FIVE EIGHTHS
(cl-define-keysym #x0ac6 "seveneighths") ;U+215E VULGAR FRACTION SEVEN EIGHTHS
(cl-define-keysym #x0ac9 "trademark") ;U+2122 TRADE MARK SIGN
(cl-define-keysym #x0aca "signaturemark") ;(U+2613 SALTIRE)
(cl-define-keysym #x0acb "trademarkincircle")
(cl-define-keysym #x0acc "leftopentriangle") ;(U+25C1 WHITE LEFT-POINTING TRIANGLE)
(cl-define-keysym #x0acd "rightopentriangle") ;(U+25B7 WHITE RIGHT-POINTING TRIANGLE)
(cl-define-keysym #x0ace "emopencircle") ;(U+25CB WHITE CIRCLE)
(cl-define-keysym #x0acf "emopenrectangle") ;(U+25AF WHITE VERTICAL RECTANGLE)
(cl-define-keysym #x0ad0 "leftsinglequotemark") ;U+2018 LEFT SINGLE QUOTATION MARK
(cl-define-keysym #x0ad1 "rightsinglequotemark") ;U+2019 RIGHT SINGLE QUOTATION MARK
(cl-define-keysym #x0ad2 "leftdoublequotemark") ;U+201C LEFT DOUBLE QUOTATION MARK
(cl-define-keysym #x0ad3 "rightdoublequotemark") ;U+201D RIGHT DOUBLE QUOTATION MARK
(cl-define-keysym #x0ad4 "prescription") ;U+211E PRESCRIPTION TAKE
(cl-define-keysym #x0ad6 "minutes") ;U+2032 PRIME
(cl-define-keysym #x0ad7 "seconds") ;U+2033 DOUBLE PRIME
(cl-define-keysym #x0ad9 "latincross") ;U+271D LATIN CROSS
(cl-define-keysym #x0ada "hexagram")
(cl-define-keysym #x0adb "filledrectbullet") ;(U+25AC BLACK RECTANGLE)
(cl-define-keysym #x0adc "filledlefttribullet") ;(U+25C0 BLACK LEFT-POINTING TRIANGLE)
(cl-define-keysym #x0add "filledrighttribullet") ;(U+25B6 BLACK RIGHT-POINTING TRIANGLE)
(cl-define-keysym #x0ade "emfilledcircle") ;(U+25CF BLACK CIRCLE)
(cl-define-keysym #x0adf "emfilledrect") ;(U+25AE BLACK VERTICAL RECTANGLE)
(cl-define-keysym #x0ae0 "enopencircbullet") ;(U+25E6 WHITE BULLET)
(cl-define-keysym #x0ae1 "enopensquarebullet") ;(U+25AB WHITE SMALL SQUARE)
(cl-define-keysym #x0ae2 "openrectbullet") ;(U+25AD WHITE RECTANGLE)
(cl-define-keysym #x0ae3 "opentribulletup") ;(U+25B3 WHITE UP-POINTING TRIANGLE)
(cl-define-keysym #x0ae4 "opentribulletdown") ;(U+25BD WHITE DOWN-POINTING TRIANGLE)
(cl-define-keysym #x0ae5 "openstar") ;(U+2606 WHITE STAR)
(cl-define-keysym #x0ae6 "enfilledcircbullet") ;(U+2022 BULLET)
(cl-define-keysym #x0ae7 "enfilledsqbullet") ;(U+25AA BLACK SMALL SQUARE)
(cl-define-keysym #x0ae8 "filledtribulletup") ;(U+25B2 BLACK UP-POINTING TRIANGLE)
(cl-define-keysym #x0ae9 "filledtribulletdown") ;(U+25BC BLACK DOWN-POINTING TRIANGLE)
(cl-define-keysym #x0aea "leftpointer") ;(U+261C WHITE LEFT POINTING INDEX)
(cl-define-keysym #x0aeb "rightpointer") ;(U+261E WHITE RIGHT POINTING INDEX)
(cl-define-keysym #x0aec "club") ;U+2663 BLACK CLUB SUIT
(cl-define-keysym #x0aed "diamond") ;U+2666 BLACK DIAMOND SUIT
(cl-define-keysym #x0aee "heart") ;U+2665 BLACK HEART SUIT
(cl-define-keysym #x0af0 "maltesecross") ;U+2720 MALTESE CROSS
(cl-define-keysym #x0af1 "dagger") ;U+2020 DAGGER
(cl-define-keysym #x0af2 "doubledagger") ;U+2021 DOUBLE DAGGER
(cl-define-keysym #x0af3 "checkmark") ;U+2713 CHECK MARK
(cl-define-keysym #x0af4 "ballotcross") ;U+2717 BALLOT X
(cl-define-keysym #x0af5 "musicalsharp") ;U+266F MUSIC SHARP SIGN
(cl-define-keysym #x0af6 "musicalflat") ;U+266D MUSIC FLAT SIGN
(cl-define-keysym #x0af7 "malesymbol") ;U+2642 MALE SIGN
(cl-define-keysym #x0af8 "femalesymbol") ;U+2640 FEMALE SIGN
(cl-define-keysym #x0af9 "telephone") ;U+260E BLACK TELEPHONE
(cl-define-keysym #x0afa "telephonerecorder") ;U+2315 TELEPHONE RECORDER
(cl-define-keysym #x0afb "phonographcopyright") ;U+2117 SOUND RECORDING COPYRIGHT
(cl-define-keysym #x0afc "caret") ;U+2038 CARET
(cl-define-keysym #x0afd "singlelowquotemark") ;U+201A SINGLE LOW-9 QUOTATION MARK
(cl-define-keysym #x0afe "doublelowquotemark") ;U+201E DOUBLE LOW-9 QUOTATION MARK
(cl-define-keysym #x0aff "cursor")
(cl-define-keysym #x0ba3 "leftcaret") ;(U+003C LESS-THAN SIGN)
(cl-define-keysym #x0ba6 "rightcaret") ;(U+003E GREATER-THAN SIGN)
(cl-define-keysym #x0ba8 "downcaret") ;(U+2228 LOGICAL OR)
(cl-define-keysym #x0ba9 "upcaret") ;(U+2227 LOGICAL AND)
(cl-define-keysym #x0bc0 "overbar") ;(U+00AF MACRON)
(cl-define-keysym #x0bc2 "downtack") ;U+22A5 UP TACK
(cl-define-keysym #x0bc3 "upshoe") ;(U+2229 INTERSECTION)
(cl-define-keysym #x0bc4 "downstile") ;U+230A LEFT FLOOR
(cl-define-keysym #x0bc6 "underbar") ;(U+005F LOW LINE)
(cl-define-keysym #x0bca "jot") ;U+2218 RING OPERATOR
(cl-define-keysym #x0bcc "quad") ;U+2395 APL FUNCTIONAL SYMBOL QUAD
(cl-define-keysym #x0bce "uptack") ;U+22A4 DOWN TACK
(cl-define-keysym #x0bcf "circle") ;U+25CB WHITE CIRCLE
(cl-define-keysym #x0bd3 "upstile") ;U+2308 LEFT CEILING
(cl-define-keysym #x0bd6 "downshoe") ;(U+222A UNION)
(cl-define-keysym #x0bd8 "rightshoe") ;(U+2283 SUPERSET OF)
(cl-define-keysym #x0bda "leftshoe") ;(U+2282 SUBSET OF)
(cl-define-keysym #x0bdc "lefttack") ;U+22A2 RIGHT TACK
(cl-define-keysym #x0bfc "righttack") ;U+22A3 LEFT TACK
(cl-define-keysym #x0cdf "hebrew_doublelowline") ;U+2017 DOUBLE LOW LINE
(cl-define-keysym #x0ce0 "hebrew_aleph") ;U+05D0 HEBREW LETTER ALEF
(cl-define-keysym #x0ce1 "hebrew_bet") ;U+05D1 HEBREW LETTER BET
(cl-define-keysym #x0ce1 "hebrew_beth") ;deprecated
(cl-define-keysym #x0ce2 "hebrew_gimel") ;U+05D2 HEBREW LETTER GIMEL
(cl-define-keysym #x0ce2 "hebrew_gimmel") ;deprecated
(cl-define-keysym #x0ce3 "hebrew_dalet") ;U+05D3 HEBREW LETTER DALET
(cl-define-keysym #x0ce3 "hebrew_daleth") ;deprecated
(cl-define-keysym #x0ce4 "hebrew_he") ;U+05D4 HEBREW LETTER HE
(cl-define-keysym #x0ce5 "hebrew_waw") ;U+05D5 HEBREW LETTER VAV
(cl-define-keysym #x0ce6 "hebrew_zain") ;U+05D6 HEBREW LETTER ZAYIN
(cl-define-keysym #x0ce6 "hebrew_zayin") ;deprecated
(cl-define-keysym #x0ce7 "hebrew_chet") ;U+05D7 HEBREW LETTER HET
(cl-define-keysym #x0ce7 "hebrew_het") ;deprecated
(cl-define-keysym #x0ce8 "hebrew_tet") ;U+05D8 HEBREW LETTER TET
(cl-define-keysym #x0ce8 "hebrew_teth") ;deprecated
(cl-define-keysym #x0ce9 "hebrew_yod") ;U+05D9 HEBREW LETTER YOD
(cl-define-keysym #x0cea "hebrew_finalkaph") ;U+05DA HEBREW LETTER FINAL KAF
(cl-define-keysym #x0ceb "hebrew_kaph") ;U+05DB HEBREW LETTER KAF
(cl-define-keysym #x0cec "hebrew_lamed") ;U+05DC HEBREW LETTER LAMED
(cl-define-keysym #x0ced "hebrew_finalmem") ;U+05DD HEBREW LETTER FINAL MEM
(cl-define-keysym #x0cee "hebrew_mem") ;U+05DE HEBREW LETTER MEM
(cl-define-keysym #x0cef "hebrew_finalnun") ;U+05DF HEBREW LETTER FINAL NUN
(cl-define-keysym #x0cf0 "hebrew_nun") ;U+05E0 HEBREW LETTER NUN
(cl-define-keysym #x0cf1 "hebrew_samech") ;U+05E1 HEBREW LETTER SAMEKH
(cl-define-keysym #x0cf1 "hebrew_samekh") ;deprecated
(cl-define-keysym #x0cf2 "hebrew_ayin") ;U+05E2 HEBREW LETTER AYIN
(cl-define-keysym #x0cf3 "hebrew_finalpe") ;U+05E3 HEBREW LETTER FINAL PE
(cl-define-keysym #x0cf4 "hebrew_pe") ;U+05E4 HEBREW LETTER PE
(cl-define-keysym #x0cf5 "hebrew_finalzade") ;U+05E5 HEBREW LETTER FINAL TSADI
(cl-define-keysym #x0cf5 "hebrew_finalzadi") ;deprecated
(cl-define-keysym #x0cf6 "hebrew_zade") ;U+05E6 HEBREW LETTER TSADI
(cl-define-keysym #x0cf6 "hebrew_zadi") ;deprecated
(cl-define-keysym #x0cf7 "hebrew_qoph") ;U+05E7 HEBREW LETTER QOF
(cl-define-keysym #x0cf7 "hebrew_kuf") ;deprecated
(cl-define-keysym #x0cf8 "hebrew_resh") ;U+05E8 HEBREW LETTER RESH
(cl-define-keysym #x0cf9 "hebrew_shin") ;U+05E9 HEBREW LETTER SHIN
(cl-define-keysym #x0cfa "hebrew_taw") ;U+05EA HEBREW LETTER TAV
(cl-define-keysym #x0cfa "hebrew_taf") ;deprecated
(cl-define-keysym #xff7e "Hebrew_switch") ;Alias for mode_switch
(cl-define-keysym #x0da1 "Thai_kokai") ;U+0E01 THAI CHARACTER KO KAI
(cl-define-keysym #x0da2 "Thai_khokhai") ;U+0E02 THAI CHARACTER KHO KHAI
(cl-define-keysym #x0da3 "Thai_khokhuat") ;U+0E03 THAI CHARACTER KHO KHUAT
(cl-define-keysym #x0da4 "Thai_khokhwai") ;U+0E04 THAI CHARACTER KHO KHWAI
(cl-define-keysym #x0da5 "Thai_khokhon") ;U+0E05 THAI CHARACTER KHO KHON
(cl-define-keysym #x0da6 "Thai_khorakhang") ;U+0E06 THAI CHARACTER KHO RAKHANG
(cl-define-keysym #x0da7 "Thai_ngongu") ;U+0E07 THAI CHARACTER NGO NGU
(cl-define-keysym #x0da8 "Thai_chochan") ;U+0E08 THAI CHARACTER CHO CHAN
(cl-define-keysym #x0da9 "Thai_choching") ;U+0E09 THAI CHARACTER CHO CHING
(cl-define-keysym #x0daa "Thai_chochang") ;U+0E0A THAI CHARACTER CHO CHANG
(cl-define-keysym #x0dab "Thai_soso") ;U+0E0B THAI CHARACTER SO SO
(cl-define-keysym #x0dac "Thai_chochoe") ;U+0E0C THAI CHARACTER CHO CHOE
(cl-define-keysym #x0dad "Thai_yoying") ;U+0E0D THAI CHARACTER YO YING
(cl-define-keysym #x0dae "Thai_dochada") ;U+0E0E THAI CHARACTER DO CHADA
(cl-define-keysym #x0daf "Thai_topatak") ;U+0E0F THAI CHARACTER TO PATAK
(cl-define-keysym #x0db0 "Thai_thothan") ;U+0E10 THAI CHARACTER THO THAN
(cl-define-keysym #x0db1 "Thai_thonangmontho") ;U+0E11 THAI CHARACTER THO NANGMONTHO
(cl-define-keysym #x0db2 "Thai_thophuthao") ;U+0E12 THAI CHARACTER THO PHUTHAO
(cl-define-keysym #x0db3 "Thai_nonen") ;U+0E13 THAI CHARACTER NO NEN
(cl-define-keysym #x0db4 "Thai_dodek") ;U+0E14 THAI CHARACTER DO DEK
(cl-define-keysym #x0db5 "Thai_totao") ;U+0E15 THAI CHARACTER TO TAO
(cl-define-keysym #x0db6 "Thai_thothung") ;U+0E16 THAI CHARACTER THO THUNG
(cl-define-keysym #x0db7 "Thai_thothahan") ;U+0E17 THAI CHARACTER THO THAHAN
(cl-define-keysym #x0db8 "Thai_thothong") ;U+0E18 THAI CHARACTER THO THONG
(cl-define-keysym #x0db9 "Thai_nonu") ;U+0E19 THAI CHARACTER NO NU
(cl-define-keysym #x0dba "Thai_bobaimai") ;U+0E1A THAI CHARACTER BO BAIMAI
(cl-define-keysym #x0dbb "Thai_popla") ;U+0E1B THAI CHARACTER PO PLA
(cl-define-keysym #x0dbc "Thai_phophung") ;U+0E1C THAI CHARACTER PHO PHUNG
(cl-define-keysym #x0dbd "Thai_fofa") ;U+0E1D THAI CHARACTER FO FA
(cl-define-keysym #x0dbe "Thai_phophan") ;U+0E1E THAI CHARACTER PHO PHAN
(cl-define-keysym #x0dbf "Thai_fofan") ;U+0E1F THAI CHARACTER FO FAN
(cl-define-keysym #x0dc0 "Thai_phosamphao") ;U+0E20 THAI CHARACTER PHO SAMPHAO
(cl-define-keysym #x0dc1 "Thai_moma") ;U+0E21 THAI CHARACTER MO MA
(cl-define-keysym #x0dc2 "Thai_yoyak") ;U+0E22 THAI CHARACTER YO YAK
(cl-define-keysym #x0dc3 "Thai_rorua") ;U+0E23 THAI CHARACTER RO RUA
(cl-define-keysym #x0dc4 "Thai_ru") ;U+0E24 THAI CHARACTER RU
(cl-define-keysym #x0dc5 "Thai_loling") ;U+0E25 THAI CHARACTER LO LING
(cl-define-keysym #x0dc6 "Thai_lu") ;U+0E26 THAI CHARACTER LU
(cl-define-keysym #x0dc7 "Thai_wowaen") ;U+0E27 THAI CHARACTER WO WAEN
(cl-define-keysym #x0dc8 "Thai_sosala") ;U+0E28 THAI CHARACTER SO SALA
(cl-define-keysym #x0dc9 "Thai_sorusi") ;U+0E29 THAI CHARACTER SO RUSI
(cl-define-keysym #x0dca "Thai_sosua") ;U+0E2A THAI CHARACTER SO SUA
(cl-define-keysym #x0dcb "Thai_hohip") ;U+0E2B THAI CHARACTER HO HIP
(cl-define-keysym #x0dcc "Thai_lochula") ;U+0E2C THAI CHARACTER LO CHULA
(cl-define-keysym #x0dcd "Thai_oang") ;U+0E2D THAI CHARACTER O ANG
(cl-define-keysym #x0dce "Thai_honokhuk") ;U+0E2E THAI CHARACTER HO NOKHUK
(cl-define-keysym #x0dcf "Thai_paiyannoi") ;U+0E2F THAI CHARACTER PAIYANNOI
(cl-define-keysym #x0dd0 "Thai_saraa") ;U+0E30 THAI CHARACTER SARA A
(cl-define-keysym #x0dd1 "Thai_maihanakat") ;U+0E31 THAI CHARACTER MAI HAN-AKAT
(cl-define-keysym #x0dd2 "Thai_saraaa") ;U+0E32 THAI CHARACTER SARA AA
(cl-define-keysym #x0dd3 "Thai_saraam") ;U+0E33 THAI CHARACTER SARA AM
(cl-define-keysym #x0dd4 "Thai_sarai") ;U+0E34 THAI CHARACTER SARA I
(cl-define-keysym #x0dd5 "Thai_saraii") ;U+0E35 THAI CHARACTER SARA II
(cl-define-keysym #x0dd6 "Thai_saraue") ;U+0E36 THAI CHARACTER SARA UE
(cl-define-keysym #x0dd7 "Thai_sarauee") ;U+0E37 THAI CHARACTER SARA UEE
(cl-define-keysym #x0dd8 "Thai_sarau") ;U+0E38 THAI CHARACTER SARA U
(cl-define-keysym #x0dd9 "Thai_sarauu") ;U+0E39 THAI CHARACTER SARA UU
(cl-define-keysym #x0dda "Thai_phinthu") ;U+0E3A THAI CHARACTER PHINTHU
(cl-define-keysym #x0dde "Thai_maihanakat_maitho")
(cl-define-keysym #x0ddf "Thai_baht") ;U+0E3F THAI CURRENCY SYMBOL BAHT
(cl-define-keysym #x0de0 "Thai_sarae") ;U+0E40 THAI CHARACTER SARA E
(cl-define-keysym #x0de1 "Thai_saraae") ;U+0E41 THAI CHARACTER SARA AE
(cl-define-keysym #x0de2 "Thai_sarao") ;U+0E42 THAI CHARACTER SARA O
(cl-define-keysym #x0de3 "Thai_saraaimaimuan") ;U+0E43 THAI CHARACTER SARA AI MAIMUAN
(cl-define-keysym #x0de4 "Thai_saraaimaimalai") ;U+0E44 THAI CHARACTER SARA AI MAIMALAI
(cl-define-keysym #x0de5 "Thai_lakkhangyao") ;U+0E45 THAI CHARACTER LAKKHANGYAO
(cl-define-keysym #x0de6 "Thai_maiyamok") ;U+0E46 THAI CHARACTER MAIYAMOK
(cl-define-keysym #x0de7 "Thai_maitaikhu") ;U+0E47 THAI CHARACTER MAITAIKHU
(cl-define-keysym #x0de8 "Thai_maiek") ;U+0E48 THAI CHARACTER MAI EK
(cl-define-keysym #x0de9 "Thai_maitho") ;U+0E49 THAI CHARACTER MAI THO
(cl-define-keysym #x0dea "Thai_maitri") ;U+0E4A THAI CHARACTER MAI TRI
(cl-define-keysym #x0deb "Thai_maichattawa") ;U+0E4B THAI CHARACTER MAI CHATTAWA
(cl-define-keysym #x0dec "Thai_thanthakhat") ;U+0E4C THAI CHARACTER THANTHAKHAT
(cl-define-keysym #x0ded "Thai_nikhahit") ;U+0E4D THAI CHARACTER NIKHAHIT
(cl-define-keysym #x0df0 "Thai_leksun") ;U+0E50 THAI DIGIT ZERO
(cl-define-keysym #x0df1 "Thai_leknung") ;U+0E51 THAI DIGIT ONE
(cl-define-keysym #x0df2 "Thai_leksong") ;U+0E52 THAI DIGIT TWO
(cl-define-keysym #x0df3 "Thai_leksam") ;U+0E53 THAI DIGIT THREE
(cl-define-keysym #x0df4 "Thai_leksi") ;U+0E54 THAI DIGIT FOUR
(cl-define-keysym #x0df5 "Thai_lekha") ;U+0E55 THAI DIGIT FIVE
(cl-define-keysym #x0df6 "Thai_lekhok") ;U+0E56 THAI DIGIT SIX
(cl-define-keysym #x0df7 "Thai_lekchet") ;U+0E57 THAI DIGIT SEVEN
(cl-define-keysym #x0df8 "Thai_lekpaet") ;U+0E58 THAI DIGIT EIGHT
(cl-define-keysym #x0df9 "Thai_lekkao") ;U+0E59 THAI DIGIT NINE
(cl-define-keysym #xff31 "Hangul") ;Hangul start/stop(toggle)
(cl-define-keysym #xff32 "Hangul_Start") ;Hangul start
(cl-define-keysym #xff33 "Hangul_End") ;Hangul end, English start
(cl-define-keysym #xff34 "Hangul_Hanja") ;Start Hangul->Hanja Conversion
(cl-define-keysym #xff35 "Hangul_Jamo") ;Hangul Jamo mode
(cl-define-keysym #xff36 "Hangul_Romaja") ;Hangul Romaja mode
(cl-define-keysym #xff37 "Hangul_Codeinput") ;Hangul code input mode
(cl-define-keysym #xff38 "Hangul_Jeonja") ;Jeonja mode
(cl-define-keysym #xff39 "Hangul_Banja") ;Banja mode
(cl-define-keysym #xff3a "Hangul_PreHanja") ;Pre Hanja conversion
(cl-define-keysym #xff3b "Hangul_PostHanja") ;Post Hanja conversion
(cl-define-keysym #xff3c "Hangul_SingleCandidate") ;Single candidate
(cl-define-keysym #xff3d "Hangul_MultipleCandidate") ;Multiple candidate
(cl-define-keysym #xff3e "Hangul_PreviousCandidate") ;Previous candidate
(cl-define-keysym #xff3f "Hangul_Special") ;Special symbols
(cl-define-keysym #xff7e "Hangul_switch") ;Alias for mode_switch
(cl-define-keysym #x0ea1 "Hangul_Kiyeog")
(cl-define-keysym #x0ea2 "Hangul_SsangKiyeog")
(cl-define-keysym #x0ea3 "Hangul_KiyeogSios")
(cl-define-keysym #x0ea4 "Hangul_Nieun")
(cl-define-keysym #x0ea5 "Hangul_NieunJieuj")
(cl-define-keysym #x0ea6 "Hangul_NieunHieuh")
(cl-define-keysym #x0ea7 "Hangul_Dikeud")
(cl-define-keysym #x0ea8 "Hangul_SsangDikeud")
(cl-define-keysym #x0ea9 "Hangul_Rieul")
(cl-define-keysym #x0eaa "Hangul_RieulKiyeog")
(cl-define-keysym #x0eab "Hangul_RieulMieum")
(cl-define-keysym #x0eac "Hangul_RieulPieub")
(cl-define-keysym #x0ead "Hangul_RieulSios")
(cl-define-keysym #x0eae "Hangul_RieulTieut")
(cl-define-keysym #x0eaf "Hangul_RieulPhieuf")
(cl-define-keysym #x0eb0 "Hangul_RieulHieuh")
(cl-define-keysym #x0eb1 "Hangul_Mieum")
(cl-define-keysym #x0eb2 "Hangul_Pieub")
(cl-define-keysym #x0eb3 "Hangul_SsangPieub")
(cl-define-keysym #x0eb4 "Hangul_PieubSios")
(cl-define-keysym #x0eb5 "Hangul_Sios")
(cl-define-keysym #x0eb6 "Hangul_SsangSios")
(cl-define-keysym #x0eb7 "Hangul_Ieung")
(cl-define-keysym #x0eb8 "Hangul_Jieuj")
(cl-define-keysym #x0eb9 "Hangul_SsangJieuj")
(cl-define-keysym #x0eba "Hangul_Cieuc")
(cl-define-keysym #x0ebb "Hangul_Khieuq")
(cl-define-keysym #x0ebc "Hangul_Tieut")
(cl-define-keysym #x0ebd "Hangul_Phieuf")
(cl-define-keysym #x0ebe "Hangul_Hieuh")
(cl-define-keysym #x0ebf "Hangul_A")
(cl-define-keysym #x0ec0 "Hangul_AE")
(cl-define-keysym #x0ec1 "Hangul_YA")
(cl-define-keysym #x0ec2 "Hangul_YAE")
(cl-define-keysym #x0ec3 "Hangul_EO")
(cl-define-keysym #x0ec4 "Hangul_E")
(cl-define-keysym #x0ec5 "Hangul_YEO")
(cl-define-keysym #x0ec6 "Hangul_YE")
(cl-define-keysym #x0ec7 "Hangul_O")
(cl-define-keysym #x0ec8 "Hangul_WA")
(cl-define-keysym #x0ec9 "Hangul_WAE")
(cl-define-keysym #x0eca "Hangul_OE")
(cl-define-keysym #x0ecb "Hangul_YO")
(cl-define-keysym #x0ecc "Hangul_U")
(cl-define-keysym #x0ecd "Hangul_WEO")
(cl-define-keysym #x0ece "Hangul_WE")
(cl-define-keysym #x0ecf "Hangul_WI")
(cl-define-keysym #x0ed0 "Hangul_YU")
(cl-define-keysym #x0ed1 "Hangul_EU")
(cl-define-keysym #x0ed2 "Hangul_YI")
(cl-define-keysym #x0ed3 "Hangul_I")
(cl-define-keysym #x0ed4 "Hangul_J_Kiyeog")
(cl-define-keysym #x0ed5 "Hangul_J_SsangKiyeog")
(cl-define-keysym #x0ed6 "Hangul_J_KiyeogSios")
(cl-define-keysym #x0ed7 "Hangul_J_Nieun")
(cl-define-keysym #x0ed8 "Hangul_J_NieunJieuj")
(cl-define-keysym #x0ed9 "Hangul_J_NieunHieuh")
(cl-define-keysym #x0eda "Hangul_J_Dikeud")
(cl-define-keysym #x0edb "Hangul_J_Rieul")
(cl-define-keysym #x0edc "Hangul_J_RieulKiyeog")
(cl-define-keysym #x0edd "Hangul_J_RieulMieum")
(cl-define-keysym #x0ede "Hangul_J_RieulPieub")
(cl-define-keysym #x0edf "Hangul_J_RieulSios")
(cl-define-keysym #x0ee0 "Hangul_J_RieulTieut")
(cl-define-keysym #x0ee1 "Hangul_J_RieulPhieuf")
(cl-define-keysym #x0ee2 "Hangul_J_RieulHieuh")
(cl-define-keysym #x0ee3 "Hangul_J_Mieum")
(cl-define-keysym #x0ee4 "Hangul_J_Pieub")
(cl-define-keysym #x0ee5 "Hangul_J_PieubSios")
(cl-define-keysym #x0ee6 "Hangul_J_Sios")
(cl-define-keysym #x0ee7 "Hangul_J_SsangSios")
(cl-define-keysym #x0ee8 "Hangul_J_Ieung")
(cl-define-keysym #x0ee9 "Hangul_J_Jieuj")
(cl-define-keysym #x0eea "Hangul_J_Cieuc")
(cl-define-keysym #x0eeb "Hangul_J_Khieuq")
(cl-define-keysym #x0eec "Hangul_J_Tieut")
(cl-define-keysym #x0eed "Hangul_J_Phieuf")
(cl-define-keysym #x0eee "Hangul_J_Hieuh")
(cl-define-keysym #x0eef "Hangul_RieulYeorinHieuh")
(cl-define-keysym #x0ef0 "Hangul_SunkyeongeumMieum")
(cl-define-keysym #x0ef1 "Hangul_SunkyeongeumPieub")
(cl-define-keysym #x0ef2 "Hangul_PanSios")
(cl-define-keysym #x0ef3 "Hangul_KkogjiDalrinIeung")
(cl-define-keysym #x0ef4 "Hangul_SunkyeongeumPhieuf")
(cl-define-keysym #x0ef5 "Hangul_YeorinHieuh")
(cl-define-keysym #x0ef6 "Hangul_AraeA")
(cl-define-keysym #x0ef7 "Hangul_AraeAE")
(cl-define-keysym #x0ef8 "Hangul_J_PanSios")
(cl-define-keysym #x0ef9 "Hangul_J_KkogjiDalrinIeung")
(cl-define-keysym #x0efa "Hangul_J_YeorinHieuh")
(cl-define-keysym #x0eff "Korean_Won") ;(U+20A9 WON SIGN)
(cl-define-keysym #x1000587 "Armenian_ligature_ew") ;U+0587 ARMENIAN SMALL LIGATURE ECH YIWN
(cl-define-keysym #x1000589 "Armenian_full_stop") ;U+0589 ARMENIAN FULL STOP
(cl-define-keysym #x1000589 "Armenian_verjaket") ;U+0589 ARMENIAN FULL STOP
(cl-define-keysym #x100055d "Armenian_separation_mark") ;U+055D ARMENIAN COMMA
(cl-define-keysym #x100055d "Armenian_but") ;U+055D ARMENIAN COMMA
(cl-define-keysym #x100058a "Armenian_hyphen") ;U+058A ARMENIAN HYPHEN
(cl-define-keysym #x100058a "Armenian_yentamna") ;U+058A ARMENIAN HYPHEN
(cl-define-keysym #x100055c "Armenian_exclam") ;U+055C ARMENIAN EXCLAMATION MARK
(cl-define-keysym #x100055c "Armenian_amanak") ;U+055C ARMENIAN EXCLAMATION MARK
(cl-define-keysym #x100055b "Armenian_accent") ;U+055B ARMENIAN EMPHASIS MARK
(cl-define-keysym #x100055b "Armenian_shesht") ;U+055B ARMENIAN EMPHASIS MARK
(cl-define-keysym #x100055e "Armenian_question") ;U+055E ARMENIAN QUESTION MARK
(cl-define-keysym #x100055e "Armenian_paruyk") ;U+055E ARMENIAN QUESTION MARK
(cl-define-keysym #x1000531 "Armenian_AYB") ;U+0531 ARMENIAN CAPITAL LETTER AYB
(cl-define-keysym #x1000561 "Armenian_ayb") ;U+0561 ARMENIAN SMALL LETTER AYB
(cl-define-keysym #x1000532 "Armenian_BEN") ;U+0532 ARMENIAN CAPITAL LETTER BEN
(cl-define-keysym #x1000562 "Armenian_ben") ;U+0562 ARMENIAN SMALL LETTER BEN
(cl-define-keysym #x1000533 "Armenian_GIM") ;U+0533 ARMENIAN CAPITAL LETTER GIM
(cl-define-keysym #x1000563 "Armenian_gim") ;U+0563 ARMENIAN SMALL LETTER GIM
(cl-define-keysym #x1000534 "Armenian_DA") ;U+0534 ARMENIAN CAPITAL LETTER DA
(cl-define-keysym #x1000564 "Armenian_da") ;U+0564 ARMENIAN SMALL LETTER DA
(cl-define-keysym #x1000535 "Armenian_YECH") ;U+0535 ARMENIAN CAPITAL LETTER ECH
(cl-define-keysym #x1000565 "Armenian_yech") ;U+0565 ARMENIAN SMALL LETTER ECH
(cl-define-keysym #x1000536 "Armenian_ZA") ;U+0536 ARMENIAN CAPITAL LETTER ZA
(cl-define-keysym #x1000566 "Armenian_za") ;U+0566 ARMENIAN SMALL LETTER ZA
(cl-define-keysym #x1000537 "Armenian_E") ;U+0537 ARMENIAN CAPITAL LETTER EH
(cl-define-keysym #x1000567 "Armenian_e") ;U+0567 ARMENIAN SMALL LETTER EH
(cl-define-keysym #x1000538 "Armenian_AT") ;U+0538 ARMENIAN CAPITAL LETTER ET
(cl-define-keysym #x1000568 "Armenian_at") ;U+0568 ARMENIAN SMALL LETTER ET
(cl-define-keysym #x1000539 "Armenian_TO") ;U+0539 ARMENIAN CAPITAL LETTER TO
(cl-define-keysym #x1000569 "Armenian_to") ;U+0569 ARMENIAN SMALL LETTER TO
(cl-define-keysym #x100053a "Armenian_ZHE") ;U+053A ARMENIAN CAPITAL LETTER ZHE
(cl-define-keysym #x100056a "Armenian_zhe") ;U+056A ARMENIAN SMALL LETTER ZHE
(cl-define-keysym #x100053b "Armenian_INI") ;U+053B ARMENIAN CAPITAL LETTER INI
(cl-define-keysym #x100056b "Armenian_ini") ;U+056B ARMENIAN SMALL LETTER INI
(cl-define-keysym #x100053c "Armenian_LYUN") ;U+053C ARMENIAN CAPITAL LETTER LIWN
(cl-define-keysym #x100056c "Armenian_lyun") ;U+056C ARMENIAN SMALL LETTER LIWN
(cl-define-keysym #x100053d "Armenian_KHE") ;U+053D ARMENIAN CAPITAL LETTER XEH
(cl-define-keysym #x100056d "Armenian_khe") ;U+056D ARMENIAN SMALL LETTER XEH
(cl-define-keysym #x100053e "Armenian_TSA") ;U+053E ARMENIAN CAPITAL LETTER CA
(cl-define-keysym #x100056e "Armenian_tsa") ;U+056E ARMENIAN SMALL LETTER CA
(cl-define-keysym #x100053f "Armenian_KEN") ;U+053F ARMENIAN CAPITAL LETTER KEN
(cl-define-keysym #x100056f "Armenian_ken") ;U+056F ARMENIAN SMALL LETTER KEN
(cl-define-keysym #x1000540 "Armenian_HO") ;U+0540 ARMENIAN CAPITAL LETTER HO
(cl-define-keysym #x1000570 "Armenian_ho") ;U+0570 ARMENIAN SMALL LETTER HO
(cl-define-keysym #x1000541 "Armenian_DZA") ;U+0541 ARMENIAN CAPITAL LETTER JA
(cl-define-keysym #x1000571 "Armenian_dza") ;U+0571 ARMENIAN SMALL LETTER JA
(cl-define-keysym #x1000542 "Armenian_GHAT") ;U+0542 ARMENIAN CAPITAL LETTER GHAD
(cl-define-keysym #x1000572 "Armenian_ghat") ;U+0572 ARMENIAN SMALL LETTER GHAD
(cl-define-keysym #x1000543 "Armenian_TCHE") ;U+0543 ARMENIAN CAPITAL LETTER CHEH
(cl-define-keysym #x1000573 "Armenian_tche") ;U+0573 ARMENIAN SMALL LETTER CHEH
(cl-define-keysym #x1000544 "Armenian_MEN") ;U+0544 ARMENIAN CAPITAL LETTER MEN
(cl-define-keysym #x1000574 "Armenian_men") ;U+0574 ARMENIAN SMALL LETTER MEN
(cl-define-keysym #x1000545 "Armenian_HI") ;U+0545 ARMENIAN CAPITAL LETTER YI
(cl-define-keysym #x1000575 "Armenian_hi") ;U+0575 ARMENIAN SMALL LETTER YI
(cl-define-keysym #x1000546 "Armenian_NU") ;U+0546 ARMENIAN CAPITAL LETTER NOW
(cl-define-keysym #x1000576 "Armenian_nu") ;U+0576 ARMENIAN SMALL LETTER NOW
(cl-define-keysym #x1000547 "Armenian_SHA") ;U+0547 ARMENIAN CAPITAL LETTER SHA
(cl-define-keysym #x1000577 "Armenian_sha") ;U+0577 ARMENIAN SMALL LETTER SHA
(cl-define-keysym #x1000548 "Armenian_VO") ;U+0548 ARMENIAN CAPITAL LETTER VO
(cl-define-keysym #x1000578 "Armenian_vo") ;U+0578 ARMENIAN SMALL LETTER VO
(cl-define-keysym #x1000549 "Armenian_CHA") ;U+0549 ARMENIAN CAPITAL LETTER CHA
(cl-define-keysym #x1000579 "Armenian_cha") ;U+0579 ARMENIAN SMALL LETTER CHA
(cl-define-keysym #x100054a "Armenian_PE") ;U+054A ARMENIAN CAPITAL LETTER PEH
(cl-define-keysym #x100057a "Armenian_pe") ;U+057A ARMENIAN SMALL LETTER PEH
(cl-define-keysym #x100054b "Armenian_JE") ;U+054B ARMENIAN CAPITAL LETTER JHEH
(cl-define-keysym #x100057b "Armenian_je") ;U+057B ARMENIAN SMALL LETTER JHEH
(cl-define-keysym #x100054c "Armenian_RA") ;U+054C ARMENIAN CAPITAL LETTER RA
(cl-define-keysym #x100057c "Armenian_ra") ;U+057C ARMENIAN SMALL LETTER RA
(cl-define-keysym #x100054d "Armenian_SE") ;U+054D ARMENIAN CAPITAL LETTER SEH
(cl-define-keysym #x100057d "Armenian_se") ;U+057D ARMENIAN SMALL LETTER SEH
(cl-define-keysym #x100054e "Armenian_VEV") ;U+054E ARMENIAN CAPITAL LETTER VEW
(cl-define-keysym #x100057e "Armenian_vev") ;U+057E ARMENIAN SMALL LETTER VEW
(cl-define-keysym #x100054f "Armenian_TYUN") ;U+054F ARMENIAN CAPITAL LETTER TIWN
(cl-define-keysym #x100057f "Armenian_tyun") ;U+057F ARMENIAN SMALL LETTER TIWN
(cl-define-keysym #x1000550 "Armenian_RE") ;U+0550 ARMENIAN CAPITAL LETTER REH
(cl-define-keysym #x1000580 "Armenian_re") ;U+0580 ARMENIAN SMALL LETTER REH
(cl-define-keysym #x1000551 "Armenian_TSO") ;U+0551 ARMENIAN CAPITAL LETTER CO
(cl-define-keysym #x1000581 "Armenian_tso") ;U+0581 ARMENIAN SMALL LETTER CO
(cl-define-keysym #x1000552 "Armenian_VYUN") ;U+0552 ARMENIAN CAPITAL LETTER YIWN
(cl-define-keysym #x1000582 "Armenian_vyun") ;U+0582 ARMENIAN SMALL LETTER YIWN
(cl-define-keysym #x1000553 "Armenian_PYUR") ;U+0553 ARMENIAN CAPITAL LETTER PIWR
(cl-define-keysym #x1000583 "Armenian_pyur") ;U+0583 ARMENIAN SMALL LETTER PIWR
(cl-define-keysym #x1000554 "Armenian_KE") ;U+0554 ARMENIAN CAPITAL LETTER KEH
(cl-define-keysym #x1000584 "Armenian_ke") ;U+0584 ARMENIAN SMALL LETTER KEH
(cl-define-keysym #x1000555 "Armenian_O") ;U+0555 ARMENIAN CAPITAL LETTER OH
(cl-define-keysym #x1000585 "Armenian_o") ;U+0585 ARMENIAN SMALL LETTER OH
(cl-define-keysym #x1000556 "Armenian_FE") ;U+0556 ARMENIAN CAPITAL LETTER FEH
(cl-define-keysym #x1000586 "Armenian_fe") ;U+0586 ARMENIAN SMALL LETTER FEH
(cl-define-keysym #x100055a "Armenian_apostrophe") ;U+055A ARMENIAN APOSTROPHE
(cl-define-keysym #x10010d0 "Georgian_an") ;U+10D0 GEORGIAN LETTER AN
(cl-define-keysym #x10010d1 "Georgian_ban") ;U+10D1 GEORGIAN LETTER BAN
(cl-define-keysym #x10010d2 "Georgian_gan") ;U+10D2 GEORGIAN LETTER GAN
(cl-define-keysym #x10010d3 "Georgian_don") ;U+10D3 GEORGIAN LETTER DON
(cl-define-keysym #x10010d4 "Georgian_en") ;U+10D4 GEORGIAN LETTER EN
(cl-define-keysym #x10010d5 "Georgian_vin") ;U+10D5 GEORGIAN LETTER VIN
(cl-define-keysym #x10010d6 "Georgian_zen") ;U+10D6 GEORGIAN LETTER ZEN
(cl-define-keysym #x10010d7 "Georgian_tan") ;U+10D7 GEORGIAN LETTER TAN
(cl-define-keysym #x10010d8 "Georgian_in") ;U+10D8 GEORGIAN LETTER IN
(cl-define-keysym #x10010d9 "Georgian_kan") ;U+10D9 GEORGIAN LETTER KAN
(cl-define-keysym #x10010da "Georgian_las") ;U+10DA GEORGIAN LETTER LAS
(cl-define-keysym #x10010db "Georgian_man") ;U+10DB GEORGIAN LETTER MAN
(cl-define-keysym #x10010dc "Georgian_nar") ;U+10DC GEORGIAN LETTER NAR
(cl-define-keysym #x10010dd "Georgian_on") ;U+10DD GEORGIAN LETTER ON
(cl-define-keysym #x10010de "Georgian_par") ;U+10DE GEORGIAN LETTER PAR
(cl-define-keysym #x10010df "Georgian_zhar") ;U+10DF GEORGIAN LETTER ZHAR
(cl-define-keysym #x10010e0 "Georgian_rae") ;U+10E0 GEORGIAN LETTER RAE
(cl-define-keysym #x10010e1 "Georgian_san") ;U+10E1 GEORGIAN LETTER SAN
(cl-define-keysym #x10010e2 "Georgian_tar") ;U+10E2 GEORGIAN LETTER TAR
(cl-define-keysym #x10010e3 "Georgian_un") ;U+10E3 GEORGIAN LETTER UN
(cl-define-keysym #x10010e4 "Georgian_phar") ;U+10E4 GEORGIAN LETTER PHAR
(cl-define-keysym #x10010e5 "Georgian_khar") ;U+10E5 GEORGIAN LETTER KHAR
(cl-define-keysym #x10010e6 "Georgian_ghan") ;U+10E6 GEORGIAN LETTER GHAN
(cl-define-keysym #x10010e7 "Georgian_qar") ;U+10E7 GEORGIAN LETTER QAR
(cl-define-keysym #x10010e8 "Georgian_shin") ;U+10E8 GEORGIAN LETTER SHIN
(cl-define-keysym #x10010e9 "Georgian_chin") ;U+10E9 GEORGIAN LETTER CHIN
(cl-define-keysym #x10010ea "Georgian_can") ;U+10EA GEORGIAN LETTER CAN
(cl-define-keysym #x10010eb "Georgian_jil") ;U+10EB GEORGIAN LETTER JIL
(cl-define-keysym #x10010ec "Georgian_cil") ;U+10EC GEORGIAN LETTER CIL
(cl-define-keysym #x10010ed "Georgian_char") ;U+10ED GEORGIAN LETTER CHAR
(cl-define-keysym #x10010ee "Georgian_xan") ;U+10EE GEORGIAN LETTER XAN
(cl-define-keysym #x10010ef "Georgian_jhan") ;U+10EF GEORGIAN LETTER JHAN
(cl-define-keysym #x10010f0 "Georgian_hae") ;U+10F0 GEORGIAN LETTER HAE
(cl-define-keysym #x10010f1 "Georgian_he") ;U+10F1 GEORGIAN LETTER HE
(cl-define-keysym #x10010f2 "Georgian_hie") ;U+10F2 GEORGIAN LETTER HIE
(cl-define-keysym #x10010f3 "Georgian_we") ;U+10F3 GEORGIAN LETTER WE
(cl-define-keysym #x10010f4 "Georgian_har") ;U+10F4 GEORGIAN LETTER HAR
(cl-define-keysym #x10010f5 "Georgian_hoe") ;U+10F5 GEORGIAN LETTER HOE
(cl-define-keysym #x10010f6 "Georgian_fi") ;U+10F6 GEORGIAN LETTER FI
(cl-define-keysym #x1001e8a "Xabovedot") ;U+1E8A LATIN CAPITAL LETTER X WITH DOT ABOVE
(cl-define-keysym #x100012c "Ibreve") ;U+012C LATIN CAPITAL LETTER I WITH BREVE
(cl-define-keysym #x10001b5 "Zstroke") ;U+01B5 LATIN CAPITAL LETTER Z WITH STROKE
(cl-define-keysym #x10001e6 "Gcaron") ;U+01E6 LATIN CAPITAL LETTER G WITH CARON
(cl-define-keysym #x10001d1 "Ocaron") ;U+01D2 LATIN CAPITAL LETTER O WITH CARON
(cl-define-keysym #x100019f "Obarred") ;U+019F LATIN CAPITAL LETTER O WITH MIDDLE TILDE
(cl-define-keysym #x1001e8b "xabovedot") ;U+1E8B LATIN SMALL LETTER X WITH DOT ABOVE
(cl-define-keysym #x100012d "ibreve") ;U+012D LATIN SMALL LETTER I WITH BREVE
(cl-define-keysym #x10001b6 "zstroke") ;U+01B6 LATIN SMALL LETTER Z WITH STROKE
(cl-define-keysym #x10001e7 "gcaron") ;U+01E7 LATIN SMALL LETTER G WITH CARON
(cl-define-keysym #x10001d2 "ocaron") ;U+01D2 LATIN SMALL LETTER O WITH CARON
(cl-define-keysym #x1000275 "obarred") ;U+0275 LATIN SMALL LETTER BARRED O
(cl-define-keysym #x100018f "SCHWA") ;U+018F LATIN CAPITAL LETTER SCHWA
(cl-define-keysym #x1000259 "schwa") ;U+0259 LATIN SMALL LETTER SCHWA
(cl-define-keysym #x1001e36 "Lbelowdot") ;U+1E36 LATIN CAPITAL LETTER L WITH DOT BELOW
(cl-define-keysym #x1001e37 "lbelowdot") ;U+1E37 LATIN SMALL LETTER L WITH DOT BELOW
(cl-define-keysym #x1001ea0 "Abelowdot") ;U+1EA0 LATIN CAPITAL LETTER A WITH DOT BELOW
(cl-define-keysym #x1001ea1 "abelowdot") ;U+1EA1 LATIN SMALL LETTER A WITH DOT BELOW
(cl-define-keysym #x1001ea2 "Ahook") ;U+1EA2 LATIN CAPITAL LETTER A WITH HOOK ABOVE
(cl-define-keysym #x1001ea3 "ahook") ;U+1EA3 LATIN SMALL LETTER A WITH HOOK ABOVE
(cl-define-keysym #x1001ea4 "Acircumflexacute") ;U+1EA4 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE
(cl-define-keysym #x1001ea5 "acircumflexacute") ;U+1EA5 LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE
(cl-define-keysym #x1001ea6 "Acircumflexgrave") ;U+1EA6 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE
(cl-define-keysym #x1001ea7 "acircumflexgrave") ;U+1EA7 LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE
(cl-define-keysym #x1001ea8 "Acircumflexhook") ;U+1EA8 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE
(cl-define-keysym #x1001ea9 "acircumflexhook") ;U+1EA9 LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE
(cl-define-keysym #x1001eaa "Acircumflextilde") ;U+1EAA LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE
(cl-define-keysym #x1001eab "acircumflextilde") ;U+1EAB LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE
(cl-define-keysym #x1001eac "Acircumflexbelowdot") ;U+1EAC LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW
(cl-define-keysym #x1001ead "acircumflexbelowdot") ;U+1EAD LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW
(cl-define-keysym #x1001eae "Abreveacute") ;U+1EAE LATIN CAPITAL LETTER A WITH BREVE AND ACUTE
(cl-define-keysym #x1001eaf "abreveacute") ;U+1EAF LATIN SMALL LETTER A WITH BREVE AND ACUTE
(cl-define-keysym #x1001eb0 "Abrevegrave") ;U+1EB0 LATIN CAPITAL LETTER A WITH BREVE AND GRAVE
(cl-define-keysym #x1001eb1 "abrevegrave") ;U+1EB1 LATIN SMALL LETTER A WITH BREVE AND GRAVE
(cl-define-keysym #x1001eb2 "Abrevehook") ;U+1EB2 LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE
(cl-define-keysym #x1001eb3 "abrevehook") ;U+1EB3 LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE
(cl-define-keysym #x1001eb4 "Abrevetilde") ;U+1EB4 LATIN CAPITAL LETTER A WITH BREVE AND TILDE
(cl-define-keysym #x1001eb5 "abrevetilde") ;U+1EB5 LATIN SMALL LETTER A WITH BREVE AND TILDE
(cl-define-keysym #x1001eb6 "Abrevebelowdot") ;U+1EB6 LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW
(cl-define-keysym #x1001eb7 "abrevebelowdot") ;U+1EB7 LATIN SMALL LETTER A WITH BREVE AND DOT BELOW
(cl-define-keysym #x1001eb8 "Ebelowdot") ;U+1EB8 LATIN CAPITAL LETTER E WITH DOT BELOW
(cl-define-keysym #x1001eb9 "ebelowdot") ;U+1EB9 LATIN SMALL LETTER E WITH DOT BELOW
(cl-define-keysym #x1001eba "Ehook") ;U+1EBA LATIN CAPITAL LETTER E WITH HOOK ABOVE
(cl-define-keysym #x1001ebb "ehook") ;U+1EBB LATIN SMALL LETTER E WITH HOOK ABOVE
(cl-define-keysym #x1001ebc "Etilde") ;U+1EBC LATIN CAPITAL LETTER E WITH TILDE
(cl-define-keysym #x1001ebd "etilde") ;U+1EBD LATIN SMALL LETTER E WITH TILDE
(cl-define-keysym #x1001ebe "Ecircumflexacute") ;U+1EBE LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE
(cl-define-keysym #x1001ebf "ecircumflexacute") ;U+1EBF LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE
(cl-define-keysym #x1001ec0 "Ecircumflexgrave") ;U+1EC0 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE
(cl-define-keysym #x1001ec1 "ecircumflexgrave") ;U+1EC1 LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE
(cl-define-keysym #x1001ec2 "Ecircumflexhook") ;U+1EC2 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE
(cl-define-keysym #x1001ec3 "ecircumflexhook") ;U+1EC3 LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE
(cl-define-keysym #x1001ec4 "Ecircumflextilde") ;U+1EC4 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE
(cl-define-keysym #x1001ec5 "ecircumflextilde") ;U+1EC5 LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE
(cl-define-keysym #x1001ec6 "Ecircumflexbelowdot") ;U+1EC6 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW
(cl-define-keysym #x1001ec7 "ecircumflexbelowdot") ;U+1EC7 LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW
(cl-define-keysym #x1001ec8 "Ihook") ;U+1EC8 LATIN CAPITAL LETTER I WITH HOOK ABOVE
(cl-define-keysym #x1001ec9 "ihook") ;U+1EC9 LATIN SMALL LETTER I WITH HOOK ABOVE
(cl-define-keysym #x1001eca "Ibelowdot") ;U+1ECA LATIN CAPITAL LETTER I WITH DOT BELOW
(cl-define-keysym #x1001ecb "ibelowdot") ;U+1ECB LATIN SMALL LETTER I WITH DOT BELOW
(cl-define-keysym #x1001ecc "Obelowdot") ;U+1ECC LATIN CAPITAL LETTER O WITH DOT BELOW
(cl-define-keysym #x1001ecd "obelowdot") ;U+1ECD LATIN SMALL LETTER O WITH DOT BELOW
(cl-define-keysym #x1001ece "Ohook") ;U+1ECE LATIN CAPITAL LETTER O WITH HOOK ABOVE
(cl-define-keysym #x1001ecf "ohook") ;U+1ECF LATIN SMALL LETTER O WITH HOOK ABOVE
(cl-define-keysym #x1001ed0 "Ocircumflexacute") ;U+1ED0 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE
(cl-define-keysym #x1001ed1 "ocircumflexacute") ;U+1ED1 LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE
(cl-define-keysym #x1001ed2 "Ocircumflexgrave") ;U+1ED2 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE
(cl-define-keysym #x1001ed3 "ocircumflexgrave") ;U+1ED3 LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE
(cl-define-keysym #x1001ed4 "Ocircumflexhook") ;U+1ED4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE
(cl-define-keysym #x1001ed5 "ocircumflexhook") ;U+1ED5 LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE
(cl-define-keysym #x1001ed6 "Ocircumflextilde") ;U+1ED6 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE
(cl-define-keysym #x1001ed7 "ocircumflextilde") ;U+1ED7 LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE
(cl-define-keysym #x1001ed8 "Ocircumflexbelowdot") ;U+1ED8 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW
(cl-define-keysym #x1001ed9 "ocircumflexbelowdot") ;U+1ED9 LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW
(cl-define-keysym #x1001eda "Ohornacute") ;U+1EDA LATIN CAPITAL LETTER O WITH HORN AND ACUTE
(cl-define-keysym #x1001edb "ohornacute") ;U+1EDB LATIN SMALL LETTER O WITH HORN AND ACUTE
(cl-define-keysym #x1001edc "Ohorngrave") ;U+1EDC LATIN CAPITAL LETTER O WITH HORN AND GRAVE
(cl-define-keysym #x1001edd "ohorngrave") ;U+1EDD LATIN SMALL LETTER O WITH HORN AND GRAVE
(cl-define-keysym #x1001ede "Ohornhook") ;U+1EDE LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE
(cl-define-keysym #x1001edf "ohornhook") ;U+1EDF LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE
(cl-define-keysym #x1001ee0 "Ohorntilde") ;U+1EE0 LATIN CAPITAL LETTER O WITH HORN AND TILDE
(cl-define-keysym #x1001ee1 "ohorntilde") ;U+1EE1 LATIN SMALL LETTER O WITH HORN AND TILDE
(cl-define-keysym #x1001ee2 "Ohornbelowdot") ;U+1EE2 LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW
(cl-define-keysym #x1001ee3 "ohornbelowdot") ;U+1EE3 LATIN SMALL LETTER O WITH HORN AND DOT BELOW
(cl-define-keysym #x1001ee4 "Ubelowdot") ;U+1EE4 LATIN CAPITAL LETTER U WITH DOT BELOW
(cl-define-keysym #x1001ee5 "ubelowdot") ;U+1EE5 LATIN SMALL LETTER U WITH DOT BELOW
(cl-define-keysym #x1001ee6 "Uhook") ;U+1EE6 LATIN CAPITAL LETTER U WITH HOOK ABOVE
(cl-define-keysym #x1001ee7 "uhook") ;U+1EE7 LATIN SMALL LETTER U WITH HOOK ABOVE
(cl-define-keysym #x1001ee8 "Uhornacute") ;U+1EE8 LATIN CAPITAL LETTER U WITH HORN AND ACUTE
(cl-define-keysym #x1001ee9 "uhornacute") ;U+1EE9 LATIN SMALL LETTER U WITH HORN AND ACUTE
(cl-define-keysym #x1001eea "Uhorngrave") ;U+1EEA LATIN CAPITAL LETTER U WITH HORN AND GRAVE
(cl-define-keysym #x1001eeb "uhorngrave") ;U+1EEB LATIN SMALL LETTER U WITH HORN AND GRAVE
(cl-define-keysym #x1001eec "Uhornhook") ;U+1EEC LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE
(cl-define-keysym #x1001eed "uhornhook") ;U+1EED LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE
(cl-define-keysym #x1001eee "Uhorntilde") ;U+1EEE LATIN CAPITAL LETTER U WITH HORN AND TILDE
(cl-define-keysym #x1001eef "uhorntilde") ;U+1EEF LATIN SMALL LETTER U WITH HORN AND TILDE
(cl-define-keysym #x1001ef0 "Uhornbelowdot") ;U+1EF0 LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW
(cl-define-keysym #x1001ef1 "uhornbelowdot") ;U+1EF1 LATIN SMALL LETTER U WITH HORN AND DOT BELOW
(cl-define-keysym #x1001ef4 "Ybelowdot") ;U+1EF4 LATIN CAPITAL LETTER Y WITH DOT BELOW
(cl-define-keysym #x1001ef5 "ybelowdot") ;U+1EF5 LATIN SMALL LETTER Y WITH DOT BELOW
(cl-define-keysym #x1001ef6 "Yhook") ;U+1EF6 LATIN CAPITAL LETTER Y WITH HOOK ABOVE
(cl-define-keysym #x1001ef7 "yhook") ;U+1EF7 LATIN SMALL LETTER Y WITH HOOK ABOVE
(cl-define-keysym #x1001ef8 "Ytilde") ;U+1EF8 LATIN CAPITAL LETTER Y WITH TILDE
(cl-define-keysym #x1001ef9 "ytilde") ;U+1EF9 LATIN SMALL LETTER Y WITH TILDE
(cl-define-keysym #x10001a0 "Ohorn") ;U+01A0 LATIN CAPITAL LETTER O WITH HORN
(cl-define-keysym #x10001a1 "ohorn") ;U+01A1 LATIN SMALL LETTER O WITH HORN
(cl-define-keysym #x10001af "Uhorn") ;U+01AF LATIN CAPITAL LETTER U WITH HORN
(cl-define-keysym #x10001b0 "uhorn") ;U+01B0 LATIN SMALL LETTER U WITH HORN
(cl-define-keysym #x10020a0 "EcuSign") ;U+20A0 EURO-CURRENCY SIGN
(cl-define-keysym #x10020a1 "ColonSign") ;U+20A1 COLON SIGN
(cl-define-keysym #x10020a2 "CruzeiroSign") ;U+20A2 CRUZEIRO SIGN
(cl-define-keysym #x10020a3 "FFrancSign") ;U+20A3 FRENCH FRANC SIGN
(cl-define-keysym #x10020a4 "LiraSign") ;U+20A4 LIRA SIGN
(cl-define-keysym #x10020a5 "MillSign") ;U+20A5 MILL SIGN
(cl-define-keysym #x10020a6 "NairaSign") ;U+20A6 NAIRA SIGN
(cl-define-keysym #x10020a7 "PesetaSign") ;U+20A7 PESETA SIGN
(cl-define-keysym #x10020a8 "RupeeSign") ;U+20A8 RUPEE SIGN
(cl-define-keysym #x10020a9 "WonSign") ;U+20A9 WON SIGN
(cl-define-keysym #x10020aa "NewSheqelSign") ;U+20AA NEW SHEQEL SIGN
(cl-define-keysym #x10020ab "DongSign") ;U+20AB DONG SIGN
(cl-define-keysym #x20ac "EuroSign") ;U+20AC EURO SIGN
(cl-define-keysym #x1002070 "zerosuperior") ;U+2070 SUPERSCRIPT ZERO
(cl-define-keysym #x1002074 "foursuperior") ;U+2074 SUPERSCRIPT FOUR
(cl-define-keysym #x1002075 "fivesuperior") ;U+2075 SUPERSCRIPT FIVE
(cl-define-keysym #x1002076 "sixsuperior") ;U+2076 SUPERSCRIPT SIX
(cl-define-keysym #x1002077 "sevensuperior") ;U+2077 SUPERSCRIPT SEVEN
(cl-define-keysym #x1002078 "eightsuperior") ;U+2078 SUPERSCRIPT EIGHT
(cl-define-keysym #x1002079 "ninesuperior") ;U+2079 SUPERSCRIPT NINE
(cl-define-keysym #x1002080 "zerosubscript") ;U+2080 SUBSCRIPT ZERO
(cl-define-keysym #x1002081 "onesubscript") ;U+2081 SUBSCRIPT ONE
(cl-define-keysym #x1002082 "twosubscript") ;U+2082 SUBSCRIPT TWO
(cl-define-keysym #x1002083 "threesubscript") ;U+2083 SUBSCRIPT THREE
(cl-define-keysym #x1002084 "foursubscript") ;U+2084 SUBSCRIPT FOUR
(cl-define-keysym #x1002085 "fivesubscript") ;U+2085 SUBSCRIPT FIVE
(cl-define-keysym #x1002086 "sixsubscript") ;U+2086 SUBSCRIPT SIX
(cl-define-keysym #x1002087 "sevensubscript") ;U+2087 SUBSCRIPT SEVEN
(cl-define-keysym #x1002088 "eightsubscript") ;U+2088 SUBSCRIPT EIGHT
(cl-define-keysym #x1002089 "ninesubscript") ;U+2089 SUBSCRIPT NINE
(cl-define-keysym #x1002202 "partdifferential") ;U+2202 PARTIAL DIFFERENTIAL
(cl-define-keysym #x1002205 "emptyset") ;U+2205 NULL SET
(cl-define-keysym #x1002208 "elementof") ;U+2208 ELEMENT OF
(cl-define-keysym #x1002209 "notelementof") ;U+2209 NOT AN ELEMENT OF
(cl-define-keysym #x100220B "containsas") ;U+220B CONTAINS AS MEMBER
(cl-define-keysym #x100221A "squareroot") ;U+221A SQUARE ROOT
(cl-define-keysym #x100221B "cuberoot") ;U+221B CUBE ROOT
(cl-define-keysym #x100221C "fourthroot") ;U+221C FOURTH ROOT
(cl-define-keysym #x100222C "dintegral") ;U+222C DOUBLE INTEGRAL
(cl-define-keysym #x100222D "tintegral") ;U+222D TRIPLE INTEGRAL
(cl-define-keysym #x1002235 "because") ;U+2235 BECAUSE
(cl-define-keysym #x1002248 "approxeq") ;U+2245 ALMOST EQUAL TO
(cl-define-keysym #x1002247 "notapproxeq") ;U+2247 NOT ALMOST EQUAL TO
(cl-define-keysym #x1002262 "notidentical") ;U+2262 NOT IDENTICAL TO
(cl-define-keysym #x1002263 "stricteq") ;U+2263 STRICTLY EQUIVALENT TO
;; A bunch of extended keysyms
(cl-define-keysym #x100000A8 "hpmute_acute")
(cl-define-keysym #x100000A9 "hpmute_grave")
(cl-define-keysym #x100000AA "hpmute_asciicircum")
(cl-define-keysym #x100000AB "hpmute_diaeresis")
(cl-define-keysym #x100000AC "hpmute_asciitilde")
(cl-define-keysym #x100000AF "hplira")
(cl-define-keysym #x100000BE "hpguilder")
(cl-define-keysym #x100000EE "hpYdiaeresis")
(cl-define-keysym #x100000EE "hpIO")
(cl-define-keysym #x100000F6 "hplongminus")
(cl-define-keysym #x100000FC "hpblock")
(cl-define-keysym #x1000FF00 "apLineDel")
(cl-define-keysym #x1000FF01 "apCharDel")
(cl-define-keysym #x1000FF02 "apCopy")
(cl-define-keysym #x1000FF03 "apCut")
(cl-define-keysym #x1000FF04 "apPaste")
(cl-define-keysym #x1000FF05 "apMove")
(cl-define-keysym #x1000FF06 "apGrow")
(cl-define-keysym #x1000FF07 "apCmd")
(cl-define-keysym #x1000FF08 "apShell")
(cl-define-keysym #x1000FF09 "apLeftBar")
(cl-define-keysym #x1000FF0A "apRightBar")
(cl-define-keysym #x1000FF0B "apLeftBox")
(cl-define-keysym #x1000FF0C "apRightBox")
(cl-define-keysym #x1000FF0D "apUpBox")
(cl-define-keysym #x1000FF0E "apDownBox")
(cl-define-keysym #x1000FF0F "apPop")
(cl-define-keysym #x1000FF10 "apRead")
(cl-define-keysym #x1000FF11 "apEdit")
(cl-define-keysym #x1000FF12 "apSave")
(cl-define-keysym #x1000FF13 "apExit")
(cl-define-keysym #x1000FF14 "apRepeat")
(cl-define-keysym #x1000FF48 "hpModelock1")
(cl-define-keysym #x1000FF49 "hpModelock2")
(cl-define-keysym #x1000FF6C "hpReset")
(cl-define-keysym #x1000FF6D "hpSystem")
(cl-define-keysym #x1000FF6E "hpUser")
(cl-define-keysym #x1000FF6F "hpClearLine")
(cl-define-keysym #x1000FF70 "hpInsertLine")
(cl-define-keysym #x1000FF71 "hpDeleteLine")
(cl-define-keysym #x1000FF72 "hpInsertChar")
(cl-define-keysym #x1000FF73 "hpDeleteChar")
(cl-define-keysym #x1000FF74 "hpBackTab")
(cl-define-keysym #x1000FF75 "hpKP_BackTab")
(cl-define-keysym #x1000FFA8 "apKP_parenleft")
(cl-define-keysym #x1000FFA9 "apKP_parenright")
(cl-define-keysym #x10004001 "I2ND_FUNC_L")
(cl-define-keysym #x10004002 "I2ND_FUNC_R")
(cl-define-keysym #x10004003 "IREMOVE")
(cl-define-keysym #x10004004 "IREPEAT")
(cl-define-keysym #x10004101 "IA1")
(cl-define-keysym #x10004102 "IA2")
(cl-define-keysym #x10004103 "IA3")
(cl-define-keysym #x10004104 "IA4")
(cl-define-keysym #x10004105 "IA5")
(cl-define-keysym #x10004106 "IA6")
(cl-define-keysym #x10004107 "IA7")
(cl-define-keysym #x10004108 "IA8")
(cl-define-keysym #x10004109 "IA9")
(cl-define-keysym #x1000410A "IA10")
(cl-define-keysym #x1000410B "IA11")
(cl-define-keysym #x1000410C "IA12")
(cl-define-keysym #x1000410D "IA13")
(cl-define-keysym #x1000410E "IA14")
(cl-define-keysym #x1000410F "IA15")
(cl-define-keysym #x10004201 "IB1")
(cl-define-keysym #x10004202 "IB2")
(cl-define-keysym #x10004203 "IB3")
(cl-define-keysym #x10004204 "IB4")
(cl-define-keysym #x10004205 "IB5")
(cl-define-keysym #x10004206 "IB6")
(cl-define-keysym #x10004207 "IB7")
(cl-define-keysym #x10004208 "IB8")
(cl-define-keysym #x10004209 "IB9")
(cl-define-keysym #x1000420A "IB10")
(cl-define-keysym #x1000420B "IB11")
(cl-define-keysym #x1000420C "IB12")
(cl-define-keysym #x1000420D "IB13")
(cl-define-keysym #x1000420E "IB14")
(cl-define-keysym #x1000420F "IB15")
(cl-define-keysym #x10004210 "IB16")
(cl-define-keysym #x1000FF00 "DRemove")
(cl-define-keysym #x1000FEB0 "Dring_accent")
(cl-define-keysym #x1000FE5E "Dcircumflex_accent")
(cl-define-keysym #x1000FE2C "Dcedilla_accent")
(cl-define-keysym #x1000FE27 "Dacute_accent")
(cl-define-keysym #x1000FE60 "Dgrave_accent")
(cl-define-keysym #x1000FE7E "Dtilde")
(cl-define-keysym #x1000FE22 "Ddiaeresis")
(cl-define-keysym #x1004FF02 "osfCopy")
(cl-define-keysym #x1004FF03 "osfCut")
(cl-define-keysym #x1004FF04 "osfPaste")
(cl-define-keysym #x1004FF07 "osfBackTab")
(cl-define-keysym #x1004FF08 "osfBackSpace")
(cl-define-keysym #x1004FF0B "osfClear")
(cl-define-keysym #x1004FF1B "osfEscape")
(cl-define-keysym #x1004FF31 "osfAddMode")
(cl-define-keysym #x1004FF32 "osfPrimaryPaste")
(cl-define-keysym #x1004FF33 "osfQuickPaste")
(cl-define-keysym #x1004FF40 "osfPageLeft")
(cl-define-keysym #x1004FF41 "osfPageUp")
(cl-define-keysym #x1004FF42 "osfPageDown")
(cl-define-keysym #x1004FF43 "osfPageRight")
(cl-define-keysym #x1004FF44 "osfActivate")
(cl-define-keysym #x1004FF45 "osfMenuBar")
(cl-define-keysym #x1004FF51 "osfLeft")
(cl-define-keysym #x1004FF52 "osfUp")
(cl-define-keysym #x1004FF53 "osfRight")
(cl-define-keysym #x1004FF54 "osfDown")
(cl-define-keysym #x1004FF55 "osfPrior")
(cl-define-keysym #x1004FF56 "osfNext")
(cl-define-keysym #x1004FF57 "osfEndLine")
(cl-define-keysym #x1004FF58 "osfBeginLine")
(cl-define-keysym #x1004FF59 "osfEndData")
(cl-define-keysym #x1004FF5A "osfBeginData")
(cl-define-keysym #x1004FF5B "osfPrevMenu")
(cl-define-keysym #x1004FF5C "osfNextMenu")
(cl-define-keysym #x1004FF5D "osfPrevField")
(cl-define-keysym #x1004FF5E "osfNextField")
(cl-define-keysym #x1004FF60 "osfSelect")
(cl-define-keysym #x1004FF63 "osfInsert")
(cl-define-keysym #x1004FF65 "osfUndo")
(cl-define-keysym #x1004FF67 "osfMenu")
(cl-define-keysym #x1004FF69 "osfCancel")
(cl-define-keysym #x1004FF6A "osfHelp")
(cl-define-keysym #x1004FF71 "osfSelectAll")
(cl-define-keysym #x1004FF72 "osfDeselectAll")
(cl-define-keysym #x1004FF73 "osfReselect")
(cl-define-keysym #x1004FF74 "osfExtend")
(cl-define-keysym #x1004FF78 "osfRestore")
(cl-define-keysym #x1004FF7E "osfSwitchDirection")
(cl-define-keysym #x1004FFF5 "osfPriorMinor")
(cl-define-keysym #x1004FFF6 "osfNextMinor")
(cl-define-keysym #x1004FFF7 "osfRightLine")
(cl-define-keysym #x1004FFF8 "osfLeftLine")
(cl-define-keysym #x1004FFFF "osfDelete")
(cl-define-keysym #x1005FF00 "SunFA_Grave")
(cl-define-keysym #x1005FF01 "SunFA_Circum")
(cl-define-keysym #x1005FF02 "SunFA_Tilde")
(cl-define-keysym #x1005FF03 "SunFA_Acute")
(cl-define-keysym #x1005FF04 "SunFA_Diaeresis")
(cl-define-keysym #x1005FF05 "SunFA_Cedilla")
(cl-define-keysym #x1005FF10 "SunF36")
(cl-define-keysym #x1005FF11 "SunF37")
(cl-define-keysym #x1005FF60 "SunSys_Req")
(cl-define-keysym #x1005FF70 "SunProps")
(cl-define-keysym #x1005FF71 "SunFront")
(cl-define-keysym #x1005FF72 "SunCopy")
(cl-define-keysym #x1005FF73 "SunOpen")
(cl-define-keysym #x1005FF74 "SunPaste")
(cl-define-keysym #x1005FF75 "SunCut")
(cl-define-keysym #x1005FF76 "SunPowerSwitch")
(cl-define-keysym #x1005FF77 "SunAudioLowerVolume")
(cl-define-keysym #x1005FF78 "SunAudioMute")
(cl-define-keysym #x1005FF79 "SunAudioRaiseVolume")
(cl-define-keysym #x1005FF7A "SunVideoDegauss")
(cl-define-keysym #x1005FF7B "SunVideoLowerBrightness")
(cl-define-keysym #x1005FF7C "SunVideoRaiseBrightness")
(cl-define-keysym #x1005FF7D "SunPowerSwitchShift")
(cl-define-keysym #xFF20 "SunCompose")
(cl-define-keysym #xFF55 "SunPageUp")
(cl-define-keysym #xFF56 "SunPageDown")
(cl-define-keysym #xFF61 "SunPrint_Screen")
(cl-define-keysym #xFF65 "SunUndo")
(cl-define-keysym #xFF66 "SunAgain")
(cl-define-keysym #xFF68 "SunFind")
(cl-define-keysym #xFF69 "SunStop")
(cl-define-keysym #xFF7E "SunAltGraph")
(cl-define-keysym #x1006FF00 "WYSetup")
(cl-define-keysym #x1006FF00 "ncdSetup")
(cl-define-keysym #x10070001 "XeroxPointerButton1")
(cl-define-keysym #x10070002 "XeroxPointerButton2")
(cl-define-keysym #x10070003 "XeroxPointerButton3")
(cl-define-keysym #x10070004 "XeroxPointerButton4")
(cl-define-keysym #x10070005 "XeroxPointerButton5")
(cl-define-keysym #x1008FF01 "XF86ModeLock")
(cl-define-keysym #x1008FF10 "XF86Standby")
(cl-define-keysym #x1008FF11 "XF86AudioLowerVolume")
(cl-define-keysym #x1008FF12 "XF86AudioMute")
(cl-define-keysym #x1008FF13 "XF86AudioRaiseVolume")
(cl-define-keysym #x1008FF14 "XF86AudioPlay")
(cl-define-keysym #x1008FF15 "XF86AudioStop")
(cl-define-keysym #x1008FF16 "XF86AudioPrev")
(cl-define-keysym #x1008FF17 "XF86AudioNext")
(cl-define-keysym #x1008FF18 "XF86HomePage")
(cl-define-keysym #x1008FF19 "XF86Mail")
(cl-define-keysym #x1008FF1A "XF86Start")
(cl-define-keysym #x1008FF1B "XF86Search")
(cl-define-keysym #x1008FF1C "XF86AudioRecord")
(cl-define-keysym #x1008FF1D "XF86Calculator")
(cl-define-keysym #x1008FF1E "XF86Memo")
(cl-define-keysym #x1008FF1F "XF86ToDoList")
(cl-define-keysym #x1008FF20 "XF86Calendar")
(cl-define-keysym #x1008FF21 "XF86PowerDown")
(cl-define-keysym #x1008FF22 "XF86ContrastAdjust")
(cl-define-keysym #x1008FF23 "XF86RockerUp")
(cl-define-keysym #x1008FF24 "XF86RockerDown")
(cl-define-keysym #x1008FF25 "XF86RockerEnter")
(cl-define-keysym #x1008FF26 "XF86Back")
(cl-define-keysym #x1008FF27 "XF86Forward")
(cl-define-keysym #x1008FF28 "XF86Stop")
(cl-define-keysym #x1008FF29 "XF86Refresh")
(cl-define-keysym #x1008FF2A "XF86PowerOff")
(cl-define-keysym #x1008FF2B "XF86WakeUp")
(cl-define-keysym #x1008FF2C "XF86Eject")
(cl-define-keysym #x1008FF2D "XF86ScreenSaver")
(cl-define-keysym #x1008FF2E "XF86WWW")
(cl-define-keysym #x1008FF2F "XF86Sleep")
(cl-define-keysym #x1008FF30 "XF86Favorites")
(cl-define-keysym #x1008FF31 "XF86AudioPause")
(cl-define-keysym #x1008FF32 "XF86AudioMedia")
(cl-define-keysym #x1008FF33 "XF86MyComputer")
(cl-define-keysym #x1008FF34 "XF86VendorHome")
(cl-define-keysym #x1008FF35 "XF86LightBulb")
(cl-define-keysym #x1008FF36 "XF86Shop")
(cl-define-keysym #x1008FF37 "XF86History")
(cl-define-keysym #x1008FF38 "XF86OpenURL")
(cl-define-keysym #x1008FF39 "XF86AddFavorite")
(cl-define-keysym #x1008FF3A "XF86HotLinks")
(cl-define-keysym #x1008FF3B "XF86BrightnessAdjust")
(cl-define-keysym #x1008FF3C "XF86Finance")
(cl-define-keysym #x1008FF3D "XF86Community")
(cl-define-keysym #x1008FF3E "XF86AudioRewind")
(cl-define-keysym #x1008FF3F "XF86BackForward")
(cl-define-keysym #x1008FF40 "XF86Launch0")
(cl-define-keysym #x1008FF41 "XF86Launch1")
(cl-define-keysym #x1008FF42 "XF86Launch2")
(cl-define-keysym #x1008FF43 "XF86Launch3")
(cl-define-keysym #x1008FF44 "XF86Launch4")
(cl-define-keysym #x1008FF45 "XF86Launch5")
(cl-define-keysym #x1008FF46 "XF86Launch6")
(cl-define-keysym #x1008FF47 "XF86Launch7")
(cl-define-keysym #x1008FF48 "XF86Launch8")
(cl-define-keysym #x1008FF49 "XF86Launch9")
(cl-define-keysym #x1008FF4A "XF86LaunchA")
(cl-define-keysym #x1008FF4B "XF86LaunchB")
(cl-define-keysym #x1008FF4C "XF86LaunchC")
(cl-define-keysym #x1008FF4D "XF86LaunchD")
(cl-define-keysym #x1008FF4E "XF86LaunchE")
(cl-define-keysym #x1008FF4F "XF86LaunchF")
(cl-define-keysym #x1008FF50 "XF86ApplicationLeft")
(cl-define-keysym #x1008FF51 "XF86ApplicationRight")
(cl-define-keysym #x1008FF52 "XF86Book")
(cl-define-keysym #x1008FF53 "XF86CD")
(cl-define-keysym #x1008FF54 "XF86Calculater")
(cl-define-keysym #x1008FF55 "XF86Clear")
(cl-define-keysym #x1008FF56 "XF86Close")
(cl-define-keysym #x1008FF57 "XF86Copy")
(cl-define-keysym #x1008FF58 "XF86Cut")
(cl-define-keysym #x1008FF59 "XF86Display")
(cl-define-keysym #x1008FF5A "XF86DOS")
(cl-define-keysym #x1008FF5B "XF86Documents")
(cl-define-keysym #x1008FF5C "XF86Excel")
(cl-define-keysym #x1008FF5D "XF86Explorer")
(cl-define-keysym #x1008FF5E "XF86Game")
(cl-define-keysym #x1008FF5F "XF86Go")
(cl-define-keysym #x1008FF60 "XF86iTouch")
(cl-define-keysym #x1008FF61 "XF86LogOff")
(cl-define-keysym #x1008FF62 "XF86Market")
(cl-define-keysym #x1008FF63 "XF86Meeting")
(cl-define-keysym #x1008FF65 "XF86MenuKB")
(cl-define-keysym #x1008FF66 "XF86MenuPB")
(cl-define-keysym #x1008FF67 "XF86MySites")
(cl-define-keysym #x1008FF68 "XF86New")
(cl-define-keysym #x1008FF69 "XF86News")
(cl-define-keysym #x1008FF6A "XF86OfficeHome")
(cl-define-keysym #x1008FF6B "XF86Open")
(cl-define-keysym #x1008FF6C "XF86Option")
(cl-define-keysym #x1008FF6D "XF86Paste")
(cl-define-keysym #x1008FF6E "XF86Phone")
(cl-define-keysym #x1008FF70 "XF86Q")
(cl-define-keysym #x1008FF72 "XF86Reply")
(cl-define-keysym #x1008FF73 "XF86Reload")
(cl-define-keysym #x1008FF74 "XF86RotateWindows")
(cl-define-keysym #x1008FF75 "XF86RotationPB")
(cl-define-keysym #x1008FF76 "XF86RotationKB")
(cl-define-keysym #x1008FF77 "XF86Save")
(cl-define-keysym #x1008FF78 "XF86ScrollUp")
(cl-define-keysym #x1008FF79 "XF86ScrollDown")
(cl-define-keysym #x1008FF7A "XF86ScrollClick")
(cl-define-keysym #x1008FF7B "XF86Send")
(cl-define-keysym #x1008FF7C "XF86Spell")
(cl-define-keysym #x1008FF7D "XF86SplitScreen")
(cl-define-keysym #x1008FF7E "XF86Support")
(cl-define-keysym #x1008FF7F "XF86TaskPane")
(cl-define-keysym #x1008FF80 "XF86Terminal")
(cl-define-keysym #x1008FF81 "XF86Tools")
(cl-define-keysym #x1008FF82 "XF86Travel")
(cl-define-keysym #x1008FF84 "XF86UserPB")
(cl-define-keysym #x1008FF85 "XF86User1KB")
(cl-define-keysym #x1008FF86 "XF86User2KB")
(cl-define-keysym #x1008FF87 "XF86Video")
(cl-define-keysym #x1008FF88 "XF86WheelButton")
(cl-define-keysym #x1008FF89 "XF86Word")
(cl-define-keysym #x1008FF8A "XF86Xfer")
(cl-define-keysym #x1008FF8B "XF86ZoomIn")
(cl-define-keysym #x1008FF8C "XF86ZoomOut")
(cl-define-keysym #x1008FF8D "XF86Away")
(cl-define-keysym #x1008FF8E "XF86Messenger")
(cl-define-keysym #x1008FF8F "XF86WebCam")
(cl-define-keysym #x1008FF90 "XF86MailForward")
(cl-define-keysym #x1008FF91 "XF86Pictures")
(cl-define-keysym #x1008FF92 "XF86Music")
(cl-define-keysym #x1008FE01 "XF86_Switch_VT_1")
(cl-define-keysym #x1008FE02 "XF86_Switch_VT_2")
(cl-define-keysym #x1008FE03 "XF86_Switch_VT_3")
(cl-define-keysym #x1008FE04 "XF86_Switch_VT_4")
(cl-define-keysym #x1008FE05 "XF86_Switch_VT_5")
(cl-define-keysym #x1008FE06 "XF86_Switch_VT_6")
(cl-define-keysym #x1008FE07 "XF86_Switch_VT_7")
(cl-define-keysym #x1008FE08 "XF86_Switch_VT_8")
(cl-define-keysym #x1008FE09 "XF86_Switch_VT_9")
(cl-define-keysym #x1008FE0A "XF86_Switch_VT_10")
(cl-define-keysym #x1008FE0B "XF86_Switch_VT_11")
(cl-define-keysym #x1008FE0C "XF86_Switch_VT_12")
(cl-define-keysym #x1008FE20 "XF86_Ungrab")
(cl-define-keysym #x1008FE21 "XF86_ClearGrab")
(cl-define-keysym #x1008FE22 "XF86_Next_VMode")
(cl-define-keysym #x1008FE23 "XF86_Prev_VMode")
(cl-define-keysym #x100000A8 "usldead_acute")
(cl-define-keysym #x100000A9 "usldead_grave")
(cl-define-keysym #x100000AB "usldead_diaeresis")
(cl-define-keysym #x100000AA "usldead_asciicircum")
(cl-define-keysym #x100000AC "usldead_asciitilde")
(cl-define-keysym #x1000FE2C "usldead_cedilla")
(cl-define-keysym #x1000FEB0 "usldead_ring")
;; For convenience
(cl-define-keysym #xff55 "Page_Up")
(cl-define-keysym #xff56 "Page_Down")
| 129,298 | Common Lisp | .lisp | 2,055 | 61.889538 | 115 | 0.761088 | thijs/clfswm-old | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 43a7ef77a7f998854d2740a3916af0c4c615bf0d8fa290adbee41abdfdc6c6a1 | 22,201 | [
-1
] |
22,218 | clfswm.asd | thijs_clfswm-old/clfswm.asd | ;;;; -*- Mode: Lisp -*-
;;;; Author: Philippe Brochard <[email protected]>
;;;; ASDF System Definition
;;;
;;;; Modified (2016) by M.L. Oppermann <[email protected]>
;;;
(in-package #:cl-user)
(defpackage #:clfswm-asd
(:export #:*base-directory*)
(:use :cl :asdf))
(defparameter clfswm-asd:*base-directory*
(make-pathname :name nil :type nil :defaults *load-truename*))
(in-package #:clfswm-asd)
(defparameter *clfswm-version* "16??.?"
"This version of clfswm.")
(export '*clfswm-version*)
(defsystem #:clfswm
:name "CLFSWM"
:description "CLFSWM: Fullscreen Window Manager"
:version #.*clfswm-version*
:author "Philippe Brochard <[email protected]>"
:licence "GNU Public License (GPL)"
:components ((:module "src"
:components
((:file "tools")
(:file "my-html"
:depends-on ("tools"))
(:file "package"
:depends-on ("my-html"
"tools"))
(:file "keysyms"
:depends-on ("package"))
(:file "xlib-util"
:depends-on ("package"
"keysyms"
"tools"))
(:file "config"
:depends-on ("package"
"xlib-util"))
(:file "netwm-util"
:depends-on ("package"
"xlib-util"))
(:file "clfswm-keys"
:depends-on ("package"
"config"
"xlib-util"
"keysyms"))
(:file "clfswm-autodoc"
:depends-on ("package"
"clfswm-keys"
"my-html"
"tools"
"config"))
(:file "clfswm-internal"
:depends-on ("xlib-util"
"clfswm-keys"
"netwm-util"
"tools"
"config"))
(:file "clfswm-placement"
:depends-on ("package"
"clfswm-internal"))
(:file "clfswm-generic-mode"
:depends-on ("package"
"tools"
"xlib-util"
"clfswm-internal"))
(:file "clfswm-query"
:depends-on ("package"
"config"
"xlib-util"
"clfswm-keys"
"clfswm-generic-mode"
"clfswm-placement"))
(:file "clfswm-circulate-mode"
:depends-on ("xlib-util"
"clfswm-keys"
"clfswm-generic-mode"
"clfswm-internal"
"netwm-util"
"tools"
"config"
"clfswm-placement"))
(:file "clfswm"
:depends-on ("xlib-util"
"netwm-util"
"clfswm-keys"
"config"
"clfswm-internal"
"clfswm-circulate-mode"
"tools"))
(:file "clfswm-second-mode"
:depends-on ("package"
"clfswm"
"clfswm-internal"
"clfswm-generic-mode"
"clfswm-placement"))
(:file "clfswm-expose-mode"
:depends-on ("package"
"config"
"clfswm-internal"
"xlib-util"
"tools"
"clfswm-keys"
"clfswm-generic-mode"
"clfswm-placement"
"clfswm-query"))
(:file "clfswm-fastswitch-mode"
:depends-on ("package"
"config"
"clfswm-internal"
"xlib-util"
"tools"
"clfswm-keys"
"clfswm-generic-mode"
"clfswm-placement"
"clfswm-expose-mode"))
(:file "clfswm-corner"
:depends-on ("package"
"config"
"clfswm-internal"
"clfswm-expose-mode"
"xlib-util"))
(:file "clfswm-info"
:depends-on ("package"
"xlib-util"
"config"
"clfswm-keys"
"clfswm"
"clfswm-internal"
"clfswm-autodoc"
"clfswm-corner"
"clfswm-generic-mode"
"clfswm-placement"))
(:file "clfswm-menu"
:depends-on ("package"
"clfswm-info"))
(:file "clfswm-util"
:depends-on ("clfswm"
"keysyms"
"clfswm-info"
"clfswm-second-mode"
"clfswm-query"
"clfswm-menu"
"clfswm-autodoc"
"clfswm-corner"
"clfswm-placement"
"tools"))
(:file "clfswm-configuration"
:depends-on ("package"
"config"
"clfswm-internal"
"clfswm-util"
"clfswm-query"
"clfswm-menu"))
(:file "menu-def"
:depends-on ("clfswm-menu"
"clfswm-configuration"
"clfswm"
"clfswm-util"
"clfswm-info"))
(:file "clfswm-layout"
:depends-on ("package"
"clfswm-internal"
"clfswm-util"
"clfswm-info"
"menu-def"))
(:file "clfswm-pack"
:depends-on ("clfswm"
"xlib-util"
"clfswm-util"
"clfswm-second-mode"
"clfswm-layout"))
(:file "clfswm-nw-hooks"
:depends-on ("package"
"clfswm-util"
"clfswm-info"
"clfswm-layout"
"menu-def"))
(:file "bindings"
:depends-on ("clfswm"
"clfswm-internal"
"clfswm-util"
"clfswm-menu"))
(:file "bindings-second-mode"
:depends-on ("clfswm"
"clfswm-util"
"clfswm-query"
"bindings"
"clfswm-pack"
"clfswm-menu"
"menu-def"
"clfswm-layout")))))
:depends-on (#-:CLX
:clx
#+:sbcl :sb-posix))
| 10,463 | Common Lisp | .asd | 196 | 17.969388 | 68 | 0.251511 | thijs/clfswm-old | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | debc1bdca3ee20122e275afd686a3579aee6d6660535689f972029ef4cda9f83 | 22,218 | [
-1
] |
22,292 | movie.lisp | sgarciac_gordon/movie.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
(genclass movie-info (swf-movie-object)
((length 0 integer)
(xsize 100 integer)
(ysize 100 integer)
(frame-rate 10 integer)
(frames-counter 0 integer)
))
(genclass movie ()
((frames-counter 0 integer)
(stream 0 stream)
))
(defgeneric add-to-movie (movie object)
(:documentation
"The generic function which oversees adding an object to a movie."))
;;; Marshall a movie info
(defmethod marshall ((movie-info movie-info))
(xappend
(i2ui8 (char-code #\F)) ;F
(i2ui8 (char-code #\W)) ;W
(i2ui8 (char-code #\S)) ;S
(i2ui8 *flash-version*) ; version
(i2ui32 (movie-info-length movie-info))
(marshall (make-instance 'rect :xmin 0 :ymin 0
:xmax (movie-info-xsize movie-info)
:ymax (movie-info-ysize movie-info)))
(i2ui8 0) ; this byte is ignored
(i2ui8 (movie-info-frame-rate movie-info)) ; rate
(i2ui16 (movie-info-frames-counter movie-info)) ; number of frames
))
(defmethod add-to-movie ((movie movie) (object tag))
(write-sequence (flat-marshall-data (marshall object))
(movie-stream movie)))
(defmethod add-to-movie ((movie movie) (object tag-showframe))
(incf (movie-frames-counter movie))
(write-sequence (flat-marshall-data (marshall object))
(movie-stream movie)))
(defmethod add-to-movie ((movie movie) (stream stream))
(loop with buffer = (make-array 500)
for read-counter = (read-sequence buffer stream) then
(read-sequence buffer stream) while (not (zerop read-counter))
do (write-sequence buffer (movie-stream movie)
:start 0
:end read-counter)))
(defun add-shape (m id depth shape x y)
(add-to-movie m (make-instance 'tag-define-shape
:id id
:shape shape))
(add-to-movie m (make-instance 'tag-place-object2
:depth depth
:id id
:matrix (make-instance 'matrix
:translate-x x
:translate-y y))))
(defmacro with-movie
((varname filename &key (frame-rate 12) (width 10000) (height 10000)
(bgcolor nil) (debug nil)) &body body)
(with-gensyms (outputstream movie-info movie-length)
`(with-open-file (,outputstream ,filename
:direction :output
:if-exists :supersede
:element-type '(unsigned-byte 8))
(let ((,varname
(make-instance
'movie :stream ,outputstream
))
(,movie-info
(make-instance
'movie-info :xsize ,width
:ysize ,height
:frame-rate ,frame-rate)))
(write-sequence
(flat-marshall-data (marshall ,movie-info))
(movie-stream ,varname))
,@(if bgcolor `((add-to-movie
,varname
(make-instance 'tag-SBC :bgcolor ,bgcolor))))
,@(if debug `((add-to-movie
,varname
(make-instance 'tag-enable-debugger2))))
,@body
(let ((,movie-length (file-position (movie-stream ,varname))))
(file-position (movie-stream ,varname) 0)
(setf (movie-info-frames-counter ,movie-info)
(movie-frames-counter ,varname))
(setf (movie-info-length ,movie-info)
,movie-length)
(write-sequence
(flat-marshall-data (marshall ,movie-info))
(movie-stream ,varname))
)))))
| 3,920 | Common Lisp | .lisp | 106 | 32.650943 | 79 | 0.684405 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 084c1997a7fbaab7b334c2b139796c90d2110e0f6f2a58bc588c0864dfc9419d | 22,292 | [
-1
] |
22,293 | types.lisp | sgarciac_gordon/types.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
;;;; Structures of "higher" SWF types
(genclass color (swf-movie-object)() "The superclass for all swf colors")
(genclass shape-record ()() "The superclass for all shape records.")
(genclass shape
(swf-movie-object)
((records ()(or list null)))
"The superclass for all swf shapes")
(genclass rect
(swf-movie-object)
((xmin 0 integer)
(xmax 0 integer)
(ymin 0 integer)
(ymax 0 integer))
"The basic construct for rectangles consisting of four integer coordinates. This is not a swf shape in that it doesn't contain shape-records.")
(genclass rgb
(color)
((r 0 integer)
(g 0 integer)
(b 0 integer))
"The basic construct for color representation consisting of three color values (red, green, and blue).")
(genclass rgba
(rgb)
((a 0 integer))
"The basic construct for color representation consisting of three colors (red, green, and blue) and an alpha channel.")
;; color transformation with alpha
(genclass cxform-wa
(swf-movie-object)
((rmult 1.0 float)
(gmult 1.0 float)
(bmult 1.0 float)
(amult 1.0 float)
(radd 0 integer)
(gadd 0 integer)
(badd 0 integer)
(aadd 0 integer))
"The basic construct for transforming colors by multiples or integer values.")
(defmethod cxform-has-mult ((cx cxform-wa))
(not (and (= (cxform-wa-rmult cx) 1)
(= (cxform-wa-gmult cx) 1)
(= (cxform-wa-bmult cx) 1)
(= (cxform-wa-amult cx) 1))))
(defmethod cxform-has-add ((cx cxform-wa))
(not (and (zerop (cxform-wa-radd cx))
(zerop (cxform-wa-gadd cx))
(zerop (cxform-wa-badd cx))
(zerop (cxform-wa-aadd cx)))))
(defmethod marshall ((cx cxform-wa))
(let ((hm (cxform-has-mult cx))
(hd (cxform-has-add cx)))
(xappend
(bif hd)
(bif hm)
(when (or hm hd)
(is2besbitawithmax
(append
(when hm (mapcar (lambda (n) (floor (* 256 n)))
`(,(cxform-wa-rmult cx)
,(cxform-wa-gmult cx)
,(cxform-wa-bmult cx)
,(cxform-wa-amult cx))))
(when hd `(,(cxform-wa-radd cx)
,(cxform-wa-gadd cx)
,(cxform-wa-badd cx)
,(cxform-wa-aadd cx))))
4)))))
(genclass matrix
(swf-movie-object)
((scale-x 1.0 float)
(scale-y 1.0 float)
(rotate-skew-0 0.0 float)
(rotate-skew-1 0.0 float)
(translate-x 0 integer)
(translate-y 0 integer))
"A two dimensional matrix which can be scaled, skewed, or translated in both x and y directions.")
(genclass gradient-record
(swf-movie-object)
((ratio 1 integer)
(color (make-instance 'rgb) color))
"An individual record of color for use in the description of a color gradient.")
(genclass gradient
(swf-movie-object)
((record-list () list))
"A description of a gradient color pattern.")
; Shape styles
(genclass fillstyle
(swf-movie-object)
((type *solid-fill* integer)
(color nil (or color null))
(gradient-matrix nil (or matrix null))
(gradient nil (or gradient null))
(bitmap-id nil (or integer null))
(bitmap-matrix nil (or matrix null)))
"A description of how a shaped is filled. Colors, color gradients, and bitmaps can be used in this description.")
(genclass linestyle
(swf-movie-object)
((width 1 integer)
(color nil (or color null)))
"A description of how a line is rendered. The line width and color are part of this description.")
(genclass fillstyle-array
(swf-movie-object)
((styles () list))
"A container for fillstyles.")
(genclass linestyle-array
(swf-movie-object)
((styles () list))
"A container for linestyles.")
(genclass style-change-record
(shape-record)
((delta-x 0 integer)
(delta-y 0 integer)
(fillstyle0 nil (or null integer))
(fillstyle1 nil (or null integer))
(linestyle nil (or null integer)))
"A record used to indicate a style change either in x/y position, fillstyle or linestyle.")
(genclass straight-edge-record
(shape-record)
((delta-x 0 integer)
(delta-y 0 integer))
"A record representing the coordinates used in a straight line.")
(genclass curved-edge-record
(shape-record)
((control-delta-x 0 integer)
(control-delta-y 0 integer)
(anchor-delta-x 0 integer)
(anchor-delta-y 0 integer))
"A record representing the coordinates used in a curved line.")
(genclass end-record
(shape-record)
()
"The closing record.")
(genclass shape-with-style
(shape)
((fillstyles nil (or fillstyle-array null))
(linestyles nil (or linestyle-array null)))
"A description of a shape which includes fillstyle and linestyle descriptions.")
(genclass button-record
(swf-movie-object)
((test-hit)
(state-down)
(state-over)
(state-up)
(character-id)
(depth)
(place-matrix nil matrix)
(color-transform nil cxform-wa))
"A record describing one aspect of a button.")
(defgeneric calculate-shape-bounds (shape)
(:documentation "Calculate the minimum rectangle (with sides parallel to the axis) that contains a shape. This is used by the DEFINE SHAPE TAG. If no rectangle is defined, the refresh may fail."))
(genclass xy-accum
()
((x 0 integer)
(y 0 integer))
"A helper class used for accumulating bounds information.")
(defgeneric calculate-shape-record-bounds (record rect xy-accum)
(:documentation "A helper function to calculate a shape record's bounds."))
(defmethod calculate-shape-bounds ((shape shape))
(let ((bounds (make-instance 'rect))
(accum (make-instance 'xy-accum)))
(dolist (record (shape-records shape) bounds)
(calculate-shape-record-bounds record bounds accum))))
(defmethod calculate-shape-record-bounds ((record style-change-record)
(rect rect)
(accum xy-accum))
(with-slots (x y) accum
(with-slots (xmin xmax ymin ymax) rect
(setf x (+ x (style-change-record-delta-x record)))
(setf y (+ y (style-change-record-delta-y record)))
(setf xmin (min x xmin))
(setf xmax (max x xmax))
(setf ymin (min y ymin))
(setf ymax (max y ymax)))))
(defmethod calculate-shape-record-bounds ((record straight-edge-record)
(rect rect)
(accum xy-accum))
(with-slots (x y) accum
(with-slots (xmin xmax ymin ymax) rect
(setf x (+ x (straight-edge-record-delta-x record)))
(setf y (+ y (straight-edge-record-delta-y record)))
(setf xmin (min x xmin))
(setf xmax (max x xmax))
(setf ymin (min y ymin))
(setf ymax (max y ymax)))))
(defmethod calculate-shape-record-bounds ((record curved-edge-record)
(rect rect)
(accum xy-accum))
(with-slots (x y) accum
(with-slots (xmin xmax ymin ymax) rect
(let ((ix (+ x (curved-edge-record-control-delta-x record)))
(iy (+ y (curved-edge-record-control-delta-y record))))
(setf x (+ ix (curved-edge-record-anchor-delta-x record)))
(setf y (+ iy (curved-edge-record-anchor-delta-y record)))
(setf xmin (min x ix xmin))
(setf xmax (max x ix xmax))
(setf ymin (min y iy ymin))
(setf ymax (max y iy ymax))))))
;;;; Multiply transformation matrix
(defun make-rotation-matrix-angle (angle)
(make-instance 'matrix
:scale-x (cos angle)
:scale-y (cos angle)
:rotate-skew-0 (* -1 (sin angle))
:rotate-skew-1 (sin angle)))
(defun +-matrix (matrix1 matrix2)
(make-instance 'matrix
:scale-x (+ (matrix-scale-x matrix1) (matrix-scale-x matrix2))
:scale-y (+ (matrix-scale-y matrix1) (matrix-scale-y matrix2))
:rotate-skew-0 (+ (matrix-rotate-skew-0 matrix1) (matrix-rotate-skew-0 matrix2))
:rotate-skew-1 (+ (matrix-rotate-skew-1 matrix1) (matrix-rotate-skew-1 matrix2))
:translate-x (+ (matrix-translate-x matrix1) (matrix-translate-x matrix2))
:translate-y (+ (matrix-translate-y matrix1) (matrix-translate-y matrix2))))
(defun *-matrix (matrix1 matrix2)
(make-instance 'matrix
:scale-x (+ (* (matrix-scale-x matrix1) (matrix-scale-x matrix2))
(* (matrix-rotate-skew-0 matrix1) (matrix-rotate-skew-1 matrix2)))
:scale-y (+ (* (matrix-rotate-skew-1 matrix1) (matrix-rotate-skew-0 matrix2))
(* (matrix-scale-y matrix1) (matrix-scale-y matrix2)))
:rotate-skew-0 (+ (* (matrix-scale-x matrix1) (matrix-rotate-skew-0 matrix2))
(* (matrix-rotate-skew-0 matrix1) (matrix-scale-y matrix2)))
:rotate-skew-1 (+ (* (matrix-rotate-skew-1 matrix1) (matrix-scale-x matrix2))
(* (matrix-scale-x matrix1) (matrix-scale-y matrix2)))
:translate-x (floor (+ (* (matrix-scale-x matrix1) (matrix-translate-x matrix2))
(* (matrix-rotate-skew-0 matrix1) (matrix-translate-y matrix2))
(matrix-translate-x matrix1)))
:translate-y (floor (+ (* (matrix-scale-y matrix1) (matrix-translate-y matrix2))
(* (matrix-rotate-skew-1 matrix1) (matrix-translate-x matrix2))
(matrix-translate-y matrix1)))))
;;;;
;;;; Marshalling of SWF objects
;;;; the type returned for all marshall functions is
;;;; a list that contains byte arrays and bit arrays
;;;;
;;; this functions takes a list that represents marshalled data, and
;;; returns the corresponsing SWF byte array, byte-aligned
(defun flat-marshall-data (md)
(apply #'concba (nreverse
(reduce #'push-val (xappend md (list *empty-ba*)) :initial-value '())
)))
;(defun push-val (lst val)
; (cond ((typep (car lst) '(or null byte-array)) (push val lst))
; ((and (typep (car lst) 'bit-array) (typep val 'bit-array))
; (push-val (cdr lst) (concbita (car lst) val)))
; ((and (typep (car lst) 'bit-array) (typep val 'byte-array))
; (push-val (cdr lst) (concba (bita2beba (car lst)) val)))
; (t (error (format nil "unrecognized type ~A ~A " (type-of (car lst)) (type-of val))))))
(defun push-val (lst val)
(cond ((typep (car lst) '(or null byte-array)) (push val lst))
((and (typep (car lst) 'bit-array) (typep val 'bit-array))
(let ((ato (concbita (pop lst) val)))
(push-val lst ato)))
((and (typep (car lst) 'bit-array) (typep val 'byte-array))
(let ((ato (bita2beba (pop lst))))
(push-val lst (concba ato val))))
(t (error (format nil "unrecognized type ~A ~A " (type-of (car lst)) (type-of val))))))
(defmethod marshall ((rect rect))
(xappend (is2besbitawithmax
`(,(rect-xmin rect)
,(rect-xmax rect)
,(rect-ymin rect)
,(rect-ymax rect))
5)))
(defmethod marshall ((col rgb))
(xappend (i2ui8 (rgb-r col))
(i2ui8 (rgb-g col))
(i2ui8 (rgb-b col))))
(defmethod marshall ((col rgba))
(xappend (call-next-method)
(i2ui8 (rgba-a col))))
(defmethod marshall ((gr gradient-record))
(xappend (i2ui8 (gradient-record-ratio gr))
(marshall (gradient-record-color gr))))
(defmethod marshall ((g gradient))
(apply #'xappend (i2ui8 (length (gradient-record-list g)))
`(,@(mapcar #'marshall (gradient-record-list g)))))
(defmethod marshall ((br button-record))
(xappend
(i2ubita 0 4)
(bif (button-record-test-hit br))
(bif (button-record-state-down br))
(bif (button-record-state-over br))
(bif (button-record-state-up br))
(i2ui16 (button-record-character-id br))
(i2ui16 (button-record-depth br))
(marshall (button-record-place-matrix br))
*empty-ba*
(marshall (button-record-color-transform br))
*empty-ba*))
(defmethod marshall ((fs fillstyle))
(xappend
(i2ui8 (fillstyle-type fs))
(if (= (fillstyle-type fs) *solid-fill*)
(if (fillstyle-color fs)
(marshall (fillstyle-color fs)))
*empty-ba*)
(if (or (= (fillstyle-type fs) *linear-gradient-fill*)
(= (fillstyle-type fs) *radial-gradient-fill*))
(xappend (marshall (fillstyle-gradient-matrix fs))
(marshall (fillstyle-gradient fs)))
(xappend *empty-bita* *empty-ba*))
(if (find (fillstyle-type fs) `(,*repeating-bitmap-fill*
,*clipped-bitmap-fill*
,*non-smoothed-repeating-bitmap*
,*non-smoothed-clipped-bitmap*))
(xappend (i2ui16 (fillstyle-bitmap-id fs))
(marshall (fillstyle-bitmap-matrix fs))
*empty-ba*)
(xappend *empty-bita* *empty-ba*))))
(defmethod marshall ((fa fillstyle-array))
(let ((styles (fillstyle-array-styles fa)))
(xappend
(if (< (length styles) 255)
(i2ui8 (length styles))
(xappend (i2ui8 255) (i2ui16 (length styles))))
(apply #'xappend
(mapcar #'(lambda (x)(marshall x)) styles)))))
(defmethod marshall ((ls linestyle))
(xappend (i2ui16 (linestyle-width ls))
(if (linestyle-color ls)
(marshall (linestyle-color ls)))))
(defmethod marshall ((la linestyle-array))
(let ((styles (linestyle-array-styles la)))
(xappend
(if (< (length styles) 255)
(i2ui8 (length styles))
(xappend (i2ui8 255) (i2ui16 (length styles))))
(apply #'xappend
(mapcar #'(lambda (x)(marshall x)) styles)))))
;;; marshall a matrix
(defmethod matrix-has-scale ((m matrix))
(not (= 1 (matrix-scale-x m) (matrix-scale-y m))))
(defmethod matrix-has-rotation ((m matrix))
(not (= 0 (matrix-rotate-skew-1 m) (matrix-rotate-skew-0 m))))
(defmethod matrix-has-translation ((m matrix))
(not (= 0 (matrix-translate-x m) (matrix-translate-y m))))
(defmethod marshall ((m matrix))
(xappend
(if (matrix-has-scale m)
(xappend *yes-bit*
(fs2besbitawithmax
`(,(matrix-scale-x m)
,(matrix-scale-y m)) 5))
*no-bit*)
(if (matrix-has-rotation m)
(xappend *yes-bit*
(fs2besbitawithmax
`(,(matrix-rotate-skew-0 m)
,(matrix-rotate-skew-1 m)) 5))
*no-bit*)
;;(if (matrix-has-translation m)
;; (xappend *yes-bit*
(is2besbitawithmax
`(,(matrix-translate-x m)
,(matrix-translate-y m)) 5)))
;; *no-bit*)))
;;; shapes marshalling
(defun style-change-record-has-delta (sc)
(or
(not (zerop (style-change-record-delta-x sc)))
(not (zerop (style-change-record-delta-y sc)))))
(defmethod marshall ((sr style-change-record))
(xappend
*no-bit* ;no edge
*no-bit* ;no new styles
(bif (style-change-record-linestyle sr))
(bif (style-change-record-fillstyle1 sr))
(bif (style-change-record-fillstyle0 sr))
(if (style-change-record-has-delta sr)
(xappend *yes-bit*
(is2besbitawithmax `(,(style-change-record-delta-x sr)
,(style-change-record-delta-y sr))
5))
*no-bit*)
(when (style-change-record-fillstyle0 sr)
(i2ubita (style-change-record-fillstyle0 sr) *fillbits*))
(when (style-change-record-fillstyle1 sr)
(i2ubita (style-change-record-fillstyle1 sr) *fillbits*))
(when (style-change-record-linestyle sr)
(i2ubita (style-change-record-linestyle sr) *linebits*))))
(defmethod marshall ((end-record end-record))
(declare (ignore end-record))
(xappend
*no-bit*
(i2ubita 0 5)))
(defmethod marshall ((er curved-edge-record))
(let ((neededsize (max
(needsize (curved-edge-record-control-delta-x er) t)
(needsize (curved-edge-record-control-delta-y er) t)
(needsize (curved-edge-record-anchor-delta-x er) t)
(needsize (curved-edge-record-anchor-delta-y er) t))))
(xappend
*yes-bit* ;edge
*no-bit* ;not straight
(i2ubita (- neededsize 2) 4)
(i2sbita (curved-edge-record-control-delta-x er) neededsize)
(i2sbita (curved-edge-record-control-delta-y er) neededsize)
(i2sbita (curved-edge-record-anchor-delta-x er) neededsize)
(i2sbita (curved-edge-record-anchor-delta-y er) neededsize))))
(defmethod marshall ((er straight-edge-record))
(let ((neededsize (max
2
(needsize (straight-edge-record-delta-x er) t)
(needsize (straight-edge-record-delta-y er) t))))
(xappend
*yes-bit* ;edge record
*yes-bit* ;straight
(i2ubita (- neededsize 2) 4)
(cond ((not (or (zerop (straight-edge-record-delta-x er))
(zerop (straight-edge-record-delta-y er))))
(xappend
*yes-bit*
(i2sbita (straight-edge-record-delta-x er) neededsize)
(i2sbita (straight-edge-record-delta-y er) neededsize)))
((zerop (straight-edge-record-delta-x er))
(xappend
*no-bit*
*yes-bit*
(i2sbita (straight-edge-record-delta-y er) neededsize)))
(t
(xappend
*no-bit*
*no-bit*
(i2sbita (straight-edge-record-delta-x er) neededsize)))))))
(defmethod marshall ((shp shape))
(let* ((*fillbits* (needsize 1 nil))
(*linebits* (needsize 1 nil)))
(declare (special *fillbits* *linebits*))
(xappend
(i2ubita *fillbits* 4)
(i2ubita *linebits* 4)
(apply #'xappend
(mapcar (lambda (x) (marshall x))
(append (shape-records shp)
(list (make-instance 'end-record))))))))
(defmethod marshall ((sws shape-with-style))
(let* ((fs-count
(length (fillstyle-array-styles (shape-with-style-fillstyles sws))))
(ls-count
(length (linestyle-array-styles (shape-with-style-linestyles sws))))
(*fillbits* (needsize fs-count nil))
(*linebits* (needsize ls-count nil)))
(declare (special *fillbits* *linebits*))
(xappend
(marshall (shape-with-style-fillstyles sws))
(marshall (shape-with-style-linestyles sws))
(i2ubita *fillbits* 4)
(i2ubita *linebits* 4)
(apply #'xappend
(mapcar (lambda (x) (marshall x))
(append (shape-records sws)
(list (make-instance 'end-record))))))))
| 18,584 | Common Lisp | .lisp | 465 | 34.488172 | 198 | 0.645582 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 244236eb0d054c38e6a8dcf7f48ca5fbe93018cfa0ebe10054bbf305945a0366 | 22,293 | [
-1
] |
22,294 | marshalling-tests.lisp | sgarciac_gordon/marshalling-tests.lisp | ;;; Here a collection of marshalling tests are setup to allow
;;; the accuracy of marshalling code changes to be tested.
(in-package :gordon)
(defun report (object-symbol value)
(format t "~%~A: ~A" object-symbol value))
(defmacro test-marshalling (object
form
expected-value
test)
`(report ',object (funcall
,test
(marshall ,form :output nil)
',expected-value)))
(format t "~%Testing object marshalling from types.lisp")
(test-marshalling rect (make-instance 'rect) (#*000010000) #'equalp)
(test-marshalling rgb (make-instance 'rgb) (#(0) #(0) #(0)) #'equalp)
(test-marshalling rgba (make-instance 'rgba) (#(0) #(0) #(0) #(0)) #'equalp)
(test-marshalling cxform-wa (make-instance 'cxform-wa) (#*0 #*0) #'equal)
(test-marshalling cxform-wa (make-instance 'cxform-wa
:rmult 2.0
:gmult 1.0
:bmult 3.0
:amult 3.0
:gadd 3
:radd 1
:badd 3
:aadd 2)
(#*1 #*1 #*10110100000000000100000000011000000000110000000000000000001000000000110000000001100000000010)
#'equal)
(test-marshalling matrix (make-instance 'matrix) (#*0 #*0 #*0000100) #'equal)
(test-marshalling matrix (make-instance 'matrix
:scale-x 2.0
:scale-y -2.0
:rotate-skew-0 0.3
:rotate-skew-1 -4.5
:translate-x 23
:translate-y -2)
(#*1 #*1001101000000000000000001100000000000000000 #*1
#*1001100001001100110011000111000000000000000 #*00110010111111110)
#'equal)
(test-marshalling gradient-record (make-instance 'gradient-record) (#(1) #(0) #(0) #(0)) #'equalp)
(test-marshalling gradient (make-instance 'gradient) (#(0)) #'equalp)
(test-marshalling gradient (make-instance 'gradient
:record-list
(loop for i from 0 to 10 collect
(make-instance
'gradient-record)))
(#(11) #(1) #(0) #(0) #(0) #(1) #(0) #(0)
#(0) #(1) #(0) #(0) #(0) #(1) #(0) #(0)
#(0) #(1) #(0) #(0) #(0) #(1) #(0) #(0)
#(0) #(1) #(0) #(0) #(0) #(1) #(0) #(0)
#(0) #(1) #(0) #(0) #(0) #(1) #(0) #(0)
#(0) #(1) #(0) #(0) #(0))
#'equalp)
(test-marshalling fillstyle
(make-instance 'fillstyle)
(#(0) #* #() #* #())
#'equalp)
(test-marshalling fillstyle
(make-instance 'fillstyle
:color (make-instance 'rgb
:r 255
:g 0
:b 128))
(#(0) #(255) #(0) #(128) #* #() #* #())
#'equalp)
(test-marshalling fillstyle
(make-instance 'fillstyle
:type *repeating-bitmap-fill*
:bitmap-id 32
:bitmap-matrix (make-instance 'matrix
:scale-x 3.3))
(#(64) #() #* #() #(32 0) #*1 #*1001101101001100110011000010000000000000000 #*0 #*0000100 #())
#'equalp)
(test-marshalling
fillstyle
(make-instance 'fillstyle
:type *radial-gradient-fill*
:gradient-matrix (make-instance 'matrix)
:gradient (make-instance 'gradient
:record-list
`(,(make-instance 'gradient-record))))
(#(18) #() #*0 #*0 #*0000100 #(1) #(1) #(0) #(0) #(0) #* #())
#'equalp)
(test-marshalling linestyle (make-instance 'linestyle) (#(1 0)) #'equalp)
(test-marshalling linestyle (make-instance 'linestyle
:width 2000
:color *a-yellow*)
(#(208 7) #(255) #(255) #(0) #(255))
#'equalp)
(test-marshalling
fillstyle-array
(make-instance 'fillstyle-array
:styles (loop for i from 0 to 10
collecting (make-instance 'fillstyle)))
(#(11) #(0) #* #() #* #() #(0) #* #() #* #() #(0) #* #() #* #() #(0) #* #() #*
#() #(0) #* #() #* #() #(0) #* #() #* #() #(0) #* #() #* #() #(0) #* #() #*
#() #(0) #* #() #* #() #(0) #* #() #* #() #(0) #* #() #* #())
#'equalp)
(test-marshalling
linestyle-array
(make-instance 'linestyle-array
:styles (loop for i from 0 to 10
collecting (make-instance 'linestyle)))
(#(11) #(1 0) #(1 0) #(1 0) #(1 0) #(1 0) #(1 0) #(1 0) #(1 0) #(1 0) #(1 0)
#(1 0))
#'equalp)
(test-marshalling style-change-record
(make-instance 'style-change-record)
(#*0 #*0 #*0 #*0 #*0 #*0)
#'equal)
;; I need to add more style-change-record tests in here.
(test-marshalling end-record
(make-instance 'end-record)
(#*0 #*00000)
#'equal)
(test-marshalling curved-edge-record
(make-instance 'curved-edge-record)
(#*1 #*0 #*1111 #*0 #*0 #*0 #*0)
#'equal)
(test-marshalling straight-edge-record
(make-instance 'straight-edge-record)
(#*1 #*1 #*0000 #*0 #*1 #*00)
#'equal)
(test-marshalling
shape
(make-instance 'shape
:records (list (make-instance 'straight-edge-record)))
(#*0001 #*0001 #*1 #*1 #*0000 #*0 #*1 #*00 #*0 #*00000)
#'equalp)
(test-marshalling
shape-with-style
(make-instance
'shape-with-style
:records (list (make-instance 'curved-edge-record))
:linestyles (make-instance 'linestyle-array
:styles (list
(make-instance
'linestyle
:width 2)))
:fillstyles (make-instance 'fillstyle-array
:styles (list (make-instance 'fillstyle
:color *a-red*))))
(#(1) #(0) #(255) #(0) #(0) #(255) #* #() #* #() #(1) #(2 0) #*0001 #*0001 #*1
#*0 #*1111 #*0 #*0 #*0 #*0 #*0 #*00000)
#'equalp) | 7,099 | Common Lisp | .lisp | 146 | 30.020548 | 122 | 0.410707 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 4847088b45fbd8f1eae36046530cd199ab32c4bf038637dfe9686939291555d1 | 22,294 | [
-1
] |
22,295 | types-library.lisp | sgarciac_gordon/types-library.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
;;; make a random argb color
(defun random-argb ()
(make-instance 'rgba :r (random 255) :g (random 255) :b (random 255) :a 255))
;;; make a random rgb color
(defun random-rgb ()
(make-instance 'rgba :r (random 255) :g (random 255) :b (random 255)))
;;; make a matrix that defines only translation
(defun translation-matrix (x y)
(make-instance 'matrix
:translate-x x
:translate-y y))
| 1,231 | Common Lisp | .lisp | 27 | 43.62963 | 81 | 0.728261 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 5bab3d805088fa9deb3891ab61126a5c0207e5d3d6c075e32e8fc9fdf04e55b9 | 22,295 | [
-1
] |
22,296 | basic-classes.lisp | sgarciac_gordon/basic-classes.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;; COPYRIGHT 2006 Elliott Johnson <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
(defclass swf-movie-object ()()
(:documentation "A superclass for all flash objects in Gordon."))
(defgeneric marshall (swf-movie-object)
(:documentation "The generic function which oversees the marshalling of an object."))
(defmethod marshall ((obj swf-movie-object))
(error "The swf-object class is abstract and therefore cannot marshall body information."))
| 1,252 | Common Lisp | .lisp | 23 | 53 | 93 | 0.760816 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 8f629aaebc17f63b5711138c6c0480c0e8b31ed7fe779287069491cb02115e82 | 22,296 | [
-1
] |
22,297 | basic-types.lisp | sgarciac_gordon/basic-types.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
;;;;
;;;;
;;;; SWF Basic Types library
;;;;
;;;;
;;; convertion to SWF integer types as byte arrays
;; return the byte corresponding to the 8 bits
;; of a bit array that start in x
(deftype byte-array ()
`(vector (unsigned-byte 8)))
(deftype bit-array ()
`(vector bit))
(defun i2SI8 (val)
(is2lesbitaba `(,val) `(,8)))
(defun i2UI8 (val)
(is2leubitaba `(,val) `(,8)))
(defun i2SI16 (val)
(is2lesbitaba `(,val) `(,16)))
(defun i2UI16 (val)
(is2lesbitaba `(,val) `(,16)))
(defun i2SI32 (val)
(is2lesbitaba `(,val) `(,32)))
(defun i2UI32 (val)
(is2lesbitaba `(,val) `(,32)))
(defun f2f (val)
(multiple-value-bind (high low) (floor (abs val))
(let ((s (if (>= val 0) 1 -1)))
(concba
(i2UI16 (floor (* low (expt 2 16))))
(i2SI16 (* s high))))))
(defmacro bita2byte (bita x)
`(coerce (+ ,@(mapcar (lambda (n) `(* (bit ,bita (+ ,x ,n)) ,(expt 2 (- 7 n)))) '(0 1 2 3 4 5 6 7 ))) '(unsigned-byte 8)))
;;; returns a array of bytes with the
;;; concatenation of arrays of bits containint
;;; the representations of a list of numbers
;;; (signed or unsigned according to signs)
;;; in the respective sizes.
;;; endianism applies to the order of the bytes in
;;; the array.
(defun vs2bita (vals sizes signs)
(apply #'concbita
(mapcar
(lambda (val siz sig)
(funcall
(if (integerp val)
(if sig
#'i2sbita
#'i2ubita)
#'f2sbita)
val siz))
vals sizes signs)))
;;; Same as the former, but it returns the array of bits
;;; transformed to an array of bytes, with little endianism and padding
;;; if necessary
(defun vs2bitaba (vals sizes signs &optional (endianism :BE))
(funcall (if (eq endianism :LE)
#'bita2leba
#'bita2beba)
(vs2bita vals sizes signs)
))
(defun is2leubitaba (ints sizes)
(bita2leba (apply #'concbita (mapcar #'i2ubita ints sizes))))
(defun is2lesbitaba (ints sizes)
(bita2leba (apply #'concbita (mapcar #'i2sbita ints sizes))))
;;; like the former, but big endian
(defun is2beubitaba (ints sizes)
(bita2beba (apply #'concbita (mapcar #'i2ubita ints sizes))))
(defun is2besbitaba (ints sizes)
(bita2beba (apply #'concbita (mapcar #'i2sbita ints sizes))))
;;; return a bit array, big endian, containing the signed representation
;;; of a list of ints, prefixed with an array of bitsmaxsize with the
;;; unsigned integer representation of the number of bits used for all
;;; the other values.
(defun is2besbitawithmax (vals bitsmaxsize)
(let ((maxsize (apply #'max (mapcar (lambda (x) (needsize x t)) vals))))
(concbita (i2ubita maxsize bitsmaxsize)
(apply #'concbita (mapcar
#'i2sbita vals
(make-list (length vals) :initial-element maxsize))))))
(defun is2beubitawithmax (vals bitsmaxsize)
(let ((maxsize (apply #'max (mapcar (lambda (x) (needsize x nil)) vals))))
(concbita (i2ubita maxsize bitsmaxsize)
(apply #'concbita (mapcar
#'i2ubita vals
(make-list (length vals) :initial-element maxsize))))))
(defun fs2besbitawithmax (vals bitsmaxsize)
(let ((maxsize (apply #'max (mapcar (lambda (x) (needsize x t)) vals))))
(concbita (i2ubita maxsize bitsmaxsize)
(apply #'concbita (mapcar
#'f2sbita vals
(make-list (length vals) :initial-element maxsize))))))
;;; return a bit array of size b with the unsigned representation
;;; of integer c
(defun i2ubita (c b)
(let ((rarray (make-array b :element-type 'bit :initial-element 0)))
(do* ((i (1- b) (1- i))
(n c (ash n -1))
(v (bti (logbitp 0 c)) (bti (logbitp 0 n))))
((= i -1) rarray)
(setf (bit rarray i) v))))
;;; Return a bit array of size b witht he signed representation of integer c
(defun f2sbita (c b)
(check-type c float)
(multiple-value-bind (high low) (floor c)
(concbita
(i2sbita high (- b 16))
(i2ubita (floor (* low (expt 2 16))) 16)
)))
;;; return a bit array of size b with the signed representation
;;; of integer c
(defun i2sbita (c b)
(if (>= c 0)
(i2ubita c b)
(bit-not (i2ubita (1- (abs c)) b))))
(defun concbita (&rest others)
(apply #'concatenate '(vector bit) others))
(defun concba (&rest others)
(apply #'concatenate '(vector (unsigned-byte 8)) others))
;;; inyect the contents of the first array to the second
;;; array, with an optional argument on the start point
(defun inject (sources dest &optional (sp 0))
(unless (null sources)
(let ((source (car sources)))
(dotimes (i (array-total-size source) dest)
(setf (aref dest (+ i sp)) (aref source i)))
(inject (cdr sources) dest (+ sp (length source)))
dest)))
;;; pad a bit array so it ends in a multiple of 8
(defun pad8 (bita)
(let ((osize (array-total-size bita)))
(if (zerop (mod osize 8))
bita
(adjust-array bita (+ osize (- 8 (mod osize 8))) :initial-element 0))))
;;; String to byte array
(defun string2string2 (s &optional (with-end nil))
(let ((result-length (+ (length s) (if with-end 1 0))))
(vs2bitaba (char-codes s with-end)
(make-list result-length :initial-element 8)
(make-list result-length :initial-element nil))))
(defun string2string (s &optional (with-end nil))
(let ((values (loop for code in (char-codes s with-end) appending (if (< code 128) (list code)
(list (+ 192 (floor (/ code 64))) (+ 128 (mod code 64)))))))
(let ((result-length (+ (length values) (if with-end 1 0))))
(vs2bitaba values
(make-list result-length :initial-element 8)
(make-list result-length :initial-element nil)))))
;;; returns a big endian array of bytes with the
;;; concatenation of arrays of bits containint
;;; the unsigned representations of a list of integers
;;; in the respective sizes
;;; re-implement by increasing array size?
(defun bita2beba (bita)
(let* ((pbita (pad8 bita))
(bitsize (array-total-size pbita))
(barray (make-array (/ bitsize 8)
:element-type '(unsigned-byte 8))))
(dotimes (i (array-total-size barray) barray)
(setf (aref barray i) (bita2byte pbita (* 8 i))))))
(defun bita2leba (bita)
(let* ((pbita (pad8 bita))
(bitsize (array-total-size pbita))
(barray (make-array (/ bitsize 8)
:element-type '(unsigned-byte 8)))
(basize (array-total-size barray)))
(dotimes (i basize barray)
(setf (aref barray (- basize (1+ i))) (bita2byte pbita (* 8 i))))))
(defun needsize (i s)
"return the number of bits necessary to represent an integer. s
set to true means that the repsentation is signed"
(typecase i
(integer (+ (integer-length i) (bti s)))
(float (let* ((vs (> i 0))
(hp (* (if vs 1 -1) (floor (abs i)))))
(+ 16 (needsize hp s))))))
| 7,556 | Common Lisp | .lisp | 190 | 35.868421 | 124 | 0.662188 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 47a1015094d8b9310c25d6268d5bf8b78f5e8bbf9352fde9fd608b44c32c9590 | 22,297 | [
-1
] |
22,298 | basic-constants.lisp | sgarciac_gordon/basic-constants.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
(defparameter *flash-version* 6)
(defparameter *solid-fill* 0)
(defparameter *linear-gradient-fill* 16)
(defparameter *radial-gradient-fill* 18)
(defparameter *repeating-bitmap-fill* 64)
(defparameter *clipped-bitmap-fill* 65)
(defparameter *non-smoothed-repeating-bitmap* 66)
(defparameter *non-smoothed-clipped-bitmap* 67)
(defparameter *yes-bit* #*1)
(defparameter *no-bit* #*0)
(defparameter *empty-ba* (make-array 0 :element-type '(unsigned-byte 8)))
(defparameter *empty-bita* (make-array 0 :element-type 'bit)) | 1,345 | Common Lisp | .lisp | 28 | 46.821429 | 79 | 0.757622 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 54576f37f20281a6f473b40e1b713ab34db4c816388236020533261cf1af0fe6 | 22,298 | [
-1
] |
22,299 | utilities.lisp | sgarciac_gordon/utilities.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
;;;;
;;;; Some utilities
;;;;
(defun bti (b)
(if b 1 0))
(defun itb (i)
(not (equal i 0)))
(defun bif (test)
(if test *yes-bit* *no-bit*))
;;; return the sum of the length of sequences in a list
(defun ttl (lst)
(reduce
(lambda (x y) (+ x (length y)))
lst :initial-value 0))
(defun char-codes (str &optional (final nil))
(if final
(append (map 'list #'char-code str) '(0))
(map 'list #'char-code str)))
;;; appends a list of elements including atoms if present
(defun xappend (&rest vals)
(apply #'append (mapcar (lambda (x) (if (typep x 'list) x (list x))) vals)))
(defmacro with-gensyms (syms &body body)
`(let ,(mapcar #'(lambda (s)
`(,s (gensym)))
syms)
,@body))
;; generate a random number betwen min and max included
(defun xrandom (min max)
(+ min (random (1+ (- max min)))))
;; generate a vector of size size, with random numbers between min and max included
(defun random-vector (size min max)
(let ((v (make-array size)))
(dotimes (i size v)
(setf (aref v i) (xrandom min max)))))
;;; some utilities
(defun skip (in n)
(dotimes (i n)
(read-byte in)))
(defun accumulate-n (n f)
(do
((i 0 (1+ i))
(acc
(list (funcall f))
(cons (funcall f) acc)))
((= i (1- n)) acc)))
(defmacro debug-read-bytes (in &rest body)
(with-gensyms (ip result)
`(let ((,ip (file-position ,in))
(,result ,@body))
(format t "Read bytes: ~A~%" (- (file-position in) ,ip))
,result)))
(defun filter-type (lst type)
(mapcan (lambda (x) (when (typep x type) (list x))) lst))
(defun find-if-case (lst type)
(find-if (lambda (x) (typep x type)) lst))
(defun mapcar-pos (fun lst)
(let ((counter -1))
(mapcar (lambda (x) (funcall fun x (incf counter))) lst)))
(defun mapcar-with-last-result (fun lst first)
(let ((tmp first))
(mapcar (lambda (x) (setq tmp (funcall fun x tmp))) lst)))
(defun mapcar-with-last (fun lst first)
(let ((tmp first))
(mapcar (lambda (x) (let ((y (funcall fun x tmp))) (setq tmp x) y)) lst)))
(defun integer-to-214 (x)
(if (= 0 (ldb (byte 1 15) x))
(+ (ldb (byte 2 14) x) (coerce (/ (ldb (byte 14 0) x) 16384) 'float))
(* -1 (+ (- 3 (ldb (byte 2 14) x)) (- 1 (coerce (/ (ldb (byte 14 0) x) 16384) 'float))))))
(defun integrize (x)
(coerce x 'integer))
(defmacro incf-after (place &optional (delta 1))
(with-gensyms (temp)
`(let ((,temp ,place))
(incf ,place ,delta)
,temp)))
(defmacro with (varname exp &body body)
`(let ((,varname ,exp))
(when ,varname ,@body)))
;;; Copyright Zach Beane
;;; No need to rely on external programs to find the dimensions of a
;;; JPEG; the format is specified in CCITT T.81 and is pretty easy to
;;; process for metadata.
(defun read-uint16 (stream)
(logand #xFFFF
(logior (ash (read-byte stream)
8)
(ash (read-byte stream)
0))))
(defun standalone-marker-p (marker)
;; Table B.1
(<= #xD0 marker #xD9))
(defun sof-marker-p (marker)
;; Table B.1
(or (<= #xC0 marker #xC7)
(<= #xC9 marker #xCB)
(<= #xCD marker #xCF)))
(defun skip-length (stream)
(let ((length (read-uint16 stream)))
(file-position stream (+ (file-position stream)
(- length 2)))))
(defun sofn-dimensions (stream)
;; Section B.2.2
(let ((length (read-uint16 stream))
(precision (read-byte stream))
(height (read-uint16 stream))
(width (read-uint16 stream)))
(declare (ignore length precision))
(values width height)))
(defun jpeg-stream-dimensions (stream)
"Returns the WIDTH and HEIGHT of the frame in the JPEG stream STREAM
as multiple values, or NIL if no frame is found."
;; Section B.1.1.2
(do ((first-byte (read-byte stream nil)
next-byte)
(next-byte (read-byte stream nil)
(read-byte stream nil)))
((not (and first-byte next-byte)))
(when (and (= first-byte #xFF)
(/= next-byte #xFF #x00))
(cond ((sof-marker-p next-byte)
(return (sofn-dimensions stream)))
((not (standalone-marker-p next-byte))
(skip-length stream))))))
(defun jpeg-stream-p (stream)
(and (eql (read-byte stream nil)
#xFF)
(eql (read-byte stream nil)
#xD8)))
(defun jpeg-dimensions (file)
"Returns the WIDTH and HEIGHT of the JPEG file FILE as multiple
values, or NIL if the file is not a valid JPEG file."
(with-open-file (stream file
:direction :input
:element-type '(unsigned-byte 8))
(when (jpeg-stream-p stream)
(jpeg-stream-dimensions stream))))
;;; Elliott Johnson
;;; 03.27.2006
;;; CLOS utility functions heavily influenced by Peter Seibel. Thanks Peter
(defun as-keyword (name)
"Borrowed directly from Peter Seibel's practical common lisp code."
(intern (symbol-name name) :keyword))
(defun as-accessor (class-name slot-name &optional (string-separator "-"))
"Created based upon Peter's AS-KEYWORD code. This function will return
an accessor function symbol based upon the concatenation of the class-name,
string-separator, and the slot name. For example a slot BAR of class FOO
using the default string-separator will have a slot accessor of FOO-BAR."
(intern
(concatenate 'string
(symbol-name class-name)
string-separator
(symbol-name slot-name))))
(defun describe-slot (class-name name &optional (initform nil) (type t) (allocation :instance))
"Constructs a slot description list based upon the name, initform, and
type information."
`(,name :accessor ,(as-accessor class-name name)
:initform ,initform
:initarg ,(as-keyword name)
:type ,type
:allocation ,allocation
))
(defun describe-slots (slot-descriptions class-name)
"Applys the describe-slot function across all provided slot description
lists."
(mapcar #'(lambda (x)(apply #'describe-slot (cons class-name (typecase x (cons x) (t (list x))))))
slot-descriptions))
(defmacro genclass (class-name
inheritance
slots-list
&optional (docstring ""))
"GENCLASS defines a class named CLASS-NAME which inherits from
the list INHERITANCE. It's slots are defined by a list of slot
description lists of the form (slot-name initform type). The initform
and type information are optional and default to NIL and T respectivly."
`(defclass ,class-name ,inheritance
,(describe-slots slots-list class-name)
(:documentation ,docstring)))
| 7,187 | Common Lisp | .lisp | 193 | 33.647668 | 100 | 0.672764 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | f63e24d80d997b00fc28f06bdd7521cdc7de6144c67e26c0b6261b1e09b01b9b | 22,299 | [
-1
] |
22,300 | tags.lisp | sgarciac_gordon/tags.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
(genclass tag (swf-movie-object) ()
"The superclass for all tags.")
(defgeneric marshall-tag-body (tag)
(:documentation
"The generic function which oversees the marshalling of a body tag."))
(defmethod marshall ((tag tag))
(let* ((mtd (flat-marshall-data (marshall-tag-body tag)))
(tt (slot-value tag 'tag-id))
(l (length mtd))
(long? (>= l 63))
(recordheader (if long?
(list
(is2leubitaba (list tt 63) '(10 6))
(i2ui32 l))
(is2leubitaba (list tt l) '(10 6)))))
(xappend recordheader mtd)))
;;;;;;;;;;;;;;;;;;;;; ALL THE TAGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(genclass tag-end
(tag)
((tag-id 0 integer :class))
"The TAG that finishes a movie.")
(defmethod marshall-tag-body ((tag-end tag-end))
(declare (ignore tag-end))
*empty-ba*)
(genclass tag-enable-debugger2
(tag)
((tag-id 64 integer :class))
"The TAG that enables debugged.")
(defmethod marshall-tag-body ((tag-e-d2 tag-enable-debugger2))
(declare (ignore tag-e-d2))
(xappend
(i2ui16 0)
(i2ui8 0)))
(genclass tag-showframe
(tag)
((tag-id 1 integer :class))
"The TAG that makes the player display a new frame.")
(defmethod marshall-tag-body ((t-sf tag-showframe))
(declare (ignore t-sf))
*empty-ba*)
(genclass tag-SBC
(tag)
((tag-id 9 integer :class) bgcolor)
"A TAG that changes the background color (an RGB) of the movie.")
(defmethod marshall-tag-body ((tag-sbc tag-sbc))
(marshall (tag-SBC-bgcolor tag-sbc)))
(genclass tag-framelabel
(tag)
((tag-id 43 integer :class) name)
"Sets a name for the current frame, so it can
be refered later by that name.")
(defmethod marshall-tag-body ((t-fl tag-framelabel))
(string2string (tag-framelabel-name t-fl) t))
(genclass tag-define-shape
(tag)
((tag-id 32 integer :class) id shape)
"A TAG that adds a new shape to the dictionary.")
(defmethod marshall-tag-body ((t-d-s tag-define-shape))
(with-slots
(id shape)
t-d-s
(xappend
(i2ui16 id)
(marshall (calculate-shape-bounds shape))
(marshall shape))))
(genclass tag-place-object2
(tag)
((tag-id 26 integer :class)
depth
id
move
matrix
cx
name)
"A TAG that places (or moves) an object from the dictionary in
the scene.")
(defmethod marshall-tag-body ((t-p-o2 tag-place-object2))
(with-slots (depth id move matrix cx name)
t-p-o2
(xappend
*no-bit*
*no-bit*
(bif name)
*no-bit*
(bif cx)
(bif matrix)
(bif id)
(bif move)
(i2ui16 depth)
(when id
(i2ui16 id))
(when matrix
(marshall matrix))
(when cx
(marshall cx))
(when name
(string2string name t)))))
(genclass tag-remove-object
(tag)
((tag-id 28 integer :class)
depth)
"A TAG to remove the object at a particular depth, from the scene.")
(defmethod marshall-tag-body ((t-r-o tag-remove-object))
(i2ui16 (tag-remove-object-depth t-r-o)))
(genclass tag-define-font-2
(tag)
((tag-id 48 integer :class)
(id 0 integer)
(name "stupid-font" string)
(offsets nil) ;defined in defineFont
(shapes nil) ;defined in defineFont
(codes nil)
(ascent 1000 integer)
(descent 100 integer)
(leading 100 integer)
(advance 800))
"This TAG defines a new font.")
(defmethod marshall-tag-body ((font tag-define-font-2))
(with-slots
(id name offsets shapes codes ascent descent leading advance)
font
(let ((marshalled-shapes
(mapcar (lambda (x) (flat-marshall-data (marshall x)))
shapes))
(numglyphs (length shapes)))
(xappend
(i2ui16 id)
*yes-bit* ;has layout
*no-bit* ;JIS
*no-bit* ;small text
*no-bit* ;ANSI
*yes-bit* ;wide offsets
*yes-bit* ;wide codes
*no-bit* ;italic
*no-bit* ;bold
(i2ui8 1) ;langage code latin
(i2ui8 (array-dimension name 0))
(string2string name)
(i2ui16 numglyphs) ;numglyphs
(loop
for i = 0 then (1+ i)
for marshalled-shape in marshalled-shapes
collecting (+
(* 4 (1+ numglyphs))
total) into offsets
summing (length marshalled-shape) into total
finally (return (mapcar #'i2ui32 offsets)))
;offsets
(i2ui32 (+ (* 4 (1+ numglyphs))
(reduce (lambda (total item)
(+ total (length (flat-marshall-data item))))
marshalled-shapes :initial-value 0))) ;codetable offset
(apply #'xappend marshalled-shapes)
(mapcar #'i2ui16 codes) ; the codes
(i2si16 ascent)
(i2si16 descent)
(i2si16 leading)
(mapcar #'i2si16 advance)
; (make-list numglyphs :initial-element (i2si16 (tag-define-font-2-advance font)))
(apply #'xappend
(make-list numglyphs :initial-element
(xappend (marshall
(make-instance 'rect
:xmin 0
:xmax 1000
:ymin 0
:ymax 100))
*empty-ba*)))
;(apply #'xappend (make-list numglyphs :initial-element (marshall-rect (make-rect :xmin 0 :xmax 100 :ymin 0 :ymax 100)) ))
(i2ui16 0)))))
(genclass tag-define-edit-text
(tag)
((tag-id 37 integer :class)
(id nil)
(word-wrap t)
(bounds (make-instance 'rect :xmin 0 :xmax 2000 :ymin 0 :ymax 2000))
(password nil)
(editable nil)
(selectable nil)
(border nil)
(html nil)
(use-outlines t)
(font-id nil)
(font-height 12)
(color *a-black*)
(autosize nil)
(max-length nil)
(multi-lines nil)
(align nil)
(left-margin 0)
(right-margin 0)
(indent 0)
(leading 0)
(variable-name nil)
(initial-text "Gordon Rules"))
"This TAG defines a new edition box object")
(defmethod marshall-tag-body ((texto tag-define-edit-text))
(with-slots
(id word-wrap bounds password editable selectable border html use-outlines
font-id font-height color autosize max-length multi-lines
align left-margin right-margin indent leading variable-name
initial-text)
texto
(xappend
(i2ui16 id)
(marshall bounds)
*empty-ba* ; the former is necesary to force
; byte-alignment when are structures
; byte aligned? I guess they always
; are, except if they are part
; of an array. Im not yet sure this
; is true, tho.
(bif initial-text)
(bif word-wrap )
(bif multi-lines)
(bif password)
(bif (not editable))
(bif color)
(bif max-length)
(bif font-id)
*no-bit* ; reserved
(bif autosize)
(bif (or
align
(not (zerop left-margin))
(not (zerop right-margin))
(not (zerop indent))
(not (zerop leading)))) ; layout
(bif (not selectable))
(bif border)
*no-bit* ;reserved
(bif html)
(bif use-outlines)
(with id font-id
(xappend
(i2ui16 id)
(i2ui16 font-height)))
(with color color
(marshall color))
(with max max-length (i2ui16 max))
(when (or
align
(not (zerop left-margin))
(not (zerop right-margin))
(not (zerop indent))
(not (zerop leading)))
(xappend
(i2ui8 (case align
(:LEFT 0)
(:RIGHT 1)
(:CENTER 2)
(:JUSTIFY 3)
(nil 2)))
(i2ui16 left-margin)
(i2ui16 right-margin)
(i2ui16 indent)
(i2ui16 leading)))
(string2string variable-name t)
(string2string initial-text t))))
(genclass tag-do-action
(tag)
((tag-id 12 integer :class) records)
"This TAG makes the player execute an action.")
(defmethod marshall-tag-body ((t-d-a tag-do-action))
(xappend
(apply #'xappend
(mapcar #'marshall-action-record (tag-do-action-records t-d-a)))
(i2ui8 0)))
(genclass tag-define-bits
(tag)
((tag-id 6 integer :class)
(id nil)
(jpegdata nil))
"This TAG creates a new object in the dictionary,
containing a jpeg bitmap. Use tag-define-bits2 instead.")
(defmethod marshall-tag-body ((t-d-b tag-define-bits))
(xappend
(i2ui16 (tag-define-bits-id t-d-b))
(tag-define-bits-jpegdata t-d-b)))
(genclass tag-define-bits2
(tag)
((tag-id 21 integer :class) (id nil)
(jpegdata nil))
"This TAG creates a new object in the dictionary,
containing a jpeg bitmap.")
(defmethod marshall-tag-body ((t-d-b2 tag-define-bits2))
(xappend
(i2ui16 (tag-define-bits2-id t-d-b2))
(tag-define-bits2-jpegdata t-d-b2)))
(genclass tag-define-bits3
(tag)
((tag-id 35 integer :class) (id nil)
(jpegdata nil)
(alpha nil))
"This TAG creates a new object in the dictionary,
containing a jpeg bitmap, and supporting alpha channel.")
(defmethod marshall-tag-body ((t-d-b3 tag-define-bits3))
(xappend
(i2ui16 (tag-define-bits3-id t-d-b3))
(i2ui32 (length (tag-define-bits3-jpegdata t-d-b3)))
(tag-define-bits3-jpegdata t-d-b3)
(tag-define-bits3-alpha t-d-b3)))
(genclass tag-define-button-2
(tag)
((tag-id 34 integer :class) (id nil)
(menu nil)
(action-offset nil)
(characters nil)
(actions nil))
"Creates a button object and puts it in the dictionary.")
(defmethod marshall-tag-body ((tdb tag-define-button-2))
(with-slots
(id menu actions characters)
tdb
(let* ((chars
(apply #'xappend (mapcar #'marshall
characters
)))
(marshalled-characters (flat-marshall-data chars)))
(xappend
(i2ui16 id)
(i2ubita 0 7)
(bif menu)
(if (zerop (length actions))
(i2ui16 0) (i2ui16 (length marshalled-characters)))
;(i2ui16 0)
marshalled-characters
(i2ui8 0)))))
(defun make-jpeg-tag (id file)
(with-open-file (stream file :direction :input
:element-type '(unsigned-byte 8))
(let ((seq (make-array (file-length stream)
:element-type '(unsigned-byte 8))))
(read-sequence seq stream)
(make-instance 'tag-define-bits2 :id id :jpegdata seq)
)))
(type-of (make-array 3 :element-type '(unsigned-byte 8)))
| 11,250 | Common Lisp | .lisp | 353 | 25.640227 | 128 | 0.618022 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | ec46dd924a085dfdd2e26f0314f0a0f55c5b60942f818480a8f877f4b3b9cacc | 22,300 | [
-1
] |
22,301 | actions.lisp | sgarciac_gordon/actions.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
;; the action
(defparameter *action-record-data-marshallers* (make-hash-table))
(defparameter *action-record-codes* (make-hash-table))
(defun action-record-type (action-record)
(gethash (type-of action-record) *action-record-codes*))
(defun marshall-action-record-data (action-record)
(funcall (gethash (type-of action-record) *action-record-data-marshallers*) action-record))
(defmacro add-action-record-type(name code fields marshaller)
`(progn (defstruct ,name ,@fields)
(setf (gethash ',name *action-record-codes*) ,code)
(setf (gethash ',name *action-record-data-marshallers*) ,marshaller)
))
;;; Marshall a tag
(defun marshall-action-record (action-record)
(let* ((mard (flat-marshall-data (marshall-action-record-data action-record)))
(art (action-record-type action-record))
(l (length mard))
(longp (>= art 128))
(recordheader
(if longp
(list
(i2ui8 art)
(i2ui16 l))
(i2ui8 art))))
(xappend recordheader mard)))
(add-action-record-type action-record-next-frame
4
()
(lambda (x) nil))
(add-action-record-type action-record-previous-frame
5
()
(lambda (x) nil))
(add-action-record-type action-record-play
6
()
(lambda (x) nil))
(add-action-record-type action-record-stop
7
()
(lambda (x) nil))
(add-action-record-type action-record-toggle-quality
8
()
(lambda (x) nil))
(add-action-record-type action-record-stop-sounds
9
()
(lambda (x) nil))
(add-action-record-type action-record-goto-frame
129
((index 1))
(lambda (x) (i2ui16 (action-record-goto-frame-index x))))
(add-action-record-type action-record-get-url
131
((url "") (target ""))
(lambda (x) (xappend
(string2string (action-record-get-url-url x) t)
(string2string (action-record-get-url-target x) t))))
(add-action-record-type action-record-wait-for-frame
138
((index 1) (skip-count 0))
(lambda (x) (xappend
(i2ui16 (action-record-wait-for-frame-index x))
(i2ui8 (action-record-wait-for-frame-skip-count x)))))
(add-action-record-type action-record-set-target
139
((name 1))
(lambda (x) (string2string (action-record-set-target-name x) t)))
(add-action-record-type action-record-goto-label
140
((name 1))
(lambda (x) (string2string (action-record-goto-label-name x) t)))
(add-action-record-type action-record-push
150
((value 1))
(lambda (x)
(xappend (i2ui8 0)
(string2string (action-record-push-value x) t))))
(add-action-record-type action-record-set-variable
29
()
(lambda (x) nil))
| 3,434 | Common Lisp | .lisp | 99 | 31.050505 | 93 | 0.700969 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | c80b056457e7e06009a6c9544c6897db4d145c972dfdceb6984f90b9991d1b9a | 22,301 | [
-1
] |
22,302 | contours.lisp | sgarciac_gordon/contours.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
(defun draw-shape-with-style (contours
&key
(fill-gradient-matrix nil)
(fill-gradient nil)
(fill-bitmap nil)
(fill-bitmap-style *clipped-bitmap-fill*)
(fill-bitmap-matrix (make-instance 'matrix))
(fill-color *a-white*)
(stroke-color *a-black*)
(stroke-width 20))
"Creates a flash shape from a list of contours. A contour is a list of straight lines and curved lines, defined as a list of steps. An step is either an (xdelta ydelta) delta or an (xcontol ycontrol xdelta ydelta). The first step is always a (x y) and signals the start point of the contour. Draw-shape will not verify that the contours are closed."
(make-instance
'shape-with-style
:fillstyles (make-instance
'fillstyle-array
:styles (cond ((and fill-gradient-matrix fill-gradient)
(list
(make-instance 'fillstyle
:type *radial-gradient-fill*
:gradient-matrix fill-gradient-matrix
:gradient fill-gradient)
))
(fill-bitmap
(list (make-instance 'fillstyle :type
fill-bitmap-style
:bitmap-id fill-bitmap
:bitmap-matrix fill-bitmap-matrix
)))
(t (list (make-instance 'fillstyle :color fill-color)))))
:linestyles (make-instance 'linestyle-array
:styles `(,(make-instance 'linestyle
:width stroke-width
:color stroke-color)))
:records (apply #'append (mapcar #'make-records-from-contour contours))))
(defun curved-edge-p (x)
(= 4 (length x)))
(defun straight-edge-p (x)
(= 2 (length x)))
(defun make-records-from-contour (contour &key (linestyle 1) (fillstyle0 1) (fillstyle1 0))
(labels ((make-record (x)
(when (or
(not (or (straight-edge-p x) (curved-edge-p x)))
(not (find-if (lambda (it) (not (zerop it))) x)))
(format t "Corrupt step in contour?: ~A" x))
(if (straight-edge-p x)
(make-instance 'straight-edge-record
:delta-x (first x)
:delta-y (second x))
(make-instance 'curved-edge-record
:control-delta-x (first x)
:control-delta-y (second x)
:anchor-delta-x (third x)
:anchor-delta-y (fourth x)))))
(cons (make-instance 'style-change-record :delta-x (first (first contour))
:delta-y (second (first contour))
:linestyle linestyle
:fillstyle0 fillstyle0
:fillstyle1 fillstyle1)
(mapcar #'make-record (cdr contour)))))
(defun make-polygone-contour (n l)
(cons '(0 0)
(do ((i 0 (1+ i))
(angle 0 (+ angle (/ (* 2 pi) n)))
(sides `() (append sides (list (list (round (* l (sin angle))) (round (* l (cos angle))))))))
((= i n) sides))))
(defun make-arch (segments-count radio angle &key (initial-angle 0))
(labels ((make-segment (distance total-angle angle reminders)
(multiple-value-bind (xcontrol-value xcontrol-reminder)
(round (+ (first reminders ) (* distance (cos total-angle))))
(multiple-value-bind (ycontrol-value ycontrol-reminder)
(round (+ (second reminders) (* distance (sin total-angle))))
(multiple-value-bind (xdelta-value xdelta-reminder)
(round (+ (third reminders) (* distance (cos (+ angle total-angle)))))
(multiple-value-bind (ydelta-value ydelta-reminder)
(round (+ (fourth reminders) (* distance (sin (+ angle total-angle)))))
(cons (list xcontrol-value ycontrol-value xdelta-value ydelta-value)
(list xcontrol-reminder ycontrol-reminder xdelta-reminder ydelta-reminder))))))))
(let*
((segment-angle (/ angle segments-count))
(distance (* radio (tan (/ segment-angle 2)))))
(loop
with reminders = (list 0 0 0 0)
for i from 1 upto segments-count
for total-angle = initial-angle then (+ total-angle segment-angle)
for calculate-segment = (make-segment distance total-angle segment-angle reminders)
do (setf reminders (cdr calculate-segment))
collecting (car calculate-segment)))))
(defun make-circle-contour (n r)
"Creates a circular contour of radio r, using n steps"
(cons '(0 0) (make-arch n r (* 2 pi))))
(defun make-rect-contour (w h)
"Creates a rectangular contour of width w and height h"
`((0 0) (,w 0) (0 ,h) (,(- w) 0) (0 ,(- h))))
(defun make-bridge-contour (steps radio angle width &key (initial-angle 0))
(close-contour
(append
`((,(round (* radio (sin initial-angle))) ,(- (round (* radio (cos initial-angle))))))
(make-arch steps radio angle :initial-angle initial-angle)
`((,(round (* width (cos (+ initial-angle angle (/ pi 2))))) ,(round (* width (sin (+ initial-angle angle (/ pi 2)))))))
(make-arch steps (- radio width) (* -1 angle) :initial-angle (- (+ initial-angle angle) (* 2 pi)))
`((,(round (* width (cos (- initial-angle (/ pi 2))))) ,(round (* width (sin (- initial-angle (/ pi 2))))))))))
(defun closed-p (contour)
(let ((delta
(reduce (lambda (total step)
(if (straight-edge-p step)
(cons (- (car total) (first step))
(- (cdr total) (second step)))
(cons (- (car total) (first step) (third step))
(- (cdr total) (second step) (fourth step)))))
(cdr contour) :initial-value '(0 . 0))))
(= 0 (car delta) (cdr delta))))
(defun add-joint-to-contour (contour)
"given a contour, returns a contour that is closed, adding an straight edge if necessary"
(let ((delta
(reduce (lambda (total step)
(if (straight-edge-p step)
(cons (- (car total) (first step))
(- (cdr total) (second step)))
(cons (- (car total) (first step) (third step))
(- (cdr total) (second step) (fourth step)))))
(cdr contour) :initial-value '(0 . 0))))
(if (not (= 0 (car delta) (cdr delta)))
(append contour (list (list (car delta) (cdr delta))))
contour)))
(defun close-contour (contour)
"given a contour, returns a contour that is closed, by changing the last edge"
(let ((delta
(reduce (lambda (total step)
(if (straight-edge-p step)
(cons (- (car total) (first step))
(- (cdr total) (second step)))
(cons (- (car total) (first step) (third step))
(- (cdr total) (second step) (fourth step)))))
(cdr contour) :initial-value '(0 . 0)))
(last-edge (car (last contour))))
(if (not (= 0 (car delta) (cdr delta)))
(append (subseq contour 0 (- (length contour) 1))
(if (curved-edge-p last-edge)
(list (list (first last-edge) (second last-edge)
(+ (car delta) (third last-edge))
(+ (cdr delta) (fourth last-edge))))
(list (list (+ (first last-edge) (car delta))
(+ (second last-edge) (cdr delta))))))
contour)))
(defun invert-contour-vertical (contour)
(mapcar (lambda (step) (mapcar-pos (lambda (item pos) (if (oddp pos) (* -1 item) item)) step)) contour))
(defun scale-contour (contour xscale yscale)
(let ((new-contour
(mapcar (lambda (step) (if (straight-edge-p step)
(list (floor (* xscale (first step)))
(floor (* yscale (second step))))
(list (floor (* xscale (first step)))
(floor (* yscale (second step)))
(floor (* xscale (third step)))
(floor (* yscale (fourth step))))))
contour)))
(if (closed-p contour)
(close-contour new-contour)
new-contour)))
(defun scale-contours (contours xscale yscale)
(mapcar (lambda (contour) (scale-contour contour xscale yscale)) contours))
(defun final-point (contour)
(reduce (lambda (current step) (if (curved-edge-p step)
(cons (+ (car current) (first step) (third step))
(+ (cdr current) (second step) (fourth step)))
(cons (+ (car current) (first step))
(+ (cdr current) (second step)))))
contour
:initial-value '(0 . 0)))
| 8,575 | Common Lisp | .lisp | 185 | 40.454054 | 351 | 0.637575 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | ae719241da7dd23a4e4ab4b5c87f497aeab7b1c7911ab361d144b0b7bfebf3fa | 22,302 | [
-1
] |
22,303 | constants.lisp | sgarciac_gordon/constants.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:gordon)
;;; colors
(defparameter *black* (make-instance 'rgb :r 0 :g 0 :b 0))
(defparameter *blue* (make-instance 'rgb :r 0 :g 0 :b 255))
(defparameter *brown* (make-instance 'rgb :r 128 :g 128 :b 0))
(defparameter *cyan* (make-instance 'rgb :r 0 :g 0 :b 128))
(defparameter *green* (make-instance 'rgb :r 0 :g 128 :b 0))
(defparameter *grey* (make-instance 'rgb :r 128 :g 128 :b 128))
(defparameter *lblue* (make-instance 'rgb :r 0 :g 255 :b 255))
(defparameter *lcyan* (make-instance 'rgb :r 0 :g 128 :b 128))
(defparameter *lgreen* (make-instance 'rgb :r 0 :g 255 :b 0))
(defparameter *lgrey* (make-instance 'rgb :r 192 :g 192 :b 192))
(defparameter *lmagenta* (make-instance 'rgb :r 255 :g 0 :b 255))
(defparameter *lred* (make-instance 'rgb :r 255 :g 0 :b 0))
(defparameter *magenta* (make-instance 'rgb :r 128 :g 0 :b 128))
(defparameter *red* (make-instance 'rgb :r 255 :g 0 :b 0))
(defparameter *white* (make-instance 'rgb :r 255 :g 255 :b 255))
(defparameter *yellow* (make-instance 'rgb :r 255 :g 255 :b 0))
(defparameter *a-black* (make-instance 'rgba :r 0 :g 0 :b 0 :a 255))
(defparameter *a-blue* (make-instance 'rgba :r 0 :g 0 :b 255 :a 255))
(defparameter *a-brown* (make-instance 'rgba :r 128 :g 128 :b 0 :a 255))
(defparameter *a-cyan* (make-instance 'rgba :r 0 :g 0 :b 128 :a 255))
(defparameter *a-green* (make-instance 'rgba :r 0 :g 128 :b 0 :a 255))
(defparameter *a-grey* (make-instance 'rgba :r 128 :g 128 :b 128 :a 255))
(defparameter *a-lblue* (make-instance 'rgba :r 0 :g 255 :b 255 :a 255))
(defparameter *a-lcyan* (make-instance 'rgba :r 0 :g 128 :b 128 :a 255))
(defparameter *a-lgreen* (make-instance 'rgba :r 0 :g 255 :b 0 :a 255))
(defparameter *a-lgrey* (make-instance 'rgba :r 192 :g 192 :b 192 :a 255))
(defparameter *a-lmagenta* (make-instance 'rgba :r 255 :g 0 :b 255 :a 255))
(defparameter *a-lred* (make-instance 'rgba :r 255 :g 0 :b 0 :a 255))
(defparameter *a-magenta* (make-instance 'rgba :r 128 :g 0 :b 128 :a 255))
(defparameter *a-red* (make-instance 'rgba :r 255 :g 0 :b 0 :a 255))
(defparameter *a-white* (make-instance 'rgba :r 255 :g 255 :b 255 :a 255))
(defparameter *a-yellow* (make-instance 'rgba :r 255 :g 255 :b 0 :a 255))
| 2,998 | Common Lisp | .lisp | 49 | 60.020408 | 79 | 0.691366 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | f067e89e50e0b7e253b315cd6576d94c1b2a8e1da24c2d4f239de427cc5a1e58 | 22,303 | [
-1
] |
22,304 | packages.lisp | sgarciac_gordon/packages.lisp | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:cl-user)
(defpackage #:gordon
(:use #:cl)
(:export
#:*blue*
#:*black*
#:*brown*
#:*cyan*
#:*green*
#:*grey*
#:*lblue*
#:*lcyan*
#:*lgreen*
#:*lgrey*
#:*lmagenta*
#:*lred*
#:*magenta*
#:*red*
#:*white*
#:*yellow*
#:curved-edge-record
#:straight-edge-record
#:style-change-record
#:shape
#:tag-define-font-2
#:gradient
#:rect
#:matrix
#:gradient-record
#:*a-black*
#:*a-blue*
#:*a-brown*
#:*a-cyan*
#:*a-green*
#:*a-grey*
#:*a-lblue*
#:*a-lcyan*
#:*a-lgreen*
#:*a-lgrey*
#:*a-lmagenta*
#:*a-lred*
#:*a-magenta*
#:*a-red*
#:*a-white*
#:*a-yellow*
#:with-movie
#:invert-contour-vertical
#:final-point
#:curved-edge-p
#:straight-edge-p
#:*repeating-bitmap-fill*
#:*clipped-bitmap-fill*
#:make-rotation-matrix-angle
#:add-to-movie
#:add-shape
#:*-matrix
#:+-matrix
#:flat-marshall-data
#:marshall
#:make-records-from-contour
#:make-shape
#:tag-define-font-2
#:make-jpeg-tag
#:make-style-change-record
#:make-straight-edge-record
#:make-curved-edge-record
#:make-bridge-contour
#:rgba
#:rgb
#:rgb-r
#:rgb-b
#:rgb-g
#:rgba-a
#:cxform-wa
#:tag-define-shape
#:tag-place-object2
#:random-argb
#:random-vector
#:translation-matrix
#:xrandom
#:tag-define-edit-text
#:close-contour
#:scale-contours
#:tag-SBC
#:write-movie
#:tag-end
#:tag-enable-debugger2
#:tag-remove-object
#:draw-shape-with-style
#:make-action-record-get-url
#:make-action-record-goto-frame
#:make-action-record-goto-label
#:make-action-record-next-frame
#:make-action-record-play
#:make-action-record-previous-frame
#:make-action-record-push
#:make-action-record-set-target
#:make-action-record-set-variable
#:make-action-record-stop
#:make-action-record-stop-sounds
#:make-action-record-toggle-quality
#:make-action-record-wait-for-frame
#:tag-do-action
#:tag-showframe
#:make-polygone-contour
#:make-circle-contour
#:make-rect-contour
#:tag-define-bits3
#:button-record
#:tag-define-button-2
))
| 3,005 | Common Lisp | .lisp | 126 | 20.166667 | 79 | 0.657023 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 3fa588f9cbcc9a17522e6ced6aca86aee9c27fbf328e3cd2888861e61d8ef6a1 | 22,304 | [
-1
] |
22,305 | lines.lisp | sgarciac_gordon/demos/lines.lisp | (use-package :gordon
)
(with-movie (m "line.swf"
:width 5000
:height 5000
:frame-rate 12
:bgcolor *white*)
(add-shape m 1 1
(draw-shape-with-style `((
(0 0)
(5000 5000)
)))
0 0)
(add-to-movie m (make-instance
'tag-end)))
| 315 | Common Lisp | .lisp | 15 | 13.733333 | 33 | 0.486577 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 54f0b59fd4e546ded70ac0c76840230c83dc5cc88c035100c8e1865dd9a43f78 | 22,305 | [
-1
] |
22,306 | translucentlayers.lisp | sgarciac_gordon/demos/translucentlayers.lisp | ; Contributed by Jeff Cunningham
(use-package :gordon)
(let* ((swf "flasher.swf")
(width 279)
(height 457)
(img1 '(:file "sergio.jpg" :width 279 :height 457))
(a-white (make-instance 'rgba :r 255 :g 255 :b 255 :a 255))
)
(with-movie (m swf :width width :height height :frame-rate 15 :bgcolor *white*)
(add-to-movie m (make-jpeg-tag 1 (getf img1 :file)))
(add-to-movie m (make-instance 'tag-define-shape :id 3
:shape (draw-shape-with-style
`(,(make-rect-contour (getf img1 :width) (getf img1 :height)))
:stroke-width 1
:stroke-color a-white
:fill-bitmap 1
)))
;; Fade is obtained here by adding and subtracting semi-opaque
;; white layers on top of the image
(let ((nfade 20)
(nwait 60)
(alpha))
;; First add the opaque layers to the dictionary
;; Increase the rate near the end by increasing alpha as well
;; Note: this is still a little rough - a better sequence of alphas would smooth it out.
(dotimes (id nfade)
(setf alpha (+ 25 id))
(add-to-movie m (make-instance 'tag-define-shape :id (+ 4 id)
:shape (draw-shape-with-style `(,(make-rect-contour (getf img1 :width) (getf img1 :height)))
:stroke-width 1
:stroke-color a-white
:fill-color (make-instance 'rgba :r 255 :g 255 :b 255 :a alpha)))))
;; Add the image to the movie
(add-to-movie m (make-instance 'tag-place-object2 :id 3 :depth 3))
;; Add all the translucent layers on top of it
(dotimes (id nfade)
(add-to-movie m (make-instance 'tag-place-object2 :id (+ 4 id) :depth (+ 4 id))))
;; Show what we've got (should be invisible at this point)
(add-to-movie m (make-instance 'tag-showframe))
;; Remove the layers one at a time
(dotimes (id nfade)
(add-to-movie m (make-instance 'tag-remove-object :depth (+ 4 id)))
(add-to-movie m (make-instance 'tag-showframe)))
;; Wait awhile
(dotimes (id nwait)
(add-to-movie m (make-instance 'tag-showframe)))
;; Now put translucent layers back again
(dotimes (id nfade)
(add-to-movie m (make-instance 'tag-place-object2 :id (+ 4 id) :depth (+ 4 id)))
(add-to-movie m (make-instance 'tag-showframe))))
(add-to-movie m (make-instance 'tag-end))))
| 2,728 | Common Lisp | .lisp | 51 | 39.078431 | 131 | 0.536036 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 219d7b59b21705552e9e9a5ddc92d82d715e1e08cdc2b3fd4a366fe7ab928ed6 | 22,306 | [
-1
] |
22,307 | inner-contour.lisp | sgarciac_gordon/demos/inner-contour.lisp | (use-package :gordon)
(with-movie (m "inner-contour.swf" :width 6000
:height 6000
:frame-rate 12
:bgcolor *white*)
(add-shape m 1 1
(draw-shape-with-style
'(((200 200) (0 1000) (1000 0) (0 -1000) (-1000 0))
((300 300) (800 0) (0 800) (-800 0) (0 -800)))
:fill-color *a-green*)
3000
3000)
(add-to-movie m (make-instance 'tag-showframe))
(add-to-movie m (make-instance 'tag-end)))
| 453 | Common Lisp | .lisp | 14 | 26.071429 | 58 | 0.575758 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 4969d492ea68ed951a4cc6d0d256f7f2c1b113cb52bbbbfeeb9c10f01f4bb71a | 22,307 | [
-1
] |
22,308 | falling-stars.lisp | sgarciac_gordon/demos/falling-stars.lisp | (use-package :gordon)
(defun make-curved-star-path (n l c)
(close-contour
(cons '(0 0)
(do ((i 0 (1+ i))
(angle 0 (+ angle (/ (* 2 pi) n)))
(sides `()
(let* ((lprima (sqrt (+ (expt (/ l 2) 2) (expt c 2))))
(gamma (- angle (atan (/ c (/ l 2)))))
(x1 (* lprima (sin gamma)))
(y1 (* lprima (cos gamma))))
(append sides (list (list
(round x1)
(round y1)
(round (- (* l (sin angle)) x1))
(round (- (* l (cos angle)) y1))
))))))
((= i n) sides)))))
(let* ((width 6000)
(height 6000)
(nshapes 50)
(sizelength 200)
(maxsides 8)
(downtimes 10)
(xs (random-vector nshapes 0 width))
(ys (random-vector nshapes 0 height)))
(with-movie (m "falling-stars.swf" :width width
:height height
:frame-rate 12
:bgcolor *white*)
;; create the curved stars and place them randomly
(dotimes (i nshapes)
(add-shape m (1+ i) (1+ i)
(draw-shape-with-style
(list (make-curved-star-path
(xrandom 3 maxsides)
(+ (* i 5) sizelength)
(+ (* i 5) 1000)))
:fill-color (random-argb))
(aref xs i)
(aref ys i))
(add-to-movie m (make-instance 'tag-showframe)))
;; make the stars fall
(dotimes (i nshapes)
(dotimes (j downtimes)
(add-to-movie m (make-instance 'tag-place-object2
:move t
:depth (- nshapes i)
:matrix (translation-matrix (aref xs (- nshapes (1+ i)))
(+ (aref ys (- nshapes (1+ i)))
(* j (/ height downtimes))))))
(add-to-movie m (make-instance 'tag-showframe))))
(add-to-movie m (make-instance 'tag-end))))
| 1,696 | Common Lisp | .lisp | 53 | 25.075472 | 62 | 0.53808 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | e1293e0cc9e166c62da7888c3f1b0c1292e2113ca32545311a2942514888a52b | 22,308 | [
-1
] |
22,309 | image.lisp | sgarciac_gordon/demos/image.lisp | (use-package :gordon)
(let* ((width 6000)
(height 6000)
(radius 500))
(with-movie (m "image.swf"
:width width
:height height
:frame-rate 12
:bgcolor *black*)
(add-to-movie m (make-jpeg-tag 1 "azul.jpeg"))
(add-shape m 2 2
(draw-shape-with-style
`(,(make-circle-contour 10 1000))
:fill-bitmap 1
:fill-bitmap-style *repeating-bitmap-fill*)
2000 2000)
(loop for i from 0 upto 200 do
(progn
(add-to-movie m
(make-instance 'tag-place-object2
:depth 2 :move t :matrix
(+-matrix (make-rotation-matrix-angle (* 0.05 i))
(make-instance 'matrix :scale-x (* 0.1 i) :scale-y (* i 0.1) :rotate-skew-0 0.0 :rotate-skew-1 0.0 :translate-x 2000 :translate-y (* -1 (* 3 i))))
))
(add-to-movie m (make-instance 'tag-showframe))))
(add-to-movie m (make-instance 'tag-end))))
| 885 | Common Lisp | .lisp | 26 | 28.076923 | 150 | 0.606132 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 3647f4467752dbb8dde649bcacdfc703a604f154561088ff7c075ceda731c2e4 | 22,309 | [
-1
] |
22,310 | gradient-balls.lisp | sgarciac_gordon/demos/gradient-balls.lisp | (use-package :gordon)
(let* ((width 6000)
(height 6000)
(radius 500)
(grad (make-instance 'gradient
:record-list (list (make-instance 'gradient-record
:color *yellow*)))))
(with-movie (m "gradient-balls.swf"
:width width
:height height
:frame-rate 12
:bgcolor *white*)
(dotimes (i 20)
(add-shape m (1+ i) (1+ i)
(draw-shape-with-style `(((0 0)
(0 ,radius ,radius 0)
(,radius 0 0 ,(- radius))
(0 ,(- radius) ,(- radius) 0)
(,(- radius) 0 0 ,radius)))
:fill-gradient-matrix (make-instance 'matrix
:scale-x 0.1
:scale-y 0.1
:translate-x radius
:translate-y 0)
:fill-gradient
(make-instance 'gradient
:record-list `(,(make-instance 'gradient-record
:ratio 0
:color (random-argb))
,(make-instance 'gradient-record
:ratio 100
:color (random-argb))
,(make-instance 'gradient-record
:ratio 255
:color (random-argb)))))
(xrandom radius width) (xrandom radius height)))
(add-to-movie m (make-instance 'tag-showframe))
(add-to-movie m (make-instance 'tag-end))))
| 1,249 | Common Lisp | .lisp | 38 | 24.052632 | 58 | 0.558475 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | d3264b1fa21fe081b9759f1fb774b4411ba3f93d967bbccb72d321d98b0c5af9 | 22,310 | [
-1
] |
22,311 | button.lisp | sgarciac_gordon/demos/button.lisp | (in-package :gordon)
(let* ((width 6000)
(height 6000)
)
(with-movie (m "button.swf"
:width width
:height height
:frame-rate 12
:bgcolor *white*)
(add-to-movie m (make-instance 'tag-define-shape :id 1 :shape (draw-shape-with-style
`(,(make-circle-contour 20 500))
:fill-color *a-lmagenta*))
)
(add-to-movie m (make-instance 'tag-define-shape :id 2 :shape (draw-shape-with-style
`(,(make-circle-contour 20 500))
:fill-color *a-yellow*))
)
(add-to-movie m
(make-instance 'tag-define-button-2
:id 3
:characters (list (make-instance 'button-record
:state-up t
:test-hit t
:character-id 1
:depth 1
:place-matrix (make-instance 'matrix)
:color-transform (make-instance 'cxform-wa :amult 1.0 :radd 100 :rmult 2.0 :gmult 2.0 :bmult 2.0))
(make-instance 'button-record
:state-over t
:character-id 2
:depth 2
:place-matrix (make-instance 'matrix)
:color-transform (make-instance 'cxform-wa :amult 0.9 :radd 100 :rmult 2.0 :gmult 2.0 :bmult 2.0))
(make-instance 'button-record
:state-down t
:character-id 2
:depth 3
:place-matrix (make-instance 'matrix)
:color-transform (make-instance 'cxform-wa :amult 0.2 :radd 10 :rmult 2.0 :gmult 2.0 :bmult 2.0))
)))
(add-to-movie m (make-instance 'tag-place-object2 :depth 4 :id 3 :matrix (make-instance 'matrix :translate-x 1000 :translate-y 1000)))
(add-to-movie m (make-instance 'tag-showframe))
(add-to-movie m (make-instance 'tag-end))))
| 1,565 | Common Lisp | .lisp | 43 | 30.906977 | 138 | 0.644079 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | fd7b4ed9685931144df05a2832c992a8f0a49723d95fad68302029843fc61052 | 22,311 | [
-1
] |
22,312 | circle.lisp | sgarciac_gordon/demos/circle.lisp | (use-package :gordon)
(let* ((width 6000)
(height 6000)
(radius 500))
(with-movie (m "circle.swf"
:width width
:height height
:frame-rate 12
:bgcolor *white*)
(add-shape m 1 1
(draw-shape-with-style `(,(make-circle-contour 20 200))
:fill-color *a-red*)
1000 1000)
(add-to-movie m (make-instance 'tag-showframe))
(add-to-movie m (make-instance 'tag-end))))
| 427 | Common Lisp | .lisp | 15 | 22.733333 | 63 | 0.602439 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | be8bb328b656df93a977766484f33fb6bde60a8db30677b0ddddcbbcdb258db6 | 22,312 | [
-1
] |
22,313 | simple-crossed.lisp | sgarciac_gordon/demos/simple-crossed.lisp | (use-package :gordon)
(with-movie (m "simple-crossed.swf"
:width 5000
:height 5000
:frame-rate 12
:bgcolor *green*)
(add-shape m 1 1
(draw-shape-with-style `((
(0 0)
(0 2000)
(2000 0)
(0 -2000)
(-2000 0)
)
(
(1000 1000)
(0 2000)
(2000 0)
(0 -2000)
(-2000 0)
)
)
:fill-color *a-red*)
0 0)
(add-to-movie m (make-instance 'tag-end)))
| 554 | Common Lisp | .lisp | 25 | 12.24 | 44 | 0.400387 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | bb587fbc8283bdbd468716478c101fabedf154e71bb394eb18d574a3b7f18c73 | 22,313 | [
-1
] |
22,314 | cxmatrix.lisp | sgarciac_gordon/demos/cxmatrix.lisp | (use-package :gordon)
(let* ((swf "sergio.swf")
(width 279)
(height 457)
(img1 '(:file "sergio.jpg" :width 279 :height 457))
(a-white (make-instance 'rgba :r 255 :g 255 :b 255 :a 10)))
(with-movie (m swf :width width :height height :frame-rate 10 :bgcolor *white*)
(add-to-movie m (make-jpeg-tag
1 (getf img1 :file)))
(add-to-movie m (make-instance 'tag-define-shape :id 2
:shape (draw-shape-with-style
`(,(make-rect-contour
(getf img1 :width)
(getf img1 :height)))
:fill-color *a-blue*
:stroke-width 1
:stroke-color a-white
:fill-bitmap 1)))
(add-to-movie m (make-instance 'tag-place-object2 :id 2 :depth 1))
(dotimes (i 100)
(add-to-movie m (make-instance 'tag-place-object2
:move t
:depth 1
:cx (make-instance 'cxform-wa
:amult (coerce (/ 1 (+ 1 i)) 'float))))
(add-to-movie m (make-instance 'tag-showframe)))
(add-to-movie m (make-instance 'tag-end))))
| 1,347 | Common Lisp | .lisp | 27 | 30.740741 | 81 | 0.451238 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | fc3e1bf4162519aeea2cfcdfb92c4adc00fc34a59ad4b6cef7685ee2b49cfd87 | 22,314 | [
-1
] |
22,315 | gordon.asd | sgarciac_gordon/gordon.asd | ;;; COPYRIGHT 2006 Sergio Garcia <[email protected]>
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU Lesser General Public License as published by
;;; the Free Software Foundation; either version 2.1 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(in-package #:cl-user)
(defpackage #:gordon-system
(:use #:asdf #:cl))
(in-package #:gordon-system)
(defsystem "gordon"
:depends-on ()
:components (
; external packages
(:file "packages")
; basic infrastructure
(:file "basic-constants" :depends-on ("packages"))
(:file "utilities" :depends-on ("basic-constants"))
; ttf related files
;flash files
(:file "basic-classes" :depends-on ("utilities"))
(:file "basic-types" :depends-on ("basic-constants" "utilities"))
(:file "types" :depends-on ("basic-types" "basic-classes"))
(:file "constants" :depends-on ("types"))
(:file "contours" :depends-on ("constants"))
(:file "types-library" :depends-on ("contours"))
(:file "actions" :depends-on ("constants"))
(:file "tags" :depends-on ("constants"))
(:file "movie" :depends-on ("constants"))))
| 1,660 | Common Lisp | .asd | 38 | 40.763158 | 79 | 0.696539 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | a95d057c69d7c60fb1b447723329223113c6ae86553baff38f859d1bf2a706b4 | 22,315 | [
-1
] |
22,335 | test-all.sh | sgarciac_gordon/demos/test-all.sh | #!/bin/bash
for file in *.lisp; do
echo \"$file\"
sbcl --eval "(progn (load-system :gordon) (load \"$file\") (quit))"
done
| 123 | Common Lisp | .l | 5 | 23.6 | 67 | 0.635593 | sgarciac/gordon | 2 | 1 | 3 | LGPL-2.1 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | d6509830159ebf5dc28a4d2be404fd1bbfd358be3e66dd0fe8fd3aa005b579ba | 22,335 | [
-1
] |
22,357 | group.lisp | joelagnel_stumpwm/group.lisp | ;; Copyright (C) 2003-2008 Shawn Betts
;;
;; This file is part of stumpwm.
;;
;; stumpwm is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; stumpwm is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;; Commentary:
;;
;; All group related code resides here
;;
;; Code:
(in-package #:stumpwm)
(export '(current-group))
(defvar *default-group-type* 'tile-group
"The type of group that should be created by default.")
(defclass group ()
((screen :initarg :screen :accessor group-screen)
(windows :initform nil :accessor group-windows)
(number :initarg :number :accessor group-number)
(name :initarg :name :accessor group-name)))
;;; The group API
(defgeneric group-add-window (group window &key &allow-other-keys)
(:documentation "Called when a window is added to the group. All
house keeping is already taken care of. Only the group's specific
window managing housekeeping need be done. This function accepts keys
to inform the group on how to place the window."))
(defgeneric group-delete-window (group window)
(:documentation "Called when a window is removed from thegroup. All
house keeping is already taken care of. Only the group's specific
window managing housekeeping need be done."))
(defgeneric group-wake-up (group)
(:documentation "When the group becomes the current group, this
function is called. This call is expected to set the focus."))
(defgeneric group-suspend (group)
(:documentation "When the group is no longer the current group, this
function is called."))
(defgeneric group-current-window (group)
(:documentation "The group is asked to return its focused window."))
(defgeneric group-current-head (group)
(:documentation "The group is asked to return its current head."))
(defgeneric group-resize-request (group window width height)
(:documentation "The window requested a width and/or height change."))
(defgeneric group-move-request (group window x y relative-to)
(:documentation "The window requested a position change."))
(defgeneric group-raise-request (group window type)
(:documentation "A request has been made to raise the window. TYPE
is the type of raise request being made. :MAP means the window has
made requested to be mapped. :above means the window has requested to
to be placed above its siblings."))
(defgeneric group-lost-focus (group)
(:documentation "The current window was hidden or destroyed or
something happened to it. So the group is asked to do something smart
about it."))
(defgeneric group-indicate-focus (group)
(:documentation "The group is asked to in some way show the user where the keyboard focus is."))
(defgeneric group-focus-window (group win)
(:documentation "The group is asked to focus the specified window wherever it is."))
(defgeneric group-button-press (group x y child)
(:documentation "The user clicked somewhere in the group."))
(defgeneric group-root-exposure (group)
(:documentation "The root window got an exposure event. If the group
needs to redraw anything on it, this is where it should do it."))
(defgeneric group-add-head (group)
(:documentation "A new head was added."))
(defgeneric group-sync-head (group head)
(:documentation "When a head or its usable area is resized, this is
called. When the modeline size changes, this is called."))
(defun current-group (&optional (screen (current-screen)))
"Return the current group for the current screen, unless
otherwise specified."
(screen-current-group screen))
(defun move-group-to-head (screen group)
"Move window to the head of the group's window list."
;(assert (member window (screen-mapped-windows screen)))
(move-to-head (screen-groups screen) group))
(defun sort-groups (screen)
"Return a copy of the screen's group list sorted by number."
(sort1 (screen-groups screen) '< :key 'group-number))
(defun fmt-group-status (group)
(let ((screen (group-screen group)))
(cond ((eq group (screen-current-group screen))
#\*)
((and (typep (second (screen-groups screen)) 'group)
(eq group (second (screen-groups screen))))
#\+)
(t #\-))))
(defun find-free-group-number (screen)
"Return a free group number in SCREEN."
(find-free-number (mapcar 'group-number (screen-groups screen)) 1))
(defun find-free-hidden-group-number (screen)
"Return a free hidden group number for SCREEN. Hidden group numbers
start at -1 and go down."
(find-free-number (mapcar 'group-number (screen-groups screen)) -1 :negative))
(defun non-hidden-groups (groups)
"Return only those groups that are not hidden."
(remove-if (lambda (g)
(< (group-number g) 1))
groups))
(defun netwm-group-id (group)
"netwm specifies that desktop/group numbers are contiguous and start
at 0. Return a netwm compliant group id."
(let ((screen (group-screen group)))
(position group (sort-groups screen))))
(defun switch-to-group (new-group)
(let* ((screen (group-screen new-group))
(old-group (screen-current-group screen)))
(unless (eq new-group old-group)
;; restore the visible windows
(dolist (w (group-windows new-group))
(when (eq (window-state w) +normal-state+)
(xwin-unhide (window-xwin w) (window-parent w))))
(dolist (w (reverse (group-windows old-group)))
(when (eq (window-state w) +normal-state+)
(xwin-hide w)))
(setf (screen-current-group screen) new-group)
(move-group-to-head screen new-group)
;; restore the focus
(setf (screen-focus screen) nil)
(group-wake-up new-group)
(xlib:change-property (screen-root screen) :_NET_CURRENT_DESKTOP
(list (netwm-group-id new-group))
:cardinal 32)
(update-all-mode-lines)
(run-hook-with-args *focus-group-hook* new-group old-group))))
(defun move-window-to-group (window to-group)
(labels ((really-move-window (window to-group)
(unless (eq (window-group window) to-group)
(hide-window window)
;; house keeping
(setf (group-windows (window-group window))
(remove window (group-windows (window-group window))))
(group-delete-window (window-group window) window)
(setf (window-group window) to-group
(window-number window) (find-free-window-number to-group))
(push window (group-windows to-group))
(xlib:change-property (window-xwin window) :_NET_WM_DESKTOP
(list (netwm-group-id to-group))
:cardinal 32)
(group-add-window to-group window))))
;; When a modal window is moved, all the windows it shadows must be moved
;; as well. When a shadowed window is moved, the modal shadowing it must
;; be moved.
(cond
((window-modal-p window)
(mapc (lambda (w)
(really-move-window w to-group))
(append (list window) (shadows-of window))))
((modals-of window)
(mapc (lambda (w)
(move-window-to-group w to-group))
(modals-of window)))
(t
(really-move-window window to-group)))))
(defun next-group (current &optional (list (screen-groups (group-screen current))))
;; ditch the negative groups
(setf list (non-hidden-groups list))
(let* ((matches (member current list)))
(if (null (cdr matches))
;; If the last one in the list is current, then
;; use the first one.
(car list)
;; Otherwise, use the next one in the list.
(cadr matches))))
(defun merge-groups (from-group to-group)
"Merge all windows in FROM-GROUP into TO-GROUP."
(dolist (window (group-windows from-group))
(move-window-to-group window to-group)))
(defun netwm-group (window &optional (screen (window-screen window)))
"Get the window's desktop property and return a matching group, if
there exists one."
(let ((id (first (xlib:get-property (window-xwin window) :_NET_WM_DESKTOP))))
(when (and id (< id (length (screen-groups screen))))
(elt (sort-groups screen) id))))
(defun netwm-set-group (window)
"Set the desktop property for the given window."
(xlib:change-property (window-xwin window) :_NET_WM_DESKTOP
(list (netwm-group-id (window-group window)))
:cardinal 32))
(defun netwm-set-allowed-actions (window)
(xlib:change-property (window-xwin window) :_NET_WM_ALLOWED_ACTIONS
(mapcar (lambda (a)
(xlib:intern-atom *display* a))
+netwm-allowed-actions+)
:atom 32))
(defun netwm-update-groups (screen)
"update all windows to reflect a change in the group list."
;; FIXME: This could be optimized only to update windows when there
;; is a need.
(loop for i from 0
for group in (sort-groups screen)
do (dolist (w (group-windows group))
(xlib:change-property (window-xwin w) :_NET_WM_DESKTOP
(list i)
:cardinal 32))))
(defun netwm-set-group-properties (screen)
"Set NETWM properties regarding groups of SCREEN.
Groups are known as \"virtual desktops\" in the NETWM standard."
(let ((root (screen-root screen)))
;; _NET_NUMBER_OF_DESKTOPS
(xlib:change-property root :_NET_NUMBER_OF_DESKTOPS
(list (length (screen-groups screen)))
:cardinal 32)
(unless *initializing*
;; _NET_CURRENT_DESKTOP
(xlib:change-property root :_NET_CURRENT_DESKTOP
(list (netwm-group-id (screen-current-group screen)))
:cardinal 32))
;; _NET_DESKTOP_NAMES
(xlib:change-property root :_NET_DESKTOP_NAMES
(let ((names (mapcan
(lambda (group)
(list (string-to-utf8 (group-name group))
'(0)))
(sort-groups screen))))
(apply #'concatenate 'list names))
:UTF8_STRING 8)))
(defun kill-group (group to-group)
(unless (eq group to-group)
(let ((screen (group-screen group)))
(merge-groups group to-group)
(setf (screen-groups screen) (remove group (screen-groups screen)))
(netwm-update-groups screen)
(netwm-set-group-properties screen))))
(defun add-group (screen name &optional (type *default-group-type*))
"Create a new group in SCREEN with the supplied name. group names
starting with a . are considered hidden groups. Hidden groups are
skipped by gprev and gnext and do not show up in the group
listings (unless *list-hidden-groups* is T). They also use negative
numbers."
(check-type screen screen)
(check-type name string)
(unless (or (string= name "")
(string= name "."))
(or (find-group screen name)
(let ((ng (make-instance type
:screen screen
:number (if (char= (char name 0) #\.)
(find-free-hidden-group-number screen)
(find-free-group-number screen))
:name name)))
(setf (screen-groups screen) (append (screen-groups screen) (list ng)))
(netwm-set-group-properties screen)
(netwm-update-groups screen)
ng))))
(defun find-group (screen name)
"Return the group with the name, NAME. Or NIL if none exists."
(find name (screen-groups screen) :key 'group-name :test 'string=))
;;; Group commands
;; FIXME: groups are to screens exactly as windows are to
;; groups. There is a lot of duplicate code that could be globbed
;; together.
(defun group-forward (current list)
"Switch to the next group in the list, if one exists. Returns the
new group."
(let ((ng (next-group current list)))
(when ng
(switch-to-group ng)
ng)))
(defun group-forward-with-window (current list)
"Switch to the next group in the list, if one exists, and moves the
current window of the current group to the new one."
(let ((next (group-forward current list))
(win (group-current-window current)))
(when (and next win)
(move-window-to-group win next)
(really-raise-window win))))
(defcommand gnew (name) ((:string "Group Name: "))
"Create a new group with the specified name. The new group becomes the
current group. If @var{name} begins with a dot (``.'') the group new
group will be created in the hidden state. Hidden groups have group
numbers less than one and are invisible to from gprev, gnext, and, optionally,
groups and vgroups commands."
(let ((group (add-group (current-screen) name)))
(if group
(switch-to-group group)
(message "^B^3*Groups must have a name!"))))
(defcommand gnewbg (name) ((:string "Group Name: "))
"Create a new group but do not switch to it."
(unless (find-group (current-screen) name)
(add-group (current-screen) name)))
(defcommand gnext () ()
"Cycle to the next group in the group list."
(group-forward (current-group)
(sort-groups (current-screen))))
(defcommand gprev () ()
"Cycle to the previous group in the group list."
(group-forward (current-group)
(reverse (sort-groups (current-screen)))))
(defcommand gnext-with-window () ()
"Cycle to the next group in the group list, taking the current
window along."
(group-forward-with-window (current-group)
(sort-groups (current-screen))))
(defcommand gprev-with-window () ()
"Cycle to the previous group in the group list, taking the current
window along."
(group-forward-with-window (current-group)
(reverse (sort-groups (current-screen)))))
(defcommand gother () ()
"Go back to the last group."
(let ((groups (screen-groups (current-screen))))
(when (> (length groups) 1)
(switch-to-group (second groups)))))
(defcommand grename (name) ((:string "New name for group: "))
"Rename the current group."
(let ((group (current-group)))
(cond ((find-group (current-screen) name)
(message "^1*^BError: Name already exists"))
((or (zerop (length name))
(string= name "."))
(message "^1*^BError: empty name"))
(t
(cond ((and (char= (char name 0) #\.) ;change to hidden group
(not (char= (char (group-name group) 0) #\.)))
(setf (group-number group) (find-free-hidden-group-number (current-screen))))
((and (not (char= (char name 0) #\.)) ;change from hidden group
(char= (char (group-name group) 0) #\.))
(setf (group-number group) (find-free-group-number (current-screen)))))
(setf (group-name group) name)))))
(defun echo-groups (screen fmt &optional verbose (wfmt *window-format*))
"Print a list of the windows to the screen."
(let* ((groups (sort-groups screen))
(names (mapcan (lambda (g)
(list*
(format-expand *group-formatters* fmt g)
(when verbose
(mapcar (lambda (w)
(format-expand *window-formatters*
(concatenate 'string " " wfmt)
w))
(sort-windows g)))))
(if *list-hidden-groups* groups (non-hidden-groups groups)))))
(echo-string-list screen names)))
(defcommand groups (&optional (fmt *group-format*)) (:rest)
"Display the list of groups with their number and
name. @var{*group-format*} controls the formatting. The optional
argument @var{fmt} can be used to override the default group
formatting."
(echo-groups (current-screen) fmt))
(defcommand vgroups (&optional gfmt wfmt) (:string :rest)
"Like @command{groups} but also display the windows in each group. The
optional arguments @var{gfmt} and @var{wfmt} can be used to override
the default group formatting and window formatting, respectively."
(echo-groups (current-screen)
(or gfmt *group-format*)
t (or wfmt *window-format*)))
(defcommand gselect (to-group) ((:group "Select Group: "))
"Select the first group that starts with
@var{substring}. @var{substring} can also be a number, in which case
@command{gselect} selects the group with that number."
(when to-group
(switch-to-group to-group)))
(defcommand grouplist (&optional (fmt *group-format*)) (:rest)
"Allow the user to select a group from a list, like windowlist but
for groups"
(let ((group (second (select-from-menu
(current-screen)
(mapcar (lambda (g)
(list (format-expand *group-formatters* fmt g) g))
(screen-groups (current-screen)))))))
(when group
(switch-to-group group))))
(defcommand gmove (to-group) ((:group "To Group: "))
"Move the current window to the specified group."
(when (and to-group
(current-window))
(move-window-to-group (current-window) to-group)))
(defcommand gmove-marked (to-group) ((:group "To Group: "))
"move the marked windows to the specified group."
(when to-group
(let ((group (current-group)))
(dolist (i (marked-windows group))
(setf (window-marked i) nil)
(move-window-to-group i to-group)))))
(defcommand gkill () ()
"Kill the current group. All windows in the current group are migrated
to the next group."
(let ((dead-group (current-group))
(to-group (next-group (current-group))))
(if (eq dead-group to-group)
(message "There's only one visible group")
(if (or (not %interactivep%)
(not (group-windows dead-group))
(y-or-n-p
(format nil "You are about to kill non-empty group \"^B^3*~a^n\"
The windows will be moved to group \"^B^2*~a^n\"
^B^6*Confirm?^n " (group-name dead-group) (group-name to-group))))
(progn
(kill-group dead-group to-group)
(switch-to-group to-group)
(message "Deleted"))
(message "Canceled")))))
(defcommand gmerge (from) ((:group "From Group: "))
"Merge @var{from} into the current group. @var{from} is not deleted."
(if (eq from (current-group))
(message "^B^3*Cannot merge group with itself!")
(merge-groups from (current-group))))
| 19,262 | Common Lisp | .lisp | 407 | 39.609337 | 98 | 0.643093 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 83e3f588228e95898518e1cd7601392d57072640caf1c21c1436d87589f5a333 | 22,357 | [
-1
] |
22,359 | mode-line-cubes.lisp | joelagnel_stumpwm/mode-line-cubes.lisp | ;;; Modeline cubes - A group switcher widget for the mode-line
(in-package :stumpwm)
(export '(create-cube create-cubes destroy-cubes find-cube-window cube-clicked))
(defparameter *cubes* '())
;; Show Group numbers or Group formatted names?
(defparameter *cube-display-number* nil)
;; border
(defparameter *cube-border-width* 1)
(defparameter *cube-border-color* "Black")
;; colors
(defparameter *cube-background* "Gray")
(defparameter *cube-background-toggled* "Orange")
(defparameter *cube-foreground* "Black")
(defparameter *cube-foreground-toggled* "Black")
(defstruct cube
state
number
group
window
gcontext-normal
gcontext-toggled)
(defun create-cube (ml group &optional (x 0))
"Create cube numer num at position x on mode-line ml"
(let* ((screen (mode-line-screen ml))
(font (screen-font screen))
(parent (mode-line-window ml))
(win (xlib:create-window
:parent parent
:x x
:y 0
:width (* (xlib:char-width (screen-font screen) 0) 2)
:height (mode-line-height ml)
:border (alloc-color screen *cube-border-color*)
:border-width *cube-border-width*
:event-mask (xlib:make-event-mask :exposure :button-press)))
(fg (alloc-color screen *cube-foreground*))
(bg (alloc-color screen *cube-background*))
(fg-toggled (alloc-color screen *cube-foreground-toggled*))
(bg-toggled (alloc-color screen *cube-background-toggled*))
(gcontext-normal (xlib:create-gcontext :drawable win
:font font
:foreground fg
:background bg))
(gcontext-toggled (xlib:create-gcontext :drawable win
:font font
:foreground fg-toggled
:background bg-toggled))
(cube (make-cube :state :normal
:number (group-number group)
:group group
:window win
; :mode-line ml
:gcontext-normal gcontext-normal
:gcontext-toggled gcontext-toggled))
(pixmap nil))
(setf (xlib:window-plist win) (list 'cube cube 'pixmap pixmap))
cube))
(defun toggle-cube (cube)
(cond ((eq (cube-state cube) :normal)
(setf (cube-state cube) :toggled))
((eq (cube-state cube) :toggled)
(setf (cube-state cube) :normal))))
(defun add-cube-group (ml group)
(setf (mode-line-cubes ml)
(sort (append (mode-line-cubes ml) (list (create-cube ml group)))
#'< :key 'cube-number)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; cube events ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; click
(defun cube-clicked (cube)
(let ((new-group (find (cube-number cube) (screen-groups (current-screen)) :key 'group-number)))
(and new-group (switch-to-group new-group))))
;; exposure
(defun draw-cube (cube)
(let* ((win (cube-window cube))
(px (getf (xlib:window-plist win) 'pixmap))
(gc (or (and (eq (cube-state cube) :toggled) (cube-gcontext-toggled cube))
(cube-gcontext-normal cube)))
(font (xlib:gcontext-font gc))
;(xlib:char-width font 0))
(string (cube-string cube))
(char-width (xlib:char-width font 0))
(text-width (xlib:text-width font string))
(window-width (+ text-width
char-width)))
;; change window width if different
(unless (eq (xlib:drawable-width win) window-width)
(setf (xlib:drawable-width win) window-width))
;; create pixmap if required
(when (or (not px)
(/= (xlib:drawable-width px) (xlib:drawable-width win))
(/= (xlib:drawable-height px) (xlib:drawable-height win)))
(setf px (xlib:create-pixmap
:drawable win
:width (xlib:drawable-width win)
:height (xlib:drawable-height win)
:depth (xlib:drawable-depth win))
(getf (xlib:window-plist win) 'pixmap) px))
;; sync window background with gc background
(setf (xlib:window-background win) (xlib:gcontext-background gc))
(xlib:map-window win)
;; draw text
(xlib:clear-area win)
(xlib:with-gcontext (gc :foreground (xlib:gcontext-background gc))
(xlib:draw-rectangle px gc 0 0 (xlib:drawable-width px) (xlib:drawable-height px) t))
(xlib:draw-image-glyphs px gc (round (/ char-width 2)) ;; char-width / 2 draws at center
(xlib:font-ascent font)
string
:translate #'translate-id
:size 16)
(xlib:copy-area px gc 0 0 (xlib:drawable-width px) (xlib:drawable-height px) win 0 0)
(xlib:display-finish-output *display*)))
(defun cube-string (cube)
(if *cube-display-number*
(write-to-string (group-number (cube-group cube)))
(format-expand *group-formatters* *group-format* (cube-group cube))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; cube management ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun destroy-cubes (ml)
(setf (mode-line-cubes ml) (remove-if (lambda (cube)
(xlib:destroy-window (cube-window cube)) t)
(mode-line-cubes ml)))
(xlib:display-finish-output *display*))
(defun find-cube-window (win)
(second (xlib:window-plist win)))
(defun find-cube-number (ml num)
(find-if (lambda (cube)
(eq (cube-number cube) num))
(mode-line-cubes ml)))
(defun find-cube-group (ml group)
(find-if (lambda (cube)
(eq (cube-group cube) group))
(mode-line-cubes ml)))
;; Delete a cube window and remove it from *cubes*
;; Apply key on each cube and delete if = arg
(defun delete-cube (ml arg key)
(setf (mode-line-cubes ml) (remove-if (lambda (cube)
(if (eq (funcall (symbol-function key) cube) arg)
(progn (xlib:destroy-window (cube-window cube)) t)))
(mode-line-cubes ml)))
;; (unless (zerop (length (mode-line-cubes ml))) (rearrange-cubes ml))
(xlib:display-finish-output *display*))
(defun rearrange-cubes (ml &optional (x 0))
(and
(mode-line-cubes ml)
(progn (setf (xlib:drawable-x (cube-window (first (mode-line-cubes ml))))
x)
(reduce (lambda (cube1 cube2)
(let* ((cube1-win (cube-window cube1))
(cube1-width (xlib:drawable-width cube1-win))
(cube2-x (+ (xlib:drawable-x cube1-win) cube1-width)))
(setf (xlib:drawable-x (cube-window cube2)) cube2-x))
cube2)
(mode-line-cubes ml))
(redraw-cubes ml)
(xlib:display-finish-output *display*))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stumpwm environment ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun create-mode-line-cubes (ml)
(destroy-cubes ml)
(dolist (w (sort-groups (group-screen (mode-line-current-group ml))))
(add-cube-group ml w)))
;; redraw cube windows
(defun redraw-cubes (ml)
(mapcar (lambda (cube)
(setf (cube-state cube)
(if (eq (cube-number cube) (group-number (current-group)))
:toggled
:normal))
(draw-cube cube))
(mode-line-cubes ml)))
(defun cube-switch (new old)
(let ((mls (mapcar (lambda (head) (head-mode-line head))
(screen-heads (group-screen new)))))
(mapcar (lambda (ml)
(when ml
;; Create cube for a new group
(if (not (find-cube-group ml new))
(add-cube-group ml new)
(redraw-cubes ml))
;; Delete cube if 'old' group doesn't exist
(if (not (find old (screen-groups (group-screen new))))
(delete-cube ml old 'cube-group))))
mls)))
(defun add-cube-switch-hook ()
;; Group Switch hook
;; To be moved to switch-to-group in group.lisp or update-mode-line
(add-hook *focus-group-hook* (lambda (new old) (cube-switch new old))))
| 8,661 | Common Lisp | .lisp | 191 | 33.91623 | 98 | 0.539673 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | e7c7c3ffe973252c0c3fe2643e61f09fa9cc8614f2fefbb1bd008f7ef56f410b | 22,359 | [
-1
] |
22,361 | version.lisp.in | joelagnel_stumpwm/version.lisp.in | ;; Copyright (C) 2006-2008 Martin Bishop, Ivy Foster
;;
;; This file is part of stumpwm.
;;
;; stumpwm is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; stumpwm is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;; Commentary:
;;
;; This file contains version information.
;;
;; Code:
(in-package :stumpwm)
(export '(*version* version))
(defparameter *version*
#.(concatenate 'string "@PACKAGE_VERSION@ Compiled On "
(format-expand *time-format-string-alist*
*time-format-string-default*)))
(defcommand version () ()
(message *version*))
;; End of file
| 1,166 | Common Lisp | .lisp | 30 | 37.033333 | 71 | 0.742908 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 6ba40e9dd0baf14fe5139b0d0df41980b27f18a87692f36a5abca130cae2b3cc | 22,361 | [
-1
] |
22,362 | primitives.lisp | joelagnel_stumpwm/primitives.lisp | ;; Copyright (C) 2003-2008 Shawn Betts
;;
;; This file is part of stumpwm.
;;
;; stumpwm is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; stumpwm is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;; Commentary:
;;
;; This file contains primitive data structures and functions used
;; throughout stumpwm.
;;
;; Code:
(in-package :stumpwm)
(export '(*suppress-abort-messages*
*timeout-wait*
*timeout-frame-indicator-wait*
*frame-indicator-timer*
*message-window-timer*
*urgent-window-hook*
*new-window-hook*
*destroy-window-hook*
*focus-window-hook*
*place-window-hook*
*start-hook*
*internal-loop-hook*
*focus-frame-hook*
*new-frame-hook*
*message-hook*
*top-level-error-hook*
*focus-group-hook*
*key-press-hook*
*root-click-hook*
*mode-line-click-hook*
*display*
*shell-program*
*maxsize-border-width*
*transient-border-width*
*normal-border-width*
*text-color*
*window-events*
*window-parent-events*
*message-window-padding*
*message-window-gravity*
*editor-bindings*
*input-window-gravity*
*normal-gravity*
*maxsize-gravity*
*transient-gravity*
*top-level-error-action*
*window-name-source*
*frame-number-map*
*all-modifiers*
*modifiers*
*screen-list*
*initializing*
*processing-existing-windows*
*executing-stumpwm-command*
*debug-level*
*debug-expose-events*
*debug-stream*
*window-formatters*
*window-format*
*group-formatters*
*group-format*
*list-hidden-groups*
*x-selection*
*last-command*
*max-last-message-size*
*record-last-msg-override*
*suppress-echo-timeout*
*run-or-raise-all-groups*
*run-or-raise-all-screens*
*deny-map-request*
*deny-raise-request*
*suppress-deny-messages*
*honor-window-moves*
*resize-hides-windows*
*min-frame-width*
*min-frame-height*
*new-frame-action*
*new-window-preferred-frame*
*startup-message*
*default-package*
*window-placement-rules*
*mouse-focus-policy*
*root-click-focuses-frame*
*banish-pointer-to*
*xwin-to-window*
*resize-map*
*default-group-name*
*window-border-style*
*data-dir*
add-hook
clear-window-placement-rules
data-dir-file
dformat
define-frame-preference
redirect-all-output
remove-hook
run-hook
run-hook-with-args
split-string
with-restarts-menu
with-data-file
move-to-head))
;;; Message Timer
(defvar *suppress-abort-messages* nil
"Suppress abort message when non-nil.")
(defvar *timeout-wait* 5
"Specifies, in seconds, how long a message will appear for. This must
be an integer.")
(defvar *timeout-frame-indicator-wait* 1
"The amount of time a frame indicator timeout takes.")
(defvar *frame-indicator-timer* nil
"Keep track of the timer that hides the frame indicator.")
(defvar *frame-indicator-text* " Current Frame "
"What appears in the frame indicator window?")
(defvar *suppress-frame-indicator* nil
"Set this to T if you never want to see the frame indicator.")
(defvar *message-window-timer* nil
"Keep track of the timer that hides the message window.")
;;; Hooks
(defvar *urgent-window-hook* '()
"A hook called whenever a window sets the property indicating that
it demands the user's attention")
(defvar *map-window-hook* '()
"A hook called whenever a window is mapped.")
(defvar *unmap-window-hook* '()
"A hook called whenever a window is withdrawn.")
(defvar *new-window-hook* '()
"A hook called whenever a window is added to the window list. This
includes a genuinely new window as well as bringing a withdrawn window
back into the window list.")
(defvar *destroy-window-hook* '()
"A hook called whenever a window is destroyed or withdrawn.")
(defvar *focus-window-hook* '()
"A hook called when a window is given focus. It is called with 2
arguments: the current window and the last window (could be nil).")
(defvar *place-window-hook* '()
"A hook called whenever a window is placed by rule. Arguments are
window group and frame")
(defvar *start-hook* '()
"A hook called when stumpwm starts.")
(defvar *internal-loop-hook* '()
"A hook called inside stumpwm's inner loop.")
(defvar *focus-frame-hook* '()
"A hook called when a frame is given focus. The hook functions are
called with 2 arguments: the current frame and the last frame.")
(defvar *new-frame-hook* '()
"A hook called when a new frame is created. the hook is called with
the frame as an argument.")
(defvar *message-hook* '()
"A hook called whenever stumpwm displays a message. The hook
function is passed any number of arguments. Each argument is a
line of text.")
(defvar *top-level-error-hook* '()
"Called when a top level error occurs. Note that this hook is
run before the error is dealt with according to
*top-level-error-action*.")
(defvar *focus-group-hook* '()
"A hook called whenever stumpwm switches groups. It is called with 2 arguments: the current group and the last group.")
(defvar *key-press-hook* '()
"A hook called whenever a key under *top-map* is pressed.
It is called with 3 argument: the key, the (possibly incomplete) key
sequence it is a part of, and command value bound to the key.")
(defvar *root-click-hook* '()
"A hook called whenever there is a mouse click on the root
window. Called with 4 arguments, the screen containing the root
window, the button clicked, and the x and y of the pointer.")
(defvar *mode-line-click-hook* '()
"Called whenever the mode-line is clicked. It is called with 4 arguments,
the mode-line, the button clicked, and the x and y of the pointer.")
;; Data types and globals used by stumpwm
(defvar *display* nil
"The display for the X server")
(defvar *shell-program* "/bin/sh"
"The shell program used by @code{run-shell-command}.")
(defvar *maxsize-border-width* 1
"The width in pixels given to the borders of windows with maxsize or ratio hints.")
(defvar *transient-border-width* 1
"The width in pixels given to the borders of transient or pop-up windows.")
(defvar *normal-border-width* 1
"The width in pixels given to the borders of regular windows.")
(defvar *text-color* "white"
"The color of message text.")
(defparameter +netwm-supported+
'(:_NET_SUPPORTING_WM_CHECK
:_NET_NUMBER_OF_DESKTOPS
:_NET_DESKTOP_GEOMETRY
:_NET_DESKTOP_VIEWPORT
:_NET_CURRENT_DESKTOP
:_NET_WM_WINDOW_TYPE
:_NET_WM_STATE
:_NET_WM_STATE_MODAL
:_NET_WM_ALLOWED_ACTIONS
:_NET_WM_STATE_FULLSCREEN
:_NET_WM_STATE_HIDDEN
:_NET_WM_STATE_DEMANDS_ATTENTION
:_NET_WM_FULL_WINDOW_PLACEMENT
:_NET_CLOSE_WINDOW
:_NET_CLIENT_LIST
:_NET_CLIENT_LIST_STACKING
:_NET_ACTIVE_WINDOW
:_KDE_NET_SYSTEM_TRAY_WINDOW_FOR)
"Supported NETWM properties.
Window types are in +WINDOW-TYPES+.")
(defparameter +netwm-allowed-actions+
'(:_NET_WM_ACTION_CHANGE_DESKTOP
:_NET_WM_ACTION_FULLSCREEN
:_NET_WM_ACTION_CLOSE)
"Allowed NETWM actions for managed windows")
(defparameter +netwm-window-types+
'(
;; (:_NET_WM_WINDOW_TYPE_DESKTOP . :desktop)
(:_NET_WM_WINDOW_TYPE_DOCK . :dock)
;; (:_NET_WM_WINDOW_TYPE_TOOLBAR . :toolbar)
;; (:_NET_WM_WINDOW_TYPE_MENU . :menu)
;; (:_NET_WM_WINDOW_TYPE_UTILITY . :utility)
;; (:_NET_WM_WINDOW_TYPE_SPLASH . :splash)
(:_NET_WM_WINDOW_TYPE_DIALOG . :dialog)
(:_NET_WM_WINDOW_TYPE_NORMAL . :normal))
"Alist mapping NETWM window types to keywords.
Include only those we are ready to support.")
;; Window states
(defconstant +withdrawn-state+ 0)
(defconstant +normal-state+ 1)
(defconstant +iconic-state+ 3)
(defvar *window-events* '(:structure-notify
:property-change
:colormap-change
:focus-change
:enter-window)
"The events to listen for on managed windows.")
(defvar *window-parent-events* '(:substructure-notify
:substructure-redirect)
"The events to listen for on managed windows' parents.")
;; Message window variables
(defvar *message-window-padding* 5
"The number of pixels that pad the text in the message window.")
(defvar *message-window-gravity* :top-right
"This variable controls where the message window appears. The follow
are valid values.
@table @asis
@item :top-left
@item :top-right
@item :bottom-left
@item :bottom-right
@item :center
@end table")
;; line editor
(defvar *editor-bindings* nil
"A list of key-bindings for line editing.")
(defvar *input-window-gravity* :top-right
"This variable controls where the input window appears. The follow
are valid values.
@table @asis
@item :top-left
@item :top-right
@item :bottom-left
@item :bottom-right
@item :center
@end table")
;; default values. use the set-* functions to these attributes
(defparameter +default-foreground-color+ "White")
(defparameter +default-background-color+ "Black")
(defparameter +default-window-background-color+ "Black")
(defparameter +default-border-color+ "White")
(defparameter +default-font-name+ "9x15bold")
(defparameter +default-focus-color+ "White")
(defparameter +default-unfocus-color+ "Black")
(defparameter +default-frame-outline-width+ 2)
;; Don't set these variables directly, use set-<var name> instead
(defvar *normal-gravity* :center)
(defvar *maxsize-gravity* :center)
(defvar *transient-gravity* :center)
(defvar *top-level-error-action* :abort
"If an error is encountered at the top level, in
STUMPWM-INTERNAL-LOOP, then this variable decides what action
shall be taken. By default it will print a message to the screen
and to *standard-output*.
Valid values are :message, :break, :abort. :break will break to the
debugger. This can be problematic because if the user hit's a
mapped key the ENTIRE keyboard will be frozen and you will have
to login remotely to regain control. :abort quits stumpmwm.")
(defvar *window-name-source* :title
"This variable controls what is used for the window's name. The default is @code{:title}.
@table @code
@item :title
Use the window's title given to it by its owner.
@item :class
Use the window's resource class.
@item :resource-name
Use the window's resource name.
@end table")
(defstruct frame
(number nil :type integer)
x
y
width
height
window)
(defstruct (head (:include frame))
;; point back to the screen this head belongs to
screen
;; a bar along the top or bottom that displays anything you want.
mode-line)
(defstruct screen
id
host
number
;; heads of screen
heads
;; the list of groups available on this screen
groups
current-group
;; various colors (as returned by alloc-color)
border-color
fg-color
bg-color
win-bg-color
focus-color
unfocus-color
msg-border-width
frame-outline-width
font
;; A list of all mapped windows. These are the raw
;; xlib:window's. window structures are stored in groups.
mapped-windows
;; A list of withdrawn windows. These are of type stumpwm::window
;; and when they're mapped again they'll be put back in the group
;; they were in when they were unmapped unless that group doesn't
;; exist, in which case they go into the current group.
withdrawn-windows
;; a list of windows for which (window-urgent-p) currently true.
urgent-windows
input-window
;; the window that accepts further keypresses after a toplevel key
;; has been pressed.
key-window
;; The window that gets focus when no window has focus
focus-window
;;
frame-window
frame-outline-gc
;; color contexts
message-cc
mode-line-cc
;; color maps
color-map-normal
color-map-bright
;; used to ignore the first expose even when mapping the message window.
ignore-msg-expose
;; the window that has focus
focus
current-msg
current-msg-highlights
last-msg
last-msg-highlights)
(defstruct ccontext
win
px
gc
default-fg
default-bright
default-bg)
(defun screen-message-window (screen)
(ccontext-win (screen-message-cc screen)))
(defun screen-message-pixmap (screen)
(ccontext-px (screen-message-cc screen)))
(defun screen-message-gc (screen)
(ccontext-gc (screen-message-cc screen)))
(defmethod print-object ((object frame) stream)
(format stream "#S(frame ~d ~a ~d ~d ~d ~d)"
(frame-number object) (frame-window object) (frame-x object) (frame-y object) (frame-width object) (frame-height object)))
(defvar *frame-number-map* "0123456789abcdefghijklmnopqrstuvxwyz"
"Set this to a string to remap the frame numbers to more convenient keys.
For instance,
\"hutenosa\"
would map frame 0 to 7 to be selectable by hitting the appropriate
homerow key on a dvorak keyboard. Currently, only single char keys are
supported. By default, the frame labels are the 36 (lower-case)
alphanumeric characters, starting with numbers 0-9.")
(defun get-frame-number-translation (frame)
"Given a frame return its number translation using *frame-number-map* as a char."
(let ((num (frame-number frame)))
(or (and (< num (length *frame-number-map*))
(char *frame-number-map* num))
;; translate the frame number to a char. FIXME: it loops after 9
(char (prin1-to-string num) 0))))
(defstruct modifiers
(meta nil)
(alt nil)
(hyper nil)
(super nil)
(altgr nil)
(numlock nil))
(defvar *all-modifiers* nil
"A list of all keycodes that are considered modifiers")
(defvar *modifiers* nil
"A mapping from modifier type to x11 modifier.")
(defmethod print-object ((object screen) stream)
(format stream "#S<screen ~s>" (screen-number object)))
(defvar *screen-list* '()
"The list of screens managed by stumpwm.")
(defvar *initializing* nil
"True when starting stumpwm. Use this variable in your rc file to
run code that should only be executed once, when stumpwm starts up and
loads the rc file.")
(defvar *processing-existing-windows* nil
"True when processing pre-existing windows at startup.")
(defvar *executing-stumpwm-command* nil
"True when executing external commands.")
(defvar *interactivep* nil
"True when a defcommand is executed from colon or a keybinding")
;;; The restarts menu macro
(defmacro with-restarts-menu (&body body)
"Execute BODY. If an error occurs allow the user to pick a
restart from a menu of possible restarts. If a restart is not
chosen, resignal the error."
(let ((c (gensym)))
`(handler-bind
((warning #'muffle-warning)
((or serious-condition error)
(lambda (,c)
(restarts-menu ,c)
(signal ,c))))
,@body)))
;;; Hook functionality
(defun run-hook-with-args (hook &rest args)
"Call each function in HOOK and pass args to it."
(handler-case
(with-simple-restart (abort-hooks "Abort running the remaining hooks.")
(with-restarts-menu
(dolist (fn hook)
(with-simple-restart (continue-hooks "Continue running the remaining hooks.")
(apply fn args)))))
(t (c) (message "^B^1*Error on hook ^b~S^B!~% ^n~A" hook c) (values nil c))))
(defun run-hook (hook)
"Call each function in HOOK."
(run-hook-with-args hook))
(defmacro add-hook (hook fn)
"Add @var{function} to the hook @var{hook-variable}. For example, to
display a message whenever you switch frames:
@example
\(defun my-rad-fn (from-frame to-frame)
(stumpwm:message \"Mustard!\"))
\(stumpmwm:add-hook stumpwm:*focus-frame-hook* 'my-rad-fn)
@end example"
`(setf ,hook (adjoin ,fn ,hook)))
(defmacro remove-hook (hook fn)
"Remove the specified function from the hook."
`(setf ,hook (remove ,fn ,hook)))
;; Misc. utility functions
(defun conc1 (list arg)
"Append arg to the end of list"
(nconc list (list arg)))
(defun sort1 (list sort-fn &rest keys &key &allow-other-keys)
"Return a sorted copy of list."
(let ((copy (copy-list list)))
(apply 'sort copy sort-fn keys)))
(defun mapcar-hash (fn hash)
"Just like maphash except it accumulates the result in a list."
(let ((accum nil))
(labels ((mapfn (key val)
(push (funcall fn key val) accum)))
(maphash #'mapfn hash))
accum))
(defun find-free-number (l &optional (min 0) dir)
"Return a number that is not in the list l. If dir is :negative then
look for a free number in the negative direction. anything else means
positive direction."
(let* ((dirfn (if (eq dir :negative) '> '<))
;; sort it and crop numbers below/above min depending on dir
(nums (sort (remove-if (lambda (n)
(funcall dirfn n min))
l) dirfn))
(max (car (last nums)))
(inc (if (eq dir :negative) -1 1))
(new-num (loop for n = min then (+ n inc)
for i in nums
when (/= n i)
do (return n))))
(dformat 3 "Free number: ~S~%" nums)
(if new-num
new-num
;; there was no space between the numbers, so use the max+inc
(if max
(+ inc max)
min))))
(defun remove-plist (plist &rest keys)
"Remove the keys from the plist.
Useful for re-using the &REST arg after removing some options."
(do (copy rest)
((null (setq rest (nth-value 2 (get-properties plist keys))))
(nreconc copy plist))
(do () ((eq plist rest))
(push (pop plist) copy)
(push (pop plist) copy))
(setq plist (cddr plist))))
(defun screen-display-string (screen)
(format nil "DISPLAY=~a:~d.~d"
(screen-host screen)
(xlib:display-display *display*)
(screen-id screen)))
(defun split-seq (seq separators &key test default-value)
"split a sequence into sub sequences given the list of seperators."
(let ((seps separators))
(labels ((sep (c)
(find c seps :test test)))
(or (loop for i = (position-if (complement #'sep) seq)
then (position-if (complement #'sep) seq :start j)
as j = (position-if #'sep seq :start (or i 0))
while i
collect (subseq seq i j)
while j)
;; the empty seq causes the above to return NIL, so help
;; it out a little.
default-value))))
(defun split-string (string &optional (separators "
"))
"Splits STRING into substrings where there are matches for SEPARATORS.
Each match for SEPARATORS is a splitting point.
The substrings between the splitting points are made into a list
which is returned.
***If SEPARATORS is absent, it defaults to \"[ \f\t\n\r\v]+\".
If there is match for SEPARATORS at the beginning of STRING, we do not
include a null substring for that. Likewise, if there is a match
at the end of STRING, we don't include a null substring for that.
Modifies the match data; use `save-match-data' if necessary."
(split-seq string separators :test #'char= :default-value '("")))
(defun insert-before (list item nth)
"Insert ITEM before the NTH element of LIST."
(declare (type (integer 0 *) nth))
(let* ((nth (min nth (length list)))
(pre (subseq list 0 nth))
(post (subseq list nth)))
(nconc pre (list item) post)))
(defvar *debug-level* 0
"Set this variable to a number > 0 to turn on debugging. The greater the number the more debugging output.")
(defvar *debug-expose-events* nil
"Set this variable for a visual indication of expose events on internal StumpWM windows.")
(defvar *debug-stream* *error-output*
"This is the stream debugging output is sent to. It defaults to
*error-output*. It may be more convenient for you to pipe debugging
output directly to a file.")
(defun dformat (level fmt &rest args)
(when (>= *debug-level* level)
(multiple-value-bind (sec m h) (decode-universal-time (get-universal-time))
(format *debug-stream* "~2,'0d:~2,'0d:~2,'0d " h m sec))
;; strip out non base-char chars quick-n-dirty like
(write-string (map 'string (lambda (ch)
(if (typep ch 'standard-char)
ch #\?))
(apply 'format nil fmt args))
*debug-stream*)))
(defvar *redirect-stream* nil
"This variable Keeps track of the stream all output is sent to when
`redirect-all-output' is called so if it changes we can close it
before reopening.")
(defun redirect-all-output (file)
"Elect to redirect all output to the specified file. For instance,
if you want everything to go to ~/stumpwm.d/debug-output.txt you would
do:
@example
(redirect-all-output (data-dir-file \"debug-output\" \"txt\"))
@end example
"
(when (typep *redirect-stream* 'file-stream)
(close *redirect-stream*))
(setf *redirect-stream* (open file :direction :output :if-exists :append :if-does-not-exist :create)
*error-output* *redirect-stream*
*standard-output* *redirect-stream*
*trace-output* *redirect-stream*
*debug-stream* *redirect-stream*))
;;;
;;; formatting routines
(defun format-expand (fmt-alist fmt &rest args)
(let* ((chars (coerce fmt 'list))
(output "")
(cur chars))
;; FIXME: this is horribly inneficient
(loop
(cond ((null cur)
(return-from format-expand output))
;; if % is the last char in the string then it's a literal.
((and (char= (car cur) #\%)
(cdr cur))
(setf cur (cdr cur))
(let* ((tmp (loop while (and cur (char<= #\0 (car cur) #\9))
collect (pop cur)))
(len (and tmp (parse-integer (coerce tmp 'string)))))
(if (null cur)
(format t "%~a" len)
(let* ((fmt (cadr (assoc (car cur) fmt-alist :test 'char=)))
(str (cond (fmt
;; it can return any type, not jut as string.
(format nil "~a" (apply fmt args)))
((char= (car cur) #\%)
(string #\%))
(t
(concatenate 'string (string #\%) (string (car cur)))))))
;; crop string if needed
(setf output (concatenate 'string output (if len
(subseq str 0 (min len (length str)))
str)))
(setf cur (cdr cur))))))
(t
(setf output (concatenate 'string output (string (car cur)))
cur (cdr cur)))))))
(defvar *window-formatters* '((#\n window-number)
(#\s fmt-window-status)
(#\t window-name)
(#\c window-class)
(#\i window-res)
(#\r window-role)
(#\m fmt-window-marked)
(#\h window-height)
(#\w window-width)
(#\g gravity-for-window))
"an alist containing format character format function pairs for formatting window lists.")
(defvar *window-format* "%m%n%s%50t"
"This variable decides how the window list is formatted. It is a string
with the following formatting options:
@table @asis
@item %n
Substitute the window number.
@item %s
Substitute the window's status. * means current window, + means last
window, and - means any other window.
@item %t
Substitute the window's name.
@item %c
Substitute the window's class.
@item %i
Substitute the window's resource ID.
@item %m
Draw a # if the window is marked.
@end table
Note, a prefix number can be used to crop the argument to a specified
size. For instance, @samp{%20t} crops the window's title to 20
characters.")
(defvar *window-info-format* "%wx%h %n (%t)"
"The format used in the info command. @xref{*window-format*} for formatting details.")
(defvar *group-formatters* '((#\n group-number)
(#\s fmt-group-status)
(#\t group-name))
"An alist of characters and formatter functions. The character can be
used as a format character in @var{*group-format*}. When the character
is encountered in the string, the corresponding function is called
with a group as an argument. The functions return value is inserted
into the string. If the return value isn't a string it is converted to
one using @code{prin1-to-string}.")
(defvar *group-format* "%n%s%t"
"The format string that decides what information will show up in the
group listing. The following format options are available:
@table @asis
@item %n
The group's number.
@item %s
The group's status. Similar to a window's status.
@item %t
The group's name.
@end table")
(defvar *list-hidden-groups* nil
"Controls whether hidden groups are displayed by 'groups' and 'vgroups' commands")
(defun font-height (font)
(+ (xlib:font-descent font)
(xlib:font-ascent font)))
(defvar *x-selection* nil
"This holds stumpwm's current selection. It is generally set
when killing text in the input bar.")
(defvar *last-command* nil
"Set to the last interactive command run.")
(defvar *max-last-message-size* 20
"how many previous messages to keep.")
(defvar *record-last-msg-override* nil
"assign this to T and messages won't be recorded. It is
recommended this is assigned using LET.")
(defvar *suppress-echo-timeout* nil
"Assign this T and messages will not time out. It is recommended this is assigned using LET.")
(defvar *ignore-echo-timeout* nil
"Assign this T and the message time out won't be touched. It is recommended this is assigned using LET.")
(defvar *run-or-raise-all-groups* t
"When this is @code{T} the @code{run-or-raise} function searches all groups for a
running instance. Set it to NIL to search only the current group.")
(defvar *run-or-raise-all-screens* nil
"When this is @code{T} the @code{run-or-raise} function searches all screens for a
running instance. Set it to @code{NIL} to search only the current screen. If
@var{*run-or-raise-all-groups*} is @code{NIL} this variable has no effect.")
(defvar *deny-map-request* nil
"A list of window properties that stumpwm should deny matching windows'
requests to become mapped for the first time.")
(defvar *deny-raise-request* nil
"Exactly the same as @var{*deny-map-request*} but for raise requests.
Note that no denial message is displayed if the window is already visible.")
(defvar *suppress-deny-messages* nil
"For complete focus on the task at hand, set this to @code{T} and no
raise/map denial messages will be seen.")
(defvar *honor-window-moves* t
"Allow windows to move between frames.")
(defvar *resize-hides-windows* nil
"Set to T to hide windows during interactive resize")
(defun deny-request-p (window deny-list)
(or (eq deny-list t)
(and
(listp deny-list)
(find-if (lambda (props)
(apply 'window-matches-properties-p window props))
deny-list)
t)))
(defun list-splice-replace (item list &rest replacements)
"splice REPLACEMENTS into LIST where ITEM is, removing
ITEM. Return the new list."
(let ((p (position item list)))
(if p
(nconc (subseq list 0 p) replacements (subseq list (1+ p)))
list)))
(defvar *min-frame-width* 50
"The minimum width a frame can be. A frame will not shrink below this
width. Splitting will not affect frames if the new frame widths are
less than this value.")
(defvar *min-frame-height* 50
"The minimum height a frame can be. A frame will not shrink below this
height. Splitting will not affect frames if the new frame heights are
less than this value.")
(defvar *new-frame-action* :last-window
"When a new frame is created, this variable controls what is put in the
new frame. Valid values are
@table @code
@item :empty
The frame is left empty
@item :last-window
The last focused window that is not currently visible is placed in the
frame. This is the default.
@end table")
(defvar *new-window-preferred-frame* '(:focused)
"This variable controls what frame a new window appears in. It is a
list of preferences. The first preference that is satisfied is
used. Valid list elements are as follows:
@table @code
@item :focused
Choose the focused frame.
@item :last
Choose the last focused frame.
@item :empty
Choose any empty frame.
@item :unfocused
Choose any unfocused frame.
@end table
Alternatively, it can be set to a function that takes one argument, the new
window, and returns the preferred frame or a list of the above preferences.")
(defun backtrace-string ()
"Similar to print-backtrace, but return the backtrace as a string."
(with-output-to-string (*standard-output*)
(print-backtrace)))
(defvar *startup-message* "^2*Welcome to The ^BStump^b ^BW^bindow ^BM^banager!
Press ^5*~a ?^2* for help."
"This is the message StumpWM displays when it starts. Set it to NIL to
suppress.")
(defvar *default-package* (find-package '#:stumpwm-user)
"This is the package eval reads and executes in. You might want to set
this to @code{:stumpwm} if you find yourself using a lot of internal
stumpwm symbols. Setting this variable anywhere but in your rc file
will have no effect.")
(defun concat (&rest strings)
(apply 'concatenate 'string strings))
(defvar *window-placement-rules* '()
"List of rules governing window placement. Use define-frame-preference to
add rules")
(defmacro define-frame-preference (target-group &rest frame-rules)
"Create a rule that matches windows and automatically places them in
a specified group and frame. Each frame rule is a lambda list:
@example
\(frame-number raise lock &key create restore dump-name class instance type role title)
@end example
@table @var
@item frame-number
The frame number to send matching windows to
@item raise
When non-nil, raise and focus the window in its frame
@item lock
When this is nil, this rule will only match when the current group
matches @var{target-group}. When non-nil, this rule matches regardless
of the group and the window is sent to @var{target-group}. If
@var{lock} and @var{raise} are both non-nil, then stumpwm will jump to
the specified group and focus the matched window.
@item create
When non-NIL the group is created and eventually restored when the value of
create is a group dump filename in *DATA-DIR*. Defaults to NIL.
@item restore
When non-NIL the group is restored even if it already exists. This arg should
be set to the dump filename to use for forced restore. Defaults to NIL
@item class
The window's class must match @var{class}.
@item instance
The window's instance/resource name must match @var{instance}.
@item type
The window's type must match @var{type}.
@item role
The window's role must match @var{role}.
@item title
The window's title must match @var{title}.
@end table"
(let ((x (gensym "X")))
`(dolist (,x ',frame-rules)
;; verify the correct structure
(destructuring-bind (frame-number raise lock
&rest keys
&key create restore class instance type role title) ,x
(declare (ignore create restore class instance type role title))
(push (list* ,target-group frame-number raise lock keys)
*window-placement-rules*)))))
(defun clear-window-placement-rules ()
"Clear all window placement rules."
(setf *window-placement-rules* nil))
(defvar *mouse-focus-policy* :ignore
"The mouse focus policy decides how the mouse affects input
focus. Possible values are :ignore, :sloppy, and :click. :ignore means
stumpwm ignores the mouse. :sloppy means input focus follows the
mouse; the window that the mouse is in gets the focus. :click means
input focus is transfered to the window you click on.")
(defvar *root-click-focuses-frame* t
"Set to NIL if you don't want clicking the root window to focus the frame
containing the pointer when *mouse-focus-policy* is :click.")
(defvar *banish-pointer-to* :head
"Where to put the pointer when no argument is given to (banish-pointer) or the banish
command. May be one of :screen :head :frame or :window")
(defvar *xwin-to-window* (make-hash-table)
"Hash table for looking up windows quickly.")
(defvar *resize-map* nil
"The keymap used for resizing a window")
(defvar *default-group-name* "Default"
"The name of the default group.")
(defmacro with-focus (xwin &body body)
"Set the focus to xwin, do body, then restore focus"
`(progn
(grab-keyboard ,xwin)
(unwind-protect
(progn ,@body)
(ungrab-keyboard))))
(defvar *last-unhandled-error* nil
"If an unrecoverable error occurs, this variable will contain the
condition and the backtrace.")
(defvar *show-command-backtrace* nil
"When this is T a backtrace is displayed with errors that occurred
within an interactive call to a command.")
(defvar *window-border-style* :thick
"This controls the appearance of the border around windows. valid
values are:
@table @var
@item :thick
All space within the frame not used by the window is dedicated to the
border.
@item :thin
Only the border width as controlled by *maxsize-border-width*
*normal-border-width* and *transient-border-width* is used as the
border. The rest is filled with the unfocus color.
@item :tight
The same as :thin but the border surrounds the window and the wasted
space within the frame is not obscured, revealing the background.
@item :none
Like :tight but no border is ever visible.
@end table
After changing this variable you may need to call
sync-all-frame-windows to see the change.")
(defvar *data-dir* (make-pathname :directory (append (pathname-directory (user-homedir-pathname))
(list ".stumpwm.d")))
"The directory used by stumpwm to store data between sessions.")
(defun data-dir-file (name &optional type)
"Return a pathname inside stumpwm's data dir with the specified name and type"
(ensure-directories-exist *data-dir*)
(make-pathname :name name :type type :defaults *data-dir*))
(defmacro with-data-file ((s file &rest keys &key (if-exists :supersede) &allow-other-keys) &body body)
"Open a file in StumpWM's data directory. keyword arguments are sent
directly to OPEN. Note that IF-EXISTS defaults to :supersede, instead
of :error."
(declare (ignorable if-exists))
`(progn
(ensure-directories-exist *data-dir*)
(with-open-file (,s ,(merge-pathnames *data-dir* file)
,@keys)
,@body)))
(defmacro move-to-head (list elt)
"Move the specified element in in LIST to the head of the list."
`(progn
(setf ,list (remove ,elt ,list))
(push ,elt ,list)))
(define-condition stumpwm-error (error)
() (:documentation "Any stumpwm specific error should inherit this."))
(defun intern1 (thing &optional (package *package*) (rt *readtable*))
"A DWIM intern."
(intern
(ecase (readtable-case rt)
(:upcase (string-upcase thing))
(:downcase (string-downcase thing))
;; Prooobably this is what they want? It could make sense to
;; upcase them as well.
(:preserve thing)
(:invert (string-downcase thing)))
package))
| 36,471 | Common Lisp | .lisp | 910 | 34.659341 | 132 | 0.681913 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | bfc4502e282cc89a1aa4a8e58bce52f2c288691a8faa2765557c627def8f7a1c | 22,362 | [
-1
] |
22,363 | stumpwm.lisp | joelagnel_stumpwm/stumpwm.lisp | ;; Copyright (C) 2003-2008 Shawn Betts
;;
;; This file is part of stumpwm.
;;
;; stumpwm is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; stumpwm is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;; Commentary:
;;
;; Code:
(in-package :stumpwm)
(export '(cancel-timer
load-contrib
run-with-timer
stumpwm
timer-p))
;;; Main
(defun load-rc-file (&optional (catch-errors t))
"Load the user's .stumpwmrc file or the system wide one if that
doesn't exist. Returns a values list: whether the file loaded (t if no
rc files exist), the error if it didn't, and the rc file that was
loaded. When CATCH-ERRORS is nil, errors are left to be handled further up. "
(let* ((user-rc (probe-file (merge-pathnames (user-homedir-pathname) #p".stumpwmrc")))
(etc-rc (probe-file #p"/etc/stumpwmrc"))
(rc (or user-rc etc-rc)))
(if rc
;; TODO: Should we compile the file before we load it?
(if catch-errors
(handler-case (load rc)
(error (c) (values nil (format nil "~a" c) rc))
(:no-error (&rest args) (declare (ignore args)) (values t nil rc)))
(progn
(load rc)
(values t nil rc)))
(values t nil nil))))
(defun error-handler (display error-key &rest key-vals &key asynchronous &allow-other-keys)
"Handle X errors"
(cond
;; ignore asynchronous window errors
((and asynchronous
(find error-key '(xlib:window-error xlib:drawable-error xlib:match-error)))
(dformat 4 "Ignoring error: ~s~%" error-key))
((eq error-key 'xlib:access-error)
(write-line "Another window manager is running.")
(throw :top-level :quit))
;; all other asynchronous errors are printed.
(asynchronous
(message "Caught Asynchronous X Error: ~s ~s" error-key key-vals))
(t
(apply 'error error-key :display display :error-key error-key key-vals))))
;;; Timers
(defvar *timer-list* nil
"List of active timers.")
(defstruct timer
time repeat function args)
(defun run-with-timer (secs repeat function &rest args)
"Perform an action after a delay of SECS seconds.
Repeat the action every REPEAT seconds, if repeat is non-nil.
SECS and REPEAT may be reals.
The action is to call FUNCTION with arguments ARGS."
(check-type secs (real 0 *))
(check-type repeat (or null (real 0 *)))
(check-type function (or function symbol))
(let ((timer (make-timer
:repeat repeat
:function function
:args args)))
(schedule-timer timer secs)
(setf *timer-list* (sort-timers (cons timer *timer-list*)))
timer))
(defun cancel-timer (timer)
"Remove TIMER from the list of active timers."
(check-type timer timer)
(setf *timer-list* (remove timer *timer-list*)))
(defun schedule-timer (timer when)
(setf (timer-time timer) (+ (get-internal-real-time)
(* when internal-time-units-per-second))))
(defun sort-timers (timers)
"Return a new list of timers sorted by time to time out."
(sort (copy-list timers)
(lambda (a b)
(< (timer-time a) (timer-time b)))))
(defun run-expired-timers (timers)
"Return a new list of valid timers and run the timer functions
of those expired."
(let ((now (get-internal-real-time)))
(sort-timers (loop for i in timers
with keepers = nil do
(if (< (timer-time i) now)
(progn
(apply (timer-function i) (timer-args i))
(when (timer-repeat i)
(schedule-timer i (timer-repeat i))
(push i keepers)))
(push i keepers))
finally (return keepers)))))
(defun get-next-timeout (timers)
"Return the number of seconds until the next timeout or nil if there are no timers."
(when timers
(max (/ (- (timer-time (car timers)) (get-internal-real-time))
internal-time-units-per-second)
0)))
(defun perform-top-level-error-action (c)
(ecase *top-level-error-action*
(:message
(let ((s (format nil "~&Caught '~a' at the top level. Please report this." c)))
(write-line s)
(print-backtrace)
(message "^1*^B~a" s)))
(:break (invoke-debugger c))
(:abort
(throw :top-level (list c (backtrace-string))))))
(defun stumpwm-internal-loop ()
"The internal loop that waits for events and handles them."
(loop
(run-hook *internal-loop-hook*)
(handler-bind
((xlib:lookup-error (lambda (c)
(if (lookup-error-recoverable-p)
(recover-from-lookup-error)
(error c))))
(warning #'muffle-warning)
((or serious-condition error)
(lambda (c)
(run-hook *top-level-error-hook*)
(perform-top-level-error-action c)))
(t
(lambda (c)
;; some other wacko condition was raised so first try
;; what we can to keep going.
(cond ((find-restart 'muffle-warning)
(muffle-warning))
((find-restart 'continue)
(continue)))
;; and if that fails treat it like a top level error.
(perform-top-level-error-action c))))
;; Note: process-event appears to hang for an unknown
;; reason. This is why it is passed a timeout in hopes that
;; this will keep it from hanging.
(let ((timeout (get-next-timeout *timer-list*)))
(dformat 10 "timeout: ~a~%" timeout)
(if timeout
(let* ((nevents (xlib:event-listen *display* (ceiling timeout))))
(setf *timer-list* (run-expired-timers *timer-list*))
(when nevents
(xlib:process-event *display* :handler #'handle-event)))
;; Otherwise, simply wait for an event
(xlib:process-event *display* :handler #'handle-event))
;; flush any pending output. You'd think process-event would, but
;; it seems not.
(xlib:display-finish-output *display*)
;;(dformat 10 "toplevel focus: ~a~%" (multiple-value-list (xlib:input-focus *display*)))
))))
(defun parse-display-string (display)
"Parse an X11 DISPLAY string and return the host and display from it."
(ppcre:register-groups-bind (protocol host ('parse-integer display screen))
("^(?:(.*?)/)?(.*?)?:(\\d+)(?:\\.(\\d+))?" display :sharedp t)
(values
;; clx doesn't like (vector character *)
(coerce (or host "")
'(simple-array character (*)))
display screen
(cond (protocol
(intern1 protocol :keyword))
((or (string= host "")
(string-equal host "unix"))
:local)
(t :internet)))))
(defun stumpwm-internal (display-str)
(multiple-value-bind (host display screen protocol) (parse-display-string display-str)
(declare (ignore screen))
(setf *display* (xlib:open-display host :display display :protocol protocol)
(xlib:display-error-handler *display*) 'error-handler)
(with-simple-restart (quit-stumpwm "Quit Stumpwm")
;; In the event of an error, we always need to close the display
(unwind-protect
(progn
(let ((*initializing* t))
;; we need to do this first because init-screen grabs keys
(update-modifier-map)
;; Initialize all the screens
(setf *screen-list* (loop for i in (xlib:display-roots *display*)
for n from 0
collect (init-screen i n host)))
(xlib:display-finish-output *display*)
;; Load rc file
(let ((*package* (find-package *default-package*)))
(multiple-value-bind (success err rc) (load-rc-file)
(if success
(and *startup-message* (message *startup-message* (print-key *escape-key*)))
(message "^B^1*Error loading ^b~A^B: ^n~A" rc err))))
(when *last-unhandled-error*
(message-no-timeout "^B^1*StumpWM Crashed With An Unhandled Error!~%Copy the error to the clipboard with the 'copy-unhandled-error' command.~%^b~a^B^n~%~%~a"
(first *last-unhandled-error*) (second *last-unhandled-error*)))
(mapc 'process-existing-windows *screen-list*)
;; We need to setup each screen with its current window. Go
;; through them in reverse so the first screen's frame ends up
;; with focus.
(dolist (s (reverse *screen-list*))
;; map the current group's windows
(mapc 'unhide-window (reverse (group-windows (screen-current-group s))))
;; update groups
(dolist (g (reverse (screen-groups s)))
;; raise the current window and frame.
(dformat 3 "Group windows: ~S~%" (group-windows g))
(let ((window (first (group-windows g))))
(if window
(focus-frame g (window-frame window))
(focus-frame g (tile-group-current-frame g)))))
;; switch to the (old) current group.
(let ((netwm-id (first (xlib:get-property (screen-root s) :_NET_CURRENT_DESKTOP))))
(when (and netwm-id (< netwm-id (length (screen-groups s))))
(switch-to-group (elt (sort-groups s) netwm-id))))
(redraw-current-message (current-screen))))
;; Let's manage.
(let ((*package* (find-package *default-package*)))
(run-hook *start-hook*)
(stumpwm-internal-loop)))
(xlib:close-display *display*))))
;; what should the top level loop do?
:quit)
;; Usage: (stumpwm)
(defun stumpwm (&optional (display-str (or (getenv "DISPLAY") ":0")))
"Start the stump window manager."
(loop
(let ((ret (catch :top-level
(stumpwm-internal display-str))))
(setf *last-unhandled-error* nil)
(cond ((and (consp ret)
(typep (first ret) 'condition))
(format t "~&Caught '~a' at the top level. Please report this.~%~a"
(first ret) (second ret))
(setf *last-unhandled-error* ret))
((eq ret :restart))
(t
;; the number is the unix return code
(return-from stumpwm 0))))))
| 11,285 | Common Lisp | .lisp | 246 | 35.776423 | 174 | 0.586019 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 4d3ace971dc67ff639dfd1f60888f465fd2ae3ea5442346612d20fecbada4ff5 | 22,363 | [
-1
] |
22,369 | module.lisp | joelagnel_stumpwm/module.lisp | ;; Copyright (C) 2008 Julian Stecklina, Shawn Betts, Ivy Foster
;;
;; This file is part of stumpwm.
;;
;; stumpwm is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; stumpwm is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;; Commentary:
;;
;; Use `set-contrib-dir' to set the location stumpwm searches for modules.
;; Code:
(in-package #:stumpwm)
(export '(load-module
list-modules
*contrib-dir*
set-contrib-dir
find-module))
;; Handy functions from the unClog blog
;; http://metabang.com/unclogit/?p=98
;; FIXME: These functions are part of the current version of asdf so
;; at some point we should remove them when there's no chance anyone
;; is running an older version.
(defun asdf-system-source-directory (system-name)
(make-pathname :name nil
:type nil
:defaults (asdf-system-source-file system-name)))
(defun asdf-system-source-file (system-name)
(let ((system (asdf:find-system system-name)))
(make-pathname
:type "asd"
:name (asdf:component-name system)
:defaults (asdf:component-relative-pathname system))))
(defun system-relative-pathname (system pathname &key name type)
(let ((directory (pathname-directory pathname)))
(when (eq (car directory) :absolute)
(setf (car directory) :relative))
(merge-pathnames
(make-pathname :name (or name (pathname-name pathname))
:type (or type (pathname-type pathname))
:directory directory)
(asdf-system-source-directory system))))
(defvar *contrib-dir* (system-relative-pathname
(asdf:find-system :stumpwm)
(make-pathname :directory '(:relative "contrib")))
"The location of the contrib modules on your system.")
(defcommand set-contrib-dir (dir) ((:string "Directory: "))
"Sets the location of the contrib modules"
(unless (string= "/" (subseq dir (1- (length dir))))
(setf dir (concat dir "/")))
(setf *contrib-dir* (pathname dir)))
(define-stumpwm-type :module (input prompt)
(or (argument-pop-rest input)
(completing-read (current-screen) prompt (list-modules))))
(defun list-modules ()
"Return a list of the available modules."
(mapcar 'pathname-name
(directory (make-pathname :directory *contrib-dir*
:name :wild
:type "lisp"))))
(defun find-module (name)
(make-pathname :defaults *contrib-dir*
:name name
:type "lisp"))
(defcommand load-module (name) ((:module "Load Module: "))
"Loads the contributed module with the given NAME."
;; FIXME: This should use ASDF in the future. And maybe there should
;; be an extra stumpwm-contrib repository.
(let ((module (find-module name)))
(if module
(load module)
(error "No such module: ~a" name))))
;; End of file
| 3,371 | Common Lisp | .lisp | 81 | 37.271605 | 74 | 0.697831 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | defd3d09202c214ad7cc58eafc936c278761d8d86f508ad8ac7d53075fc391b4 | 22,369 | [
-1
] |
22,370 | screen.lisp | joelagnel_stumpwm/screen.lisp | ;; Copyright (C) 2003-2008 Shawn Betts
;;
;; This file is part of stumpwm.
;;
;; stumpwm is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; stumpwm is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;; Commentary:
;;
;; Screen and head functionality
;;
;; Code:
(in-package #:stumpwm)
(export '(current-head
current-screen
current-window
screen-current-window
set-fg-color
set-bg-color
set-border-color
set-win-bg-color
set-focus-color
set-unfocus-color
set-msg-border-width
set-frame-outline-width
set-font))
;; Screen helper functions
(defun translate-id (src src-start src-end font dst dst-start)
"A simple replacement for xlib:translate-default. just the
identity with a range check."
(let ((min (xlib:font-min-char font))
(max (xlib:font-max-char font)))
(decf src-end)
(if (stringp src) ; clx does this test so i guess it's needed
(loop for i from src-start to src-end
for j from dst-start
as c = (char-code (char src i))
if (<= min c max) do (setf (aref dst j) c)
;; replace unknown characters with question marks
else do (setf (aref dst j) (char-code #\?))
finally (return i))
(loop for i from src-start to src-end
for j from dst-start
as c = (elt src i)
as n = (if (characterp c) (char-code c) c)
if (and (integerp n) (<= min n max)) do (setf (aref dst j) n)
;; ditto
else do (setf (aref dst j) (char-code #\?))
finally (return i)))))
(defun screen-x (screen)
(declare (ignore screen))
0)
(defun screen-y (screen)
(declare (ignore screen))
0)
(defun screen-height (screen)
(let ((root (screen-root screen)))
(xlib:drawable-height root)))
(defun screen-true-height (screen)
"Return the height of the screen regardless of the modeline"
(let ((root (screen-root screen)))
(xlib:drawable-height root)))
(defun screen-width (screen)
(let ((root (screen-root screen)))
(xlib:drawable-width root)))
(defun find-screen (root)
"Return the screen containing the root window."
(find-if (lambda (s)
(xlib:window-equal (screen-root s) root))
*screen-list*))
(defun screen-windows (screen)
(mapcan (lambda (g) (copy-list (group-windows g))) (screen-groups screen)))
(defun netwm-update-client-list-stacking (screen)
(unless *initializing*
(xlib:change-property (screen-root screen)
:_NET_CLIENT_LIST_STACKING
;; Order is bottom to top.
(reverse (mapcar 'window-xwin (all-windows)))
:window 32
:transform #'xlib:drawable-id
:mode :replace)))
(defun netwm-update-client-list (screen)
(xlib:change-property (screen-root screen)
:_NET_CLIENT_LIST
(screen-mapped-windows screen)
:window 32
:transform #'xlib:drawable-id
:mode :replace)
(netwm-update-client-list-stacking screen))
(defun screen-add-mapped-window (screen xwin)
(push xwin (screen-mapped-windows screen))
(netwm-update-client-list screen))
(defun screen-remove-mapped-window (screen xwin)
(unregister-window xwin)
(setf (screen-mapped-windows screen)
(remove xwin (screen-mapped-windows screen)))
(netwm-update-client-list screen))
(defun sort-screens ()
"Return the list of screen sorted by ID."
(sort1 *screen-list* '< :key 'screen-id))
(defun next-screen (&optional (list (sort-screens)))
(let ((matches (member (current-screen) list)))
(if (null (cdr matches))
;; If the last one in the list is current, then
;; use the first one.
(car list)
;; Otherwise, use the next one in the list.
(cadr matches))))
(defun move-screen-to-head (screen)
(move-to-head *screen-list* screen))
(defun switch-to-screen (screen)
(when (and screen
(not (eq screen (current-screen))))
(if (screen-focus screen)
(xlib:set-input-focus *display* (window-xwin (screen-focus screen)) :POINTER-ROOT)
(xlib:set-input-focus *display* (screen-focus-window screen) :POINTER-ROOT))
(move-screen-to-head screen)))
(defun screen-set-focus (screen window)
(when (eq (window-group window)
(screen-current-group screen))
;;(format t "FOCUS TO: ~a ~a~%" window (window-xwin window))
;;(format t "FOCUS BEFORE: ~a~%" (multiple-value-list (xlib:input-focus *display*)))
;;(format t "FOCUS RET: ~a~%" (xlib:set-input-focus *display* (window-xwin window) :POINTER-ROOT))
(xlib:set-input-focus *display* (window-xwin window) :POINTER-ROOT)
;;(xlib:display-finish-output *display*)
;;(format t "FOCUS IS: ~a~%" (multiple-value-list (xlib:input-focus *display*)))
(xlib:change-property (screen-root screen) :_NET_ACTIVE_WINDOW
(list (window-xwin window))
:window 32
:transform #'xlib:drawable-id
:mode :replace)
(setf (screen-focus screen) window)
(move-screen-to-head screen)))
(defun screen-current-window (screen)
"Return the current window on the specified screen"
(group-current-window (screen-current-group screen)))
(defun current-window ()
"Return the current window on the current screen"
(screen-current-window (current-screen)))
(defun register-window (window)
(setf (gethash (xlib:window-id (window-xwin window)) *xwin-to-window*) window))
(defun unregister-window (xwin)
(remhash (xlib:window-id xwin) *xwin-to-window*))
(defun window-by-id (id)
(gethash id *xwin-to-window*))
(defun find-window (xwin)
(window-by-id (xlib:window-id xwin)))
(defun find-window-by-parent (xwin &optional (windows (all-windows)))
(dformat 3 "find-window-by-parent!~%")
(find xwin windows :key 'window-parent :test 'xlib:window-equal))
(defun screen-root (screen)
(xlib:screen-root (screen-number screen)))
(defun update-colors-for-screen (screen)
(let ((fg (screen-fg-color screen))
(bg (screen-bg-color screen)))
(setf (xlib:gcontext-foreground (screen-message-gc screen)) fg
(xlib:gcontext-background (screen-message-gc screen)) bg
(xlib:gcontext-foreground (screen-frame-outline-gc screen)) fg
(xlib:gcontext-background (screen-frame-outline-gc screen)) bg
(ccontext-default-fg (screen-message-cc screen)) fg
(ccontext-default-bg (screen-message-cc screen)) bg))
(dolist (i (list (screen-message-window screen)
(screen-input-window screen)
(screen-frame-window screen)))
(setf (xlib:window-border i) (screen-border-color screen)
(xlib:window-background i) (screen-bg-color screen)))
;; update the backgrounds of all the managed windows
(dolist (g (screen-groups screen))
(dolist (w (group-windows g))
(unless (eq w (group-current-window g))
(setf (xlib:window-background (window-parent w)) (screen-win-bg-color screen))
(xlib:clear-area (window-parent w)))))
(dolist (i (screen-withdrawn-windows screen))
(setf (xlib:window-background (window-parent i)) (screen-win-bg-color screen))
(xlib:clear-area (window-parent i)))
(update-screen-color-context screen))
(defun update-colors-all-screens ()
"After setting the fg, bg, or border colors. call this to sync any existing windows."
(mapc 'update-colors-for-screen *screen-list*))
(defun update-border-for-screen (screen)
(setf (xlib:drawable-border-width (screen-input-window screen)) (screen-msg-border-width screen)
(xlib:drawable-border-width (screen-message-window screen)) (screen-msg-border-width screen)))
(defun update-border-all-screens ()
"After setting the border width call this to sync any existing windows."
(mapc 'update-border-for-screen *screen-list*))
(defun internal-window-p (screen win)
"Return t if win is a window used by stumpwm"
(or (xlib:window-equal (screen-message-window screen) win)
(xlib:window-equal (screen-input-window screen) win)
(xlib:window-equal (screen-focus-window screen) win)
(xlib:window-equal (screen-key-window screen) win)))
(defun color-exists-p (color)
(handler-case
(loop for i in *screen-list*
always (xlib:lookup-color (xlib:screen-default-colormap (screen-number i)) color))
(xlib:name-error () nil)))
(defun font-exists-p (font-name)
;; if we can list the font then it exists
(plusp (length (xlib:list-font-names *display* font-name :max-fonts 1))))
(defmacro set-any-color (val color)
`(progn (dolist (s *screen-list*)
(setf (,val s) (alloc-color s ,color)))
(update-colors-all-screens)))
;; FIXME: I don't like any of this. Isn't there a way to define
;; a setf method to call (update-colors-all-screens) when the user
;; does eg. (setf *foreground-color* "green") instead of having
;; these redundant set-foo functions?
(defun set-fg-color (color)
"Set the foreground color for the message bar and input
bar. @var{color} can be any color recognized by X."
(setf *text-color* color)
(set-any-color screen-fg-color color))
(defun set-bg-color (color)
"Set the background color for the message bar and input
bar. @var{color} can be any color recognized by X."
(set-any-color screen-bg-color color))
(defun set-border-color (color)
"Set the border color for the message bar and input
bar. @var{color} can be any color recognized by X."
(set-any-color screen-border-color color))
(defun set-win-bg-color (color)
"Set the background color of the window. The background color will only
be visible for windows with size increment hints such as @samp{emacs}
and @samp{xterm}."
(set-any-color screen-win-bg-color color))
(defun set-focus-color (color)
"Set the border color for focused windows. This is only used when
there is more than one frame."
(set-any-color screen-focus-color color))
(defun set-unfocus-color (color)
"Set the border color for windows without focus. This is only used when
there is more than one frame."
(set-any-color screen-unfocus-color color))
(defun set-msg-border-width (width)
"Set the border width for the message bar and input
bar."
(check-type width (integer 0))
(dolist (i *screen-list*)
(setf (screen-msg-border-width i) width))
(update-border-all-screens)
t)
(defun set-frame-outline-width (width)
(check-type width (integer 0))
(dolist (i *screen-list*)
(setf (screen-frame-outline-width i) (if (oddp width) (1+ width) width)
(xlib:gcontext-line-width (screen-frame-outline-gc i)) (screen-frame-outline-width i)))
(update-border-all-screens)
t)
(defun set-font (font)
"Set the font for the message bar and input bar."
(when (font-exists-p font)
(dolist (i *screen-list*)
(let ((fobj (xlib:open-font *display* (first (xlib:list-font-names *display* font :max-fonts 1)))))
(xlib:close-font (screen-font i))
(setf (screen-font i) fobj
(xlib:gcontext-font (screen-message-gc i)) fobj)
;; update the modelines too
(dolist (h (screen-heads i))
(when (and (head-mode-line h)
(eq (mode-line-mode (head-mode-line h)) :stump))
(setf (xlib:gcontext-font (mode-line-gc (head-mode-line h))) fobj)
(resize-mode-line (head-mode-line h))
(sync-mode-line (head-mode-line h))))))
t))
(defmacro with-current-screen (screen &body body)
"A macro to help us out with early set up."
`(let ((*screen-list* (list ,screen)))
,@body))
(defun current-screen ()
"Return the current screen."
(car *screen-list*))
(defun netwm-set-properties (screen focus-window)
"Set NETWM properties on the root window of the specified screen.
FOCUS-WINDOW is an extra window used for _NET_SUPPORTING_WM_CHECK."
(let* ((screen-number (screen-number screen))
(root (xlib:screen-root screen-number)))
;; _NET_SUPPORTED
(xlib:change-property root :_NET_SUPPORTED
(mapcar (lambda (a)
(xlib:intern-atom *display* a))
(append +netwm-supported+
(mapcar #'car +netwm-window-types+)))
:atom 32)
;; _NET_SUPPORTING_WM_CHECK
(xlib:change-property root :_NET_SUPPORTING_WM_CHECK
(list focus-window) :window 32
:transform #'xlib:drawable-id)
(xlib:change-property focus-window :_NET_SUPPORTING_WM_CHECK
(list focus-window) :window 32
:transform #'xlib:drawable-id)
(xlib:change-property focus-window :_NET_WM_NAME
"stumpwm"
:string 8 :transform #'xlib:char->card8)
;; _NET_CLIENT_LIST
(xlib:change-property root :_NET_CLIENT_LIST
() :window 32
:transform #'xlib:drawable-id)
;; _NET_DESKTOP_GEOMETRY
(xlib:change-property root :_NET_DESKTOP_GEOMETRY
(list (xlib:screen-width screen-number)
(xlib:screen-height screen-number))
:cardinal 32)
;; _NET_DESKTOP_VIEWPORT
(xlib:change-property root :_NET_DESKTOP_VIEWPORT
(list 0 0) :cardinal 32)
(netwm-set-group-properties screen)))
(defun init-screen (screen-number id host)
"Given a screen number, returns a screen structure with initialized members"
;; Listen for the window manager events on the root window
(dformat 1 "Initializing screen: ~a ~a~%" host id)
(setf (xlib:window-event-mask (xlib:screen-root screen-number))
'(:substructure-redirect
:substructure-notify
:property-change
:structure-notify
:button-press
:exposure))
(xlib:display-finish-output *display*)
;; Initialize the screen structure
(labels ((ac (color)
(xlib:alloc-color (xlib:screen-default-colormap screen-number) color)))
(let* ((screen (make-screen))
(fg (ac +default-foreground-color+))
(bg (ac +default-background-color+))
(border (ac +default-border-color+))
(focus (ac +default-focus-color+))
(unfocus (ac +default-unfocus-color+))
(win-bg (ac +default-window-background-color+))
(input-window (xlib:create-window :parent (xlib:screen-root screen-number)
:x 0 :y 0 :width 20 :height 20
:background bg
:border border
:border-width 1
:colormap (xlib:screen-default-colormap
screen-number)
:event-mask '(:key-press :key-release)
:save-under :on))
(focus-window (xlib:create-window :parent (xlib:screen-root screen-number)
:x 0 :y 0 :width 1 :height 1
:save-under :on))
(key-window (xlib:create-window :parent (xlib:screen-root screen-number)
:x 0 :y 0 :width 1 :height 1
:event-mask '(:key-press :key-release)
:save-under :on))
(message-window (xlib:create-window :parent (xlib:screen-root screen-number)
:x 0 :y 0 :width 1 :height 1
:background bg
:bit-gravity :north-east
:border border
:border-width 1
:colormap (xlib:screen-default-colormap
screen-number)
:event-mask '(:exposure)))
(frame-window (xlib:create-window :parent (xlib:screen-root screen-number)
:x 0 :y 0 :width 20 :height 20
:background bg
:border border
:border-width 1
:colormap (xlib:screen-default-colormap
screen-number)
:event-mask '(:exposure)
:save-under :on))
(font (xlib:open-font *display*
(if (font-exists-p +default-font-name+)
+default-font-name+
"*")))
(group (make-instance 'tile-group
:screen screen
:number 1
:name *default-group-name*)))
;; Create our screen structure
;; The focus window is mapped at all times
(xlib:map-window focus-window)
(xlib:map-window key-window)
(setf (screen-number screen) screen-number
(screen-id screen) id
(screen-host screen) host
(screen-groups screen) (list group)
(screen-current-group screen) group
(screen-font screen) font
(screen-fg-color screen) fg
(screen-bg-color screen) bg
(screen-win-bg-color screen) win-bg
(screen-border-color screen) border
(screen-focus-color screen) focus
(screen-unfocus-color screen) unfocus
(screen-msg-border-width screen) 1
(screen-frame-outline-width screen) +default-frame-outline-width+
(screen-input-window screen) input-window
(screen-focus-window screen) focus-window
(screen-key-window screen) key-window
(screen-frame-window screen) frame-window
(screen-ignore-msg-expose screen) 0
(screen-message-cc screen) (make-ccontext :win message-window
:gc (xlib:create-gcontext
:drawable message-window
:font font
:foreground fg
:background bg))
(screen-frame-outline-gc screen) (xlib:create-gcontext :drawable (screen-root screen)
:font font
:foreground fg
:background fg
:line-style :double-dash
:line-width +default-frame-outline-width+))
(setf (screen-heads screen) (make-screen-heads screen (xlib:screen-root screen-number))
(tile-group-frame-tree group) (copy-heads screen)
(tile-group-current-frame group) (first (tile-group-frame-tree group)))
(netwm-set-properties screen focus-window)
(update-colors-for-screen screen)
(update-color-map screen)
(xwin-grab-keys focus-window screen)
screen)))
;;; Head functions
(defun head-by-number (screen n)
(find n (screen-heads screen) :key 'head-number))
(defun parse-xinerama-head (line)
(ppcre:register-groups-bind (('parse-integer number width height x y))
("^ +head #([0-9]+): ([0-9]+)x([0-9]+) @ ([0-9]+),([0-9]+)" line :sharedp t)
(handler-case
(make-head :number number
:x x :y y
:width width
:height height)
(parse-error ()
nil))))
(defun make-screen-heads (screen root)
"or use xdpyinfo to query the xinerama extension, if it's enabled."
(or (and (xlib:query-extension *display* "XINERAMA")
(with-current-screen screen
;; Ignore 'clone' heads.
(loop
for i = 0 then (1+ i)
for h in
(delete-duplicates
(loop for i in (split-string (run-shell-command "xdpyinfo -ext XINERAMA" t))
for head = (parse-xinerama-head i)
when head
collect head)
:test #'frames-overlap-p)
do (setf (head-number h) i)
collect h)))
(list (make-head :number 0
:x 0 :y 0
:width (xlib:drawable-width root)
:height (xlib:drawable-height root)
:window nil))))
(defun copy-heads (screen)
"Return a copy of screen's heads."
(mapcar 'copy-frame (screen-heads screen)))
;; Determining a frame's head based on position probably won't
;; work with overlapping heads. Would it be better to walk
;; up the frame tree?
(defun frame-head (group frame)
(dolist (head (screen-heads (group-screen group)))
(when (and
(>= (frame-x frame) (frame-x head))
(>= (frame-y frame) (frame-y head))
(<= (+ (frame-x frame) (frame-width frame))
(+ (frame-x head) (frame-width head)))
(<= (+ (frame-y frame) (frame-height frame))
(+ (frame-y head) (frame-height head))))
(return head))))
(defun group-heads (group)
(screen-heads (group-screen group)))
(defun tile-group-frame-head (group head)
(elt (tile-group-frame-tree group) (position head (group-heads group))))
(defun (setf tile-group-frame-head) (frame group head)
(setf (elt (tile-group-frame-tree group) (position head (group-heads group))) frame))
(defun current-head (&optional (group (current-group)))
(group-current-head group))
(defun head-windows (group head)
"Returns a list of windows on HEAD of GROUP"
(remove-if-not
(lambda (w)
(eq head (window-head w)))
(group-windows group)))
(defun frame-is-head (group frame)
(< (frame-number frame) (length (group-heads group))))
(defun add-head (screen head)
(dformat 1 "Adding head #~D~%" (head-number head))
(setf (screen-heads screen) (sort (push head (screen-heads screen)) #'< :key 'head-number))
(dolist (group (screen-groups screen))
(let ((new-frame-num (find-free-frame-number group)))
(setf (tile-group-frame-tree group)
(insert-before (tile-group-frame-tree group)
(copy-frame head)
(head-number head)))
;; Try to put something in the new frame and give it an unused number
(let ((frame (tile-group-frame-head group head)))
(setf (frame-number frame) new-frame-num)
(choose-new-frame-window frame group)
(when (frame-window frame)
(unhide-window (frame-window frame)))))))
(defun remove-head (screen head)
(dformat 1 "Removing head #~D~%" (head-number head))
(when (head-mode-line head)
(toggle-mode-line screen head))
(dolist (group (screen-groups screen))
;; Hide its windows.
(let ((windows (head-windows group head)))
;; Remove it from the frame tree.
(setf (tile-group-frame-tree group) (delete (tile-group-frame-head group head) (tile-group-frame-tree group)))
;; Just set current frame to whatever.
(let ((frame (first (group-frames group))))
(setf (tile-group-current-frame group) frame
(tile-group-last-frame group) nil)
(dolist (window windows)
(hide-window window)
(setf (window-frame window) frame))))
;; Try to do something with the orphaned windows
(populate-frames group))
;; Remove it from SCREEN's head list.
(setf (screen-heads screen) (delete head (screen-heads screen))))
(defun scale-head (screen oh nh)
"Scales head OH to match the dimensions of NH."
(dolist (group (screen-groups screen))
(resize-tree (tile-group-frame-head group oh) (head-width nh) (head-height nh) (head-x nh) (head-y nh)))
(setf (head-x oh) (head-x nh)
(head-y oh) (head-y nh)
(head-width oh) (head-width nh)
(head-height oh) (head-height nh)))
(defun scale-screen (screen heads)
"Scale all frames of all groups of SCREEN to match the dimensions
of HEADS."
(when (< (length heads) (length (screen-heads screen)))
;; Some heads were removed (or cloned), try to guess which.
(dolist (oh (screen-heads screen))
(dolist (nh heads)
(when (and (= (head-x nh) (head-x oh))
(= (head-y nh) (head-y oh)))
;; Same screen position; probably the same head.
(setf (head-number nh) (head-number oh)))))
;; Actually remove the missing heads.
(dolist (head (set-difference (screen-heads screen) heads :key 'head-number))
(remove-head screen head)))
(loop
for nh in heads
as oh = (find (head-number nh) (screen-heads screen) :key 'head-number)
do (if oh
(scale-head screen oh nh)
(add-head screen nh))))
;;; Screen commands
(defcommand snext () ()
"Go to the next screen."
(switch-to-screen (next-screen))
(group-wake-up (current-group)))
(defcommand sprev () ()
"Go to the previous screen."
(switch-to-screen (next-screen (reverse (sort-screens))))
(group-wake-up (current-group)))
(defcommand sother () ()
"Go to the last screen."
(switch-to-screen (cadr *screen-list*))
(group-wake-up (current-group)))
| 26,970 | Common Lisp | .lisp | 564 | 36.347518 | 116 | 0.5839 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | a9e75ecd2d08eb9a71cd3a6e70a89004c5979bd03caeab2e3fdb1b6fc6fcab41 | 22,370 | [
-1
] |
22,373 | input.lisp | joelagnel_stumpwm/input.lisp | ;; Copyright (C) 2003-2008 Shawn Betts
;;
;; This file is part of stumpwm.
;;
;; stumpwm is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; stumpwm is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;; Commentary:
;;
;; This file handles input stuff
;;
;; Code:
(in-package :stumpwm)
(export '(*input-history-ignore-duplicates*
*input-map*
completing-read
input-delete-region
input-goto-char
input-insert-char
input-insert-string
input-point
input-substring
input-validate-region
read-one-char
read-one-line))
(defstruct input-line
string position history history-bk)
(defvar *input-map* nil
"This is the keymap containing all input editing key bindings.")
(when (null *input-map*)
(setf *input-map*
(let ((map (make-sparse-keymap)))
(define-key map (kbd "DEL") 'input-delete-backward-char)
(define-key map (kbd "M-DEL") 'input-backward-kill-word)
(define-key map (kbd "C-d") 'input-delete-forward-char)
(define-key map (kbd "M-d") 'input-forward-kill-word)
(define-key map (kbd "Delete") 'input-delete-forward-char)
(define-key map (kbd "C-f") 'input-forward-char)
(define-key map (kbd "Right") 'input-forward-char)
(define-key map (kbd "M-f") 'input-forward-word)
(define-key map (kbd "C-b") 'input-backward-char)
(define-key map (kbd "Left") 'input-backward-char)
(define-key map (kbd "M-b") 'input-backward-word)
(define-key map (kbd "C-a") 'input-move-beginning-of-line)
(define-key map (kbd "Home") 'input-move-beginning-of-line)
(define-key map (kbd "C-e") 'input-move-end-of-line)
(define-key map (kbd "End") 'input-move-end-of-line)
(define-key map (kbd "C-k") 'input-kill-line)
(define-key map (kbd "C-u") 'input-kill-to-beginning)
(define-key map (kbd "C-p") 'input-history-back)
(define-key map (kbd "Up") 'input-history-back)
(define-key map (kbd "C-n") 'input-history-forward)
(define-key map (kbd "Down") 'input-history-forward)
(define-key map (kbd "RET") 'input-submit)
(define-key map (kbd "C-g") 'input-abort)
(define-key map (kbd "ESC") 'input-abort)
(define-key map (kbd "C-y") 'input-yank-selection)
(define-key map (kbd "TAB") 'input-complete-forward)
(define-key map (kbd "ISO_Left_Tab") 'input-complete-backward)
(define-key map t 'input-self-insert)
map)))
(defvar *input-history* nil
"History for the input line.")
(defvar *input-last-command* nil
"The last input command.")
(defvar *input-completions* nil
"The list of completions")
(defvar *input-current-completions* nil
"The list of matching completions.")
(defvar *input-current-completions-idx* nil
"The current index in the current completions list.")
(defvar *input-history-ignore-duplicates* nil
"Do not add a command to the input history if it's already the first in the list.")
;;; keysym functions
(defun is-modifier (keycode)
"Return t if keycode is a modifier"
(or (find keycode *all-modifiers* :test 'eql)
;; Treat No Symbol keys as modifiers (and therefore ignorable)
(= (xlib:keycode->keysym *display* keycode 0) 0)))
(defun keycode->character (code mods)
(let ((idx (if (member :shift mods) 1 0)))
(xlib:keysym->character *display* (xlib:keycode->keysym *display* code idx) 0)))
;;; line and key reading functions
(defun setup-input-window (screen prompt input)
"Set the input window up to read input"
(let* ((height (+ (xlib:font-descent (screen-font screen))
(xlib:font-ascent (screen-font screen))))
(win (screen-input-window screen)))
;; Window dimensions
(xlib:with-state (win)
(setf (xlib:window-priority win) :above
(xlib:drawable-height win) height))
(xlib:map-window win)
;; Draw the prompt
(draw-input-bucket screen prompt input)
;; Ready to recieve input
))
(defun shutdown-input-window (screen)
(xlib:ungrab-keyboard *display*)
(xlib:unmap-window (screen-input-window screen)))
(defun input-handle-key-press-event (&rest event-slots &key event-key root code state &allow-other-keys)
(declare (ignore event-slots root))
;; FIXME: don't use a cons
(list* event-key code state))
(defun input-handle-selection-event (&key window selection property &allow-other-keys)
(declare (ignore selection))
(if property
(xlib:get-property window property :type :string :result-type 'string :transform #'xlib:card8->char :delete-p t)
""))
(defun read-key-handle-event (&rest event-slots &key display event-key &allow-other-keys)
(declare (ignore display))
(case event-key
((or :key-release :key-press)
(apply 'input-handle-key-press-event event-slots))
(t nil)))
(defun read-key-or-selection-handle-event (&rest event-slots &key display event-key &allow-other-keys)
(declare (ignore display))
(case event-key
((or :key-release :key-press)
(apply 'input-handle-key-press-event event-slots))
(:selection-notify
(apply 'input-handle-selection-event event-slots))
(t nil)))
(defun read-key ()
"Return a dotted pair (code . state) key."
(loop for ev = (xlib:process-event *display* :handler #'read-key-handle-event :timeout nil) do
(when (and (consp ev)
(eq (first ev) :key-press))
(return (cdr ev)))))
(defun read-key-no-modifiers ()
"Like read-key but never returns a modifier key."
(loop for k = (read-key)
while (is-modifier (car k))
finally (return k)))
(defun read-key-or-selection ()
(loop for ev = (xlib:process-event *display* :handler #'read-key-or-selection-handle-event :timeout nil) do
(cond ((stringp ev)
(return ev))
((and (consp ev)
(eq (first ev) :key-press))
(return (cdr ev))))))
(defun make-input-string (initial-input)
(make-array (length initial-input) :element-type 'character :initial-contents initial-input
:adjustable t :fill-pointer t))
(defun completing-read (screen prompt completions &optional (initial-input ""))
"Read a line of input through stumpwm and return it with TAB
completion. completions can be a list, an fbound symbol, or a
function. if its an fbound symbol or a function then that
function is passed the substring to complete on and is expected
to return a list of matches."
(check-type completions (or list function symbol))
(let ((*input-completions* completions)
(*input-current-completions* nil)
(*input-current-completions-idx* nil))
(read-one-line screen prompt initial-input)))
(defun read-one-line (screen prompt &optional (initial-input ""))
"Read a line of input through stumpwm and return it. returns nil if the user aborted."
(let ((*input-last-command* nil)
(input (make-input-line :string (make-input-string initial-input)
:position (length initial-input)
:history -1)))
(labels ((key-loop ()
(loop for key = (read-key-or-selection) do
(cond ((stringp key)
;; handle selection
(input-insert-string input key)
(draw-input-bucket screen prompt input))
;; skip modifiers
((is-modifier (car key)))
((process-input screen prompt input (car key) (cdr key))
(return (input-line-string input)))))))
(setup-input-window screen prompt input)
(catch :abort
(unwind-protect
(with-focus (screen-input-window screen)
(key-loop))
(shutdown-input-window screen))))))
(defun read-one-char (screen)
"Read a single character from the user."
(with-focus (screen-key-window screen)
(let ((k (read-key-no-modifiers)))
(keycode->character (car k) (xlib:make-state-keys (cdr k))))))
(defun draw-input-bucket (screen prompt input &optional errorp)
"Draw to the screen's input window the contents of input."
(let* ((gcontext (screen-message-gc screen))
(win (screen-input-window screen))
(prompt-width (xlib:text-width (screen-font screen) prompt :translate #'translate-id))
(string (input-line-string input))
(string-width (xlib:text-width (screen-font screen) string :translate #'translate-id))
(full-string-width (+ string-width
(xlib:text-width (screen-font screen) " " :translate #'translate-id)))
(pos (input-line-position input))
(width (+ prompt-width
(max 100 full-string-width))))
(xlib:with-state (win)
(xlib:clear-area win :x (+ *message-window-padding*
prompt-width
string-width))
(setf (xlib:drawable-width win) (+ width (* *message-window-padding* 2)))
(setup-win-gravity screen win *input-window-gravity*))
(xlib:with-state (win)
(xlib:draw-image-glyphs win gcontext
*message-window-padding*
(xlib:font-ascent (screen-font screen))
prompt
:translate #'translate-id
:size 16)
(xlib:draw-image-glyphs win gcontext
(+ *message-window-padding* prompt-width)
(xlib:font-ascent (screen-font screen))
string
:translate #'translate-id
:size 16)
;; draw a block cursor
(invert-rect screen win
(+ *message-window-padding*
prompt-width
(xlib:text-width (screen-font screen) (subseq string 0 pos) :translate #'translate-id))
0
(xlib:text-width (screen-font screen) (if (>= pos (length string))
" "
(string (char string pos)))
:translate #'translate-id)
(+ (xlib:font-descent (screen-font screen))
(xlib:font-ascent (screen-font screen))))
;; draw the error
(when errorp
(invert-rect screen win 0 0 (xlib:drawable-width win) (xlib:drawable-height win))
(xlib:display-force-output *display*)
(sleep 0.05)
(invert-rect screen win 0 0 (xlib:drawable-width win) (xlib:drawable-height win))))))
(defun code-state->key (code state)
(let* ((mods (xlib:make-state-keys state))
(shift-p (and (find :shift mods) t))
(altgr-p (and (intersection (modifiers-altgr *modifiers*) mods) t))
(base (if altgr-p 2 0))
(sym (xlib:keycode->keysym *display* code base))
(upsym (xlib:keycode->keysym *display* code (+ base 1))))
;; If a keysym has a shift modifier, then use the uppercase keysym
;; and remove remove the shift modifier.
(make-key :keysym (if (and shift-p (not (eql sym upsym)))
upsym
sym)
:control (and (find :control mods) t)
:shift (and shift-p (eql sym upsym))
:meta (and (intersection mods (modifiers-meta *modifiers*)) t)
:alt (and (intersection mods (modifiers-alt *modifiers*)) t)
:hyper (and (intersection mods (modifiers-hyper *modifiers*)) t)
:super (and (intersection mods (modifiers-super *modifiers*)) t))))
;;; input string utility functions
(defun input-submit (input key)
(declare (ignore input key))
:done)
(defun input-abort (input key)
(declare (ignore input key))
(throw :abort nil))
(defun input-goto-char (input point)
"Move the cursor to the specified point in the string"
(setf (input-line-position input) (min (max 0 point)
(length (input-line-string input)))))
(defun input-insert-string (input string)
"Insert @var{string} into the input at the current
position. @var{input} must be of type @var{input-line}. Input
functions are passed this structure as their first argument."
(check-type string string)
(loop for c across string
do (input-insert-char input c)))
(defun input-point (input)
"Return the position of the cursor."
(check-type input input-line)
(input-line-position input))
(defun input-validate-region (input start end)
"Return a value pair of numbers where the first number is < the
second and neither excedes the bounds of the input string."
(values (max 0 (min start end))
(min (length (input-line-string input))
(max start end))))
(defun input-delete-region (input start end)
"Delete the region between start and end in the input string"
(check-type input input-line)
(check-type start fixnum)
(check-type end fixnum)
(multiple-value-setq (start end) (input-validate-region input start end))
(replace (input-line-string input) (input-line-string input)
:start2 end :start1 start)
(decf (fill-pointer (input-line-string input)) (- end start))
(cond
((< (input-line-position input) start))
((< (input-line-position input) end)
(setf (input-line-position input) start))
(t
(decf (input-line-position input) (- end start)))))
(defun input-insert-char (input char)
"Insert @var{char} into the input at the current
position. @var{input} must be of type @var{input-line}. Input
functions are passed this structure as their first argument."
(vector-push-extend #\_ (input-line-string input))
(replace (input-line-string input) (input-line-string input)
:start2 (input-line-position input) :start1 (1+ (input-line-position input)))
(setf (char (input-line-string input) (input-line-position input)) char)
(incf (input-line-position input)))
(defun input-substring (input start end)
"Return a the substring in INPUT bounded by START and END."
(subseq (input-line-string input) start end))
;;; "interactive" input functions
(defun input-find-completions (str completions)
(if (or (functionp completions)
(and (symbolp completions)
(fboundp completions)))
(funcall completions str)
(remove-if-not (lambda (elt)
(when (listp elt)
(setf elt (car elt)))
(and (<= (length str) (length elt))
(string= str elt
:end1 (length str)
:end2 (length str))))
completions)))
(defun input-complete (input direction)
;; reset the completion list if this is the first time they're
;; trying to complete.
(unless (find *input-last-command* '(input-complete-forward
input-complete-backward))
(setf *input-current-completions* (input-find-completions (input-substring input 0 (input-point input)) *input-completions*)
*input-current-completions-idx* -1))
(if *input-current-completions*
(progn
;; Insert the next completion
(input-delete-region input 0 (input-point input))
(if (eq direction :forward)
(progn
(incf *input-current-completions-idx*)
(when (>= *input-current-completions-idx* (length *input-current-completions*))
(setf *input-current-completions-idx* 0)))
(progn
(decf *input-current-completions-idx*)
(when (< *input-current-completions-idx* 0)
(setf *input-current-completions-idx* (1- (length *input-current-completions*))))))
(let ((elt (nth *input-current-completions-idx* *input-current-completions*)))
(input-insert-string input (if (listp elt) (first elt) elt))
(input-insert-char input #\Space)))
:error))
(defun input-complete-forward (input key)
(declare (ignore key))
(input-complete input :forward))
(defun input-complete-backward (input key)
(declare (ignore key))
(input-complete input :backward))
(defun input-delete-backward-char (input key)
(declare (ignore key))
(let ((pos (input-line-position input)))
(cond ((or (<= (length (input-line-string input)) 0)
(<= pos 0))
:error)
(t
(replace (input-line-string input) (input-line-string input)
:start2 pos :start1 (1- pos))
(decf (fill-pointer (input-line-string input)))
(decf (input-line-position input))))))
(defun input-delete-forward-char (input key)
(declare (ignore key))
(let ((pos (input-line-position input)))
(cond ((>= pos
(length (input-line-string input)))
:error)
(t
(replace (input-line-string input) (input-line-string input)
:start1 pos :start2 (1+ pos))
(decf (fill-pointer (input-line-string input)))))))
(defun input-forward-kill-word (input key)
(declare (ignore key))
(let* ((p1 (position-if 'alphanumericp (input-line-string input) :start (input-line-position input)))
(p2 (and p1 (position-if-not 'alphanumericp (input-line-string input) :start p1))))
(input-delete-region input (input-point input) (or p2 (length (input-line-string input))))))
(defun input-backward-kill-word (input key)
(declare (ignore key))
(let* ((p1 (position-if 'alphanumericp (input-line-string input) :end (input-line-position input) :from-end t))
(p2 (and p1 (position-if-not 'alphanumericp (input-line-string input) :end p1 :from-end t))))
(input-delete-region input (input-point input) (or (and p2 (1+ p2)) 0))))
(defun input-forward-word (input key)
(declare (ignore key))
(let* ((p1 (position-if 'alphanumericp (input-line-string input) :start (input-line-position input)))
(p2 (and p1 (position-if-not 'alphanumericp (input-line-string input) :start p1))))
(setf (input-line-position input) (or p2 (length (input-line-string input))))))
(defun input-backward-word (input key)
(declare (ignore key))
(let* ((p1 (position-if 'alphanumericp (input-line-string input) :end (input-line-position input) :from-end t))
(p2 (and p1 (position-if-not 'alphanumericp (input-line-string input) :end p1 :from-end t))))
(setf (input-line-position input) (or (and p2 (1+ p2))
0))))
(defun input-forward-char (input key)
(declare (ignore key))
(incf (input-line-position input))
(when (> (input-line-position input)
(length (input-line-string input)))
(setf (input-line-position input) (length (input-line-string input)))))
(defun input-backward-char (input key)
(declare (ignore key))
(decf (input-line-position input))
(when (< (input-line-position input) 0)
(setf (input-line-position input) 0)))
(defun input-move-beginning-of-line (input key)
(declare (ignore key))
(setf (input-line-position input) 0))
(defun input-move-end-of-line (input key)
(declare (ignore key))
(setf (input-line-position input) (length (input-line-string input))))
(defun input-kill-line (input key)
(declare (ignore key))
(unless (= (input-line-position input) (length (input-line-string input)))
(set-x-selection (subseq (input-line-string input) (input-line-position input))))
(setf (fill-pointer (input-line-string input)) (input-line-position input)))
(defun input-kill-to-beginning (input key)
(declare (ignore key))
(unless (= (input-line-position input) 0)
(set-x-selection (subseq (input-line-string input) 0 (input-line-position input))))
(replace (input-line-string input) (input-line-string input)
:start2 (input-line-position input) :start1 0)
(decf (fill-pointer (input-line-string input)) (input-line-position input))
(setf (input-line-position input) 0))
(defun input-history-back (input key)
(declare (ignore key))
(when (= (input-line-history input) -1)
(setf (input-line-history-bk input) (input-line-string input)))
(incf (input-line-history input))
(if (>= (input-line-history input)
(length *input-history*))
(progn
(decf (input-line-history input))
:error)
(setf (input-line-string input) (make-input-string (elt *input-history* (input-line-history input)))
(input-line-position input) (length (input-line-string input)))))
(defun input-history-forward (input key)
(declare (ignore key))
(decf (input-line-history input))
(cond ((< (input-line-history input) -1)
(incf (input-line-history input))
:error)
((= (input-line-history input) -1)
(setf (input-line-string input) (input-line-history-bk input)
(input-line-position input) (length (input-line-string input))))
(t
(setf (input-line-string input) (make-input-string (elt *input-history* (input-line-history input)))
(input-line-position input) (length (input-line-string input))))))
(defun input-self-insert (input key)
(let ((char (xlib:keysym->character *display* (key-keysym key))))
(if (or (key-mods-p key) (null char)
(not (characterp char)))
:error
(input-insert-char input char))))
(defun input-yank-selection (input key)
(declare (ignore key))
;; if we own the selection then just insert it.
(if *x-selection*
(input-insert-string input *x-selection*)
(xlib:convert-selection :primary :string (screen-input-window (current-screen)) :stumpwm-selection)))
;;; Misc functions
(defun process-input (screen prompt input code state)
"Process the key (code and state), given the current input
buffer. Returns a new modified input buffer."
(labels ((process-key (code state)
"Call the appropriate function based on the key
pressed. Return 'done when the use has signalled the finish of his
input (pressing Return), nil otherwise."
(let* ((key (code-state->key code state))
(command (and key (lookup-key *input-map* key t))))
(if command
(prog1
(funcall command input key)
(setf *input-last-command* command))
:error))))
(case (process-key code state)
(:done
(unless (and *input-history-ignore-duplicates*
(string= (input-line-string input) (first *input-history*)))
(push (input-line-string input) *input-history*))
:done)
(:abort
(throw :abort t))
(:error
;; FIXME draw inverted text
(draw-input-bucket screen prompt input t)
nil)
(t
(draw-input-bucket screen prompt input)
nil))))
(defun all-modifier-codes ()
(multiple-value-bind
(shift-codes lock-codes control-codes mod1-codes mod2-codes mod3-codes mod4-codes mod5-codes)
(xlib:modifier-mapping *display*)
(append shift-codes
lock-codes
control-codes
mod1-codes
mod2-codes
mod3-codes
mod4-codes
mod5-codes)))
(defun get-modifier-map ()
(labels ((find-mod (mod codes)
(find (xlib:keysym->keycodes *display* (keysym-name->keysym mod)) codes)))
(let ((modifiers (make-modifiers)))
(multiple-value-bind
(shift-codes lock-codes control-codes mod1-codes mod2-codes mod3-codes mod4-codes mod5-codes)
(xlib:modifier-mapping *display*)
(declare (ignore shift-codes lock-codes control-codes))
(loop for mod in '(:mod-1 :mod-2 :mod-3 :mod-4 :mod-5)
for codes in (list mod1-codes mod2-codes mod3-codes mod4-codes mod5-codes)
do
(cond ((or (find-mod "Meta_L" codes)
(find-mod "Meta_R" codes))
(push mod (modifiers-meta modifiers)))
((or (find-mod "Alt_L" codes)
(find-mod "Alt_R" codes))
(push mod (modifiers-alt modifiers)))
((or (find-mod "Super_L" codes)
(find-mod "Super_R" codes))
(push mod (modifiers-super modifiers)))
((or (find-mod "Hyper_L" codes)
(find-mod "Hyper_R" codes))
(push mod (modifiers-hyper modifiers)))
((find-mod "Num_Lock" codes)
(push mod (modifiers-numlock modifiers)))
((find-mod "ISO_Level3_Shift" codes)
(push mod (modifiers-altgr modifiers)))))
;; If alt is defined but meta isn't set meta to alt and clear alt
(when (and (modifiers-alt modifiers)
(null (modifiers-meta modifiers)))
(setf (modifiers-meta modifiers) (modifiers-alt modifiers)
(modifiers-alt modifiers) nil))
modifiers))))
(defun update-modifier-map ()
(setf *modifiers* (get-modifier-map)
*all-modifiers* (all-modifier-codes)))
;; (defun x11mod->stumpmod (screen state)
;; (let ((mod nil))
;; (when (member state (modifiers-alt (screen-modifiers screen)))
;; (push :alt mod))
;; (when (member state (modifiers-meta (screen-modifiers screen)))
;; (push :meta mod))
;; (when (member state (modifiers-hyper (screen-modifiers screen)))
;; (push :hyper mod))
;; (when (member state (modifiers-super (screen-modifiers screen)))
;; (push :super mod))
;; (when (member state :control)
;; (push :control mod))
;; mod))
(defun mod->string (state)
"Convert a stump modifier list to a string"
(let ((alist '((:alt . "A-") (:meta . "M-") (:hyper . "H-") (:super . "S-"))))
(apply #'concatenate 'string (mapcar (lambda (x) (cdr (assoc x alist))) state))))
;; (defun keycode->string (code state)
;; (concatenate 'string (mod->string state)
;; (string (keysym->character *display*
;; (xlib:keycode->keysym *display* code 0)
;; state))))
;; (defun cook-keycode (code state)
;; (values (xlib:keycode->keysym *display* code 0) (x11mod->stumpmod state)))
(defun y-or-n-p (message)
"ask a \"y or n\" question on the current screen and return T if the
user presses 'y'"
(message "~a(y or n) " message)
(char= (read-one-char (current-screen))
#\y))
(defun yes-or-no-p (message)
"ask a \"yes or no\" question on the current screen and return T if the
user presses 'yes'"
(loop for line = (read-one-line (current-screen)
(format nil "~a(yes or no) " message))
until (find line '("yes" "no") :test 'string-equal)
do (message "Please answer yes or no")
(sleep 1)
finally (return (string-equal line "yes"))))
| 27,738 | Common Lisp | .lisp | 582 | 39.073883 | 128 | 0.619468 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 2855dc5a45f05811991f7690bb604e34ab123a3ae448d5221fbb972fd462dc96 | 22,373 | [
-1
] |
22,374 | tile-group.lisp | joelagnel_stumpwm/tile-group.lisp | ;; Copyright (C) 2003-2008 Shawn Betts
;;
;; This file is part of stumpwm.
;;
;; stumpwm is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; stumpwm is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA
;; Commentary:
;;
;; Frame functions
;;
;; Code:
(in-package #:stumpwm)
(export '(save-frame-excursion))
(defclass tile-group (group)
((frame-tree :accessor tile-group-frame-tree)
(last-frame :initform nil :accessor tile-group-last-frame)
(current-frame :accessor tile-group-current-frame)))
(defmethod initialize-instance :after ((group tile-group) &key &allow-other-keys)
(let* ((heads (copy-heads (group-screen group))))
(setf (tile-group-frame-tree group) heads
(tile-group-current-frame group) (first heads))))
(defmethod group-wake-up ((group tile-group))
(focus-frame group (tile-group-current-frame group))
;; doesn't get called by focus-frame
(show-frame-indicator group))
(defmethod group-delete-window ((group tile-group) window)
(let ((f (window-frame window)))
;; maybe pick a new window for the old frame
(when (eq (frame-window f) window)
(frame-raise-window group f (first (frame-windows group f)) nil))))
(defmethod group-add-window ((group tile-group) window &key frame raise &allow-other-keys)
;; This is important to get the frame slot
(change-class window 'tile-window)
;; Try to put the window in the appropriate frame for the group.
(setf (window-frame window)
(or frame
(when *processing-existing-windows*
(find-frame group (xlib:drawable-x (window-parent window))
(xlib:drawable-y (window-parent window))))
(pick-preferred-frame window)))
(when *processing-existing-windows*
(setf (frame-window (window-frame window)) window))
(when (and frame raise)
(setf (tile-group-current-frame group) frame
(frame-window frame) nil))
(sync-frame-windows group (window-frame window))
;; maybe show the window in its new frame
(when (null (frame-window (window-frame window)))
(really-raise-window window)))
(defmethod group-current-window ((group tile-group))
(frame-window (tile-group-current-frame group)))
(defmethod group-current-head ((group tile-group))
(frame-head group (tile-group-current-frame group)))
(defmethod group-move-request ((group tile-group) window x y relative-to)
(when *honor-window-moves*
(dformat 3 "Window requested new position ~D,~D relative to ~S~%" x y relative-to)
(let* ((pos (if (eq relative-to :parent)
(list
(+ (xlib:drawable-x (window-parent window)) x)
(+ (xlib:drawable-y (window-parent window)) y))
(list x y)))
(frame (apply #'find-frame group pos)))
(when frame
(pull-window window frame)))))
(defmethod group-resize-request ((group tile-group) window width height)
;; it's important to grant the resize request first so that resize
;; increment hints use the proper base size to resize from.
(set-window-geometry window :width width :height height)
(maximize-window window))
(defmethod group-raise-request ((group tile-group) window stack-mode)
(when (window-in-current-group-p window)
(case stack-mode
(:map
(maybe-map-window window))
(:above
(maybe-raise-window window)))))
(defmethod group-lost-focus ((group tile-group))
;; If this window had the focus, try to avoid losing it.
(let ((frame (tile-group-current-frame group)))
(setf (frame-window frame)
(first (remove-if 'window-hidden-p (frame-windows group frame))))
(focus-frame group frame)))
(defmethod group-indicate-focus ((group tile-group))
(show-frame-indicator group))
(defmethod group-focus-window ((group tile-group) win)
(frame-raise-window group (window-frame win) win))
(defmethod group-button-press ((group tile-group) x y (where (eql :root)))
(when (and (eq *mouse-focus-policy* :click)
*root-click-focuses-frame*)
(let* ((frame (find-frame group x y)))
(when frame
(focus-frame group frame)
(update-all-mode-lines)))))
(defmethod group-button-press ((group tile-group) x y (where window))
(declare (ignore x y))
(when (eq *mouse-focus-policy* :click)
(focus-all where)
(update-all-mode-lines)))
(defmethod group-window-visible-p ((group tile-group) win)
(eq (frame-window (window-frame win)) win))
(defmethod group-root-exposure ((group tile-group))
(show-frame-outline group nil))
(defmethod group-add-head ((group tile-group))
(sync-all-frame-windows group))
(defmethod group-sync-head ((group tile-group) head)
(dolist (f (head-frames group head))
(sync-frame-windows group f)))
;;;;;
(defun populate-frames (group)
"Try to fill empty frames in GROUP with hidden windows"
(dolist (f (group-frames group))
(unless (frame-window f)
(choose-new-frame-window f group)
(when (frame-window f)
(maximize-window (frame-window f))
(unhide-window (frame-window f))))))
(defun frame-by-number (group n)
(unless (eq n nil)
(find n (group-frames group)
:key 'frame-number
:test '=)))
(defun find-frame (group x y)
"Return the frame of GROUP containing the pixel at X Y"
(dolist (f (group-frames group))
(let* ((fy (frame-y f))
(fx (frame-x f))
(fwx (+ fx (frame-width f)))
(fhy (+ fy (frame-height f))))
(when (and
(>= y fy) (<= y fhy)
(>= x fx) (<= x fwx)
(return f))))))
(defun frame-set-x (frame v)
(decf (frame-width frame)
(- v (frame-x frame)))
(setf (frame-x frame) v))
(defun frame-set-y (frame v)
(decf (frame-height frame)
(- v (frame-y frame)))
(setf (frame-y frame) v))
(defun frame-set-r (frame v)
(setf (frame-width frame)
(- v (frame-x frame))))
(defun frame-set-b (frame v)
(setf (frame-height frame)
(- v (frame-y frame))))
(defun frame-r (frame)
(+ (frame-x frame) (frame-width frame)))
(defun frame-b (frame)
(+ (frame-y frame) (frame-height frame)))
(defun frame-display-y (group frame)
"Return a Y for frame that doesn't overlap the mode-line."
(let* ((head (frame-head group frame))
(ml (head-mode-line head))
(head-y (frame-y head))
(rel-frame-y (- (frame-y frame) head-y)))
(if (and ml (not (eq (mode-line-mode ml) :hidden)))
(case (mode-line-position ml)
(:top
(+ head-y
(+ (mode-line-height ml) (round (* rel-frame-y (mode-line-factor ml))))))
(:bottom
(+ head-y
(round (* rel-frame-y (mode-line-factor ml))))))
(frame-y frame))))
(defun frame-display-height (group frame)
"Return a HEIGHT for frame that doesn't overlap the mode-line."
(let* ((head (frame-head group frame))
(ml (head-mode-line head)))
(if (and ml (not (eq (mode-line-mode ml) :hidden)))
(round (* (frame-height frame) (mode-line-factor ml)))
(frame-height frame))))
(defun frame-intersect (f1 f2)
"Return a new frame representing (only) the intersection of F1 and F2. WIDTH and HEIGHT will be <= 0 if there is no overlap"
(let ((r (copy-frame f1)))
(when (> (frame-x f2) (frame-x f1))
(frame-set-x r (frame-x f2)))
(when (< (+ (frame-x f2) (frame-width f2))
(+ (frame-x f1) (frame-width f1)))
(frame-set-r r (frame-r f2)))
(when (> (frame-y f2) (frame-y f1))
(frame-set-y r (frame-y f2)))
(when (< (+ (frame-y f2) (frame-height f2))
(+ (frame-y f1) (frame-height f1)))
(frame-set-b r (frame-b f2)))
(values r)))
(defun frames-overlap-p (f1 f2)
"Returns T if frames F1 and F2 overlap at all"
(check-type f1 frame)
(check-type f2 frame)
(and (and (frame-p f1) (frame-p f2))
(let ((frame (frame-intersect f1 f2)))
(values (and (plusp (frame-width frame))
(plusp (frame-height frame)))))))
(defun frame-raise-window (g f w &optional (focus t))
"Raise the window w in frame f in group g. if FOCUS is
T (default) then also focus the frame."
(let ((oldw (frame-window f)))
;; nothing to do when W is nil
(setf (frame-window f) w)
(unless (and w (eq oldw w))
(if w
(raise-window w)
(mapc 'hide-window (frame-windows g f))))
;; If raising a window in the current frame we must focus it or
;; the group and screen will get out of sync.
(when (or focus
(eq (tile-group-current-frame g) f))
(focus-frame g f))
(when (and w (not (window-modal-p w)))
(raise-modals-of w))))
(defun focus-frame (group f)
(let ((w (frame-window f))
(last (tile-group-current-frame group))
(show-indicator nil))
(setf (tile-group-current-frame group) f)
;; record the last frame to be used in the fother command.
(unless (eq f last)
(setf (tile-group-last-frame group) last)
(run-hook-with-args *focus-frame-hook* f last)
(setf show-indicator t))
(if w
(focus-window w)
(no-focus group (frame-window last)))
(if show-indicator
(show-frame-indicator group)
(show-frame-outline group))))
(defun frame-windows (group f)
(remove-if-not (lambda (w) (eq (window-frame w) f))
(group-windows group)))
(defun frame-sort-windows (group f)
(remove-if-not (lambda (w) (eq (window-frame w) f))
(sort-windows group)))
(defun copy-frame-tree (tree)
"Return a copy of the frame tree."
(cond ((null tree) tree)
((typep tree 'frame)
(copy-structure tree))
(t
(mapcar #'copy-frame-tree tree))))
(defun group-frames (group)
(tree-accum-fn (tile-group-frame-tree group) 'nconc 'list))
(defun head-frames (group head)
(tree-accum-fn (tile-group-frame-head group head) 'nconc 'list))
(defun find-free-frame-number (group)
(find-free-number (mapcar 'frame-number (group-frames group))))
(defun choose-new-frame-window (frame group)
"Find out what window should go in a newly created frame."
(let ((win (case *new-frame-action*
(:last-window (other-hidden-window group))
(t nil))))
(setf (frame-window frame) win)
(when win
(setf (window-frame win) frame))))
(defun split-frame-h (group p ratio)
"Return 2 new frames. The first one stealing P's number and window"
(let* ((w (truncate (* (frame-width p) ratio)))
(h (frame-height p))
(f1 (make-frame :number (frame-number p)
:x (frame-x p)
:y (frame-y p)
:width w
:height h
:window (frame-window p)))
(f2 (make-frame :number (find-free-frame-number group)
:x (+ (frame-x p) w)
:y (frame-y p)
;; gobble up the modulo
:width (- (frame-width p) w)
:height h
:window nil)))
(run-hook-with-args *new-frame-hook* f2)
(values f1 f2)))
(defun split-frame-v (group p ratio)
"Return 2 new frames. The first one stealing P's number and window"
(let* ((w (frame-width p))
(h (truncate (* (frame-height p) ratio)))
(f1 (make-frame :number (frame-number p)
:x (frame-x p)
:y (frame-y p)
:width w
:height h
:window (frame-window p)))
(f2 (make-frame :number (find-free-frame-number group)
:x (frame-x p)
:y (+ (frame-y p) h)
:width w
;; gobble up the modulo
:height (- (frame-height p) h)
:window nil)))
(run-hook-with-args *new-frame-hook* f2)
(values f1 f2)))
(defun funcall-on-leaf (tree leaf fn)
"Return a new tree with LEAF replaced with the result of calling FN on LEAF."
(cond ((atom tree)
(if (eq leaf tree)
(funcall fn leaf)
tree))
(t (mapcar (lambda (sib)
(funcall-on-leaf sib leaf fn))
tree))))
(defun funcall-on-node (tree fn match)
"Call fn on the node where match returns t."
(if (funcall match tree)
(funcall fn tree)
(cond ((atom tree) tree)
(t (mapcar (lambda (sib)
(funcall-on-node sib fn match))
tree)))))
(defun replace-frame-in-tree (tree f &rest frames)
(funcall-on-leaf tree f (lambda (f)
(declare (ignore f))
frames)))
(defun sibling-internal (tree leaf fn)
"helper for next-sibling and prev-sibling."
(cond ((atom tree) nil)
((find leaf tree)
(let* ((rest (cdr (member leaf (funcall fn tree))))
(pick (car (if (null rest) (funcall fn tree) rest))))
(unless (eq pick leaf)
pick)))
(t (find-if (lambda (x)
(sibling-internal x leaf fn))
tree))))
(defun next-sibling (tree leaf)
"Return the sibling of LEAF in TREE."
(sibling-internal tree leaf 'identity))
(defun prev-sibling (tree leaf)
(sibling-internal tree leaf 'reverse))
(defun closest-sibling (tree leaf)
"Return the sibling to the right/below of leaf or left/above if
leaf is the most right/below of its siblings."
(let* ((parent (tree-parent tree leaf))
(lastp (= (position leaf parent) (1- (length parent)))))
(if lastp
(prev-sibling parent leaf)
(next-sibling parent leaf))))
(defun migrate-frame-windows (group src dest)
"Migrate all windows in SRC frame to DEST frame."
(mapc (lambda (w)
(when (eq (window-frame w) src)
(setf (window-frame w) dest)))
(group-windows group)))
(defun tree-accum-fn (tree acc fn)
"Run an accumulator function on fn applied to each leaf"
(cond ((null tree) nil)
((atom tree)
(funcall fn tree))
(t (apply acc (mapcar (lambda (x) (tree-accum-fn x acc fn)) tree)))))
(defun tree-iterate (tree fn)
"Call FN on every leaf in TREE"
(cond ((null tree) nil)
((atom tree)
(funcall fn tree))
(t (mapc (lambda (x) (tree-iterate x fn)) tree))))
(defun tree-x (tree)
(tree-accum-fn tree 'min 'frame-x))
(defun tree-y (tree)
(tree-accum-fn tree 'min 'frame-y))
(defun tree-width (tree)
(cond ((atom tree) (frame-width tree))
((tree-row-split tree)
;; in row splits, all children have the same width, so use the
;; first one.
(tree-width (first tree)))
(t
;; for column splits we add the width of each child
(reduce '+ tree :key 'tree-width))))
(defun tree-height (tree)
(cond ((atom tree) (frame-height tree))
((tree-column-split tree)
;; in row splits, all children have the same width, so use the
;; first one.
(tree-height (first tree)))
(t
;; for column splits we add the width of each child
(reduce '+ tree :key 'tree-height))))
(defun tree-parent (top node)
"Return the list in TOP that contains NODE."
(cond ((atom top) nil)
((find node top) top)
(t (loop for i in top
thereis (tree-parent i node)))))
(defun tree-leaf (top)
"Return a leaf of the tree. Use this when you need a leaf but
you don't care which one."
(tree-accum-fn top
(lambda (&rest siblings)
(car siblings))
#'identity))
(defun tree-row-split (tree)
"Return t if the children of tree are stacked vertically"
(loop for i in (cdr tree)
with head = (car tree)
always (= (tree-x head) (tree-x i))))
(defun tree-column-split (tree)
"Return t if the children of tree are side-by-side"
(loop for i in (cdr tree)
with head = (car tree)
always (= (tree-y head) (tree-y i))))
(defun tree-split-type (tree)
"return :row or :column"
(cond ((tree-column-split tree) :column)
((tree-row-split tree) :row)
(t (error "tree-split-type unknown"))))
(defun offset-tree (tree x y)
"move the screen's frames around."
(tree-iterate tree (lambda (frame)
(incf (frame-x frame) x)
(incf (frame-y frame) y))))
(defun offset-tree-dir (tree amount dir)
(ecase dir
(:left (offset-tree tree (- amount) 0))
(:right (offset-tree tree amount 0))
(:top (offset-tree tree 0 (- amount)))
(:bottom (offset-tree tree 0 amount))))
(defun expand-tree (tree amount dir)
"expand the frames in tree by AMOUNT in DIR direction. DIR can be :top :bottom :left :right"
(labels ((expand-frame (f amount dir)
(ecase dir
(:left (decf (frame-x f) amount)
(incf (frame-width f) amount))
(:right (incf (frame-width f) amount))
(:top (decf (frame-y f) amount)
(incf (frame-height f) amount))
(:bottom (incf (frame-height f) amount)))))
(cond ((null tree) nil)
((atom tree)
(expand-frame tree amount dir))
((or (and (find dir '(:left :right))
(tree-row-split tree))
(and (find dir '(:top :bottom))
(tree-column-split tree)))
(dolist (i tree)
(expand-tree i amount dir)))
(t
(let* ((children (if (find dir '(:left :top))
(reverse tree)
tree))
(sz-fn (if (find dir '(:left :right))
'tree-width
'tree-height))
(total (funcall sz-fn tree))
(amt-list (loop for i in children
for old-sz = (funcall sz-fn i)
collect (floor (* amount old-sz) total)))
(remainder (- amount (apply '+ amt-list)))
(ofs 0))
;; spread the remainder out as evenly as possible
(assert (< remainder (length amt-list)))
(loop for i upfrom 0
while (> remainder 0)
do
(incf (nth i amt-list))
(decf remainder))
;; resize proportionally
(loop for i in children
for amt in amt-list
do
(expand-tree i amt dir)
(offset-tree-dir i ofs dir)
(incf ofs amt)))))))
(defun join-subtrees (tree leaf)
"expand the children of tree to occupy the space of
LEAF. Return tree with leaf removed."
(let* ((others (remove leaf tree))
(newtree (if (= (length others) 1)
(car others)
others))
(split-type (tree-split-type tree))
(dir (if (eq split-type :column) :right :bottom))
(ofsdir (if (eq split-type :column) :left :top))
(amt (if (eq split-type :column)
(tree-width leaf)
(tree-height leaf)))
(after (cdr (member leaf tree))))
;; align all children after the leaf with the edge of the
;; frame before leaf.
(offset-tree-dir after amt ofsdir)
(expand-tree newtree amt dir)
newtree))
(defun resize-tree (tree w h &optional x y)
"Scale TREE to width W and height H, ignoring aspect. If X and Y are
provided, reposition the TREE as well."
(let* ((tw (tree-width tree))
(th (tree-height tree))
(wf (/ 1 (/ tw w)))
(hf (/ 1 (/ th h)))
(xo (if x (- x (tree-x tree)) 0))
(yo (if y (- y (tree-y tree)) 0)))
(tree-iterate tree (lambda (f)
(setf (frame-height f) (round (* (frame-height f) hf))
(frame-y f) (round (* (frame-y f) hf))
(frame-width f) (round (* (frame-width f) wf))
(frame-x f) (round (* (frame-x f) wf)))
(incf (frame-y f) yo)
(incf (frame-x f) xo)))
(dformat 4 "resize-tree ~Dx~D -> ~Dx~D~%" tw th (tree-width tree) (tree-height tree))))
(defun remove-frame (tree leaf)
"Return a new tree with LEAF and it's sibling merged into
one."
(cond ((atom tree) tree)
((find leaf tree)
(join-subtrees tree leaf))
(t (mapcar (lambda (sib)
(remove-frame sib leaf))
tree))))
(defun sync-frame-windows (group frame)
"synchronize windows attached to FRAME."
(mapc (lambda (w)
(when (eq (window-frame w) frame)
(dformat 3 "maximizing ~S~%" w)
(maximize-window w)))
(group-windows group)))
(defun sync-all-frame-windows (group)
"synchronize all frames in GROUP."
(let ((tree (tile-group-frame-tree group)))
(tree-iterate tree
(lambda (f)
(sync-frame-windows group f)))))
(defun sync-head-frame-windows (group head)
"synchronize all frames in GROUP and HEAD."
(dolist (f (head-frames group head))
(sync-frame-windows group f)))
(defun offset-frames (group x y)
"move the screen's frames around."
(let ((tree (tile-group-frame-tree group)))
(tree-iterate tree (lambda (frame)
(incf (frame-x frame) x)
(incf (frame-y frame) y)))))
(defun resize-frame (group frame amount dim)
"Resize FRAME by AMOUNT in DIM dimension, DIM can be
either :width or :height"
(check-type group group)
(check-type frame frame)
(check-type amount integer)
;; (check-type dim (member :width :height))
(labels ((max-amount (parent node min dim-fn)
(let ((right-sibling (cadr (member node parent)))
(left-sibling (cadr (member node (reverse parent)))))
(dformat 10 "max ~@{~a~^ ~}~%" parent node min dim-fn right-sibling left-sibling)
(if parent
(cond (right-sibling
(max 0 (- (funcall dim-fn right-sibling) min)))
(left-sibling
(max 0 (- (funcall dim-fn left-sibling) min)))
(t 0))
;; no parent means the frame can't get any bigger.
0))))
(let* ((tree (tile-group-frame-tree group))
(parent (tree-parent tree frame))
(gparent (tree-parent tree parent))
(split-type (tree-split-type parent)))
(dformat 10 "~s ~s parent: ~s ~s width: ~s h: ~s~%" dim amount split-type parent (tree-width parent) (tree-height parent))
;; normalize amount
(let* ((max (ecase dim
(:width
(if (>= (frame-width frame) (frame-width (frame-head group frame)))
0
(if (eq split-type :column)
(max-amount parent frame *min-frame-width* 'tree-width)
(max-amount gparent parent *min-frame-width* 'tree-width))))
(:height
(if (>= (frame-height frame) (frame-height (frame-head group frame)))
0
(if (eq split-type :row)
(max-amount parent frame *min-frame-height* 'tree-height)
(max-amount gparent parent *min-frame-height* 'tree-height))))))
(min (ecase dim
;; Frames taking up the entire HEAD in one
;; dimension can't be resized in that dimension.
(:width
(if (and (eq split-type :row)
(or (null gparent)
(>= (frame-width frame) (frame-width (frame-head group frame)))))
0
(- *min-frame-width* (frame-width frame))))
(:height
(if (and (eq split-type :column)
(or (null gparent)
(>= (frame-height frame) (frame-height (frame-head group frame)))))
0
(- *min-frame-height* (frame-height frame)))))))
(setf amount (max (min amount max) min))
(dformat 10 "bounds ~d ~d ~d~%" amount max min))
;; if FRAME is taking up the whole DIM or if AMOUNT = 0, do nothing
(unless (zerop amount)
(let* ((resize-parent (or (and (eq split-type :column)
(eq dim :height))
(and (eq split-type :row)
(eq dim :width))))
(to-resize (if resize-parent parent frame))
(to-resize-parent (if resize-parent gparent parent))
(lastp (= (position to-resize to-resize-parent) (1- (length to-resize-parent))))
(to-shrink (if lastp
(prev-sibling to-resize-parent to-resize)
(next-sibling to-resize-parent to-resize))))
(expand-tree to-resize amount (ecase dim
(:width (if lastp :left :right))
(:height (if lastp :top :bottom))))
(expand-tree to-shrink (- amount) (ecase dim
(:width (if lastp :right :left))
(:height (if lastp :bottom :top))))
(unless (and *resize-hides-windows* (eq *top-map* *resize-map*))
(tree-iterate to-resize
(lambda (leaf)
(sync-frame-windows group leaf)))
(tree-iterate to-shrink
(lambda (leaf)
(sync-frame-windows group leaf)))))))))
(defun balance-frames-internal (group tree)
"Resize all the children of tree to be of equal width or height
depending on the tree's split direction."
(let* ((split-type (tree-split-type tree))
(fn (if (eq split-type :column)
'tree-width
'tree-height))
(side (if (eq split-type :column)
:right
:bottom))
(total (funcall fn tree))
size rem)
(multiple-value-setq (size rem) (truncate total (length tree)))
(loop
for i in tree
for j = rem then (1- j)
for totalofs = 0 then (+ totalofs ofs)
for ofs = (+ (- size (funcall fn i)) (if (plusp j) 1 0))
do
(expand-tree i ofs side)
(offset-tree-dir i totalofs side)
(tree-iterate i (lambda (leaf)
(sync-frame-windows group leaf))))))
(defun split-frame (group how &optional (ratio 1/2))
"split the current frame into 2 frames. return T if it succeeded. NIL otherwise."
(check-type how (member :row :column))
(let* ((frame (tile-group-current-frame group))
(head (frame-head group frame)))
;; don't create frames smaller than the minimum size
(when (or (and (eq how :row)
(>= (frame-height frame) (* *min-frame-height* 2)))
(and (eq how :column)
(>= (frame-width frame) (* *min-frame-width* 2))))
(multiple-value-bind (f1 f2) (funcall (if (eq how :column)
'split-frame-h
'split-frame-v)
group frame ratio)
(setf (tile-group-frame-head group head)
(if (atom (tile-group-frame-head group head))
(list f1 f2)
(funcall-on-node (tile-group-frame-head group head)
(lambda (tree)
(if (eq (tree-split-type tree) how)
(list-splice-replace frame tree f1 f2)
(substitute (list f1 f2) frame tree)))
(lambda (tree)
(unless (atom tree)
(find frame tree))))))
(migrate-frame-windows group frame f1)
(choose-new-frame-window f2 group)
(if (eq (tile-group-current-frame group)
frame)
(setf (tile-group-current-frame group) f1))
(setf (tile-group-last-frame group) f2)
(sync-frame-windows group f1)
(sync-frame-windows group f2)
;; we also need to show the new window in the other frame
(when (frame-window f2)
(unhide-window (frame-window f2)))
t))))
(defun draw-frame-outline (group f tl br)
"Draw an outline around FRAME."
(let* ((screen (group-screen group))
(win (if (frame-window f) (window-xwin (frame-window f)) (screen-root screen)))
(width (screen-frame-outline-width screen))
(gc (screen-frame-outline-gc screen))
(halfwidth (/ width 2)))
(when (> width 0)
(let ((x (frame-x f))
(y (frame-display-y group f))
(w (frame-width f))
(h (frame-display-height group f)))
(when tl
(xlib:draw-line win gc
x (+ halfwidth y) w 0 t)
(xlib:draw-line win gc
(+ halfwidth x) y 0 h t))
(when br
(xlib:draw-line win gc
(+ x (- w halfwidth)) y 0 h t)
(xlib:draw-line win gc
x (+ y (- h halfwidth)) w 0 t))))))
(defun draw-frame-outlines (group &optional head)
"Draw an outline around all frames in GROUP."
(clear-frame-outlines group)
(dolist (h (if head (list head) (group-heads group)))
(draw-frame-outline group h nil t)
(tree-iterate (tile-group-frame-head group h) (lambda (f)
(draw-frame-outline group f t nil)))))
(defun clear-frame-outlines (group)
"Clear the outlines drawn with DRAW-FRAME-OUTLINES."
(xlib:clear-area (screen-root (group-screen group))))
(defun draw-frame-numbers (group)
"Draw the number of each frame in its corner. Return the list of
windows used to draw the numbers in. The caller must destroy them."
(let ((screen (group-screen group)))
(mapcar (lambda (f)
(let ((w (xlib:create-window
:parent (screen-root screen)
:x (frame-x f) :y (frame-display-y group f) :width 1 :height 1
:background (screen-fg-color screen)
:border (screen-border-color screen)
:border-width 1
:event-mask '())))
(xlib:map-window w)
(setf (xlib:window-priority w) :above)
(echo-in-window w (screen-font screen)
(screen-fg-color screen)
(screen-bg-color screen)
(string (get-frame-number-translation f)))
(xlib:display-finish-output *display*)
(dformat 3 "mapped ~S~%" (frame-number f))
w))
(group-frames group))))
(defmacro save-frame-excursion (&body body)
"Execute body and then restore the current frame."
(let ((oframe (gensym "OFRAME"))
(ogroup (gensym "OGROUP")))
`(let ((,oframe (tile-group-current-frame (current-group)))
(,ogroup (current-group)))
(unwind-protect (progn ,@body)
(focus-frame ,ogroup ,oframe)))))
;;; Frame commands
(defun split-frame-in-dir (group dir)
(let ((f (tile-group-current-frame group)))
(if (split-frame group dir)
(progn
(when (frame-window f)
(update-decoration (frame-window f)))
(show-frame-indicator group))
(message "Cannot split smaller than minimum size."))))
(defcommand (hsplit tile-group) () ()
"Split the current frame into 2 side-by-side frames."
(split-frame-in-dir (current-group) :column))
(defcommand (vsplit tile-group) () ()
"Split the current frame into 2 frames, one on top of the other."
(split-frame-in-dir (current-group) :row))
(defcommand (remove-split tile-group) (&optional (group (current-group)) (frame (tile-group-current-frame group))) ()
"Remove the specified frame in the specified group (defaults to current
group, current frame). Windows in the frame are migrated to the frame taking up its
space."
(let* ((head (frame-head group frame))
(current (tile-group-current-frame group))
(tree (tile-group-frame-head group head))
(s (closest-sibling (list tree) frame))
;; grab a leaf of the siblings. The siblings doesn't have to be
;; a frame.
(l (tree-accum-fn s
(lambda (&rest siblings)
(car siblings))
#'identity)))
;; Only remove the current frame if it has a sibling
(if (atom tree)
(message "No more frames!")
(when s
(when (frame-is-head group frame)
(setf (frame-number l) (frame-number frame)))
;; Move the windows from the removed frame to its sibling
(migrate-frame-windows group frame l)
;; If the frame has no window, give it the current window of
;; the current frame.
(unless (frame-window l)
(setf (frame-window l)
(frame-window frame)))
;; Unsplit
(setf (tile-group-frame-head group head) (remove-frame tree frame))
;; update the current frame and sync all windows
(when (eq frame current)
(setf (tile-group-current-frame group) l))
(tree-iterate tree
(lambda (leaf)
(sync-frame-windows group leaf)))
(frame-raise-window group l (frame-window l) nil)
(when (frame-window l)
(update-decoration (frame-window l)))
(when (eq frame current)
(show-frame-indicator group))))))
(defcommand-alias remove remove-split)
(defcommand (only tile-group) () ()
"Delete all the frames but the current one and grow it to take up the entire head."
(let* ((screen (current-screen))
(group (screen-current-group screen))
(win (group-current-window group))
(head (current-head group))
(frame (copy-frame head)))
(if (atom (tile-group-frame-head group head))
(message "There's only one frame.")
(progn
(mapc (lambda (w)
;; windows in other frames disappear
(unless (eq (window-frame w) (tile-group-current-frame group))
(hide-window w))
(setf (window-frame w) frame))
(head-windows group head))
(setf (frame-window frame) win
(tile-group-frame-head group head) frame
(tile-group-current-frame group) frame)
(focus-frame group frame)
(if (frame-window frame)
(update-decoration (frame-window frame))
(show-frame-indicator group))
(sync-frame-windows group (tile-group-current-frame group))))))
(defcommand (curframe tile-group) () ()
"Display a window indicating which frame is focused."
(show-frame-indicator (current-group) t))
(defun focus-frame-next-sibling (group)
(let* ((sib (next-sibling (tile-group-frame-tree group)
(tile-group-current-frame group))))
(when sib
(focus-frame group (tree-accum-fn sib
(lambda (x y)
(declare (ignore y))
x)
'identity))
(show-frame-indicator group))))
(defun focus-last-frame (group)
;; make sure the last frame still exists in the frame tree
(when (and (tile-group-last-frame group)
(find (tile-group-last-frame group) (group-frames group)))
(focus-frame group (tile-group-last-frame group))))
(defun focus-frame-after (group frames)
"Given a list of frames focus the next one in the list after
the current frame."
(let ((rest (cdr (member (tile-group-current-frame group) frames :test 'eq))))
(focus-frame group
(if (null rest)
(car frames)
(car rest)))))
(defun focus-next-frame (group)
(focus-frame-after group (group-frames group)))
(defun focus-prev-frame (group)
(focus-frame-after group (nreverse (group-frames group))))
(defcommand (fnext tile-group) () ()
"Cycle through the frame tree to the next frame."
(focus-next-frame (current-group)))
(defcommand (sibling tile-group) () ()
"Jump to the frame's sibling. If a frame is split into two frames,
these two frames are siblings."
(focus-frame-next-sibling (current-group)))
(defcommand (fother tile-group) () ()
"Jump to the last frame that had focus."
(focus-last-frame (current-group)))
(defun choose-frame-by-number (group)
"show a number in the corner of each frame and wait for the user to
select one. Returns the selected frame or nil if aborted."
(let* ((wins (progn
(draw-frame-outlines group)
(draw-frame-numbers group)))
(ch (read-one-char (group-screen group)))
(num (read-from-string (string ch) nil nil)))
(dformat 3 "read ~S ~S~%" ch num)
(mapc #'xlib:destroy-window wins)
(clear-frame-outlines group)
(find ch (group-frames group)
:test 'char=
:key 'get-frame-number-translation)))
(defcommand (fselect tile-group) (frame-number) ((:frame t))
"Display a number in the corner of each frame and let the user to
select a frame by number. If @var{frame-number} is specified, just
jump to that frame."
(let ((group (current-group)))
(focus-frame group frame-number)))
(defcommand (resize tile-group) (width height) ((:number "+ Width: ")
(:number "+ Height: "))
"Resize the current frame by @var{width} and @var{height} pixels"
(let* ((group (current-group))
(f (tile-group-current-frame group)))
(if (atom (tile-group-frame-tree group))
(message "No more frames!")
(progn
(clear-frame-outlines group)
(resize-frame group f width :width)
(resize-frame group f height :height)
(draw-frame-outlines group (current-head))))))
(defun clear-frame (frame group)
"Clear the given frame."
(frame-raise-window group frame nil (eq (tile-group-current-frame group) frame)))
(defcommand (fclear tile-group) () ()
"Clear the current frame."
(clear-frame (tile-group-current-frame (current-group)) (current-group)))
(defun get-edge (frame edge)
"Returns the specified edge of FRAME. Valid values for EDGE are :TOP, :BOTTOM, :LEFT, and :RIGHT.
An edge is a START, END, and OFFSET. For horizontal edges, START is the left coordinate, END is
the right coordinate, and OFFSET is the Y coordinate. Similarly, for vertical lines, START is
top, END is bottom, and OFFSET is X coordinate."
(let* ((x1 (frame-x frame))
(y1 (frame-y frame))
(x2 (+ x1 (frame-width frame)))
(y2 (+ y1 (frame-height frame))))
(ecase edge
(:top
(values x1 x2 y1))
(:bottom
(values x1 x2 y2))
(:left
(values y1 y2 x1))
(:right
(values y1 y2 x2)))))
(defun neighbour (direction frame frameset)
"Returns the best neighbour of FRAME in FRAMESET on the DIRECTION edge.
Valid directions are :UP, :DOWN, :LEFT, :RIGHT.
eg: (NEIGHBOUR :UP F FS) finds the frame in FS that is the 'best'
neighbour above F."
(let ((src-edge (ecase direction
(:up :top)
(:down :bottom)
(:left :left)
(:right :right)))
(opposite (ecase direction
(:up :bottom)
(:down :top)
(:left :right)
(:right :left)))
(best-frame nil)
(best-overlap 0))
(multiple-value-bind (src-s src-e src-offset)
(get-edge frame src-edge)
(dolist (f frameset)
(multiple-value-bind (s e offset)
(get-edge f opposite)
(let ((overlap (- (min src-e e)
(max src-s s))))
;; Two edges are neighbours if they have the same offset and their starts and ends
;; overlap. We want to find the neighbour that overlaps the most.
(when (and (= src-offset offset)
(> overlap best-overlap))
(setf best-frame f)
(setf best-overlap overlap))))))
best-frame))
(defun move-focus-and-or-window (dir &optional win-p)
(declare (type (member :up :down :left :right) dir))
(let* ((group (current-group))
(new-frame (neighbour dir (tile-group-current-frame group) (group-frames group)))
(window (current-window)))
(when new-frame
(if (and win-p window)
(pull-window window new-frame)
(focus-frame group new-frame)))))
(defcommand (move-focus tile-group) (dir) ((:direction "Direction: "))
"Focus the frame adjacent to the current one in the specified
direction. The following are valid directions:
@table @asis
@item up
@item down
@item left
@item right
@end table"
(move-focus-and-or-window dir))
(defcommand (move-window tile-group) (dir) ((:direction "Direction: "))
"Just like move-focus except that the current is pulled along."
(move-focus-and-or-window dir t))
(defcommand (next-in-frame tile-group) () ()
"Go to the next window in the current frame."
(let ((group (current-group)))
(if (group-current-window group)
(focus-forward group (frame-sort-windows group (tile-group-current-frame group)))
(other-window-in-frame group))))
(defcommand (prev-in-frame tile-group) () ()
"Go to the previous window in the current frame."
(let ((group (current-group)))
(if (group-current-window group)
(focus-forward group (reverse (frame-sort-windows group (tile-group-current-frame group))))
(other-window-in-frame group))))
(defcommand (other-in-frame tile-group) () ()
"Go to the last accessed window in the current frame."
(other-window-in-frame (current-group)))
(defcommand (balance-frames tile-group) () ()
"Make frames the same height or width in the current frame's subtree."
(let* ((group (current-group))
(tree (tree-parent (tile-group-frame-head group (current-head))
(tile-group-current-frame group))))
(if tree
(balance-frames-internal (current-group) tree)
(message "There's only one frame."))))
| 43,555 | Common Lisp | .lisp | 994 | 33.789738 | 128 | 0.573112 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 795884016b8159d8dbdc5917510a67cbba3704e1a8f1e8a1bc1c94b5217d5d09 | 22,374 | [
-1
] |
22,377 | sample-stumpwmrc.lisp | joelagnel_stumpwm/sample-stumpwmrc.lisp | ;; -*-lisp-*-
;;
;; Here is a sample .stumpwmrc file
(in-package :stumpwm)
;; change the prefix key to something else
(set-prefix-key (kbd "C-z"))
;; prompt the user for an interactive command. The first arg is an
;; optional initial contents.
(defcommand colon1 (&optional (initial "")) (:rest)
(let ((cmd (read-one-line (current-screen) ": " initial)))
(when cmd
(eval-command cmd t))))
;; Read some doc
(define-key *root-map* (kbd "d") "exec gv")
;; Browse somewhere
(define-key *root-map* (kbd "b") "colon1 exec firefox http://www.")
;; Ssh somewhere
(define-key *root-map* (kbd "C-s") "colon1 exec xterm -e ssh ")
;; Lock screen
(define-key *root-map* (kbd "C-l") "exec xlock")
;; Web jump (works for Google and Imdb)
(defmacro make-web-jump (name prefix)
`(defcommand ,name (search) ((:rest ,(concatenate 'string name " search: ")))
(substitute #\+ #\Space search)
(run-shell-command (concatenate 'string ,prefix search))))
(make-web-jump "google" "firefox http://www.google.fr/search?q=")
(make-web-jump "imdb" "firefox http://www.imdb.com/find?q=")
;; C-t M-s is a terrble binding, but you get the idea.
(define-key *root-map* (kbd "M-s") "google")
(define-key *root-map* (kbd "i") "imdb")
;; Message window font
(set-font "-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-15")
;;; Define window placement policy...
;; Clear rules
(clear-window-placement-rules)
;; Last rule to match takes precedence!
;; TIP: if the argument to :title or :role begins with an ellipsis, a substring
;; match is performed.
;; TIP: if the :create flag is set then a missing group will be created and
;; restored from *data-dir*/create file.
;; TIP: if the :restore flag is set then group dump is restored even for an
;; existing group using *data-dir*/restore file.
(define-frame-preference "Default"
;; frame raise lock (lock AND raise == jumpto)
(0 t nil :class "Konqueror" :role "...konqueror-mainwindow")
(1 t nil :class "XTerm"))
(define-frame-preference "Ardour"
(0 t t :instance "ardour_editor" :type :normal)
(0 t t :title "Ardour - Session Control")
(0 nil nil :class "XTerm")
(1 t nil :type :normal)
(1 t t :instance "ardour_mixer")
(2 t t :instance "jvmetro")
(1 t t :instance "qjackctl")
(3 t t :instance "qjackctl" :role "qjackctlMainForm"))
(define-frame-preference "Shareland"
(0 t nil :class "XTerm")
(1 nil t :class "aMule"))
(define-frame-preference "Emacs"
(1 t t :restore "emacs-editing-dump" :title "...xdvi")
(0 t t :create "emacs-dump" :class "Emacs")) | 2,569 | Common Lisp | .lisp | 61 | 40.04918 | 79 | 0.680561 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 3bafa8246c14bea1833102be01ae53cbe4671143d2a80f620fc982b268223b80 | 22,377 | [
-1
] |
22,378 | workarounds.lisp | joelagnel_stumpwm/workarounds.lisp | ;;; workarounds for bugs in clx
(in-package :xlib)
;;; SBCL workaround for a clx caching bug. This is taken from portable-clx's display.lisp.
;;; NOTE! The latest clx in Rhodes' repository has fixed this is a far
;;; better way by only caching XIDs created by the client.
;; Define functions to find the CLX data types given a display and resource-id
;; If the data type is being cached, look there first.
#+sbcl
(macrolet ((generate-lookup-functions (useless-name &body types)
`(within-definition (,useless-name generate-lookup-functions)
,@(mapcar
#'(lambda (type)
`(defun ,(xintern 'lookup- type)
(display id)
(declare (type display display)
(type resource-id id))
(declare (clx-values ,type))
,(if (member type +clx-cached-types+)
`(let ((,type (lookup-resource-id display id)))
(cond ((null ,type) ;; Not found, create and save it.
(setq ,type (,(xintern 'make- type)
:display display :id id))
(save-id display id ,type))
;; Found. Check the type
((type? ,type ',type) ,type)
(t
(restart-case
(x-error 'lookup-error
:id id
:display display
:type ',type
:object ,type)
(:one ()
:report "Invalidate this cache entry"
(save-id display id (,(xintern 'make- type) :display display :id id)))
(:all ()
:report "Invalidate all display cache"
(clrhash (display-resource-id-map display))
(save-id display id (,(xintern 'make- type) :display display :id id)))))))
;; Not being cached. Create a new one each time.
`(,(xintern 'make- type)
:display display :id id))))
types))))
(generate-lookup-functions ignore
drawable
window
pixmap
gcontext
cursor
colormap
font))
;;; Both clisp and SBCL can't handle incompliant (and in clisp's case,
;;; even compliant) wm-class strings. See test-wm-class in test-wm.lisp.
#+sbcl
(defun get-wm-class (window)
(declare (type window window))
(declare (clx-values (or null name-string) (or null class-string)))
(let ((value (get-property window :WM_CLASS :type :STRING :result-type '(vector card8))))
(declare (type (or null (vector card8)) value))
(when value
;; Buggy clients may not comply with the format, so deal with
;; the unexpected.
(let* ((first-zero (position 0 (the (vector card8) value)))
(second-zero (and first-zero
(position 0 (the (vector card8) value) :start (1+ first-zero))))
(name (subseq (the (vector card8) value) 0 first-zero))
(class (and first-zero
(subseq (the (vector card8) value) (1+ first-zero) second-zero))))
(values (and (plusp (length name)) (map 'string #'card8->char name))
(and (plusp (length class)) (map 'string #'card8->char class)))))))
#+clisp
(defun get-wm-class (window)
(let ((value (get-property window :WM_CLASS :type :STRING :result-type 'string :transform #'card8->char)))
(when value
;; Buggy clients may not comply with the format, so deal with
;; the unexpected.
(let* ((first-zero (position (load-time-value (card8->char 0)) (the string value)))
(second-zero (and first-zero
(position (load-time-value (card8->char 0)) (the string value) :start (1+ first-zero))))
(name (subseq (the string value) 0 first-zero))
(class (and first-zero
(subseq (the string value) (1+ first-zero) second-zero))))
(values (and (plusp (length name)) name)
(and (plusp (length class)) class))))))
#+clisp
(when (fboundp '%gcontext-key->mask)
(defmacro WITH-GCONTEXT ((gcontext &rest options) &body body)
(let ((saved (gensym)) (gcon (gensym)) (g0 (gensym)) (g1 (gensym))
(comps 0)
(setf-forms nil)
dashes? clip-mask?)
(do ((q options (cddr q)))
((null q))
(cond ((eq (car q) :dashes) (setf dashes? t))
((eq (car q) :clip-mask) (setf clip-mask? t)))
(setf comps (logior comps (%gcontext-key->mask (car q)))
setf-forms (nconc setf-forms
(list (list (find-symbol (ext:string-concat "GCONTEXT-" (symbol-name (car q))) :xlib)
gcon)
(cadr q)))))
`(LET* ((,gcon ,gcontext)
(,saved (%SAVE-GCONTEXT-COMPONENTS ,gcon ,comps))
,@(if dashes? (list `(,g0 (GCONTEXT-DASHES ,gcon))))
,@(if clip-mask? (list `(,g1 (GCONTEXT-CLIP-MASK ,gcon)))))
(UNWIND-PROTECT
(PROGN
(SETF ,@setf-forms)
,@body)
(PROGN
(%RESTORE-GCONTEXT-COMPONENTS ,gcon ,saved)
,@(if dashes? (list `(SETF (GCONTEXT-DASHES ,gcon) ,g0)))
,@(if clip-mask? (list `(SETF (GCONTEXT-CLIP-MASK ,gcon) ,g1)))))))))
| 5,573 | Common Lisp | .lisp | 112 | 35.9375 | 119 | 0.522465 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 8757cd8f39a13d72da3368bd02f478f5c4ea33ff72b1d91bcda6765c90ba7403 | 22,378 | [
-1
] |
22,381 | floating-group.lisp | joelagnel_stumpwm/floating-group.lisp | ;;; implementation of a floating style window management group
(in-package :stumpwm)
;;; floating window
(defclass float-window (window)
((last-width :initform 0 :accessor float-window-last-width)
(last-height :initform 0 :accessor float-window-last-height)
(last-x :initform 0 :accessor float-window-last-x)
(last-y :initform 0 :accessor float-window-last-y))
)
(defvar *float-window-border* 1)
(defvar *float-window-title-height* 10)
;; some book keeping functions
(defmethod (setf window-x) :before (val (window float-window))
(unless (eql (window-x window) val)
(setf (float-window-last-x window) (window-x window))))
(defmethod (setf window-y) :before (val (window float-window))
(unless (eql (window-y window) val)
(setf (float-window-last-y window) (window-y window))))
(defmethod (setf window-width) :before (val (window float-window))
(unless (eql (window-width window) val)
(setf (float-window-last-width window) (window-width window))))
(defmethod (setf window-height) :before (val (window float-window))
(unless (eql (window-height window) val)
(setf (float-window-last-height window) (window-height window))))
(defun float-window-move-resize (win &key x y width height (border *float-window-border*))
;; x and y position the parent window while width, height resize the
;; xwin (meaning the parent will have a larger width).
(with-slots (xwin parent) win
(xlib:with-state (parent)
(xlib:with-state (xwin)
(when x
(setf (xlib:drawable-x parent) x
(window-x win) x))
(when y
(setf (xlib:drawable-y parent) y
(window-y win) y))
(when width
(setf (xlib:drawable-width parent) (+ (xlib:drawable-x xwin) width border)
(xlib:drawable-width xwin) width
(window-width win) width))
(when height
(setf (xlib:drawable-height parent) (+ (xlib:drawable-y xwin) height border)
(xlib:drawable-height xwin) height
(window-height win) height))))))
(defmethod update-decoration ((window float-window))
(let ((group (window-group window)))
(setf (xlib:window-background (window-parent window))
(xlib:alloc-color (xlib:screen-default-colormap (screen-number (window-screen window)))
(if (eq (group-current-window group) window)
"Orange"
"SteelBlue4")))
(xlib:clear-area (window-parent window))))
(defmethod window-sync ((window float-window) hint)
(declare (ignore hint))
)
(defmethod window-head ((window float-window))
(dolist (head (screen-heads (group-screen (window-group window))))
(when (and
(>= (window-x window) (frame-x head))
(>= (window-y window) (frame-y head))
(<= (+ (window-x window) (window-width window))
(+ (frame-x head) (frame-width head)))
(<= (+ (window-y window) (window-height window))
(+ (frame-y head) (frame-height head))))
(return head))))
(defmethod window-visible-p ((win float-window))
(eql (window-state win) +normal-state+))
(defmethod (setf window-fullscreen) :after (val (window float-window))
(with-slots (last-x last-y last-width last-height parent) window
(if val
(let ((head (window-head window)))
(with-slots (x y width height) window
(format t "major on: ~a ~a ~a ~a~%" x y width height))
(set-window-geometry window :x 0 :y 0)
(float-window-move-resize window
:x (frame-x head)
:y (frame-y head)
:width (frame-width head)
:height (frame-height head)
:border 0)
(format t "loot after: ~a ~a ~a ~a~%" last-x last-y last-width last-height))
(progn
(format t "fullscreenage: ~a ~a ~a ~a~%" last-x last-y last-width last-height)
;; restore the position
(set-window-geometry window :x *float-window-border* :y *float-window-title-height*)
(float-window-move-resize window
:x last-x
:y last-y
:width last-width
:height last-height)))))
;;; floating group
(defclass float-group (group)
((current-window :accessor float-group-current-window))
)
(defmethod group-add-window ((group float-group) window &key &allow-other-keys)
(change-class window 'float-window)
(float-window-align window)
(focus-window window))
(defun &float-focus-next (group)
(if (group-windows group)
(focus-window (first (group-windows group)))
(no-focus group nil)))
(defmethod group-delete-window ((group float-group) window)
(declare (ignore window))
(&float-focus-next group))
(defmethod group-wake-up ((group float-group))
(&float-focus-next group))
(defmethod group-suspend ((group float-group))
)
(defmethod group-current-window ((group float-group))
(screen-focus (group-screen group)))
(defmethod group-current-head ((group float-group))
(first (screen-heads (group-screen group))))
(defun float-window-align (window)
(with-slots (parent xwin width height) window
(set-window-geometry window :x *float-window-border* :y *float-window-title-height*)
(xlib:with-state (parent)
(setf (xlib:drawable-width parent) (+ width (* 2 *float-window-border*))
(xlib:drawable-height parent) (+ height *float-window-title-height* *float-window-border*)
(xlib:window-background parent) (xlib:alloc-color (xlib:screen-default-colormap (screen-number (window-screen window)))
"Orange")))
(xlib:clear-area (window-parent window))))
(defmethod group-resize-request ((group float-group) window width height)
(float-window-move-resize window :width width :height height))
(defmethod group-move-request ((group float-group) window x y relative-to)
(declare (ignore relative-to))
(float-window-move-resize window :x x :y y))
(defmethod group-raise-request ((group float-group) window type)
(declare (ignore type))
(focus-window window))
(defmethod group-lost-focus ((group float-group))
(&float-focus-next group))
(defmethod group-indicate-focus ((group float-group))
)
(defmethod group-focus-window ((group float-group) window)
(focus-window window))
(defmethod group-root-exposure ((group float-group))
)
(defmethod group-add-head ((group float-group))
)
(defmethod group-sync-head ((group float-group) head)
(declare (ignore head))
)
(defmethod group-button-press ((group float-group) x y (window float-window))
(let ((screen (group-screen group)))
(cond
((or (< x (xlib:drawable-x (window-xwin window)))
(> x (+ (xlib:drawable-width (window-xwin window))
(xlib:drawable-x (window-xwin window))))
(< y (xlib:drawable-y (window-xwin window)))
(> y (+ (xlib:drawable-height (window-xwin window))
(xlib:drawable-y (window-xwin window)))))
(message "Move window! ~@{~a ~}" x y window)
(multiple-value-bind (relx rely) (xlib:query-pointer (window-parent window))
(labels ((move-window-event-handler (&rest event-slots &key event-key &allow-other-keys)
(case event-key
(:button-release
:done)
(:motion-notify
(with-slots (parent) window
(xlib:with-state (parent)
(setf (xlib:drawable-x parent) (- (getf event-slots :x) relx)
(xlib:drawable-y parent) (- (getf event-slots :y) rely))))
t)
;; We need to eat these events or they'll ALL
;; come blasting in later. Also things start
;; lagging hard if we don't (on clisp anyway).
(:configure-notify t)
(:exposure t)
(t
nil))))
(xlib:grab-pointer (screen-root screen) '(:button-release :pointer-motion))
(unwind-protect
(loop for ev = (xlib:process-event *display* :handler #'move-window-event-handler :timeout nil)
until (eq ev :done))
(ungrab-pointer))
;; don't forget to update the cache
(setf (window-x window) (xlib:drawable-x (window-parent window))
(window-y window) (xlib:drawable-y (window-parent window)))
(message "Done."))))
(t
(when (eq *mouse-focus-policy* :click)
(focus-window window))))))
(defmethod group-button-press ((group float-group) x y where)
(declare (ignore x y where))
)
(defcommand gnew-float (name) ((:rest "Name: "))
(add-group (current-screen) name 'float-group))
| 9,114 | Common Lisp | .lisp | 188 | 38.468085 | 131 | 0.604298 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 4705500c1c2af76b17ab265de1deec91fa71ac08958e8677edbdd280bd5c8fe0 | 22,381 | [
-1
] |
22,382 | make-image.lisp.in | joelagnel_stumpwm/make-image.lisp.in | ;;; SBCL
#+sbcl
(progn
(require 'asdf)
(require 'stumpwm))
#+sbcl
(progn
(load "stumpwm.asd")
(sb-ext:save-lisp-and-die "stumpwm" :toplevel (lambda ()
;; asdf requires sbcl_home to be set, so set it to the value when the image was built
(sb-posix:putenv (format nil "SBCL_HOME=~A" #.(sb-ext:posix-getenv "SBCL_HOME")))
(stumpwm:stumpwm)
0)
:executable t))
;;; CLISP
;; Is there a better way to use asdf.lisp than including it with stumpwm?
#+clisp
(progn
(load "asdf.lisp")
(load "stumpwm.asd")
(load "@PPCRE_PATH@/cl-ppcre.asd"))
#+clisp
(progn
(asdf:oos 'asdf:load-op 'stumpwm))
#+clisp
(progn
(ext:saveinitmem "stumpwm" :init-function (lambda ()
(stumpwm:stumpwm)
(ext:quit))
:executable t :keep-global-handlers t :norc t :documentation "The StumpWM Executable"))
;;; OPENMCL
;; Is there a better way to use asdf.lisp than including it with stumpwm?
#+openmcl
(progn
(require 'asdf)
(load "stumpwm.asd"))
#+openmcl
(progn
(asdf:oos 'asdf:load-op 'stumpwm))
#+openmcl
(progn
(ccl:save-application "stumpwm" :toplevel-function (lambda ()
(stumpwm:stumpwm)
(ccl:quit))))
#-(or sbcl clisp openmcl) (error "This lisp implementation is not supported.")
| 1,613 | Common Lisp | .lisp | 45 | 24.555556 | 135 | 0.520487 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | e21152c2ec6c4279a0b65f68e7f4be13cbeda6a345ce3f102ec862d865d8c498 | 22,382 | [
-1
] |
22,386 | wmii-like-stumpwmrc.lisp | joelagnel_stumpwm/contrib/wmii-like-stumpwmrc.lisp | ;;; -*- Mode: Lisp -*-
;;; Written by Julian Stecklina based on sample-stumpwmrc.lisp.
;;; This is a sample Wmii-like .stumpwmrc file using Super as modifier
;;; (which happens to be the Windows key on my keyboard). It doesn't
;;; cover the whole Wmii command set, but it will ease the transition
;;; to StumpWM for people coming from Wmii.
;;;
;;; The "normal" StumpWM commands are still available with their
;;; default keybindings (see the manual) and you will probably need
;;; them. So go read the manual. :)
(in-package :stumpwm)
;;; A mode line showing all groups in its first and all windows in the
;;; current group in the second line.
(setq *screen-mode-line-format* (format nil "%g~%%W"))
;;; Wmii-like keybindings
(defvar *terminal* "xterm"
"The command used to start a terminal. It should understand the -e
parameter.")
;; Use focus-follows-mouse, like wmii does.
(setq *mouse-focus-policy* :sloppy)
;; Change the prefix key to something else. The default is C-t. Use
;; this to access stumpwm's original keybindings.
;(set-prefix-key (kbd "Menu"))
;;; If you like Meta (most probably alt on your keyboard) more than
;;; Super (which is the Windows key on mine), change 's-' into 'M-'.
(define-key *top-map* (kbd "s-RET") (format nil "exec ~A" *terminal*))
(define-key *top-map* (kbd "s-S-RET") "exec-in-terminal")
(define-key *top-map* (kbd "s-C") "delete")
(define-key *top-map* (kbd "s-p") "exec")
(define-key *top-map* (kbd "s-d") "vsplit")
(define-key *top-map* (kbd "s-D") "hsplit")
(define-key *top-map* (kbd "s-R") "remove")
(define-key *top-map* (kbd "s-SPC") "pull-hidden-next")
;;; s-DIGIT moves or creates to a numbered group.
(loop for i from 1 to 9
do (define-key *top-map* (kbd (format nil "s-~A" i))
(format nil "gselect-or-create ~A" i)))
;;; s-[hjkl] navigate through frames. If you press shift, it will move
;;; the current window in that direction.
(loop for (vi-key name) in '(("k" "up")
("j" "down")
("h" "left")
("l" "right"))
do (let ((key-combo (format nil "s-~A" vi-key))
(shifted-key-combo (format nil "s-~A" (string-upcase vi-key))))
(define-key *top-map* (kbd key-combo)
(format nil "move-focus ~A" name))
(define-key *top-map* (kbd shifted-key-combo)
(format nil "move-window ~A" name))))
(defcommand gselect-or-create (group-number) ((:number "Group number: "))
(gselect
(or (select-group (current-screen) (format nil "~A" group-number) )
(let ((group (add-group (current-screen)
(format nil "unnamed~A" group-number))))
;; number should be free, since select-group failed.
(setf (group-number group) group-number)
group))))
(defcommand exec-in-terminal (cmd) ((:string "Command: "))
(run-shell-command (format nil "~A -e ~A" *terminal* cmd)))
#+sbcl
(defcommand swank-server (port) ((:number "Port: "))
(require :swank)
;; When this is compiled, the SWANK package probably does not
;; exist. So we have to intern the function name at runtime.
(funcall (intern "CREATE-SERVER" "SWANK") :port port :dont-close t))
;; Message window font
(set-font "-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-15")
;;; Define window placement policy...
;; Clear rules
(clear-window-placement-rules)
;;; EOF
| 3,264 | Common Lisp | .lisp | 71 | 43.309859 | 73 | 0.678954 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 77647a6829353f1a16495551afc67e34090ec1e83cdf29f67d7346979b409fa9 | 22,386 | [
-1
] |
22,390 | cpu.lisp | joelagnel_stumpwm/contrib/cpu.lisp | ;;; CPU formatters for the mode-line
;;;
;;; Copyright 2007 Anonymous Coward, Jonathan Moore Liles.
;;;
;;; Maintainer: Julian Stecklina
;;;
;;; This module is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2, or (at your option)
;;; any later version.
;;;
;;; This module is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this software; see the file COPYING. If not, write to
;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;;; Boston, MA 02111-1307 USA
;;;
;;; USAGE:
;;;
;;; Put:
;;;
;;; (load "/path/to/cpu.lisp")
;;;
;;; In your ~/.stumpwmrc
;;;
;;; Then you can use "%c %t" in your mode line format.
;;;
;;; NOTES:
;;;
;;; This is specific to Linux.
(in-package :stumpwm)
(export '(*acpi-thermal-zone*))
;; Install formatters.
(dolist (a '((#\c fmt-cpu-usage)
(#\C fmt-cpu-usage-bar)
(#\f fmt-cpu-freq)
(#\t fmt-cpu-temp)))
(pushnew a *screen-mode-line-formatters* :test 'equal))
;; Defaults arguments for fmt-cpu-usage-bar
(defvar *cpu-usage-bar-width* 10)
(defvar *cpu-usage-bar-full* #\#)
(defvar *cpu-usage-bar-empty* #\:)
(defvar *prev-user-cpu* 0)
(defvar *prev-sys-cpu* 0)
(defvar *prev-idle-cpu* 0)
(defvar *prev-iowait* 0)
(defvar *prev-result* '(0 0 0))
(defvar *prev-time* 0)
;; More or less yanked from the wiki.
(defun current-cpu-usage ()
"Return the average CPU usage since the last call. First value is percent
of CPU in use. Second value is percent of CPU in use by system processes.
Third value is percent of time since last call spent waiting for IO (or 0 if
not available). Don't make calculation more than once a second."
(let ((cpu-result 0)
(sys-result 0)
(io-result nil)
(now (/ (get-internal-real-time) internal-time-units-per-second)))
(when (>= (- now *prev-time*) 1)
(setf *prev-time* now)
(with-open-file (in #P"/proc/stat" :direction :input)
(read in)
(let* ((norm-user (read in))
(nice-user (read in))
(user (+ norm-user nice-user))
(sys (read in))
(idle (read in))
(iowait (or (ignore-errors (read in)) 0))
(step-denom (- (+ user sys idle iowait)
(+ *prev-user-cpu* *prev-sys-cpu* *prev-idle-cpu* *prev-iowait*))))
(setf cpu-result (/ (- (+ user sys)
(+ *prev-user-cpu* *prev-sys-cpu*))
step-denom)
sys-result (/ (- sys *prev-sys-cpu*)
step-denom)
io-result (/ (- iowait *prev-iowait*)
step-denom)
*prev-user-cpu* user
*prev-sys-cpu* sys
*prev-idle-cpu* idle
*prev-iowait* iowait
*prev-result* (list cpu-result sys-result io-result))))))
(apply 'values *prev-result*))
(defun fmt-cpu-usage (ml)
"Returns a string representing current the percent of average CPU
utilization."
(declare (ignore ml))
(let ((cpu (truncate (* 100 (current-cpu-usage)))))
(format nil "CPU: ^[~A~3D%^] " (bar-zone-color cpu) cpu)))
(defun fmt-cpu-usage-bar (ml &optional (width *cpu-usage-bar-width*) (full *cpu-usage-bar-full*) (empty *cpu-usage-bar-empty*))
"Returns a coloured bar-graph representing the current percent of average CPU
utilization."
(declare (ignore ml))
(let ((cpu (truncate (* 100 (current-cpu-usage)))))
(bar cpu width full empty)))
(defun get-proc-file-field (fname field)
(with-open-file (s fname :if-does-not-exist nil) ;
(if s
(do ((line (read-line s nil nil) (read-line s nil nil)))
((null line) nil)
(let ((split (cl-ppcre:split "\\s*:\\s*" line)))
(when (string= (car split) field) (return (cadr split)))))
"")))
(defun fmt-cpu-freq (ml)
"Returns a string representing the current CPU frequency (especially useful for laptop users.)"
(declare (ignore ml))
(let ((mhz (parse-integer (get-proc-file-field "/proc/cpuinfo" "cpu MHz")
:junk-allowed t)))
(if (>= mhz 1000)
(format nil "~,2FGHz" (/ mhz 1000))
(format nil "~DMHz" mhz))))
(defvar *acpi-thermal-zone* (first (last
(pathname-directory
(first
(directory (make-pathname
:directory '(:absolute
"proc" "acpi" "thermal_zone"
:wild))))))))
(defun fmt-cpu-temp (ml)
"Returns a string representing the current CPU temperature."
(declare (ignore ml))
(get-proc-file-field (concatenate 'string "/proc/acpi/thermal_zone/"
*acpi-thermal-zone* "/temperature")
"temperature"))
| 5,118 | Common Lisp | .lisp | 128 | 33.296875 | 127 | 0.603777 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 9cf6c547627a681b03f1d97fb69abfe320f7516c217548c696c8871a8f75fad1 | 22,390 | [
-1
] |
22,395 | battery-portable.lisp | joelagnel_stumpwm/contrib/battery-portable.lisp | ;;; Portable battery information for StumpWM's mode-line.
;;;
;;; Written by Julian Stecklina with inspiration from John Li and
;;; Rupert Swarbrick.
;;;
;;; Copyright (c) 2008 Julian Stecklina
;;;
;;; Permission is hereby granted, free of charge, to any person
;;; obtaining a copy of this software and associated documentation
;;; files (the "Software"), to deal in the Software without
;;; restriction, including without limitation the rights to use, copy,
;;; modify, merge, publish, distribute, sublicense, and/or sell copies
;;; of the Software, and to permit persons to whom the Software is
;;; furnished to do so, subject to the following conditions:
;;;
;;; The above copyright notice and this permission notice shall be
;;; included in all copies or substantial portions of the Software.
;;;
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
;;; DEALINGS IN THE SOFTWARE.
;;;
;;;
;;; To load this module, place
;;;
;;; (load-module "battery-portable")
;;;
;;; in your .stumpwmrc. Battery information is then available via %B
;;; in your mode-line config.
;;;
;;; If you have an older kernel and the above doesn't work, add
;;;
;;; (setf stumpwm.contrib.battery-portable:*prefer-sysfs* nil)
;;;
;;; below the above line.
(defpackage :stumpwm.contrib.battery-portable
(:use :common-lisp :stumpwm :cl-ppcre)
(:export #:*refresh-time*
#:*prefer-sysfs*
))
(in-package :stumpwm.contrib.battery-portable)
;;; CLISP doesn't include :linux in *features* even if it runs on
;;; Linux. :-/
;;; Configuration
(defvar *refresh-time* 5
"Time in seconds between updates of battery information.")
(defvar *prefer-sysfs* t
"Prefer sysfs over procfs for information gathering. This has effect
only on Linux.")
;;; Method base class
(defclass battery-method ()
()
(:documentation "Base class for battery information retrieval"))
(defgeneric all-batteries (method)
(:documentation "Returns all recognized batteries."))
(defun preferred-battery-method ()
#- linux
nil
#+ linux
(if *prefer-sysfs*
(make-instance 'sysfs-method)
(make-instance 'procfs-method)))
;;; Battery class
(defclass battery ()
()
(:documentation "Base class for battery information."))
(defgeneric state-of (battery)
(:documentation "Returns either :UNKNOWN, :CHARGED, :CHARGING,
or :DISCHARGING with the obvious meanings. If the state is
not :UNKNOWN, returns the battery fill percentage. If the state
is :CHARGING or :DISCHARGING, this function returns a third value
indicating the corresponding time in seconds."))
;;; Linux procfs implementation
#+ linux
(progn
(defclass procfs-method (battery-method)
()
(:documentation "Collect battery information through Linux' procfs interface."))
(defclass procfs-battery (battery)
((path :initarg :path :initform (error ":path missing")
:reader path-of)
(info-hash :initform (make-hash-table :test 'equal)
:reader info-hash-of)))
(defmethod update-info ((battery procfs-battery))
(clrhash (info-hash-of battery))
(loop
for filename in '("state" "info")
do (with-open-file (file (merge-pathnames (make-pathname :name filename)
(path-of battery)))
(loop
for line = (read-line file nil nil)
while line
do (multiple-value-bind (match? matches)
(scan-to-strings "^([^:]+):\\s*([^\\s]+)(\\s.*)?$" line)
(if (not match?)
(format t "Unrecognized line: ~S~%" line)
(setf (gethash (aref matches 0) (info-hash-of battery))
(aref matches 1))))))))
(define-condition info-value-not-present (error)
())
(defmethod info-value ((battery procfs-battery) key)
(multiple-value-bind (val found?)
(gethash key (info-hash-of battery))
(if found?
val
(error 'info-value-not-present))))
(defmethod info-value-int ((battery procfs-battery) key)
(values (parse-integer (info-value battery key))))
(defmethod all-batteries ((method procfs-method))
(mapcar (lambda (p)
(make-instance 'procfs-battery :path p))
(directory (make-pathname
:directory '(:absolute "proc" "acpi" "battery" :wild)))))
(defmethod state-of ((battery procfs-battery))
(handler-case
(progn
(update-info battery)
(if (string/= (info-value battery "present") "yes")
:unknown
(let* ((state (info-value battery "charging state")))
(flet ((percent ()
(/ (info-value-int battery "remaining capacity")
(info-value-int battery "last full capacity"))))
(cond
((string= state "charged") (values :charged (percent)))
((string= state "discharging")
(values :discharging (percent)
(* 3600 (/ (info-value-int battery "remaining capacity")
(info-value-int battery "present rate")))))
((string= state "charging")
(values :charging (percent)
(* 3600 (/ (- (info-value-int battery "last full capacity")
(info-value-int battery "remaining capacity"))
(info-value-int battery "present rate")))))
(t :unknown))))))
(t () :unknown))))
;;; Linux sysfs implementation
#+ linux
(progn
(defclass sysfs-method (battery-method)
()
(:documentation "Collect battery information through Linux'
class-based sysfs interface."))
(defclass sysfs-battery (battery)
((path :initarg :path :initform (error ":path missing")
:reader path-of)))
(defun sysfs-field (path name)
(with-open-file (file (merge-pathnames (make-pathname :name name)
path))
(read-line-from-sysfs file)))
(defun sysfs-int-field (path name)
(parse-integer (sysfs-field path name) :junk-allowed t))
(defmethod all-batteries ((m sysfs-method))
(remove nil
(mapcar (lambda (path)
(handler-case
(when (string= "Battery"
(sysfs-field path "type"))
(make-instance 'sysfs-battery
:path path))
(file-error () nil)))
(directory
(make-pathname :directory '(:absolute "sys" "class" "power_supply" :wild))))))
(defmethod state-of ((battery sysfs-battery))
(handler-case
(let ((path (path-of battery)))
(if (string= (sysfs-field path "present") "0")
:unknown
(let* ((state (sysfs-field path "status"))
(consumption (sysfs-int-field path "current_now"))
(curr (sysfs-int-field path "energy_now"))
(full (sysfs-int-field path "energy_full"))
(percent (* 100 (/ curr full))))
(cond
((string= state "Full") (values :charged percent))
((string= state "Discharging")
(values :discharging percent
(if (zerop consumption)
0
(* 3600 (/ curr consumption)))))
((string= state "Charging")
(values :charging percent
(if (zerop consumption)
0
(* 3600 (/ (- full curr) consumption)))))
(t :unknown)))))
(t () :unknown))))
;;; Interface to the outside world.
(defun fmt-time (stream arg colonp atp)
(declare (ignore colonp atp))
(multiple-value-bind (hours rest)
(truncate arg 3600)
(format stream "~D:~2,'0D" hours (floor rest 60))))
(defun battery-info-string ()
"Compiles a string suitable for StumpWM's mode-line."
(with-output-to-string (fmt)
(let ((batteries (all-batteries (or (preferred-battery-method)
(return-from battery-info-string
"(not implemented)")))))
(if (endp batteries)
(format fmt "(no battery)")
(loop
for bat in batteries
do (multiple-value-bind (state perc time)
(state-of bat)
(ecase state
(:unknown (format fmt "(no info)"))
(:charged (format fmt "~~ ~D%" (round perc)))
((:charging :discharging)
(format fmt "~/stumpwm.contrib.battery-portable::fmt-time/~A ^[~A~D%^]"
time
(if (eq state :charging) #\+ #\-)
(bar-zone-color perc 90 50 20 t)
(round perc))))))))))
;;; The actual mode-line format function. A bit ugly...
(let ((next 0)
(last-value ""))
(defun fmt-bat (ml)
(declare (ignore ml))
;; Return the last info again, if we are called too quickly.
(let ((now (get-universal-time)))
(when (< now next)
(return-from fmt-bat last-value))
(setf next (+ now *refresh-time*)))
;; Generate info string.
(setf last-value (battery-info-string))))
;;; Put this at the end to avoid evaluating it when the core above
;;; throws an error.
(add-screen-mode-line-formatter #\B #'fmt-bat)
;;; EOF
| 10,157 | Common Lisp | .lisp | 235 | 32.982979 | 99 | 0.575316 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 7207ff0da2038dc7b9a0dd5f97cf695d88bede4e3f3ddd72ea529c7d846de822 | 22,395 | [
-1
] |
22,396 | wifi.lisp | joelagnel_stumpwm/contrib/wifi.lisp | ;;; Wifi formatter for the mode-line
;;;
;;; Copyright 2008 John Li
;;;
;;; Maintainer: John Li
;;;
;;; This module is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2, or (at your option)
;;; any later version.
;;;
;;; This module is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this software; see the file COPYING. If not, write to
;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;;; Boston, MA 02111-1307 USA
;;;
;;; WARNING:
;;;
;;; This triggers a yet to be discovered bug in SBCL, which causes
;;; stumpwm to freeze.
;;; USAGE:
;;;
;;; Place the following in your ~/.stumpwmrc file:
;;;
;;; (load-module "wifi")
;;;
;;; Then you can use "%I" in your mode line format (both "w" and "W"
;;; were taken. Think _I_EEE 802.11 :-)).
;;;
;;; Notes: This gets information through sysfs, so it only works on
;;; Linux with a mounted sysfs.
(defpackage :stumpwm.contrib.wifi
(:use :common-lisp :stumpwm )
(:export #:*iwconfig-path*
#:*wireless-device*))
(in-package :stumpwm.contrib.wifi)
(defvar *iwconfig-path* "/sbin/iwconfig"
"Location if iwconfig, defaults to /sbin/iwconfig.")
(defvar *wireless-device* nil
"Set to the name of the wireless device you want to monitor. If set
to NIL, try to guess.")
(defmacro defun-cached (name interval arglist &body body)
"Creates a function that does simple caching. The body must be
written in a functional style - the value returned is set as the
prev-val."
(let ((prev-time (gensym "PREV-TIME"))
(prev-val (gensym "PREV-VAL"))
(now (gensym "NOW"))
(docstring (when (stringp (car body))
(pop body))))
`(let ((,prev-time 0)
(,prev-val nil))
(defun ,name ,arglist
;; if no docstring, return nothing (not even nil)
,@(when docstring (list docstring))
(let ((,now (get-internal-real-time)))
(when (>= (- ,now ,prev-time)
(* ,interval internal-time-units-per-second))
(setf ,prev-time ,now)
(setf ,prev-val (locally ,@body)))
,prev-val)))))
(defun guess-wireless-device ()
(or (loop
for path in (directory (make-pathname :directory '(:absolute "sys" "class" "net" :wild)))
thereis (let ((device-name (car (last (pathname-directory path)))))
(if (probe-file (merge-pathnames (make-pathname :directory '(:relative "wireless"))
path))
device-name
nil)))
(error "No wireless device found.")))
(defun read-wifi-info (device what)
(let ((path (make-pathname :directory `(:absolute "sys" "class" "net" ,device "wireless"))))
(with-open-file (in (merge-pathnames (make-pathname :name what)
path))
(read-line-from-sysfs in))))
(defun read-wifi-info-int (device what)
(parse-integer (read-wifi-info device what)))
(defun-cached fmt-wifi 5 (ml)
"Formatter for wifi status. Displays the ESSID of the access point
you're connected to as well as the signal strength. When no valid data
is found, just displays nil."
(declare (ignore ml))
(handler-case
(let* ((device (or *wireless-device* (guess-wireless-device)))
(essid (multiple-value-bind (match? sub)
(cl-ppcre:scan-to-strings "ESSID:\"(.*)\""
(run-shell-command (format nil "~A ~A 2>/dev/null"
*iwconfig-path*
device)
t))
(if match?
(aref sub 0)
(return-from fmt-wifi "no link")))))
(let* ((qual (read-wifi-info-int device "link")))
(format nil "~A ^[~A~D%^]"
essid (bar-zone-color qual 40 30 15 t) qual)))
(t (c) (format nil "Error ~A" c))))
;;; Add mode-line formatter
(add-screen-mode-line-formatter #\I #'fmt-wifi)
;;; EOF
| 4,567 | Common Lisp | .lisp | 105 | 34.533333 | 102 | 0.581835 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 329623b1fd11cd9f11af0ad77d188426793e5c122819a1908e78c5904976cf48 | 22,396 | [
-1
] |
22,397 | stumpwm.asd | joelagnel_stumpwm/stumpwm.asd | ;;; -*- Mode: Lisp -*-
(defpackage :stumpwm-system
(:use :cl :asdf))
(in-package :stumpwm-system)
;; This is a hack for debian because it calls cmucl's clx
;; cmucl-clx. *very* annoying. I don't actually know if debian still
;; does this.
#+cmu (progn
(ignore-errors (require :cmucl-clx))
(ignore-errors (require :clx)))
(defsystem :stumpwm
:name "StumpWM"
:author "Shawn Betts <[email protected]>"
:version "CVS"
:maintainer "Shawn Betts <[email protected]>"
;; :license "GNU General Public License"
:description "A tiling, keyboard driven window manager"
:serial t
:depends-on (:cl-ppcre #-(or cmu clisp) :clx #+sbcl :sb-posix)
:components ((:file "package")
(:file "primitives")
(:file "workarounds")
(:file "wrappers")
(:file "keysyms")
(:file "keytrans")
(:file "kmap")
(:file "input")
(:file "core")
(:file "command")
(:file "menu")
(:file "screen")
(:file "group")
(:file "window")
(:file "floating-group")
(:file "tile-group")
(:file "tile-window")
(:file "window-placement")
(:file "message-window")
(:file "selection")
(:file "user")
(:file "iresize")
(:file "bindings")
(:file "events")
(:file "help")
(:file "fdump")
(:file "time")
(:file "mode-line")
(:file "mode-line-cubes")
(:file "color")
(:file "module")
(:file "stumpwm")
;; keep this last so it always gets recompiled if
;; anything changes
(:file "version")))
| 1,760 | Common Lisp | .asd | 54 | 23.648148 | 68 | 0.518801 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 15e8a92ee206c7841f69543fc4aa75daf087ad5acd652acc627fb4b19cc17f3f | 22,397 | [
-1
] |
22,414 | Makefile.in | joelagnel_stumpwm/Makefile.in | LISP=@LISP_PROGRAM@
clisp_BUILDOPTS=-K full -on-error exit ./make-image.lisp
sbcl_BUILDOPTS=--load ./make-image.lisp
openmcl_BUILDOPTS=--load ./make-image.lisp
clisp_INFOOPTS=-K full -on-error exit -x "(load \"asdf.lisp\") (load \"stumpwm.asd\") (load \"@PPCRE_PATH@/cl-ppcre.asd\") (asdf:operate 'asdf:load-op :stumpwm) (load (compile-file \"manual.lisp\")) (stumpwm::generate-manual) (ext:exit)"
sbcl_INFOOPTS=--eval "(progn (require 'asdf) (require 'stumpwm) (load \"manual.lisp\"))" --eval "(progn (stumpwm::generate-manual) (sb-ext:quit))"
openmcl_INFOOPTS=--eval "(require 'asdf) (require 'stumpwm) (load (compile-file \"manual.lisp\")) (stumpwm::generate-manual) (quit)"
datarootdir = @datarootdir@
prefix=@prefix@
exec_prefix= @exec_prefix@
bindir=@bindir@
infodir=@infodir@
# You shouldn't have to edit past this
# This is copied from the .asd file. It'd be nice to have the list in
# one place, but oh well.
FILES=package.lisp primitives.lisp wrappers.lisp keysyms.lisp \
keytrans.lisp kmap.lisp input.lisp core.lisp command.lisp menu.lisp \
screen.lisp group.lisp window.lisp floating-group.lisp \
tile-window.lisp window-placement.lisp message-window.lisp \
selection.lisp user.lisp iresize.lisp bindings.lisp events.lisp \
help.lisp fdump.lisp mode-line.lisp mode-line-cubes.lisp time.lisp \
color.lisp module.lisp stumpwm.lisp version.lisp
all: stumpwm stumpwm.info
stumpwm.info: stumpwm.texi
makeinfo stumpwm.texi
# FIXME: This rule is too hardcoded
stumpwm.texi: stumpwm.texi.in
$(LISP) $(@LISP@_INFOOPTS)
stumpwm: $(FILES)
$(LISP) $(@LISP@_BUILDOPTS)
release:
git tag -a -m "version @PACKAGE_VERSION@" @PACKAGE_VERSION@
git-archive --format=tar --prefix=stumpwm-@PACKAGE_VERSION@/ HEAD > stumpwm-@[email protected]
tar xf stumpwm-@[email protected]
cd stumpwm-@PACKAGE_VERSION@ && tar zxf @PPCRE_PATH@/../cl-ppcre.tar.gz && mv cl-ppcre-* cl-ppcre
git log > stumpwm-@PACKAGE_VERSION@/ChangeLog
cp configure stumpwm-@PACKAGE_VERSION@/
tar zcf stumpwm-@[email protected] stumpwm-@PACKAGE_VERSION@
rm -fr stumpwm-@PACKAGE_VERSION@/ stumpwm-@[email protected]
upload-release:
gpg -b stumpwm-@[email protected]
scp stumpwm-@[email protected] stumpwm-@[email protected] [email protected]:/releases/stumpwm/
( echo rm stumpwm-latest.tgz.sig && echo rm stumpwm-latest.tgz && echo ln stumpwm-@[email protected] stumpwm-latest.tgz && echo ln stumpwm-@[email protected] stumpwm-latest.tgz.sig ) | sftp -b - [email protected]:/releases/stumpwm/
clean:
rm -f *.fasl *.fas *.lib *.*fsl stumpwm stumpwm.texi stumpwm.info
install: stumpwm.info stumpwm
test -z "$(destdir)$(bindir)" || mkdir -p "$(destdir)$(bindir)"
install -m 755 stumpwm "$(destdir)$(bindir)"
test -z "$(destdir)$(infodir)" || mkdir -p "$(destdir)$(infodir)"
install -m 644 stumpwm.info "$(destdir)$(infodir)"
install-info --info-dir="$(destdir)$(infodir)" "$(destdir)$(infodir)/stumpwm.info"
uninstall:
rm "$(destdir)$(bindir)/stumpwm"
install-info --info-dir="$(destdir)$(infodir)" --remove "$(destdir)$(infodir)/stumpwm.info"
rm "$(destdir)$(infodir)/stumpwm.info"
# End of file
| 3,148 | Common Lisp | .l | 56 | 54.517857 | 249 | 0.737407 | joelagnel/stumpwm | 2 | 1 | 0 | GPL-2.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | fc0020a696704b6618b670c7df3ed603db9ab573e818b62e3f00f88aad75642b | 22,414 | [
-1
] |
22,456 | like-that-generator.lisp | rheaplex_like-that-generator/like-that-generator.lisp | #!/usr/bin/sbcl
;; like-that-generator.lisp - Script to make Like That's works programatically.
;; Copyright (C) 2008 Rob Myers [email protected]
;;
;; This file is part of Like That.
;;
;; Like That is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; Like That is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Configuration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defparameter *project-root-name* "processing-projects/"
"The name of the project root folder.")
(defparameter *project-root*
(merge-pathnames (pathname *project-root-name*))
"The folder to create for storing processing projects in.")
(defparameter *source-root*
(merge-pathnames (pathname "source/"))
"The folder to copy .pde files from.")
(defparameter *resource-root* (pathname "resources/")
"The folder to copy image (etc.) files from.")
(defparameter *media-folder* (pathname "data/")
"The folder to copy image (etc.) files to.")
(defparameter *test-root*
(merge-pathnames (pathname "test/"))
"The folder to copy .pde files into to test them.")
(defparameter *base-file*
(namestring (merge-pathnames (pathname "like_that_base.pde") *source-root*))
"The basic code file. All-in-one.")
(defparameter *appearances* nil
"Colours and other appearances for forms.")
(defparameter *forms* nil
"Shapes, polygons and polyhedra for animation.")
(defparameter *form-resources* '()
"The list of required media, if any, for each form strategy.")
(defparameter *animations* nil
"The animation strategies.")
(defparameter *sequences* nil
"The sequence strategies.")
(defparameter *clashes* nil
"Combinations that are technically or aesthetically bad.")
(defparameter *works* '(("ghosts" white cube burst3d sequential)
("seance" white cube cluster3d sequential)
("subjects" white square burst2d sequential)
("logistics" white square cluster2d sequential)
("sometimes" white circle burst2d sequential)
("moments" white circle cluster2d sequential)
("aesthetics" black cube burst3d sequential)
("market" black cube cluster3d sequential)
("empire" black square burst2d sequential)
("cliques" black square cluster2d sequential)
("epidemic" black circle burst2d sequential)
("cool" black circle cluster2d sequential)
("citizens" polychrome cube burst3d sequential)
("come_together" polychrome cube cluster3d sequential)
("fashion" polychrome square burst2d sequential)
("opinions" polychrome square cluster2d sequential)
("scene" polychrome circle burst2d sequential)
("show" polychrome circle cluster2d sequential)
("architecture" neoplastic cube burst3d sequential)
("society" neoplastic cube cluster3d sequential)
("systems" neoplastic square burst2d sequential)
("design" neoplastic square cluster2d sequential)
("transgression" neoplastic circle burst2d sequential)
("normativity" neoplastic circle cluster2d sequential)
("laws" outline square burst2d sequential)
("obligations" outline square cluster2d sequential)
("crime" outline circle burst2d sequential)
("dissent" outline circle cluster2d sequential)
("monopoly" transparentBlack cube burst3d sequential)
("ideology" transparentBlack cube cluster3d sequential)
("uniform" transparentBlack square burst2d sequential)
("customs" transparentBlack square cluster2d sequential)
("philosophy" transparentBlack circle burst2d
sequential)
("happening" transparentBlack circle cluster2d
sequential)
("structure" transparentPolychrome cube burst3d
sequential)
("psychogeography" transparentPolychrome cube cluster3d
sequential)
("objects" transparentPolychrome square burst2d
sequential)
("commodities" transparentPolychrome square cluster2d
sequential)
("eventual" transparentPolychrome circle burst2d
sequential)
("happenstance" transparentPolychrome circle cluster2d
sequential)
("congress" flesh cube burst3d sequential)
("dance" flesh cube cluster3d sequential)
("mufti" flesh square burst2d sequential)
("party" flesh square cluster2d sequential)
("relational" flesh circle burst2d sequential)
("gossip" flesh circle cluster2d sequential))
"Names for works.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Utilitites
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun copy-file-into-stream (input-file-path output-stream)
"Open the input file and copy it into the output stream."
(with-open-file (input-stream input-file-path)
(let ((buf (make-array 4096
:element-type (stream-element-type input-stream))))
(loop for pos = (read-sequence buf input-stream)
while (plusp pos)
do (write-sequence buf output-stream :end pos)))))
(defun copy-file (from to)
"Copy the files, specified as absolute file paths."
(with-open-file (to-stream to :direction :output
:if-does-not-exist :create :if-exists :overwrite)
(copy-file-into-stream from to-stream)))
(defun directory-pde-names (directory-path)
"List any file names that end with .pde in the directory, stripping the .pde"
(let ((directory-files (directory (merge-pathnames directory-path
(pathname "/*.pde")))))
(mapcar #'pathname-name
directory-files)))
(defun first-line-of-file (file-path)
"Open the file and get its first line as a string."
(with-open-file (in file-path)
(read-line in)))
(defun first-line-of-file-after-comment (file-path)
"Open the file, assume it starts with '// ', get the rest of the line."
(subseq (first-line-of-file file-path) 3))
(defun read-first-line-of-file-after-comment (file-path)
"Parse the first line of the file after '// ' as a Lisp expression."
(read-from-string (first-line-of-file-after-comment file-path)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Work specification properties
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun source-pde (kind name)
"Make a pathname of the form ./sources/kind/.pde"
(merge-pathnames (format nil "~a/~a.pde" kind name)
*source-root*))
(defun spec-name (spec)
"Get or generate the name for the work specification"
(or (dolist (work *works*)
(when (equal spec (cdr work))
(return (car work))))
(format nil "~a_~a_~a_~a"
(first spec) (second spec) (third spec) (fourth spec))))
(defun spec-appearance (spec)
(first spec))
(defun spec-appearance-file (spec)
(namestring (merge-pathnames (source-pde "appearance" (spec-appearance spec))
*source-root*)))
(defun spec-form (spec)
(second spec))
(defun spec-form-file (spec)
(namestring (merge-pathnames (source-pde "form" (spec-form spec))
*source-root*)))
(defun spec-animation (spec)
(third spec))
(defun spec-animation-file (spec)
(namestring (merge-pathnames (source-pde "animation" (spec-animation spec))
*source-root*)))
(defun spec-sequence (spec)
(fourth spec))
(defun spec-sequence-file (spec)
(namestring (merge-pathnames (source-pde "sequence" (spec-sequence spec))
*source-root*)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Checks
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun validate-work-specifications ()
"Make sure we haven't misspelt a strategy or specified an unimplemented one."
(dolist (work *works*)
;; TODO: Check for repeated work titles
(assert (member (spec-appearance work) *appearances*))
(assert (member (spec-form work) *forms*))
(assert (member (spec-animation work) *animations*))
(assert (member (spec-sequence work) *sequences*))))
(defun generate-all-possible-work-specifications ()
"Generate every possible combination of appearance, form, and sequence."
(let ((all '()))
(dolist (appearance *appearances*)
(dolist (form *forms*)
(dolist (animation *animations*)
(dolist (sequence *sequences*)
(push (list appearance form animation sequence)
all)))))
all))
(defun expand-clashes ()
"List pairs of clashes between the first and other items of each clash list."
(let ((expanded '()))
(dolist (clashlist *clashes*)
(dolist (clashee (cdr clashlist))
(push (cons (car clashlist) clashee)
expanded)))
expanded))
(defun clash-p (candidate clash-pair)
"Does the candidate work spec list contain both cells of the pair of clashes?"
(and (member (car clash-pair) candidate :test #'string-equal)
(member (cdr clash-pair) candidate :test #'string-equal)))
(defun clashes-p (candidate clashes)
"Does the candidate work spec list contain any of the pairs of clashes?"
(let ((result nil))
(dolist (clash clashes)
(when (clash-p candidate clash)
(setf result t)
(return)))
result))
(defun possible-work-specifications-without-clashes ()
"Generate the list of possible work specs without clashes."
(let ((possible-works (generate-all-possible-work-specifications))
(clashes (expand-clashes))
(results '()))
(dolist (work possible-works)
(unless (clashes-p work clashes)
(push work results)))
results))
(defun print-unnamed-work-specifications ()
"Print any possible work specs that aren't in the list of named works."
(format t "Un-named possible combinations:~%")
(let ((possible (possible-work-specifications-without-clashes)))
(dolist (work *works*)
(setf possible (remove (cdr work) possible :test #'equal)))
(dolist (unused possible)
(format t " ~a~%" unused))))
(defun sanity-check ()
"Make sure that the script has the correct environment and resources to run."
;; Make sure we are next to the folders we need
(assert (probe-file *source-root*)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Work project creation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun copy-work-resources (work project-folder)
"If the work needs any resources, make the media folder and copy them in."
(let ((work-resources (assoc (spec-form work) *form-resources*)))
(when work-resources
(let ((work-media-folder (merge-pathnames (pathname "media/")
project-folder)))
(ensure-directories-exist work-media-folder)
(dolist (resource work-resources)
(copy-file (merge-pathnames resource *resource-root*)
work-media-folder))))))
(defun project-folder-path (work)
"Make a path string for the work's folder within the projects folder."
(namestring (merge-pathnames (concatenate 'string
(spec-name work)
"/")
*project-root*)))
(defun project-main-pde-path (work)
(namestring (merge-pathnames (format nil "~a.pde" (spec-name work))
(project-folder-path work))))
(defun generate-processing-project (work)
"Make the project folder for the work and copy in the files it needs."
(let ((project-folder (project-folder-path work)))
(ensure-directories-exist project-folder)
(format t "~a~%" (project-main-pde-path work))
(with-open-file (pde (project-main-pde-path work)
:direction :output
:if-does-not-exist :create
:if-exists :overwrite)
(copy-file-into-stream *base-file* pde)
(copy-file-into-stream (spec-appearance-file work) pde)
(copy-file-into-stream (spec-form-file work) pde)
(copy-file-into-stream (spec-animation-file work) pde)
(copy-file-into-stream (spec-sequence-file work) pde))
(copy-work-resources work project-folder)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Test project creation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun test-folder-path (name)
"Make a path string for the work's folder within the test folder."
(namestring (merge-pathnames (concatenate 'string
name
"/")
*test-root*)))
(defun test-pde-path (name)
"Make a path to the named pde in its forlder in the test directory."
(namestring (merge-pathnames (format nil "~a.pde" name)
(test-folder-path name))))
(defun generate-test-project (kind name)
"Make the project folder for the work and copy in the files it needs."
(let ((project-folder (test-folder-path name)))
(ensure-directories-exist project-folder)
(with-open-file (pde (test-pde-path name)
:direction :output
:if-does-not-exist :create
:if-exists :overwrite)
;; (copy-file-into-stream *base-file* pde)
(copy-file-into-stream (merge-pathnames (format nil "~a/~a.pde" kind name)
*source-root*) pde))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Project building
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun build-processing-project (file-path)
"Build the project using our command-line hack of processing."
;; See http://dev.processing.org/bugs/show_bug.cgi?id=219
;; and be prepared to cope with changes since then
;; This code is currently sbcl-only
(let ((output (process-output (sb-ext:run-program
"./processing/build/linux/work/processing"
(list file-path)
:output :stream
:error :output))))
(loop (let ((line (read-line output nil 'eof)))
(when (eq line 'eof)
(return))
(when (search "applet" line)
(format t "~a~%" line))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Main program structure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun backup-existing-projects-folder ()
"If there's an existing projects folder, move it aside."
(when (probe-file *project-root*)
(rename-file *project-root*
(merge-pathnames (format nil
"projects-backup.~a"
(get-universal-time))))))
(defun populate-pde-lists ()
(setf *animations*
(directory-pde-names (merge-pathnames (pathname "animation/")
*source-root*)))
(setf *appearances*
(directory-pde-names (merge-pathnames (pathname "appearance/")
*source-root*)))
(setf *forms*
(directory-pde-names (merge-pathnames (pathname "form/")
*source-root* )))
(setf *sequences*
(directory-pde-names (merge-pathnames (pathname "sequence/")
*source-root* ))))
(defun read-form-clashes ()
"Get the list of pdes that each form clashes with."
(dolist (form *forms*)
(let ((first-line
(read-first-line-of-file-after-comment
(merge-pathnames (format nil "form/~a.pde" form)
*source-root*))))
(when (eq (car first-line) :clashes)
(push (cons form (cdr first-line))
*clashes*)))))
(defun test-source-file-kinds (kind names)
(dolist (name names)
(format t "Test building: ~a~%" name)
(generate-test-project kind name)
(build-processing-project (test-pde-path name))))
(defun test-source-files ()
(ensure-directories-exist *test-root*)
(test-source-file-kinds "animation" *animations*)
(test-source-file-kinds "appearance" *appearances*)
(test-source-file-kinds "form" *forms*)
(test-source-file-kinds "sequence" *sequences*))
(defun make-processing-projects ()
"Make the projects folder then make a project for each work."
(ensure-directories-exist *project-root*)
(let* ((works-to-make (possible-work-specifications-without-clashes))
(total (length works-to-make))
(count 0))
(dolist (work works-to-make)
(incf count)
(format t "Making: ~d/~d: ~a~%" count total(spec-name work))
(generate-processing-project work)
(build-processing-project (project-main-pde-path work)))))
(defun write-index ()
(format t "Writing html index of works.~%")
(with-open-file (index (merge-pathnames (pathname "index.html"))
:direction :output
:if-does-not-exist :create
:if-exists :overwrite)
(format index "<html><head><title>Like That</title></head><body>")
(dolist (project (possible-work-specifications-without-clashes))
(format index "<p><a href=\"./processing-projects/~a/applet/index.html\">~a</a></p>"
(spec-name project) (spec-name project)))
(format index "</body></html>")))
(defun make-works ()
"The main entry point for the script."
(sanity-check)
(backup-existing-projects-folder)
(populate-pde-lists)
(read-form-clashes)
(print-unnamed-work-specifications)
;;(test-source-files)
(make-processing-projects)
(write-index))
;; Run the script.
;; (make-works) | 17,228 | Common Lisp | .lisp | 391 | 39.930946 | 90 | 0.655652 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | ec180159b3a58e7c48caf5f15bb4dfc9fdde9b12aa00d6692a909fe01e50ea6d | 22,456 | [
-1
] |
22,458 | circle_triangle_square.pde | rheaplex_like-that-generator/source/form/circle_triangle_square.pde | // (:clashes "outline" "burst_3d" "cluster_3d" "grow_3d")
String MODE = P3D;
int KIND_COUNT = 3;
class Form
{
float size;
float x;
float y;
int kind;
Form ()
{
kind = int (random (KIND_COUNT));
}
void draw ()
{
switch (kind)
{
case 0:
ellipseMode (CENTER);
ellipse (x, y, size, size);
break;
case 1:
rectMode (CENTER);
rect (x, y, size, size);
break;
case 2:
// Triangle
float halfSize = size / 2.0;
beginShape ();
vertex (-halfSize, halfSize);
vertex (0.0, -halfSize);
vertex (halfSize, halfSize);
endShape ();
break;
}
}
}
| 684 | Common Lisp | .cl | 37 | 13.189189 | 57 | 0.530421 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 4dc03f30107c14571388555e47dc36f9ede734ce0825b35e66e5bc5356524411 | 22,458 | [
-1
] |
22,459 | circle.pde | rheaplex_like-that-generator/source/form/circle.pde | // (:clashes "outline" "burst_3d" "cluster_3d" "grow_3d")
String MODE = P3D;
class Form
{
float size;
float x;
float y;
Form ()
{
}
void draw ()
{
ellipseMode (CENTER);
ellipse (x, y, size, size);
}
} | 219 | Common Lisp | .cl | 16 | 11.5625 | 57 | 0.625 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | a7621e04193e23ff3ebdaaf78566d3c5467bb8332aa051499834d85525f09b29 | 22,459 | [
-1
] |
22,475 | cluster_3d.pde | rheaplex_like-that-generator/source/animation/cluster_3d.pde | class Animation
{
float x;
float y;
float z;
float size;
float start_shrinking;
float stop_shrinking;
float shrink_factor;
float start_growing;
float stop_growing;
float grow_factor;
Animation (float xx, float yy, float zz, float siz,
float start_grow, float stop_grow,
float start_shrink, float stop_shrink)
{
x = xx;
y = yy;
z = zz;
size = siz;
start_growing = start_grow;
stop_growing = stop_grow;
start_shrinking = start_shrink;
stop_shrinking = stop_shrink;
grow_factor = 1.0 / (stop_grow - start_grow);
shrink_factor = 1.0 / (stop_shrink - start_shrink);
}
float scaleFactor (float t)
{
if (t > stop_shrinking)
{
return 0;
}
else if (t > start_shrinking)
{
return 1.0 - ((t - start_shrinking) * shrink_factor);
}
else if (t > stop_growing)
{
return 1.0;
}
else if (t > start_growing)
{
return (t - start_growing) * grow_factor;
}
// So <= start_growing
return 0.0;
}
void apply (Form form, float t)
{
float scale_factor = scaleFactor (t);
if (scale_factor == 0)
{
return;
}
form.size = size * scale_factor;
float side_length = size * scale_factor;
if (side_length > size)
{
side_length = size;
}
form.x = x * (1.0 / (scale_factor + 0.00001));
form.y = y * (1.0 / (scale_factor + 0.00001));
form.z = z * (1.0 / (scale_factor + 0.00001));
}
boolean finished (float t)
{
return t > stop_shrinking;
}
}
| 1,584 | Common Lisp | .l | 70 | 17.657143 | 59 | 0.586971 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 8844529cd2803aa3cc71e23f40c8a355720ad396a17ca3edcdae9823b770dda0 | 22,475 | [
-1
] |
22,476 | cluster_2d.pde | rheaplex_like-that-generator/source/animation/cluster_2d.pde | class Animation
{
float x;
float y;
float size;
float start_shrinking;
float stop_shrinking;
float shrink_factor;
float start_growing;
float stop_growing;
float grow_factor;
Animation (float xx, float yy, float zz, float siz,
float start_grow, float stop_grow,
float start_shrink, float stop_shrink)
{
x = xx;
y = yy;
// We ignore z...
size = siz;
start_growing = start_grow;
stop_growing = stop_grow;
start_shrinking = start_shrink;
stop_shrinking = stop_shrink;
grow_factor = 1.0 / (stop_grow - start_grow);
shrink_factor = 1.0 / (stop_shrink - start_shrink);
}
float scaleFactor (float t)
{
if (t > stop_shrinking)
{
return 0;
}
else if (t > start_shrinking)
{
return 1.0 - ((t - start_shrinking) * shrink_factor);
}
else if (t > stop_growing)
{
return 1.0;
}
else if (t > start_growing)
{
return (t - start_growing) * grow_factor;
}
// So <= start_growing
return 0.0;
}
void apply (Form form, float t)
{
float scale_factor = scaleFactor (t);
if (scale_factor == 0)
{
return;
}
form.size = size * scale_factor;
float side_length = size * scale_factor;
if (side_length > size)
{
side_length = size;
}
form.x = x * (1.0 / (scale_factor + 0.00001));
form.y = y * (1.0 / (scale_factor + 0.00001));
}
boolean finished (float t)
{
return t > stop_shrinking;
}
}
| 1,516 | Common Lisp | .l | 68 | 17.529412 | 59 | 0.596208 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 45f09506effc3178fcd84523f2aaac02234eca0721211a43dbcea3f11dbca637 | 22,476 | [
-1
] |
22,477 | sequential.pde | rheaplex_like-that-generator/source/sequence/sequential.pde | // Configuration constants
int min_objects = 4;
int max_objects = 24;
// In pixels
int canvas_width = 400;
int canvas_height = 400;
int min_object_x = -100;
int max_object_x = 100;
int min_object_y = -100;
int max_object_y = 100;
float min_object_start_t = 0.0;
float max_object_start_t = 0.5;
int min_object_size = 5;
int max_object_size = 200;
// In seconds
float min_duration = 1.0;
float max_duration = 10.0;
int num_objects;
Entity[] entities;
float rotation;
float end_of_current_sequence;
float RandomDuration ()
{
return random (min_duration, max_duration) * 1000;
}
void GenObjects ()
{
rotation = random (PI / 2.0);
num_objects = (int)random(min_objects, max_objects);
entities = new Entity[num_objects];
float start_growing = millis ();
float growing_range = RandomDuration ();
float stop_growing = start_growing + growing_range;
float start_shrinking = stop_growing + RandomDuration ();
float shrinking_range = RandomDuration ();
float stop_shrinking = start_shrinking + shrinking_range;
end_of_current_sequence = stop_shrinking;
for (int i = 0; i < num_objects; i++)
{
float t_factor = random (min_object_start_t, max_object_start_t);
entities[i] = new Entity (
new Appearance (),
new Form (),
new Animation (
random (min_object_x, max_object_x),
random (min_object_y, max_object_y),
0.0, //random (min_object_z, max_object_z),
random (min_object_size, max_object_size),
start_growing + (growing_range * t_factor),
stop_growing,
start_shrinking,
start_shrinking + (shrinking_range * t_factor)));
}
}
void DrawObjects ()
{
float now = millis ();
if (now >= end_of_current_sequence)
{
GenObjects ();
}
for (int i = 0; i < num_objects; i++)
{
if (! entities[i].finished (now))
entities[i].draw (now);
}
}
void draw ()
{
background(255);
if (MODE != P3D)
{
smooth ();
}
if ((MODE == P3D) || MODE == (OPENGL))
{
ambientLight (245, 245, 245);
directionalLight (50, 50, 50, 0, 1, -1);
translate (canvas_width / 2.0, canvas_height / 2.0,
- (max (canvas_width, canvas_height) * 0.4));
}
else
{
translate (canvas_width / 2.0, canvas_height / 2.0);
}
noStroke ();
DrawObjects ();
}
void setup ()
{
size(canvas_width, canvas_height, MODE);
frameRate(30);
GenObjects ();
}
| 2,380 | Common Lisp | .l | 94 | 22.117021 | 66 | 0.656042 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 91513fb5669a3d4a3bfb68891793dc2c22c5956f47cc0c526125cff9dc778c82 | 22,477 | [
-1
] |
22,478 | flat_black.pde | rheaplex_like-that-generator/source/appearance/flat_black.pde | class Appearance
{
void draw (Form f)
{
fill (0);
f.draw ();
}
}
| 72 | Common Lisp | .l | 8 | 7.125 | 19 | 0.59375 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 5c1ca58696eed26d10f63b3ab68dbd2b2b21a7dd1b68ae3753e1b190565e51ea | 22,478 | [
-1
] |
22,479 | transparent_black.pde | rheaplex_like-that-generator/source/appearance/transparent_black.pde | class Appearance
{
void draw (Form f)
{
fill (0, 0, 0, 245);
f.draw ();
}
}
| 83 | Common Lisp | .l | 8 | 8.5 | 22 | 0.573333 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | d21b45fe33fb498534b7459e7946088943195fbcb4c81307c5f1fc582c046e36 | 22,479 | [
-1
] |
22,480 | flesh.pde | rheaplex_like-that-generator/source/appearance/flesh.pde | class Appearance
{
void draw (Form f)
{
//fill (255, 180, 175, 200);
//fill (250, 160, 145, 200);
//fill (255, 201, 188, 200);
fill (250, 230, 210, 200);
f.draw ();
}
}
| 182 | Common Lisp | .l | 11 | 14.363636 | 30 | 0.567251 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 1a6c727b710e56fe639f13825ac0d05a912d67695552d4867e1cc3f4add25852 | 22,480 | [
-1
] |
22,481 | outline.pde | rheaplex_like-that-generator/source/appearance/outline.pde | class Appearance
{
void draw (Form f)
{
noFill ();
stroke (0);
strokeWeight (2.0);
f.draw ();
}
}
| 109 | Common Lisp | .l | 10 | 8.8 | 21 | 0.606061 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 0fdf18d6e67a5889222c4506142faae384cf580788a4efb4d4529f557ce3d522 | 22,481 | [
-1
] |
22,482 | flat_white.pde | rheaplex_like-that-generator/source/appearance/flat_white.pde | class Appearance
{
Appearance ()
{}
void draw (Form f)
{
fill (255);
f.draw ();
}
}
| 95 | Common Lisp | .l | 10 | 7.4 | 19 | 0.595238 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 9dc88cebb29b09608c1f3b9e2dd2cb87145b9fd4418cfece14a21ed4e8bfa2f9 | 22,482 | [
-1
] |
22,483 | polychrome.pde | rheaplex_like-that-generator/source/appearance/polychrome.pde | class Appearance
{
color col;
Appearance ()
{
col = color (random (255), random (255), random (255));
}
void draw (Form f)
{
fill (col);
f.draw ();
}
}
| 168 | Common Lisp | .l | 13 | 10.692308 | 57 | 0.607843 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | 4c4c952db3af615b842a9e91cc1c4d321d03cc23d550721e059ffa516f9ed9b6 | 22,483 | [
-1
] |
22,484 | transparent_polychrome.pde | rheaplex_like-that-generator/source/appearance/transparent_polychrome.pde | class Appearance
{
color col;
Appearance ()
{
col = color (random (255), random (255), random (255), 128);
}
void draw (Form f)
{
fill (col);
f.draw ();
}
}
| 173 | Common Lisp | .l | 13 | 11.076923 | 62 | 0.607595 | rheaplex/like-that-generator | 2 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:28:00 AM (Europe/Amsterdam) | e69287be42f00e3fef8221358da0357e85e554b79fc1adfb6eac045346e2097c | 22,484 | [
-1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.