Commit 1952b70c authored by Diederik van Arkel's avatar Diederik van Arkel

Fix margin colouring

parent dec32c53
......@@ -302,18 +302,34 @@ vChangeSelectionTo newSelection =
vHiliteSelection :: ViewFrame [Rectangle] Text FontInfo Selection *Picture -> *Picture
vHiliteSelection frame upds text fontInfo=:{charWidth, marginWidth, syntaxColours} selection pic
# rects = selToRects selection frame text fontInfo
/*
// # rects = trace_l rects rects
// = trace_n` ("vHiliteSelection",frame) appClipPicture (toRegion upds)(seq(map hilite rects) ) pic
# bRects = [{r & corner2.x = min r.corner2.x margin} \\ r <- rects]
# mRects = [{r & corner1.x = max r.corner1.x margin} \\ r <- rects]
= appClipPicture (toRegion upds)(seq(map hilite mRects) o setPenBack syntaxColours.marginColour o seq(map hilite bRects) o setPenBack syntaxColours.backgroundColour) pic
*/
= appClipPicture (toRegion upds)(seq(map hilite rects) ) pic
| marginWidth <= 0
= appClipPicture (toRegion upds)(seq(map hilite rects) o setPenBack syntaxColours.backgroundColour) pic
//
= appClipPicture (toRegion upds) (seq (map (hiliteBackground syntaxColours fontInfo) rects)) pic
where
margin
= marginWidth * charWidth
hiliteBackground colours {charWidth, marginWidth} r=:{ corner1 = {x=x1,y=y1}, corner2 = {x=x2,y=y2} }
| marginWidth <= 0 || x2 <= margin
= seq [ setPenBack colours.backgroundColour
, hilite r
]
| x1 >= margin
= seq [ setPenBack colours.marginColour
, hilite r
]
= seq [ setPenBack colours.marginColour
, hilite {r & corner1.x = margin}
, setPenBack colours.backgroundColour
, hilite {r & corner2.x = margin}
]
where
margin
= marginWidth * charWidth
vRemoveSelection :: EditMonad (PSt .l) nothing
vRemoveSelection =
getSelection >>>= \selection ->
......
......@@ -2,7 +2,7 @@ implementation module EdVisualText
// visual operations on texts
import StdClass, StdFunc, StdArray, StdInt, StdMisc, StdList
import StdClass, StdFunc, StdArray, StdInt, StdMisc, StdList, StdBool
import StdIOCommon, StdPicture, StdPSt, StdWindow
import EdText, EdTab, StrictList, EdMonad, EdSelection
......@@ -161,9 +161,13 @@ vUpdateRectangle text fontInfo=:{lineHeight,thefont,syntaxColours} rectangle=:{
= vUR
where
vUR pict
# lineNr1 = validateLineNr (y1 / lineHeight) text
# lineNr2 = validateLineNr (y2 / lineHeight) text
# rectangle` = {corner1 = {x = max (-1) x1, y = y1}, corner2 = {x = max (-1) x2, y = y2}}
# x1` = min x1 x2
# x2` = max x1 x2
# y1` = min y1 y2
# y2` = max y1 y2
# lineNr1 = validateLineNr (y1` / lineHeight) text
# lineNr2 = validateLineNr (y2` / lineHeight) text
# rectangle` = {corner1 = {x = max (-1) x1`, y = y1`}, corner2 = {x = max (-1) x2`, y = y2`}}
# region` = toRegion rectangle`
# pict = appClipPicture region` (seq
[ setPenFont thefont
......@@ -174,15 +178,19 @@ where
// drawBackground colours the background
drawBackground colours {charWidth, marginWidth} r=:{ corner1 = {x=x1,y=y1}, corner2 = {x=x2,y=y2} }
| marginWidth <= 0
| marginWidth <= 0 || x2 <= margin
= seq [ setPenBack colours.backgroundColour
, unfill r
]
// otherwise
= seq [ setPenBack colours.backgroundColour
, unfill {r & corner2.x = margin}
, setPenBack colours.marginColour
| x1 >= margin
= seq [ setPenBack colours.marginColour
, unfill r
]
//
= seq [ setPenBack colours.marginColour
, unfill {r & corner1.x = margin}
, setPenBack colours.backgroundColour
, unfill {r & corner2.x = margin}
]
where
margin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment