miniSql

创建
zgc123@gmail.com authored at 11/19/2023 1:40:15 AM
6136600
Tree
0 Parent(s)
Summary: 1 changed files with 73 additions and 0 deletions.
Added +73 -0
Added +73 -0
diff --git a/minisqlquery-master/src/MiniSqlQuery.Core/BasicTextFindService.cs b/minisqlquery-master/src/MiniSqlQuery.Core/BasicTextFindService.cs
new file mode 100644
index 0000000..0eac8b7
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery.Core/BasicTextFindService.cs
@@ -0,0 +1,73 @@
+#region License
+
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+
+#endregion
+
+using System;
+
+namespace MiniSqlQuery.Core
+{
+    /// <summary>
+    /// 	A simple text finding service. Currently supports forward only text matching.
+    /// </summary>
+    public class BasicTextFindService : ITextFindService
+    {
+        /// <summary>
+        /// 	The services reference.
+        /// </summary>
+        private readonly IApplicationServices _services;
+
+        /// <summary>
+        /// 	Initializes a new instance of the <see cref = "BasicTextFindService" /> class. Creates a new text find service.
+        /// </summary>
+        /// <param name = "applicationServices">A reference to the application services.</param>
+        public BasicTextFindService(IApplicationServices applicationServices)
+        {
+            _services = applicationServices;
+        }
+
+        /// <summary>
+        /// 	Looks for the next match depending on the settings in the <paramref name = "request" />.
+        /// </summary>
+        /// <param name = "request">The text find request.</param>
+        /// <returns>An updated request with the relevent values adjusted (namely position).</returns>
+        public FindTextRequest FindNext(FindTextRequest request)
+        {
+            if (request == null)
+            {
+                throw new ArgumentNullException("request");
+            }
+
+            /*
+			if (request.SearchUp)
+			{
+			    // todo - I think its the TextProvider's job...?
+			}
+			else // search down.
+			{
+			int pos = request.TextProvider.FindString(request.SearchValue, request.Position, request.StringComparison);
+			    //pos = request.TextProvider.FindString(request);
+			}
+			*/
+            int pos = request.TextProvider.FindString(request.SearchValue, request.Position, request.StringComparison);
+
+            if (pos > -1)
+            {
+                // the editor will highlight the find
+                request.Position = pos + request.SearchValue.Length;
+            }
+            else
+            {
+                // todo - notify, beep etc
+
+                // reset to start of buffer.
+                request.Position = 0;
+            }
+
+            return request;
+        }
+    }
+}
\ No newline at end of file