Hello everybody,
The following code highlights prolog code statically making use of PPTextHighlighter, I leave the code to share with the community since it might be of help to someone else.
Could someone point out how can this be converted to its dynamic counterpart?; The keystroke handler for GLMTextPresentation and what model is currently being used for instance to highlight smalltalk code would be very much appreciated.
From http://bergel.eu/download/Dyla2010/dyla10_submission_4.pdf I know that it might be neccesary a fuzzy highlighter as is written at the end of the code, and it is probably the right object to use but I can not figure out where to plug it.
Thank beforehand, Jesus | text textRenderer textShower | text := 'p(Q,R):-q(R), unify_st(X, smalltalk_code), r(T).
q(Q):-d(R). q(Q).'. textRenderer := [ PPTextHighlighter new parser: PPPrologParser new;
color: 'small_atom' with: Color blue muchDarker; bold: 'small_atom'; color: 'unify_st' with: Color green muchDarker;
bold: 'unify_st'; color: 'string' with: Color gray muchDarker; color: 'number' with: Color gray muchDarker;
color: 'boolean' with: Color gray muchDarker; highlight: text asText. ]. " __
| <Renders IN> |
W GLMTextPresentation |
<Renders IN> | W
GLMMorphicRenderer "
textShower := GLMMorphicRenderer new. (textShower open: ( GLMTextPresentation new display: textRenderer; renderGlamorouslyOn: textShower; yourself )) window title: 'Prolog Editor'.
"Here I created a highlighter through the transform method of the grammar" grammar := PPPrologParser new. highlighter := grammar transform: [ :parser |
Transcript show: parser. parser class = TokenParser ifTrue: [ parser ==> [ :token |
textShower model highlight: token style range: token interval ] ] ifFalse: [ parser ] ]. text := 'p(Q,R):-q(R), unify_st(X, smalltalk_code), r(T). q(Q):-d(R). q(Q).'. pp := highlighter parse: text asText. |
This is a copy from an email I have sent but not sure is indexed in the pharo mailing list. If somebody sees it please let me know it.
Best, Jesus Nuñez ====================================================================================== Hello everybody,
The following code highlights prolog code statically making use of PPTextHighlighter, I leave the code to share with the community since it might be of help to someone else.
Could someone point out how can this be converted to its dynamic counterpart?; The keystroke handler for GLMTextPresentation and what model is currently being used for instance to highlight smalltalk code would be very much appreciated.
From http://bergel.eu/download/Dyla2010/dyla10_submission_4.pdf I know that it might be neccesary a fuzzy highlighter as is written at the end of the code, and it is probably the right object to use but I can not figure out where to plug it.
Thank beforehand, Jesus | text textRenderer textShower | text := 'p(Q,R):-q(R), unify_st(X, smalltalk_code), r(T).
q(Q):-d(R). q(Q).'. textRenderer := [ PPTextHighlighter new parser: PPPrologParser new;
color: 'small_atom' with: Color blue muchDarker; bold: 'small_atom'; color: 'unify_st' with: Color green muchDarker;
bold: 'unify_st'; color: 'string' with: Color gray muchDarker; color: 'number' with: Color gray muchDarker;
color: 'boolean' with: Color gray muchDarker; highlight: text asText. ]. " __
| <Renders IN> |
W GLMTextPresentation |
<Renders IN> | W
GLMMorphicRenderer "
textShower := GLMMorphicRenderer new. (textShower open: ( GLMTextPresentation new display: textRenderer; renderGlamorouslyOn: textShower; yourself )) window title: 'Prolog Editor'.
"Here I created a highlighter through the transform method of the grammar" grammar := PPPrologParser new. highlighter := grammar transform: [ :parser |
Transcript show: parser. parser class = TokenParser ifTrue: [ parser ==> [ :token |
textShower model highlight: token style range: token interval ] ] ifFalse: [ parser ] ]. text := 'p(Q,R):-q(R), unify_st(X, smalltalk_code), r(T). q(Q):-d(R). q(Q).'. pp := highlighter parse: text asText. |
In reply to this post by Jesus Nuñez
Hi, Sorry for the late reply. Unfortunately, the GLMTextPresentation does not support But, if you went so far, it would actually be cool if you could try to add it :)
Cheers, Doru On Mon, Mar 18, 2013 at 11:50 AM, Jesus Nuñez <[hidden email]> wrote:
"Every thing has its own flow"
|
Free forum by Nabble | Edit this page |