Back to document index

Beautify sql and syntax highlighting
Beautify sql and syntax highlighting

 

After formatting sql, beautified sql was in plain text. There are 2 ways you can generate beautified sql in colored text with syntax highlighting, RTF and HTML output. 

 

  • RTF output

With this output, colored sql can be viewed in any editor that supported rtf format, 

such as writer and ms word. and you can use microsoft Rich Editor component in your app 

to add syntax highlighting function with RTF output. 

 

  • HTML output

With this output, colored sql can be published in website, blog, wiki and so on. 

 

The default font of output is Courier New, and it works fine. Please don't change this font although you can set new font by using gFmtOpt.HighlightingFontname. 

 

The default font size of output is 10, and it can be changed by setting new value to gFmtOpt.HighlightingFontsize. 

 

HighlightingFontname and HighlightingFontsize apply to whole output, and you can also customize each token with different color and style by using 

 

TLzHighlighterAttributes.SetForegroundInRGB
TLzHighlighterAttributes.StyleItalic
TLzHighlighterAttributes.StyleBold
TLzHighlighterAttributes.StyleStrikeout
TLzHighlighterAttributes.StyleUnderline

 

Below are all kinds of token type that you can used to customize color and style. 

 

gFmtOpt.HighlightingElements[sfkComment_dh] -- this is double hyphen comment 

gFmtOpt.HighlightingElements[sfkComment_ss] /* this is multi line comment */ 

gFmtOpt.HighlightingElements[sfkIdentifer] identifier: 

gFmtOpt.HighlightingElements[sfkstandardkeyword] keyword 

gFmtOpt.HighlightingElements[sfkNumber] number: 

gFmtOpt.HighlightingElements[sfkDatatype] datatype : 

gFmtOpt.HighlightingElements[sfkFunction] user defined function: 

gFmtOpt.HighlightingElements[sfkBuiltInFunction] database vendor built in function: 

gFmtOpt.HighlightingElements[sfkSymbol] all kinds of operator 

gFmtOpt.HighlightingElements[sfkSQString] String 

gFmtOpt.HighlightingElements[sfksqlvar] sql variable 

gFmtOpt.HighlightingElements[sfkOpenBracket] ( 

gFmtOpt.HighlightingElements[sfkCloseBracket] ) 

 

gFmtOpt.HighlightingElements[sfkmssqlst1] sql server sp: 

gFmtOpt.HighlightingElements[sfkmssqlsystemvar] sql server system variable 

 

gFmtOpt.HighlightingElements[sfkoraclesqlplus] oracle sql plus command 

gFmtOpt.HighlightingElements[sfkoracleexception] oracle exception: 

gFmtOpt.HighlightingElements[sfkbindvar] bind variable, :bindvar 

 

 

for more detailed information about syntax highlighting of formatted sql, please check this demo 

http://www.sqlparser.com/dl/samples/syntaxhighlighting.zip 

 

Below are some color in RGB format that can be used by TLzHighlighterAttributes.SetForegroundInRGB. 

 

 

Black = #000000 

Maroon = #000080 

Green = #008000 

Olive = #008080 

Navy = #800000 

Purple = #800080 

Teal = #808000 

Gray = #808080 

Silver = #C0C0C0 

Red = #0000FF 

Lime = #00FF00 

Yellow = #00FFFF 

Blue = #FF0000 

Fuchsia = #FF00FF 

Aqua = #FFFF00 

LtGray = #C0C0C0 

DkGray = #808080 

White = #FFFFFF 

MoneyGreen=#$C0DCC0 

SkyBlue = #F0CAA6 

Cream = #F0FBFF 

MedGray = #A4A0A0



  Back to document index