Add a function that adds an entry to a menuq, normalizing a common code
path; from Tiago Cunha.
 - remove redundant range check for buttons in conf_bind_mouse.
 - make conf_bind_kbd return error on non-matches to match what
   conf_bind_mouse does.
 - rename some variables while here for clarity.
 - constify bind and cmd.

from Tiago Cunha.
constify and rename some confusing variables around cmdq.
Use argument to pass down flags for mousefunc cyclegroup; removes
rcyclegroup wrapper need - now similar to kbfunc.
merge KBFLAG_NEEDCLIENT and MOUSEBIND_CTX_*; brings kbfunc and mousefunc
bits even closer.
Save the ptr position before lowering via kbd, so as to be able to cycle
back with the pointer in the right place; matches behaviour when
lowering via the mouse function.
Sprinkle a few more const; from Tiago Cunha.
Somewhat streamline event loop/restart/quit handling; most notable
change allows a restart to trigger proper teardown first, even though
teardown is not (yet) complete.

After some discussion with oga@nicotinebsd.org regarding a more
complicated version/idea.
start properly releasing X resources during teardown
cwm_argv doesn't need to be global any longer
zap whitespace
If no title is supplied, term uses only the basename for its title.
This is useless when searching for windows launched via the ssh command
menu; supply a more useful title: '[ssh] <hostname>'.

Idea from todd@, ok todd@
no need to quote within warning
correct arguments and drop the cast.

sanity check by oga@nicotinebsd
more range checking