コード例 #1
0
ファイル: browser.c プロジェクト: 3sOx/asuswrt-merlin
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();
	}
	ui_browser__refresh_dimensions(self);
	newtCenteredWindow(self->width, self->height, title);
	self->form = newt_form__new();
	if (self->form == NULL)
		return -1;

	self->sb = newtVerticalScrollbar(self->width, 0, self->height,
					 HE_COLORSET_NORMAL,
					 HE_COLORSET_SELECTED);
	if (self->sb == NULL)
		return -1;

	newtFormAddHotKey(self->form, NEWT_KEY_UP);
	newtFormAddHotKey(self->form, NEWT_KEY_DOWN);
	newtFormAddHotKey(self->form, NEWT_KEY_PGUP);
	newtFormAddHotKey(self->form, NEWT_KEY_PGDN);
	newtFormAddHotKey(self->form, NEWT_KEY_HOME);
	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;
}
コード例 #2
0
int ui_browser__show(struct ui_browser *self, const char *title,
		     const char *helpline, ...)
{
	int err;
	va_list ap;

	ui_browser__refresh_dimensions(self);

	pthread_mutex_lock(&ui__lock);
	__ui_browser__show_title(self, title);

	self->title = title;
	free(self->helpline);
	self->helpline = NULL;

	va_start(ap, helpline);
	err = vasprintf(&self->helpline, helpline, ap);
	va_end(ap);
	if (err > 0)
		ui_helpline__push(self->helpline);
	pthread_mutex_unlock(&ui__lock);
	return err ? 0 : -1;
}