[Geany-Devel] Querying current file and cursor location

Thomas Young thomasyoung at free.fr
Fri Jan 18 10:05:25 UTC 2013


 > 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 <thomasyoung at free.fr> 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
>
>>


More information about the Devel mailing list