row_heights (#77)

Implements row heights and a command-line option `-F nn` for fteapot to set the general font size.

Also improves documentation and uniformizes key bindings somewhat between teapot and fteapot.

Resolves #57.

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #77
This commit is contained in:
Glen Whitney 2023-04-09 05:41:50 +00:00
parent 118374c46e
commit 0ca9d0176b
12 changed files with 588 additions and 167 deletions

39
src/tools/interpolate.py Normal file
View file

@ -0,0 +1,39 @@
# To get around the fact that fluid only allows numerical constants
# in some places that expressions would be preferred, this
# file takes a fluid file which may contain numerical constants of the form
#
# 9999NNN/*REPLACEMENT*/
#
# where the NNN are distinct digit sequences (of any length)
# and the corresponding fluid output and replaces any 9999NNN in the output
# with REPLACEMENT (which can of course be any text). Note that the
# entire numerical constant with its replacement comment must occur within
# a single line of the fluid file. The result is written
# to a new output file with the literal string `_interpolated` interpolated
# before its extension.
from pathlib import Path
import re
import sys
fluidin = sys.argv[1]
genfile = Path(sys.argv[2])
outfile = genfile.with_stem(genfile.stem + '_interpolated')
# First collect all of the replacements from the fluidfile
replacerPattern = re.compile(r"(9999\d*)/[*](.*)[*]/")
replacement = {}
with open(fluidin) as fluidf:
for line in fluidf:
foundpat = replacerPattern.search(line)
if foundpat:
replacement[foundpat[1]] = foundpat[2]
# Now make all replacements in the generated file
with open(outfile, 'w') as outf:
with open(genfile) as genf:
for line in genf:
line = line[:-1]
for key in replacement:
line = line.replace(key, replacement[key])
print(line, file=outf)