(real_warn_same_file): truncate file names if required.

If file name is too long, message window is wider than screen.
Truncate file name to fit it in the screen.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2022-06-25 21:28:58 +03:00
parent facf199f65
commit a7833b5b2e

View File

@ -852,10 +852,39 @@ real_warn_same_file (enum OperationMode mode, const char *fmt, const char *a, co
char *msg;
int result = 0;
const char *head_msg;
int width_a, width_b, width;
head_msg = mode == Foreground ? MSG_ERROR : _("Background process error");
msg = g_strdup_printf (fmt, a, b);
width_a = str_term_width1 (a);
width_b = str_term_width1 (b);
width = COLS - 8;
if (width_a > width)
{
if (width_b > width)
{
char *s;
s = g_strndup (str_trunc (a, width), width);
b = str_trunc (b, width);
msg = g_strdup_printf (fmt, s, b);
g_free (s);
}
else
{
a = str_trunc (a, width);
msg = g_strdup_printf (fmt, a, b);
}
}
else
{
if (width_b > width)
b = str_trunc (b, width);
msg = g_strdup_printf (fmt, a, b);
}
result = query_dialog (head_msg, msg, D_ERROR, 2, _("&Skip"), _("&Abort"));
g_free (msg);
do_refresh ();