-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcodedit_selection.html
266 lines (259 loc) · 9.69 KB
/
codedit_selection.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title> codedit_selection - text selection </title>
<script src="jquery.js"></script>
<script src="jquery-cookie.js"></script>
<script src="jquery-tablesorter.js"></script>
<script src="strftime.js"></script>
<script src="mustache.js"></script>
<script src="config.js"></script>
<script src="main.js"></script>
<link rel="stylesheet" type="text/css" href="templates/reset.css" />
<link rel="stylesheet" type="text/css" href="templates/hack.css" />
<link rel="stylesheet" type="text/css" id="lights_css" />
<script>
var DOCNAME = 'codedit_selection'
var PROJECT = 'codedit'
//set the lights before rendering starts
set_lights()
</script>
</head>
<body>
<header>
<div class="container">
<div class="btn-container btn-lights-container">
<a href="#" class="btn btn-lights" id="lights">lights</a>
</div>
<div class="btn-container btn-home-container">
<a href="/" class="btn btn-home">luapower</a>
</div>
<table id="header_table">
<tr>
<td style="vertical-align: middle;" width="100%">
<h1> codedit_selection </h1>
<h2> text selection </h2>
</td>
<td style="vertical-align: middle;" align="right" style="height: 150px">
<table><tr><td>
<div class="doc" id="package_info_container">
<div id="package_info"> </div>
<div id="commit_log"> </div>
</div>
<a href="https://github.com/luapower/codedit" class="btn btn-rightside btn-github"><span class="icon"></span>View on GitHub</a>
</td></tr><tr><td>
<a href="https://github.com/luapower/codedit/tarball/master" class="btn btn-rightside">Download as .tar.gz</a>
</td></tr><tr><td>
<a href="https://github.com/luapower/codedit/zipball/master" class="btn btn-rightside">Download as .zip</a>
</td></tr></table>
</td>
</tr>
</table>
<div class="btn-container btn-discuss-container">
<a href="https://github.com/luapower/codedit/issues/new" target="_blank"
class="btn btn-rightside btn-discuss"><span class="icon"></span>Discuss</a>
</div>
</div>
</header>
<div class="bg-container">
<div class="bg-center-container">
<div class="bg bg-codedit" style="background-image: url('bg/codedit.png');"></div>
</div>
</div>
<div class="under-header">
<div class="container">
<div id="toc_container" class="toc_container doc"></div>
<button id=tab1_button class="tab_button hidden">Documentation</button>
<button id=tab2_button class="tab_button hidden">Package Info</button>
<div id="tabs_cointainer">
<div id="tab1_container">
<section class="doc">
<span id="module_info"></span>
<h2 id="local-selection-requirecodedit_selection"><code>local selection = require'codedit_selection'</code></h2>
<p>Selecting contiguous text between two char positions, (line1, col1, line2, col2), where:</p>
<ul>
<li>(line1, col1) is the first selected char</li>
<li>(line2, col2) is the char immediately after the last selected char.</li>
</ul>
<p>As far as the API for changing the selection, one on the end points is considered to be the "anchor point", and the other the "free point".</p>
<h3 id="properties">Properties</h3>
<pre class="sourceCode lua"><code class="sourceCode lua"><span class="co">--view overrides</span>
<span class="kw">background_color</span> <span class="ot">=</span> <span class="kw">nil</span>
<span class="kw">text_color</span> <span class="ot">=</span> <span class="kw">nil</span>
<span class="kw">line_rect</span> <span class="ot">=</span> <span class="kw">nil</span> <span class="co">--line_rect(line) -> x, y, w, h</span></code></pre>
<h3 id="methods">Methods</h3>
<table>
<col width="50%" />
<col width="50%" />
<tbody>
<tr class="odd">
<td align="left"><code>selection:new(buffer, [view], visible) -> sel</code></td>
<td align="left">create a selection object</td>
</tr>
<tr class="even">
<td align="left"><strong>boundaries</strong></td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left"><code>sel:isempty() -> true | false</code></td>
<td align="left">check if it's empty</td>
</tr>
<tr class="even">
<td align="left"><code>sel:isforward() -> true | false</code></td>
<td align="left">does it go top-down and left-to-rigth?</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:endpoints() -> line1, col1, line2, col2</code></td>
<td align="left">endpoints, ordered</td>
</tr>
<tr class="even">
<td align="left"><code>sel:cols(line) -> col1, col2</code></td>
<td align="left">column range of one selection line</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:next_line(line) -> line+1, col1, col2</code></td>
<td align="left">next line boundaries</td>
</tr>
<tr class="even">
<td align="left"><code>sel:lines() -> iter() -> line, col1, col2</code></td>
<td align="left">iterate over the boundaries</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:line_range() -> line1, line2</code></td>
<td align="left">the range of lines that the selection covers fully or partially</td>
</tr>
<tr class="even">
<td align="left"><code>sel:select() -> lines_t</code></td>
<td align="left">select text as a list of lines</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:contents() -> s</code></td>
<td align="left">select text using buffer's line terminator setting</td>
</tr>
<tr class="even">
<td align="left"><strong>changing the selection</strong></td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left"><code>sel:reset(line, col)</code></td>
<td align="left">empty and re-anchor to a position</td>
</tr>
<tr class="even">
<td align="left"><code>sel:extend(line, col)</code></td>
<td align="left">move selection's free endpoint</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:reverse()</code></td>
<td align="left">reverse selection's direction</td>
</tr>
<tr class="even">
<td align="left"><code>sel:set(line1, col1, line2, col2, forward)</code></td>
<td align="left">set selection endpoints, preserving or setting its direction</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:select_all()</code></td>
<td align="left">extend selection to span the entire document</td>
</tr>
<tr class="even">
<td align="left"><code>sel:reset_to_cursor(cur)</code></td>
<td align="left">reset to a cursor position</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:extend_to_cursor(cur)</code></td>
<td align="left">extend to a cursor position</td>
</tr>
<tr class="even">
<td align="left"><code>sel:set_to_selection(sel)</code></td>
<td align="left">set to match another selection</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:set_to_line_range()</code></td>
<td align="left">extend to contain all its lines in full</td>
</tr>
<tr class="even">
<td align="left"><strong>selection-based editing</strong></td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left"><code>sel:remove()</code></td>
<td align="left">remove selected text from the buffer</td>
</tr>
<tr class="even">
<td align="left"><code>sel:indent(use_tab)</code></td>
<td align="left">extend to line range and indent</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:outdent()</code></td>
<td align="left">extend to line range and outdent</td>
</tr>
<tr class="even">
<td align="left"><code>sel:move_up()</code><br /><code>sel:move_down()</code></td>
<td align="left">extend to line range and move up/down in buffer</td>
</tr>
<tr class="odd">
<td align="left"><code>sel:reflow(line_width, tabsize, align, wrap)</code></td>
<td align="left">reflow text in selection</td>
</tr>
<tr class="even">
<td align="left"><strong>hit testing</strong></td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left"><code>sel:hit_test(x, y) -> true | false</code></td>
<td align="left">hit test</td>
</tr>
<tr class="even">
<td align="left"><strong>TODO</strong></td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left"><code>sel:invalidate()</code></td>
<td align="left"></td>
</tr>
</tbody>
</table>
<h2 id="block-selections">Block Selections</h2>
<h2 id="local-block_selection-requirecodedit_blocksel"><code>local block_selection = require'codedit_blocksel'</code></h2>
<p>Extended selection object for selecting vertically aligned text between two arbitrary cursor positions (line1, col1, line2, col2), where line1,line2 are the horizontal boundaries and col1,col2 are the vertical boundaries of the rectangle.</p>
<p>The methods are the same as for normal selections, except that operate on blocks. Also, indenting and outdenting doesn't extend the selection to line range. Other differences are as follows:</p>
<table>
<col width="50%" />
<col width="50%" />
<tbody>
<tr class="odd">
<td align="left"><code>block_selection:new(buffer, view, visible) -> blocksel</code></td>
<td align="left">create a new block selection object</td>
</tr>
<tr class="even">
<td align="left"><code>blocksel.block -> true</code></td>
<td align="left">this is to distinguish from a normal selection</td>
</tr>
<tr class="odd">
<td align="left"><code>blocksel:extend_to_last_col()</code></td>
<td align="left">extend selection to the right to contain all the available text</td>
</tr>
</tbody>
</table>
</section>
</div>
<div id="tab2_container" class="doc"></div>
</div>
</div>
<div class="container">
<footer>
<div id="disqus_thread"></div>
<div class="faint">cosmin.apreutesei@gmail.com | <a href="http://unlicense.org/">public domain</a></div>
</footer>
</div>
</div>
<script type="text/x-mustache" id=info_tab_template>
<h3>Modules</h3>
<ul>
{{#module_array}}
<li>{{name}}</li>
{{/module_array}}
</ul>
</script>
</body>
</html>