quick_dlg: use WRect to hold dialog position and size.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2022-05-01 10:39:14 +03:00
parent 3978dee37c
commit ed65694caa
15 changed files with 107 additions and 77 deletions

View File

@ -186,7 +186,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
int return_val;
len = str_term_width1 (I18N (quick_dlg->title)) + 6;
quick_dlg->cols = MAX (quick_dlg->cols, len);
quick_dlg->rect.cols = MAX (quick_dlg->rect.cols, len);
y = 1;
x = x1;
@ -384,7 +384,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
}
/* adjust dialog width */
quick_dlg->cols = MAX (quick_dlg->cols, blen + 6);
quick_dlg->rect.cols = MAX (quick_dlg->rect.cols, blen + 6);
if (have_groupbox)
{
if (width1 != 0)
@ -401,16 +401,16 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
len = MAX (len, width1 + 6);
}
quick_dlg->cols = MAX (quick_dlg->cols, len);
width1 = quick_dlg->cols - 6;
width2 = (quick_dlg->cols - 7) / 2;
quick_dlg->rect.cols = MAX (quick_dlg->rect.cols, len);
width1 = quick_dlg->rect.cols - 6;
width2 = (quick_dlg->rect.cols - 7) / 2;
if (quick_dlg->x == -1 || quick_dlg->y == -1)
dd = dlg_create (TRUE, 0, 0, y + 3, quick_dlg->cols, WPOS_CENTER | WPOS_TRYUP, FALSE,
if (quick_dlg->rect.x == -1 || quick_dlg->rect.y == -1)
dd = dlg_create (TRUE, 0, 0, y + 3, quick_dlg->rect.cols, WPOS_CENTER | WPOS_TRYUP, FALSE,
dialog_colors, quick_dlg->callback, quick_dlg->mouse_callback,
quick_dlg->help, quick_dlg->title);
else
dd = dlg_create (TRUE, quick_dlg->y, quick_dlg->x, y + 3, quick_dlg->cols,
dd = dlg_create (TRUE, quick_dlg->rect.y, quick_dlg->rect.x, y + 3, quick_dlg->rect.cols,
WPOS_KEEP_DEFAULT, FALSE, dialog_colors, quick_dlg->callback,
quick_dlg->mouse_callback, quick_dlg->help, quick_dlg->title);

View File

@ -330,8 +330,8 @@ struct quick_widget_t
typedef struct
{
int y, x; /* if -1, then center the dialog */
int cols; /* heigth is calculated automatically */
WRect rect; /* if rect.x == -1 or rect.y == -1, then dialog is ceneterd;
* rect.lines is unused and ignored */
const char *title;
const char *help;
quick_widget_t *widgets;

View File

@ -9,7 +9,7 @@
Radek Doulik, 1994, 1995
Jakub Jelinek, 1995
Andrej Borsenkow, 1995
Andrew Borodin <aborodin@vmail.ru>, 2009-2014
Andrew Borodin <aborodin@vmail.ru>, 2009-2022
This file is part of the Midnight Commander.
@ -217,9 +217,11 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, COLS / 2 };
quick_dialog_t qdlg = {
-1, -1, COLS / 2, header,
help, quick_widgets, NULL, NULL
r, header, help,
quick_widgets, NULL, NULL
};
ret = quick_dialog (&qdlg);

View File

@ -6,7 +6,7 @@
Written by:
Slava Zanko <slavazanko@gmail.com>, 2010.
Andrew Borodin <aborodin@vmail.ru>, 2012
Andrew Borodin <aborodin@vmail.ru>, 2012-2022
This file is part of the Midnight Commander.
@ -101,9 +101,10 @@ mcdiffview_dialog_search (WDiff * dview)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 58 };
quick_dialog_t qdlg = {
-1, -1, 58,
N_("Search"), "[Input Line Keys]",
r, N_("Search"), "[Input Line Keys]",
quick_widgets, NULL, NULL
};

View File

@ -7,7 +7,7 @@
Written by:
Daniel Borca <dborca@yahoo.com>, 2007
Slava Zanko <slavazanko@gmail.com>, 2010, 2013
Andrew Borodin <aborodin@vmail.ru>, 2010, 2012, 2013, 2016
Andrew Borodin <aborodin@vmail.ru>, 2010-2022
Ilia Maslakov <il.smind@gmail.com>, 2010
This file is part of the Midnight Commander.
@ -2379,9 +2379,10 @@ dview_diff_options (WDiff * dview)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 56 };
quick_dialog_t qdlg = {
-1, -1, 56,
N_("Diff Options"), "[Diff Options]",
r, N_("Diff Options"), "[Diff Options]",
quick_widgets, NULL, NULL
};

