如何自定义折叠部分关键字和括号高亮匹配.

Topics: Developer Forum, Project Management Forum, User Forum
Dec 11, 2009 at 7:03 AM
Edited Dec 11, 2009 at 11:28 AM

英语实在不好,所以用汉语描述一下,如果碰巧你们能看懂就更好了。
一共两个问题:
1、如何自定义折叠关键字,比如,我要在 scintilla1.ConfigurationManager.Language = "cs"; 的时候让其也支持 select...from的折叠样式 ,效果如图: http://218.25.154.154:8081/temp/a.jpg

2、如何自定义括号匹配,比如,我要在 scintilla1.ConfigurationManager.Language = "mssql";的时候其支持  ()的高亮匹配。

My English is poor, so I use Chinese to describe, if you can understand better,That would be great.
Now  There are two problems:

1, how to customize folding keyword, for for example . I want to be in  [scintilla1. ConfigurationManager.Language = "cs." ]    also support the [select... From]  effect, the folding style as http://218.25.154.154:8081/temp/a.jpg:

2 how to customize brace to highlight matching , for example, I  want to be in [scintilla1. ConfigurationManager.Language = "mssql" ]  also support   ( ... )    highlight matching.

 

Developer
Dec 11, 2009 at 10:00 AM
Edited Dec 11, 2009 at 10:01 AM

Hi I can only reply to the second point:

Brace matching should be achieved with the Property

Scintilla.IsBraceMatching = true
  and in
Scintilla.Styles.BraceBad 
Scintilla.Styles.BraceLight

Then your Braces should be highlighted when you set the cursor to a pair:

 

But I guess you can not use the cs (cpp) lexer for folding the keywords you want, without writing / modifying a new Lexer.

Best Regards

Dec 11, 2009 at 11:37 AM

 Klingel : Thank you
 I'm sorry, I was wrong at the second point。 I fix it。
2.how to customize brace to highlight matching , for example, I  want to be in [scintilla1. ConfigurationManager.Language = "mssql" ]  also support   ( ... )    highlight matching.

Developer
Dec 14, 2009 at 1:15 PM
Edited Dec 14, 2009 at 1:21 PM

So after a little Research I just found out, that there must be some unexpected issues in Scintilla.cs "PositionIsOnComment".

There are some If-Else Statements that return true, where they should return false.

ca. line 3292

 

else if ((lexer == Lexer.Flagship)
&& style == 1
|| style == 2
|| style == 3
|| style == 4
|| style == 5
|| style == 6)
{
return true; // flagship
}

 

My Lexer is set to MSSQL but the above Statements still returns true. If I add some parentheses ( ) after the && I get the expected result of false.
I've not teste if, it works with the matching of the Braces but I guess this should be copied to a work Item.

Perhaps Chris can say more about your problem.

So long & Best regards

Klingel

Edit:

So I just tested it, if you want to match simple praentheses ( ) just clip the above Code (Scintilla.ca ca. line 3292) after the && with extra braces:

else if ((lexer == Lexer.Flagship)
&& (style == 1
|| style == 2
|| style == 3
|| style == 4
|| style == 5
|| style == 6))
{
return true; // flagship
}

Now you should get the Brakets highlighted.

Dec 15, 2009 at 10:20 AM

Great!! it  so good!thanks a lot.