mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
add str_isutf8 return 1 if codeset_name is utf8 or utf-8
add unsigned int utf8:1 to struct WEdit if utf8 then file multibute codeset
This commit is contained in:
parent
36bf010af6
commit
b5c4a9ddf2
@ -65,6 +65,7 @@ struct WEdit {
|
||||
unsigned int screen_modified:1; /* File has been changed since the last screen draw */
|
||||
unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
|
||||
unsigned int highlight:1; /* There is a selected block */
|
||||
unsigned int utf8:1; /* It's multibyte file codeset */
|
||||
long prev_col; /* recent column position of the cursor - used when moving
|
||||
up or down past lines that are shorter than the current line */
|
||||
long curs_line; /* line number of the cursor. */
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include "../src/wtools.h" /* query_dialog() */
|
||||
#include "../src/timefmt.h" /* time formatting */
|
||||
#include "../src/strutil.h" /* utf string functions */
|
||||
#include "../src/charsets.h" /* get_codepage_id */
|
||||
#include "../src/main.h" /* source_codepage */
|
||||
|
||||
/*
|
||||
what editor are we going to emulate? one of EDIT_KEY_EMULATION_NORMAL
|
||||
@ -162,6 +164,7 @@ edit_load_file_fast (WEdit *edit, const char *filename)
|
||||
|
||||
edit->curs2 = edit->last_byte;
|
||||
buf2 = edit->curs2 >> S_EDIT_BUF_SIZE;
|
||||
edit->utf8 = str_isutf8 (get_codepage_id( source_codepage ));
|
||||
|
||||
if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) {
|
||||
GString *errmsg = g_string_new(NULL);
|
||||
|
@ -52,7 +52,7 @@
|
||||
#include "../src/tty.h" /* LINES */
|
||||
#include "../src/widget.h" /* listbox_new() */
|
||||
#include "../src/layout.h" /* clr_scr() */
|
||||
#include "../src/main.h" /* mc_home */
|
||||
#include "../src/main.h" /* mc_home source_codepage */
|
||||
#include "../src/help.h" /* interactive_display() */
|
||||
#include "../src/key.h" /* XCTRL */
|
||||
#include "../src/dialog.h" /* do_refresh() */
|
||||
@ -2932,6 +2932,7 @@ edit_select_codepage_cmd (WEdit *edit)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
do_select_codepage ();
|
||||
edit->utf8 = str_isutf8 (get_codepage_id (source_codepage));
|
||||
edit->force = REDRAW_COMPLETELY;
|
||||
edit_refresh_cmd (edit);
|
||||
#endif
|
||||
|
@ -398,6 +398,16 @@ str_choose_str_functions ()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
str_isutf8 (char *codeset_name)
|
||||
{
|
||||
int result = 0;
|
||||
if (str_test_encoding_class (codeset_name, str_utf8_encodings)) {
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
str_init_strings (const char *termenc)
|
||||
{
|
||||
|
@ -533,5 +533,10 @@ int str_key_collate (const char *t1, const char *t2, int case_sen);
|
||||
*/
|
||||
void str_release_key (char *key, int case_sen);
|
||||
|
||||
/* return 1 if codeset_name is utf8 or utf-8
|
||||
* I
|
||||
*/
|
||||
int str_isutf8 (char *codeset_name);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user