View File

@ -6,7 +6,7 @@
Written by:
Paul Sheer, 1996, 1997
Andrew Borodin <aborodin@vmail.ru>, 2012-2021
Andrew Borodin <aborodin@vmail.ru>, 2012-2022
Ilia Maslakov <il.smind@gmail.com>, 2012
This file is part of the Midnight Commander.
@ -409,9 +409,10 @@ edit_get_save_file_as (WEdit * edit)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 64 };
quick_dialog_t qdlg = {
-1, -1, 64,
N_("Save As"), "[Save File As]",
r, N_("Save As"), "[Save File As]",
quick_widgets, NULL, NULL
};
@ -882,9 +883,10 @@ edit_save_mode_cmd (void)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 38 };
quick_dialog_t qdlg = {
-1, -1, 38,
N_("Edit Save Mode"), "[Edit Save Mode]",
r, N_("Edit Save Mode"), "[Edit Save Mode]",
quick_widgets, edit_save_mode_callback, NULL
};
@ -1963,9 +1965,10 @@ edit_mail_dialog (WEdit * edit)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 50 };
quick_dialog_t qdlg = {
-1, -1, 50,
N_("Mail"), "[Input Line Keys]",
r, N_("Mail"), "[Input Line Keys]",
quick_widgets, NULL, NULL
};

View File

@ -6,7 +6,7 @@
Written by:
Paul Sheer, 1996, 1997
Andrew Borodin <aborodin@vmail.ru>, 2012
Andrew Borodin <aborodin@vmail.ru>, 2012-2022
This file is part of the Midnight Commander.
@ -184,9 +184,10 @@ edit_options_dialog (WDialog * h)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 74 };
quick_dialog_t qdlg = {
-1, -1, 74,
N_("Editor options"), "[Editor options]",
r, N_("Editor options"), "[Editor options]",
quick_widgets, NULL, NULL
};

View File

@ -5,7 +5,7 @@
Free Software Foundation, Inc.
Written by:
Andrew Borodin <aborodin@vmail.ru>, 2021
Andrew Borodin <aborodin@vmail.ru>, 2021-2022
This file is part of the Midnight Commander.
@ -107,9 +107,10 @@ edit_dialog_search_show (WEdit * edit)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 58 };
quick_dialog_t qdlg = {
-1, -1, 58,
N_("Search"), "[Input Line Keys]",
r, N_("Search"), "[Input Line Keys]",
quick_widgets, NULL, NULL
};
@ -183,9 +184,10 @@ edit_dialog_replace_show (WEdit * edit, const char *search_default, const char *
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 58 };
quick_dialog_t qdlg = {
-1, -1, 58,
N_("Replace"), "[Input Line Keys]",
r, N_("Replace"), "[Input Line Keys]",
quick_widgets, NULL, NULL
};
@ -247,9 +249,10 @@ edit_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text, i
/* *INDENT-ON* */
};
WRect r = { ypos, xpos, 0, -1 };
quick_dialog_t qdlg = {
ypos, xpos, -1,
N_("Confirm replace"), NULL,
r, N_("Confirm replace"), NULL,
quick_widgets, NULL, NULL
};

View File

