Jelly2 - new code editor for FB (Edit: new name WinFBE)

Started by Paul Squires, September 16, 2015, 09:13:28 PM

Previous topic - Next topic

Paul Squires

It has been a bit slow around here for the past few days so I thought that I would post a preview of a program that I am working on. Jelly2 Editor will be the successor to JellyFB Editor.

A lot of functionality is not implemented yet but the core functionality is mostly there.

The full source code will be available and be able to be compiled using FireFly for FreeBASIC. I can't post the code yet because it was created with FF 3.77 that has not been posted yet. The new version contains new functionality for "localization". Basically, you can create and customize language files so that your application displays in the language of your choice. The editor allows this by selecting the applicable (*.lang) localization file (using View/Environment Options/Code Editor).

Here is what I will have in the updated FF Help file:
Quote
Projects can be created that allow the end user to select the language that they wish for the application to use. This concept, known as localization, allows the developer to create an application using the spoken language of their choice (eg. English) but have the user graphical display (menus, toolbars, statusbar, message boxes, etc) display using text based on the user's choice (for example, French or German).

You must enable support for Multilanguage projects from the "Project Properties" dialog.

During the code generation phase of a FireFly compile, FireFly will search all menus, toolbar buttons that contain text, statusbars (simple and panels), and automatically generate a file in the application folder called "default.lang". That file is a simple text file that can be viewed in any text editor. The format of the file is extremely simple. Each line represents a key/value pair separated by an equals "=" sign. The key is to the left of the equals sign and the value/data is to the right of the equals sign.

For example:

FORM1                                              =My Aplication
6000|FORM1_MNUFILE                                 =&File
6001|FORM1_MNUFILENEW                              =&New\tCtrl+N
6002|FORM1_MNUFILEOPEN                             =&Open...\tCtrl+O
6004|FORM1_MNUFILECLOSE                            =&Close\tCtrl+Q
6005|FORM1_MNUFILECLOSEALL                         =C&lose All
6007|FORM1_MNUFILESAVE                             =&Save\tCtrl+S
6008|FORM1_MNUFILESAVEAS                           =Save &As...\tF12
6009|FORM1_MNUFILESAVEALL                          =Sa&ve All
6011|FORM1_MNUFILEPRINT                            =&Print...\tCtrl+P
6013|FORM1_MNUFILERECENTFILES                      =&Recent Files
6014|FORM1_MNUMOSTRECENTLYUSED                     =Most Recently Used
6016|FORM1_MNUFILECOMMANDPROMPT                    =Co&mmand Prompt...\tCtrl+D
6018|FORM1_MNUFILEEXIT                             =E&xit
FORM1_COMMAND1                                     =Command1
FORM1_LABEL3                                       =Label3
FORM1_LABEL2                                       =Label2
FORM1_LABEL1                                       =Label1
MSGBOX_CAPTION                                     =MyMessageBox
MSGBOX_TEXT                                        =This is my message box text.\rAnd this is the second line.


To create a new localization language you simply need to make a copy of the "default.lang" file and rename it to the language of your choice (for example, French.lang or German.lang). You would then change each data portion of each line to the corresponding new language (that is, in the above example you would change "My Application", "&File", "&New\tCtrl+N", etc...).

For menu entries, do not change the keyboard accelerators. Those are the values after the "\t".

Take notice of the last two lines in the above example:

MSGBOX_CAPTION                                     =MyMessageBox
MSGBOX_TEXT                                        =This is my message box text.\rAnd this is the second line.

Those are user defined values are for a message box that is presented to the end user. The definition for these values are defined directly in the code for the program as follows:

