OSDN Git Service

ロード時にキャレットをファイルの終わりに置く必要はそもそもなかった
authortest <test@yahoo.co.jp>
Sat, 12 Dec 2020 12:13:04 +0000 (21:13 +0900)
committertest <test@yahoo.co.jp>
Sat, 12 Dec 2020 12:13:04 +0000 (21:13 +0900)
Core/Document.cs
Core/EditView.cs
Core/ViewBase.cs

index 5395d20..54a2693 100644 (file)
@@ -82,6 +82,10 @@ namespace FooEditEngine
         /// ドキュメント全体が削除されたことを表す
         /// </summary>
         Clear,
+        /// <summary>
+        /// レイアウトが再構築されたことを表す
+        /// </summary>
+        RebuildLayout,
     }
 
     /// <summary>
@@ -752,10 +756,8 @@ namespace FooEditEngine
         /// </summary>
         public void PerformLayout()
         {
-            //単に再構築するだけなので行ダーティフラグは更新してはいけない
             this.LayoutLines.IsFrozneDirtyFlag = true;
-            this.FireUpdate(new DocumentUpdateEventArgs(UpdateType.Clear, -1, -1, -1));
-            this.FireUpdate(new DocumentUpdateEventArgs(UpdateType.Replace, 0, 0, this.Length));
+            this.FireUpdate(new DocumentUpdateEventArgs(UpdateType.RebuildLayout, -1, -1, -1));
             this.LayoutLines.IsFrozneDirtyFlag = false;
             if (this.PerformLayouted != null)
                 this.PerformLayouted(this, null);
@@ -1304,6 +1306,10 @@ namespace FooEditEngine
         {
             switch (e.type)
             {
+                case UpdateType.RebuildLayout:
+                    this._LayoutLines.Clear();
+                    this._LayoutLines.UpdateAsReplace(0, 0, this.Length);
+                    break;
                 case UpdateType.Replace:
                     if (e.row == null)
                     {
@@ -1315,12 +1321,13 @@ namespace FooEditEngine
                         this._LayoutLines.UpdateLineAsReplace(e.row.Value, e.removeLength, e.insertLength);
                         this.Markers.UpdateMarkers(this.LayoutLines.GetIndexFromLineNumber(e.row.Value), e.insertLength, e.removeLength);
                     }
+                    this.Dirty = true;
                     break;
                 case UpdateType.Clear:
                     this._LayoutLines.Clear();
+                    this.Dirty = true;
                     break;
             }
-            this.Dirty = true;
             if(this.FireUpdateEvent)
                 this.Update(this, e);
         }
index 70990b9..ed3bd2e 100644 (file)
@@ -733,14 +733,15 @@ namespace FooEditEngine
 
             if (flow == AdjustFlow.Row || flow == AdjustFlow.Both)
             {
+                int PhyLineCountOnScreen = (int)(this.render.TextArea.Height / this.render.emSize.Height);
                 //計算量を減らすため
-                if (tp.row < this.Src.Row)
+                if (tp.row < this.Src.Row || tp.row + PhyLineCountOnScreen * 2 > this.Src.Row)
                     this.Document.Src = new SrcPoint(this.Src.X, tp.row, -relPoint.Y);
 
                 //キャレットのY座標を求める
                 double lineHeight = this.render.emSize.Height;
                 double caret_y = this.Src.OffsetY;  //src.rowからキャレット位置
-                double alignedHeight = (int)(this.render.TextArea.Height / this.render.emSize.Height) * this.render.emSize.Height;
+                double alignedHeight = PhyLineCountOnScreen * this.render.emSize.Height;
                 for (int i = this.Src.Row; i < tp.row; i++)
                 {
                     int lineHeadIndex = this.LayoutLines.GetIndexFromLineNumber(i);
@@ -956,6 +957,12 @@ namespace FooEditEngine
 
         public override void CalculateWhloeViewPort()
         {
+            if(this.Document.LineBreak == LineBreakMethod.None)
+            {
+                this._LongestHeight = this.LayoutLines.Count * this.render.emSize.Height;
+                //CalculateLineCountOnScreenで最小幅は計算する
+                return;
+            }
             double width = 0, height = 0;
             for(int i = 0; i < this.LayoutLines.Count; i++)
             {
index 14e116c..7759deb 100644 (file)
@@ -474,6 +474,7 @@ namespace FooEditEngine
         {
             switch (e.type)
             {
+                case UpdateType.RebuildLayout:
                 case UpdateType.Clear:
                     this._LongestWidth = 0;
                     break;