lib: nice helper function for writing `case` statments.

* lib/zile/lib.lua (case): New function. Instead of a cascade
of elseifs that recalculate the same comparison, this function
calculates it one and looks up a dispatch function in the
passed table.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
MutableString: make sub `to` argument optional.

* lib/zile/MutableString.lua (sub): Default `to` to end of string.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
MutableString: Add topointer method.

* lib/zile/MutableString.lua (topointer): Call topointer() on
self.buf.buffer.
(MutableString.__index): Move table of methods from here...
(_functions): ...to here.
(MutableString.__index): Merge topointer to make method table.
(move, replace, set): Use topointer.
(_init): Allow initialisation from another MutableString, or a
byte count as well as a Lua string.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
MutableString: support [] for per-character references by offset.

* lib/zile/MutableString.lua (__index): Move methods from here...
(methods): ...to here.
(__index): If argument is a number, return the character at that
offset, otherwise try the method table.
* lib/zile/estr.lua (__index): Defer to MutableString.__index.
* lib/zile/buffer.lua (get_buffer_char): Fetch a character
directly from the buffer without an intermediate tostring().

Signed-off-by: Gary V. Vaughan <gary@gnu.org>