Skip to content

Commit

Permalink
build highlighting for ghost elements, minor refactoring (area9innova…
Browse files Browse the repository at this point in the history
  • Loading branch information
chekaninmaxim committed May 6, 2019
1 parent 9b19178 commit 1f7afb4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/form/paragraph3.flow
Original file line number Diff line number Diff line change
Expand Up @@ -665,15 +665,15 @@ RenderLine(
Ghost(xc, yc, fm): {
nextDistinct(xc, ^alignmentOffset);
nextDistinct(yc, y + dy);
None();
Some(applyStylesAndOffset(Empty()));
}
InspectGhost(xc, yc, wh, lh, ln, fm): {
nextDistinct(xc, ^alignmentOffset);
nextDistinct(yc, y + dy);
nextDistinct(wh, WidthHeight(m.width, m.height));
nextDistinct(lh, lineHeight);
nextDistinct(ln, lineNumber);
None();
Some(applyStylesAndOffset(Empty()));
}
CoordinateInspectElement(in, xc, yc, wh, lh, fm): {
fo = applyStylesAndOffset(fm);
Expand Down Expand Up @@ -701,7 +701,6 @@ applyIntStylesAndHighlighting(
height : double,
interWord : double,
) -> Form {

getStyleForBackgroundFromCharStyle = \s -> eitherMap(
tryExtractStruct(s, BackgroundFill(white)),
\backFill -> [
Expand All @@ -714,7 +713,10 @@ applyIntStylesAndHighlighting(
makeBackRect = \defStyle, dynStyle -> Rectangle(
width + interWord,
height,
replaceStructMany(defStyle, getStyleForBackgroundFromCharStyle(dynStyle))
replaceStructMany(
getStyleForBackgroundFromCharStyle(defStyle),
getStyleForBackgroundFromCharStyle(dynStyle)
)
);

dynamicCharStyleBM = tryExtractStruct(styles, DynamicCharStyle(make([])));
Expand All @@ -730,16 +732,15 @@ applyIntStylesAndHighlighting(
)
);

defBackStyle = getStyleForBackgroundFromCharStyle(txtStyle);
// We draw custom highlighting to fix gaps for cases of justifying alignment
// And to have more straight and pretty highlighting.
eitherMap(
dynamicCharStyleBM,
\dynCharStyle -> Pair(
Select(dynCharStyle.styleB, \chStyle -> makeTxt(chStyle)),
Select(dynCharStyle.styleB, \chStyle -> makeBackRect(defBackStyle, chStyle))
Select(dynCharStyle.styleB, \chStyle -> makeBackRect(txtStyle, chStyle))
),
Pair(makeTxt([]), makeBackRect(defBackStyle, []))
Pair(makeTxt([]), makeBackRect(txtStyle, []))
)
}
default : Pair(
Expand Down

0 comments on commit 1f7afb4

Please sign in to comment.