I summarize briefly my results with colorful display using Scintilla controls.
I restricted my problem to monospace fonts inherited from the parent window of the scintilla control.
The kernel of the task is the appending of styled text.
Code: Select all
predicates
% Append styled text to the end of the contents of the control.
appendStyledText:(string Text, sci_style) procedure.
clauses
% Append styled text to the end of the contents of the control.
appendStyledText(Text,UsedStyle) :-
styleNumSym(UsedStyle,_Sym),
P1=used_lexer:currentPos,
used_lexer:addText(Text),
used_lexer:startStyling(P1,31), % Wired-in magic constant
used_lexer:setStyling(string::length(Text),UsedStyle),
!.
% Use plain style instead of unregistered style.
appendStyledText(Text,_) :-
styleNumSym(style_plain,_Sym),
appendStyledText(Text,style_plain),
!.
% Restore settings if plain style is missing.
appendStyledText(Text,_) :-
restoreSettings(),
appendStyledText(Text,style_plain).
If it is not defined then the plain style is used.
If the plain style is not defined then the default setting are restored.
Dominique's has solved a syntax coloring task. My goal is paint the lines according to their importance. I have defined the following default styles:
Code: Select all
constants
style_plain : sci_style = 0.
style_title : sci_style = 1.
style_table_header : sci_style = 2.
style_table_body : sci_style = 3.
style_table_footer : sci_style = 4.
style_name_and_value = 5.
style_error = 6.
style_warning = 7.
Code: Select all
domains
color3 = rgb(integer, integer, integer).
lex_style=les(
sci_style,
string Symbol,
color3 ForeGround, color3 Background,
boolean IsBold, boolean IsUnderlined, boolean IsItalic).
class facts - default_settings
default_setting:(lex_style) nondeterm.
clauses
default_setting(les(style_plain,"plain",rgb(0,0,0),rgb(255,255,255),false,false,false)).
default_setting(les(style_title,"title",rgb(0,0,255),rgb(255,255,255),true,false,false)).
default_setting(les(style_table_header,"table header",rgb(0,255,0),rgb(255,255,255),false,true,false)).
default_setting(les(style_table_body,"table body",rgb(0,255,255),rgb(255,255,255),false,false,false)).
default_setting(les(style_table_footer,"table footer",rgb(0,255,0),rgb(255,255,255),false,false,true)).
default_setting(les(style_name_and_value,"name and value",rgb(0,0,255),rgb(255,255,255),false,false,true)).
default_setting(les(style_error,"error",rgb(255,0,0),rgb(255,255,0),true,false,false)).
default_setting(les(style_warning,"warning",rgb(255,0,255),rgb(255,255,0),true,false,false)).
