May 15, 2024, 11:44:30 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


A custom made scintilla lexer for ebasic

Started by sapero, October 25, 2009, 11:03:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

October 25, 2009, 11:03:10 PM Last Edit: October 28, 2009, 08:38:49 AM by sapero
I have downloaded, modified and recompilled the newest scintilla source code (v201), have added styling and folding designed for EB.
I think that there is all ok, but maybe you find a missing option (fold, color). Attached is sample editor code, scitilla control, and the c++ module.

* fixed outlining for "end sub" and "end interface"

aurelCB

Great Sapero... :)
Very useful thing for study how scintilla works.
Just one question.
I have somwhere scintilla.dll not scilexer and is smaller in size then scilexer.
I think that is version 1.5.6.0 and i understand that this dll dont have lexers.
So if i want use this dll do i must all set manualy and what is your expirience with this dll?

Aurel

sapero

Zlatko, you'll need to handle SCN_STYLENEEDED as described here
QuoteSendEditor(SCI_SETLEXER, SCLEX_CONTAINER);
ON_NOTIFY(SCN_STYLENEEDED, WINDOW_ID, OnStyleNeeded)
Translates to_SendMessage(hwndSci, SCI_SetLexer, SCLEX_CONTAINER, 0)
ONCONTROL(win, id, SCN_STYLENEEDED, &OnStyleNeeded)

sub OnStyleNeeded(),int
pointer notify = *<SCNotification>@LPARAM
settype notify, SCNotification

' from CDocumentWindow::OnStyleNeeded
_SendMessage(hwndSci, SCI_STARTSTYLING, start_pos, 0x1f)
' create a loop from start_pos to end_pos
' and use SCI_SETSTYLING to change colors

To implement folding, use SCI_SETFOLDLEVEL at the end of each line after colorizing. I have no examples for SCLEX_CONTAINER yet.

Anyway there are the newest scintilla headers for Ebasic. It will be removed when the next SDK pak will be out.

Ficko

Thanks Sapero it is very interesting.

What is your exact plan with it?

Do you want to make it a full featured alternative for "ebdev" ?

That case I would have some requests. :D

Like asm highlights, saving folding states etc. ;D


sapero

Yes, this will be an IDE, where you can create projects with mixed compiler types - ebasic code + aurora code + c/c++ code + assembly, and user defined. Here is a screenshot of the alpha stage: http://i34.tinypic.com/jj4l6c.png

Ficko

That's awesome!!!    :D

I hope you are going to use "*.ini" files not registries to support easy modifications of command line params, paths ect. !? ;)

Haim

Hello sapero
This looks very impressive!

Haim

aurelCB

Thanks Sapero :)
I know that you work on something big.
This would be great IDE...

sapero

October 27, 2009, 07:17:22 AM #8 Last Edit: October 27, 2009, 07:21:40 AM by sapero
Ficko, I'll use XML for settings and projects, because I need a tree. For example a Compiler subnode will hold all possible parameters with description:
<Compilers>
 <Compiler Name="Ebasic compiler" Path="...exe" commandline="$(CompilerPath) $(CompilerOptions) ..."
    DefaultCompilerOptions="/D WIN32">
 todo: put default options into debug/release/userdefined subnodes
   <CompilerOptions>
     <Option name="/D" Description="Defines a symbol" RequireParameter="true" />

Saving folding states is already implemented, it may slow down close/reopen all documents, because I need to force all the folds to be created: SCI_COLORIZE(0, -1).
Or, I can initialize only the last active/last opened document, and all other documents could be initialized in the background, like I did in chmmaker.

Ficko

October 27, 2009, 09:08:12 AM #9 Last Edit: October 27, 2009, 09:12:41 AM by Ficko
Quote from: sapero on October 27, 2009, 07:17:22 AM
Ficko, I'll use XML for settings and projects....
That's fair enough. :D
Quote
Saving folding states is already implemented...
I can initialize only the last active/last opened document, and all other documents could be initialized in the background...

It sounds great to let it run on a separate tread I not really know other IDE than "IDA Pro" which does things parallel not even VS does. :D - at least you have the impression it does not. -

Just couple more things I think a "muss" for a good IDE: - may you did already implement it - ;)
Block editing and code sniplets.

I hope you will have some alpha soon to play with. ;D


sapero

Sure, IDA Pro loads input files in background, but not all is working correctly (scrolling) while it is loading. PDB download is synchronous (and long), at least with ida 5.0.0.x.

I have updated the example code, added simple folding to asm lexer, added a lexer for resource files. The toolbar displays now icons in true color. When you activate main window, all opened documents will be checked for file modification (last-modified time difference up to 100ms is ignored).
File drag-drop, commandline handling, and clipboard monitoring added also.

Ficko

It works very well I am already a fan of it. ;D

I observed one little glitch.

EB accepts space as separation in some compound HL commands like VB - end if, end sub etc. -

"end sub" triggers a folding point.

sapero

October 28, 2009, 06:59:11 AM #12 Last Edit: October 28, 2009, 07:03:17 AM by sapero
Thanks for reporting. "End interface" was missing also.
I'm not sure about "else if" - I do remember having recently execution problems with this expression. Elseif is outlined and executes correctly, but "else if" creates two fold points:
if 0
print 0
elseif 2
print 2 /*active*/
else if 1
print 1
else
print "else"
endif

If you run it, it will print 2. When you remove the last else+print, it will show 1, so I think "else if" is acceptable, but not handled by the parser correctly.
It looks like the "else if" expressin moves the "if" into new line, and appends "then":if 0
print 0
elseif 2
print 2
else
if 1 then print 1
else
print "else"
endif

Ficko


remove the last else+print, it will show 1


By all respect Sir  ;D I am not able to get 1 no matter how I am twisting your sample. :D

I think the folding point is interpreted just fine only a syntax error message is missing on not correctly pared IF-ELSE-ENDIF.

This code print nothing but compiles:


A = 4
IF (A = 1) THEN
PRINT "1"
ELSEIF (A = 2)
PRINT "2"
ELSE
IF (A = 3) THEN PRINT "3"
ELSE
PRINT "ELSE"
ENDIF


This is ok:


A = 4
IF (A = 1) THEN
PRINT "1"
ELSEIF (A = 2)
PRINT "2"
ELSE IF (A = 3) THEN PRINT "3"
ELSE
PRINT "ELSE"
ENDIF


sapero

November 02, 2009, 04:33:38 PM #14 Last Edit: November 02, 2009, 06:15:18 PM by sapero
Ok, here is the requested demo of my IDE: http://www.sendspace.com/file/1h13jm (811KB). It can open, edit, find-replace, compile (no link), save. To compile anything, you will need to manually setup paths in options (edit/compilers or edit/global settings). I'm still working on settings layout, how to organize it to get easy to use templates for any compiler.
Before you run it for the first time, please copy the xml file to CSIDL_APPDATA folder (for current user).
If you want to use Microsoft c/c++ compiler, please edit Environment tree in global settings, then restart the program.
When you compile c/c++ code, all public (and supported) symbols will be undecorated. This is currently a hardcoded option.
If you open .inc file, the type (ebasic/aurora/assembler) should be detected automatically.

The current version depends on Windows XP - it uses PickIconDlg, RtlFirstEntrySList, RtlInterlockedPushEntrySList apis, and all possible text handling api's are unicode.

EDIT - fixed compiler log file.

aurelCB

Looking great , Sapero ;)
But one thing is weird .Why scintilla control flashing when i resizing window?
Is it bug in new scintilla ?
I use old 1.6.8.0 in ABasic and work fine with resizing.

sapero

It is flickering because Ebasic core message handlers erase the background. You can subclass all opened windows and eat the WM_ERASEBKGND message:
sub Start()
...
OPENWINDOW g_frame,...
SetProp(g_frame.hwnd, "LPFN2", SetWindowLong(g_frame.hwnd, GWL_WNDPROC, &MyChildProc))

sub CMdiChild::Create
...
OPENWINDOW *p,
SetProp(*p.win.hwnd, "LPFN2", SetWindowLong(*p.win.hwnd, GWL_WNDPROC, &MyChildProc))

' and the callback to add
sub MyChildProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam),LRESULT
WNDPROC proc = GetProp(hwnd, "LPFN2")
select (uMsg)
case WM_ERASEBKGND
return 0
case WM_DESTROY
SetWindowLong(hwnd, GWL_WNDPROC, proc)
RemoveProp(hwnd, "LPFN2")
endselect
return CallWindowProc(proc,hwnd,uMsg,wParam,lParam)
endsub

Ficko

Thanx Sapero looks great let's play with it! ;D

Ionic Wind Support Team

No need to subclass, see the emergence designer source, I use a scintilla control in an MDI child and prevent flickering by specifying @NOAUTODRAW|WS_CLIPCHILDREN in the styles.

Paul.
Ionic Wind Support Team

aurelCB

Thanks Paul ...
I doubt about that becose when i use controls in FB ,every control flickering like crazy :o
but with WS_CLIPCHILDREN not.

sapero

I have added automatic scrolling for drag-drop operation - http://www.sendspace.com/file/bewelp
It will start scrolling when you leave the invisible, centered rectangle inside scintilla client area - the text area.
It is 5 pixels smaller on each side, five margins to left and scrollbars are excluded. Scrolling will stop when you enter the rectangle again.

aurelCB

Sapero maby i bothering you but i find one small and maby trival problem with scintilla control.
You know that i use old 1.6.8.0 version but i try load file with your adev2 demo and same problem
is also there.
Why scintilla add one extra empty line after code is loaded?
So i load same file with emergence editor and remove last extra empty line , then save same file
again. Then load again same file with emergence editor and there is no extra empty line.
It seems that emergence editor know how remove extra last empty line.
I try file with 50 lines.
Is there any solution?
Here is way in creative how i load file:
if(len(filename) > 0)
buffer = ""
if( openfile(file1,filename,"R") = 0)
do
if(read(file1,ln) = 0)
if len(buffer) < (32766-256)
buffer = buffer + ln + chr$(13) + chr$(10)
endif
endif
until eof(file1)
closefile file1

SendMessage(w1,SCI_CLEARALL,0,0,IDC_SCI)
Setcontroltext w1,IDC_SCI,buffer
endif
endif


sapero

November 07, 2009, 01:37:59 PM #22 Last Edit: November 07, 2009, 04:08:34 PM by sapero
Probably the last byte in your file is 13 or 10, and the SCI_ConvertEols message (in CMdiChild::CreateFromFile) extends it to 13,10.

EDIT - In Emergence, when the last byte of text file is 13 or 10 - you will see additional, empty line at the end. So it must be a special (control) character interpreted by scintilla as new line character, you need to check it.

aurelCB


Ficko

Hi AurelCB

Quote
Why scintilla add one extra empty line after code is loaded?

Why you think it is happening?

I am trying to load/save files but I do not see this effect. :o

How can I reproduce that exactly?