bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dialog enhance fselect / dselect


From: tiago . t
Subject: Dialog enhance fselect / dselect
Date: Wed, 13 Nov 2019 16:47:40 +0000
User-agent: IMP PTMail 6.1.23


Good afternoon,

While using dialog, when prompting to select a folder, I noticed the "Directories"/"Files" is not changeable, which I kinda needed to be.

I noticed fselect/dselect takes 4 parameters, with a 5th optional parameter (which seemed unused), so I took advantage of that to make that 5th argument the prompt.

I built and tested it and seems to be working fine.

Attached is a screenshot of a dselect with command:
$ ./dialog --title Title --backtitle BackTitle --dselect $HOME 16 40 "Select folder"

And here's the diff file (also attached):

diff -Naur a/dialog.c b/dialog.c
--- a/dialog.c  2019-09-24 09:26:46.000000000 +0100
+++ b/dialog.c  2019-11-13 16:26:14.013694135 +0000
@@ -925,7 +925,8 @@
     return dialog_dselect(t,
                          av[1],
                          numeric_arg(av, 2),
-                         numeric_arg(av, 3));
+                         numeric_arg(av, 3),
+                         optional_str(av, 4, 0));
 }

 static int
@@ -945,7 +946,8 @@
     return dialog_fselect(t,
                          av[1],
                          numeric_arg(av, 2),
-                         numeric_arg(av, 3));
+                         numeric_arg(av, 3),
+                         optional_str(av, 4, 0));
 }

 static int
diff -Naur a/dialog.h b/dialog.h
--- a/dialog.h  2019-11-10 23:17:37.000000000 +0000
+++ b/dialog.h  2019-11-13 16:26:14.013694135 +0000
@@ -642,10 +642,10 @@
extern int dialog_buildlist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*order_mode*/); extern int dialog_calendar(const char * /*title*/, const char * /*subtitle*/, int /*height*/, int /*width*/, int /*day*/, int /*month*/, int /*year*/); extern int dialog_checklist(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*list_height*/, int /*item_no*/, char ** /*items*/, int /*flag*/); -extern int dialog_dselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/); +extern int dialog_dselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/, const char * /*prompt*/); extern int dialog_editbox(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/); extern int dialog_form(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*form_height*/, int /*item_no*/, char ** /*items*/); -extern int dialog_fselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/); +extern int dialog_fselect(const char * /*title*/, const char * /*path*/, int /*height*/, int /*width*/, const char * /*prompt*/); extern int dialog_gauge(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, int /*percent*/); extern int dialog_helpfile(const char * /*title*/, const char * /*file*/, int /*height*/, int /*width*/); extern int dialog_inputbox(const char * /*title*/, const char * /*cprompt*/, int /*height*/, int /*width*/, const char * /*init*/, const int /*password*/);
diff -Naur a/fselect.c b/fselect.c
--- a/fselect.c 2019-11-11 00:48:13.000000000 +0000
+++ b/fselect.c 2019-11-13 16:26:59.495526990 +0000
@@ -562,7 +562,7 @@
  * Display a dialog box for entering a filename
  */
 static int
-dlg_fselect(const char *title, const char *path, int height, int width, int dselect) +dlg_fselect(const char *title, const char *path, int height, int width, int dselect, const char *prompt)
 {
     /* *INDENT-OFF* */
     static DLG_KEYS_BINDING binding[] = {
@@ -607,8 +607,8 @@
     WINDOW *w_text = 0;
     WINDOW *w_work = 0;
     const char **buttons = dlg_ok_labels();
-    const char *d_label = _("Directories");
-    const char *f_label = _("Files");
+    const char *d_label = prompt ? prompt : _("Directories");
+    const char *f_label = prompt ? prompt : _("Files");
     char *partial = 0;
     int min_wide = MIN_WIDE;
     int min_items = height ? 0 : 4;
@@ -935,16 +935,16 @@
  * Display a dialog box for entering a filename
  */
 int
-dialog_fselect(const char *title, const char *path, int height, int width)
+dialog_fselect(const char *title, const char *path, int height, int width, const char *prompt)
 {
-    return dlg_fselect(title, path, height, width, FALSE);
+    return dlg_fselect(title, path, height, width, FALSE, prompt);
 }

 /*
  * Display a dialog box for entering a directory
  */
 int
-dialog_dselect(const char *title, const char *path, int height, int width)
+dialog_dselect(const char *title, const char *path, int height, int width, const char *prompt)
 {
-    return dlg_fselect(title, path, height, width, TRUE);
+    return dlg_fselect(title, path, height, width, TRUE, prompt);
 }

Attachment: dialog-screenshot.png
Description: PNG image

Attachment: dialog_fselect
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]