Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gfngfn committed Oct 9, 2018
2 parents 2c950de + c61df7b commit 3e56069
Show file tree
Hide file tree
Showing 68 changed files with 3,910 additions and 1,626 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.0.3] - 2018-10-09
### Fixed
- Does NOT insert spacing between different scripts when the [line breaking class](http://unicode.org/reports/tr14/) of the posterior charcter is CL, CP, QU, NS, JLCP, JLNS, JLCM, or JLFS.

# Added
- Supports the application of math commands to optional arguments.
- Provides primitives `set-space-ratio-between-scripts` and `get-space-ratio-between-scripts`.

## [0.0.2] - 2018-08-09
### Fixed
Expand Down
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ ATTYPE_GEN=$(FRONTEND)/__attype.gen.ml
VM_GEN=$(BYTECOMP)/__vm.gen.ml
IR_GEN=$(BYTECOMP)/__ir.gen.ml
EVAL_GEN=$(FRONTEND)/__evaluator.gen.ml
PRIM_GEN=$(FRONTEND)/__primitives.gen.ml
PRIM_PDF_GEN=$(FRONTEND)/__primitives_pdf_mode.gen.ml
PRIM_TEXT_GEN=$(FRONTEND)/__primitives_text_mode.gen.ml
GENS= \
$(INSTTYPE_GEN) \
$(ATTYPE_GEN) \
$(VM_GEN) \
$(IR_GEN) \
$(EVAL_GEN) \
$(PRIM_GEN)
$(PRIM_PDF_GEN) \
$(PRIM_TEXT_GEN)

.PHONY: all gen install lib uninstall clean

Expand All @@ -49,8 +51,11 @@ $(IR_GEN): $(INSTDEF) $(GENCODE)
$(EVAL_GEN): $(INSTDEF) $(GENCODE)
$(RUBY) $(GENCODE) --gen-interps $(INSTDEF) > $@

$(PRIM_GEN): $(INSTDEF) $(GENCODE)
$(RUBY) $(GENCODE) --gen-prims $(INSTDEF) > $@
$(PRIM_PDF_GEN): $(INSTDEF) $(GENCODE)
$(RUBY) $(GENCODE) --gen-pdf-mode-prims $(INSTDEF) > $@

$(PRIM_TEXT_GEN): $(INSTDEF) $(GENCODE)
$(RUBY) $(GENCODE) --gen-text-mode-prims $(INSTDEF) > $@

install: $(TARGET)
mkdir -p $(BINDIR)
Expand Down
6 changes: 3 additions & 3 deletions doc/local.satyh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@require: pervasives
@require: math
@require: stdja
@import: vdecoset
@import: decoset
@require: vdecoset
@require: hdecoset


type type-syntax =
Expand Down Expand Up @@ -178,7 +178,7 @@ let-inline ctx \meta m =

let-inline ctx \code inner =
let pads-code = (2pt, 2pt, 2pt, 2pt) in
let decoset-code = DecoSet.rectangle-round-fill 4pt 2pt (Color.gray 0.9) in
let decoset-code = HDecoSet.rectangle-round-fill 4pt 2pt (Color.gray 0.9) in
let ctx-code =
name-context ctx |> set-math-command (command \meta)
in
Expand Down
46 changes: 40 additions & 6 deletions doc/tabular.satyh
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
@require: option

let-inline ctx \tabular lstf =
let pads = (5pt, 5pt, 2pt, 10pt) in
let cellf it = NormalCell(pads, inline-fil ++ (read-inline ctx it) ++ inline-fil) in
let multif nr nc it = MultiCell(nr, nc, pads, inline-fil ++ (read-inline ctx it) ++ inline-fil) in
let empty = EmptyCell in
tabular (lstf cellf multif empty)
type cell-record =
(|
left : bool;
right : bool;
|)


module Tabular : sig

direct \tabular : [
(cell-record option -> inline-text -> cell) ->
(cell-record option -> int -> int -> inline-text -> cell) ->
cell ->
(cell list) list;
length list -> length list -> graphics list;
] inline-cmd

end = struct

let make-alignments ropt =
let r = Option.from (| right = true; left = true; |) ropt in
let f b = if b then inline-fil else inline-nil in
(f r#left, f r#right)


let-inline ctx \tabular lstf =
let pads = (5pt, 5pt, 2pt, 10pt) in
let cellf ropt it =
let (alignL, alignR) = make-alignments ropt in
NormalCell(pads, alignL ++ read-inline ctx it ++ alignR)
in
let multif ropt nr nc it =
let (alignL, alignR) = make-alignments ropt in
MultiCell(nr, nc, pads, alignL ++ (read-inline ctx it) ++ alignR)
in
let empty = EmptyCell in
tabular (lstf cellf multif empty)

end
25 changes: 17 additions & 8 deletions gen_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def default_false b
if b == nil then false else b end
end

def gen_prims
def gen_prims tag
YAML.load_stream(ARGF.read) do |inst|
if inst["is-primitive"] && inst["name"] != nil then
if default_false(inst[tag]) && inst["name"] != nil then
len = inst["params"].length
args = []
for i in 1..len
Expand All @@ -52,9 +52,17 @@ def gen_prims
end
end

def gen_pdf_mode_prims
gen_prims("is-pdf-mode-primitive")
end

def gen_text_mode_prims
gen_prims("is-text-mode-primitive")
end

def gen_interps
YAML.load_stream(ARGF.read) do |inst|
if inst["is-primitive"] && !default_false(inst["no-interp"]) then
if (inst["is-pdf-mode-primitive"] || inst["is-text-mode-primitive"]) && !default_false(inst["no-interp"]) then
tmpn = 0
astargs = []
valueidents = []
Expand Down Expand Up @@ -141,15 +149,15 @@ def gen_vminstrs
if inst["needs-reducef"] then
puts " let reducef = exec_application #{ENVIRONMENT} in"
end
if inst["is-primitive"] then
if (inst["is-pdf-mode-primitive"] || inst["is-text-mode-primitive"]) then
puts " let #{RET} ="
else
puts " begin"
end
inst["code"].each_line do |line|
puts " #{line}"
end
if inst["is-primitive"] then
if (inst["is-pdf-mode-primitive"] || inst["is-text-mode-primitive"]) then
puts " in #{VMEXEC} (#{RET} :: #{STACK}) #{ENVIRONMENT} #{CODE} #{DUMP}"
else
puts " end"
Expand Down Expand Up @@ -179,7 +187,7 @@ def gen_insttype

def gen_attype
YAML.load_stream(ARGF.read) do |inst|
if inst["is-primitive"] && !default_false(inst["no-ircode"]) then
if (inst["is-pdf-mode-primitive"] || inst["is-text-mode-primitive"]) && !default_false(inst["no-ircode"]) then
if inst["params"] != nil then
puts " | #{inst["inst"]} of #{(["abstract_tree"] * inst["params"].length).join ' * '}"
else
Expand All @@ -191,7 +199,7 @@ def gen_attype

def gen_ircases
YAML.load_stream(ARGF.read) do |inst|
if inst["is-primitive"] && !default_false(inst["no-ircode"]) then
if (inst["is-pdf-mode-primitive"] || inst["is-text-mode-primitive"]) && !default_false(inst["no-ircode"]) then
params = [*1..inst["params"].length].collect{|n| "p"+n.to_s}

puts " | #{inst["inst"]}(#{params.join ', '}) ->"
Expand All @@ -210,7 +218,8 @@ def gen_ircases
opt.on('--gen-insttype') {|v| func = method(:gen_insttype) }
opt.on('--gen-attype') {|v| func = method(:gen_attype) }
opt.on('--gen-interps') {|v| func = method(:gen_interps) }
opt.on('--gen-prims') {|v| func = method(:gen_prims) }
opt.on('--gen-pdf-mode-prims') {|v| func = method(:gen_pdf_mode_prims) }
opt.on('--gen-text-mode-prims') {|v| func = method(:gen_text_mode_prims) }

opt.parse!(ARGV)

Expand Down
3 changes: 2 additions & 1 deletion lib-satysfi/dist/hash/fonts.satysfi-hash
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"Junicode-b": <Single: {"src-dist": "Junicode-Bold.ttf"}>,
"Junicode-it": <Single: {"src-dist": "Junicode-Italic.ttf"}>,
"HiraKakuProN-W2": <Single: {"src-dist": "HiraKakuProN-W2.otf"}>,
"HiraKakuProN-W5": <Single: {"src-dist": "HiraKakuProN-W5.otf"}>
"HiraKakuProN-W5": <Single: {"src-dist": "HiraKakuProN-W5.otf"}>,
"Menlo": <Collection: {"src-dist": "Menlo.ttc", "index": 1}>
}
33 changes: 29 additions & 4 deletions lib-satysfi/dist/packages/code.satyh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
@require: pervasives
@require: list
@require: color
@require: gr
@require: vdecoset

module Code : sig

val scheme : deco-set -> color -> context -> string -> block-boxes
direct +code : [string] block-cmd
direct +console : [string] block-cmd
direct \code : [string] inline-cmd
direct \console : [string] inline-cmd
direct \d-code : [string] inline-cmd

end = struct

Expand Down Expand Up @@ -59,11 +64,16 @@ end = struct
(deco, deco, deco, deco)


let code-scheme decoset txtcolor ctx code =
let set-code-font ctx =
ctx |> set-font Latin (`lmmono`, 1., 0.)
|> set-hyphen-penalty 100000


let scheme decoset txtcolor ctx code =
let pads = (5pt, 5pt, 5pt, 5pt) in
block-frame-breakable ctx pads decoset (fun ctx -> (
let fontsize = get-font-size ctx in
let ctx = ctx |> set-font Latin (`lmmono`, 1., 0.) in
let ctx = ctx |> set-code-font in
let charwid = get-natural-width (read-inline ctx {0}) in
let ctx-code =
ctx |> set-space-ratio (charwid /' fontsize) 0. 0.
Expand Down Expand Up @@ -97,10 +107,25 @@ end = struct


let-block ctx +code code =
code-scheme decoset-code Color.black ctx code
scheme decoset-code Color.black ctx code


let-inline ctx \d-code code =
inline-fil ++ embed-block-breakable ctx
(read-block ctx '<+code(code);>)


let-block ctx +console code =
code-scheme decoset-console Color.white ctx code
scheme decoset-console Color.white ctx code


let-inline ctx \console code =
inline-fil ++ embed-block-breakable ctx
(read-block ctx '<+console(code);>)


let-inline ctx \code code =
script-guard Latin
(read-inline (ctx |> set-code-font) (embed-string code))

end
80 changes: 80 additions & 0 deletions lib-satysfi/dist/packages/footnote-scheme.satyh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@require: color
@require: gr


module FootnoteScheme : sig

val start-page : unit -> unit
val main : context -> (int -> inline-boxes) -> (int -> block-boxes) -> inline-boxes

end = struct

let-mutable footnote-ref <- 0
let-mutable first-footnote <- true


let bar-ratio = 0.5


let start-page () =
first-footnote <- true


let generate-footnote-label n =
`footnote:` ^ (arabic n)


let promote-another-trial () =
register-cross-reference `changed` `T`


let main ctx ibf bbf =
let () = footnote-ref <- !footnote-ref + 1 in
let num = !footnote-ref in
let label = generate-footnote-label num in
let it-num = embed-string (arabic num) in
let size = get-font-size ctx in
let ib-num = ibf num in
let bb = bbf num in
let bb-before =
match get-cross-reference label with
| Some(`T`) ->
let () = display-message (`'` ^ label ^ `': T`) in % for debug
let bar-top-margin = size in
let bar-bottom-margin = size *' 0.125 in
let wid = get-text-width ctx *' bar-ratio in
let ib =
inline-graphics wid bar-top-margin bar-bottom-margin (fun (x, y) ->
[ stroke 0.5pt Color.black (Gr.line (x, y) (x +' wid, y)); ]
) ++ inline-fil
in
line-break false false (ctx |> set-paragraph-margin 0pt 0pt) ib

| _ ->
let () = display-message (`'` ^ label ^ `': F`) in % for debug
block-skip (size *' 0.5)
in
no-break
(add-footnote (bb-before +++ bb) ++ ib-num
++ hook-page-break (fun _ _ -> (
let () =
if !first-footnote then
match get-cross-reference label with
| Some(`T`) ->
()

| _ ->
let () = promote-another-trial () in
register-cross-reference label `T`
else
match get-cross-reference label with
| Some(`F`) ->
()

| _ ->
let () = promote-another-trial () in
register-cross-reference label `F`
in
first-footnote <- false)))

end
25 changes: 25 additions & 0 deletions lib-satysfi/dist/packages/html-base.satyh-html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@require: option
@require: list

module HTMLBase : sig

val tag : (string * string) list?-> bool?-> int?-> text-info -> string -> (text-info -> string) -> string

end = struct

let make-props props =
props |> List.fold-left (fun sacc (k, v) -> (
sacc ^ #` `# ^ k ^ `="` ^ v ^ `"`
)) ` `


let tag ?:propsopt ?:bropt ?:indentopt tinfo s sf =
let props = Option.from [] propsopt in
let br = Option.from true bropt in
let indent = Option.from 2 indentopt in
let tinfo-inner = tinfo |> deepen-indent indent in
`<` ^ s ^ (make-props props) ^ `>` ^ (if br then break tinfo-inner else ` `)
^ (sf tinfo-inner)
^ (if br then break tinfo else ` `) ^ `</ ` ^ s ^ `>`

end
Loading

0 comments on commit 3e56069

Please sign in to comment.