[Geany-Devel] Querying current file and cursor location

Lex Trotman elextr at gmail.com
Thu Jan 17 20:13:30 UTC 2013


On 18 January 2013 00:17, Thomas Young <thomasyoung at free.fr> wrote:
> Hello,
>
> I've hacked a small change into Geany locally, to help with integration with
> gdb.
>

Hi Thomas,

Have you tried the debugger plugin, it runs gdb and provides a GUI
interface in Geany.  Its still relatively new, but seems to work.
(Don't use geanygdb plugin, its been deprecated).

What does it not provide that you need?  Perhaps you could contribute
to that plugin.

Cheers
Lex


> Basically, what I've done is to add a '--print-location' command line
> option, which essentially just duplicates the functionality of the existing
> '--list-documents' option (through main.c/h and socket.c/h), but with the
> actual string generation bit that corresponds to build_document_list()
> changed to the following:
>
> static gchar *build_location(void)
> {
>         GString *location = g_string_new(NULL);
>         const gchar *filename;
>         gint pos, line, col;
>
>         GeanyDocument *doc = document_get_current();
>         if(doc)
>         {
>                 filename = DOC_FILENAME(doc);
>                 pos = sci_get_current_position(doc->editor->sci);
>                 line = sci_get_line_from_position(doc->editor->sci, pos);
>                 col = sci_get_col_from_position(doc->editor->sci, pos);
>                 g_string_append_printf(location, "%s:%d:%d", filename, line
> + 1, col);
>                 g_string_append_c(location, '\n');
>         }
>         return g_string_free(location, FALSE);
> }
>
> So what the overall change does then is basically to allow you to query for
> the currently selected file, and current cursor location within that file,
> from outside of geany, like so:
>
> thomas at MS-7752 ~ $ geany --print-location
> /home/thomas/Downloads/geany_git/src/socket.c:600:33
>
> I can then use this in a python command within gdb (running completely
> separately within a terminal) to set break points for positions selected in
> files in Geany within having to actually type the whole filename and line
> number bit each time.
>
> This was based on the nightly build for January 17th, and seems to be
> working correctly.
>
> Should I submit a patch for this change?
> If so, how?
> (Not used to this whole open source malarky!)
>
> I got the nightly build archive instead of using git, but I have copies of
> the source archive both before and after the change.
>
> Is it possible for this change (or something similar) to be included in the
> Geany mainline?
>
> Best regards,
>
> Thomas
> _______________________________________________
> Devel mailing list
> Devel at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/devel


More information about the Devel mailing list