Consistent styles across different lexers

View: New views
6 Messages — Rating Filter:   Alert me  

Consistent styles across different lexers

by dan.sg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm writing an editor on top of scintilla (not enough of that done IMO :), and I'd like specified styles to stay consistent across languages.

For example, if I specify that keywords should be blue and bold, I'd like that to be true for all supported languages (where it makes sense). I can't find an easy way to do this, since different id's mean different things in different lexers (brief excerpt below).

Is there something I'm missing?


                   STC_PS_NAME  5
                    STC_P_WORD  5
     STC_SCRIPTOL_COMMENTBLOCK  5
                 STC_SH_STRING  5
               STC_T3_OPERATOR  5
              STC_TCL_IN_QUOTE  5
                  STC_TEX_TEXT  5
             STC_VHDL_OPERATOR  5
                    STC_V_WORD  5

Re: Consistent styles across different lexers

by Robert Roessler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

dan.sg wrote:
> I'm writing an editor on top of scintilla (not enough of that done IMO :),
> and I'd like specified styles to stay consistent across languages.
>
> For example, if I specify that keywords should be blue and bold, I'd like
> that to be true for all supported languages (where it makes sense). I can't
> find an easy way to do this, since different id's mean different things in
> different lexers (brief excerpt below).
>
> Is there something I'm missing?

Just look at the way, say, SciTE does it - you effectively add a level
of indirection.

This means that for each language-specific .properties file (to follow
SciTE's conventions), you just map specific styles in that lexer to
values like, e.g., "$(font.base)" or "$(colour.operator)".

That way, in a global .properties file, you can define all the common
values for font face, weight, color, etc. to values that all your
supported can share (when it makes sense).

You can take a look at the global definitions in
SciTEGlobal.properties and see how those are used by some of the
individual lexer .properties files.

Robert Roessler
robertr@...
http://www.rftp.com
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Parent Message unknown Re: Consistent styles across different lexers

by dan.sg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you for the quick reply.

I was hoping to not have to roll my own level of indirection, but as long as I'm doing it, is there any interest in having this work somehow be contributed back to the project? I imagine anyone writing an editor on top of scintilla has to do this.

--
Dan
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: Re: Consistent styles across different lexers

by Robert Roessler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dan G wrote:
> I was hoping to not have to roll my own level of indirection, but as
> long as I'm doing it, is there any interest in having this work somehow
> be contributed back to the project? I imagine anyone writing an editor
> on top of scintilla has to do this.

There may be some misunderstanding here - as I was just mentioning how
SciTE does this as *an* example of how to share style information
across multiple lexers, there are 2 things to note:

1) the data structures/interpretation are in the editor ("container"),
not in Scintilla

2) *this* functionality is already present in SciTE, so it isn't
entirely clear where you would make your contribution... ;)

Robert Roessler
robertr@...
http://www.rftp.com
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: Re: Consistent styles across different lexers

by Neil Hodgson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

   Languages differ greatly in which elements and element
relationships are considered important. Scintilla could provide a few
common flags (Comment/Identifier/Literal)  for each style but this
would only provide minimal guidance to containers. For example, in C
there are string and character literals but other languages (such as
Python) don't need to make that distinction and may instead prefer to
differentiate between short and multi-line-capable literals. Or the
user may want to use ' versus " to indicate whether a literal requires
translation. I doubt there is anything achievable with reasonable
effort that will greatly assist over the range of languages supported
by Scintilla.

   Neil
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Parent Message unknown Re: Consistent styles across different lexers

by dan.sg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> ... Scintilla could provide a few common flags (Comment/Identifier/Literal) ...

That's what I meant, but didn't manage to put into words, thank you. Just something like  Keyword / Comment / String. I think that anyone writing an editor on top of Scintilla will have to deal with this issue, could be nice to have this simple, minimal functionality.

--
Dan
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest