Difference between revisions of "LGUI2:Text Scanners"

From Lavish Software Wiki
Jump to navigation Jump to search
(Created page with "A LavishGUI 2 Text Scanner is responsible for altering text appearance, usually highlighting based on the content of the text itself. LavishGUI 2 currently provides 3 Tex...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
A [[LavishGUI 2]] Text Scanner is responsible for altering text appearance, usually highlighting based on the content of the text itself.
+
A [[LavishGUI 2]] Text Scanner selects a [[LGUI2:Text Type|Text Type]] and any related options for decorating text, such as colors and fonts for special portions of text (for example, syntax highlighting).
 +
 
 +
Each LavishGUI 2 Element with Text (any [[LGUI2:commandbox|commandbox]], [[LGUI2:textbox|textbox]], [[LGUI2:textblock|textblock]]) can have its own Text Scanner defined.
  
LavishGUI 2 currently provides 3 Text Scanner types:
 
* '''raw''': No alterations
 
* '''character''': Highlights specific characters, with specified colors, independent of any context. As such, this scanner can handle any text format, though in a simplified way
 
* '''json''': Highlights specific characters recognized by JSON parsers, with specified colors, currently independent of context (as with the "character" scanner)
 
  
 
== Defining a Text Scanner ==
 
== Defining a Text Scanner ==
 +
A Text Scanner is defined as a JSON Object, usually as part of an [[LGUI2:Element|Element]] (currently including [[LGUI2:commandbox|commandbox]], [[LGUI2:textbox|textbox]], [[LGUI2:textblock|textblock]])
 +
  
 
{| border="1" style="border-collapse:collapse" cellpadding="5"
 
{| border="1" style="border-collapse:collapse" cellpadding="5"
Line 12: Line 12:
 
|-
 
|-
 
! type
 
! type
| The type of the Text Scanner. Currently one of "raw", "character", or "json"
+
| The [[LGUI2:Text Type|Text Type]], usually a type of container, to process text as
|-
 
!colspan="2"|"raw" Text Scanner properties
 
|-
 
|colspan="2"|"raw" Text Scanner has no properties.
 
|-
 
!colspan="2"|"character" Text Scanner properties
 
|-
 
! characters
 
| A JSON object which maps individual characters such as "{" each to a [[LGUI2:Color|Color]]. Example: <tt>{ "{": [1.0,0.0,0.0], "}": [0.0,1.0,0.0] }</tt>
 
|-
 
!colspan="2"|"json" Text Scanner properties
 
|-
 
!{
 
| A [[LGUI2:Color|Color]] definition specifying the color for this character
 
|-
 
!}
 
| A [[LGUI2:Color|Color]] definition specifying the color for this character
 
|-
 
![
 
| A [[LGUI2:Color|Color]] definition specifying the color for this character
 
|-
 
!]
 
| A [[LGUI2:Color|Color]] definition specifying the color for this character
 
|-
 
!,
 
| A [[LGUI2:Color|Color]] definition specifying the color for this character
 
|-
 
!"
 
| A [[LGUI2:Color|Color]] definition specifying the color for this character
 
 
|-
 
|-
!:
+
! <type_name>
| A [[LGUI2:Color|Color]] definition specifying the color for this character
+
| An object specifying optional "color", "backgroundBrush" and "font" properties for a specified type
 
|-
 
|-
!\
+
! <type_name>
| A [[LGUI2:Color|Color]] definition specifying the color for this character
+
| ... (same as above, any number of these may be present)
 
|}
 
|}
  
  
 +
== Examples ==
 +
; A LavishScript 1 command lines Text Scanner, with background colors specified for Data Sequence, Index, and Type Casts
 +
"textScanner": {
 +
  "type": "ls1_commandlines",
 +
  "ls1_commandline": { "color": [ 0.8,1.0,0.8] },
 +
  "ls1_${": { "color": [ 1.0, 1.0, 0.0 ] },
 +
  "ls1_$": { "color": [ 1.0,0.2,0.2 ] },
 +
  "ls1_}": { "color": [ 1.0, 1.0, 0.0 ] },
 +
  "ls1_[": { "color": [ 1.0, 0.5, 0.5 ] },
 +
  "ls1_]": { "color": [ 1.0, 0.5, 0.5 ] },
 +
  "ls1_(": { "color": [ 0.5, 0.5, 1.0 ] },
 +
  "ls1_)": { "color": [ 0.5, 0.5, 1.0 ] },
 +
  "ls1_,": { "color": [ 1.0, 0.5, 0.5 ] },
 +
  "ls1_\"": { "color": [ 1.0, 0.5, 0.0 ] },
 +
  "escape": { "color": [ 0.5, 0.5, 0.5 ] },
 +
  "ls1_datasequence_inner": { },
 +
  "ls1_datasequence": { "backgroundBrush": { "color": [ 0.2, 0.2, 0.0 ] } },
 +
  "ls1_index": { "backgroundBrush": { "color": [ 0.2, 0.1, 0.1 ] } },
 +
  "ls1_typecast": { "backgroundBrush": { "color": [ 0.1, 0.1, 0.2 ] } },
 +
  "ls1_index_inner": { },
 +
  "ls1_quoted": { },
 +
  "ls1_other": { },
 +
  "ls1_commandlines": { }
 +
  }
 +
 +
This example requires loading relevant [[LGUI2:Text Types|Text Types]].
 +
 +
 +
{{LGUI2:TextTypes}}
 
{{LGUI2:Topic}}
 
{{LGUI2:Topic}}
  
 
[[Category:LavishGUI 2 Text]]
 
[[Category:LavishGUI 2 Text]]

Latest revision as of 15:40, 10 December 2018

A LavishGUI 2 Text Scanner selects a Text Type and any related options for decorating text, such as colors and fonts for special portions of text (for example, syntax highlighting).

Each LavishGUI 2 Element with Text (any commandbox, textbox, textblock) can have its own Text Scanner defined.


Defining a Text Scanner

A Text Scanner is defined as a JSON Object, usually as part of an Element (currently including commandbox, textbox, textblock)


Text Scanner properties
type The Text Type, usually a type of container, to process text as
<type_name> An object specifying optional "color", "backgroundBrush" and "font" properties for a specified type
<type_name> ... (same as above, any number of these may be present)


Examples

A LavishScript 1 command lines Text Scanner, with background colors specified for Data Sequence, Index, and Type Casts
"textScanner": {
  "type": "ls1_commandlines",
  "ls1_commandline": { "color": [ 0.8,1.0,0.8] },
  "ls1_${": { "color": [ 1.0, 1.0, 0.0 ] },
  "ls1_$": { "color": [ 1.0,0.2,0.2 ] },
  "ls1_}": { "color": [ 1.0, 1.0, 0.0 ] },
  "ls1_[": { "color": [ 1.0, 0.5, 0.5 ] },
  "ls1_]": { "color": [ 1.0, 0.5, 0.5 ] },
  "ls1_(": { "color": [ 0.5, 0.5, 1.0 ] },
  "ls1_)": { "color": [ 0.5, 0.5, 1.0 ] },
  "ls1_,": { "color": [ 1.0, 0.5, 0.5 ] },
  "ls1_\"": { "color": [ 1.0, 0.5, 0.0 ] },
  "escape": { "color": [ 0.5, 0.5, 0.5 ] },
  "ls1_datasequence_inner": { },
  "ls1_datasequence": { "backgroundBrush": { "color": [ 0.2, 0.2, 0.0 ] } },
  "ls1_index": { "backgroundBrush": { "color": [ 0.2, 0.1, 0.1 ] } },
  "ls1_typecast": { "backgroundBrush": { "color": [ 0.1, 0.1, 0.2 ] } },
  "ls1_index_inner": { },
  "ls1_quoted": { },
  "ls1_other": { },
  "ls1_commandlines": { }
  }

This example requires loading relevant Text Types.


LavishGUI 2 Text Types

Built-in
any - container - crlf - escape - plain
User-defined only
character - sequence

LavishGUI 2 Topics