1
1
Этот коммит содержится в:
Ilia Maslakov 2009-04-18 14:50:05 +00:00
родитель b8184a4595
Коммит d8175b3e6b
2 изменённых файлов: 42 добавлений и 33 удалений

Просмотреть файл

@ -257,14 +257,41 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
edit->charbuf[edit->charpoint] = '\0';
}
if (!edit->utf8) {
/* input from 8-bit locale */
if ( utf8_display ) {
/* input from 8-bit locale */
if ( !utf8_display ) {
/* source in 8-bit codeset */
if (!edit->utf8) {
c = convert_from_input_c (x_key);
if (is_printable (c)) {
char_for_insertion = c;
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 {
edit->charbuf[edit->charpoint + 1] = '\0';
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;
}
}
} 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
convert_from_utf_to_current (const char *str)
{
if (!str)
return '.';
unsigned char buf_ch[6 + 1];
unsigned char ch;
char *cp_from = NULL;
GIConv conv;
GString *translated_data;
int res = 0;
translated_data = g_string_new ("");
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 (str_convert (conv, (char *) str, translated_data) != ESTR_FAILURE) {
ch = translated_data->str[0];
} else {
switch (str_translate_char (conv, str, res, buf_ch, sizeof(buf_ch))) {
case 0:
ch = buf_ch[0];
break;
case 1:
ch = '.';
break;
case 2:
ch = '.';
}
str_close_conv (conv);
}
g_string_free (translated_data, TRUE);
return ch;
}