From 2b7a4e8d26e71569edd13c2d2cc74e6c9bedd864 Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Mon, 23 May 2022 23:14:55 +0200 Subject: [PATCH] clean up implicits --- copret/src/syntax.scala | 4 ++-- copret/src/templates.scala | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/copret/src/syntax.scala b/copret/src/syntax.scala index 0850a41..8fb3dba 100644 --- a/copret/src/syntax.scala +++ b/copret/src/syntax.scala @@ -1,7 +1,7 @@ package de.qwertyuiop.copret object syntax extends Templates with TerminalSyntax with SlideSyntax: - import Format._ + import Format.* extension (str: String) def code(using theme: Theme) = Format.ticks.replaceAllIn(str, m => theme.style("code")("$1").render) def text(using Theme) = Paragraph(str) @@ -22,7 +22,7 @@ object syntax extends Templates with TerminalSyntax with SlideSyntax: def red = fansi.Color.Red(str) extension (str: fansi.Str) - def text(using Theme) = Paragraph(str) + def text(using Theme) = Paragraph(str.toString) def style(key: String, default: fansi.Attrs)(using theme: Theme) = theme.style(key, default)(str) def blue = fansi.Color.Blue(str) diff --git a/copret/src/templates.scala b/copret/src/templates.scala index 29f4d9b..ee5447b 100644 --- a/copret/src/templates.scala +++ b/copret/src/templates.scala @@ -1,24 +1,28 @@ package de.qwertyuiop.copret -import syntax._ -import ammonite.ops.{Path, %, %%, pwd} +import syntax.* +import ammonite.ops.{Path, %, %%, pwd, ImplicitWd} trait Templates: - def titleLine(title: String)(implicit theme: Theme) = Paragraph( + def titleLine(title: String)(using theme: Theme) = Paragraph( "\n" + Format.figlet(title, theme.font("titleLine", "pagga")).block.blue + "\n" ) - def header(implicit theme: Theme) = Meta((p, pos) => { + def header(using theme: Theme) = Meta((p, pos) => { val left = p.meta.getOrElse("author", "") val center = p.meta.getOrElse("title", "") val right = s"${pos} / ${p.slides.size - 1}" theme.style("titleLine")(Format.distribute(left, center, right)).text }) - def slide(title: String)(slides: Slide*) = Group(Clear :: header :: titleLine(title) :: slides.toList) - def slide(slides: Slide*) = Group(Clear :: header :: slides.toList) + def slide(title: String)(slides: Slide*)(using Theme) = Group(Clear :: header :: titleLine(title) :: slides.toList) + def slide(slides: Slide*)(using Theme) = Group(Clear :: header :: slides.toList) - def markdown(title: String, content: Path) = slide(title)(IncludeMarkdown(content)) + def markdown(title: String, content: Path)(using Theme) = slide(title)( + Paragraph( + %%%("/usr/bin/mdcat", "--columns", (columns * 0.8).toInt.toString, content.toString)(using ImplicitWd.implicitCwd).block + ) + ) - lazy val --- = Paragraph(("═" * columns).yellow) + lazy val --- = Paragraph(("═" * columns).yellow.toString) /* vim:set tw=120: */