Skip to content

Commit d5aa63d

Browse files
MartinRykforsMartin Rykfors
and
Martin Rykfors
authored
Improve relative / ordinal diagram in the docs (#1277)
## Checklist - [x] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [x] I have not broken the cheatsheet - [x] I have tested building the docs Replace the hand-written diagram of relative / ordinal modifiers with one generated by LaTeX / tikz. If it is necessary in the future to change this image, you can reuse and modify the below latex code to regenerate it. ``` \documentclass[tikz]{standalone} \usepackage{tikz} \usetikzlibrary{decorations.pathreplacing,calligraphy} % to convert pdf -> png: % convert -density 300 relative-ordinal.pdf -quality 100 -background white -alpha remove relative_ordinal.png \begin{document} \def\spacing{1.4cm} \newcommand{\ibrace}[4]{ \draw [decorate, decoration = {brace, amplitude=5pt}] (#2*\spacing, #1*0.8cm + 0.5cm) -- (#3*\spacing, #1*0.8cm + 0.5cm) node[above=5pt, pos=0.5, scale=0.8] {\texttt{"#4"}}; } \newcommand{\bbrace}[4]{ \draw [decorate, decoration = {brace, amplitude=5pt}] (#2*\spacing, #1*0.8cm + 0.5cm) -- (#3*\spacing, #1*0.8cm + 0.5cm) node[above=-20pt, pos=0.5, scale=0.8] {#4}; } \newcommand{\funk}[3]{ \draw[fill=black] (#1*\spacing,0) circle (0.1cm) node[below=#2, text width=1cm,align=left,scale=0.7] (F#1) {\texttt{"#3"}}; } \begin{tikzpicture}[ultra thick] \funk{0}{0pt}{first funk} \funk{1}{0pt}{second funk} \funk{2}{0pt}{third previous funk} \funk{3}{0pt}{second previous funk} \funk{4}{0pt}{previous funk} \funk{5}{0pt}{funk} \funk{6}{0pt}{next funk} \funk{7}{0pt}{second next funk} \funk{8}{0pt}{third next funk} \funk{9}{0pt}{second last funk} \funk{10}{0pt}{last funk} \draw[latex-] (F5) -- +(0,-0.8cm) node[below=2pt,scale=0.8] {input target}; \ibrace{0}{6}{8}{next three funks}; \ibrace{0}{2}{4}{previous three funks}; \ibrace{1}{5}{7}{three funks}; \ibrace{2}{3}{5}{three funks backward}; \ibrace{0}{0}{1}{first two funks}; \ibrace{0}{9}{10}{last two funks}; \bbrace{-3}{10}{0}{iteration scope}; \end{tikzpicture} \end{document} ``` --------- Co-authored-by: Martin Rykfors <[email protected]>
1 parent 96e06e7 commit d5aa63d

File tree

4 files changed

+106
-2
lines changed

4 files changed

+106
-2
lines changed

docs/user/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,11 @@ For example, `"take funk blue air"` selects the function containing the token wi
182182

183183
We support several modifiers that allow you to refer to scopes relative to the input target, or relative to the canonical iteration scope of the scope type. For example, the iteration scope of functions is a class, of tokens is a line, of characters is a token, etc.
184184

185-
Here is a diagram of the possible relative / ordinal modifiers:
185+
Here is a diagram of the possible relative / ordinal modifiers using the `funk` scope as an example:
186186

187-
![Relative ordinal diagram](images/relative-ordinal.jpeg)
187+
![Relative ordinal diagram](images/relative_ordinal.png)
188+
189+
([Image source](https://github.com/cursorless-dev/cursorless/blob/main/docs/user/images/relative_ordinal.tex))
188190

189191
And here is a table of the spoken forms:
190192

-493 KB
Binary file not shown.

docs/user/images/relative_ordinal.png

77.3 KB
Loading

docs/user/images/relative_ordinal.tex

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
\documentclass[varwidth=28cm]{standalone}
2+
\usepackage{tikz}
3+
\usetikzlibrary{decorations.pathreplacing,calligraphy}
4+
\usepackage{caption}
5+
\usepackage{subcaption}
6+
7+
% To build:
8+
% pdflatex relative_ordinal.tex
9+
% To auto build on save:
10+
% latexmk -pdf -pvc -halt-on-error relative_ordinal.tex
11+
% To build png:
12+
% convert -density 200 relative_ordinal.pdf -quality 100 -background white -alpha remove relative_ordinal.png
13+
14+
\def\vspacing{1.0cm}
15+
\def\hspacing{0.4cm}
16+
\def\overshoot{0.4cm}
17+
\def\offset{1.2cm}
18+
19+
\newcommand{\abrace}[5][0.5]{
20+
\draw [decorate, decoration = {calligraphic brace, amplitude=5pt, aspect=#1}, very thick]
21+
(#2*\hspacing + \offset, -#3*\vspacing+\overshoot) -- (#2*\hspacing + \offset, -#4*\vspacing-\overshoot)
22+
node[right=5pt, pos=#1] {#5};
23+
}
24+
25+
\newcommand{\funk}[3][black]{
26+
\node[left=1cm,align=right] at (0,-#2*\vspacing) {\texttt{#3}};
27+
\node[align=left] at (0,-#2*\vspacing) [scale=0.8,text=#1,fill=#1!5!white]
28+
{\texttt{def fun():} \\ \texttt{\quad \quad...}};
29+
}
30+
31+
\newcommand{\elide}[1]{
32+
\node[minimum height=0.5cm,scale=1.5] at (0,-#1*\vspacing) {\texttt{...}};
33+
}
34+
35+
\begin{document}
36+
\begin{figure}
37+
% \centering
38+
\begin{subfigure}[t]{.37\linewidth}
39+
\begin{tikzpicture}
40+
\elide{1}
41+
\funk{2}{"third previous funk"}
42+
\funk{3}{"second previous funk"}
43+
\funk{4}{"previous funk"}
44+
\funk[red]{5}{}
45+
\funk{6}{"next funk"}
46+
\funk{7}{"second next funk"}
47+
\funk{8}{"third next funk"}
48+
\elide{9}
49+
\abrace{0}{6}{8}{\texttt{"next three funks"}};
50+
\abrace{0}{2}{4}{\texttt{"previous three funks"}};
51+
\end{tikzpicture}
52+
% \caption{Relative exclusive modifiers}
53+
\end{subfigure}
54+
\begin{subfigure}[t]{.28\linewidth}
55+
\begin{tikzpicture}
56+
\elide{1}
57+
\funk{2}{}
58+
\funk{3}{}
59+
\funk{4}{}
60+
\funk[red]{5}{"funk"}
61+
\funk{6}{}
62+
\funk{7}{}
63+
\funk{8}{}
64+
\elide{9}
65+
\abrace{0}{5}{7}{\texttt{"three funks"}};
66+
\abrace{1}{3}{5}{\texttt{"three funks backward"}};
67+
\end{tikzpicture}
68+
% \caption{Relative inclusive modifiers}
69+
\end{subfigure}
70+
\begin{subfigure}[t]{.3\linewidth}
71+
\begin{tikzpicture}
72+
\funk{1}{"first funk"}
73+
\funk{2}{"second funk"}
74+
\funk{3}{}
75+
\elide{4}
76+
\funk[red]{5}{}
77+
\elide{6}
78+
\funk{7}{}
79+
\funk{8}{"second last funk"}
80+
\funk{9}{"last funk"}
81+
\abrace{0}{7}{9}{\texttt{"last three funks"}};
82+
\abrace{0}{1}{2}{\texttt{"first two funks"}};
83+
\end{tikzpicture}
84+
% \caption{Absolute modifiers}
85+
\end{subfigure}
86+
\\
87+
\begin{subfigure}[t]{\linewidth}
88+
\begin{tikzpicture}
89+
\funk[red]{0}{}
90+
\node[align=left,right=0.8cm] at (0,0) {= function containing input target};
91+
\end{tikzpicture}
92+
\end{subfigure}
93+
\\
94+
\begin{subfigure}[t]{\linewidth}
95+
\begin{tikzpicture}
96+
\funk{0}{}
97+
\node[align=left,right=0.8cm] at (0,0) {= function within iteration scope of input target};
98+
\end{tikzpicture}
99+
\end{subfigure}
100+
101+
\end{figure}
102+
\end{document}

0 commit comments

Comments
 (0)