let m = Regex.Match(X.Text, "\\b(select)|(where)|(from)\\b", RegexOptions.IgnoreCase)
он выделяет только Select, так что я думаю, проблема в моем синтаксисе Regex.Match, но я не вижу где?
со всеми изменениями мое текущее решение выглядит так:
module SQL_Highlighing
open System.Runtime.InteropServices
module Lock =
[<DllImport(@"User32", CharSet = CharSet.Ansi, SetLastError = false, ExactSpelling = true)>]
extern void LockWindowUpdate(int hWnd)
open System.Text.RegularExpressions
open System.Drawing
type SyntaxRTB() =
inherit System.Windows.Forms.RichTextBox()
override X.OnTextChanged(e : System.EventArgs) =
base.OnTextChanged(e); X.ColorTheKeyWords()
member X.ColorTheKeyWords() =
let HL s c =
let color(m : Match, color : Color) =
X.SelectionStart <- m.Index
X.SelectionLength <- m.Length
X.SelectionColor <- color
Regex.Matches(X.Text, "\\b" + s + "\\b", RegexOptions.IgnoreCase) |> fun mx ->
for m in mx do if (m.Success) then color(m,c)
let SelectionAt = X.SelectionStart
Lock.LockWindowUpdate(X.Handle.ToInt32())
HL "(select)|(where)|(from)|(top)|(order)|(group)|(by)|(as)|(null)" Color.Blue
HL "(join)|(left)|(inner)|(outer)|(right)|(on)" Color.Red
HL "(and)|(or)|(not)" Color.DarkSlateGray
HL "(case)|(when)|(then)|(else)|(end)" Color.BurlyWood
HL "(cast)|(nvarchar)|(bit)" Color.BlueViolet
HL "(datepart)" Color.Teal
X.SelectionStart <- SelectionAt
X.SelectionLength <- 0
X.SelectionColor <- Color.Black
Lock.LockWindowUpdate(0)