Package: dialog
Version: 1.3-20190211-1
Severity: normal
Tags: patch

When dialog is invoked with the --backtitle option and the window displaying the
widget is resized, the window will be redrawn but the title will disappear.

Example command: dialog --backtitle 'Back Title' --msgbox Text 0 0

The attached patch fixes this (originally developed for Ubuntu14 and QA-tested
for the widgets we use there).

-- System Information:
Debian Release: 10.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-8-amd64 (SMP w/24 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages dialog depends on:
ii  debianutils   4.8.6.1
ii  libc6         2.28-10
ii  libncursesw6  6.1+20181013-2+deb10u2
ii  libtinfo6     6.1+20181013-2+deb10u2

dialog recommends no packages.

dialog suggests no packages.

-- no debconf information
--- a/buildlist.c
+++ b/buildlist.c
@@ -1097,9 +1097,7 @@ dlg_buildlist(const char *title,
 		height = old_height;
 		width = old_width;
 		free(prompt);
-		dlg_clear();
-		dlg_del_window(dialog);
-		dlg_mouse_free_regions();
+                dlg_redraw_prep(dialog);
 		/* repaint */
 		first = TRUE;
 		goto retry;
diff --git a/calendar.c b/calendar.c
index 497533b..5fd2f7a 100644
--- a/calendar.c
+++ b/calendar.c
@@ -920,9 +920,7 @@ dialog_calendar(const char *title,
 		height = old_height;
 		width = old_width;
 		free(prompt);
-		dlg_clear();
-		dlg_del_window(dialog);
-		dlg_mouse_free_regions();
+                dlg_redraw_prep(dialog);
 		/* repaint */
 		goto retry;
 #endif
diff --git a/checklist.c b/checklist.c
index 778c4bb..175737c 100644
--- a/checklist.c
+++ b/checklist.c
@@ -577,9 +577,7 @@ dlg_checklist(const char *title,
 		height = old_height;
 		width = old_width;
 		free(prompt);
-		dlg_clear();
-		dlg_del_window(dialog);
-		dlg_mouse_free_regions();
+                dlg_redraw_prep(dialog);
 		/* repaint */
 		goto retry;
 #endif
diff --git a/debian/changelog b/debian/changelog
index 738a0a0..d568a15 100644
--- a/dialog.h
+++ b/dialog.h
@@ -843,6 +843,10 @@ extern void dlg_trim_string(char * /*src*/);
 extern void end_dialog(void);
 extern void init_dialog(FILE * /*input*/, FILE * /*output*/);
 
+extern void dlg_redraw_clear(void);
+extern void dlg_redraw_prep(WINDOW *);
+extern void dlg_redraw_refresh(WINDOW *);
+
 extern void dlg_exiterr(const char *, ...) GCC_NORETURN GCC_PRINTFLIKE(1,2);
 
 #ifdef HAVE_COLOR
diff --git a/editbox.c b/editbox.c
index db0620d..710510f 100644
--- a/editbox.c
+++ b/editbox.c
@@ -699,7 +699,7 @@ dlg_editbox(const char *title,
 		/* reset data */
 		height = old_height;
 		width = old_width;
-		dlg_clear();
+		dlg_redraw_clear();
 		dlg_unregister_window(editing);
 		dlg_del_window(editing);
 		dlg_del_window(dialog);
diff --git a/formbox.c b/formbox.c
index a5de876..a6c1fab 100644
--- a/formbox.c
+++ b/formbox.c
@@ -780,10 +780,8 @@ dlg_form(const char *title,
 		height = old_height;
 		width = old_width;
 		free(prompt);
-		dlg_clear();
+                dlg_redraw_prep(dialog);
 		dlg_unregister_window(form);
-		dlg_del_window(dialog);
-		dlg_mouse_free_regions();
 		/* repaint */
 		goto retry;
 #endif
diff --git a/fselect.c b/fselect.c
index a8e5d7e..6432d05 100644
--- a/fselect.c
+++ b/fselect.c
@@ -861,10 +861,7 @@ dlg_fselect(const char *title, const char *path, int height, int width, int dsel
 		*current = 0;
 		resized = TRUE;
 		/* repaint */
-		dlg_clear();
-		dlg_del_window(dialog);
-		refresh();
-		dlg_mouse_free_regions();
+                dlg_redraw_refresh(dialog);
 		goto retry;
 #endif
 	    default:
diff --git a/guage.c b/guage.c
index 95664b0..9d240dd 100644
--- a/guage.c
+++ b/guage.c
@@ -436,7 +436,7 @@ dialog_gauge(const char *title,
 	    oldobj->obj.keep_win = FALSE;
 
 	    /* remove the old version of the gauge */
-	    dlg_clear();
+	    dlg_redraw_clear();
 	    dlg_remove_callback(&(oldobj->obj));
 	    refresh();
 
diff --git a/inputbox.c b/inputbox.c
index a627e7a..206b50a 100644
--- a/inputbox.c
+++ b/inputbox.c
@@ -243,10 +243,7 @@ dialog_inputbox(const char *title, const char *cprompt, int height, int width,
 		height = old_height;
 		width = old_width;
 		/* repaint */
-		dlg_clear();
-		dlg_del_window(dialog);
-		refresh();
-		dlg_mouse_free_regions();
+                dlg_redraw_refresh(dialog);
 		goto retry;
 #endif
 	    default:
diff --git a/menubox.c b/menubox.c
index abbe11c..efc531c 100644
--- a/menubox.c
+++ b/menubox.c
@@ -730,9 +730,7 @@ dlg_menu(const char *title,
 		resizeit(height, LINES);
 		resizeit(width, COLS);
 		free(prompt);
-		dlg_clear();
-		dlg_del_window(dialog);
-		dlg_mouse_free_regions();
+                dlg_redraw_prep(dialog);
 		/* repaint */
 		goto retry;
 #endif
diff --git a/msgbox.c b/msgbox.c
index d9a2eb1..154f329 100644
--- a/msgbox.c
+++ b/msgbox.c
@@ -137,7 +137,7 @@ dialog_msgbox(const char *title, const char *cprompt, int height, int width,
 #ifdef KEY_RESIZE
 		case KEY_RESIZE:
 		    dlg_will_resize(dialog);
-		    dlg_clear();
+		    dlg_redraw_clear();
 		    free(prompt);
 		    height = req_high;
 		    width = req_wide;
diff --git a/pause.c b/pause.c
index eeff0fe..469224d 100644
--- a/pause.c
+++ b/pause.c
@@ -203,7 +203,7 @@ dialog_pause(const char *title,
 #ifdef KEY_RESIZE
 	    case KEY_RESIZE:
 		dlg_will_resize(dialog);
-		dlg_clear();	/* fill the background */
+		dlg_redraw_clear();	/* fill the background */
 		dlg_del_window(dialog);		/* delete this window */
 		height = old_height;
 		width = old_width;
diff --git a/po/makefile.in b/po/makefile.in
index b8d89fa..007ea6a 100644
--- a/rangebox.c
+++ b/rangebox.c
@@ -392,9 +392,7 @@ dialog_rangebox(const char *title,
 		    width = old_width;
 		    /* repaint */
 		    free(prompt);
-		    dlg_clear();
-		    dlg_del_window(dialog);
-		    dlg_mouse_free_regions();
+		    dlg_redraw_prep(dialog);
 		    goto retry;
 #endif
 		case DLGK_MOUSE('i'):
diff --git a/tailbox.c b/tailbox.c
index 137355b..b836302 100644
--- a/tailbox.c
+++ b/tailbox.c
@@ -409,10 +409,7 @@ dialog_tailbox(const char *title,
 		height = old_height;
 		width = old_width;
 		/* repaint */
-		dlg_clear();
-		dlg_del_window(dialog);
-		refresh();
-		dlg_mouse_free_regions();
+                dlg_redraw_refresh(dialog);
 		dlg_button_layout(buttons, &min_width);
 		goto retry;
 	    }
diff --git a/textbox.c b/textbox.c
index eb06eec..b4caccc 100644
--- a/textbox.c
+++ b/textbox.c
@@ -954,9 +954,7 @@ dialog_textbox(const char *title, const char *filename, int height, int width)
 		width = old_width;
 		back_lines(&obj, obj.page_length);
 		/* repaint */
-		dlg_clear();
-		dlg_del_window(dialog);
-		dlg_mouse_free_regions();
+                dlg_redraw_prep(dialog);
 		goto retry;
 #endif
 	    }
diff --git a/timebox.c b/timebox.c
index 288e767..1688f6f 100644
--- a/timebox.c
+++ b/timebox.c
@@ -360,10 +360,7 @@ dialog_timebox(const char *title,
 		    minute = mn_box.value;
 		    second = sc_box.value;
 		    /* repaint */
-		    free(prompt);
-		    dlg_clear();
-		    dlg_del_window(dialog);
-		    dlg_mouse_free_regions();
+                    dlg_redraw_prep(dialog);
 		    goto retry;
 #endif
 		default:
diff --git a/treeview.c b/treeview.c
index 934761e..b9bbec3 100644
--- a/treeview.c
+++ b/treeview.c
@@ -537,10 +537,7 @@ dlg_treeview(const char *title,
 		height = old_height;
 		width = old_width;
 		/* repaint */
-		dlg_clear();
-		dlg_del_window(dialog);
-		refresh();
-		dlg_mouse_free_regions();
+                dlg_redraw_refresh(dialog);
 		goto retry;
 #endif
 	    default:
diff --git a/util.c b/util.c
index 5b0efb7..6fa917e 100644
--- a/util.c
+++ b/util.c
@@ -230,6 +230,26 @@ dlg_clear(void)
     dlg_attr_clear(stdscr, LINES, COLS, screen_attr);
 }
 
+void
+dlg_redraw_clear(void)
+{
+    dlg_clear();
+    dlg_put_backtitle();
+}
+
+void dlg_redraw_prep(WINDOW *w)
+{
+    dlg_redraw_clear();
+    dlg_del_window(w);
+    dlg_mouse_free_regions();
+}
+
+void dlg_redraw_refresh(WINDOW *w)
+{
+    dlg_redraw_prep(w);
+    refresh();
+}
+
 #define isprivate(s) ((s) != 0 && strstr(s, "\033[?") != 0)
 
 #define TTY_DEVICE "/dev/tty"
diff --git a/yesno.c b/yesno.c
index 3605f67..25de979 100644
--- a/yesno.c
+++ b/yesno.c
@@ -143,6 +143,7 @@ dialog_yesno(const char *title, const char *cprompt, int height, int width)
 #ifdef KEY_RESIZE
 	    case KEY_RESIZE:
 		dlg_will_resize(dialog);
+		dlg_redraw_clear();
 		dlg_clear();
 		free(prompt);
 		height = req_high;

Reply via email to