Re: [Geany-Devel] Plugin Advice
I appreciate the help, Lex. What I meant for the scanning was that it would happen twice, once to determine that, e.g. fold level 5 is actually fold level 2 and fold level 9 is actually fold level 3, and then again to do the actual folding. I think your outline of folding-as-you-go would probably work, too, and may, in fact, be better. It would only scan when the user initiates the (un)fold all at level X action. Geany scans the whole file for the (un)fold all action already, and given that that doesn't take too long, I'm guessing that this wouldn't either. But I haven't tried it out yet. Peter On Sat, Jan 25, 2014 at 3:13 PM, Lex Trotman ele...@gmail.com wrote: On 26 January 2014 02:53, Peter O'Malley ooomal...@gmail.com wrote: On Fri, Jan 24, 2014 at 2:29 PM, Lex Trotman ele...@gmail.com wrote: ... 4) The folder would have to always count increases/decreases from the start of the file to actually get a level that counts correctly or save state on the file. At the moment it starts from near the start of the visible range most of the time to make it faster, and saves no state so it only knows the actual indentation, not the level number. You will have to keep count yourself as you go through the file clearing/setting the fold points. Cheers Lex Let's say that I'm only interested in python code that's (close to) PEP 8 and ignore stuff like triple-quoted strings for the moment. Ok, just thought docstrings might be useful for you to show. Keeping count myself throughout the entire file is basically the only idea I had come up with. I was thinking of something fairly simple like this: * User requested to fold level 2 * Check document for HEADERFLAG's at fold level 1; found some; increment counter * Check level 2... none exist, level 3... none exist... (etc) found some at level 5 * Counter now at 2, so fold all level 5 Obviously this wouldn't scale too well for large files. But in my (limited) experience python files don't grow very large... wrong :) If its put in Geany-Plugins you *will* get bug reports if its slow with big files. Remember you are maintaining it :) If I read your above right, you are scanning the file multiple times. And what is triggering this? How often will it run and annoy your users? But if its only triggered manually I would have said its ok. But in any case, naively I would have said only one scan is needed using the levels from the current lexer (warning, not much thought gone into this :) level = 0 fold_level = 0 for all lines: line_level = get_fold_level_of_line() if fold_level line_level): ++level elif fold_level line_level: --level fold_level = line_level if line has header_flag: if level level_to_expand_to: unfold else fold and I personally don't like large source files anyway ;-). Again if you are making it public via G-P it needs a reasonable level of quality since its not just your files any more :) (And I suppose this functionality could be turned on/off with a setting, too.) Well, its a plugin, so it can be disabled. Thats fine. Cheers Lex How does this sound? And thanks for the pointers, too! Best, Peter ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel Again if you are making it public via G-P it needs a reasonable level of quality ___ 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] Plugin Advice
On 28 January 2014 10:00, Peter O'Malley ooomal...@gmail.com wrote: I appreciate the help, Lex. What I meant for the scanning was that it would happen twice, once to determine that, e.g. fold level 5 is actually fold level 2 and fold level 9 is actually fold level 3, and then again to do the actual folding. Ok, but you are assuming that file level say 5 will be fold level say 3 throughout the file. I think your outline of folding-as-you-go would probably work, too, and may, in fact, be better. The important thing is the algorithm comparing if the line level is greater than or less than the previous line, thats what Python actually does. Note it doesn't actually care what the numbers are, just if they increase or decrease. It would only scan when the user initiates the (un)fold all at level X action. Geany scans the whole file for the (un)fold all action already, and given that that doesn't take too long, I'm guessing that this wouldn't either. But I haven't tried it out yet. Ok, scanning all but *very* big files will likely be less than the time to re-render the screen. Cheers Lex Peter On Sat, Jan 25, 2014 at 3:13 PM, Lex Trotman ele...@gmail.com wrote: On 26 January 2014 02:53, Peter O'Malley ooomal...@gmail.com wrote: On Fri, Jan 24, 2014 at 2:29 PM, Lex Trotman ele...@gmail.com wrote: ... 4) The folder would have to always count increases/decreases from the start of the file to actually get a level that counts correctly or save state on the file. At the moment it starts from near the start of the visible range most of the time to make it faster, and saves no state so it only knows the actual indentation, not the level number. You will have to keep count yourself as you go through the file clearing/setting the fold points. Cheers Lex Let's say that I'm only interested in python code that's (close to) PEP 8 and ignore stuff like triple-quoted strings for the moment. Ok, just thought docstrings might be useful for you to show. Keeping count myself throughout the entire file is basically the only idea I had come up with. I was thinking of something fairly simple like this: * User requested to fold level 2 * Check document for HEADERFLAG's at fold level 1; found some; increment counter * Check level 2... none exist, level 3... none exist... (etc) found some at level 5 * Counter now at 2, so fold all level 5 Obviously this wouldn't scale too well for large files. But in my (limited) experience python files don't grow very large... wrong :) If its put in Geany-Plugins you *will* get bug reports if its slow with big files. Remember you are maintaining it :) If I read your above right, you are scanning the file multiple times. And what is triggering this? How often will it run and annoy your users? But if its only triggered manually I would have said its ok. But in any case, naively I would have said only one scan is needed using the levels from the current lexer (warning, not much thought gone into this :) level = 0 fold_level = 0 for all lines: line_level = get_fold_level_of_line() if fold_level line_level): ++level elif fold_level line_level: --level fold_level = line_level if line has header_flag: if level level_to_expand_to: unfold else fold and I personally don't like large source files anyway ;-). Again if you are making it public via G-P it needs a reasonable level of quality since its not just your files any more :) (And I suppose this functionality could be turned on/off with a setting, too.) Well, its a plugin, so it can be disabled. Thats fine. Cheers Lex How does this sound? And thanks for the pointers, too! Best, Peter ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel Again if you are making it public via G-P it needs a reasonable level of quality ___ 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] Plugin Advice
On Fri, Jan 24, 2014 at 2:29 PM, Lex Trotman ele...@gmail.com wrote: ... 4) The folder would have to always count increases/decreases from the start of the file to actually get a level that counts correctly or save state on the file. At the moment it starts from near the start of the visible range most of the time to make it faster, and saves no state so it only knows the actual indentation, not the level number. You will have to keep count yourself as you go through the file clearing/setting the fold points. Cheers Lex Let's say that I'm only interested in python code that's (close to) PEP 8 and ignore stuff like triple-quoted strings for the moment. Keeping count myself throughout the entire file is basically the only idea I had come up with. I was thinking of something fairly simple like this: * User requested to fold level 2 * Check document for HEADERFLAG's at fold level 1; found some; increment counter * Check level 2... none exist, level 3... none exist... (etc) found some at level 5 * Counter now at 2, so fold all level 5 Obviously this wouldn't scale too well for large files. But in my (limited) experience python files don't grow very large... and I personally don't like large source files anyway ;-). (And I suppose this functionality could be turned on/off with a setting, too.) How does this sound? And thanks for the pointers, too! Best, Peter ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Plugin Advice
On 26 January 2014 02:53, Peter O'Malley ooomal...@gmail.com wrote: On Fri, Jan 24, 2014 at 2:29 PM, Lex Trotman ele...@gmail.com wrote: ... 4) The folder would have to always count increases/decreases from the start of the file to actually get a level that counts correctly or save state on the file. At the moment it starts from near the start of the visible range most of the time to make it faster, and saves no state so it only knows the actual indentation, not the level number. You will have to keep count yourself as you go through the file clearing/setting the fold points. Cheers Lex Let's say that I'm only interested in python code that's (close to) PEP 8 and ignore stuff like triple-quoted strings for the moment. Ok, just thought docstrings might be useful for you to show. Keeping count myself throughout the entire file is basically the only idea I had come up with. I was thinking of something fairly simple like this: * User requested to fold level 2 * Check document for HEADERFLAG's at fold level 1; found some; increment counter * Check level 2... none exist, level 3... none exist... (etc) found some at level 5 * Counter now at 2, so fold all level 5 Obviously this wouldn't scale too well for large files. But in my (limited) experience python files don't grow very large... wrong :) If its put in Geany-Plugins you *will* get bug reports if its slow with big files. Remember you are maintaining it :) If I read your above right, you are scanning the file multiple times. And what is triggering this? How often will it run and annoy your users? But if its only triggered manually I would have said its ok. But in any case, naively I would have said only one scan is needed using the levels from the current lexer (warning, not much thought gone into this :) level = 0 fold_level = 0 for all lines: line_level = get_fold_level_of_line() if fold_level line_level): ++level elif fold_level line_level: --level fold_level = line_level if line has header_flag: if level level_to_expand_to: unfold else fold and I personally don't like large source files anyway ;-). Again if you are making it public via G-P it needs a reasonable level of quality since its not just your files any more :) (And I suppose this functionality could be turned on/off with a setting, too.) Well, its a plugin, so it can be disabled. Thats fine. Cheers Lex How does this sound? And thanks for the pointers, too! Best, Peter ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel Again if you are making it public via G-P it needs a reasonable level of quality ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Plugin Advice
Am 19.01.2014 22:08, schrieb Lex Trotman: On 20 January 2014 01:24, Frank Lanitz fr...@frank.uvena.de mailto:fr...@frank.uvena.de wrote: On Wed, 15 Jan 2014 19:24:31 -0800 (PST) Steven Blatnick steve8tr...@yahoo.com mailto:steve8tr...@yahoo.com wrote: 5. I am guessing geany-plugins welcomes more plugins, so long as the dev agrees to maintain their plugin. Yes. New plugins are welcome as long as they have a minimum in quality and will be maintained in future. That is *at least* a minimum quality :) Yepp. What Lex says ;) Cheers, Frank signature.asc Description: OpenPGP digital signature ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Plugin Advice
OK, thanks everyone. I will follow your advice :-). (Though I am a bit skeptical about using the scintilla API directly, but I guess that's less likely to change.) I will hopefully soon have something completed to work with, but at the moment I'm having trouble getting my plugin to compile as part of geany-plugins; for some reason GETTEXT_PACKAGE is undeclared even though LOCALEDIR is fine. Once I have enough time to sort that out I'll create a pull request so y'all can take a look and see if you're interested in it. Thanks, Peter On Fri, Jan 24, 2014 at 4:20 AM, Frank Lanitz fr...@frank.uvena.de wrote: Am 19.01.2014 22:08, schrieb Lex Trotman: On 20 January 2014 01:24, Frank Lanitz fr...@frank.uvena.de mailto:fr...@frank.uvena.de wrote: On Wed, 15 Jan 2014 19:24:31 -0800 (PST) Steven Blatnick steve8tr...@yahoo.com mailto:steve8tr...@yahoo.com wrote: 5. I am guessing geany-plugins welcomes more plugins, so long as the dev agrees to maintain their plugin. Yes. New plugins are welcome as long as they have a minimum in quality and will be maintained in future. That is *at least* a minimum quality :) Yepp. What Lex says ;) Cheers, Frank ___ 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] Plugin Advice
Le 24/01/2014 17:56, Peter O'Malley a écrit : [...] I will hopefully soon have something completed to work with, but at the moment I'm having trouble getting my plugin to compile as part of geany-plugins; for some reason GETTEXT_PACKAGE is undeclared even though LOCALEDIR is fine. Once I have enough time to sort that out I'll create a pull request so y'all can take a look and see if you're interested in it. Do you include config.h? Regards, Colomban ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Plugin Advice
Turns out I'm pretty rusty working in C... I knew it would be something silly. Thanks! I have another question: the code folding works fine, but I'm having an issue with how the fold levels are counted in python. The top block is still level 1, but the next block is level 5, I gather because it's indented four spaces. I'd prefer if it's counted as level two. I realize that due to the rules python has about indenting it makes sense for the parser to work this way. However, is there any obvious way I can change it? Or would I have to either go deep into Scintilla to fix something that isn't broken, or try to work around it at the top level? I'm basically wondering if I'm missing anything obvious. Thanks, Peter On Fri, Jan 24, 2014 at 9:12 AM, Colomban Wendling lists@herbesfolles.org wrote: Le 24/01/2014 17:56, Peter O'Malley a écrit : [...] I will hopefully soon have something completed to work with, but at the moment I'm having trouble getting my plugin to compile as part of geany-plugins; for some reason GETTEXT_PACKAGE is undeclared even though LOCALEDIR is fine. Once I have enough time to sort that out I'll create a pull request so y'all can take a look and see if you're interested in it. Do you include config.h? Regards, Colomban ___ 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] Plugin Advice
On 25 January 2014 07:20, Peter O'Malley ooomal...@gmail.com wrote: Turns out I'm pretty rusty working in C... I knew it would be something silly. Thanks! I have another question: the code folding works fine, but I'm having an issue with how the fold levels are counted in python. The top block is still level 1, but the next block is level 5, I gather because it's indented four spaces. I'd prefer if it's counted as level two. I realize that due to the rules python has about indenting it makes sense for the parser to work this way. However, is there any obvious way I can change it? Or would I have to either go deep into Scintilla to fix something that isn't broken, or try to work around it at the top level? I'm basically wondering if I'm missing anything obvious. Deep in LexPython.cxx :) But consider: 1) The level number the folder produces is for folding purposes, not Python syntax, so for eg successive lines of triple quoted strings have the level increased by one to cause the string to be foldable, even though the actual source is not indented further. 2) The folder only works for PEP8 styled files, some legal but non-PEP-8 implicit or explicit line continuation situations are folded wrongly 3) An increase in the level number is the fold point, not what the number's value is. Or you could read the SC_FOLDLEVELHEADERFLAG flag which erm ... flags the start of a fold. 4) The folder would have to always count increases/decreases from the start of the file to actually get a level that counts correctly or save state on the file. At the moment it starts from near the start of the visible range most of the time to make it faster, and saves no state so it only knows the actual indentation, not the level number. You will have to keep count yourself as you go through the file clearing/setting the fold points. Cheers Lex Thanks, Peter On Fri, Jan 24, 2014 at 9:12 AM, Colomban Wendling lists@herbesfolles.org wrote: Le 24/01/2014 17:56, Peter O'Malley a écrit : [...] I will hopefully soon have something completed to work with, but at the moment I'm having trouble getting my plugin to compile as part of geany-plugins; for some reason GETTEXT_PACKAGE is undeclared even though LOCALEDIR is fine. Once I have enough time to sort that out I'll create a pull request so y'all can take a look and see if you're interested in it. Do you include config.h? Regards, Colomban ___ 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] Plugin Advice
On 20 January 2014 01:24, Frank Lanitz fr...@frank.uvena.de wrote: On Wed, 15 Jan 2014 19:24:31 -0800 (PST) Steven Blatnick steve8tr...@yahoo.com wrote: 5. I am guessing geany-plugins welcomes more plugins, so long as the dev agrees to maintain their plugin. Yes. New plugins are welcome as long as they have a minimum in quality and will be maintained in future. That is *at least* a minimum quality :) Cheers Lex Cheers, Frank ___ 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] Plugin Advice
On 14-01-15 07:02 PM, Peter O'Malley wrote: [snip] 3) In the actual folding code I used sci_get_fold_level (and a couple other scintilla wrappers) which aren't in the plugin API so I gather my plugin may break at some point. There doesn't seem to be a way around this for what I want to do. Is this ok? You can just use the exposed Scintilla API, like: scintilla_send_message(sci, SCI_GETFOLDLEVEL, line, 0); Cheers, Matthew Brush ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] Plugin Advice
[...] 1) The submenu is in the tools menu, but I feel it would be better in the Document menu underneath the existing folding functions. Is this a good idea, and if so, how to I get at the document menu (since I can't say geany-main_widgets-tools_menu)? In general its not a good idea to hide your menu items in existing menus, users don't know where to look. 2) I didn't set the keybindings since it's not recommended as it may interfere with existing ones. Is there a way to set them if the given key is not in use, or is that a bad idea? How do you know that the user hasn't defined this key for the *next* plugin to be loaded after yours, the loading order is not defined? No, bad idea. 3) In the actual folding code I used sci_get_fold_level (and a couple other scintilla wrappers) which aren't in the plugin API so I gather my plugin may break at some point. There doesn't seem to be a way around this for what I want to do. Is this ok? No, as you say the plugin may break in the future and it won't work on windows IIUC. Ask on the dev ML for what you need in the API, it may be able to be added. 4) Is there another plugin out there that does this? I couldn't find one. 5) Would geany-plugins accept another plugin? As Steven said, if you commit to maintaining it, most likely. Cheers Lex Thanks, Peter O'Malley ___ 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