SciLexer

From wiki.visual-prolog.com

Revision as of 16:47, 21 November 2012 by Thomas Linder Puls (talk | contribs) (Category)

Template:Preliminary Documentation

The sciLexer provides comprehensive bindings to the Scintilla editor with language lexers. Including a lexer for Visual Prolog code.

The sciLexer is the editor in the IDE, and it is the message window in all applications (unless you explicitly use the deprecated vpiMessage window).

sciLexer internally works in utf-8 meode, but the bindings uses standard Visual Prolog string domain (utf-16).

sciLexer control

To use the sciLexer in a dialog or form simply add it as a custom control.

The contents of the editor is available as the properties text and textUtf8.

properties
    text : string.
    textUtf8 : string8.
    % @short
    % The entire text of the editor.
    % If you then save the text, you should use setSavepoint to mark the text as unmodified.
    % @end

The editor example (IDE: Help | Install Examples...) allong with other things shows how to bind menu and keyboard commands to the editor.

Lexers

Lexers are used to provide token coloring and region collapsing of for certain (programming) language.

The sciLexer have lexers for over 100 languages, including Visual Prolog.

The lexers for Visual Prolog, C/C++, HTML and XML are in particular easy to use.

You simply call one of the predicates:

predicates
    lexerDefault_visualProlog : ().
    lexerDefault_cpp : ().
    lexerDefault_html : ().
    lexerDefault_xml : ().
    % @short
    % Use lexer and set default styles for the lexer.
    % Before calling this predicate set style_default as desired (for exampel by calling setDefaultLexerStyle)
    % @end

To use other languages it is normally necessary to set the keywords for the language and define colors, etc. for the styles of the language. The code for the predicates mentioned above illustrates how that is done.

copy not only place plain text on the clipboard, it also places a HTML text reflects the token styling. So when you paste into HTML aware editors (like Microsoft Word) token styling will be preserved.