-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[geanylua] geany.scintilla() does not work with SCI_SETLEXER #646
Comments
You should not set the lexer directly, set the Geany filetype instead. |
How can I do this? I found |
Since the Geanylua documentation seems to be absent on the web I can't really help you, a normal plugin would use Geanylua being orphaned and unmaintained I'm not sure if the missing documentation problem will get fixed. |
Unlikely if no one adopt it. |
"normal" plugin? :) Maybe try something like --- "geanylua/glspi_doc.c"
+++ "geanylua/glspi_doc.c"
@@ -32,12 +32,15 @@
static gint glspi_newfile(lua_State* L)
{
const gchar *fn=NULL;
+ const gchar *tf=NULL;
if (lua_gettop(L)>0) {
if (!lua_isstring(L, 1)) { return FAIL_STRING_ARG(1); }
fn=lua_tostring(L, 1);
if ( '\0' == fn[0] ) { fn = NULL; }
+ tf=lua_tostring(L, 2);
+ if ( '\0' == tf[0] ) { tf = NULL; }
}
- document_new_file(fn, NULL, NULL);
+ document_new_file(fn, tf, NULL);
return 0;
} ? local t = geany.fileinfo();
geany.newfile("", t.type); for untitled document/new tab. (I have not tried it yet, just thought.) Edit: edit "patch" |
By a "normal" plugin I mean one that uses the standard Geany plugin API, C, C++, Cython, anything else that accesses C and compiles to a But IIRC Geanylua provided only a customised and limited subset of that API. If the functionality is not available then I don't think you will be able to do whatever you are trying to do. To explain further, there are several reasons to use the Geany filetype, not set the lexer directly:
|
Won't be able to do it in Geanylua that is. |
I tried to use
Need to think. |
Ok, you can do it if you extend your own Geanylua. And since its unowned, why not :) You C code is passing a string as the filetype, it should be a pointer to the filetype structure, use [Edit: s/cod/code/ its not THAT fishy :) ] |
Hmm, seems to work fine and I think I fixed two warnings... Make PR? |
@frlan do you accept PRs for orphaned plugins? |
Sorry, it's too cool for me :) And I found a workaround: local t = geany.fileinfo();
geany.newfile("UNTITLED" .. t.ext); (but untitled document would be more convenient because it's obvious). Well, I do not want to lose, maybe will useful :), patch (like diff --git a/geanylua/glspi_doc.c b/geanylua/glspi_doc.c
index 888ce8d5..b536033e 100644
--- a/geanylua/glspi_doc.c
+++ b/geanylua/glspi_doc.c
@@ -32,12 +32,23 @@ static gint glspi_filename(lua_State* L)
static gint glspi_newfile(lua_State* L)
{
const gchar *fn=NULL;
- if (lua_gettop(L)>0) {
+ GeanyFiletype *ft=NULL;
+ switch (lua_gettop(L)) {
+ case 0: break;
+ case 2:
+ if (!lua_isstring(L, 2)) { return FAIL_STRING_ARG(2); }
+ const gchar *tmp=lua_tostring(L, 2);
+ if ( '\0' == tmp[0] ) {
+ ft=NULL;
+ } else {
+ ft=filetypes_lookup_by_name(tmp);
+ }
+ default:
if (!lua_isstring(L, 1)) { return FAIL_STRING_ARG(1); }
fn=lua_tostring(L, 1);
- if ( '\0' == fn[0] ) { fn = NULL; }
+ if ( '\0' == fn[0] ) { fn=NULL; }
}
- document_new_file(fn, NULL, NULL);
+ document_new_file(fn, ft, NULL);
return 0;
}
diff --git a/geanylua/docs/geanylua-ref.html b/geanylua/docs/geanylua-ref.html
index 9795c165..0c92b246 100644
--- a/geanylua/docs/geanylua-ref.html
+++ b/geanylua/docs/geanylua-ref.html
@@ -136,7 +136,7 @@ The Geany module provides these functions and variables...<br><br><br>
</tr>
<tr class="odd">
- <td> function <a href="#newfile"><b>newfile</b></a> ( [filename] )<br></td>
+ <td> function <a href="#newfile"><b>newfile</b></a> ( [filename [, filetype] )<br></td>
<td class="desc">-- Create a new document.</td>
</tr>
@@ -756,10 +756,23 @@ the selection is treated as <i>rectangular</i> rather than <i>linear</i>.<br>
<br><br>
-<a name="newfile"></a><hr><h3><tt>geany.newfile ( [filename] )</tt></h3><p>
-When called with one argument, creates a new document with the specified
-<tt>filename</tt>. </p><p>When called with no arguments, creates a new, untitled document.
-</p><br><br>
+<a name="newfile"></a><hr><h3><tt>geany.newfile ( [filename [, filetype] )</tt></h3><p>
+<p>When called with no arguments, creates a new, untitled document.</p>
+<p>When called with one argument, creates a new document with the specified
+<tt>filename</tt>.</p>
+<p>When called with two argument, creates a new document with the specified
+<tt>filename</tt> and <tt>filetype</tt> (a one-word description of the filetype,
+e.g. "C" or "Python".). If you want untitled document then set <tt>filename</tt> as <tt>""</tt>.</p>
+<p>So you can use it like this:</p>
+<pre>local s = geany.selection();
+
+if (s ~= "") and (s ~= nil) then
+ local t = geany.fileinfo();
+ geany.newfile("", t.type);
+ geany.selection(s);
+end</pre>
+<p>(create a new, untitled document, with selected text and auto set filetype).</p>
+<br><br>
Edit: del all warnings fixes, add freeing memory, fix indents |
Hmm... I'm looking at Nightly Builds stdout and I have question: how to fix
? And why Nightly Builds without this warning? Xubuntu 17.10 |
You have items of mixed signedness in the expression. This is IIRC a fairly new stupid warning. To shut it up just cast argc to an unsigned type. The nightly probably uses a compiler thats older than the stupid warning. |
@elextr |
No its not the Thats why its a stupid warning (or at least stupid to enable by default) because many system interfaces use just |
Can I just ignore this warning? :) |
For your own stuff sure. |
To be fair, it's not the actual Also, unrelated, that line looks wrong because of the order of operations and missing parenthesis, I believe it will allocate room for the needed pointers plus one byte. Presumably it's meant to be To fix the warning and bug, it could probably be changed to: argv = g_malloc0_n(argc+1, sizeof(gchar*)); |
@codebrainz good catch. Luckily for any geanylua users the allocated memory is likely to round up to a multiple of a pointer anyway for alignment reasons. |
I tried argv = g_malloc0_n(argc+1, sizeof(gchar*)); and I have:
Xubuntu 17.10 x64,
|
Maybe I'd better use gcc-6 (6.4.0) or gcc-5 (5.5.0)? |
or set option |
@Skif-off try this: argv=g_malloc0_n(argc + 1u, sizeof(gchar *)); |
This also works: diff --git a/geanylua/glspi_app.c b/geanylua/glspi_app.c
index ed82d5eb..23818170 100644
--- a/geanylua/glspi_app.c
+++ b/geanylua/glspi_app.c
@@ -418,11 +418,11 @@ static gint glspi_launch(lua_State* L)
gchar **argv=NULL;
gboolean rv;
GError *err=NULL;
- if (argc==0) { return FAIL_STRING_ARG(1); }
+ if (argc<=0) { return FAIL_STRING_ARG(1); }
for (i=1;i<=argc;i++) {
if (!lua_isstring(L,i)) { return FAIL_STRING_ARG(i); }
}
- argv=g_malloc0(sizeof(gchar *)*argc+1);
+ argv=g_malloc0_n(argc+1, sizeof(gchar *));
for (i=0;i<argc;i++) {
argv[i]=(g_strdup(lua_tostring(L,i+1)));
} |
@codebrainz In file included from /usr/include/x86_64-linux-gnu/sys/stat.h:25:0,
from glspi_app.c:8:
/usr/include/features.h:183:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
^~~~~~~ I added line |
@Skif-off yeah, I saw that warning, but it's just a deprecation warning. Proper fix would be for GeanyLua to use build system to check for |
Something like this: diff --git a/configure.ac b/configure.ac
index 7fb7d402..fa3bf5a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,6 +9,7 @@ AC_CONFIG_SRCDIR([po/POTFILES.in])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([build/cache])
+AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
diff --git a/geanylua/glspi_app.c b/geanylua/glspi_app.c
index 23818170..f6379f74 100644
--- a/geanylua/glspi_app.c
+++ b/geanylua/glspi_app.c
@@ -4,7 +4,10 @@
* See the file "geanylua.c" for copyright information.
*/
-#define _BSD_SOURCE /* for stat() and lstat() */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h> |
@codebrainz maybe you'll make a PR? As part of the development team :) |
P.S. diff --git a/geanylua/glspi_app.c b/geanylua/glspi_app.c
index ed82d5eb..b59d6b9a 100644
--- a/geanylua/glspi_app.c
+++ b/geanylua/glspi_app.c
@@ -604,6 +604,12 @@ static gint glspi_keygrab(lua_State* L)
}
+static gint glspi_reloadconf(lua_State* L)
+{
+ main_reload_configuration();
+ return 0;
+}
+
static const struct luaL_reg glspi_app_funcs[] = {
{"pluginver", glspi_pluginver},
@@ -620,6 +626,7 @@ static const struct luaL_reg glspi_app_funcs[] = {
{"keycmd", glspi_keycmd},
{"launch", glspi_launch},
{"keygrab", glspi_keygrab},
+ {"reloadconf", glspi_reloadconf},
{NULL,NULL}
};
|
Its any name known to your system iconv, so its system specific, Geany has some common names in its menus, but in fact even those are not guaranteed to be available.
The project does not package Geany for any distros, its done by external packagers who are experts in the peculiarities of their distro. So the project has no package building scripts. |
You should make separate pull requests for the above patches if you want to get them merged. That plugin doesn't have a dedicated maintainer, so making it easy on committers will give you a better chance to get changes in ... or if you volunteer to become the new maintainer :) |
Thanks, here it is necessary to think.
I saw https://nightly.geany.org/ and thought that it's a part of the development team :) Ok, I'll wait for the packages 1.32 in the repository.
Ok, I'll do it today-tomorrow.
It's impossible :) I like Geany, I like GeanyLua (with |
As far as we know there is no programmatic way of getting a list of the available encodings at runtime, (the equivalent of the
Yes the nightlys are provided by one of the developers, but they are for checking the build on a number of configurations, the packages produced are intended only as an artifact, although they may work if your system matches the build one. But the scripts are not published AFAIK and probably the build scripts are very specific to the particular setup and would not be useful even if they were published. Packages for Debian are not built by the packagers any more IIUC, the packagers submit jobs to a Debian build farm that makes packages for all the platforms and systems Debian supports, so only authorised people can make packages for Debian. Ubuntu is the same IIUC. Other distros may vary :) Packagers are of course individual contributors and their ability to immediately respond to a new Geany release may vary from time to time. |
Well, now I understand why I did not find examples of using this feature :))
I don't think so and they are not much different from Debian repositories (geany, geany-plugins) :) I use Debian-based OS and I wanted to see |
I added small script:
SCI_GETLEXER
works fine, all values (SCLEX_*
) were correctly received, butSCI_SETLEXER
is not working.Why? It's bug or not implemented?
Xubuntu 17.10 x64, Geany 1.31, I also checked current Git versions.
[Edit: example changes
glspi_newfile
here]The text was updated successfully, but these errors were encountered: