OSDN Git Service

InsertPointプロパティはなくても実装できるので廃止した&インターフェイスの実装漏れを修正した
authorgdkhd812 <test@nnn.co.jp>
Sun, 25 Oct 2015 06:42:26 +0000 (12:12 +0530)
committergdkhd812 <test@nnn.co.jp>
Sun, 25 Oct 2015 06:42:26 +0000 (12:12 +0530)
Core/Controller.cs
Core/EditView.cs
Core/TextServiceFramework/TextStoreHelper.cs
WPF/UnitTest/DummyRender.cs
WPF/UnitTest/UnitTest4.cs

index bee7a83..fc34dd8 100644 (file)
@@ -178,15 +178,10 @@ namespace FooEditEngine
                 TextPoint startTextPoint = this.View.GetLayoutLineFromIndex(start);
                 TextPoint endTextPoint = this.View.GetLayoutLineFromIndex(start + length);
                 this.SelectByRectangle(new TextRectangle(startTextPoint, endTextPoint));
-                if (startTextPoint.col == endTextPoint.col)
-                    this.View.InsertPoint = new SelectCollection(this.View.Selections);
-                else
-                    this.View.InsertPoint = null;
             }
             else if(length != 0)
             {
                 this.View.Selections.Add(Selection.Create(start, length));
-                this.View.InsertPoint = null;
             }
             this.SelectionChanged(this, null);
         }
@@ -207,11 +202,6 @@ namespace FooEditEngine
             
             this.SelectByRectangle(new TextRectangle(tp,end));
             
-            if (width == 0)
-                this.View.InsertPoint = new SelectCollection(this.View.Selections);
-            else
-                this.View.InsertPoint = null;
-
             this.SelectionChanged(this, null);
         }
 
@@ -618,12 +608,24 @@ namespace FooEditEngine
             this.Document.UnLock();
         }
 
+        public bool IsRectInsertMode()
+        {
+            if (!this.RectSelection)
+                return false;
+            foreach(Selection sel in this.View.Selections)
+            {
+                if (sel.length != 0)
+                    return false;
+            }
+            return true;
+        }
+
         /// <summary>
         /// キャレット位置の文字を一文字削除し、キャレット位置を後ろにずらす
         /// </summary>
         public void DoBackSpaceAction()
         {
-            if (this.View.InsertPoint != null)
+            if (this.IsRectInsertMode())
             {
                 this.ReplaceBeforeSelectionArea(this.View.Selections, 1, "");
                 return;
@@ -696,7 +698,7 @@ namespace FooEditEngine
             if (str == "\t" && this.IndentMode == IndentMode.Space)
                 str = this.GetIndentSpace(CaretPos.col);
 
-            if (this.View.InsertPoint != null)
+            if (this.IsRectInsertMode())
             {
                 this.ReplaceBeforeSelectionArea(this.View.Selections, 0, str);
                 return;
@@ -757,7 +759,6 @@ namespace FooEditEngine
                 this.Select(this.AnchorIndex, CaretPostion - this.AnchorIndex);
             }else{
                 this.AnchorIndex = CaretPostion;
-                this.View.InsertPoint = null;
                 this.Select(CaretPostion, 0);
             }
         }
@@ -994,7 +995,7 @@ namespace FooEditEngine
             if (this.RectSelection == false || this.Document.FireUpdateEvent == false)
                 throw new InvalidOperationException();
 
-            SelectCollection temp = this.View.InsertPoint;
+            SelectCollection temp = this.View.Selections;
             int selectStart = temp.First().start;
             int selectEnd = temp.Last().start + temp.Last().length;
 
@@ -1155,7 +1156,7 @@ namespace FooEditEngine
             }
             this.JumpCaret(StartIndex);
             if (updateInsertPoint && newInsertPoint.Count > 0)
-                this.View.InsertPoint = newInsertPoint;
+                this.View.Selections = newInsertPoint;
         }
 
         private string GetTextFromLineSelectArea(SelectCollection Selections)
