IonicWind Software

Aurora Compiler => Software Projects => Topic started by: sapero on November 03, 2006, 03:20:19 PM

Title: CScintilla class - complete!
Post by: sapero on November 03, 2006, 03:20:19 PM
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)
Title: Re: CScintilla class - complete!
Post by: Parker on November 03, 2006, 04:44:48 PM
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.
Title: Re: CScintilla class - complete!
Post by: Steven Picard on November 03, 2006, 06:19:58 PM
Wow! This great.  Thanks for sharing.
Title: Re: CScintilla class - complete!
Post by: sapero on November 04, 2006, 02:38:08 AM
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.
Title: Re: CScintilla class - complete!
Post by: sapero on November 04, 2006, 06:30:53 AM
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);
Title: Re: CScintilla class - complete!
Post by: ExMember001 on November 05, 2006, 01:34:09 AM
Great work again sapero  8)
Title: Re: CScintilla class - complete!
Post by: Zen on November 06, 2006, 02:40:08 AM
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
Title: Re: CScintilla class - complete!
Post by: sapero on November 06, 2006, 07:20:11 AM
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.
Title: Re: CScintilla class - complete!
Post by: Bruce Peaslee on January 08, 2007, 11:56:40 AM
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.