edit_set_codeset(): new function to set codeset in MC editor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
родитель
d37af446b7
Коммит
72144b4895
src/editor
@ -193,6 +193,7 @@ void edit_update_curs_row (WEdit * edit);
|
||||
void edit_update_curs_col (WEdit * edit);
|
||||
void edit_find_bracket (WEdit * edit);
|
||||
int edit_reload_line (WEdit * edit, const char *filename, long line);
|
||||
void edit_set_codeset (WEdit *edit);
|
||||
|
||||
void edit_block_copy_cmd (WEdit * edit);
|
||||
void edit_block_move_cmd (WEdit * edit);
|
||||
|
@ -904,28 +904,10 @@ edit_init (WEdit * edit, int lines, int columns, const char *filename, long line
|
||||
edit->stack_size = START_STACK_SIZE;
|
||||
edit->stack_size_mask = START_STACK_SIZE - 1;
|
||||
edit->undo_stack = g_malloc0 ((edit->stack_size + 10) * sizeof (long));
|
||||
|
||||
edit->utf8 = 0;
|
||||
edit->converter = str_cnv_from_term;
|
||||
#ifdef HAVE_CHARSET
|
||||
{
|
||||
const char *cp_id = NULL;
|
||||
cp_id = get_codepage_id (source_codepage >= 0 ? source_codepage : display_codepage);
|
||||
|
||||
if (cp_id != NULL)
|
||||
{
|
||||
GIConv conv;
|
||||
conv = str_crt_conv_from (cp_id);
|
||||
if (conv != INVALID_CONV)
|
||||
{
|
||||
if (edit->converter != str_cnv_from_term)
|
||||
str_close_conv (edit->converter);
|
||||
edit->converter = conv;
|
||||
}
|
||||
}
|
||||
if (cp_id != NULL)
|
||||
edit->utf8 = str_isutf8 (cp_id);
|
||||
}
|
||||
#endif
|
||||
edit_set_codeset (edit);
|
||||
|
||||
if (edit_load_file (edit))
|
||||
{
|
||||
@ -1069,6 +1051,33 @@ edit_reload_line (WEdit * edit, const char *filename, long line)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
edit_set_codeset (WEdit *edit)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
const char *cp_id;
|
||||
|
||||
cp_id = get_codepage_id (source_codepage >= 0 ? source_codepage : display_codepage);
|
||||
|
||||
if (cp_id != NULL)
|
||||
{
|
||||
GIConv conv;
|
||||
conv = str_crt_conv_from (cp_id);
|
||||
if (conv != INVALID_CONV)
|
||||
{
|
||||
if (edit->converter != str_cnv_from_term)
|
||||
str_close_conv (edit->converter);
|
||||
edit->converter = conv;
|
||||
}
|
||||
}
|
||||
|
||||
if (cp_id != NULL)
|
||||
edit->utf8 = str_isutf8 (cp_id);
|
||||
#else
|
||||
(void) edit;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Recording stack for undo:
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "src/history.h"
|
||||
#include "src/widget.h" /* listbox_new() */
|
||||
#include "src/layout.h" /* clr_scr() */
|
||||
#include "src/main.h" /* mc_home source_codepage */
|
||||
#include "src/main.h" /* mc_home */
|
||||
#include "src/help.h" /* interactive_display() */
|
||||
#include "src/wtools.h" /* message() */
|
||||
#include "src/charsets.h"
|
||||
@ -2880,26 +2880,8 @@ void
|
||||
edit_select_codepage_cmd (WEdit * edit)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
const char *cp_id = NULL;
|
||||
if (do_select_codepage ())
|
||||
{
|
||||
cp_id = get_codepage_id (source_codepage >= 0 ? source_codepage : display_codepage);
|
||||
|
||||
if (cp_id != NULL)
|
||||
{
|
||||
GIConv conv;
|
||||
conv = str_crt_conv_from (cp_id);
|
||||
if (conv != INVALID_CONV)
|
||||
{
|
||||
if (edit->converter != str_cnv_from_term)
|
||||
str_close_conv (edit->converter);
|
||||
edit->converter = conv;
|
||||
}
|
||||
}
|
||||
|
||||
if (cp_id != NULL)
|
||||
edit->utf8 = str_isutf8 (cp_id);
|
||||
}
|
||||
edit_set_codeset (edit);
|
||||
|
||||
edit->force = REDRAW_COMPLETELY;
|
||||
edit_refresh_cmd (edit);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user