-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend
Inline
and Block
, and add String
- Loading branch information
Showing
7 changed files
with
212 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,46 @@ | ||
use List | ||
use Inline | ||
|
||
module Block :> sig | ||
val nil : block-boxes | ||
val concat : list block-boxes -> block-boxes | ||
val skip : length -> block-boxes | ||
val clear-page : block-boxes | ||
val form-paragraph : context -> inline-boxes -> block-boxes | ||
val +skip : block [length] | ||
val \skip : inline [length] | ||
val +clear-page : block [] | ||
val +ragged-right : block [inline-text] | ||
val +centering : block [inline-text] | ||
val \skip : inline [length] | ||
end = struct | ||
|
||
val nil = | ||
block-nil | ||
val nil = block-nil %PRIMITIVE | ||
|
||
val concat bbs = | ||
List.fold ( +++ ) nil bbs | ||
|
||
val skip = block-skip %PRIMITIVE | ||
|
||
val clear-page = clear-page %PRIMITIVE | ||
|
||
val form-paragraph = | ||
line-break true true | ||
|
||
val block ctx +skip len = | ||
block-skip len | ||
|
||
val inline ctx \skip len = | ||
inline-fil ++ embed-block-breakable ctx (block-skip len) ++ omit-skip-after | ||
|
||
val block ctx +clear-page = | ||
clear-page | ||
|
||
val block ctx +ragged-right it = | ||
form-paragraph ctx (inline-fil ++ read-inline ctx it) | ||
form-paragraph ctx (Inline.fil ++ read-inline ctx it) | ||
|
||
val block ctx +centering it = | ||
form-paragraph ctx (inline-fil ++ read-inline ctx it ++ inline-fil) | ||
form-paragraph ctx (Inline.fil ++ read-inline ctx it ++ Inline.fil) | ||
|
||
val inline ctx \skip len = | ||
Inline.fil | ||
++ Inline.embed-block-breakable ctx (skip len) | ||
++ Inline.omit-skip-after | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 61 additions & 18 deletions
79
lib-satysfi/packages/stdlib/stdlib.0.0.1/src/inline.satyh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,93 @@ | ||
use open Basic | ||
use List | ||
use Deco | ||
|
||
module Inline :> sig | ||
val get-natural-advance : inline-boxes -> length | ||
val nil : inline-boxes | ||
val concat : list inline-boxes -> inline-boxes | ||
val fil : inline-boxes | ||
val get-natural-metrics : inline-boxes -> length * length * length | ||
val get-natural-advance : inline-boxes -> length | ||
val skip : length -> inline-boxes | ||
val kern : length -> inline-boxes | ||
val \skip : inline [length] | ||
val glue : length -> length -> length -> inline-boxes | ||
val frame-inner : paddings -> deco -> inline-boxes -> inline-boxes | ||
val frame-outer : paddings -> deco -> inline-boxes -> inline-boxes | ||
val frame-fixed : length -> paddings -> deco -> inline-boxes -> inline-boxes | ||
val frame-breakable : paddings -> deco-set -> inline-boxes -> inline-boxes | ||
val embed-block-breakable : context -> block-boxes -> inline-boxes | ||
val graphics-fixed : length -> length -> length -> (point -> graphics) -> inline-boxes | ||
val graphics-outer : length -> length -> (length -> point -> graphics) -> inline-boxes | ||
val no-break : inline-boxes -> inline-boxes | ||
val mandatory-break : context -> inline-boxes | ||
val omit-skip-after : inline-boxes | ||
val \skip : inline [length] | ||
val \no-break : inline [inline-text] | ||
val \fil : inline [] | ||
val \fil-both : inline [] | ||
val mandatory-break : context -> inline-boxes | ||
val \mandatory-break : inline [] | ||
end = struct | ||
|
||
val nil = inline-nil %PRIMITIVE | ||
|
||
val concat ibs = | ||
List.fold ( ++ ) nil ibs | ||
|
||
val fil = inline-fil %PRIMITIVE | ||
|
||
val get-natural-metrics = get-natural-metrics %PRIMITIVE | ||
|
||
val get-natural-advance ib = | ||
let (wid, _, _) = get-natural-metrics ib in | ||
wid | ||
|
||
val nil = | ||
inline-nil | ||
val skip = inline-skip %PRIMITIVE | ||
|
||
val concat ibs = | ||
List.fold ( ++ ) nil ibs | ||
val kern len = | ||
skip (0pt -' len) | ||
|
||
val kern len = inline-skip (0pt -' len) | ||
val glue = inline-glue %PRIMITIVE | ||
|
||
val inline ctx \skip len = | ||
inline-skip len | ||
val discretionary = discretionary %PRIMITIVE | ||
|
||
val mandatory-break ctx = | ||
discretionary 0 (skip (get-text-width ctx *' 2.)) fil nil | ||
|
||
val frame-inner = inline-frame-inner %PRIMITIVE | ||
|
||
val frame-outer = inline-frame-outer %PRIMITIVE | ||
|
||
val frame-fixed = inline-frame-fixed %PRIMITIVE | ||
|
||
val frame-breakable = inline-frame-breakable %PRIMITIVE | ||
|
||
val embed-block-breakable = embed-block-breakable %PRIMITIVE | ||
|
||
val graphics-fixed = inline-graphics %PRIMITIVE | ||
|
||
val graphics-outer = inline-graphics-outer %PRIMITIVE | ||
|
||
val no-break ib = | ||
inline-frame-outer (0pt, 0pt, 0pt, 0pt) (fun _ _ _ _ -> unite-graphics []) ib | ||
inline-frame-outer (0pt, 0pt, 0pt, 0pt) Deco.empty ib | ||
|
||
val inline ctx \no-break inner = | ||
no-break (read-inline ctx inner) | ||
val omit-skip-after = omit-skip-after %PRIMITIVE | ||
|
||
val inline ctx \skip len = | ||
skip len | ||
|
||
val inline ctx \kern len = | ||
kern len | ||
|
||
val inline ctx \fil = | ||
discretionary 0 inline-nil inline-fil inline-nil | ||
discretionary 0 nil fil nil | ||
|
||
val inline ctx \fil-both = | ||
discretionary 0 inline-nil inline-fil inline-fil | ||
|
||
val mandatory-break ctx = | ||
discretionary 0 (inline-skip (get-text-width ctx *' 2.)) inline-fil inline-nil | ||
discretionary 0 nil fil fil | ||
|
||
val inline ctx \mandatory-break = | ||
mandatory-break ctx | ||
|
||
val inline ctx \no-break inner = | ||
no-break (read-inline ctx inner) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use open Basic | ||
use Int | ||
use List | ||
|
||
module String :> sig | ||
type t = string | ||
val ~lift : string -> code string | ||
val persistent ~compare : string -> string -> ordering | ||
val persistent ~equal : string -> string -> bool | ||
val persistent ~append : string -> string -> string | ||
val persistent ~length : string -> int | ||
val persistent ~byte-length : string -> int | ||
val persistent ~sub : string -> int -> int -> string | ||
val persistent ~sub-bytes : string -> int -> int -> string | ||
val persistent ~to-scalar-values : string -> list int | ||
val persistent ~from-scalar-values : list int -> string | ||
val persistent ~normalize-to-nfc : string -> string | ||
val persistent ~normalize-to-nfd : string -> string | ||
val persistent ~split-into-grapheme-clusters : string -> list string | ||
val persistent ~empty : string | ||
val persistent ~split-into-lines : string -> list (int * string) | ||
end = struct | ||
|
||
type t = string | ||
|
||
val ~lift = lift-string %PRIMITIVE | ||
|
||
val persistent ~equal = string-same %PRIMITIVE | ||
|
||
val persistent ~append = ( ^ ) %PRIMITIVE | ||
|
||
val persistent ~length = string-length %PRIMITIVE | ||
|
||
val persistent ~byte-length = string-byte-length %PRIMITIVE | ||
|
||
val persistent ~sub = string-sub %PRIMITIVE | ||
|
||
val persistent ~sub-bytes = string-sub-bytes %PRIMITIVE | ||
|
||
val persistent ~to-scalar-values = string-explode %PRIMITIVE | ||
|
||
val persistent ~from-scalar-values = string-unexplode %PRIMITIVE | ||
|
||
val persistent ~normalize-to-nfc = normalize-string-to-nfc %PRIMITIVE | ||
|
||
val persistent ~normalize-to-nfd = normalize-string-to-nfd %PRIMITIVE | ||
|
||
val persistent ~split-into-grapheme-clusters = split-grapheme-cluster %PRIMITIVE | ||
|
||
val persistent ~compare s1 s2 = | ||
List.compare Int.compare (to-scalar-values s1) (to-scalar-values s2) | ||
|
||
val persistent ~empty = | ||
` ` | ||
|
||
val persistent ~split-into-lines = split-into-lines %PRIMITIVE | ||
|
||
end |