Re: [Geany-Devel] Querying current file and cursor location
On Fri, 18 Jan 2013 09:31:18 +0100 Thomas Young wrote: > btw. What's the situation for the 'Scope' plugin? > e.g. Is this working / in active development? It works since the first upload, the ChangeLog is long only because it's very detailed. Currently there are 2 known bugs: switching to Locals may cause segfault (may be OK with update_all_views = true), and gtk_tree_model_get(string) leaks everywhere (though you'll need to debug a lot to reach 1MB). I fixed them and am testing ATM. > Sounds like this aims to address some of the issues I can see with GUI > integrated debugging, in particular the possibility to still interact > directly (and to some extent 'properly') with gdb. You can send any gdb command at any time and watch it's output in the "Debug Console" subpage. Some commands are even implemented that way, for example adding a breakpoint simply opens the CL dialog with "-break-insert :", and lets you specify any other options. > One tricky point I can see is: how to mix programmed and direct > interaction with gdb whilst still keeping the tab symbol completion? Don't know, but Geany auto-completion may be an option. > And it looks like there are other rough edges to be worked out for this, > e.g. with regards to program interruption (--exec-interrupt requiring some > kind of asynchronous mode that I couldn't get working, ctrl-C not being > passed on to the target). A local -exec-interrupt simply emits SIGINT. In both debugger and Scope, the signal is sent to Geany and eventually gdb, but not the target. :) May be different for remote. ^C should be sent directly to the target terminal, for example with Scope "Program Terminal -> Feed -> 3" (though right clicking a thread and choosing "Interrupt" would be easier). If the target and gdb use the same terminal, you won't be able to communicate with gdb properly. -- E-gards: Jimmy ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
> And what if filename contains a : ? Well, the external code I have for processing this output actually searches back from the end of the string, so that wouldn't be a problem in this case. For info, the python code I am using to implement a kind of 'editor breakpoint' command with this looks like this: import gdb class BreakPointAtEditorLocationCommand(gdb.Command): def __init__ (self): super(BreakPointAtEditorLocationCommand, self).__init__ ("eb", gdb.COMMAND_USER) def invoke (self, arg, from_tty): output = subprocess.check_output(["geany", "--print-location"]) pos = output.rfind(':') if not pos == -1: command = "b " + output[:pos] gdb.execute(command) BreakPointAtEditorLocationCommand() #required to register command Thomas On 18/01/13 10:55, Lex Trotman wrote: On 18 January 2013 20:36, Thomas Young wrote: Hmm.. not sure what happens if the filename is UTF-8. DOC_FILENAME is always UTF-8. Basically, where some existing code (which is documented as supporting UTF-8 filenames) was doing; filename = DOC_FILENAME(documents[i]); g_string_append(doc_list, filename); g_string_append_c(doc_list, '\n'); I am doing instead: 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\n", filename, line + 1, col); And what if filename contains a : ? Anyway it will be written in UTF-8, you will have to handle locale encoding elsewhere maybe. Cheers Lex ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
On 18 January 2013 20:36, Thomas Young wrote: > Hmm.. not sure what happens if the filename is UTF-8. DOC_FILENAME is always UTF-8. > > Basically, where some existing code (which is documented as supporting UTF-8 > filenames) was doing; > > filename = DOC_FILENAME(documents[i]); > g_string_append(doc_list, filename); > g_string_append_c(doc_list, '\n'); > > I am doing instead: > > > 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\n", filename, > line + 1, col); And what if filename contains a : ? Anyway it will be written in UTF-8, you will have to handle locale encoding elsewhere maybe. Cheers Lex > > > > On 18/01/13 09:10, Thomas Young wrote: >> >> Cheers Steve. >> >> Ok, I changed spaces to tabs, and a patch from diff output is attached. >> Will try and do things more properly next time! >> >> Thomas >> >> On 17/01/13 17:15, Steven Blatnick wrote: >>> >>> I'm new too, but the first time I submitted something, they took a patch >>> I attached to an email sent to this mailing list. Subsequent >>> submissions, I signed up for a github account and forked geany and >>> geany-plugins. Using git hub, changes can be submitted through a "pull >>> request". I also signed up to SourceForge for submitting bugs. >>> >>> Here is where I read about the process: >>> http://www.geany.org/Contribute/Developers >>> >>> So far I've found the people on this project have been helpful and >>> friendly compared to my minor previous experiences with open source >>> projects. >>> >>> Welcome :-) >>> >>> Steven Blatnick >>> >>> >>> On 01/17/2013 06:17 AM, Thomas Young wrote: Hello, I've hacked a small change into Geany locally, to help with integration with gdb. 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@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@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel >>> >>> >>> ___ >>> Devel mailing list >>> Devel@lists.geany.org >>> https://lists.geany.org/cgi-bin/mailman/listinfo/devel >>> >> >> >> ___ >> Devel mailing list >> Devel@lists.geany.org >> https://lists.geany.org/cgi-bin/mailman/listinfo/devel >> > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
Hmm.. not sure what happens if the filename is UTF-8. Basically, where some existing code (which is documented as supporting UTF-8 filenames) was doing; filename = DOC_FILENAME(documents[i]); g_string_append(doc_list, filename); g_string_append_c(doc_list, '\n'); I am doing instead: 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\n", filename, line + 1, col); On 18/01/13 09:10, Thomas Young wrote: Cheers Steve. Ok, I changed spaces to tabs, and a patch from diff output is attached. Will try and do things more properly next time! Thomas On 17/01/13 17:15, Steven Blatnick wrote: I'm new too, but the first time I submitted something, they took a patch I attached to an email sent to this mailing list. Subsequent submissions, I signed up for a github account and forked geany and geany-plugins. Using git hub, changes can be submitted through a "pull request". I also signed up to SourceForge for submitting bugs. Here is where I read about the process: http://www.geany.org/Contribute/Developers So far I've found the people on this project have been helpful and friendly compared to my minor previous experiences with open source projects. Welcome :-) Steven Blatnick On 01/17/2013 06:17 AM, Thomas Young wrote: Hello, I've hacked a small change into Geany locally, to help with integration with gdb. 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@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@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
On 18 January 2013 20:09, Thomas Young wrote: > Hi Lex, > > >> Don't forget to update the manual to include your new cl >> option. > > How to do this? > > I can see references to --list-documents in doc/geany.html and > doc/geany.txt, so I suppose we add a similar entry for the new option, but I > guess one of those files is generated from the other? Yes, geany.txt generates geany.html so just update the .txt which is written in restructured text markup, just follow the other cl examples. Cheers Lex > > I attached a patch to another reply, but didn't include a manual update with > this.. Thats the problem with patches to the ML, they get missed and lost and forgotten :) Cheers Lex > > Thomas > > > > On 18/01/13 09:43, Lex Trotman wrote: >>> >>> The proposed change then adds the possibility to do more things with this >>> kind of setup, with a very minimal change (in particular, the change >>> doesn't >>> do anything that geany didn't do already, since it just mimics the >>> existing >>> code path and logic for the --list-documents command). >> >> >> Probably best to just make a pull request (preferred) or a patch and >> lets see. Don't forget to update the manual to include your new cl >> option. >> >> Cheers >> Lex >> >>> >>> Best regards, >>> >>> Thomas >>> > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
Hi Lex, > Don't forget to update the manual to include your new cl > option. How to do this? I can see references to --list-documents in doc/geany.html and doc/geany.txt, so I suppose we add a similar entry for the new option, but I guess one of those files is generated from the other? I attached a patch to another reply, but didn't include a manual update with this.. Thomas On 18/01/13 09:43, Lex Trotman wrote: The proposed change then adds the possibility to do more things with this kind of setup, with a very minimal change (in particular, the change doesn't do anything that geany didn't do already, since it just mimics the existing code path and logic for the --list-documents command). Probably best to just make a pull request (preferred) or a patch and lets see. Don't forget to update the manual to include your new cl option. Cheers Lex Best regards, Thomas ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
On 18 January 2013 19:21, Thomas Young wrote: > Hi Lex, > > Right, seems like there are basically two ways to approach the general > problem: > > * GUI integrated gdb, potentially using the machine interface and so on > or > * interacting directly with gdb in a dedicated terminal > > Yes I tried the debugger plugin, but it just doesn't seem as 'solid' as gdb > in a dedicated terminal (e.g. when I tried using this I seemed to get some > random hangs and crashes in geany, which normally seems completely stable). Hi Thomas, Yes, debugger is still in development, please let the dev have backtraces of any crashes, thats the fastest way of getting them fixed :) > > This kind of GUI integrated debugger is kind of what I was looking for > first, since I am basically coming from MSVC. > And I guess it is probably the ideal case (i.e. it is nice to be able to see > all the breakpoint markers next to the text, and so on). > > But, after looking into it a bit, it seems like it is actually quite tricky > to integrate gdb 'properly' with a GUI, i.e. to be able to do all the GUI > stuff whilst still being able to do everything else that you can do with gdb > when running directly in a terminal. Yes, with all due respect to its developer, I think debugger will never incorporate all the gdb capabilities into the gui. And I don't think he is trying to achieve that. > > Basically, I think gdb is really something that has been designed around > direct interaction in a terminal, and various more or less subtle things > depend on this. > One tricky point I can see is: how to mix programmed and direct interaction > with gdb whilst still keeping the tab symbol completion? > > And it looks like there are other rough edges to be worked out for this, > e.g. with regards to program interruption (--exec-interrupt requiring some > kind of asynchronous mode that I couldn't get working, ctrl-C not being > passed on to the target). > > I think that bottom line is then that working with gdb separately remains a > potentially useful setup. Sure, just pointed you at the plugin because if it met your requirement it would save you much work. (And I might have persuaded you to help on it :) > > The geany command line already includes some support specific for this (the > +filespec option - if you set the EDITOR environment variable to 'geany' > then you can type 'ed' in gdb in a separate terminal and get taken to the > current source location in geany). > > The proposed change then adds the possibility to do more things with this > kind of setup, with a very minimal change (in particular, the change doesn't > do anything that geany didn't do already, since it just mimics the existing > code path and logic for the --list-documents command). Probably best to just make a pull request (preferred) or a patch and lets see. Don't forget to update the manual to include your new cl option. Cheers Lex > > Best regards, > > Thomas > > > > On 17/01/13 21:13, Lex Trotman wrote: >> >> On 18 January 2013 00:17, Thomas Young 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 >> > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
btw. What's the situation for the 'Scope' plugin? e.g. Is this working / in active development? I saw Dimitar's post about this, but didn't get a chance to try this out yet, but this sounds interesting. Sounds like this aims to address some of the issues I can see with GUI integrated debugging, in particular the possibility to still interact directly (and to some extent 'properly') with gdb. (If I recall correctly, the debugger plugin doesn't attempt do this, and geanygdb seemed to have problems if you typed stuff in to it's terminal.) On 17/01/13 21:13, Lex Trotman wrote: On 18 January 2013 00:17, Thomas Young 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 ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
Hi Lex, Right, seems like there are basically two ways to approach the general problem: * GUI integrated gdb, potentially using the machine interface and so on or * interacting directly with gdb in a dedicated terminal Yes I tried the debugger plugin, but it just doesn't seem as 'solid' as gdb in a dedicated terminal (e.g. when I tried using this I seemed to get some random hangs and crashes in geany, which normally seems completely stable). This kind of GUI integrated debugger is kind of what I was looking for first, since I am basically coming from MSVC. And I guess it is probably the ideal case (i.e. it is nice to be able to see all the breakpoint markers next to the text, and so on). But, after looking into it a bit, it seems like it is actually quite tricky to integrate gdb 'properly' with a GUI, i.e. to be able to do all the GUI stuff whilst still being able to do everything else that you can do with gdb when running directly in a terminal. Basically, I think gdb is really something that has been designed around direct interaction in a terminal, and various more or less subtle things depend on this. One tricky point I can see is: how to mix programmed and direct interaction with gdb whilst still keeping the tab symbol completion? And it looks like there are other rough edges to be worked out for this, e.g. with regards to program interruption (--exec-interrupt requiring some kind of asynchronous mode that I couldn't get working, ctrl-C not being passed on to the target). I think that bottom line is then that working with gdb separately remains a potentially useful setup. The geany command line already includes some support specific for this (the +filespec option - if you set the EDITOR environment variable to 'geany' then you can type 'ed' in gdb in a separate terminal and get taken to the current source location in geany). The proposed change then adds the possibility to do more things with this kind of setup, with a very minimal change (in particular, the change doesn't do anything that geany didn't do already, since it just mimics the existing code path and logic for the --list-documents command). Best regards, Thomas On 17/01/13 21:13, Lex Trotman wrote: On 18 January 2013 00:17, Thomas Young 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 ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
Cheers Steve. Ok, I changed spaces to tabs, and a patch from diff output is attached. Will try and do things more properly next time! Thomas On 17/01/13 17:15, Steven Blatnick wrote: I'm new too, but the first time I submitted something, they took a patch I attached to an email sent to this mailing list. Subsequent submissions, I signed up for a github account and forked geany and geany-plugins. Using git hub, changes can be submitted through a "pull request". I also signed up to SourceForge for submitting bugs. Here is where I read about the process: http://www.geany.org/Contribute/Developers So far I've found the people on this project have been helpful and friendly compared to my minor previous experiences with open source projects. Welcome :-) Steven Blatnick On 01/17/2013 06:17 AM, Thomas Young wrote: Hello, I've hacked a small change into Geany locally, to help with integration with gdb. 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@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@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel diff -u geany_before_changes_17_jan/src/main.c geany_git/src/main.c --- geany_before_changes_17_jan/src/main.c 2013-01-15 22:28:00.0 +0100 +++ geany_git/src/main.c2013-01-17 13:08:27.607352186 +0100 @@ -127,6 +127,7 @@ { "new-instance", 'i', 0, G_OPTION_ARG_NONE, &cl_options.new_instance, N_("Don't open files in a running instance, force opening a new instance"), NULL }, { "socket-file", 0, 0, G_OPTION_ARG_FILENAME, &cl_options.socket_filename, N_("Use this socket filename for communication with a running Geany instance"), NULL }, { "list-documents", 0, 0, G_OPTION_ARG_NONE, &cl_options.list_documents, N_("Return a list of open documents in a running Geany instance"), NULL }, + { "print-location", 0, 0, G_OPTION_ARG_NONE, &cl_options.print_location, N_("Prints current open file and cursor location in a running Geany instance"), NULL }, #endif { "line", 'l', 0, G_OPTION_ARG_INT, &cl_options.goto_line, N_("Set initial line number for the first opened file"), NULL }, { "no-msgwin", 'm', 0, G_OPTION_ARG_NONE, &no_msgwin, N_("Don't show message window at startup"), NULL }, @@ -1007,7 +1008,7 @@ { /* Quit if filenames were sent to first instance or the list of open * documents has been sent */ - if (argc > 1 || cl_options.list_documents) + if (argc > 1 || cl_options.list_documents || cl_options.print_location) { gdk_notify_startup_complete(); g_free(app->configdir); diff -u geany_before_changes_17_jan/src/main.h geany_git/src/main.h --- geany_before_changes_17_jan/src/main.h 2013-01-15 22:28:00.0 +0100 +++ geany_git/src/main.h2013-01-17 13:08:27.675352227 +0100 @@ -32,6 +32,7 @@
Re: [Geany-Devel] Querying current file and cursor location
On 18 January 2013 00:17, Thomas Young 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@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@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Querying current file and cursor location
I'm new too, but the first time I submitted something, they took a patch I attached to an email sent to this mailing list. Subsequent submissions, I signed up for a github account and forked geany and geany-plugins. Using git hub, changes can be submitted through a "pull request". I also signed up to SourceForge for submitting bugs. Here is where I read about the process: http://www.geany.org/Contribute/Developers So far I've found the people on this project have been helpful and friendly compared to my minor previous experiences with open source projects. Welcome :-) Steven Blatnick On 01/17/2013 06:17 AM, Thomas Young wrote: Hello, I've hacked a small change into Geany locally, to help with integration with gdb. 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@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@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel