MaxGUITextAreaScintilla

BlitzMax Forums/Brucey's Modules/MaxGUITextAreaScintilla

Hezkore(Posted 2016) [#1]
I have a question about MaxGUITextAreaScintilla.
What exactly is it?
Does it have any syntax highlighting stuff?
The example is comes with didn't quite give me any hints, and the gadget doesn't seem to have any "special" functions, just the normal text area stuff.


Derron(Posted 2016) [#2]
It is an alternative to the textarea provided by MaxGUI.

It has syntax highlighting (support) - including BlitzMax (patched in).
It has inbuilt-undo-support (which is flawed in maxIDE which utilizes the MaxGUI Textarea).
It has some more options than the other one.

It adds variety / flexibility to choose something different.


bye
Ron


Hezkore(Posted 2016) [#3]
Where are these changes documented/demonstrated?


Derron(Posted 2016) [#4]
Should they get demonstrated (read: should Brucey write examples how to use commands the wrapper provides)? It is another textarea, no "changed maxgui-textarea".

To read about Scintilla (and its features), visit the Project-Website


bye
Ron


Hezkore(Posted 2016) [#5]
Yes I think they should get demonstrated heh.
I haven't used Scintilla so it's pretty confusing to me.
For example, at the page under "How to implement a lexer in the container" (which shows code in C or something, which I don't know) it tells me to use a "SendEditor" method, which doesn't even seem to exist in MaxGUITextAreaScintilla.
Googling around I get completely different examples telling me to do something very different in a language I don't know, with a bunch of other functions and methods that doesn't exist either.

But this seems very advanced, I was hoping for something like myTextArea.LoadLexer(file:string).

Thanks anyways.


Derron(Posted 2016) [#6]
The lexer thing has to get done in "C" ... Brucey already added the BlitzMax-Lexer for you.

If you want to add you own, you will have to modify the module-sources - just check how "BlitzMax" was added there (or "blitzbasic").


bye
Ron


Hezkore(Posted 2016) [#7]
Well the problem is I don't know how to activate ANY lexer.
BlitzMax lexer would be fine, but when I create the gadget it's just a normal text field.
It doesn't hightlight or do anything special.


Derron(Posted 2016) [#8]
Self.SetLexerLanguage("blitzmax") is what I use in wxScintilla. For the GTK-Part Brucey might have not enabled that.


I mixed the assumptions up a bit: My thoughts were based on the wxScintilla.mod-Module from Brucey for wxWidgets (which is, what I use instead of MaxGUI).

Dunno if MaxGUITextAreaScintilla is even supported on Win32/Mac - as the imports are commented out in my local repo clone of bah.mod


Nonetheless, for linux there are some functions to set styles for characters starting at "pos" for a length of "length" - so this sounds as if you would have to style / "highlight" it on your own - until Brucey exposes some more functions.


Maybe you could open up an github issue at the according module:
https://github.com/maxmods/bah.mod/issues


bye
Ron


Brucey(Posted 2016) [#9]
I have a question about MaxGUITextAreaScintilla.
What exactly is it?

It's intended as a drop-in replacement for MaxGUI's textarea gadget.

So far (as of today), it has only been implemented for the Linux GTK platform.

As a drop-in replacement, it isn't intended to do much other than support MaxGUI's interpretation of a textarea gadget - you can style a range of text, etc.
However, it does provide line-numbering, which I find highly useful in MaxIDE on Linux.


markcw(Posted 2016) [#10]
Klepto had a version for win32 - I haven't tested this.
http://www.blitzmax.com/Community/posts.php?topic=85716


Hezkore(Posted 2016) [#11]
That's pretty darn neat munch!
Thanks for finding and sharing. :)


markcw(Posted 2016) [#12]
I've got around to trying klepto's Scintilla and while it works on it's own there is something going on in the Maxide source which makes the gadget go white, no matter what I tried it was always white.

There are 3 textareas, the code, output window and sample in ide options. Even when I tried with the sample it was white. I guess this is why nobody ever released a scintilla version of Maxide for win.


Brucey(Posted 2016) [#13]
I've got around to trying klepto's Scintilla...

Looking at the code I just downloaded (which may not be the latest version) , it's leaking memory like a bucket with no bottom :-p

I'll do my own implementation for MaxGUITextAreaScintilla, which will be NG-only, since I'm modifying win32maxguiex to support "plugin" text areas.
It may be back-portable at a later date, but since NG is pointer-friendly (as opposed to Int-friendly legacy BlitzMax), it may be a mess to support both.


markcw(Posted 2016) [#14]
That would be very kind, even just for x64 would be great.

I'm actually getting used to the standard textarea now, it's not so bad if your careful with undo/redo.

There is a problem I found building Maxide in x64 though. The Find in Files window doesn't show the list of search results. I will see if I can get an example.

Meanwhile I think I should test out other win IDEs and maybe buy Blide.


xlsior(Posted 2016) [#15]
I'll do my own implementation for MaxGUITextAreaScintilla, which will be NG-only, since I'm modifying win32maxguiex to support "plugin" text areas.


Potentially enabling Scintilla based code folding in MaxIDE?


markcw(Posted 2016) [#16]
There is a problem I found building Maxide in x64 though. The Find in Files window doesn't show the list of search results. I will see if I can get an example.

Using tdm 5.1.0 64 this is working properly now in x86/x64! I was wondering if this was a fix by Brucey but have decided, or guessed, since it happened when I was using tdm 4.8.1 it must be from fixes in 5.1.0.


markcw(Posted 2016) [#17]
Actually, there is a bug here, it was working but now it's not, so it's a bit mysterious.

I found an example, it's the Maxgui docs example createlistbox.bmx so it just seems to be Listbox going blank, combobox is fine. Edit: Happens in x86/64 debug/release in win7.

Edit: Strange now it works, but sometimes only 2 of 4 items get created other times 4.


markcw(Posted 2016) [#18]
I've got around to trying klepto's Scintilla and while it works on it's own there is something going on in the Maxide source which makes the gadget go white, no matter what I tried it was always white.

Well I realized it was white because you need the dll in the same folder or installed to system, this folder is system32 or SysWOW64 on 64 bit win.

I'm still working on it, the file keeps insisting it's dirty since I replace undo/redo, when it's ready I'll fork maxide 1.44, hopefully fix memory leaks later. What tool can I use for this? Thanks.


Brucey(Posted 2016) [#19]
My Win32 build of MaxGUITextAreaScintilla is coming along nicely, now that I've worked out how to use it properly - reading the Scintilla docs helped a lot, funnily enough! :-p

And now my glue code for Win32 is almost the same as the Gtk glue - which means I can copy/paste most of the glue without requiring many changes. :o)

Well I realized it was white because you need the dll in the same folder

Glad you are winning there. ;-)

Of course, MaxGUITextAreaScintilla requires changes to Win32MaxGUIEx, rather than the apps (like MaxIDE), what with it being a factory-style drop-in replacement for the default TextArea - simply add the import and MaxGUITextAreaScintilla is used instead of the default.
This probably limits it to NG builds, because I have control over the MaxGUI modules there.

What tool can I use for this?

For finding memory leaks?
Most of the issues I saw just require a basic understand of how BlitzMax works - like converting a String to a Byte Ptr and never freeing it.
Otherwise, I dunno. I feel OS X and Linux developer tools are much stronger in this regard.


markcw(Posted 2016) [#20]
reading the Scintilla docs helped a lot, funnily enough! :-p

I'm one of those people who Googles to pick the brains of the people who have read the docs, and only read the docs as a last resort. I did find everything I needed by testing except one thing, how to set the color for matching braces. It seems there's a color for matching and also one for bad braces. Not a big deal though so I gave up.

Also I noticed there are keys that insert a ctrl character when you press ctrl+key, so I found out how to disable this to avoid an ugly mess if someone presses the wrong shortcut, the code was:
textarea.GetScintilla().SendEditor(SCI_CLEARCMDKEY, KEY_Q|(SCMOD_CTRL Shl 16), 0)
' keys list is: Q W E R I O P F G H K B M + 17 (for S) 

And are you going to provide code folding by default? I don't really use this feature so I'll add a menu option to enable it. The thing I don't like is the ugly "vline" stuff, so I may remove that. I'm not sure what they're supposed to do.

Most of the issues I saw just require a basic understand of how BlitzMax works

Thanks. I was wondering how you knew it was "leaking memory like a bucket with no bottom". I thought you were using a tool like Resource Monitor (Task manager > Performance tab).


Brucey(Posted 2016) [#21]
And are you going to provide code folding by default?

No, just a basic text area gadget - with line numbers. If you've seen my Linux MaxIDE build, it will look like that.

I suppose for the future one could extend functionality - or perhaps introduce some kind of "feature" request as part of the API. You ask the gadget if it supports "X" and if so, you can call that functionality. For example the default textarea could answer no to most requests :-)


Derron(Posted 2016) [#22]
I did not check it but isn't "v-line" a vertical ruler to indicate when 72 chars are exceeded?

If so, this is to avoid stress on your eyes because they have to move too wide when reading a very long line. My code comments are following the 72chars-limit, my code at least tries :-)


@answer no
No means no.

How to handle Undo/Redo then? MaxIDE handles it for the textarea while scintilla provides that functionality already. Needs a "canHandleXYZ"-Function then, so MaxIDE could assist for nonexisting features?

bye
Ron


markcw(Posted 2016) [#23]
No, just a basic text area gadget - with line numbers

Well good to know, nothing wrong with that as the main problem is the buggy undo/redo which is a maxide issue as I was able to reproduce it yesterday on win. My fix was to edit Method Undo and comment out SetTextAreaText and SelectTextAreaText and add SCI_UNDO same for Redo.

I also had to add in Create:TOpenCode SCI_EmptyUndoBuffer without this I could undo to an empty textarea and SCI_SetSavePoint which seems to be an autosave if at loading point thing.

I did not check it but isn't "v-line" a vertical ruler to indicate when 72 chars are exceeded?

Sorry, it's not the vline (the vline is the code folding line drawn in the margin) I meant the indentation guides which appear when code is indented, set with SCI_SETINDENTATIONGUIDES.

Also managed to fix the not saving code bug, I added to SaveSource a cursor hack as I discovered when you selectall and save it works, so I store TextAreaCursor and TextAreaSelLen then use SelectTextAreaText at the start and restore at the end. Edit: that moved the vscroll position but I found a fix, store SCI_GETFIRSTVISIBLELINE, then SelectTextAreaText to zero, then after SCI_LINESCROLL it back and SelectTextAreaText using stored cursor and sellen.

There's also some buggy use of Replace in SaveSource for CR/LF which caused a bug in scintilla [where LF seemed to be saved as] CF/CF/LF causing an extra newline when reloading the file.


markcw(Posted 2016) [#24]
I had to go back to using Replace in SaveSource because a loop through each character was way too slow on large files, but it seems to save LF as CF+LF properly now.

I fixed a bug in HighlightLine where the TSearchRequester (find in files) selects the wrong length of text. The problem was TextAreaText was returning a string that was past the line end, so I had to Find the LF to get the right length.

The biggest problem I have now is when pressing Enter or Baskspace on lines. Sometimes it enters 2 lines due to some hidden character, and sometimes the editor shows a line as ok when it's actually been deleted to the previous line thus breaking code.


markcw(Posted 2016) [#25]
Just to say I finished this now and it's working well.

My fork of Maxide is HERE. It features auto complete, code folding, better undo/redo and cpp syntax highlighting.


Dabhand(Posted 2016) [#26]

Just to say I finished this now and it's working well.

My fork of Maxide is HERE. It features auto complete, code folding, better undo/redo and cpp syntax highlighting.



*cough*

http://www.blitzbasic.com/Community/post.php?topic=103112&post=1299453

Same my end as well... Windows 10

Dabz