0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 7.4.913

Problem:    No utf-8 support for the hangul input feature.
Solution:   Add utf-8 support. (Namsh)
This commit is contained in:
Bram Moolenaar
2015-11-10 14:35:18 +01:00
parent e01f4f86ce
commit 72f4cc4a98
8 changed files with 121 additions and 32 deletions

View File

@@ -1,11 +1,8 @@
*hangulin.txt* For Vim version 7.4. Last change: 2009 Jun 24 *hangulin.txt* For Vim version 7.4. Last change: 2015 Nov 10
VIM REFERENCE MANUAL by Chi-Deok Hwang and Sung-Hyun Nam VIM REFERENCE MANUAL by Chi-Deok Hwang and Sung-Hyun Nam
NOTE: The |+hangul_input| feature is scheduled to be removed. If you want to
keep it, please send a message to the Vim user maillist.
Introduction *hangul* Introduction *hangul*
------------ ------------
@@ -17,7 +14,8 @@ Compile
------- -------
Next is a basic option. You can add any other configure option. > Next is a basic option. You can add any other configure option. >
./configure --with-x --enable-multibyte --enable-fontset --enable-hangulinput ./configure --with-x --enable-multibyte --enable-hangulinput \
--disable-xim
And you should check feature.h. If |+hangul_input| feature is enabled And you should check feature.h. If |+hangul_input| feature is enabled
by configure, you can select more options such as keyboard type, 2 bulsik by configure, you can select more options such as keyboard type, 2 bulsik
@@ -26,18 +24,21 @@ or 3 bulsik. You can find keywords like next in there. >
#define HANGUL_DEFAULT_KEYBOARD 2 #define HANGUL_DEFAULT_KEYBOARD 2
#define ESC_CHG_TO_ENG_MODE #define ESC_CHG_TO_ENG_MODE
/* #define X_LOCALE */ /* #define X_LOCALE */
/* #define SLOW_XSERVER */
Environment variables Environment variables
--------------------- ---------------------
You should set LANG variable to Korean locale such as ko or ko_KR.euc. You should set LANG variable to Korean locale such as ko, ko_KR.eucKR
or ko_KR.UTF-8.
If you set LC_ALL variable, it should be set to Korean locale also. If you set LC_ALL variable, it should be set to Korean locale also.
VIM resource VIM resource
------------ ------------
You should add nexts to your global vimrc ($HOME/.vimrc). > You may want to set 'encoding' and 'fileencodings'.
Next are examples:
:set fileencoding=korea :set encoding=euc-kr
:set encoding=utf-8
:set fileencodings=ucs-bom,utf-8,cp949,euc-kr,latin1
Keyboard Keyboard
-------- --------
@@ -52,8 +53,16 @@ If both are set, VIM_KEYBOARD has higher priority.
Hangul Fonts Hangul Fonts
------------ ------------
You can set text font using $HOME/.Xdefaults or in your gvimrc file. If you use GTK version of GVIM, you should set 'guifont' and 'guifontwide'.
But to use Hangul, you should set 'guifontset' in your vimrc. For example:
set guifont=Courier\ 12
set guifontwide=NanumGothicCoding\ 12
If you use Motif or Athena version of GVIM, you should set 'guifontset' in
your vimrc. You can set fontset in the .Xdefaults file.
$HOME/.gvimrc: >
set guifontset=english_font,hangul_font
$HOME/.Xdefaults: > $HOME/.Xdefaults: >
Vim.font: english_font Vim.font: english_font
@@ -66,40 +75,38 @@ $HOME/.Xdefaults: >
*international: True *international: True
Vim*fontList: english_font;hangul_font: Vim*fontList: english_font;hangul_font:
$HOME/.gvimrc: >
set guifontset=english_font,hangul_font
attention! the , (comma) or ; (semicolon) attention! the , (comma) or ; (semicolon)
And there should be no ':set guifont'. If it exists, then Gvim ignores And there should be no ':set guifont'. If it exists, then Gvim ignores
':set guifontset'. It means VIM runs without fontset supporting. ':set guifontset'. It means VIM runs without fontset supporting.
So, you can see only English. Hangul does not be correctly displayed. So, you can see only English. Hangul does not be correctly displayed.
After 'fontset' feature is enabled, VIM does not allow using 'font'. After 'fontset' feature is enabled, VIM does not allow using english
font only in 'font' setting for syntax.
For example, if you use > For example, if you use >
:set guifontset=eng_font,your_font :set guifontset=eng_font,your_font
in your .gvimrc, then you should do for syntax > in your .gvimrc, then you should do for syntax >
:hi Comment guifg=Cyan font=another_eng_font,another_your_font :hi Comment guifg=Cyan font=another_eng_font,another_your_font
If you just do > If you just do >
:hi Comment font=another_eng_font :hi Comment font=another_eng_font
then you can see a GOOD error message. Be careful! then you can see a error message. Be careful!
hangul_font width should be twice than english_font width. hangul_font width should be twice than english_font width.
Unsupported Feature Unsupported Feature
------------------- -------------------
Johab font not yet supported. And I don't have any plan. We don't support Johab font.
If you really want to use johab font, you can use the We don't support Hanja input.
hanguldraw.c in gau package. And We don't have any plan to support them.
Hanja input not yet supported. And I don't have any plan. If you really need such features, you can use console version of VIM with a
If you really want to input hanja, just use VIM with hanterm. capable terminal emulator.
Bug or Comment Bug or Comment
-------------- --------------
Send comments, patches and suggestions to: Send comments, patches and suggestions to:
Chi-Deok Hwang <hwang@mizi.co.kr>
SungHyun Nam <goweol@gmail.com> SungHyun Nam <goweol@gmail.com>
Chi-Deok Hwang <...>
vim:tw=78:ts=8:ft=help:norl: vim:tw=78:ts=8:ft=help:norl:

