chiark / gitweb /
otter.git
2 years agosubst: Use ${...} format internally for most things
Ian Jackson [Sun, 15 May 2022 14:22:54 +0000 (15:22 +0100)]
subst: Use ${...} format internally for most things

This saves allocating in the usual case and is also clearer.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst tests: Add test cases for converting needles
Ian Jackson [Sun, 15 May 2022 14:29:40 +0000 (15:29 +0100)]
subst tests: Add test cases for converting needles

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Have substitutor handle any needle syntax
Ian Jackson [Sun, 15 May 2022 14:09:29 +0000 (15:09 +0100)]
subst: Have substitutor handle any needle syntax

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Have subst_general return the resolved needle
Ian Jackson [Sun, 15 May 2022 19:23:36 +0000 (20:23 +0100)]
subst: Have subst_general return the resolved needle

This corrects the error reporting to show what we actually looked for.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst test: Add many dbg calls
Ian Jackson [Sun, 15 May 2022 14:36:49 +0000 (15:36 +0100)]
subst test: Add many dbg calls

It turns out that I can make these fail and having it debug is useful.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: Change the inner edges in the blue d8
Ian Jackson [Sun, 15 May 2022 13:36:48 +0000 (14:36 +0100)]
dice: Change the inner edges in the blue d8

This looks better.  We will have to recolour them for the red die.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Substitute x* variables into magic template
Ian Jackson [Sun, 15 May 2022 13:35:10 +0000 (14:35 +0100)]
subst: Substitute x* variables into magic template

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: red wip
Ian Jackson [Sun, 15 May 2022 02:25:17 +0000 (03:25 +0100)]
dice: red wip

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: d8 wip
Ian Jackson [Sun, 15 May 2022 02:17:38 +0000 (03:17 +0100)]
dice: d8 wip

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Allow non-'static keys
Ian Jackson [Sun, 15 May 2022 12:34:18 +0000 (13:34 +0100)]
subst: Allow non-'static keys

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agomagic: Use new ${image} syntax
Ian Jackson [Sun, 15 May 2022 12:20:57 +0000 (13:20 +0100)]
magic: Use new ${image} syntax

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst test: Test format 2 more thoroughly
Ian Jackson [Sun, 15 May 2022 12:56:22 +0000 (13:56 +0100)]
subst test: Test format 2 more thoroughly

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst tests: Disable under miri
Ian Jackson [Sun, 15 May 2022 16:59:36 +0000 (17:59 +0100)]
subst tests: Disable under miri

We're going to add dbg! calls, which break.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst test: Test format 2
Ian Jackson [Sun, 15 May 2022 12:52:04 +0000 (13:52 +0100)]
subst test: Test format 2

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst test: Test mf1 Filename
Ian Jackson [Sun, 15 May 2022 12:49:41 +0000 (13:49 +0100)]
subst test: Test mf1 Filename

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst test: Reintroduce and fix up for new API
Ian Jackson [Sun, 15 May 2022 12:41:12 +0000 (13:41 +0100)]
subst test: Reintroduce and fix up for new API

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Make some things into methods
Ian Jackson [Sun, 15 May 2022 12:07:02 +0000 (13:07 +0100)]
subst: Make some things into methods

Wanted to do this for subst and substn but this terminally confuses
the borrow checker.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Always substitute dollars in mformat 2 text
Ian Jackson [Sun, 15 May 2022 11:47:50 +0000 (12:47 +0100)]
subst: Always substitute dollars in mformat 2 text

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Provide Dollars::enabled
Ian Jackson [Sun, 15 May 2022 11:45:46 +0000 (12:45 +0100)]
subst: Provide Dollars::enabled

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Hoist dollars into c_* aliases
Ian Jackson [Sun, 15 May 2022 11:43:52 +0000 (12:43 +0100)]
subst: Hoist dollars into c_* aliases

So now colour_subst_1 knows if it's text or not.
No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Demote PerhapsSubst
Ian Jackson [Sun, 15 May 2022 11:36:50 +0000 (12:36 +0100)]
subst: Demote PerhapsSubst

Reverts
  subst: Promote PerhapsSubst

We shouldn't do this for anything but colour specs.

And, really, we ought to do it only for the item name and not for the
other things, or the ${$} de-escaping is very confusing.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Track whether we're working in a filename
Ian Jackson [Sun, 15 May 2022 10:59:03 +0000 (11:59 +0100)]
subst: Track whether we're working in a filename

