-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
453 lines (411 loc) · 34.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
<!--
For editing this page, use backticks and the following RegEx to quickly create links to sections with information about a class or function:
replace: `(?<word>[a-zA-Z]+)`
by: <a href="#$1" class="mke-member">$1</a>
This will replace - for example - `TreeNode` by <a href="#TreeNode" class="mke-member">TreeNode</a>.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>MathKeyboardEngine Documentation v0.1 (Python)</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="../../docs.css"></link>
</head>
<body>
<h1>Documentation v0.1 (Python)</h1>
<div class="warning">
This is documenation of version 0.1. Go to the <strong><a href="https://mathkeyboardengine.github.io/docs/python/latest">latest version</a></strong>.<br/>
Links from this page to declarations lead to an <a href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/tree/v0.1">older version of the repository on branch "v0.1"</a>.<br/>
Other links - for example for searching occurrences - lead to the new repository.
</div>
<p>This page shows all <strong>MathKeyboardEngine for Python</strong> classes and functions that you can directly use.
Helper functions that are not avaible from the root namespace of the library, are not mentioned.
This documentation is not exhaustive.
Use <span class="repo-link">View declaration</span> to see the class or function declaration and
use <span class="repo-link">Search occurrences</span> for finding all occurrences in unit tests
and other parts of the <a target="_blank" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python">GitHub repository</a>.
</p>
<p>Before diving into this documentation:
<ul>
<li>Read the <a target="_blank" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python#readme">repository readme</a>.</li>
<li>Play with one of the <a target="_blank" href="https://mathkeyboardengine.github.io/">live examples</a>.</li>
<li>Have a look at the <a target="_blank" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/tree/main/examples">source code</a> of a Python example.</li>
</ul>
</p>
<h2>1. Basics</h2>
<h3><span id="KeyboardMemory">KeyboardMemory</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/KeyboardMemory.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=KeyboardMemory">Search occurrences</a>
</div>
<p>If you type into a 'math textbox', you use a <a href="#KeyboardMemory" class="mke-member">KeyboardMemory</a> instance for that textbox. The <a href="#KeyboardMemory" class="mke-member">KeyboardMemory</a> class will hold the syntax tree of what you've typed and what the <code>current</code> position is of the cursor. If you'd like to have multiple math textboxes on one page, then use multple instances of the <a href="#KeyboardMemory" class="mke-member">KeyboardMemory</a> class, each linked to a single 'textbox'.</p>
<h3><span id="LatexConfiguration">LatexConfiguration</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/LatexConfiguration.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=LatexConfiguration">Search occurrences</a>
</div>
<p>In the <a href="#LatexConfiguration" class="mke-member">LatexConfiguration</a> class, the cursor is called the "active placeholder".
You can choose the shape and color of the active placeholder ('cursor') and also of all other <a href="#Placeholder" class="mke-member">Placeholder</a>s that are empty but that are not the current position of your 'cursor'.
</p>
<p>You can also choose how to highlight a selection - for example via a background color. (See <a href="#select_left" class="mke-member">select_left</a>.)</p>
<h3>
<span id="get_edit_mode_latex">get_edit_mode_latex</span>
and
<span id="get_view_mode_latex">get_view_mode_latex</span>
</h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/get_latex/get_edit_mode_latex.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=get_edit_mode_latex">Search occurrences</a>
<br />
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/get_latex/get_view_mode_latex.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=get_view_mode_latex">Search occurrences</a>
</div>
<p>
Calling <a href="#get_edit_mode_latex" class="mke-member">get_edit_mode_latex</a> outputs the LaTeX for display in a 'math textbox'. It will also contain the cursor (called the "active placeholder" in <a href="#LatexConfiguration" class="mke-member">LatexConfiguration</a>).<br/>
If you use MathKeyboardEngine for a course in which the typed answers of students need to be checked, you'll probably also want to use <a href="#get_view_mode_latex" class="mke-member">get_view_mode_latex</a>, which outputs the LaTeX without cursor.
</p>
<h2>2. Syntax tree components</h2>
<h3><span id="Placeholder">Placeholder</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/Placeholder/Placeholder.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=Placeholder">Search occurrences</a>
</div>
<p>A <a href="#Placeholder" class="mke-member">Placeholder</a> can be empty or it can contain <a href="#TreeNode" class="mke-member">TreeNode</a>s. If you type <kbd>a</kbd>, <kbd>+</kbd> and <kbd>1</kbd>, then the syntax tree consists of one <a href="#Placeholder" class="mke-member">Placeholder</a> (<a href="#KeyboardMemory" class="mke-member">KeyboardMemory</a>'s <code>syntax_tree_root</code>) and three <a href="#TreeNode" class="mke-member">TreeNode</a>s:<br />
<div class="drawing-Placeholder">
<div class="drawing-TreeNode">
a
</div>
<div class="drawing-TreeNode">
+
</div>
<div class="drawing-TreeNode">
1
</div>
</div>
<h3><span id="TreeNode">TreeNode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/base/TreeNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=TreeNode">Search occurrences</a>
</div>
<p>A <a href="#TreeNode" class="mke-member">TreeNode</a> can be as simple as '3', which is called a <a href="#LeafNode" class="mke-member">LeafNode</a> (it has no <a href="#Placeholder" class="mke-member">Placeholder</a>s). A fraction has two <a href="#Placeholder" class="mke-member">Placeholder</a>s: the numerator and the denominator. If a <a href="#TreeNode" class="mke-member">TreeNode</a> has <i>one or multiple</i> <a href="#Placeholder" class="mke-member">Placeholder</a>s, it is called a <a href="#BranchingNode" class="mke-member">BranchingNode</a>.</p>
<h3><span id="LeafNode">LeafNode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/base/LeafNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=LeafNode">Search occurrences</a>
</div>
<p>The base class for all <a href="#TreeNode" class="mke-member">TreeNode</a>s that have no <a href="#Placeholder" class="mke-member">Placeholder</a>s. You'll probably not use this class directly in your code, unless you would like to create your own SyntaxTree-manipulating functions.</p>
<p>A single <a href="#LeafNode" class="mke-member">LeafNode</a> - not nested in the <a href="#KeyboardMemory" class="mke-member">KeyboardMemory</a>'s <code>syntax_tree_root</code>:</p>
<div class="drawing-TreeNode">
y
</div>
<h3><span id="StandardLeafNode">StandardLeafNode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/LeafNodes/StandardLeafNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=StandardLeafNode">Search occurrences</a>
</div>
<p>The <a href="#StandardLeafNode" class="mke-member">StandardLeafNode</a> should be used for everything that has no <a href="#Placeholder" class="mke-member">Placeholder</a>, except if it is part of a number with digits (such as 12.75, for which you should use <a href="#DigitNode" class="mke-member">DigitNode</a>s and the <a href="#DecimalSeparatorNode" class="mke-member">DecimalSeparatorNode</a>). So, use this for variables x, y, z, for arrows, and more.</p>
<h3><span id="DigitNode">DigitNode</span> and <span id="DecimalSeparatorNode">DecimalSeparatorNode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/LeafNodes/DigitNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=DigitNode">Search occurrences</a>
<br />
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/LeafNodes/DecimalSeparatorNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=DecimalSeparatorNode">Search occurrences</a>
</div>
<p>Use the <a href="#DigitNode" class="mke-member">DigitNode</a> for composing a number with 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (and maybe other symbols if you like to type not in base 10, but in - for example - base 12) and the <a href="#DecimalSeparatorNode" class="mke-member">DecimalSeparatorNode</a> for its decimal separator ('.' or ',' in some cultures).<br />
The <a href="#DigitNode" class="mke-member">DigitNode</a> and <a href="#DecimalSeparatorNode" class="mke-member">DecimalSeparatorNode</a> are treated specially by some functions. For example, <a href="#insert_with_encapsulate_current" class="mke-member">insert_with_encapsulate_current</a> treats '12.75' as a single 'thing' instead of 5 separate <a href="#TreeNode" class="mke-member">TreeNode</a>s, so that if you insert a fraction after typing a number, it moves the whole number to the numerator of the fraction.</p>
<h3><span id="BranchingNode">BranchingNode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/base/BranchingNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=BranchingNode">Search occurrences</a>
</div>
<p>The base class for all <a href="#TreeNode" class="mke-member">TreeNode</a>s that have <i>one or multiple</i> <a href="#Placeholder" class="mke-member">Placeholder</a>s. You'll probably not use this class directly in your code, unless you would like to create your own SyntaxTree-manipulating functions.</p>
<p>A single-placeholder <a href="#BranchingNode" class="mke-member">BranchingNode</a> that contains a <a href="#LeafNode" class="mke-member">LeafNode</a>:</p>
<div class="drawing-TreeNode">
\sqrt{
<div class="drawing-Placeholder">
<div class="drawing-TreeNode">
2
</div>
</div>
}
</div>
<p>A multi-placeholder <a href="#BranchingNode" class="mke-member">BranchingNode</a> of which the first <a href="#Placeholder" class="mke-member">Placeholder</a> contains two <a href="#LeafNode" class="mke-member">LeafNode</a>s and the second <a href="#Placeholder" class="mke-member">Placeholder</a> is empty:</p>
<div class="drawing-TreeNode">
\frac{
<div class="drawing-Placeholder">
<div class="drawing-TreeNode">
2
</div>
<div class="drawing-TreeNode">
x
</div>
</div>
}{
<div class="drawing-Placeholder">
</div>
}
</div>
<p>A single-placeholder <a href="#BranchingNode" class="mke-member">BranchingNode</a> that contains two <a href="#LeafNode" class="mke-member">LeafNode</a>s and one multi-placeholder <a href="#BranchingNode" class="mke-member">BranchingNode</a>:</p>
<div class="drawing-TreeNode">
\sqrt{
<div class="drawing-Placeholder">
<div class="drawing-TreeNode">
1
</div>
<div class="drawing-TreeNode">
+
</div>
<div class="drawing-TreeNode">
\frac{
<div class="drawing-Placeholder">
</div>
}{
<div class="drawing-Placeholder">
</div>
}
</div>
</div>
}
</div>
<h3><span id="StandardBranchingNode">StandardBranchingNode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/BranchingNodes/StandardBranchingNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=StandardBranchingNode">Search occurrences</a>
</div>
<p>The <a href="#StandardBranchingNode" class="mke-member">StandardBranchingNode</a> is a <a href="#BranchingNode" class="mke-member">BranchingNode</a> with <i>one or multiple</i> <a href="#Placeholder" class="mke-member">Placeholder</a>s. The number of <a href="#Placeholder" class="mke-member">Placeholder</a>s that is created, depends on the number of constructor arguments as follows:<br />
<code>number of placeholders = number of constructor arguments - 1</code><br />
Use <a href="#StandardBranchingNode" class="mke-member">StandardBranchingNode</a> for all single-placeholder <a href="#BranchingNode" class="mke-member">BranchingNode</a>s, except for a pair of round brackets (then use the <a href="#RoundBracketsNode" class="mke-member">RoundBracketsNode</a>).<br />
<p>
Examples:
<ul>
<li>Square root: <code>StandardBranchingNode(r'\sqrt{', '}')</code></li>
<li>Power with a fixed exponent: <code>StandardBranchingNode('', '^2')</code></li>
</ul>
</p>
Note: the <a href="#StandardBranchingNode" class="mke-member">StandardBranchingNode</a> does not have pre-configured up/down navigation, so for most multi-placeholder <a href="#BranchingNode" class="mke-member">BranchingNode</a>s, you'd probably want to use <a href="#AscendingBranchingNode" class="mke-member">AscendingBranchingNode</a> or <a href="#DescendingBranchingNode" class="mke-member">DescendingBranchingNode</a>.<br /></p>
<h3><span id="AscendingBranchingNode">AscendingBranchingNode</span> and <span id="DescendingBranchingNode">DescendingBranchingNode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/BranchingNodes/AscendingBranchingNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=AscendingBranchingNode">Search occurrences</a>
<br />
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/BranchingNodes/DescendingBranchingNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=DescendingBranchingNode">Search occurrences</a>
</div>
<p>The <a href="#AscendingBranchingNode" class="mke-member">AscendingBranchingNode</a> and <a href="#DescendingBranchingNode" class="mke-member">DescendingBranchingNode</a> both extend the <a href="#StandardBranchingNode" class="mke-member">StandardBranchingNode</a>, but also have ready-to-use up/down navigation.</p>
<p>
When "reading" a power from left to right, you first read its base and then its exponent, which is slightly higher. So, you're reading from left to right and "upwards" or in an "ascending" manner. The <a href="#AscendingBranchingNode" class="mke-member">AscendingBranchingNode</a> provides ready-to-use up/down navigation, where <a href="#move_right" class="mke-member">move_right</a> is equal to <a href="#move_up" class="mke-member">move_up</a> (unless your cursor is in the last <a href="#Placeholder" class="mke-member">Placeholder</a>).<br />
For fractions, subscripts, etc. that are read "downwards", the <a href="#DescendingBranchingNode" class="mke-member">DescendingBranchingNode</a> provides ready-to-use up/down navigation.
</p>
<p>Examples:
<ul>
<li>Power: <code>AscendingBranchingNode('', '^{', '}')</code></li>
<li>Fraction: <code>DescendingBranchingNode(r'\frac{', '}{', '}')</code></li>
</ul>
</p>
<h3><span id="RoundBracketsNode">RoundBracketsNode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/BranchingNodes/RoundBracketsNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=RoundBracketsNode">Search occurrences</a>
</div>
<p>
Instead of using two <a href="#StandardLeafNode" class="mke-member">StandardLeafNode</a>s or one single-placeholder <a href="#StandardBranchingNode" class="mke-member">StandardBranchingNode</a> for two brackets, you probably want to use the <a href="#RoundBracketsNode" class="mke-member">RoundBracketsNode</a>, because some functions treat it specially.<br />
Especially when typing with the physical keyboard, the need for special treatment arises: when typing <kbd>(</kbd> <kbd>1</kbd> <kbd>+</kbd> <kbd>x</kbd> <kbd>)</kbd> <kbd>/</kbd> <kbd>x</kbd> you probably want <code>\frac{1+x}{x}</code> as output - so, without brackets.<br />
A trick to do this, is: let pressing <kbd>(</kbd> result in <a href="#insert" class="mke-member">insert</a>ing the <a href="#RoundBracketsNode" class="mke-member">RoundBracketsNode</a>, let pressing <kbd>)</kbd> result in a <a href="#move_right" class="mke-member">move_right</a> and let pressing <kbd>/</kbd> result in <a href="#insert_with_encapsulate_current" class="mke-member">insert_with_encapsulate_current</a> (with the argument <code>delete_outer_round_brackets_if_any = True</code>) for a fraction node (as <a href="#DescendingBranchingNode" class="mke-member">DescendingBranchingNode</a>).
</p>
<h3><span id="MatrixNode">MatrixNode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/syntax_tree_components/nodes/BranchingNodes/MatrixNode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=MatrixNode">Search occurrences</a>
</div>
<p>
The <a href="#MatrixNode" class="mke-member">MatrixNode</a> has ready-to-use left/right/up/down navigation.<br />
The first constructor argument is the type of matrix, for example "pmatrix" for a matrix with round brackets on the left and right. Search the documentation of your typesetting library (for example KaTeX or MathJax) for other matrix types.
</p>
<h2>3. Adding to KeyboardMemory</h2>
<p>Whether you're using MathKeyboardEngine with virtual keys, physical keys or both, you'll need to add nodes to a <a href="#KeyboardMemory" class="mke-member">KeyboardMemory</a> instance via one of the four insert functions.</p>
<h3><span id="insert">insert</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/insertion/insert.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=insert">Search occurrences</a>
</div>
<p>You could use only this function and skip the other insert functions, but users "expect" certain behaviour - for example at "2 to the power of 10":<br />
not:<br />
<pre>
<code>insert(k, AscendingBranchingNode('', '^{', '}'))</code>
<code>insert(k, DigitNode('2'))</code>
<code>move_right(k)</code>
<code>insert(k, DigitNode('1'))</code>
<code>insert(k, DigitNode('0'))</code>
</pre>
but:
<pre>
<code>insert(k, DigitNode('2'))</code>
<code>insert_with_encapsulate_current(k, AscendingBranchingNode('', '^{', '}'))</code>
<code>insert(k, DigitNode('1'))</code>
<code>insert(k, DigitNode('0'))</code>
</pre>
Both result in the (view_mode_)latex <code>2^{10}</code>.
</p>
<h3><span id="insert_with_encapsulate_current">insert_with_encapsulate_current</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/insertion/insert_with_encapsulate_current.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=insert_with_encapsulate_current">Search occurrences</a>
</div>
<p>See the explanation at <a href="#insert" class="mke-member">insert</a>.</p>
<h3><span id="insert_with_encapsulate_selection">insert_with_encapsulate_selection</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/insertion/insert_with_encapsulate_selection.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=insert_with_encapsulate_selection">Search occurrences</a>
</div>
<p>Let's say you've typed 1 + x and you then* decide that this should become the numerator of a fraction. In that case, you can use <a href="#select_left" class="mke-member">select_left</a> and call <a href="#insert_with_encapsulate_selection" class="mke-member">insert_with_encapsulate_selection</a> to insert a "fraction node".</p>
<p>*There are multiple ways to do this more efficiently.</p>
<h3><span id="insert_with_encapsulate_selection_and_previous">insert_with_encapsulate_selection_and_previous</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/insertion/insert_with_encapsulate_selection_and_previous.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=insert_with_encapsulate_selection_and_previous">Search occurrences</a>
</div>
<p>Let's say you wanted to type "2 to the power of 10", but you type "210". Now you can (enter "selection mode" and) use <a href="#select_left" class="mke-member">select_left</a> twice, followed by <a href="#insert_with_encapsulate_selection_and_previous" class="mke-member">insert_with_encapsulate_selection_and_previous</a> to get what you intended to get.</p>
<h2>4. Deleting from KeyboardMemory</h2>
<h3><span id="delete_current">delete_current</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/deletion/delete_current.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=delete_current">Search occurrences</a>
</div>
<p>A backwards delete, with special behaviour (depending on the position of the cursor) for <a href="#BranchingNode" class="mke-member">BranchingNode</a>s.</p>
<h3><span id="delete_selection">delete_selection</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/deletion/delete_selection.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=delete_selection">Search occurrences</a>
</div>
<p>To be used together with - for example - <a href="#select_left" class="mke-member">select_left</a>. Very probably, users will use <a href="#delete_current" class="mke-member">delete_current</a> multiple times instead. But if you're in selection and the delete key is pressed, this function provides the expected behaviour.</p>
<h2>5. Navigation</h2>
<h3><span id="move_left">move_left</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/navigation/move_left.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=move_left">Search occurrences</a>
</div>
<p>Moves the cursor to the left.</p>
<h3><span id="move_right">move_right</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/navigation/move_right.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=move_right">Search occurrences</a>
</div>
<p>Moves the cursor to the right.</p>
<h3><span id="move_down">move_down</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/navigation/move_down.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=move_down">Search occurrences</a>
</div>
<p>The <a href="#MatrixNode" class="mke-member">MatrixNode</a>, <a href="#AscendingBranchingNode" class="mke-member">AscendingBranchingNode</a> and <a href="#DescendingBranchingNode" class="mke-member">DescendingBranchingNode</a> implement <a href="#BranchingNode" class="mke-member">BranchingNode</a>'s <code>get_move_down_suggestion </code> and therefore support moving the cursor down. You can also extend the <a href="#BranchingNode" class="mke-member">BranchingNode</a> class to support other up/down-navigation patterns.</p>
<h3><span id="move_up">move_up</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/navigation/move_up.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=move_up">Search occurrences</a>
</div>
<p>The <a href="#MatrixNode" class="mke-member">MatrixNode</a>, <a href="#AscendingBranchingNode" class="mke-member">AscendingBranchingNode</a> and <a href="#DescendingBranchingNode" class="mke-member">DescendingBranchingNode</a> implement <a href="#BranchingNode" class="mke-member">BranchingNode</a>'s <code>get_move_up_suggestion </code>, and therefore support moving the cursor up. You can also extend the <a href="#BranchingNode" class="mke-member">BranchingNode</a> class to support other up/down-navigation patterns.</p>
<h2>6. Selection mode</h2>
<p>Several functions to be used together with - for example - <a href="#insert_with_encapsulate_selection" class="mke-member">insert_with_encapsulate_selection</a>, <a href="#insert_with_encapsulate_selection_and_previous" class="mke-member">insert_with_encapsulate_selection_and_previous</a> or <a href="#delete_selection" class="mke-member">delete_selection</a>.<br />
Of course you can decide not to use any of the "Selection" functions if you don't need the functionality.</p>
<h3><span id="select_left">select_left</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/selection/select_left.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=select_left">Search occurrences</a>
</div>
<p>Do or undo a (highlighted) selection of parts of what you've typed. Set your preferred highlighting color in the <a href="#LatexConfiguration" class="mke-member">LatexConfiguration</a>.</p>
<h3><span id="select_right">select_right</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/selection/select_right.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=select_right">Search occurrences</a>
</div>
<p>Do or undo a (highlighted) selection of parts of what you've typed. Set your preferred highlighting color in the <a href="#LatexConfiguration" class="mke-member">LatexConfiguration</a>.</p>
<h3><span id="enter_selection_mode">enter_selection_mode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/selection/enter_selection_mode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=enter_selection_mode">Search occurrences</a>
</div>
<p>
To make your virtual math keyboard culture-independent, you may want to have a "enter selection mode" key that has no text, but has the same background color as the highlighting color as configured via the <a href="#LatexConfiguration" class="mke-member">LatexConfiguration</a>'s <code>selection_hightlight_start</code> and <code>selection_hightlight_end</code>.<br />
Note that the command for coloring may differ per typesetting library - for example KaTeX uses a <code>colorbox</code> and MathJax uses a <code>bbox</code>.
</p>
<h3><span id="leave_selection_mode">leave_selection_mode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/selection/leave_selection_mode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=leave_selection_mode">Search occurrences</a>
</div>
<p>
Forgetting to call <a href="#leave_selection_mode" class="mke-member">leave_selection_mode</a> may lead to weird behaviour... for example at <a href="#insert" class="mke-member">insert</a>ing a <a href="#TreeNode" class="mke-member">TreeNode</a> while still being in selection mode.
</p>
<h3><span id="in_selection_mode">in_selection_mode</span></h3>
<div class="external-links">
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/blob/v0.1/src/keyboard_engine/functions/selection/in_selection_mode.py">View declaration</a>
<a target="_blank" class="repo-link" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python/search?q=in_selection_mode">Search occurrences</a>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div class="center">If you've found an error on this page, please <a target="_blank" href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.github.io/blob/main/docs/python/0.1/index.html">report it or open a pull request</a>.</div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div id="footer-note">
<hr/>
See the <a href="https://github.com/MathKeyboardEngine/MathKeyboardEngine.Python#readme">MathKeyboardEngine GitHub repository</a> for more information.
</div>
</body>
</html>