The refill slot was only putting as many items as possible in a
stack, which does nothing for tools. Tools could benefit from repair,
recharging, or other behaviour depending on the type of tool. Change the
default refill behaviour to repair mechanical wear as well as fully
stacking. Because other kinds of refill will require knowledge of the
metadata format, they can't be directly handled here. So add an on_refill
hook, that tool definitions can supply to plug in appropriate behaviour.
Keep the current inventory search string when performing inventory
form actions other than searching. This means the player's input is
not lost if the player breaks off from entering it to switch pages,
or if the player absent-mindedly ends text input with <return>.