Skip to content

Commit 72f4cc4

Browse files
committed
patch 7.4.913
Problem: No utf-8 support for the hangul input feature. Solution: Add utf-8 support. (Namsh)
1 parent e01f4f8 commit 72f4cc4

8 files changed

Lines changed: 121 additions & 32 deletions

File tree

runtime/doc/hangulin.txt

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
*hangulin.txt* For Vim version 7.4. Last change: 2009 Jun 24
1+
*hangulin.txt* For Vim version 7.4. Last change: 2015 Nov 10
22

33

44
VIM REFERENCE MANUAL by Chi-Deok Hwang and Sung-Hyun Nam
55

6-
NOTE: The |+hangul_input| feature is scheduled to be removed. If you want to
7-
keep it, please send a message to the Vim user maillist.
8-
96

107
Introduction *hangul*
118
------------
@@ -17,7 +14,8 @@ Compile
1714
-------
1815
Next is a basic option. You can add any other configure option. >
1916
20-
./configure --with-x --enable-multibyte --enable-fontset --enable-hangulinput
17+
./configure --with-x --enable-multibyte --enable-hangulinput \
18+
--disable-xim
2119
2220
And you should check feature.h. If |+hangul_input| feature is enabled
2321
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. >
2624
#define HANGUL_DEFAULT_KEYBOARD 2
2725
#define ESC_CHG_TO_ENG_MODE
2826
/* #define X_LOCALE */
29-
/* #define SLOW_XSERVER */
3027
3128
Environment variables
3229
---------------------
33-
You should set LANG variable to Korean locale such as ko or ko_KR.euc.
30+
You should set LANG variable to Korean locale such as ko, ko_KR.eucKR
31+
or ko_KR.UTF-8.
3432
If you set LC_ALL variable, it should be set to Korean locale also.
3533

3634
VIM resource
3735
------------
38-
You should add nexts to your global vimrc ($HOME/.vimrc). >
36+
You may want to set 'encoding' and 'fileencodings'.
37+
Next are examples:
3938

40-
:set fileencoding=korea
39+
:set encoding=euc-kr
40+
:set encoding=utf-8
41+
:set fileencodings=ucs-bom,utf-8,cp949,euc-kr,latin1
4142

4243
Keyboard
4344
--------
@@ -52,8 +53,16 @@ If both are set, VIM_KEYBOARD has higher priority.
5253

5354
Hangul Fonts
5455
------------
55-
You can set text font using $HOME/.Xdefaults or in your gvimrc file.
56-
But to use Hangul, you should set 'guifontset' in your vimrc.
56+
If you use GTK version of GVIM, you should set 'guifont' and 'guifontwide'.
57+
For example:
58+
set guifont=Courier\ 12
59+
set guifontwide=NanumGothicCoding\ 12
60+
61+
If you use Motif or Athena version of GVIM, you should set 'guifontset' in
62+
your vimrc. You can set fontset in the .Xdefaults file.
63+
64+
$HOME/.gvimrc: >
65+
set guifontset=english_font,hangul_font
5766
5867
$HOME/.Xdefaults: >
5968
Vim.font: english_font
@@ -66,40 +75,38 @@ $HOME/.Xdefaults: >
6675
*international: True
6776
Vim*fontList: english_font;hangul_font:
6877
69-
$HOME/.gvimrc: >
70-
set guifontset=english_font,hangul_font
71-
7278
attention! the , (comma) or ; (semicolon)
7379

7480
And there should be no ':set guifont'. If it exists, then Gvim ignores
7581
':set guifontset'. It means VIM runs without fontset supporting.
7682
So, you can see only English. Hangul does not be correctly displayed.
7783

78-
After 'fontset' feature is enabled, VIM does not allow using 'font'.
84+
After 'fontset' feature is enabled, VIM does not allow using english
85+
font only in 'font' setting for syntax.
7986
For example, if you use >
8087
:set guifontset=eng_font,your_font
8188
in your .gvimrc, then you should do for syntax >
8289
:hi Comment guifg=Cyan font=another_eng_font,another_your_font
8390
If you just do >
8491
:hi Comment font=another_eng_font
85-
then you can see a GOOD error message. Be careful!
92+
then you can see a error message. Be careful!
8693

8794
hangul_font width should be twice than english_font width.
8895

8996
Unsupported Feature
9097
-------------------
91-
Johab font not yet supported. And I don't have any plan.
92-
If you really want to use johab font, you can use the
93-
hanguldraw.c in gau package.
98+
We don't support Johab font.
99+
We don't support Hanja input.
100+
And We don't have any plan to support them.
94101

95-
Hanja input not yet supported. And I don't have any plan.
96-
If you really want to input hanja, just use VIM with hanterm.
102+
If you really need such features, you can use console version of VIM with a
103+
capable terminal emulator.
97104

98105
Bug or Comment
99106
--------------
100107
Send comments, patches and suggestions to:
101108

102-
Chi-Deok Hwang <[email protected]>
103109
SungHyun Nam <[email protected]>
110+
Chi-Deok Hwang <...>
104111

105112
vim:tw=78:ts=8:ft=help:norl:

src/feature.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,17 +677,13 @@
677677
# define ESC_CHG_TO_ENG_MODE /* if defined, when ESC pressed,
678678
* turn to english mode
679679
*/
680-
# if !defined(FEAT_XFONTSET) && defined(HAVE_X11) && !defined(FEAT_GUI_GTK)
681-
# define FEAT_XFONTSET /* Hangul input requires xfontset */
682-
# endif
683680
# if defined(FEAT_XIM) && !defined(LINT)
684681
Error: You should select only ONE of XIM and HANGUL INPUT
685682
# endif
686683
#endif
687684
#if defined(FEAT_HANGULIN) || defined(FEAT_XIM)
688685
/* # define X_LOCALE */ /* for OS with incomplete locale
689686
support, like old linux versions. */
690-
/* # define SLOW_XSERVER */ /* for extremely slow X server */
691687
#endif
692688

