I have been advancing with my lexer and it is going real well. Now there is something I would like to do but I am not sure how to approach it. I want my Lexer to style any string contained in two asterisks characters and:
1) remove the asterisks 2) convert string to bold
I would like to be able to do that internally, that means not setting up a Style state where the user would do that manually.
Can you point me in to the functions I would be using for this? Up to now I have been using a lot of sc.Match, sc.SetState, sc.ChangeState and others but I am sure this is not the correct approach for this problem.
> I have been advancing with my lexer and it is going real well. Now there
> is something I would like to do but I am not sure how to approach it.
> I want my Lexer to style any string contained in
> two asterisks characters and:
> 1) remove the asterisks
> 2) convert string to bold
> I would like to be able to do that internally, that means not setting up
> a Style state where the user would do that manually.
> Can you point me in to the functions I would be using for this?
> Up to now I have been using a lot of sc.Match, sc.SetState,
> sc.ChangeState and others but I am sure this is not the correct approach
> for this problem.
I answered this yesterday, but I don't see my answer here...
Anyway, my answer was: no, a lexer cannot change the text in the buffer, or at least it should not do it.
And it sets style ids, but it doesn't choose how a style is rendered. That's the task of Scintilla, following the settings set by its client.
It is about a source code editor, not a rich text editor: if, for example, you do a markup lexer, you can be tempted to hide the characters of the markup and show the appropriate rendering, but then it would be hard to manually remove or change the markup. It would be the task of the client to offer commands to do so... But, again, that's the wrong component to use for this task.
> I have been advancing with my lexer and it is going real well. Now there is something I
> would like to do but I am not sure how to approach it.
> I want my Lexer to style any string contained in two asterisks characters and:
> 1) remove the asterisks
> 2) convert string to bold
> I would like to be able to do that internally, that means not setting up a Style state
> where the user would do that manually.
> Can you point me in to the functions I would be using for this?
> Up to now I have been using a lot of sc.Match, sc.SetState, sc.ChangeState and others but
> I am sure this is not the correct approach for this problem.
1) A lexer cannot (or should not) change the content of the display nor hide or add characters. Beside, it isn't convenient: if it is, for example, a markup lexer, I can understand you want to show the effect and not the markup, but then the user depends on the client around Scintilla to add or remove these marks.
In this case, you are not looking for Scintilla, but for some rich text edit component...
2) A lexer doesn't change the attributes (bold, italic, font choice, size...) of the text, it only marks part of the text with a number (the lexer style id) and another part maps this number to a concrete style. It is the responsibility of the client to ensure a given id is always displayed as bold.
I am not trying to be dogmatic, just pointing out the way all the lexers (that I have looked at) work... If you need to change the way Scintilla works, well, you have to patch it. :-) (But it won't work if you aim to ship a lexer working with vanilla Scintilla.)
-- Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr -- -- -- -- -- -- -- -- -- -- -- -- -- --
> On 31/10/2012 00:28, RaptorX wrote:
>>[snip snip snip]
>> Can you point me in to the functions I would be using for this?
>> Up to now I have been using a lot of sc.Match, sc.SetState,
>> sc.ChangeState and others but I am sure this is not the correct
>> approach
>> for this problem.
> I answered this yesterday, but I don't see my answer here...
A slight delay with moderation, but really IMHO it was Google messing with Google Groups.
Your membership entry is (and was) of course fully enabled for posting, but somehow GGroups flagged that message for moderation yesterday.
I hope this does not become a trend with GGroups, I have little enough faith in User Interface 'innovations' these days... :-)
-- Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia
> A slight delay with moderation, but really IMHO it was Google messing with Google Groups.
The new groups interface has just worsened an already poor job. I tried to moderate the "spam report" using an iPad from a hotel with poor Internet. Groups defaults to a dumbed down interface when iOS is detected then loses the context when you say "pretend this is a real computer".
>> A slight delay with moderation, but really IMHO it was Google messing with Google Groups.
> The new groups interface has just worsened an already poor job. I tried to moderate the "spam report" using an iPad from a hotel with poor Internet. Groups defaults to a dumbed down interface when iOS is detected then loses the context when you say "pretend this is a real computer".
Grrrr. I stopped using my tablet pretty much all together for the web because of websites dumbing down their content, layouts and usability as if it's a 2" phone device. This is the modern day equivalent of Animated GIFs or <blink> HTML tags :)
P.S. Sorry veering off of the group's topic, this just drives me absolutely bonkers :)