Public Member Functions | |
_.Library.Boolean | Attributes (Language, _.Library.List Attributes) |
_.Library.Boolean | Color (_.Stream.Object InStream, _.Stream.Object OutStream, _.Library.String Language, _.Library.String Flags, _.Library.String DefFg, _.Library.String DefBg, _.Library.String Langs, _.Library.Boolean ColoringErrors, _.Library.String ErrorEnv, _.Library.Boolean ColoringWarnings, _.Library.String Symbols) |
_.Library.Boolean | GetCSS (_.Stream.Object OutStream, _.Library.String Language, _.Library.Integer Format) |
_.Library.Boolean | Languages (_.Library.List Languages) |
![]() | |
_.Library.Status | OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount) |
This callback method is invoked when the current object is added to the SaveSet,. More... | |
_.Library.Status | OnConstructClone (_.Library.RegisteredObject object, _.Library.Boolean deep, _.Library.String cloned) |
This callback method is invoked by the <METHOD>ConstructClone</METHOD> method to. More... | |
_.Library.Status | OnNew () |
This callback method is invoked by the <METHOD>New</METHOD> method to. More... | |
_.Library.Status | OnValidateObject () |
This callback method is invoked by the <METHOD>ValidateObject</METHOD> method to. More... | |
Static Public Member Functions | |
_.Library.String | Join (_.Library.List SubStrings, _.Library.String Delimiter) |
_.Library.String | PathToDLL (_.Library.Boolean SixtyFour) |
_.Library.Boolean | SameLanguage (_.Library.String Lang1, _.Library.String Lang2) |
_.Library.String | SymbolsString (_.Library.Boolean ProcedureBlock, _.Library.List ParameterNames, _.Library.List PublicNames) |
Public Attributes | |
DLLCallMode | |
DLLHandle | |
More... | |
DLLResultCode | |
NoStyleNameUnderscore | |
Static Public Attributes | |
ORDINALATTRIBUTES = None | |
![]() | |
CAPTION = None | |
Optional name used by the Form Wizard for a class when generating forms. More... | |
JAVATYPE = None | |
The Java type to be used when exported. | |
PROPERTYVALIDATION = None | |
This parameter controls the default validation behavior for the object. More... | |
Private Member Functions | |
_.Library.Status | OnClose () |
This callback method is invoked by the <METHOD>Close</METHOD> method to. More... | |
_.Library.String | __ConfigName () |
_.Library.List | __InvokeDLL (_.Library.Integer DLLFunction, DLLArgs) |
_.Library.String | __ZF5 (_.Library.Integer handle, _.Library.Integer DLLFunction, DLLArgs, _.Library.Boolean failed) |
_.Library.String | __ZF6 (_.Library.String DLLPath32, _.Library.String DLLPath64, _.Library.Integer DLLFunction, DLLArgs, _.Library.Boolean failed) |
Static Private Member Functions | |
_.Library.String | __Assignments (_.Library.List NameValues, _.Library.List SymbolKinds) |
Syntax color source code, generating HTML markup and stylesheets.
Note that this class is only available in Windows (both 32-bit and 64-bit) at present.
|
private |
This callback method is invoked by the <METHOD>Close</METHOD> method to.
provide notification that the current object is being closed.
The return value of this method is ignored.
Reimplemented from RegisteredObject.
|
staticprivate |
Given a list of names or 'name=value' strings and a list of symbol kinds (not documented)
Return a linefeed-delimited list of assignments to the names for each name/kind combination
_.Library.Boolean Attributes | ( | Language, | |
_.Library.List | Attributes | ||
) |
Return a $List of coloring attribute names for the given language
The first name corresponds to attribute #0 in the K-flag JSON output
The language can be passed as a numerical index or as a canonical language moniker as returned by <METHOD>Languages</METHOD>
_.Library.Boolean Color | ( | _.Stream.Object | InStream, |
_.Stream.Object | OutStream, | ||
_.Library.String | Language, | ||
_.Library.String | Flags, | ||
_.Library.String | DefFg, | ||
_.Library.String | DefBg, | ||
_.Library.String | Langs, | ||
_.Library.Boolean | ColoringErrors, | ||
_.Library.String | ErrorEnv, | ||
_.Library.Boolean | ColoringWarnings, | ||
_.Library.String | Symbols | ||
) |
Syntax color the given source code using the given language.
Note that this class is only available in Windows (both 32-bit and 64-bit) at present.
InStream is a stream containing the source code, we rewind it before using it
OutStream is a stream to which the HTML (or CSV) is written (not the stylesheet - you need to use GetCSS for that)
Language is the lang moniker for the language (e.g. "BAS", "JS", "COS", "HTML"). The default is "COS"
Flags is a string of flag letters. A flag letter can be followed by "=" and a list of subflags (terminated by a ",").
DefFg and DefBg are ignored if stylesheets are used. When stylesheets are not used DefFg and DefBg are HTML color codes in hex #xxxxxx format (i.e. they should be passed as strings). They default to black and white, respectively. They are used whenever a color is specified as "default foreground" or "default background" in the Studio registry settings.
Langs is returned with a list of language monikers used (so you know what stylesheets to request) - e.g. $LB("COS","HTML")
ColoringErrors is returned with 0 if there were no syntax coloring errors, 1 otherwise
Some flags only apply to certain output modes (HTML/CSV/XML). Supported flags are :-
S/s (HTML) specifies that stylesheets should be used, otherwise it just embeds FONT settings into the marked up source
P/p (HTML) suppresses the enclosing <PRE>...</PRE>
F/f (HTML) suppresses the outer <FONT>...lt;/FONT> which sets the default foreground and background
I/i (HTML) inserts an HTML comment just before </PRE> (or the error messages section) if present, otherwise at the end of the output; the comment contains information about the parsers used and the HTML rendering
I/i (CSV) inserts "\i" followed by parser information at the end of the output
I/i (XML) writes an <info info="..."/> tag at the end of the output (before </color>) with the parser information as the attribute value
U/u (HTML) suppresses the "_" character in style names
C/c selects CSV output (see below)
Q selects XML output (but if C/c is given as well Q flag is ignored)
The Q can be followed by "=" and one or more (case-sensitive) subflags to tailor the XML output :-
P .. include XML prolog ("<?xml...") at start of output
L .. include source language in the XML tag name - e.g. <COS_Command>
l .. include source language as an XML attribute - e.g. <Command language="COS">
N .. wrap XML tags for each source line in <line>...</line> tags
n .. use <newline/> tags to mark line-breaks
Notes:
If neither L nor l is given the attribute language is not shown.
If neither N nor n is given the line-breaks are not shown.
E/e (ALL) includes empty source lines in the output
A/a (CSV) outputs attribute descriptions instead of hexadecimal codes
B/b (CSV) outputs both a hexadecimal code and an attribute description, separated by a "|" character
R/r (HTML) inserts one or more HTML comments just before </PRE> if present, otherwise at the end of the output; the comments contain coloring error messages returned by the parsers
R/r (CSV) inserts one or more lines at the end of the output, each consisting of "\e " followed by a tab-delimited record made up of the fields of a parser coloring error :- description,source,location,linenumber,lineoffset (linenumber and lineoffset are 1-based) (any tab character in the original error info is converted to a space)
R/r (XML) writes one or <error message="..."/> tag at the end of the output (before </color>) with parser coloring error messages as the attribute values
CSV output writes a line to the output stream for each syntax element and for each special element :-
a syntax element is written as a record with commas delimiting the three components :-
the first component is the language name - e.g. COS
the second component is the terminal index in base 16 - e.g. 2F
the third component is the source code fragment
Note that the third component can contain commas.
a special element begins with "\" :-
"\n" indicates newline in the source
"\i " precedes an information line, shown when the I flag is given
The S, P, F and U flags and the DefFg and DefBg parameters are ignored when CSV/XML output is selected.
The method returns 1 if it succeeded in generating the required HTML, CSV or XML; 0 if it failed to do so. In the case of failure the DLLResultCode property will sometimes contain a message with more information about the failure.
Typical use :-
Set instr=##class(GlobalCharacterStream).New() Do instr.WriteLine(" &SQL(SELECT * FROM A WHERE B=C)") Set outstr=##class(GlobalCharacterStream).New() Set colorer=##class(SyntaxColor).New() Set ret=colorer.Color(instr,outstr,"COS","PFS",,,.langs,.coloringerrors) If 'ret {Write "Fatal error: ",colorer.DLLResultCode,! Quit} If coloringerrors { Write "Syntax error(s)",! } Do outstr.Rewind() While 'outstr.AtEnd { Write outstr.ReadLine(),! }
|
private |
Helper function to return the InterSystems IRIS configuration name.
_.Library.Boolean GetCSS | ( | _.Stream.Object | OutStream, |
_.Library.String | Language, | ||
_.Library.Integer | Format | ||
) |
Generates a CSS stylesheet for the given language moniker.
Note that this class is only available in Windows (both 32-bit and 64-bit) at present.
OutStream is a stream to which the stylesheet is written
Language is the language moniker (e.g. "COS" or "BAS")
The method returns 1 if it succeeded in generating the required stylesheet, 0 if it failed to do so. In the case of failure the DLLResultCode property will sometimes contain a message with more information about the failure.
Underscores are suppressed in the style names if either Color was last called with this flag OR if you explicitly set NoStyleNameUnderscore before calling this method
Typical use (continues on from the <METHOD>Color</METHOD> example) :-
Set css=##class(GlobalCharacterStream).New() For i=1:1:$ListLength(langs) D colorer.GetCSS(css,$List(langs,i)) Do css.Rewind() While 'css.AtEnd { Write css.ReadLine(),! }
|
private |
Invoke the CacheColorHTML DLL function (DLLFunction), passing DLLArgs.
Returns what the $ZF call into the DLL returns, or something in the same format :-
$LISTBUILD(ZFOK, $LISTBUILD(Lang1, Lang2, ...), ColoringErrors, DLLResultCode)
|
static |
Given a list of strings: combine the ones which are non-empty, separating them using the given delimiter
_.Library.Boolean Languages | ( | _.Library.List | Languages | ) |
Return a $List of canonical language monikers
The first moniker corresponds to language #0 in the K-flag JSON output
|
static |
Return the path to the DLL
|
static |
Return whether two Studio language monikers are for the same language (ignoring moniker extensions)
|
static |
Given the procedure block setting and optional lists of parameter and public names (with optional '=xxx' tails)
Return a string suitable for passing as a Symbols parameter to <METHOD>Color</METHOD>
ProcedureBlock must be omitted or passed as 1 for coloring warnings to be available
- if ProcedureBlock is "" the PROCBLOCK symbol is not set at all
|
private |
Sets failed to 1 if the $ZF(-5,..) call fails, otherwise sets it to 0 and returns the DLL return code
|
private |
Sets failed to 1 if the $ZF(-6,..) call fails, otherwise sets it to 0 and returns the DLL return code
|
static |
Syntax color source code, generating HTML markup and stylesheets.
Note that this class is only available in Windows (both 32-bit and 64-bit) at present.
DLLCallMode |
How we call the DLL
Takes one of the following values :-
1 - use $ZF(-3) ... handy for debugging the DLL because it doesn't stay loaded
2 - use $ZF(-4)/$ZF(-5) ... to cache the DLL handle
3 - use $ZF(-4)/$ZF(-6) ... the default - there's normally no reason to change it
Initialised to 3
DLLHandle |
The cached DLLHandle (used only when DLLCallMode=2)
DLLResultCode |
Set to a result code string returned by CacheColorHTML.DLL.
Mainly of use to Intersystems support.
NoStyleNameUnderscore |
Set to the underscore-suppression flag as last used in a call to Color
- so that we can pass it to GetCSS