April 29, 2024, 10:43:51 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


CScintilla class - complete!

Started by sapero, November 03, 2006, 03:20:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

November 03, 2006, 03:20:19 PM Last Edit: November 06, 2006, 07:14:21 AM by sapero
As well as features found in standard text editing components, Scintilla includes features especially useful when editing and debugging source code. These include support for syntax styling, error indicators, code completion and call tips. [...]
Scintilla is used in your Aurora IDE, so you should like it.

I've created a wrapper class with all the messages for scintilla ;D
In this example is shown, what to do to colorize the syntax, and create automatic folding with brace highlighting
Note: the syntax highlighting is case sensitive, i don't know how to change this feature not using custom lexer.

Before you compile this project, be sure to copy scilexer.dll from \aurora\bin to \windows\system32 or project directory.
Every Scintilla method redirects your arguments to complicated execution handler where scintilla instance is checked before executing messages.

// edit: fixed SetHotSpot* methods (addred parameters)

Parker

November 03, 2006, 04:44:48 PM #1 Last Edit: November 03, 2006, 04:47:10 PM by Parker
Cool! Would you allow this to go in the official distribution? It would be a nice addition if you and Paul are okay with that.

Edit - just so you're aware, there is a SCLEX_CPPNOCASE that ignores case like Aurora.

Steven Picard

Wow! This great.  Thanks for sharing.

sapero

November 04, 2006, 02:38:08 AM #3 Last Edit: November 04, 2006, 02:56:09 AM by sapero
Parker, why not? The code itself is 12KB, the rest library size are method names defined twice (in .obj and .lib) :)
And thanks for the constant

update:sci.SetLexer(SCLEX_CPP|SCLEX_CPPNOCASE);
Some methods are with "Sci" prefix (SciUndo, SciCut, OnSc*Focus) - I've created this class first for other gui library where Undo and the rest were defined in window class, as default replacements for window messages and notifications. So born the problem, how to avoid duplicates with scintilla.

sapero

And here's second update for non-matching braces highlighting:
CSci::OnUpdateUi(SCNotification *scn)
{
static int highlighted = 0; // performance only

int pos1 = GetCurrentPos();
dstring curchar[4];
curchar[1] = 0;
curchar[0] = GetCharAt(pos1);

// if not a brace, check character to left
if (!StrFind("()[]{}", curchar))
{
pos1--;
curchar[0] = GetCharAt(pos1);
}
// if not a brace, remove brace highlight, if any
if (!StrFind("()[]{}", curchar))
{
if (highlighted) BraceHighLight(-1,-1); highlighted=0;
}
else
{
// find matching brace
int pos2 = BraceMatch(pos1, 0);
if (pos2 == -1)
BraceBadLight(pos1)
else
BraceHighLight(pos1,pos2);

highlighted = 1;
}
}

Then append these methods to CWnd::SetupSyntaxHighlighting()
sci.StyleSetFore(STYLE_BRACEBAD, 0xFF);
sci.StyleSetBold(STYLE_BRACEBAD, TRUE);

ExMember001


Zen

Sapero you are a star. I've been meaning to do this myself but never quite found the time, so you've saved me loads of trouble. Thanks a lot. Excellent job.

Lewis

sapero

Thanks, it was easy to code using macros: block copy from sci doc to .inc/append parameters in .asm.

The class has been updated - fixed SetHotSpot* methods - added parameters. Today i've played with hotspot styles, and got "wrong number of parameters" error.
hanges:SetHotSpotActiveFore(BOOL useHotSpotForeColour,COLORREF colour),int;
SetHotSpotActiveBack(BOOL useHotSpotBackColour,COLORREF colour),int;
SetHotSpotActiveUnderline(BOOL underline),int;
SetHotSpotSingleLine(BOOL singleLine),int;

Added zipped nasm source with all macros and makefile.

Bruce Peaslee

I just now have a use for this class and was fiddling around with myself. Boy, am I ever happy you have already invented the wheel! Nice work.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles