OSDN Git Service

正常に選択できないバグを修正した
[fooeditengine/FooEditEngine.git] / Common / Controller.cs
index edb6a32..14d0fea 100644 (file)
@@ -51,14 +51,13 @@ namespace FooEditEngine
             this.View.PerformLayouted += View_LineBreakChanged;\r
             this.View.PageBoundChanged += View_PageBoundChanged;\r
             this.Document.Clear();\r
-            this.CaretMoved += new EventHandler((s, e) => { });\r
+            this.SelectionChanged += new EventHandler((s, e) => { });\r
         }\r
 \r
         /// <summary>\r
-        /// キャレット移動時に通知される\r
+        /// 選択領域変更時に通知される\r
         /// </summary>\r
-        public event EventHandler CaretMoved;\r
-\r
+        public event EventHandler SelectionChanged;\r
 \r
         /// <summary>\r
         /// 矩形選択モードなら真を返し、そうでない場合は偽を返す\r
@@ -166,11 +165,12 @@ namespace FooEditEngine
                 else\r
                     this.View.InsertPoint = null;\r
             }\r
-            else\r
+            else if(length != 0)\r
             {\r
                 this.View.Selections.Add(Selection.Create(start, length));\r
                 this.View.InsertPoint = null;\r
             }\r
+            this.SelectionChanged(this, null);\r
         }\r
 \r
         public void Select(TextPoint tp, int width, int height)\r
@@ -193,6 +193,8 @@ namespace FooEditEngine
                 this.View.InsertPoint = new SelectCollection(this.View.Selections);\r
             else\r
                 this.View.InsertPoint = null;\r
+\r
+            this.SelectionChanged(this, null);\r
         }\r
 \r
         private void SelectByRectangle(TextRectangle rect)\r
@@ -386,8 +388,6 @@ namespace FooEditEngine
             this.View.AdjustCaretAndSrc();\r
 \r
             this.SelectWithMoveCaret(false);\r
-\r
-            this.CaretMoved(this, null);\r
         }\r
 \r
         /// <summary>\r
@@ -401,7 +401,6 @@ namespace FooEditEngine
             this.View.JumpCaret(0, 0);\r
             this.View.AdjustCaretAndSrc();\r
             this.SelectWithMoveCaret(isSelected);\r
-            this.CaretMoved(this, null);\r
         }\r
 \r
         /// <summary>\r
@@ -418,7 +417,6 @@ namespace FooEditEngine
             this.View.JumpCaret(this.View.LayoutLines.Count - 1, 0);\r
             this.View.AdjustCaretAndSrc();\r
             this.SelectWithMoveCaret(isSelected);\r
-            this.CaretMoved(this, null);\r
         }\r
 \r
         /// <summary>\r
@@ -471,7 +469,6 @@ namespace FooEditEngine
                 this.View.JumpCaret(toRow, 0);\r
                 this.View.AdjustCaretAndSrc();\r
                 this.SelectWithMoveCaret(isSelected);\r
-                this.CaretMoved(this, null);\r
             }\r
             else\r
             {\r
@@ -501,7 +498,6 @@ namespace FooEditEngine
             }\r
             this.View.AdjustCaretAndSrc(AdjustFlow.Col);\r
             this.SelectWithMoveCaret(isSelected);\r
-            this.CaretMoved(this, null);\r
         }\r
 \r
         void AlignNearestWord(bool MoveFlow)\r
@@ -536,7 +532,6 @@ namespace FooEditEngine
                 this.MoveCaretVertical(deltarow > 0);\r
             this.View.AdjustCaretAndSrc(AdjustFlow.Both);\r
             this.SelectWithMoveCaret(isSelected);\r
-            this.CaretMoved(this, null);\r
         }\r
 \r
         /// <summary>\r
@@ -689,10 +684,10 @@ namespace FooEditEngine
             \r
             SelectCollection Selections = this.View.Selections;\r
             if (isSelected)\r
-                this.Select(this.AnchorIndex, CaretPostion - this.AnchorIndex);\r
-            else\r
             {\r
-                this.View.Selections.Clear();\r
+                this.Select(this.AnchorIndex, CaretPostion - this.AnchorIndex);\r
+            }else{\r
+                this.Select(CaretPostion, 0);\r
                 this.AnchorIndex = CaretPostion;\r
                 this.View.InsertPoint = null;\r
             }\r