#include <stdlib.h>
 #include <sys/ttydefaults.h>
 #include "browser.h"
+#include "helpline.h"
 #include "../color.h"
 #include "../util.h"
 
        self->seek(self, 0, SEEK_SET);
 }
 
-int ui_browser__show(struct ui_browser *self, const char *title)
+int ui_browser__show(struct ui_browser *self, const char *title,
+                    const char *helpline, ...)
 {
+       va_list ap;
+
        if (self->form != NULL) {
                newtFormDestroy(self->form);
                newtPopWindow();
        newtFormAddHotKey(self->form, NEWT_KEY_END);
        newtFormAddHotKey(self->form, ' ');
        newtFormAddComponent(self->form, self->sb);
+
+       va_start(ap, helpline);
+       ui_helpline__vpush(helpline, ap);
+       va_end(ap);
        return 0;
 }
 
+void ui_browser__hide(struct ui_browser *self)
+{
+       newtFormDestroy(self->form);
+       newtPopWindow();
+       self->form = NULL;
+       ui_helpline__pop();
+}
+
 int ui_browser__refresh(struct ui_browser *self)
 {
        int row;
 
 void ui_browser__refresh_dimensions(struct ui_browser *self);
 void ui_browser__reset_index(struct ui_browser *self);
 
-int ui_browser__show(struct ui_browser *self, const char *title);
+int ui_browser__show(struct ui_browser *self, const char *title,
+                    const char *helpline, ...);
+void ui_browser__hide(struct ui_browser *self);
 int ui_browser__refresh(struct ui_browser *self);
 int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es);
 
 
        struct rb_node *nd;
        struct hist_entry *he = self->b.priv;
 
-       if (ui_browser__show(&self->b, he->ms.sym->name) < 0)
+       if (ui_browser__show(&self->b, he->ms.sym->name,
+                            "<- or ESC: exit, TAB/shift+TAB: cycle thru samples") < 0)
                return -1;
 
-       ui_helpline__fpush("<- or ESC: exit, TAB/shift+TAB: cycle thru samples");
        newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT);
 
        nd = self->curr_hot;
                }
        }
 out:
-       newtFormDestroy(self->b.form);
-       newtPopWindow();
-       ui_helpline__pop();
+       ui_browser__hide(&self->b);
        return 0;
 }
 
 
                 nr_events, unit);
        newtDrawRootText(0, 0, str);
 
-       if (ui_browser__show(&self->b, title) < 0)
+       if (ui_browser__show(&self->b, title,
+                            "Press '?' for help on key bindings") < 0)
                return -1;
 
        newtFormAddHotKey(self->b.form, 'A');
                        return 0;
                }
        }
+
+       ui_browser__hide(&self->b);
        return 0;
 }
 
 
 
 static int map_browser__run(struct map_browser *self, struct newtExitStruct *es)
 {
-       if (ui_browser__show(&self->b, self->map->dso->long_name) < 0)
+       if (ui_browser__show(&self->b, self->map->dso->long_name,
+                            "Press <- or ESC to exit, %s / to search",
+                            verbose ? "" : "restart with -v to use") < 0)
                return -1;
 
-       ui_helpline__fpush("Press <- or ESC to exit, %s / to search",
-                          verbose ? "" : "restart with -v to use");
        newtFormAddHotKey(self->b.form, NEWT_KEY_LEFT);
        newtFormAddHotKey(self->b.form, NEWT_KEY_ENTER);
        if (verbose)
                        break;
        }
 
-       newtFormDestroy(self->b.form);
-       newtPopWindow();
-       ui_helpline__pop();
+       ui_browser__hide(&self->b);
        return 0;
 }
 
 
        newtPushHelpLine(msg);
 }
 
-static void ui_helpline__vpush(const char *fmt, va_list ap)
+void ui_helpline__vpush(const char *fmt, va_list ap)
 {
        char *s;
 
 
 void ui_helpline__init(void);
 void ui_helpline__pop(void);
 void ui_helpline__push(const char *msg);
+void ui_helpline__vpush(const char *fmt, va_list ap);
 void ui_helpline__fpush(const char *fmt, ...);
 void ui_helpline__puts(const char *msg);