From 8a9519f2183b64fe220bcb1f6acedbe6acc190cd Mon Sep 17 00:00:00 2001 From: Michael Vrhel Date: Tue, 9 Sep 2014 16:28:57 -0700 Subject: Fix bug in text selection. The code was doing the proper highlighting but failing to add all but the first character in the first selected line. --- platform/winrt/gsview/MainWindow.xaml.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'platform') diff --git a/platform/winrt/gsview/MainWindow.xaml.cs b/platform/winrt/gsview/MainWindow.xaml.cs index b4a1fb6d..6e6ee855 100644 --- a/platform/winrt/gsview/MainWindow.xaml.cs +++ b/platform/winrt/gsview/MainWindow.xaml.cs @@ -3771,20 +3771,30 @@ namespace gsview start_line.Height = 0; start_line.Scale = m_doczoom; /* Use either anchor point or mouse pos */ + bool highlight_done = false; for (int mm = 0; mm < lett.Count; mm++) { double letscale = m_doczoom / lett[mm].Scale; if (lett[mm].X * letscale + lett[mm].Width * letscale >= val) { - start_line.Color = m_textselectcolor; - /* special color for debug */ - //start_line.Color = "#40FF0000"; - start_line.Height = lines[kk].Height * scale; - start_line.Width = lines[kk].X * scale + lines[kk].Width * scale - lett[mm].X * letscale; - start_line.X = lett[mm].X * letscale; - start_line.Y = lines[kk].Y * scale; + /* In this case, we are done with the + * highlight section as it only + * depends upon the first character + * we encounter and the line end. + * But we must continue to add in + * the selected characters */ + if (!highlight_done) + { + start_line.Color = m_textselectcolor; + /* special color for debug */ + /* start_line.Color = "#40FF0000"; */ + start_line.Height = lines[kk].Height * scale; + start_line.Width = lines[kk].X * scale + lines[kk].Width * scale - lett[mm].X * letscale; + start_line.X = lett[mm].X * letscale; + start_line.Y = lines[kk].Y * scale; + highlight_done = true; + } start_line.TextCharacters.Add(lett[mm]); - break; } } if (start_line.Height > 0) -- cgit v1.2.3