Hello one and all,
I've written my first plugin for geany. Having been a long time user of ConTEXT, I've written a plugin that implements numbered bookmarks. I also made it remember the state of folds in a document and applies them when you open the document again.
The numbered bookmarks bit is working, but the but that remembers the fold state has a bug, and I'd be most apreciative if anyone had any ideas. The problem lies on line 443. For some reason if I get rid of the dialogs_show_msgbox call then the fold state is not re-applied, and if it is included then the fold state is re-applied. I can't think of any reason why this is so. I use messages to help me debug, so I use calls like dialogs_show_msgbox to tell me what's going on, but It makes the plugin a pain to use if left in the final code. I have tried using gdb but despite compiling with the -g or the -ggdb arguments I can't get gdb to use line numbers of have any idea of the source code, so I can't monitor what's going on.
I'd be most grateful if anyone can spot what's going on here.
William Fraser
On 1 November 2010 18:33, WILLIAM FRASER william.fraser@virgin.net wrote:
Hello one and all,
I've written my first plugin for geany. Having been a long time user of ConTEXT, I've written a plugin that implements numbered bookmarks. I also made it remember the state of folds in a document and applies them when you open the document again.
The numbered bookmarks bit is working, but the but that remembers the fold state has a bug, and I'd be most apreciative if anyone had any ideas. The problem lies on line 443. For some reason if I get rid of the dialogs_show_msgbox call then the fold state is not re-applied, and if it is included then the fold state is re-applied. I can't think of any reason why this is so. I use messages to help me debug, so I use calls like dialogs_show_msgbox to tell me what's going on, but It makes the plugin a pain to use if left in the final code. I have tried using gdb but despite compiling with the -g or the -ggdb arguments I can't get gdb to use line numbers of have any idea of the source code, so I can't monitor what's going on.
I'd be most grateful if anyone can spot what's going on here.
William Fraser
Not sure if its part of the problem, but I notice that line 436 responds GTK_RESPONSE_OK which is not a case in the switch(l) statement at line 445 so it should do default which makes it do nothing.
Cheers Lex
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
My apologies for any confusion. My code style is very terse, and I don't put in as many comments as other programmers (I started off in machine code on 64K machines, and have never properly got into the habit of commenting properly.)
GTK_RESPONSE_ACCEPT is the default code as we hit the switch. This is the case if we haven't encountered any problems while opening the document (no one has edited the file since it was last saved by geany, and so the line numbers where the bookmarks are, and the number of folds should be the same).
GTK_RESPONSE_OK is only possible if the file has changed. It is used to indicate that the file has changed and that the user is ok with the advice to not try to apply the saved positions to the file in case it makes a mess of things. So there is no case in the switch for this (it's caught by the default statement) as we ignore the bookmark and fold data.
GTK_RESPONSE_REJECT is again only possible if the file has changed. It is used to indicate that the file has changed, but that the user wants to ignore the program's advice and try to apply bookmarks anyway accepting that they might be in the wrong place. Fold data could be a real mess if it's attempted to be applied in the wrong place, so it doesn't even try.
When testing I opened a file in another editor and then saved it again, so that I would only get GTK_RESPONSE_REJECT or GTK_RESPONSE_OK messages when the program reached the switch statement. I'm fairly sure that this isn't the cause of the problem...
Not sure if its part of the problem, but I notice that line 436 responds GTK_RESPONSE_OK which is not a case in the switch(l) statement at line 445 so it should do default which makes it do nothing.
Cheers Lex