mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Tweak of select codepage code in case of --disable-charset
...in mceditor, mcviewer and mcdiffviewer. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
973aae2b5e
commit
fec326f641
@ -117,46 +117,6 @@ TAB_SKIP (int ts, int pos)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
|
||||||
dview_set_codeset (WDiff * dview)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_CHARSET
|
|
||||||
const char *encoding_id = NULL;
|
|
||||||
|
|
||||||
dview->utf8 = TRUE;
|
|
||||||
encoding_id =
|
|
||||||
get_codepage_id (mc_global.source_codepage >=
|
|
||||||
0 ? mc_global.source_codepage : mc_global.display_codepage);
|
|
||||||
if (encoding_id != NULL)
|
|
||||||
{
|
|
||||||
GIConv conv;
|
|
||||||
conv = str_crt_conv_from (encoding_id);
|
|
||||||
if (conv != INVALID_CONV)
|
|
||||||
{
|
|
||||||
if (dview->converter != str_cnv_from_term)
|
|
||||||
str_close_conv (dview->converter);
|
|
||||||
dview->converter = conv;
|
|
||||||
}
|
|
||||||
dview->utf8 = (gboolean) str_isutf8 (encoding_id);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
(void) dview;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#ifdef HAVE_CHARSET
|
|
||||||
static void
|
|
||||||
dview_select_encoding (WDiff * dview)
|
|
||||||
{
|
|
||||||
if (do_select_codepage ())
|
|
||||||
dview_set_codeset (dview);
|
|
||||||
}
|
|
||||||
#endif /* HAVE_CHARSET */
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
rewrite_backup_content (const vfs_path_t * from_file_name_vpath, const char *to_file_name)
|
rewrite_backup_content (const vfs_path_t * from_file_name_vpath, const char *to_file_name)
|
||||||
{
|
{
|
||||||
@ -2281,6 +2241,118 @@ dview_compute_areas (WDiff * dview)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void
|
||||||
|
dview_reread (WDiff * dview)
|
||||||
|
{
|
||||||
|
int ndiff;
|
||||||
|
|
||||||
|
destroy_hdiff (dview);
|
||||||
|
if (dview->a[0] != NULL)
|
||||||
|
{
|
||||||
|
g_array_foreach (dview->a[0], DIFFLN, cc_free_elt);
|
||||||
|
g_array_free (dview->a[0], TRUE);
|
||||||
|
}
|
||||||
|
if (dview->a[1] != NULL)
|
||||||
|
{
|
||||||
|
g_array_foreach (dview->a[1], DIFFLN, cc_free_elt);
|
||||||
|
g_array_free (dview->a[1], TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dview->a[0] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
|
||||||
|
dview->a[1] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
|
||||||
|
|
||||||
|
ndiff = redo_diff (dview);
|
||||||
|
if (ndiff >= 0)
|
||||||
|
dview->ndiff = ndiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef HAVE_CHARSET
|
||||||
|
static void
|
||||||
|
dview_set_codeset (WDiff * dview)
|
||||||
|
{
|
||||||
|
const char *encoding_id = NULL;
|
||||||
|
|
||||||
|
dview->utf8 = TRUE;
|
||||||
|
encoding_id =
|
||||||
|
get_codepage_id (mc_global.source_codepage >=
|
||||||
|
0 ? mc_global.source_codepage : mc_global.display_codepage);
|
||||||
|
if (encoding_id != NULL)
|
||||||
|
{
|
||||||
|
GIConv conv;
|
||||||
|
conv = str_crt_conv_from (encoding_id);
|
||||||
|
if (conv != INVALID_CONV)
|
||||||
|
{
|
||||||
|
if (dview->converter != str_cnv_from_term)
|
||||||
|
str_close_conv (dview->converter);
|
||||||
|
dview->converter = conv;
|
||||||
|
}
|
||||||
|
dview->utf8 = (gboolean) str_isutf8 (encoding_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void
|
||||||
|
dview_select_encoding (WDiff * dview)
|
||||||
|
{
|
||||||
|
if (do_select_codepage ())
|
||||||
|
dview_set_codeset (dview);
|
||||||
|
|
||||||
|
dview_reread (dview);
|
||||||
|
tty_touch_screen ();
|
||||||
|
repaint_screen ();
|
||||||
|
}
|
||||||
|
#endif /* HAVE_CHARSET */
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void
|
||||||
|
dview_diff_options (WDiff * dview)
|
||||||
|
{
|
||||||
|
const char *quality_str[] = {
|
||||||
|
N_("No&rmal"),
|
||||||
|
N_("&Fastest (Assume large files)"),
|
||||||
|
N_("&Minimal (Find a smaller set of change)")
|
||||||
|
};
|
||||||
|
|
||||||
|
QuickWidget diffopt_widgets[] = {
|
||||||
|
QUICK_BUTTON (6, 10, 14, OPTY, N_("&Cancel"), B_CANCEL, NULL),
|
||||||
|
QUICK_BUTTON (2, 10, 14, OPTY, N_("&OK"), B_ENTER, NULL),
|
||||||
|
|
||||||
|
QUICK_CHECKBOX (3, OPTX, 12, OPTY,
|
||||||
|
N_("Strip &trailing carriage return"), &dview->opt.strip_trailing_cr),
|
||||||
|
QUICK_CHECKBOX (3, OPTX, 11, OPTY,
|
||||||
|
N_("Ignore all &whitespace"), &dview->opt.ignore_all_space),
|
||||||
|
QUICK_CHECKBOX (3, OPTX, 10, OPTY,
|
||||||
|
N_("Ignore &space change"), &dview->opt.ignore_space_change),
|
||||||
|
QUICK_CHECKBOX (3, OPTX, 9, OPTY,
|
||||||
|
N_("Ignore tab &expansion"), &dview->opt.ignore_tab_expansion),
|
||||||
|
QUICK_CHECKBOX (3, OPTX, 8, OPTY,
|
||||||
|
N_("&Ignore case"), &dview->opt.ignore_case),
|
||||||
|
QUICK_LABEL (3, OPTX, 7, OPTY, N_("Diff extra options")),
|
||||||
|
QUICK_RADIO (3, OPTX, 3, OPTY,
|
||||||
|
3, (const char **) quality_str, (int *) &dview->opt.quality),
|
||||||
|
QUICK_LABEL (3, OPTX, 2, OPTY, N_("Diff algorithm")),
|
||||||
|
|
||||||
|
QUICK_END
|
||||||
|
};
|
||||||
|
|
||||||
|
QuickDialog diffopt = {
|
||||||
|
OPTX, OPTY, -1, -1,
|
||||||
|
N_("Diff Options"), "[Diff Options]",
|
||||||
|
diffopt_widgets, NULL, NULL, FALSE
|
||||||
|
};
|
||||||
|
|
||||||
|
if (quick_dialog (&diffopt) != B_CANCEL)
|
||||||
|
{
|
||||||
|
dview_reread (dview);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dview_init (WDiff * dview, const char *args, const char *file1, const char *file2,
|
dview_init (WDiff * dview, const char *args, const char *file1, const char *file2,
|
||||||
const char *label1, const char *label2, DSRC dsrc)
|
const char *label1, const char *label2, DSRC dsrc)
|
||||||
@ -2328,8 +2400,9 @@ dview_init (WDiff * dview, const char *args, const char *file1, const char *file
|
|||||||
dview->hdiff = NULL;
|
dview->hdiff = NULL;
|
||||||
dview->dsrc = dsrc;
|
dview->dsrc = dsrc;
|
||||||
dview->converter = str_cnv_from_term;
|
dview->converter = str_cnv_from_term;
|
||||||
|
#ifdef HAVE_CHARSET
|
||||||
dview_set_codeset (dview);
|
dview_set_codeset (dview);
|
||||||
|
#endif
|
||||||
dview->a[0] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
|
dview->a[0] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
|
||||||
dview->a[1] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
|
dview->a[1] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
|
||||||
|
|
||||||
@ -2374,77 +2447,6 @@ dview_init (WDiff * dview, const char *args, const char *file1, const char *file
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
|
||||||
dview_reread (WDiff * dview)
|
|
||||||
{
|
|
||||||
int ndiff = dview->ndiff;
|
|
||||||
|
|
||||||
destroy_hdiff (dview);
|
|
||||||
if (dview->a[0] != NULL)
|
|
||||||
{
|
|
||||||
g_array_foreach (dview->a[0], DIFFLN, cc_free_elt);
|
|
||||||
g_array_free (dview->a[0], TRUE);
|
|
||||||
}
|
|
||||||
if (dview->a[1] != NULL)
|
|
||||||
{
|
|
||||||
g_array_foreach (dview->a[1], DIFFLN, cc_free_elt);
|
|
||||||
g_array_free (dview->a[1], TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
dview->a[0] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
|
|
||||||
dview->a[1] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
|
|
||||||
|
|
||||||
ndiff = redo_diff (dview);
|
|
||||||
if (ndiff >= 0)
|
|
||||||
dview->ndiff = ndiff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
static void
|
|
||||||
dview_diff_options (WDiff * dview)
|
|
||||||
{
|
|
||||||
const char *quality_str[] = {
|
|
||||||
N_("No&rmal"),
|
|
||||||
N_("&Fastest (Assume large files)"),
|
|
||||||
N_("&Minimal (Find a smaller set of change)")
|
|
||||||
};
|
|
||||||
|
|
||||||
QuickWidget diffopt_widgets[] = {
|
|
||||||
QUICK_BUTTON (6, 10, 14, OPTY, N_("&Cancel"), B_CANCEL, NULL),
|
|
||||||
QUICK_BUTTON (2, 10, 14, OPTY, N_("&OK"), B_ENTER, NULL),
|
|
||||||
|
|
||||||
QUICK_CHECKBOX (3, OPTX, 12, OPTY,
|
|
||||||
N_("Strip &trailing carriage return"), &dview->opt.strip_trailing_cr),
|
|
||||||
QUICK_CHECKBOX (3, OPTX, 11, OPTY,
|
|
||||||
N_("Ignore all &whitespace"), &dview->opt.ignore_all_space),
|
|
||||||
QUICK_CHECKBOX (3, OPTX, 10, OPTY,
|
|
||||||
N_("Ignore &space change"), &dview->opt.ignore_space_change),
|
|
||||||
QUICK_CHECKBOX (3, OPTX, 9, OPTY,
|
|
||||||
N_("Ignore tab &expansion"), &dview->opt.ignore_tab_expansion),
|
|
||||||
QUICK_CHECKBOX (3, OPTX, 8, OPTY,
|
|
||||||
N_("&Ignore case"), &dview->opt.ignore_case),
|
|
||||||
QUICK_LABEL (3, OPTX, 7, OPTY, N_("Diff extra options")),
|
|
||||||
QUICK_RADIO (3, OPTX, 3, OPTY,
|
|
||||||
3, (const char **) quality_str, (int *) &dview->opt.quality),
|
|
||||||
QUICK_LABEL (3, OPTX, 2, OPTY, N_("Diff algorithm")),
|
|
||||||
|
|
||||||
QUICK_END
|
|
||||||
};
|
|
||||||
|
|
||||||
QuickDialog diffopt = {
|
|
||||||
OPTX, OPTY, -1, -1,
|
|
||||||
N_("Diff Options"), "[Diff Options]",
|
|
||||||
diffopt_widgets, NULL, NULL, FALSE
|
|
||||||
};
|
|
||||||
|
|
||||||
if (quick_dialog (&diffopt) != B_CANCEL)
|
|
||||||
{
|
|
||||||
dview_reread (dview);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dview_fini (WDiff * dview)
|
dview_fini (WDiff * dview)
|
||||||
{
|
{
|
||||||
@ -3141,9 +3143,6 @@ dview_execute_cmd (WDiff * dview, unsigned long command)
|
|||||||
#ifdef HAVE_CHARSET
|
#ifdef HAVE_CHARSET
|
||||||
case CK_SelectCodepage:
|
case CK_SelectCodepage:
|
||||||
dview_select_encoding (dview);
|
dview_select_encoding (dview);
|
||||||
dview_reread (dview);
|
|
||||||
tty_touch_screen ();
|
|
||||||
repaint_screen ();
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case CK_Cancel:
|
case CK_Cancel:
|
||||||
|
@ -3401,19 +3401,17 @@ edit_complete_word_cmd (WEdit * edit)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef HAVE_CHARSET
|
||||||
void
|
void
|
||||||
edit_select_codepage_cmd (WEdit * edit)
|
edit_select_codepage_cmd (WEdit * edit)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_CHARSET
|
|
||||||
if (do_select_codepage ())
|
if (do_select_codepage ())
|
||||||
edit_set_codeset (edit);
|
edit_set_codeset (edit);
|
||||||
|
|
||||||
edit->force = REDRAW_PAGE;
|
edit->force = REDRAW_PAGE;
|
||||||
send_message ((Widget *) edit, WIDGET_DRAW, 0);
|
send_message ((Widget *) edit, WIDGET_DRAW, 0);
|
||||||
#else
|
|
||||||
(void) edit;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -337,16 +337,14 @@ mcview_set_codeset (mcview_t * view)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef HAVE_CHARSET
|
||||||
void
|
void
|
||||||
mcview_select_encoding (mcview_t * view)
|
mcview_select_encoding (mcview_t * view)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_CHARSET
|
|
||||||
if (do_select_codepage ())
|
if (do_select_codepage ())
|
||||||
mcview_set_codeset (view);
|
mcview_set_codeset (view);
|
||||||
#else
|
|
||||||
(void) view;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user