DBG(UI, ul_debug("delete window: %p",
cf->lines[i].w));
- delwin(cf->lines[i].w);
+ if (cf->lines[i].w)
+ delwin(cf->lines[i].w);
+ cf->lines[i].w = NULL;
++i;
}
cf->act_win = NULL;
free(cf->lines);
+ cf->lines = NULL;
}
/*
* Read data about partitions from libfdisk and prepare output lines.
struct libscols_line *lsl;
assert(l);
+ assert(l->extra);
if (!data || !*data)
return 0;
DBG(UI, ul_debug("draw extra"));
+ assert(ln->extra);
+
if (cf->act_win)
wclear(cf->act_win);
- if (scols_table_is_empty(ln->extra))
+ if (scols_table_is_empty(ln->extra)) {
extra_prepare_data(cf);
+ if (scols_table_is_empty(ln->extra))
+ return 0;
+ }
ndatalines = fdisk_table_get_nents(cf->table) + 1;
}
free(end);
- delwin(ln->w);
+ if (ln->w)
+ delwin(ln->w);
DBG(UI, ul_debug("draw window: %p", win_ex));
touchwin(stdscr);
clrtoeol();
}
- if ((size_t) cf->lines_idx > nparts - 1)
+ if (nparts == 0 || (size_t) cf->lines_idx > nparts - 1)
cf->lines_idx = nparts ? nparts - 1 : 0;
/* print header */
uint64_t bytes = fdisk_get_nsectors(cf->cxt) * fdisk_get_sector_size(cf->cxt);
char *strsz;
- erase();
if (!ui_enabled)
return -EINVAL;
lb = fdisk_get_label(cf->cxt, NULL);
assert(lb);
+ clear();
+
/* header */
attron(A_BOLD);
ui_center(0, _("Disk: %s"), fdisk_get_devname(cf->cxt));
ui_draw_extra(cf);
}
+static void toggle_show_extra(struct cfdisk *cf)
+{
+ if (cf->show_extra && cf->act_win) {
+ wclear(cf->act_win);
+ touchwin(stdscr);
+ }
+ cf->show_extra = cf->show_extra ? 0 : 1;
+
+ if (cf->show_extra)
+ ui_draw_extra(cf);
+ DBG(MENU, ul_debug("extra: %s", cf->show_extra ? "ENABLED" : "DISABLED" ));
+}
+
static int ui_run(struct cfdisk *cf)
{
int rc = 0;
menu_push(cf, main_menuitems);
cf->menu->ignore_cb = main_menu_ignore_keys;
-
rc = ui_refresh(cf);
if (rc)
return rc;
if (fdisk_is_readonly(cf->cxt))
ui_warnx(_("Device open in read-only mode."));
else if (cf->wrong_order)
- ui_info(_("Note that partition table entries are not in disk order now."));
+ ui_info(_("Note that partition table entries are not in disk order now."));
do {
int key = getch();
rc = main_menu_action(cf, 0);
break;
case 'x': /* Extra */
- cf->show_extra = cf->show_extra ? 0 : 1;
- DBG(MENU, ul_debug("extra: %s", cf->show_extra ? "ENABLED" : "DISABLED" ));
+ toggle_show_extra(cf);
break;
default:
rc = main_menu_action(cf, key);