~ehmry/hottext

aa42c01b35fe09cbc19bf650b375566027651db8 — Emery Hemingway 1 year, 9 days ago fcd21c2 20231003
Lock inputs to fix build
9 files changed, 29 insertions(+), 6 deletions(-)

A .envrc
M .gitignore
A Tupfile
A configure.nix
M hottext.nimble
A lock.json
A shell.nix
A src/Tupfile
M src/hottext.nim
A .envrc => .envrc +3 -0
@@ 0,0 1,3 @@
source_env ..
use nix
export HOTTEXT_FONT_PATH=$(fc-list 'GentiumPlus-Regular' | awk -F: 'NR==1{print $1}')

M .gitignore => .gitignore +2 -1
@@ 1,2 1,3 @@
flake.lock
/nim.cfg
/src/gentium
hottext

A Tupfile => Tupfile +3 -0
@@ 0,0 1,3 @@
include_rules
: |> !nim_lk |> | ./<lock>
: configure.nix | lock.json |> nix eval --file %f --raw > %o |> nim.cfg | ./<lock>

A configure.nix => configure.nix +6 -0
@@ 0,0 1,6 @@
let
  pkgs = import <nixpkgs> { };
  inherit (pkgs) lib;
  lock = with builtins; fromJSON (readFile ./lock.json);
in lib.strings.concatLines
(map ({ path, srcDir, ... }: ''path:"${path}/${srcDir}"'') lock.depends)

M hottext.nimble => hottext.nimble +1 -1
@@ 1,6 1,6 @@
# Package

version       = "1.4"
version = "20231003"
author        = "Emery Hemingway"
description   = "Rapid serial text presenter"
license       = "Unlicense"

