Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

How can I color some lines within a Scilex control?

Unread post by Ferenc Nagy »

If I execute the following code fragment with redirected standard output to a Scilex control then I get lines in the default black on white color.

Code: Select all

        S="Summary of Facts",         stdio::nl,         stdio::write(S),         stdio::nl,         stdio::writef("%10.10s = %10.10","Is Unicode",IsUnicode),         stdio::writef("%10.10s= %8d,", "Total",Count_Found),         stdio::writef("%10.10s= %8d,", "Unique",Unique_Found),         stdio::nl,         stdio::writef("%10.10s= %8d,", "Duplicates",Dupl_Found),         stdio::writef("%10.10s= %8d,", "Unexpected",More_Found),         stdio::writef("%10.10s= %8d.","Missing",Less_Found),         stdio::nl,         stdio::write(string::create(evaluated_chars,"=")),         stdio::nl,         stdio::writef("% %.",Source,Decision:value),         stdio::nl,
The plain b/w result is:
Summary of Facts
Is Unicode = false Total= 44, Unique= 44,
Duplicates= 0,Unexpected= 0, Missing= 0.
========================================================================
Which Scilexer predicate calls have I to insert into the above code to get
Summary of Facts
Is Unicode = false Total= 44, Unique= 44,
Duplicates= 0,Unexpected= 0, Missing= 0.
========================================================================
or
Summary of Facts
Is Unicode = false Total= 44, Unique= 44,
Duplicates= 0,Unexpected= 0, Missing= 0.
========================================================================
respectively?
TIA, Regards,
Frank Nagy
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

It is quite difficult.

You have to define styles with predicates like styleSetFont and then you have to apply the styles to thye text in the editor using the predicates startStyling and setStyling.

There is no way of just changing the style during writing to stdio.
Regards Thomas Linder Puls
PDC
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Is AppendText easier Than of redirected stdout?

Unread post by Ferenc Nagy »

>It is quite difficult.


I have found an appendText predicate in the help file.
Can you give me a link to an example containing
appendText, styleSetFont, startStyling and setStyling?
TIA, Regards,
Frank Nagy
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

The predicate lexerDefault_visualProlog_style in sciLexer.pro defines the styles used for Visual Prolog token coloring.

But I cannot provide links to anything that uses such styles.

The Visual Prolog token coloring is performed in a comptetely different way than what you are looking for (and secondly it is performed in C++) so that will not help.

But I guess you could (in a predicate similar to appendText):
  1. obtain the current position P1
  2. do the actual appending of text
  3. obtain the current position P2
  4. call startStyling with P1
  5. call setStyling with the "current style" and P2-P1
Regards Thomas Linder Puls
PDC
dominique f pannier
Active Member
Posts: 40
Joined: 23 Sep 2002 23:01

Unread post by dominique f pannier »

Hi Frank,

If you have time to study the mechanism of coloring a text with a lexer, look at the attached file.
It is a form in which is added a lexer.
The most interesting part for you is the "LEXER" section, and inside principally the predicate:
- clearText()
And naturally the whole predicates following on.
Attachments
displayInf.pro
(25.98 KiB) Downloaded 443 times
Regards
Dominique Pannier
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

On the way of perception

Unread post by Ferenc Nagy »

Hi Dominique,
I am on the way of perception of your code.
What is ilogObject? Where is it defined?
TIA, Regards,
Frank Nagy
dominique f pannier
Active Member
Posts: 40
Joined: 23 Sep 2002 23:01

Unread post by dominique f pannier »

Frank,

I sent to you a file which calls information from other parts of the program : ilogObject is an object of the program.
That's what does the predicate setLexerLines. Like you can see, it stores this information in the fact-variable lexerLines which will be used further in the setLexerGen predicate. So you could replace the ilogObject's call by the length of your own text.

I'm sorry, I do not have any time to extract from this code the only efficient part for understanding the mechanism, neither to translate in english the comments. I think it should be relatively easy, if you have some practice of Prolog, to understand the code from the "LEXER" section , like I told you above.

To help you in this understanding, the idea is to extract from the whole lines of the text each token contained in a line and store it in a base. It allows in a second time to apply to each token or type of token the desired style. If you need not a so sophisticated handling, you can easily derive from the code the handling of a single line :-)
Regards
Dominique Pannier
Post Reply