'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     as Integer, _   ' index in Control Array
                                   hWndForm         as HWnd, _      ' handle of Form
                                   hWndControl      as HWnd, _      ' handle of Control
                                   idButtonControl  as Integer   _  ' identifier of button
                                   ) as Integer

   ' Let the programmer define a key/data multilanguage pair that FireFly
   ' will recognize during parsing.
   
   'MULTILANG: MSGBOX_CAPTION=MyMessageBox
   'MULTILANG: MSGBOX_TEXT=This is my message box text.\rAnd this is the second line.
   Select Case MessageBox( hWndForm, FF_GetLangSt("MSGBOX_TEXT"), FF_GetLangSt("MSGBOX_CAPTION"), _
                           MB_OK Or MB_DEFBUTTON1 Or MB_APPLMODAL )
      Case IDOK
   End Select

   Function = 0   ' change according to your needs
End Function


You must use the 'MULITLANG: identifier to signal to FireFly that during parsing you want the key/data that follows the label to represent a multilanguage definition to be output to the "default.lang" file. These 'MULTILANG tags do not have to appear directly next to the place where you intend to use them (although that makes reading the code much easier). You could place all of them in a separate code module or in FF_APPSTART if you wish.

Notice that for the MSGBOX_TEXT key that the data values contains a "\r" embedded "carriage return" specifier. When FireFly loads this string it will replace the \r with a Chr(13,10) in order to break the string into multiple lines.

When multilanguage support is enabled for a project, FireFly will automatically add code your project that loads your language of choice and puts the key/value pairs into an extremely small and fast hash data structure. To retrieve the text you use the built in FireFly function call FF_GetLangSt (this roughly means "Get Language String").

To load your desired language you call the built in FireFly functions called FF_LoadLanguage specifying the file name of your language to load. The file name could be hard coded or based on a user selection from, say, a listbox containing all of the available translated language files available. For best results, this function must be called in FF_APPSTART.

' Define the language file that we will use for our multilanguage support
FF_LoadLanguage("French.lang")



Good luck! Hopefully the Jelly2.exe will work on your system.
Paul Squires
PlanetSquires Software

Marc Pons

Hi Paul

Tested , and works under XP sp3 , vista

I've immediatly tested the copy/paste with multiples lines (you know why) it works perfectly...

hope to have soon the FF 3.77 and the source code to play with.

I've done some adaptations on the Jose Roca CSED editor to be a FreeBasic editor and some extentions:

code beautifier , embedded RC , dead code comment , direct connection to FF generated source files ,
direct dll  or lib creation
all done with powerbasic , if you need the code , do not hesitate

I also noticed, you are using the SciLexer.dll , is it a specific version adapted to FreeBasic?
or the PowerBasic/VisualBasic , I've also adapted one to work better with the comment blocks  /'...'/, labels, more keywords categories...

I'm also ready to help debugging...

regards / Marc

Paul Squires

Thanks Marc - I was hoping that you would be interested in this project  :)

The SciLexer that I am using is simply the one that Jose uses for CSED. I am using that for testing until the editor gets more developed. If you have a better more FreeBASIC centric lexer available then I would love to have it. I have my GCC environment configured so that I can create 32 and 64 bit versions of the Scintilla DLL.

I intend to leave the "Project" functionality to last. I need to try out many other editors and also seek suggestions from the community as to the best way to implement the Project stuff.



Paul Squires
PlanetSquires Software

Marc Pons

#3
hi Paul
here the lexer , i have modified  (lexVB.cxx  + some other files)

**   improved labels , string escape sequences , 3 new keywords categories (0 to 6)
**   comments after preprocessor  in the same line...

**   5 levels of imbricated Comment_block categories( const 19 and 28 to 31) + special Warning (27)
        1 static var   ( via set_firo ; get_firo functions ) able to be get from  prog
         to warn when block comment level exceeds 5 levels   if exceeds value = 99

   usage interface prog ( PB example) to acess the static var in the dll
   ' ========================================================================
   FUNCTION SCI_GET_FIRO (BYVAL hSci AS DWORD ) AS LONG
      FUNCTION = SendMessageA(hSci, 9999,0,0)
   END FUNCTION
   ' ========================================================================
   ' ========================================================================
   FUNCTION SCI_SET_FIRO (BYVAL hSci AS DWORD, BYVAL value1 AS LONG) AS LONG
      FUNCTION = SendMessageA(hSci, 9998, value1, 0)
   END FUNCTION


note :in fact you can define colors for each comment-block level

have a look in my csed_fb posted here in the forum to test the effect

the only point i'm not completly satisfied with, is the global folding way ( indentation dependant)
it is not complete , it would be nice to check also the function/sub/type ...  organization

it is also to avoid that folding points , i've done a beautifier in csed_fb !

to compile  in batch mode :  in   _Auto_Make.bat adapt to your c/c++ path
In don't know if it is 64 bit compliant


Marc Pons

Paul to continue

here the complete source code for Csed_fb 
( + the tool to re-launch it , interresting to modify the lang setting )

I've done many modifications from the original coming from Jose ( thanks again)
but i was not very well organized to maintain these evolutions ( it began only for my own usage)

it could be interresting for you for a direct connection with FF and other stuff

Paul Squires

Hi Marc, thanks for the code :)

I have downloaded all of your stuff but I am not yet ready to implement the syntax coloring and code folding (basically, the lexer). I have a lot done since the last exe that I posted. I just need to finish the Replace dialog code and then I will upload the source code. The editor is really coming along very nicely.
Paul Squires
PlanetSquires Software

Paul Squires

Lots done today. Need to work on the Compile/Run code. Should be able to borrow a lot from FireFly for that stuff. After that it is on to the syntax highlighting and code folding eventually ending with CodeTips.

I will also be changing the name of the editor so if you have any great ideas then please let me know. It will probably be an obscure animal name. I have used Jelly too much over the years and I want this editor to be new and fresh.

I will also be putting the source code on GitHub.

:)


Paul Squires
PlanetSquires Software

Paul Squires

Paul Squires
PlanetSquires Software

Paul Squires

Updated the Jelly2 attachment in the original post to the most latest exe that I compiled tonight. Editor is starting to take shape now.
Paul Squires
PlanetSquires Software

Marc Pons

hi Paul

fedit is very similar to existing : fbedit , wich is used for years by fb guys

and not so far to fbide also old ide

why not continue with parent name   with Fire something   or Fly something

I aggre better not connect again to Jelly

But , you can decide that's your baby

For the features : I have in mind one very good editor for C/C++  Java... but not basic unfortunatly
C-Free5, it works with files only or projects 
it shows the var , func , types ... of the opened files or project
it shows in the funct , the  var underlined  when declared or function parameters...
it gets the declare (under cursor) , the reference  , the definition ...
many windows and tools ,but for me much more simple to use than codeblock , it could be a good inspiration for yours
it can be downloaded for free (30 days usage) , it is also a reduced features for free but the C-Free5 is much better

Paul Squires

Thanks Marc, I have never heard of C-Free5 before. Thanks for turning me on to it. I will download the evaluation copy and see what functionality it has.  :)
Paul Squires
PlanetSquires Software

Marc Pons

for features :
think about source code beautifier , direct connection to firefly generated files (as a project),
the direct access to code warnings or errors from the result pad (freebasic compiler show the list),
and even incorporate the debugger ( check from Sarg , he posted his source in freebasic forum)
I've been dreaming to incorporate it into csed_fb but , it is lot of work to do...

something also nice to have is the tracking of the modifications (c-free5 or FBedit do that by coloring the left part of the line in source pane in different colors)

José Roca

There is a problem with the combo boxes.

Paul Squires

...I think that I forgot to apply afxScale to them  :)
Paul Squires
PlanetSquires Software

Gary Stout

Quote from: TechSupport on September 22, 2015, 06:20:28 PM
I will also be changing the name of the editor so if you have any great ideas then please let me know.
:)

Just don't have it begin with EZ and post page after page of the same old stuff  :o even though we all know FF is superior!!!

Gary