fix: incorrect input
Этот коммит содержится в:
родитель
b8184a4595
Коммит
d8175b3e6b
@ -257,14 +257,41 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||||||
edit->charbuf[edit->charpoint] = '\0';
|
edit->charbuf[edit->charpoint] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!edit->utf8) {
|
/* input from 8-bit locale */
|
||||||
/* input from 8-bit locale */
|
if ( !utf8_display ) {
|
||||||
if ( utf8_display ) {
|
/* source in 8-bit codeset */
|
||||||
|
if (!edit->utf8) {
|
||||||
c = convert_from_input_c (x_key);
|
c = convert_from_input_c (x_key);
|
||||||
if (is_printable (c)) {
|
if (is_printable (c)) {
|
||||||
char_for_insertion = c;
|
char_for_insertion = c;
|
||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
//FIXME: need more think about
|
||||||
|
//must be return multibyte char
|
||||||
|
}
|
||||||
|
/* UTF-8 locale */
|
||||||
|
} else {
|
||||||
|
/* source in UTF-8 codeset */
|
||||||
|
if ( edit->utf8 ) {
|
||||||
|
int res = str_is_valid_char (edit->charbuf, edit->charpoint);
|
||||||
|
if (res < 0) {
|
||||||
|
if (res != -2) {
|
||||||
|
edit->charpoint = 0; /* broken multibyte char, skip */
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
char_for_insertion = x_key;
|
||||||
|
goto fin;
|
||||||
|
} else {
|
||||||
|
edit->charbuf[edit->charpoint]='\0';
|
||||||
|
edit->charpoint = 0;
|
||||||
|
if ( g_unichar_isprint (g_utf8_get_char(edit->charbuf))) {
|
||||||
|
char_for_insertion = x_key;
|
||||||
|
goto fin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 8-bit source */
|
||||||
} else {
|
} else {
|
||||||
edit->charbuf[edit->charpoint + 1] = '\0';
|
edit->charbuf[edit->charpoint + 1] = '\0';
|
||||||
int res = str_is_valid_char (edit->charbuf, edit->charpoint);
|
int res = str_is_valid_char (edit->charbuf, edit->charpoint);
|
||||||
@ -291,29 +318,6 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
int res = str_is_valid_char (edit->charbuf, edit->charpoint);
|
|
||||||
|
|
||||||
if (res < 0) {
|
|
||||||
if (res != -2) {
|
|
||||||
edit->charpoint = 0; /* broken multibyte char, skip */
|
|
||||||
goto fin;
|
|
||||||
}
|
|
||||||
char_for_insertion = x_key;
|
|
||||||
goto fin;
|
|
||||||
} else {
|
|
||||||
edit->charbuf[edit->charpoint]='\0';
|
|
||||||
edit->charpoint = 0;
|
|
||||||
if ( g_unichar_isprint (g_utf8_get_char(edit->charbuf))) {
|
|
||||||
mc_log("input:%s \n", edit->charbuf);
|
|
||||||
char_for_insertion = x_key;
|
|
||||||
goto fin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//char_for_insertion = x_key;
|
|
||||||
//goto fin;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,27 +297,32 @@ str_convert_from_input (char *str)
|
|||||||
unsigned char
|
unsigned char
|
||||||
convert_from_utf_to_current (const char *str)
|
convert_from_utf_to_current (const char *str)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return '.';
|
return '.';
|
||||||
|
|
||||||
|
unsigned char buf_ch[6 + 1];
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
char *cp_from = NULL;
|
char *cp_from = NULL;
|
||||||
GIConv conv;
|
GIConv conv;
|
||||||
GString *translated_data;
|
int res = 0;
|
||||||
|
|
||||||
translated_data = g_string_new ("");
|
|
||||||
cp_from = get_codepage_id ( source_codepage );
|
cp_from = get_codepage_id ( source_codepage );
|
||||||
conv = str_crt_conv_from (cp_from);
|
conv = str_crt_conv_from ( cp_from );
|
||||||
|
|
||||||
if (conv != INVALID_CONV) {
|
if (conv != INVALID_CONV) {
|
||||||
if (str_convert (conv, (char *) str, translated_data) != ESTR_FAILURE) {
|
switch (str_translate_char (conv, str, res, buf_ch, sizeof(buf_ch))) {
|
||||||
ch = translated_data->str[0];
|
case 0:
|
||||||
} else {
|
ch = buf_ch[0];
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ch = '.';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
ch = '.';
|
ch = '.';
|
||||||
}
|
}
|
||||||
str_close_conv (conv);
|
str_close_conv (conv);
|
||||||
}
|
}
|
||||||
g_string_free (translated_data, TRUE);
|
|
||||||
return ch;
|
return ch;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user