OSDN Git Service

InsertPointプロパティはなくても実装できるので廃止した&インターフェイスの実装漏れを修正した
[fooeditengine/FooEditEngine.git] / Core / Controller.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)