Link Search Menu Expand Document

StyleEdit.SetKeywordStyle Method

Explanation Register the style and the keyword to be applied in the style number.
Call format StyleEdit1.SetKeywordStyle( styleNo, keywordsOrRegExp, mode, fgColor [, bgColor [, fontFace [, fontKind [, fontSize ] ] ] ] )
Return value None
Arguments integer styleNo The style number to register.
The range that can be specified is from 0 to 8.
String keywordsOrRegExp Specify a keyword list or regular expression.
The keyword list is a character string in which keywords are separated by one of the characters "\ n", "\ r", "\ t", and a space.
Up to 256 keywords can be registered.
Since the condition is applied to the regular expression line by line, you cannot specify a style that spans multiple lines.
integer mode Specifies the behavior of the style.
Constant Description
StyleEdit.REGEXP Interpret the keyword as a regular expression
StyleEdit.NOCASE Case insensitive
StyleEdit.HOTSPOT Specify the hotspots ( mouse clickable style )
StyleEdit.BRACESTART Specify the start keyword for the collapsed paragraph
StyleEdit.BRACEEND Specify the end keyword for the collapsed paragraph

StyleEdit.BRACESTART and StyleEdit.BRACEEND have been added from Ver.4.1.3
integer fgColor Specify the font color with a color constant .
integer bgColor Specify the background color with a color constant .
integer fontFace Specifies the decoration attributes of the font.The value follows the FontFace property.
integer fontKind Specifies the font type. The value follows the FontKind property.
integer fontSize Specifies the font size. The value follows the FontSize property.
Exception Func-4 Invalid arguments
Example of use
    /* keyword list */
    StyleEdit1.SetKeywordStyle(0, "AXISSOFT\nアクシス\nソフト\nbiz-collections", StyleEdit.NOCASE, $RED, $STD, $BOLD, $STD, 14);
    
    /* Display URL in blue, specify hotspot */
    StyleEdit1.SetKeywordStyle(1, "http[s]*://[0-9a-z_/\\.\\-?=&~#:]+", StyleEdit.REGEXP + StyleEdit.NOCASE + StyleEdit.HOTSPOT, $BLUE);
    
    /* Specify BEGIN to END as a folding paragraph */
    StyleEdit1.SetKeywordStyle(5, "BEGIN", StyleEdit.NOCASE + StyleEdit.BRACESTART, $RED);
    StyleEdit1.SetKeywordStyle(6, "END", StyleEdit.BRACEEND, $RED);
    
Related item SetStyle, ResetStyle method

Regular expressions that can be used with StyleEdit

The regular expression specifications that can be used in the StyleEdit class are as follows. (Specifications are different from the regular expression of RegexPattern class)

.. Any character
[] One character in parentheses
[abc] matches a, b, c.
[A-Z] matches all uppercase alphabets.
[^] One character not included in parentheses
^ ^ Match at the beginning of the line
$ Match at the end of the line
* Repeat 0 or more times of the previous pattern
+ Repeat one or more of the previous pattern
\ () The part enclosed by this can be called later with \ n.
Numbers starting from 1 are assigned, and the number is specified for n.
\ n Call the part enclosed in \ (). (N is a number from 1 to 9)
\ \ Escape the metacharacters \ [] * + ^ $

Since “" is also an escape character of CRS script, when writing a regular expression in a script, overlap it like “\”. For example, if you want to match the character \, it will be “\\”.