Ie, we are going to do this in a principled way, depending on what
kind of thing we are trying to generate, rather than just whether we
saw something other than "_c".

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Provide and use internal_err()
Ian Jackson [Sun, 15 May 2022 11:09:29 +0000 (12:09 +0100)]
subst: Provide and use internal_err()

We're going to have more things that might be wrong at runtime...

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Break out Substituting::err
Ian Jackson [Sun, 15 May 2022 11:05:33 +0000 (12:05 +0100)]
subst: Break out Substituting::err

We're going to want to reuse this.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoMake InternalLogicError be Clone, with an Arc
Ian Jackson [Sun, 15 May 2022 11:04:23 +0000 (12:04 +0100)]
Make InternalLogicError be Clone, with an Arc

shapelib wants this for SubstErrors which ought to be Clone.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Implement format 2 and convert all libraries
Ian Jackson [Sun, 15 May 2022 10:35:05 +0000 (11:35 +0100)]
subst: Implement format 2 and convert all libraries

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Have internal functions take borrows
Ian Jackson [Sun, 15 May 2022 10:28:30 +0000 (11:28 +0100)]
subst: Have internal functions take borrows

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Plumb mformat into Substituting, and change it to be Cow
Ian Jackson [Sun, 15 May 2022 10:04:46 +0000 (11:04 +0100)]
subst: Plumb mformat into Substituting, and change it to be Cow

This will allow us to do know whether to use the new format.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Temporarily comment out the test
Ian Jackson [Sun, 15 May 2022 12:40:46 +0000 (13:40 +0100)]
subst: Temporarily comment out the test

There is so much reorg here.  I don't want to keep editing this.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Track in type whether we're substituting
Ian Jackson [Sun, 15 May 2022 08:49:34 +0000 (09:49 +0100)]
subst: Track in type whether we're substituting