View File

@@ -677,9 +677,6 @@
# define ESC_CHG_TO_ENG_MODE /* if defined, when ESC pressed, # define ESC_CHG_TO_ENG_MODE /* if defined, when ESC pressed,
* turn to english mode * turn to english mode
*/ */
# if !defined(FEAT_XFONTSET) && defined(HAVE_X11) && !defined(FEAT_GUI_GTK)
# define FEAT_XFONTSET /* Hangul input requires xfontset */
# endif
# if defined(FEAT_XIM) && !defined(LINT) # if defined(FEAT_XIM) && !defined(LINT)
Error: You should select only ONE of XIM and HANGUL INPUT Error: You should select only ONE of XIM and HANGUL INPUT
# endif # endif
@@ -687,7 +684,6 @@
#if defined(FEAT_HANGULIN) || defined(FEAT_XIM) #if defined(FEAT_HANGULIN) || defined(FEAT_XIM)
/* # define X_LOCALE */ /* for OS with incomplete locale /* # define X_LOCALE */ /* for OS with incomplete locale
support, like old linux versions. */ support, like old linux versions. */
/* # define SLOW_XSERVER */ /* for extremely slow X server */
#endif #endif
/* /*

View File

@@ -1223,8 +1223,19 @@ gui_update_cursor(force, clear_selection)
gui.highlight_mask = (cattr | attr); gui.highlight_mask = (cattr | attr);
#ifdef FEAT_HANGULIN #ifdef FEAT_HANGULIN
if (composing_hangul) if (composing_hangul)
(void)gui_outstr_nowrap(composing_hangul_buffer, 2, {
GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR, cfg, cbg, 0); char_u *comp_buf;
int comp_len;
comp_buf = hangul_composing_buffer_get(&comp_len);
if (comp_buf)
{
(void)gui_outstr_nowrap(comp_buf, comp_len,
GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR,
cfg, cbg, 0);
vim_free(comp_buf);
}
}
else else
#endif #endif
(void)gui_screenchar(LineOffset[gui.row] + gui.col, (void)gui_screenchar(LineOffset[gui.row] + gui.col,
@@ -2572,9 +2583,19 @@ gui_undraw_cursor()
#ifdef FEAT_HANGULIN #ifdef FEAT_HANGULIN
if (composing_hangul if (composing_hangul
&& gui.col == gui.cursor_col && gui.row == gui.cursor_row) && gui.col == gui.cursor_col && gui.row == gui.cursor_row)
(void)gui_outstr_nowrap(composing_hangul_buffer, 2, {
GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR, char_u *comp_buf;
gui.norm_pixel, gui.back_pixel, 0); int comp_len;
comp_buf = hangul_composing_buffer_get(&comp_len);
if (comp_buf)
{
(void)gui_outstr_nowrap(comp_buf, comp_len,
GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR,
gui.norm_pixel, gui.back_pixel, 0);
vim_free(comp_buf);
}
}
else else
{ {
#endif #endif

View File

@@ -1619,3 +1619,49 @@ convert_3_to_ks(fv, mv, lv, des)
*des++ = johab_lcon_to_wan[lv]; *des++ = johab_lcon_to_wan[lv];
return 8; return 8;
} }
char_u *
hangul_string_convert(buf, p_len)
char_u *buf;
int *p_len;
{
char_u *tmpbuf = NULL;
vimconv_T vc;
if (enc_utf8)
{
vc.vc_type = CONV_NONE;
if (convert_setup(&vc, (char_u *)"euc-kr", p_enc) == OK)
{
tmpbuf = string_convert(&vc, buf, p_len);
convert_setup(&vc, NULL, NULL);
}
}
return tmpbuf;
}
char_u *
hangul_composing_buffer_get(p_len)
int *p_len;
{
char_u *tmpbuf = NULL;
if (composing_hangul)
{
int len = 2;
tmpbuf = hangul_string_convert(composing_hangul_buffer, &len);
if (tmpbuf != NULL)
{
*p_len = len;
}
else
{
tmpbuf = vim_strnsave(composing_hangul_buffer, 2);
*p_len = 2;
}
}
return tmpbuf;
}

View File

@@ -6,4 +6,6 @@ void hangul_input_state_toggle __ARGS((void));
void hangul_keyboard_set __ARGS((void)); void hangul_keyboard_set __ARGS((void));
int hangul_input_process __ARGS((char_u *s, int len)); int hangul_input_process __ARGS((char_u *s, int len));
void hangul_input_clear __ARGS((void)); void hangul_input_clear __ARGS((void));
char_u *hangul_string_convert __ARGS((char_u *buf, int *p_len));
char_u *hangul_composing_buffer_get __ARGS((int *p_len));
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@@ -10047,7 +10047,13 @@ showmode()
if (gui.in_use) if (gui.in_use)
{ {
if (hangul_input_state_get()) if (hangul_input_state_get())
MSG_PUTS_ATTR(" \307\321\261\333", attr); /* HANGUL */ {
/* HANGUL */
if (enc_utf8)
MSG_PUTS_ATTR(" \355\225\234\352\270\200", attr);
else
MSG_PUTS_ATTR(" \307\321\261\333", attr);
}
} }
#endif #endif
#ifdef FEAT_INS_EXPAND #ifdef FEAT_INS_EXPAND

View File

@@ -1723,8 +1723,17 @@ push_raw_key(s, len)
char_u *s; char_u *s;
int len; int len;
{ {
char_u *tmpbuf;
tmpbuf = hangul_string_convert(s, &len);
if (tmpbuf != NULL)
s = tmpbuf;
while (len--) while (len--)
inbuf[inbufcount++] = *s++; inbuf[inbufcount++] = *s++;
if (tmpbuf != NULL)
vim_free(tmpbuf);
} }
#endif #endif

View File

@@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
913,
/**/ /**/
912, 912,
/**/ /**/