Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions geanylua/docs/geanylua-ref.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,63 +150,67 @@
<td class="desc">-- Paste text from the clipboard.</td>
</tr>


<tr class="even">
<td>&nbsp; function <a href="#range"><b>range</b></a> ( start, stop [, multi] )<br></td>
<td class="desc">-- Get the text in the specified range.</td>
</tr>

<tr class="odd">
<td>&nbsp; function <a href="#rowcol"><b>rowcol</b></a> ( [pos]|[row,col] )<br></td>
<td class="desc">-- Translate between linear and rectangular locations.</td>
</tr>

<tr class="odd">
<tr class="even">
<td>&nbsp; function <a href="#save"><b>save</b></a> ( [filename]|[index] )<br></td>
<td class="desc">-- Save an open document to a disk file.</td>
</tr>

<tr class="even">
<tr class="odd">
<td>&nbsp; function <a href="#scintilla"><b>scintilla</b></a> ( msg_id, wparam, lparam )<br></td>
<td class="desc">-- Send a message directly to the Scintilla widget.</td>
</tr>

<tr class="odd">
<tr class="even">
<td>&nbsp; function <a href="#select"><b>select</b></a> ( [[start,] stop] )<br></td>
<td class="desc">-- Get or set the selection endpoints and caret.</td>
</tr>

<tr class="even">
<tr class="odd">
<td>&nbsp; function <a href="#selection"><b>selection</b></a> ( [content] )<br></td>
<td class="desc">-- Get or set the contents of the document's selection.</td>
</tr>

<tr class="odd">
<tr class="even">
<td>&nbsp; function <a href="#settype"><b>settype</b></a> ( filetype )<br></td>
<td class="desc">-- Change the current file type.</td>
</tr>

<tr class="even">
<tr class="odd">
<td>&nbsp; function <a href="#signal"><b>signal</b></a> ( widget, signal )<br></td>
<td class="desc">-- Send a GTK signal to a Geany interface widget.</td>
</tr>

<tr class="odd">
<tr class="even">
<td>&nbsp; function <a href="#status"><b>status</b></a> ( message )<br></td>
<td class="desc">-- Send a string to display in the status tab of the messages window.</td>
</tr>

<tr class="even">
<tr class="odd">
<td>&nbsp; function <a href="#text"><b>text</b></a> ( [content] )<br></td>
<td class="desc">-- Get or set the contents of the entire document.</td>
</tr>

<tr class="odd">
<tr class="even">
<td>&nbsp; function <a href="#word"><b>word</b></a> ( [position] )<br></td>
<td class="desc">-- Get the word at the specified location.</td>
</tr>

<tr class="even">
<tr class="odd">
<td>&nbsp; function <a href="#xsel"><b>xsel</b></a> ( [text] )<br></td>
<td class="desc">-- Get or set the contents of the primary X selection.</td>
</tr>

<tr class="odd">
<tr class="even">
<td>&nbsp; function <a href="#yield"><b>yield</b></a> ()<br></td>
<td class="desc">-- Refreshes the user interface.</td>
</tr>
Expand Down Expand Up @@ -825,6 +829,19 @@
<br><br>


<a name="range"></a><hr><h3><tt>geany.range ( start, stop [, multi] )</tt></h3>
<p>Returns the text from position <tt><b>start</b></tt> to position <tt><b>stop</b></tt>.<br>
<tt><b>multi</b></tt> is an optional boolean parameter
(<tt><b>true</b></tt> or <tt><b>false</b></tt>, <tt><b>false</b></tt> used by default):
if the position lands inside a multi-byte sequence, <tt><b>geany.range</b></tt>
will use the position at the beginning (<tt><b>start</b></tt>) or
at the end (<tt><b>stop</b></tt>) of that multi-byte character. This is usually
not necessary because GeanyLua functions (<tt><b>geany.caret</b></tt>,
<tt><b>geany.find</b></tt> and so on) and Lua functions (<tt><b>string.find</b></tt> and so on)
use positions in bytes.</p>
<br><br>


<a name="reloadconf"></a><hr><h3><tt>geany.reloadconf ()</tt></h3>
<p>This function will cause Geany to reload most of it's configuration files without restarting
(as menu item <b><i>Tools-><u>R</u>eload Configuration</i></b>).</p>
Expand Down
36 changes: 36 additions & 0 deletions geanylua/glspi_sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,41 @@ struct Sci_TextToFind {



static gint glspi_range(lua_State* L)
{
gint argc = lua_gettop(L);
gboolean multi = FALSE;
gint start, stop, x, y;
gchar *text;
DOC_REQUIRED
gint len = sci_get_length(doc->editor->sci);
if ( (len == 0) || (argc < 2) || (argc > 3) ) {
lua_pushnil(L);
return 1;
}
if (!lua_isnumber(L, 1)) { return FAIL_NUMERIC_ARG(1); }
start = lua_tonumber(L, 1);
if (!lua_isnumber(L, 2)) { return FAIL_NUMERIC_ARG(2); }
stop = lua_tonumber(L, 2);
if (start < 0) { return FAIL_UNSIGNED_ARG(1); }
if (stop < 0) { return FAIL_UNSIGNED_ARG(2); }
if (start > stop) { swap(&start, &stop); }
if (stop > len) { stop = len; }
if (lua_isboolean(L, 3)) { multi = lua_toboolean(L, 3); }
if (multi) {
x = scintilla_send_message(doc->editor->sci, SCI_POSITIONBEFORE, start, 0);
y = scintilla_send_message(doc->editor->sci, SCI_POSITIONAFTER, stop, 0);
text = sci_get_contents_range(doc->editor->sci, x, y);
} else {
text = sci_get_contents_range(doc->editor->sci, start, stop);
}
lua_pushstring(L, text);
g_free(text);
return 1;
}



static const struct luaL_Reg glspi_sci_funcs[] = {
{"text", glspi_text},
{"selection", glspi_selection},
Expand All @@ -994,6 +1029,7 @@ static const struct luaL_Reg glspi_sci_funcs[] = {
{"byte", glspi_byte},
{"scintilla", glspi_scintilla},
{"find", glspi_find},
{"range", glspi_range},
{NULL,NULL}
};

Expand Down
Loading