From 34a13fafb5dcd4aa3ebb453f8b348f6a1aec226c Mon Sep 17 00:00:00 2001 From: gdkhd812 Date: Thu, 29 Oct 2015 15:09:47 +0530 Subject: [PATCH] =?utf8?q?=E3=82=AD=E3=83=A3=E3=83=AC=E3=83=83=E3=83=88?= =?utf8?q?=E9=A0=98=E5=9F=9F=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B?= =?utf8?q?=E9=83=A8=E5=88=86=E3=82=92=E4=B8=80=E3=81=A4=E3=81=AE=E9=96=A2?= =?utf8?q?=E6=95=B0=E3=81=AB=E3=81=BE=E3=81=A8=E3=82=81=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Core/EditView.cs | 19 +++++++++++++++++++ WPF/FooEditEngine/FooTextBox.cs | 13 +------------ Windows/FooEditEngine/FooTextBox.cs | 10 +--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Core/EditView.cs b/Core/EditView.cs index 1a4ad02..23cdec3 100644 --- a/Core/EditView.cs +++ b/Core/EditView.cs @@ -426,6 +426,25 @@ namespace FooEditEngine } /// + /// 現在のキャレット位置の領域を返す + /// + /// 矩形領域を表すRectangle + public Rectangle GetCurrentCaretRect() + { + ITextLayout layout = this.LayoutLines.GetLayout(this.Document.CaretPostion.row); + double width = layout.GetWidthFromIndex(this.Document.CaretPostion.col); + if (width == 0.0) + width = this.CaretWidthOnInsertMode; + double height = layout.Height; + Rectangle updateRect = new Rectangle( + this.CaretLocation.X, + this.CaretLocation.Y, + width, + height); + return updateRect; + } + + /// /// 指定した座標の一番近くにあるTextPointを取得する /// /// テキストエリアを左上とする相対位置 diff --git a/WPF/FooEditEngine/FooTextBox.cs b/WPF/FooEditEngine/FooTextBox.cs index fab0265..707e58b 100644 --- a/WPF/FooEditEngine/FooTextBox.cs +++ b/WPF/FooEditEngine/FooTextBox.cs @@ -992,21 +992,10 @@ namespace FooEditEngine.WPF bool updateAll = this.View.LayoutLines.HilightAll() || this.View.LayoutLines.GenerateFolding(); - ITextLayout layout = this.View.LayoutLines.GetLayout(this.Document.CaretPostion.row); - double width = layout.GetWidthFromIndex(this.Document.CaretPostion.col); - if (width == 0.0) - width = this.View.CaretWidthOnInsertMode; - double height = layout.Height; - Rectangle updateRect = new Rectangle( - this.View.CaretLocation.X, - this.View.CaretLocation.Y, - width, - height); - if (updateAll) this.Refresh(); else - this.Refresh(updateRect); + this.Refresh(this.View.GetCurrentCaretRect()); } void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e) diff --git a/Windows/FooEditEngine/FooTextBox.cs b/Windows/FooEditEngine/FooTextBox.cs index c0e7a0e..f8ebaa2 100644 --- a/Windows/FooEditEngine/FooTextBox.cs +++ b/Windows/FooEditEngine/FooTextBox.cs @@ -1480,20 +1480,12 @@ namespace FooEditEngine.Windows if (this.Document.CaretPostion.row >= this.View.LayoutLines.Count || DesignMode) return; - ITextLayout layout = this.View.LayoutLines.GetLayout(this.Document.CaretPostion.row); - - Size redrawSize = new Size(); - redrawSize.Width = layout.GetWidthFromIndex(this.Document.CaretPostion.col); - if (redrawSize.Width == 0.0) - redrawSize.Width = this.View.CaretWidthOnInsertMode; - redrawSize.Height = layout.Height; - bool updateAll = this.View.LayoutLines.HilightAll() || this.View.LayoutLines.GenerateFolding(); if (updateAll) this.Invalidate(); else - this.Invalidate(new System.Drawing.Rectangle(this.View.CaretLocation, redrawSize)); + this.Invalidate(new System.Drawing.Rectangle(this.View.CaretLocation, this.View.GetCurrentCaretRect().Size)); } void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e) -- 2.11.0