A lock.json => lock.json +1 -0
@@ 0,0 1,1 @@
{"depends":[{"url":"https://github.com/treeform/typography","rev":"a2a5165c36e0098dea526712890fb7e988ba27f2","date":"2022-08-20T19:38:32-07:00","path":"/nix/store/mp2pqjp7h27mzvk8nfl168j8jcq1j218-typography-a2a5165","sha256":"0n42hlvh0d9wkjr01p04jnkyn7y4y62pwjdcqw52absapbpsr1lb","hash":"sha256-i4as77pKLyUKx6xJfoXxxB/rp5UE3ACynDw1ADeFglg=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"0.7.14","packages":["typography"],"srcDir":"src"},{"url":"https://github.com/nim-lang/sdl2","rev":"84d4702e838d684b7304882ffe796f57ef422fb6","date":"2023-06-04T22:38:30+08:00","path":"/nix/store/7m8g6mlyvv0p8bvni1wndpvdgdab4si6-sdl2-84d4702","sha256":"1vilid9xx5mp2yvssa3wf6g9svqdan87090klis891k9w1dd8i51","hash":"sha256-oUTUWuBphoR0pBMkcJBVDW+dnnF8KK23F7eW3lOLNO4=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"v2.0.5","packages":["sdl2"],"srcDir":"src"},{"url":"https://github.com/guzba/nimsimd","rev":"156e424306756a106442aca985eed61a8d12097b","date":"2023-08-28T23:09:35-05:00","path":"/nix/store/yaxnrv03gsr70fgb1a8f0r9vkphd0giz-nimsimd-156e424","sha256":"0hg9iq509rjsgd33cp3452v7whgbc30b5lnajifkls0z66rc2ndh","hash":"sha256-sFnBsjEfaDpdlMrSssBg60F+tihkXDZGe1rmBAqO6UE=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"1.2.6","packages":["nimsimd"],"srcDir":"src"},{"url":"https://github.com/treeform/chroma","rev":"b2e71179174e040884ebf6a16cbac711c84620b9","date":"2022-08-01T19:16:58-07:00","path":"/nix/store/y23an7kvnlvf1x8rlwr7cgc46rnfq22n-chroma-b2e7117","sha256":"0pi6cq43ysm1wy5vva3i2dqvyh4dqppjjjl04yj9wfq7mngpqaa1","hash":"sha256-QSl8n60HO56kJ4BKKe/FjUC/cRNxqL2L56FqPwhmJl4=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"0.2.7","packages":["chroma"],"srcDir":"src"},{"url":"https://github.com/treeform/flatty","rev":"07f6ba8ab96238e5bd1264cf0cea1d1746abb00c","date":"2022-06-09T09:32:17+03:00","path":"/nix/store/xi687zj5k1f08npmgcvyahqr6dljqjzl-flatty-07f6ba8","sha256":"005nrldaasfl09zdsni1vi8s7dk0y85ijv6rm2wpj94435x66s36","hash":"sha256-ZmhjehmEJHm5qNlsGQvyYLajUdwhWt1+AtRppRrNtgA=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"0.3.4","packages":["flatty"],"srcDir":"src"},{"url":"https://github.com/guzba/zippy","rev":"a3fd6f0458ffdd7cbbd416be99f2ca80a7852d82","date":"2023-05-25T19:15:08-05:00","path":"/nix/store/hja2ysnkrxw8h0z868pcp9h3v56ymcbg-zippy-a3fd6f0","sha256":"0zmavr2jnyyqkvvi6hlg2kh6qv6lzakwvsqjy0sjm3qdsna0aldg","hash":"sha256-r1EFlNUNjyo18BLrzaf61Gxs4BSPQhP3nth7K0Xeqn4=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"0.10.10","packages":["zippy"],"srcDir":"src"},{"url":"https://github.com/treeform/bumpy","rev":"d7eaf00c24820ad0317c9926737402e62431e931","date":"2023-06-30T06:40:21-07:00","path":"/nix/store/flcdfpnbyv5snq870q7f9qj35x1898n8-bumpy-d7eaf00","sha256":"0wrvdpvbwv4ysjsqc6hhvd97vql4k0m5l0zdrsrjlljd1n5g2haq","hash":"sha256-WEHxig1NUiqzzu0DWiqYhOJ9UtsQGoa11J5svvZtO3M=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"1.1.2","packages":["bumpy"],"srcDir":"src"},{"url":"https://github.com/guzba/crunchy","rev":"d0c9ad33ae72aece49093d7688fc78a7101aa4b0","date":"2023-07-08T14:28:10-05:00","path":"/nix/store/may5kiym3zrylwkvc9s8ip6vgzr6sxwx-crunchy-d0c9ad3","sha256":"14qgxcnyznjc180kdbilqzzya589rqaznfpp75yp37n47zdknfw0","hash":"sha256-gDs72z/EnnF9Ofc6+xXOCRXl/8c0rjYBCkza7y3rD5M=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"0.1.9","packages":["crunchy"],"srcDir":"src"},{"url":"https://github.com/treeform/vmath","rev":"7282ae1247f2f384ebeaec3826d7fa38fd0e1df1","date":"2023-05-11T22:26:03-07:00","path":"/nix/store/0y7n54q3j5zkh6xsx7m425d04n0l8vvr-vmath-7282ae1","sha256":"1plw9lfrm42qar01rnjhm0d9mkzsc7c3b8kz43w5pb8j8drx1lyn","hash":"sha256-1tPQc0MSrVv4IH+iNdhh+s+aGqhQ2hxAVliQmh1NnN4=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"2.0.0","packages":["vmath"],"srcDir":"src"},{"url":"https://github.com/treeform/print","rev":"fb09637d6ebd6416b322a2b9bb95dd513040dea7","date":"2021-11-19T22:15:12+00:00","path":"/nix/store/ysmik93nkq7jyxbhfjbzizfmxs1s6xfj-print-fb09637","sha256":"1lyfnirwpy12lq9gr0sbnkf7ih7ayfvb1acjxk2z5gzlgxm1azp1","hash":"sha256-4X4Van/0v/LF7JKpsLbz6sB43LRLg/wSpiL4y3O0ztM=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"1.0.2","packages":["print"],"srcDir":"src"},{"url":"https://github.com/treeform/pixie","rev":"f3e73f722fbb0e5d496fbc59ee860a9fd49983de","date":"2023-01-24T19:36:47-08:00","path":"/nix/store/7xn1f6h8vas5d7gizw64zrqvzzinclhq-pixie-f3e73f7","sha256":"12mqlczckhxcrg6il213fn7mcnqz3khwkh7i4bn57l55nzrhfvrh","hash":"sha256-MG8H87el0FPsIvHAyeEcH1tWj3UjCBrNy6zDyT6juIo=","fetchLFS":false,"fetchSubmodules":true,"deepClone":false,"leaveDotGit":false,"method":"git","ref":"5.0.6","packages":["pixie"],"srcDir":"src"}]}

A shell.nix => shell.nix +4 -0
@@ 0,0 1,4 @@
let pkgs = import <nixpkgs> { }; in pkgs.nimPackages.buildNimPackage {
  name = "hottext";
  buildInputs = [ pkgs.SDL2 ];
}

A src/Tupfile => src/Tupfile +2 -0
@@ 0,0 1,2 @@
include_rules
: hottext.nim | ../<lock> |> !nim_bin |>

M src/hottext.nim => src/hottext.nim +7 -4
@@ 1,12 1,14 @@
# SPDX-License-Identifier: Unlicense

import pixie, hashes, tables, typography, typography/svgfont, unicode, vmath
import streams, strutils
import std/[streams, strutils]
import hashes, tables, typography, typography/svgfont, unicode, vmath, pixie
import sdl2

from os import getEnv, splitfile

const
  parseOtf = parser.parseOtf
  parseTtf = parser.parseTtf
  fontPathEnvKey = "HOTTEXT_FONT_PATH"
  fontSizeEnvKey = "HOTTEXT_FONT_SIZE"
  wpmKey = "HOTTEXT_WPM"


@@ 23,6 25,7 @@ proc defaultFont(): tuple[data: string, ext: string] =
const (defaultFontData, defaultFontExt) = defaultFont()

type
  Font = font.Font
  GlyphKey = object
    rune: Rune
    size: float


@@ 50,7 53,7 @@ type State = object
  wpm, period, delay, pos: int
  paused: bool

proc `=destroy`(state: var State) =
proc `=destroy`(state: State) =
  destroy(state.renderer)
  destroy(state.window)



@@ 193,7 196,7 @@ proc initState(): State =
  let fontSizeStr = getEnv(fontSizeEnvKey)
  result.font.size =
      if fontSizeStr == "": 48
      else: fontSizeStr.parseInt
      else: fontSizeStr.parseInt.float
  result.glyphCache = initTable[GlyphKey, GlyphEntry]()
  result.words = newSeq[string]()
  discard createWindowAndRenderer(