From e2469328aefd3244e56daf8551e472c85aa30487 Mon Sep 17 00:00:00 2001 From: rolanmen1 Date: Sun, 12 Aug 2012 07:06:38 +0000 Subject: [PATCH] LuaWriter. Color numbers, need to make it color hexadecimals aswell. --- BizHawk.MultiClient/Config.cs | 2 ++ BizHawk.MultiClient/tools/LuaWriter.cs | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index d985c6528e..ab56da7e86 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -566,6 +566,8 @@ namespace BizHawk.MultiClient public bool LuaSymbolBold = false; public int LuaLibraryColor = -16711681; public bool LuaLibraryBold = false; + public int LuaDecimalColor = -23296; + public bool LuaDecimalBold = false; public float LuaWriterFontSize = 11; public string LuaWriterFont = "Courier New"; public float LuaWriterZoom = 1; diff --git a/BizHawk.MultiClient/tools/LuaWriter.cs b/BizHawk.MultiClient/tools/LuaWriter.cs index 0fcdd9b604..3a68988f6f 100644 --- a/BizHawk.MultiClient/tools/LuaWriter.cs +++ b/BizHawk.MultiClient/tools/LuaWriter.cs @@ -87,6 +87,7 @@ namespace BizHawk.MultiClient LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Regular); AddCommentsAndStrings(); + AddNumbers(); AddKeyWords(); AddLibraries(); AddSymbols(); @@ -99,6 +100,29 @@ namespace BizHawk.MultiClient LuaText.Refresh(); } + private void AddNumbers() + { + string temp = LuaText.Text; + foreach (Match match in new Regex(@"(\d+\.?\d+|\.\d+|\d+)").Matches(temp)) + { + if (!IsThisPartOfStringOrComment(match.Index)) + { + char before = ' ', after = ' '; + + if (match.Index > 0) + before = LuaText.Text[match.Index - 1]; + + if (match.Index + match.Length != LuaText.Text.Length) + after = LuaText.Text[match.Index + match.Length]; + + if (!char.IsLetter(before) && !char.IsLetter(after)) + { + AddPosition(match.Index, match.Length, Global.Config.LuaDecimalColor, Global.Config.LuaDecimalBold, 0); + } + } + } + } + private void AddCommentsAndStrings() { string temp = LuaText.Text;