diff --git a/README.md b/README.md index 0ac5387..009c5b1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ # STTextBox STTextBox is a pure GDI-drawn WinForm control, which can support transparent colors and Emoji, etc., and can customize the display style of text through the text style monitor. -STTextBox is a WinForm control drawn by me and my friend [netero](https://github.com/0x54164) using GDI. +STTextBox is a WinForm control drawn by me and my friend [tpbeldie](https://github.com/tpbeldie) using GDI. We adopt the MIT open source license, and the code is built with .Net3.5 + vs2010, so it is compatible with almost all VS versions. @@ -45,4 +45,4 @@ So we have not considered the rendering speed of extreme cases for the time bein * Github: [DebugST](https://github.com/DebugST/) * Blog: [Crystal_lz](http://st233.com) * Mail: (2212233137@qq.com) -* TG: [DebugST](t.me/DebugST) \ No newline at end of file +* TG: [DebugST](t.me/DebugST) diff --git a/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs b/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs index 443d8dd..f94422b 100644 --- a/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs +++ b/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs @@ -13,6 +13,7 @@ public class SelectionStyleMonitor : ITextStyleMonitor private static WordSplitter m_spliter = new WordSplitter(); private List m_lst = new List(); + private Regex m_reg_reg = new Regex(@"([*.?+$^\[\](){}|\\])"); public SelectionStyleMonitor() { this.Style = new TextStyle() { @@ -41,18 +42,25 @@ public void OnSelectionChanged(TextManager textManager, int nStart, int nLen) { } return false; }); - if (!string.IsNullOrEmpty(strKey)) { - string strText = textManager.GetText(); - List lst = new List(); - foreach (Match m in Regex.Matches(strText, "\\b" + strKey + "\\b")) { - lst.Add(new TextStyleRange() { - Index = m.Index, - Length = m.Length, - Style = this.Style - }); - } - m_lst = TextStyleMonitor.FillDefaultStyle(lst, strText.Length, TextStyle.Empty); + + // https://github.com/DebugST/STTextBox/pull/1 + // if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey)) { + // strKey = "\\" + strKey; + // } + strKey = m_reg_reg.Replace(strKey, @"\$1"); + if (string.IsNullOrEmpty(strKey)) { + return; + } + string strText = textManager.GetText(); + List lst = new List(); + foreach (Match m in Regex.Matches(strText, "\\b" + strKey + "\\b")) { + lst.Add(new TextStyleRange() { + Index = m.Index, + Length = m.Length, + Style = this.Style + }); } + m_lst = TextStyleMonitor.FillDefaultStyle(lst, strText.Length, TextStyle.Empty); } public void OnTextChanged(TextManager textManager, List thrs) { diff --git a/ST.Library.UI.STTextBox/STTextBox.cs b/ST.Library.UI.STTextBox/STTextBox.cs index 725488c..709f314 100644 --- a/ST.Library.UI.STTextBox/STTextBox.cs +++ b/ST.Library.UI.STTextBox/STTextBox.cs @@ -464,6 +464,7 @@ private void OnImeStartPrivate(IntPtr hIMC) { ptCurrentPos = m_core.Caret.Location }; Win32.ImmSetCandidateWindow(hIMC, ref CandidateForm); + var CompositionForm = new Win32.COMPOSITIONFORM() { dwStyle = Win32.CFS_FORCE_POSITION, ptCurrentPos = m_core.Caret.Location