@ -6,7 +6,7 @@
Written by:
Paul Sheer, 1996, 1997
Andrew Borodin <aborodin@vmail.ru> 2012, 2013
Andrew Borodin <aborodin@vmail.ru> 2012-2022
This file is part of the Midnight Commander.
@ -159,9 +159,10 @@ edit_about (void)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 40 };
quick_dialog_t qdlg = {
-1, -1, 40,
N_("About"), "[Internal File Editor]",
r, N_("About"), "[Internal File Editor]",
quick_widgets, NULL, NULL
};

View File

@ -7,7 +7,7 @@
Written by:
Miguel de Icaza, 1994, 1995
Jakub Jelinek, 1995
Andrew Borodin <aborodin@vmail.ru>, 2009-2015
Andrew Borodin <aborodin@vmail.ru>, 2009-2022
This file is part of the Midnight Commander.
@ -591,9 +591,10 @@ configure_box (void)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 60 };
quick_dialog_t qdlg = {
-1, -1, 60,
N_("Configure options"), "[Configuration]",
r, N_("Configure options"), "[Configuration]",
quick_widgets, configure_callback, NULL
};
@ -644,9 +645,10 @@ appearance_box (void)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 54 };
quick_dialog_t qdlg = {
-1, -1, 54,
N_("Appearance"), "[Appearance]",
r, N_("Appearance"), "[Appearance]",
quick_widgets, appearance_box_callback, NULL
};
@ -724,9 +726,10 @@ panel_options_box (void)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 60 };
quick_dialog_t qdlg = {
-1, -1, 60,
N_("Panel options"), "[Panel options]",
r, N_("Panel options"), "[Panel options]",
quick_widgets, NULL, NULL
};
@ -800,9 +803,10 @@ panel_listing_box (WPanel * panel, int num, char **userp, char **minip, gboolean
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 48 };
quick_dialog_t qdlg = {
-1, -1, 48,
N_("Listing format"), "[Listing Format...]",
r, N_("Listing format"), "[Listing Format...]",
quick_widgets, panel_listing_callback, NULL
};
@ -890,9 +894,10 @@ sort_box (dir_sort_options_t * op, const panel_field_t * sort_field)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 40 };
quick_dialog_t qdlg = {
-1, -1, 40,
N_("Sort order"), "[Sort Order...]",
r, N_("Sort order"), "[Sort Order...]",
quick_widgets, NULL, NULL
};
@ -929,9 +934,10 @@ confirm_box (void)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 46 };
quick_dialog_t qdlg = {
-1, -1, 46,
N_("Confirmation"), "[Confirmation]",
r, N_("Confirmation"), "[Confirmation]",
quick_widgets, NULL, NULL
};
@ -964,9 +970,10 @@ display_bits_box (void)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 46 };
quick_dialog_t qdlg = {
-1, -1, 46,
_("Display bits"), "[Display bits]",
r, _("Display bits"), "[Display bits]",
quick_widgets, NULL, NULL
};
@ -1022,9 +1029,10 @@ display_bits_box (void)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 46 };
quick_dialog_t qdlg = {
-1, -1, 46,
N_("Display bits"), "[Display bits]",
r, N_("Display bits"), "[Display bits]",
quick_widgets, NULL, NULL
};
@ -1149,9 +1157,10 @@ configure_vfs_box (void)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 56 };
quick_dialog_t qdlg = {
-1, -1, 56,
N_("Virtual File System Setting"), "[Virtual FS]",
r, N_("Virtual File System Setting"), "[Virtual FS]",
quick_widgets,
#ifdef ENABLE_VFS_FTP
confvfs_callback,
@ -1205,9 +1214,10 @@ cd_box (const WPanel * panel)
QUICK_END
};
WRect r = { w->y + w->lines - 6, w->x, 0, w->cols };
quick_dialog_t qdlg = {
w->y + w->lines - 6, w->x, w->cols,
N_("Quick cd"), "[Quick cd]",
r, N_("Quick cd"), "[Quick cd]",
quick_widgets, NULL, NULL
};
@ -1234,9 +1244,10 @@ symlink_box (const vfs_path_t * existing_vpath, const vfs_path_t * new_vpath,
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 64 };
quick_dialog_t qdlg = {
-1, -1, 64,
N_("Symbolic link"), "[File Menu]",
r, N_("Symbolic link"), "[File Menu]",
quick_widgets, NULL, NULL
};

