Skip to content

Commit

Permalink
spanned rendering wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yatli committed May 6, 2019
1 parent ff700f4 commit d534d07
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions Editor.xaml.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,34 @@ type Editor() as this =
let text = FormattedText()
text.Typeface <- typeface
text.TextAlignment <- TextAlignment.Left
str |> List.iteri (fun i t ->
let fontPos = rounding(topLeft + getPoint 0 i)
text.Text <- t
ctx.DrawText(fg, fontPos, text.PlatformImpl)

let sb = StringBuilder()

let _space = Seq.forall Char.IsWhiteSpace
let _span = Seq.forall Char.IsLetterOrDigit
let (|SPAN|DRAW|SKIP|) (x: string) =
if false then SPAN
elif _space x then SKIP
else DRAW

let mutable i0 = 0

let _draw () =
let str = sb.ToString()
ignore <| sb.Clear()
if str <> String.Empty then
let fontPos = rounding(topLeft + getPoint 0 i0)
text.Text <- str
ctx.DrawText(fg, fontPos, text.PlatformImpl)

str |> List.iteri (fun i s ->
match s with
| SPAN -> ignore <| sb.Append s
| DRAW -> _draw() ; i0 <- i; ignore <| sb.Append(s); _draw(); i0 <- i + 1
| SKIP -> _draw() ; i0 <- i + 1;
)
_draw()


// assembles text from grid and draw onto the context.
let drawBufferLine (ctx: IDrawingContextImpl) y x0 xN =
Expand Down

0 comments on commit d534d07

Please sign in to comment.