From c832b7830853c33bed586e89ddae261200bb526e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 2 Aug 2017 08:27:33 -0400 Subject: [PATCH] slightly fix caret movement and wrapping --- ShiftOS.Frontend/Apps/Terminal.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ShiftOS.Frontend/Apps/Terminal.cs b/ShiftOS.Frontend/Apps/Terminal.cs index 9fe71de..5bedcf0 100644 --- a/ShiftOS.Frontend/Apps/Terminal.cs +++ b/ShiftOS.Frontend/Apps/Terminal.cs @@ -183,11 +183,17 @@ namespace ShiftOS.Frontend.Apps var font = new Font(LoadedSkin.TerminalFont.Name, LoadedSkin.TerminalFont.Size * _zoomFactor, LoadedSkin.TerminalFont.Style); int currline = GetCurrentLine(); string substring = String.Join(Environment.NewLine, Lines.Take(currline + 1)); - int h = (int)Math.Round(gfx.SmartMeasureString(substring, font).Height - font.Height); - var lineMeasure = gfx.SmartMeasureString(Lines[currline], font); + int h = (int)Math.Round(gfx.SmartMeasureString(substring, font, Width).Height - font.Height); + + int linestart = String.Join(Environment.NewLine, Lines.Take(GetCurrentLine())).Length; + + var lineMeasure = gfx.SmartMeasureString(Text.Substring(linestart, Index - linestart), font); int w = (int)Math.Floor(lineMeasure.Width); - if (w > Width - 4) - w = Width - 4; + while (w > Width) + { + w -= Width; + h += (int)lineMeasure.Height; + } return new System.Drawing.Point(w, h); }