View File

@ -21,7 +21,7 @@
Norbert Warmuth, 1997
Pavel Machek, 1998
Slava Zanko, 2009, 2010, 2011, 2012, 2013
Andrew Borodin <aborodin@vmail.ru>, 2009, 2010, 2011, 2012, 2013
Andrew Borodin <aborodin@vmail.ru>, 2009-2022
This file is part of the Midnight Commander.
@ -1365,9 +1365,10 @@ file_mask_dialog (file_op_context_t * ctx, FileOperation operation, gboolean onl
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, fmd_xlen };
quick_dialog_t qdlg = {
-1, -1, fmd_xlen,
op_names[operation], "[Mask Copy/Rename]",
r, op_names[operation], "[Mask Copy/Rename]",
quick_widgets, NULL, NULL
};

View File

@ -9,7 +9,7 @@
Janne Kukonlehto, 1995
Andrej Borsenkow, 1996
Norbert Warmuth, 1997
Andrew Borodin <aborodin@vmail.ru>, 2012, 2013
Andrew Borodin <aborodin@vmail.ru>, 2012-2022
Janne did the original Hotlist code, Andrej made the groupable
hotlist; the move hotlist and revamped the file format and made
@ -1017,9 +1017,10 @@ add_new_entry_input (const char *header, const char *text1, const char *text2,
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 64 };
quick_dialog_t qdlg = {
-1, -1, 64,
header, help,
r, header, help,
quick_widgets, NULL, NULL
};
@ -1079,9 +1080,10 @@ add_new_group_input (const char *header, const char *label, char **result)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 64 };
quick_dialog_t qdlg = {
-1, -1, 64,
header, "[Hotlist]",
r, header, "[Hotlist]",
quick_widgets, NULL, NULL
};

View File

@ -2554,8 +2554,10 @@ panel_select_unselect_files_dialog (select_flags_t * flags, const char *title,
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 50 };
quick_dialog_t qdlg = {
-1, -1, 50, title, help_section,
r, title, help_section,
quick_widgets, NULL, NULL
};

View File

@ -14,7 +14,7 @@
Pavel Machek, 1998
Roland Illig <roland.illig@gmx.de>, 2004, 2005
Slava Zanko <slavazanko@google.com>, 2009
Andrew Borodin <aborodin@vmail.ru>, 2009, 2012
Andrew Borodin <aborodin@vmail.ru>, 2009-2022
Ilia Maslakov <il.smind@gmail.com>, 2009
This file is part of the Midnight Commander.
@ -98,9 +98,10 @@ mcview_dialog_search (WView * view)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 58 };
quick_dialog_t qdlg = {
-1, -1, 58,
N_("Search"), "[Input Line Keys]",
r, N_("Search"), "[Input Line Keys]",
quick_widgets, NULL, NULL
};
@ -181,9 +182,10 @@ mcview_dialog_goto (WView * view, off_t * offset)
/* *INDENT-ON* */
};
WRect r = { -1, -1, 0, 40 };
quick_dialog_t qdlg = {
-1, -1, 40,
N_("Goto"), "[Input Line Keys]",
r, N_("Goto"), "[Input Line Keys]",
quick_widgets, NULL, NULL
};

View File

@ -14,7 +14,7 @@
Pavel Machek, 1998
Roland Illig <roland.illig@gmx.de>, 2004, 2005
Slava Zanko <slavazanko@google.com>, 2009
Andrew Borodin <aborodin@vmail.ru>, 2009, 2013
Andrew Borodin <aborodin@vmail.ru>, 2009-2022
Ilia Maslakov <il.smind@gmail.com>, 2009
This file is part of the Midnight Commander.