index b4185a1..b83d6f9 100644 (file)
@@ -58,7 +58,6 @@ namespace FooEditEngine
             this.CaretPostion = TextPoint.Null;
             this.CaretLocation = new Point(this.render.TextArea.X, this.render.TextArea.Y);
             this.LayoutLines.FoldingCollection.StatusChanged += FoldingCollection_StatusChanged;
-            this.InsertPoint = null;
             this.HideLineMarker = true;
             this.IsFocused = false;
             this.Selections = new SelectCollection();
@@ -71,7 +70,7 @@ namespace FooEditEngine
         internal SelectCollection Selections
         {
             get;
-            private set;
+            set;
         }
 
         /// <summary>
@@ -185,15 +184,6 @@ namespace FooEditEngine
         }
 
         /// <summary>
-        /// 矩形選択モード中に文字列が挿入される位置を表す
-        /// </summary>
-        public SelectCollection InsertPoint
-        {
-            get;
-            set;
-        }
-
-        /// <summary>
         /// キャレットがある領域を示す
         /// </summary>
         public Point CaretLocation
@@ -316,8 +306,7 @@ namespace FooEditEngine
                     pos.Y += this.LayoutLines.GetLayout(i).Height;
                 }
 
-                if (this.InsertPoint != null)
-                    this.DrawInsertPoint();
+                this.DrawInsertPoint();
 
                 render.CacheContent();
             }
@@ -399,8 +388,11 @@ namespace FooEditEngine
 
         void DrawInsertPoint()
         {
+            //一つしかない場合は行選択の可能性がある
+            if (this.Selections.Count <= 1)
+                return;
             IEditorRender render = (IEditorRender)base.render;
-            foreach (Selection sel in this.InsertPoint)
+            foreach (Selection sel in this.Selections)
             {
                 if (sel.length == 0)
                 {
index 7db5df1..e9649aa 100644 (file)
@@ -76,10 +76,10 @@ namespace FooEditEngine
 
         public static void SetSelectionIndex(Controller controller,EditView view,int i_startIndex, int i_endIndex)
         {
-            if (controller.RectSelection && view.InsertPoint != null)
+            if (controller.IsRectInsertMode())
             {
                 TextPoint start = view.LayoutLines.GetTextPointFromIndex(i_startIndex);
-                TextPoint end = view.LayoutLines.GetTextPointFromIndex(view.InsertPoint.Last().start);
+                TextPoint end = view.LayoutLines.GetTextPointFromIndex(view.Selections.Last().start);
                 controller.JumpCaret(i_endIndex);
                 controller.Select(start, i_endIndex - i_startIndex, end.row - start.row);
             }
index 2788f90..b83f38e 100644 (file)
@@ -110,6 +110,11 @@ namespace UnitTest
         {
             return new DummyTextLayout();
         }
+
+        public void DrawGripper(Point p, double radius)
+        {
+            throw new NotImplementedException();
+        }
     }
     class DummyTextLayout : ITextLayout
     {
index fca1f38..3023f08 100644 (file)
@@ -82,15 +82,15 @@ namespace UnitTest
                 view.LayoutLines[1] == "x\n" &&
                 view.LayoutLines[2] == "x");
             Assert.IsTrue(
-                view.InsertPoint[0].start == 0 &&
-                view.InsertPoint[1].start == 2 &&
-                view.InsertPoint[2].start == 4);
+                view.Selections[0].start == 0 &&
+                view.Selections[1].start == 2 &&
+                view.Selections[2].start == 4);
 
             ctrl.DoInputString("x", true);
             Assert.IsTrue(
-                view.InsertPoint[0].start == 1 &&
-                view.InsertPoint[1].start == 4 &&
-                view.InsertPoint[2].start == 7);
+                view.Selections[0].start == 1 &&
+                view.Selections[1].start == 4 &&
+                view.Selections[2].start == 7);
 
             doc.Clear();
             doc.Append("a\nb\nc");