From 57709316691a4b4a53f954ffa538a8d83ec926e4 Mon Sep 17 00:00:00 2001 From: jxq2000 Date: Mon, 6 Aug 2012 23:19:05 +0000 Subject: [PATCH] Some work in ProcessText to try and alleviate the "OMG WE ARE ALWAYS SCROLLING" problem when typing. Still needs some work (so no functional change yet), but the initial idea is to allow for checking/updating of only the current row when called from timer_Tick. --- BizHawk.MultiClient/tools/LuaWriter.cs | 62 ++++++++++++++++++-------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/BizHawk.MultiClient/tools/LuaWriter.cs b/BizHawk.MultiClient/tools/LuaWriter.cs index 990b322245..aa629dd4b1 100644 --- a/BizHawk.MultiClient/tools/LuaWriter.cs +++ b/BizHawk.MultiClient/tools/LuaWriter.cs @@ -68,34 +68,60 @@ namespace BizHawk.MultiClient return; } - ProcessText(); + ProcessText(LuaText.GetLineFromCharIndex(LuaText.SelectionStart)); hasChanged = false; } - private void ProcessText() + /// + /// ProcessText - Adds color and formatting to the text depending on the formatting settings selected + /// + /// This indicates the row that needs updating. Likely will need upates later + /// to support multiple rows at once (e.g. when pasting multiple lines). + /// For now, default value is 0, which will keep behavior as it was (update all lines). + private void ProcessText(int rowChanged = 0) { ProcessingText = true; - int selPos = LuaText.SelectionStart; - int selChars = LuaText.SelectedText.Length; + int selPos = LuaText.SelectionStart; + int selChars = LuaText.SelectedText.Length; - LuaText.SelectAll(); - LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaDefaultTextColor); - if(Global.Config.LuaDefaultTextBold) - LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Bold); - else - LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Regular); + if (rowChanged == 0) //Deafult case, change all lines + { - AddKeyWords(); - AddLibraries(); - AddSymbols(); - AddComments(); - AddStrings(); - AddLongStrings(); + LuaText.SelectAll(); + LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaDefaultTextColor); + if (Global.Config.LuaDefaultTextBold) + LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Bold); + else + LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Regular); - ColorText(); + AddKeyWords(); + AddLibraries(); + AddSymbols(); + AddComments(); + AddStrings(); + AddLongStrings(); - LuaText.Select(selPos, selChars); + ColorText(); + } + + else //Specific line was passed in to change, only update that line + { + LuaText.Select(LuaText.GetFirstCharIndexFromLine(rowChanged),LuaText.GetFirstCharIndexFromLine(rowChanged + 1) - 1); + + //Currently just calls the same tags - they will need to be updated to only look to the appropriate row. + AddKeyWords(); + AddLibraries(); + AddSymbols(); + AddComments(); + AddStrings(); + AddLongStrings(); + + ColorText(); + + } + + LuaText.Select(selPos, selChars); ProcessingText = false; }