From 91f90befb3712a77d519a687310218628e8cf007 Mon Sep 17 00:00:00 2001 From: yumaojun Date: Thu, 2 Mar 2023 17:50:08 +0800 Subject: [PATCH 1/4] =?UTF-8?q?bugfix=EF=BC=9A=E6=AD=A3=E5=88=99=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E5=AD=97=E7=AC=A6=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implementation/StyleMonitor/SelectionStyleMonitor.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs b/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs index 443d8dd..0a041ff 100644 --- a/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs +++ b/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs @@ -41,10 +41,14 @@ public void OnSelectionChanged(TextManager textManager, int nStart, int nLen) { } return false; }); - if (!string.IsNullOrEmpty(strKey)) { + if (!string.IsNullOrEmpty(strKey)) { string strText = textManager.GetText(); List lst = new List(); - foreach (Match m in Regex.Matches(strText, "\\b" + strKey + "\\b")) { + if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey)) + { + strKey = "\\" + strKey; + } + foreach (Match m in Regex.Matches(strText, "\\b" + strKey + "\\b")) { // * . ? + $ ^ [ ] ( ) { } | \ / lst.Add(new TextStyleRange() { Index = m.Index, Length = m.Length, From 19db65103ec87cec0b3e42f935eecae9a5f44cdf Mon Sep 17 00:00:00 2001 From: DebugST <2212233137@qq.com> Date: Fri, 3 Mar 2023 10:55:00 +0800 Subject: [PATCH 2/4] fixed the bug. pull request([#1](https://github.com/DebugST/STTextBox/pull/1)) --- .../Implementation/StyleMonitor/SelectionStyleMonitor.cs | 8 +++++++- ST.Library.UI.STTextBox/STTextBox.cs | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs b/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs index 443d8dd..a079230 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,7 +42,12 @@ public void OnSelectionChanged(TextManager textManager, int nStart, int nLen) { } return false; }); - if (!string.IsNullOrEmpty(strKey)) { + // https://github.com/DebugST/STTextBox/pull/1 + //if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey)) { + // strKey = "\\" + strKey; + //} + strKey = m_reg_reg.Replace(strKey, @"\$1"); + if (!string.IsNullOrEmpty(strKey)) { string strText = textManager.GetText(); List lst = new List(); foreach (Match m in Regex.Matches(strText, "\\b" + strKey + "\\b")) { 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 From 61524d5fe5de9e836793d25c89da08f4dc150523 Mon Sep 17 00:00:00 2001 From: DebugST <2212233137@qq.com> Date: Fri, 3 Mar 2023 11:20:03 +0800 Subject: [PATCH 3/4] Fixed the bug: Pull requests(#1) --- .../StyleMonitor/SelectionStyleMonitor.cs | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs b/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs index 0d333ea..f94422b 100644 --- a/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs +++ b/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs @@ -44,26 +44,23 @@ public void OnSelectionChanged(TextManager textManager, int nStart, int nLen) { }); // https://github.com/DebugST/STTextBox/pull/1 - //if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey)) { - // strKey = "\\" + strKey; - //} + // if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey)) { + // strKey = "\\" + strKey; + // } strKey = m_reg_reg.Replace(strKey, @"\$1"); - if (!string.IsNullOrEmpty(strKey)) { - string strText = textManager.GetText(); - List lst = new List(); - if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey)) - { - strKey = "\\" + strKey; - } - 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); + 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) { From 7145a5c8ce012ee4eaac8912899269bb6b92ef6d Mon Sep 17 00:00:00 2001 From: tpbeldie <122232758+tpbeldie@users.noreply.github.com> Date: Fri, 24 Nov 2023 20:24:24 +0200 Subject: [PATCH 4/4] Update README.md netero was my old alias, tpbeldie is my new identity. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)