PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: WinFBE code templates  (Read 484 times)

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8366
  • Windows 10
    • PlanetSquires Software
WinFBE code templates
« on: January 05, 2018, 09:48:20 PM »

Hi Jose, you might want to weigh in on this discussion.

I want to look at changes to the way that templates (*.fbtpl) files are handled in WinFBE. Before I make changes, I want to be 100% sure that it is the right direction to go in. I want to make creating and using templates easier for the end user.

Currently, you basically have to make a template by manually editing the .fbtpl file to include certain information on the first 4 lines of the file as well as adding an optional "|" symbol that designates where the editor should place the cursor once the file is loaded.

I would like to add two new menu options under the "File" menu. (1) Open Template... (2) Save As Template...

I also propose to add "Directives" that get inserted into the code that WinFBE will recognize. For example:

'#TEMPLATE_FILETYPE = ".bas"   (or, .xml, .rc, .inc, etc...)

'#TEMPLATE_DESCRIPTION = "CWindow: COM: Explorer Browser in a tab page"

'#TEMPLATE_SUBSYSTEM = "GUI"    (or Console)

'#TEMPLATE_CURSOR

I also envision allowing the user to save templates into subdirectories off of the main Templates folder. This will allow the user to better categorize and organize their templates. WinFBE will load the folders and into a Treeview rather than the current Listbox. As an alternative, maybe even do away with the current toolbar dropdown listbox and instead show a popup dialog that would have the treeview as well as additional options to create/change/delete the template folder and subfolder structure. Allow the user to set the template file type and template description via this dialog (versus having to enter them directly into the code as a directive).

Thoughts? Anything else that should be added/changed? Is it good enough the way it is?
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2918
    • Jos
Re: WinFBE code templates
« Reply #1 on: January 05, 2018, 10:59:38 PM »

I think that for this is better to create a project. This is what I have done with the sample projects, that are in fact templates that need to use resources such icons or a manifest. The .fbtpl templates are thought as a quick way to demonstrate how to use the CWindow class and other stuff of the framework. I also use them when I want to write a short example: I load the more appropriate for the purpose and modify it. But when you will finish the visual designer, nobody except me will use them, because nobody except me will code by hand. Power Basic has identical .pbtpl templates and I bet that I'm the only one that has written templates for it.

Therefore, I think that it would be a better idea to provide a way to store code snippets (maybe using a SQLite database), that are ready to be copied, edited or deleted. It can even be done as an external tool, as I did for the CSED editor (tool name: CSED_CODEKEEPER, see capture below). Instead of using a Listbox, as I did, you can use a TreeView. Once done, the current templates can be removed from the editor.

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8366
  • Windows 10
    • PlanetSquires Software
Re: WinFBE code templates
« Reply #2 on: January 06, 2018, 12:09:37 AM »

Thanks Jose, that makes a lot of sense. With FireFly I also had a code snippet manager. I think you're right that this would be a better long-term approach. I am going to sleep on the ideas tonight and start fresh in the morning with a plan.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Marc Pons

  • FireFly3 Registered User
  • Junior FireFly Member
  • *
  • Posts: 114
  • FF3 User
Re: WinFBE code templates
« Reply #3 on: January 06, 2018, 06:08:30 AM »

Hi Paul, Jose

when i was adapting csed to fb , i 've also imagined a better way to manage the templates for the user, my conclusion was the same as Jose reply, better use the code snippet tool...

nice also to see  "Directives" like : '#TEMPLATE_SUBSYSTEM = "GUI"    (or Console)

just a tip :  it is not the best to isolate that directives after the comment, because you loose the ability to enable/disable with comment (and to highlight correctly)

i've used interresting properties given by freebasic   the continuation line "_" in conjunction with the new line ":"
for the same king of directives i've used :      _:[CSED_COMPIL_CONSOLE]:   ' Force compile with Console!

for the freebasic code parser it is seen as a comment, so it will be ignored

but for your own treatment it is enabled,  and you still have the opportunity to disable with a comment char before or under comment block

if you are modifiying the lexer , you could have a specific highlight category for that directives too...


on that subject, have you modified the vb-lexer for the comment-block ( and nested comment blocks)?

when i've tried to do it, i was not very happy with my resulting solution,
 i was not able to have infinite levels of nested comment blocks  ( as freebasic can accept )
 my solution was only with 6 levels of nested comment blocks (each level using a specific highlight category)

receive also my best wishes for 2018  :)



 
« Last Edit: January 06, 2018, 06:14:30 AM by Marc Pons »
Logged

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8366
  • Windows 10
    • PlanetSquires Software
Re: WinFBE code templates
« Reply #4 on: January 06, 2018, 08:01:32 AM »

Hi Marc, thanks for your thoughts on this subject. I appreciate it.

For the directives, you could still comment them out. The parser would look for the directive at the start of the line so if it found two comment characters followed by the directive then it would not be a valid directive.

I did modify the scintilla source to get comment blocks to properly color, however, I heve not even attempted to do nested comment blocks. Something like that would be low on my list of priorities.

I am going to implement a code snippet manager, but it won't be for the next release. I want to finished the changes I made to the codetips/autocomplete/autoinsert code and get a new release released. I also want to switch focus back to the visual designer again.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor