OSDN Git Service

キャレットポジションをドキュメントから操作可能なのにできないバグを修正した
authorkonekoneko <test2214@hotmail.co.jp>
Thu, 3 Nov 2016 19:03:29 +0000 (00:33 +0530)
committerkonekoneko <test2214@hotmail.co.jp>
Thu, 3 Nov 2016 19:03:29 +0000 (00:33 +0530)
Core/Controller.cs
Core/Document.cs

index feaec0a..ad1c9cc 100644 (file)
@@ -80,6 +80,7 @@ namespace FooEditEngine
                     this._Document.StatusUpdate -= Document_StatusChanged;
                     this._Document.SelectionChanged -= Document_SelectionChanged;
                     this._Document.PerformLayouted -= View_LineBreakChanged;
+                    this._Document.CaretChanged -= _Document_CaretChanged;
                 }
 
                 this._Document = value;
@@ -88,9 +89,16 @@ namespace FooEditEngine
                 this._Document.StatusUpdate += Document_StatusChanged;
                 this._Document.SelectionChanged += Document_SelectionChanged;
                 this._Document.PerformLayouted += View_LineBreakChanged;
+                this._Document.CaretChanged += _Document_CaretChanged;
             }
         }
 
+        private void _Document_CaretChanged(object sender, EventArgs e)
+        {
+            TextPoint pos = this.Document.CaretPostion;
+            this.JumpCaret(pos.row, pos.col);
+        }
+
         private void Document_SelectionChanged(object sender, EventArgs e)
         {
             if (this.IsReverseSelect())
index 661a9dd..1131ab8 100644 (file)
@@ -190,6 +190,7 @@ namespace FooEditEngine
             this.HideLineMarker = true;
             this.SelectGrippers = new GripperRectangle(new Gripper(), new Gripper());
             this.SelectionChanged += new EventHandler((s, e) => { });
+            this.CaretChanged += (s, e) => { };
         }
 
         void WacthDogPattern_Updated(object sender, EventArgs e)
@@ -410,14 +411,24 @@ namespace FooEditEngine
             }
         }
 
+        TextPoint _CaretPostion;
         /// <summary>
         /// レイアウト行のどこにキャレットがあるかを表す
         /// </summary>
-        /// <remarks>この値を変更しても反映されないので、EditView側でAdjustCaret()メソッドを呼び出す必要があります</remarks>
         public TextPoint CaretPostion
         {
-            get;
-            set;
+            get
+            {
+                return this._CaretPostion;
+            }
+            set
+            {
+                if(this._CaretPostion != value)
+                {
+                    this._CaretPostion = value;
+                    this.CaretChanged(this, null);
+                }
+            }
         }
 
         /// <summary>
@@ -711,6 +722,11 @@ namespace FooEditEngine
         public event EventHandler SelectionChanged;
 
         /// <summary>
+        /// キャレット移動時に通知される
+        /// </summary>
+        public event EventHandler CaretChanged;
+
+        /// <summary>
         /// 指定された範囲を選択する
         /// </summary>
         /// <param name="start"></param>