This stops us from failing to do a final cleanup step (which is going
to be replacing `${$}` when we have mformat 2 style.  It also stop us
restarting substitution unexpectedly, and marks places where text
enters the substitution machinery.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Promote PerhapsSubst
Ian Jackson [Sun, 15 May 2022 08:24:32 +0000 (09:24 +0100)]
subst: Promote PerhapsSubst

I thought we wanted this for sorts.  I find we don't, but I don't want
to drop this change and deal with the conflicts.  I will revert it
later.  Much later.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Make PerhapsSubst::finish fallible
Ian Jackson [Sun, 15 May 2022 08:19:14 +0000 (09:19 +0100)]
subst: Make PerhapsSubst::finish fallible

It is going to throw SubstError.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosubst: Introduce PerhapsSubst which will let us have subst chaining
Ian Jackson [Sun, 15 May 2022 08:15:35 +0000 (09:15 +0100)]
subst: Introduce PerhapsSubst which will let us have subst chaining

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: d8 wip
Ian Jackson [Sun, 15 May 2022 02:15:04 +0000 (03:15 +0100)]
dice: d8 wip

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: d8 wip
Ian Jackson [Sun, 15 May 2022 02:00:08 +0000 (03:00 +0100)]
dice: d8 wip

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: d8 wip
Ian Jackson [Sun, 15 May 2022 01:56:51 +0000 (02:56 +0100)]
dice: d8 wip

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agootterlib: Show large objects a bit bigger
Ian Jackson [Sun, 15 May 2022 01:48:44 +0000 (02:48 +0100)]
otterlib: Show large objects a bit bigger

This algorithm is a bit paants.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agootterlib: Show three views only for first two faces
Ian Jackson [Sun, 15 May 2022 01:46:43 +0000 (02:46 +0100)]
otterlib: Show three views only for first two faces

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agootterlib: Fix column handling in preview
Ian Jackson [Sun, 15 May 2022 01:44:13 +0000 (02:44 +0100)]
otterlib: Fix column handling in preview

This was very confused.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: Get size right in preview with a special entrypoint
Ian Jackson [Sun, 15 May 2022 00:36:30 +0000 (01:36 +0100)]
dice: Get size right in preview with a special entrypoint

This is the code from
  dice: Get size right in preview by setting bbox, breaking other things
but in a new entrypoint used only for preview.  The comment explains why.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoRevert "dice: Get size right in preview by setting bbox, breaking other things"
Ian Jackson [Sun, 15 May 2022 00:36:43 +0000 (01:36 +0100)]
Revert "dice: Get size right in preview by setting bbox, breaking other things"

This reverts commit 1df93eed42dc37563a7bf5df825f800cb871396d.

2 years agodice: Get size right in preview by setting bbox, breaking other things
Ian Jackson [Sun, 15 May 2022 00:34:32 +0000 (01:34 +0100)]
dice: Get size right in preview by setting bbox, breaking other things

This is wrong.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: Unwrap surround_path
Ian Jackson [Sun, 15 May 2022 00:34:14 +0000 (01:34 +0100)]
dice: Unwrap surround_path

We're making changes here and it's confusing.  Make this more
prominent.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: Delegate our shape and bbox to outline
Ian Jackson [Sun, 15 May 2022 00:07:10 +0000 (01:07 +0100)]
dice: Delegate our shape and bbox to outline

The bbox is still wrong.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: Preview partially-cooled-down
Ian Jackson [Sat, 14 May 2022 12:51:26 +0000 (13:51 +0100)]
dice: Preview partially-cooled-down

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agospecs: Adjust shapes to be right with new code
Ian Jackson [Sat, 14 May 2022 22:56:13 +0000 (23:56 +0100)]
specs: Adjust shapes to be right with new code

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: Adjust circle size to be right for images which are circles
Ian Jackson [Sat, 14 May 2022 22:41:53 +0000 (23:41 +0100)]
dice: Adjust circle size to be right for images which are circles

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoAdd shape method to OutlineTrait
Ian Jackson [Sat, 14 May 2022 22:17:24 +0000 (23:17 +0100)]
Add shape method to OutlineTrait

dice will use this to decide their own outline.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoimpl OutlineTrait via ambassador for GenericSimpleShape
Ian Jackson [Sat, 14 May 2022 22:29:21 +0000 (23:29 +0100)]
impl OutlineTrait via ambassador for GenericSimpleShape

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoimpl_via_ambassador: Support generics
Ian Jackson [Sat, 14 May 2022 22:32:55 +0000 (23:32 +0100)]
impl_via_ambassador: Support generics

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoimpl OutlineTrait via ambassador for many types
Ian Jackson [Sat, 14 May 2022 22:17:20 +0000 (23:17 +0100)]
impl OutlineTrait via ambassador for many types

We're going to add a method...

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoMove shapelib Outline structs into outline
Ian Jackson [Sat, 14 May 2022 22:14:24 +0000 (23:14 +0100)]
Move shapelib Outline structs into outline

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoMove outline into its own file
Ian Jackson [Sat, 14 May 2022 22:11:56 +0000 (23:11 +0100)]
Move outline into its own file

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoUnify outlines from shapelib and spec
Ian Jackson [Sat, 14 May 2022 22:09:04 +0000 (23:09 +0100)]
Unify outlines from shapelib and spec

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoMacro-ise spec::outline
Ian Jackson [Sat, 14 May 2022 21:59:00 +0000 (22:59 +0100)]
Macro-ise spec::outline

We're going to do more here...

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoRename RectOutline and CircleOutline
Ian Jackson [Sat, 14 May 2022 21:50:56 +0000 (22:50 +0100)]
Rename RectOutline and CircleOutline

These are outlines and we are going to want an enum for just the
shapes.  Well, that's the Defn from shapelib but we want it more
generally.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Rationalise some imports
Ian Jackson [Sat, 14 May 2022 21:30:56 +0000 (22:30 +0100)]
shapelib: Rationalise some imports

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agootterlib: Show selection ring *over* the piece
Ian Jackson [Sat, 14 May 2022 20:57:01 +0000 (21:57 +0100)]
otterlib: Show selection ring *over* the piece

This is what the game UI does.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agopiece API: rename save_reloaded_hook
Ian Jackson [Sat, 14 May 2022 20:51:36 +0000 (21:51 +0100)]
piece API: rename save_reloaded_hook

This is clearer, given that we have load() for turning a spec into a
loaded piece.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosupport: Move slotmap
Ian Jackson [Sat, 14 May 2022 19:41:45 +0000 (20:41 +0100)]
support: Move slotmap

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosupport: Move digestrw and timedfd
Ian Jackson [Sat, 14 May 2022 19:37:30 +0000 (20:37 +0100)]
support: Move digestrw and timedfd

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosupport: Move config
Ian Jackson [Sat, 14 May 2022 19:18:55 +0000 (20:18 +0100)]
support: Move config

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosupport: Rename PacketFrame errors
Ian Jackson [Sat, 14 May 2022 18:58:25 +0000 (19:58 +0100)]
support: Rename PacketFrame errors

That's what they are.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosupport: Move packetframe et al.
Ian Jackson [Sat, 14 May 2022 18:37:12 +0000 (19:37 +0100)]
support: Move packetframe et al.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosupport: Move childio and debugmutex
Ian Jackson [Sat, 14 May 2022 18:18:59 +0000 (19:18 +0100)]
support: Move childio and debugmutex

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agosupport: Move tz file to right directory
Ian Jackson [Sat, 14 May 2022 18:10:51 +0000 (19:10 +0100)]
support: Move tz file to right directory

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agocrate structure: Write down the import structure doctrine.
Ian Jackson [Sat, 14 May 2022 17:09:18 +0000 (18:09 +0100)]
crate structure: Write down the import structure doctrine.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agocrate structure: Rename "prelude-part" to "imports"
Ian Jackson [Sat, 14 May 2022 17:01:55 +0000 (18:01 +0100)]
crate structure: Rename "prelude-part" to "imports"

This is less clumsy.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agocrate structure: Rename "imports" to "crates"
Ian Jackson [Sat, 14 May 2022 16:59:03 +0000 (17:59 +0100)]
crate structure: Rename "imports" to "crates"

This will let us use "imports" for what is now "prelude-part".

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agocrate structure: Introduce otter-support crate
Ian Jackson [Sat, 14 May 2022 15:29:19 +0000 (16:29 +0100)]
crate structure: Introduce otter-support crate

Currently this only has tz.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoDrop some unneeded re-exports, and make the use of imports::* pub
Ian Jackson [Sat, 14 May 2022 16:11:56 +0000 (17:11 +0100)]
Drop some unneeded re-exports, and make the use of imports::* pub

I think these re-exports were there because I thought the multiple
paths to import were making things ambiguous but actually,
experimentation shows that making the imports re-export pub works
and that it isn't possible to re-export things from the private use.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agodice: Introduce die-d6-blue library item and use it
Ian Jackson [Fri, 13 May 2022 19:08:35 +0000 (20:08 +0100)]
dice: Introduce die-d6-blue library item and use it

This moves the die spec into the library.  It works now!  Although
it's not cosmetically very nice.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Do not "note" the nonexistent SVG for magic items
Ian Jackson [Sat, 14 May 2022 18:07:19 +0000 (19:07 +0100)]
shapelib: Do not "note" the nonexistent SVG for magic items

These do not need processing during bundle upload.  Indeed, attempting
it causes it to fail since there isn't actually any SVG.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Break out LibrarySvgNoter
Ian Jackson [Sat, 14 May 2022 18:05:34 +0000 (19:05 +0100)]
shapelib: Break out LibrarySvgNoter

We're going to want a dummy one for magic library items.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Substitute _colour multiple times if necessary
Ian Jackson [Sat, 14 May 2022 14:36:21 +0000 (15:36 +0100)]
shapelib: Substitute _colour multiple times if necessary

No, or many, is not an error here.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib subst: Provide subst_general and change substn
Ian Jackson [Sat, 14 May 2022 14:35:20 +0000 (15:35 +0100)]
shapelib subst: Provide subst_general and change substn

We're going to want this convenience alias.  substn's previous
signature was not helpful.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib subst: Provide subst arg to colour_subst_1
Ian Jackson [Sat, 14 May 2022 14:33:22 +0000 (15:33 +0100)]
shapelib subst: Provide subst arg to colour_subst_1

We're going to want to call substn too.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib subst: Provide substn
Ian Jackson [Sat, 14 May 2022 14:13:55 +0000 (15:13 +0100)]
shapelib subst: Provide substn

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib subst: Add test cases for subst()
Ian Jackson [Sat, 14 May 2022 14:18:18 +0000 (15:18 +0100)]
shapelib subst: Add test cases for subst()

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: magic: Actually substitute _colour in the template
Ian Jackson [Sat, 14 May 2022 14:11:06 +0000 (15:11 +0100)]
shapelib: magic: Actually substitute _colour in the template

This doesn't actually work because _colour appears multiple times and
subst insists on it being there only once.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Add a trace call for the magic template
Ian Jackson [Sat, 14 May 2022 14:08:39 +0000 (15:08 +0100)]
shapelib: Add a trace call for the magic template

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agootterlib: Initialise the nwtemplates
Ian Jackson [Sat, 14 May 2022 13:53:01 +0000 (14:53 +0100)]
otterlib: Initialise the nwtemplates

Otherwise library items that depend on magical pieces that use these
templates (eg, dice) don't work correctly.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agonwtemplates: Split init_from_config and init_from_dir
Ian Jackson [Sat, 14 May 2022 13:54:03 +0000 (14:54 +0100)]
nwtemplates: Split init_from_config and init_from_dir

otterlib is going to call init_from_dir.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agonwtemplates: Log a warning if there are no templates
Ian Jackson [Sat, 14 May 2022 13:52:42 +0000 (14:52 +0100)]
nwtemplates: Log a warning if there are no templates

This is probably an installation or usage error.  Reporting that helps
if subsequently a template isn't found.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agootterlib: Pass opts to preview()
Ian Jackson [Sat, 14 May 2022 13:57:57 +0000 (14:57 +0100)]
otterlib: Pass opts to preview()

This is going to want the nwtemplates directory.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agootterlib: Plumb gpc through from load to render
Ian Jackson [Sat, 14 May 2022 13:02:59 +0000 (14:02 +0100)]
otterlib: Plumb gpc through from load to render

Some magical pieces require their xdata (which they set in load) for
rendering.  And now we can have library pieces which contain magical
pieces which otterlib must therefore handle.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoMakefile: Break out NWTEMPLATEASSETS variable
Ian Jackson [Sat, 14 May 2022 13:59:50 +0000 (14:59 +0100)]
Makefile: Break out NWTEMPLATEASSETS variable

We're going to want this for the dependencies of the shapelib,
since otterlib will need to read this template.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib magic: implement
Ian Jackson [Fri, 13 May 2022 23:44:19 +0000 (00:44 +0100)]
shapelib magic: implement

This still has some bugs.  We mustn't invoke it just yet in our
library bundles, because it will fail.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agospec: LibraryItemNotFound: Actually report the ItemSpec
Ian Jackson [Sat, 14 May 2022 14:43:55 +0000 (15:43 +0100)]
spec: LibraryItemNotFound: Actually report the ItemSpec

This error message was hopeless.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoMake TomlQuote pub
Ian Jackson [Sat, 14 May 2022 12:21:11 +0000 (13:21 +0100)]
Make TomlQuote pub

Like it should have been.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Break out subst_item_name
Ian Jackson [Sat, 14 May 2022 12:19:42 +0000 (13:19 +0100)]
shapelib: Break out subst_item_name

Magic is going to want this.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Break out format_item_name
Ian Jackson [Sat, 14 May 2022 10:01:44 +0000 (11:01 +0100)]
shapelib: Break out format_item_name

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Rework colour substitution
Ian Jackson [Sat, 14 May 2022 11:50:09 +0000 (12:50 +0100)]
shapelib: Rework colour substitution

There were too many repetitions of the variable names etc.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Fix sort key colour abbrev
Ian Jackson [Sat, 14 May 2022 11:48:36 +0000 (12:48 +0100)]
shapelib: Fix sort key colour abbrev

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoProvide TomlQuote instead
Ian Jackson [Sat, 14 May 2022 01:05:09 +0000 (02:05 +0100)]
Provide TomlQuote instead

This is slightly better in terms of consing.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoProvide toml_quote_string
Ian Jackson [Sat, 14 May 2022 00:50:55 +0000 (01:50 +0100)]
Provide toml_quote_string

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoAdd lazy_regex dependency
Ian Jackson [Fri, 13 May 2022 23:49:17 +0000 (00:49 +0100)]
Add lazy_regex dependency

Sadly we can't use this in spec.rs because it's not compatible with
concat!

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Break out Catalouge::add_item
Ian Jackson [Fri, 13 May 2022 23:36:25 +0000 (00:36 +0100)]
shapelib: Break out Catalouge::add_item

We're going to want to call this again in add1, I think.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Break out process_files_entry
Ian Jackson [Fri, 13 May 2022 23:24:41 +0000 (00:24 +0100)]
shapelib: Break out process_files_entry

load_catalogue was getting quite unwieldy.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoshapelib: Implement Magic catalogue entries
Ian Jackson [Fri, 13 May 2022 22:52:07 +0000 (23:52 +0100)]
shapelib: Implement Magic catalogue entries

But nothing constructs them.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>