From a5e8194d59ca0b0cd3f172f499600858dce9f6dd Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Fri, 18 Jul 2025 17:30:42 +0200 Subject: [PATCH] merged with-ctx-style and get-ctx --- src/core/draw/separator.typ | 8 ++++---- src/core/utils.typ | 21 +++++++-------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/core/draw/separator.typ b/src/core/draw/separator.typ index 54c5176..895897c 100644 --- a/src/core/draw/separator.typ +++ b/src/core/draw/separator.typ @@ -1,7 +1,7 @@ #import "/src/cetz.typ": draw, styles #import "/src/consts.typ": * -#import "/src/core/utils.typ": normalize-units, set-y, with-ctx-style +#import "/src/core/utils.typ": get-ctx, normalize-units, set-y #let separator-default-style = ( inset: ( @@ -13,9 +13,9 @@ outset: 20pt ) -#let render(sep) = with-ctx-style((ctx, glob-style) => { +#let render(sep) = get-ctx(ctx => { let style = styles.resolve( - glob-style, + ctx.style, merge: sep.style, root: "separator", base: separator-default-style @@ -23,7 +23,7 @@ let gap = normalize-units(style.gap) let outset = normalize-units(style.outset) - ctx.y -= glob-style.y-space + ctx.y -= ctx.style.y-space let x0 = ctx.x-pos.first() - outset let x1 = ctx.x-pos.last() + outset diff --git a/src/core/utils.typ b/src/core/utils.typ index b5ec822..4ce1ae4 100644 --- a/src/core/utils.typ +++ b/src/core/utils.typ @@ -112,6 +112,13 @@ #let get-ctx(func) = draw.get-ctx(c => { let ctx = extract-ctx(c) + ctx.style = styles.resolve( + c.style, + root: "chronos", + base: default-style + ) + // Normalize because it is used very frequently + ctx.style.y-space = normalize-units(ctx.style.y-space) func(ctx) }) @@ -129,17 +136,3 @@ } return ctx }) - -#let with-ctx-style(func) = draw.get-ctx(cetz-ctx => { - let ctx = extract-ctx(cetz-ctx) - let glob-style = styles.resolve( - cetz-ctx.style, - root: "chronos", - base: default-style - ) - - // Normalize because it is used very frequently - glob-style.y-space = normalize-units(glob-style.y-space) - - func(ctx, glob-style) -}) \ No newline at end of file