[commit: haskeline] master: Fix bug in Windows line redrawing. (655912e)
Ian Lynagh
igloo at earth.li
Mon May 7 13:53:39 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/haskeline
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/655912e609efa8db3d01e61557b7f561475ed8dc
>---------------------------------------------------------------
commit 655912e609efa8db3d01e61557b7f561475ed8dc
Author: Judah Jacobson <judah.jacobson at gmail.com>
Date: Sat Apr 28 20:26:58 2012 +0000
Fix bug in Windows line redrawing.
>---------------------------------------------------------------
System/Console/Haskeline/Backend/Win32.hsc | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/System/Console/Haskeline/Backend/Win32.hsc b/System/Console/Haskeline/Backend/Win32.hsc
index e3663c8..4f6ae98 100644
--- a/System/Console/Haskeline/Backend/Win32.hsc
+++ b/System/Console/Haskeline/Backend/Win32.hsc
@@ -264,11 +264,15 @@ printText txt = do
h <- asks hOut
liftIO (writeConsole h txt)
-printAfter :: String -> DrawM ()
-printAfter str = do
- p <- getPos
- printText str
- setPos p
+printAfter :: [Grapheme] -> DrawM ()
+printAfter gs = do
+ -- NOTE: you may be tempted to write
+ -- do {p <- getPos; printText (...); setPos p}
+ -- Unfortunately, that would be WRONG, because if printText wraps
+ -- a line at the bottom of the window, causing the window to scroll,
+ -- then the old value of p will be incorrect.
+ printText (graphemesToString gs)
+ movePosLeft gs
drawLineDiffWin :: LineChars -> LineChars -> DrawM ()
drawLineDiffWin (xs1,ys1) (xs2,ys2) = case matchInit xs1 xs2 of
@@ -278,9 +282,9 @@ drawLineDiffWin (xs1,ys1) (xs2,ys2) = case matchInit xs1 xs2 of
(xs1',xs2') -> do
movePosLeft xs1'
let m = gsWidth xs1' + gsWidth ys1 - (gsWidth xs2' + gsWidth ys2)
- let deadText = replicate m ' '
+ let deadText = stringToGraphemes $ replicate m ' '
printText (graphemesToString xs2')
- printAfter (graphemesToString ys2 ++ deadText)
+ printAfter (ys2 ++ deadText)
movePosRight, movePosLeft :: [Grapheme] -> DrawM ()
movePosRight str = do
More information about the Cvs-libraries
mailing list