Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: GitHub noreply@github.com Date: Sun, 30 Jan 2022 21:25:31 UTC Commit: 1f823b2e6146f2e0d70db0b73d731d6dff1b495e https://github.com/geany/geany-plugins/commit/1f823b2e6146f2e0d70db0b73d731d...
Log Message: ----------- Merge pull request #1157 from Skif-off/geanylua-setfiletype
GeanyLua: Add geany.settype()
Modified Paths: -------------- geanylua/docs/geanylua-ref.html geanylua/glspi_doc.c geanylua/keywords.list
Modified: geanylua/docs/geanylua-ref.html 21 lines changed, 16 insertions(+), 5 deletions(-) =================================================================== @@ -177,31 +177,36 @@ </tr>
<tr class="odd"> + <td> function <a href="#settype"><b>settype</b></a> ( filetype )<br></td> + <td class="desc">-- Change the current file type.</td> +</tr> + +<tr class="even"> <td> 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="even"> +<tr class="odd"> <td> 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="odd"> +<tr class="even"> <td> 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="even"> +<tr class="odd"> <td> 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="odd"> +<tr class="even"> <td> 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="even"> +<tr class="odd"> <td> function <a href="#yield"><b>yield</b></a> ()<br></td> <td class="desc">-- Refreshes the user interface.</td> </tr> @@ -955,6 +960,12 @@ (caret) position. </p><br><br>
+<a name="settype"></a><hr><h3><tt>geany.settype ( filetype )</tt></h3> +<p>Will change the current file type. Use one-word description of the +file type, e.g. "C" or "Python" (see the "<tt>filetype_extensions.conf</tt>" +file). +</p><br><br> + <a name="signal"></a><hr><h3><tt>geany.signal ( widget, signal )</tt></h3><p> Emits a GTK signal to a given widget in the Geany user interface.</p><p> The <tt>widget</tt> argument is a string identifying the widget by its Glade <tt><b>"id"</b></tt> attribute.<br>
Modified: geanylua/glspi_doc.c 24 lines changed, 24 insertions(+), 0 deletions(-) =================================================================== @@ -334,11 +334,35 @@ static gint glspi_fileinfo(lua_State* L) }
+/* Change the current file type */ +static gint glspi_setfiletype(lua_State* L) +{ + GeanyDocument *doc=NULL; + GeanyFiletype *ft=NULL; + const gchar *ftn=NULL; + + if (lua_gettop(L)==1){ + if (!lua_isstring(L, 1)) { return FAIL_STRING_ARG(1); } + doc = document_get_current(); + if (!(doc && doc->is_valid)) { return 0; } + ftn=lua_tostring(L, 1); + if ('\0' == ftn[0]) { return 0; } + ft=filetypes_lookup_by_name(ftn); + if (ft != NULL){ + document_set_filetype(doc, ft); + return 1; + } + } + return 0; +} + +
static const struct luaL_reg glspi_doc_funcs[] = { {"filename", glspi_filename}, {"fileinfo", glspi_fileinfo}, + {"settype", glspi_setfiletype}, {"documents", glspi_documents}, {"count", glspi_count}, {"activate", glspi_activate},
Modified: geanylua/keywords.list 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -7,4 +7,4 @@ word5=0xf0a000;0xffffff;false;false
## Put this in the [keywords] section: -user1=geany.activate geany.appinfo geany.banner geany.basename geany.batch geany.byte geany.caller geany.caret geany.choose geany.close geany.confirm geany.copy geany.count geany.cut geany.dirlist geany.dirname geany.dirsep geany.documents geany.fileinfo geany.filename geany.find geany.fullpath geany.height geany.input geany.keycmd geany.keygrab geany.launch geany.length geany.lines geany.match geany.message geany.navigate geany.newfile geany.open geany.optimize geany.paste geany.pickfile geany.pluginver geany.rectsel geany.reloadconf geany.rescan geany.rowcol geany.save geany.scintilla geany.script geany.select geany.selection geany.signal geany.stat geany.status geany.text geany.timeout geany.wkdir geany.word geany.wordchars geany.xsel geany.yield dialog.checkbox dialog.color dialog.file dialog.font dialog.group dialog.heading dialog.hr dialog.label dialog.new dialog.option dialog.password dialog.radio dialog.run dialog.select dialog.text dialog.textarea keyfile.comment keyfile.data keyfile.groups keyfile.has keyfile.keys keyfile.new keyfile.remove keyfile.value +user1=geany.activate geany.appinfo geany.banner geany.basename geany.batch geany.byte geany.caller geany.caret geany.choose geany.close geany.confirm geany.copy geany.count geany.cut geany.dirlist geany.dirname geany.dirsep geany.documents geany.fileinfo geany.filename geany.find geany.fullpath geany.height geany.input geany.keycmd geany.keygrab geany.launch geany.length geany.lines geany.match geany.message geany.navigate geany.newfile geany.open geany.optimize geany.paste geany.pickfile geany.pluginver geany.rectsel geany.reloadconf geany.rescan geany.rowcol geany.save geany.scintilla geany.script geany.select geany.selection geany.settype geany.signal geany.stat geany.status geany.text geany.timeout geany.wkdir geany.word geany.wordchars geany.xsel geany.yield dialog.checkbox dialog.color dialog.file dialog.font dialog.group dialog.heading dialog.hr dialog.label dialog.new dialog.option dialog.password dialog.radio dialog.run dialog.select dialog.text dialog.textarea keyfile.comment keyfile.data keyfile.groups keyfile.has keyfile.keys keyfile.new keyfile.remove keyfile.value
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org