Skip to content

Commit

Permalink
Improved dynamic highlighting, added XML-docfile for FastColoredTextB…
Browse files Browse the repository at this point in the history
…ox library.
  • Loading branch information
yallie committed Mar 10, 2012
1 parent b106795 commit 57e8255
Show file tree
Hide file tree
Showing 2 changed files with 1,956 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private int VScrollPos {
public void LockTextBox() {
// Stop redrawing:
TextBox.BeginUpdate();
//SendMessage(TextBox.Handle, WM_SETREDRAW, 0, IntPtr.Zero);
SendMessage(TextBox.Handle, WM_SETREDRAW, 0, IntPtr.Zero);
// Stop sending of events:
_savedEventMask = SendMessage(TextBox.Handle, EM_GETEVENTMASK, 0, IntPtr.Zero);
SendMessage(TextBox.Handle, EM_SETEVENTMASK, 0, IntPtr.Zero);
Expand All @@ -230,28 +230,25 @@ public void UnlockTextBox() {
// turn on events
SendMessage(TextBox.Handle, EM_SETEVENTMASK, 0, _savedEventMask);
// turn on redrawing
//SendMessage(TextBox.Handle, WM_SETREDRAW, 1, IntPtr.Zero);
SendMessage(TextBox.Handle, WM_SETREDRAW, 1, IntPtr.Zero);
TextBox.EndUpdate();
}

void Adapter_ColorizeTokens(object sender, ColorizeEventArgs args) {
if (_disposed) return;
//Debug.WriteLine("Coloring " + args.Tokens.Count + " tokens.");

_colorizing = true;
TextBox.BeginUpdate();
try {
foreach (Token tkn in args.Tokens) {
var tokenRange = TextBox.GetRange(tkn.Location.Position, tkn.Location.Position + tkn.Length);
var tokenStyle = GetTokenStyle(tkn);
tokenRange.ClearStyle(StyleIndex.All);
tokenRange.SetStyle(tokenStyle);
}
} finally {
TextBox.EndUpdate();
_colorizing = false;
}

TextBox.Refresh();
}

private Style GetTokenStyle(Token token) {
Expand Down
Loading

0 comments on commit 57e8255

Please sign in to comment.