693689
/*

src/gui.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,8 +1223,19 @@ gui_update_cursor(force, clear_selection)
12231223
gui.highlight_mask = (cattr | attr);
12241224
#ifdef FEAT_HANGULIN
12251225
if (composing_hangul)
1226-
(void)gui_outstr_nowrap(composing_hangul_buffer, 2,
1227-
GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR, cfg, cbg, 0);
1226+
{
1227+
char_u *comp_buf;
1228+
int comp_len;
1229+
1230+
comp_buf = hangul_composing_buffer_get(&comp_len);
1231+
if (comp_buf)
1232+
{
1233+
(void)gui_outstr_nowrap(comp_buf, comp_len,
1234+
GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR,
1235+
cfg, cbg, 0);
1236+
vim_free(comp_buf);
1237+
}
1238+
}
12281239
else
12291240
#endif
12301241
(void)gui_screenchar(LineOffset[gui.row] + gui.col,
@@ -2572,9 +2583,19 @@ gui_undraw_cursor()
25722583
#ifdef FEAT_HANGULIN
25732584
if (composing_hangul
25742585
&& gui.col == gui.cursor_col && gui.row == gui.cursor_row)
2575-
(void)gui_outstr_nowrap(composing_hangul_buffer, 2,
2576-
GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR,
2577-
gui.norm_pixel, gui.back_pixel, 0);
2586+
{
2587+
char_u *comp_buf;
2588+
int comp_len;
2589+
2590+
comp_buf = hangul_composing_buffer_get(&comp_len);
2591+
if (comp_buf)
2592+
{
2593+
(void)gui_outstr_nowrap(comp_buf, comp_len,
2594+
GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR,
2595+
gui.norm_pixel, gui.back_pixel, 0);
2596+
vim_free(comp_buf);
2597+
}
2598+
}
25782599
else
25792600
{
25802601
#endif

src/hangulin.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,3 +1619,49 @@ convert_3_to_ks(fv, mv, lv, des)
16191619
*des++ = johab_lcon_to_wan[lv];
16201620
return 8;
16211621
}
1622+
1623+
char_u *
1624+
hangul_string_convert(buf, p_len)
1625+
char_u *buf;
1626+
int *p_len;
1627+
{
1628+
char_u *tmpbuf = NULL;
1629+
vimconv_T vc;
1630+
1631+
if (enc_utf8)
1632+
{
1633+
vc.vc_type = CONV_NONE;
1634+
if (convert_setup(&vc, (char_u *)"euc-kr", p_enc) == OK)
1635+
{
1636+
tmpbuf = string_convert(&vc, buf, p_len);
1637+
convert_setup(&vc, NULL, NULL);
1638+
}
1639+
}
1640+
1641+
return tmpbuf;
1642+
}
1643+
1644+
char_u *
1645+
hangul_composing_buffer_get(p_len)
1646+
int *p_len;
1647+
{
1648+
char_u *tmpbuf = NULL;
1649+
1650+
if (composing_hangul)
1651+
{
1652+
int len = 2;
1653+
1654+
tmpbuf = hangul_string_convert(composing_hangul_buffer, &len);
1655+
if (tmpbuf != NULL)
1656+
{
1657+
*p_len = len;
1658+
}
1659+
else
1660+
{
1661+
tmpbuf = vim_strnsave(composing_hangul_buffer, 2);
1662+
*p_len = 2;
1663+
}
1664+
}
1665+
1666+
return tmpbuf;
1667+
}

src/proto/hangulin.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ void hangul_input_state_toggle __ARGS((void));
66
void hangul_keyboard_set __ARGS((void));
77
int hangul_input_process __ARGS((char_u *s, int len));
88
void hangul_input_clear __ARGS((void));
9+
char_u *hangul_string_convert __ARGS((char_u *buf, int *p_len));
10+
char_u *hangul_composing_buffer_get __ARGS((int *p_len));
911
/* vim: set ft=c : */

src/screen.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10047,7 +10047,13 @@ showmode()
1004710047
if (gui.in_use)
1004810048
{
1004910049
if (hangul_input_state_get())
10050-
MSG_PUTS_ATTR(" \307\321\261\333", attr); /* HANGUL */
10050+
{
10051+
/* HANGUL */
10052+
if (enc_utf8)
10053+
MSG_PUTS_ATTR(" \355\225\234\352\270\200", attr);
10054+
else
10055+
MSG_PUTS_ATTR(" \307\321\261\333", attr);
10056+
}
1005110057
}
1005210058
#endif
1005310059
#ifdef FEAT_INS_EXPAND

src/ui.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,8 +1723,17 @@ push_raw_key(s, len)
17231723
char_u *s;
17241724
int len;
17251725
{
1726+
char_u *tmpbuf;
1727+
1728+
tmpbuf = hangul_string_convert(s, &len);
1729+
if (tmpbuf != NULL)
1730+
s = tmpbuf;
1731+
17261732
while (len--)
17271733
inbuf[inbufcount++] = *s++;
1734+
1735+
if (tmpbuf != NULL)
1736+
vim_free(tmpbuf);
17281737
}
17291738
#endif
17301739

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
913,
744746
/**/
745747
912,
746748
/**/

0 commit comments

Comments
 (0)