Compare commits

..

5 Commits

Author SHA1 Message Date
Bram Moolenaar
6315a9ae92 patch 8.0.1336: cannot use imactivatefunc() unless compiled with +xim
Problem:    Cannot use imactivatefunc() unless compiled with +xim.
Solution:   Allow using imactivatefunc() when not compiled with +xim.
            (Yasuhiro Matsumoto, closes #2349)
2017-11-25 15:20:02 +01:00
Bram Moolenaar
291a9d15ed patch 8.0.1335: writefile() using fsync() may give an error.
Problem:    Writefile() using fsync() may give an error for a device.
            (Yasuhiro Matsumoto)
Solution:   Ignore fsync() failing. (closes #2373)
2017-11-25 14:37:11 +01:00
Bram Moolenaar
3167c3e701 patch 8.0.1334: splitting a window with a WinBar damages window layout
Problem:    Splitting a window with a WinBar damages window layout.
            (Lifepillar)
Solution:   Take the winbar into account when computing the new window
            position.  Add WINBAR_HEIGHT().
2017-11-25 14:19:43 +01:00
Bram Moolenaar
2c997d7603 patch 8.0.1333: some tests are run twice
Problem:    Some tests are run twice.
Solution:   Invoked most utf8 tests only from test_alot_utf8. (Yegappan
            Lakshmanan, closes #2369)
2017-11-23 22:52:09 +01:00
Bram Moolenaar
93a32e2ec4 patch 8.0.1332: highlighting in quickfix window could be better
Problem:    Highlighting in quickfix window could be better. (Axel Bender)
Solution:   Use the qfSeparator highlight item. (Yegappan Lakshmanan)
2017-11-23 22:05:45 +01:00
16 changed files with 201 additions and 79 deletions

View File

@@ -26,8 +26,9 @@ For changing the language of messages and menus see |mlang.txt|.
7. Input on X11 |mbyte-XIM|
8. Input on MS-Windows |mbyte-IME|
9. Input with a keymap |mbyte-keymap|
10. Using UTF-8 |mbyte-utf8|
11. Overview of options |mbyte-options|
10. Input with imactivatefunc() |mbyte-func|
11. Using UTF-8 |mbyte-utf8|
12. Overview of options |mbyte-options|
NOTE: This file contains UTF-8 characters. These may show up as strange
characters or boxes when using another encoding.
@@ -1254,7 +1255,35 @@ Combining forms:
ﭏ 0xfb4f Xal alef-lamed
==============================================================================
10. Using UTF-8 *mbyte-utf8* *UTF-8* *utf-8* *utf8*
10. Input with imactivatefunc() *mbyte-func*
Vim has |imactivatefunc()| and |imstatusfunc()|. This is useful to
activate/deativate input method from Vim in any way, also with an external
command. For example, fcitx provide fcitx-remote command: >
set iminsert=2
set imsearch=2
set imcmdline
set imactivatefunc=ImActivate
function! ImActivate(active)
if a:active
call system('fcitx-remote -o')
else
call system('fcitx-remote -c')
endif
endfunction
set imstatusfunc=ImStatus
function! ImStatus()
return system('fcitx-remote')[0] is# '2'
endfunction
Using this script, you can activate/deactivate XIM via Vim even when it is not
compiled with |+xim|.
==============================================================================
11. Using UTF-8 *mbyte-utf8* *UTF-8* *utf-8* *utf8*
*Unicode* *unicode*
The Unicode character set was designed to include all characters from other
character sets. Therefore it is possible to write text in any language using
@@ -1402,7 +1431,7 @@ not everybody is able to type a composing character.
==============================================================================
11. Overview of options *mbyte-options*
12. Overview of options *mbyte-options*
These options are relevant for editing multi-byte files. Check the help in
options.txt for detailed information.

View File

@@ -4256,8 +4256,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'imactivatefunc' 'imaf' string (default "")
global
{not in Vi}
{only available when compiled with |+xim| and
|+GUI_GTK|}
{only available when compiled with |+mbyte|}
This option specifies a function that will be called to
activate/inactivate Input Method.
@@ -4308,8 +4307,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'imcmdline' 'imc' boolean (default off)
global
{not in Vi}
{only available when compiled with the |+xim|,
|+multi_byte_ime| or |global-ime| features}
{only available when compiled with |+mbyte|}
When set the Input Method is always on when starting to edit a command
line, unless entering a search pattern (see 'imsearch' for that).
Setting this option is useful when your input method allows entering
@@ -4320,8 +4318,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'imdisable' 'imd' boolean (default off, on for some systems (SGI))
global
{not in Vi}
{only available when compiled with the |+xim|,
|+multi_byte_ime| or |global-ime| features}
{only available when compiled with |+mbyte|}
When set the Input Method is never used. This is useful to disable
the IM when it doesn't work properly.
Currently this option is on by default for SGI/IRIX machines. This
@@ -4336,8 +4333,6 @@ A jump table for the options with a short description can be found at |Q_op|.
0 :lmap is off and IM is off
1 :lmap is ON and IM is off
2 :lmap is off and IM is ON
2 is available only when compiled with the |+multi_byte_ime|, |+xim|
or |global-ime|.
To always reset the option to zero when leaving Insert mode with <Esc>
this can be used: >
:inoremap <ESC> <ESC>:set iminsert=0<CR>
@@ -4350,6 +4345,10 @@ A jump table for the options with a short description can be found at |Q_op|.
The value 0 may not work correctly with Athena and Motif with some XIM
methods. Use 'imdisable' to disable XIM then.
You can set 'imactivatefunc' and 'imstatusfunc' to handle IME/XIM
via external command if vim is not compiled with the |+xim|,
|+multi_byte_ime| or |global-ime|.
*'imsearch'* *'ims'*
'imsearch' 'ims' number (default -1)
local to buffer
@@ -4372,8 +4371,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'imstatusfunc' 'imsf' string (default "")
global
{not in Vi}
{only available when compiled with |+xim| and
|+GUI_GTK|}
{only available when compiled with |+mbyte|}
This option specifies a function that is called to obtain the status
of Input Method. It must return a positive number when IME is active.

View File

@@ -2190,6 +2190,7 @@ test_arglist \
test_highlight \
test_history \
test_hlsearch \
test_iminsert \
test_increment \
test_increment_dbcs \
test_ins_complete \

View File

@@ -13449,8 +13449,10 @@ f_writefile(typval_T *argvars, typval_T *rettv)
if (write_list(fd, list, binary) == FAIL)
ret = -1;
#ifdef HAVE_FSYNC
else if (do_fsync && fsync(fileno(fd)) != 0)
EMSG(_(e_fsync));
else if (do_fsync)
/* Ignore the error, the user wouldn't know what to do about it.
* May happen for a device. */
ignored = fsync(fileno(fd));
#endif
fclose(fd);
}

View File

@@ -4782,6 +4782,20 @@ iconv_end(void)
#endif /* FEAT_MBYTE */
#ifdef FEAT_EVAL
static void
call_imactivatefunc(int active)
{
char_u *argv[1];
if (active)
argv[0] = (char_u *)"1";
else
argv[0] = (char_u *)"0";
(void)call_func_retnr(p_imaf, 1, argv, FALSE);
}
#endif
#if defined(FEAT_XIM) || defined(PROTO)
# if defined(FEAT_GUI_GTK) || defined(PROTO)
@@ -4824,7 +4838,14 @@ im_set_active(int active)
im_is_active = (active && !p_imdisable);
if (im_is_active != was_active)
xim_reset();
{
#ifdef FEAT_EVAL
if (p_imaf[0] != NUL)
call_imactivatefunc(im_is_active);
else
#endif
xim_reset();
}
}
void
@@ -5666,15 +5687,7 @@ xim_reset(void)
# ifdef FEAT_EVAL
if (p_imaf[0] != NUL)
{
char_u *argv[1];
if (im_is_active)
argv[0] = (char_u *)"1";
else
argv[0] = (char_u *)"0";
(void)call_func_retnr(p_imaf, 1, argv, FALSE);
}
call_imactivatefunc(im_is_active);
else
# endif
if (im_activatekey_keyval != GDK_VoidSymbol)
@@ -6442,6 +6455,45 @@ xim_get_status_area_height(void)
}
# endif
#else /* !defined(FEAT_XIM) */
# ifndef FEAT_GUI_W32
int
im_get_status()
{
# ifdef FEAT_EVAL
if (p_imsf[0] != NUL)
{
int is_active;
/* FIXME: Don't execute user function in unsafe situation. */
if (exiting
# ifdef FEAT_AUTOCMD
|| is_autocmd_blocked()
# endif
)
return FALSE;
/* FIXME: :py print 'xxx' is shown duplicate result.
* Use silent to avoid it. */
++msg_silent;
is_active = call_func_retnr(p_imsf, 0, NULL, FALSE);
--msg_silent;
return (is_active > 0);
}
# endif
return FALSE;
}
void
im_set_active(int active)
{
# ifdef(USE_IM_CONTROL) && defined(FEAT_EVAL)
if (p_imaf[0] != NUL)
call_imactivatefunc(p_imdisable ? FALSE : active);
# endif
}
# endif
#endif /* FEAT_XIM */
#if defined(FEAT_MBYTE) || defined(PROTO)

View File

@@ -1539,7 +1539,7 @@ static struct vimoption options[] =
(char_u *)&p_ic, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
#if defined(FEAT_EVAL) && defined(USE_IM_CONTROL)
(char_u *)&p_imaf, PV_NONE,
{(char_u *)"", (char_u *)NULL}
# else
@@ -1582,7 +1582,7 @@ static struct vimoption options[] =
{(char_u *)B_IMODE_USE_INSERT, (char_u *)0L}
SCRIPTID_INIT},
{"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
#if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
#if defined(FEAT_EVAL) && defined(USE_IM_CONTROL)
(char_u *)&p_imsf, PV_NONE,
{(char_u *)"", (char_u *)NULL}
#else

View File

@@ -581,11 +581,13 @@ EXTERN char_u *p_iconstring; /* 'iconstring' */
EXTERN int p_ic; /* 'ignorecase' */
#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
EXTERN char_u *p_imak; /* 'imactivatekey' */
#define IM_ON_THE_SPOT 0L
#define IM_OVER_THE_SPOT 1L
EXTERN long p_imst; /* 'imstyle' */
#endif
#if defined(FEAT_EVAL) && defined(USE_IM_CONTROL)
EXTERN char_u *p_imaf; /* 'imactivatefunc' */
EXTERN char_u *p_imsf; /* 'imstatusfunc' */
EXTERN long p_imst; /* 'imstyle' */
# define IM_ON_THE_SPOT 0L
# define IM_OVER_THE_SPOT 1L
#endif
#ifdef USE_IM_CONTROL
EXTERN int p_imcmdline; /* 'imcmdline' */

View File

@@ -2654,6 +2654,9 @@ qf_list(exarg_T *eap)
int idx2 = -1;
char_u *arg = eap->arg;
int plus = FALSE;
int qfFileAttr;
int qfSepAttr;
int qfLineAttr;
int all = eap->forceit; /* if not :cl!, only show
recognised errors */
qf_info_T *qi = &ql_info;
@@ -2699,6 +2702,20 @@ qf_list(exarg_T *eap)
idx2 = (-idx2 > i) ? 0 : idx2 + i + 1;
}
/*
* Get the attributes for the different quickfix highlight items. Note
* that this depends on syntax items defined in the qf.vim syntax file
*/
qfFileAttr = syn_name2attr((char_u *)"qfFileName");
if (qfFileAttr == 0)
qfFileAttr = HL_ATTR(HLF_D);
qfSepAttr = syn_name2attr((char_u *)"qfSeparator");
if (qfSepAttr == 0)
qfSepAttr = HL_ATTR(HLF_D);
qfLineAttr = syn_name2attr((char_u *)"qfLineNr");
if (qfLineAttr == 0)
qfLineAttr = HL_ATTR(HLF_N);
if (qi->qf_lists[qi->qf_curlist].qf_nonevalid)
all = TRUE;
qfp = qi->qf_lists[qi->qf_curlist].qf_start;
@@ -2724,22 +2741,26 @@ qf_list(exarg_T *eap)
vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
i, (char *)fname);
msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
? HL_ATTR(HLF_QFL) : HL_ATTR(HLF_D));
? HL_ATTR(HLF_QFL) : qfFileAttr);
if (qfp->qf_lnum != 0)
msg_puts_attr((char_u *)":", qfSepAttr);
if (qfp->qf_lnum == 0)
IObuff[0] = NUL;
else if (qfp->qf_col == 0)
sprintf((char *)IObuff, ":%ld", qfp->qf_lnum);
sprintf((char *)IObuff, "%ld", qfp->qf_lnum);
else
sprintf((char *)IObuff, ":%ld col %d",
sprintf((char *)IObuff, "%ld col %d",
qfp->qf_lnum, qfp->qf_col);
sprintf((char *)IObuff + STRLEN(IObuff), "%s:",
sprintf((char *)IObuff + STRLEN(IObuff), "%s",
(char *)qf_types(qfp->qf_type, qfp->qf_nr));
msg_puts_attr(IObuff, HL_ATTR(HLF_N));
msg_puts_attr(IObuff, qfLineAttr);
msg_puts_attr((char_u *)":", qfSepAttr);
if (qfp->qf_pattern != NULL)
{
qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE);
STRCAT(IObuff, ":");
msg_puts(IObuff);
msg_puts_attr((char_u *)":", qfSepAttr);
}
msg_puts((char_u *)" ");

View File

@@ -2091,12 +2091,8 @@ struct file_buffer
#define B_IMODE_USE_INSERT -1 /* Use b_p_iminsert value for search */
#define B_IMODE_NONE 0 /* Input via none */
#define B_IMODE_LMAP 1 /* Input via langmap */
#ifndef USE_IM_CONTROL
# define B_IMODE_LAST 1
#else
# define B_IMODE_IM 2 /* Input via input method */
# define B_IMODE_LAST 2
#endif
#define B_IMODE_IM 2 /* Input via input method */
#define B_IMODE_LAST 2
#ifdef FEAT_KEYMAP
short b_kmap_state; /* using "lmap" mappings */

View File

@@ -79,7 +79,6 @@ NEW_TESTS = test_arabic.res \
test_cdo.res \
test_channel.res \
test_charsearch.res \
test_charsearch_utf8.res \
test_cindent.res \
test_clientserver.res \
test_close_count.res \
@@ -98,7 +97,6 @@ NEW_TESTS = test_arabic.res \
test_exec_while_if.res \
test_exists.res \
test_exists_autocmd.res \
test_expr_utf8.res \
test_farsi.res \
test_file_size.res \
test_find_complete.res \
@@ -117,6 +115,7 @@ NEW_TESTS = test_arabic.res \
test_highlight.res \
test_history.res \
test_hlsearch.res \
test_iminsert.res \
test_increment.res \
test_increment_dbcs.res \
test_ins_complete.res \
@@ -128,16 +127,13 @@ NEW_TESTS = test_arabic.res \
test_listchars.res \
test_listdict.res \
test_listlbr.res \
test_listlbr_utf8.res \
test_lua.res \
test_makeencoding.res \
test_man.res \
test_maparg.res \
test_marks.res \
test_matchadd_conceal.res \
test_matchadd_conceal_utf8.res \
test_mksession.res \
test_mksession_utf8.res \
test_nested_function.res \
test_netbeans.res \
test_normal.res \
@@ -156,8 +152,6 @@ NEW_TESTS = test_arabic.res \
test_quickfix.res \
test_quotestar.res \
test_regex_char_classes.res \
test_regexp_latin.res \
test_regexp_utf8.res \
test_registers.res \
test_retab.res \
test_ruby.res \
@@ -165,10 +159,8 @@ NEW_TESTS = test_arabic.res \
test_search.res \
test_signs.res \
test_smartindent.res \
test_source_utf8.res \
test_spell.res \
test_startup.res \
test_startup_utf8.res \
test_stat.res \
test_substitute.res \
test_swap.res \
@@ -183,8 +175,6 @@ NEW_TESTS = test_arabic.res \
test_undo.res \
test_user_func.res \
test_usercommands.res \
test_utf8.res \
test_utf8_comparisons.res \
test_viminfo.res \
test_vimscript.res \
test_visual.res \

View File

@@ -7,8 +7,11 @@
source test_charsearch_utf8.vim
source test_expr_utf8.vim
source test_listlbr_utf8.vim
source test_matchadd_conceal_utf8.vim
source test_mksession_utf8.vim
source test_regexp_utf8.vim
source test_source_utf8.vim
source test_startup_utf8.vim
source test_utf8.vim
source test_utf8_comparisons.vim

View File

@@ -0,0 +1,29 @@
if !has('multi_byte')
finish
endif
source view_util.vim
let s:imactivatefunc_called = 0
let s:imstatusfunc_called = 0
func IM_activatefunc(active)
let s:imactivatefunc_called = 1
endfunc
func IM_statusfunc()
let s:imstatusfunc_called = 1
return 0
endfunc
func Test_iminsert2()
set imactivatefunc=IM_activatefunc
set imstatusfunc=IM_statusfunc
set iminsert=2
normal! i
set iminsert=0
set imactivatefunc=
set imstatusfunc=
call assert_equal(1, s:imactivatefunc_called)
call assert_equal(1, s:imstatusfunc_called)
endfunc

View File

@@ -99,6 +99,7 @@ func Test_mksession_utf8()
call delete('test_mks.out')
call delete(tmpfile)
let &wrap = wrap_save
set sessionoptions& splitbelow& fileencoding&
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -771,6 +771,16 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1336,
/**/
1335,
/**/
1334,
/**/
1333,
/**/
1332,
/**/
1331,
/**/

View File

@@ -536,9 +536,7 @@ typedef unsigned long u8char_T; /* long should be 32 bits or more */
/*
* Check input method control.
*/
#if defined(FEAT_XIM) \
|| (defined(FEAT_GUI) && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \
|| (defined(FEAT_GUI_MAC) && defined(FEAT_MBYTE))
#if defined(FEAT_MBYTE)
# define USE_IM_CONTROL
#endif
@@ -1485,6 +1483,11 @@ typedef UINT32_TYPEDEF UINT32_T;
#define MIN_COLUMNS 12 /* minimal columns for screen */
#define MIN_LINES 2 /* minimal lines for screen */
#define STATUS_HEIGHT 1 /* height of a status line under a window */
#ifdef FEAT_MENU /* height of a status line under a window */
# define WINBAR_HEIGHT(wp) (wp)->w_winbar_height
#else
# define WINBAR_HEIGHT(wp) 0
#endif
#define QF_WINHEIGHT 10 /* default height for quickfix window */
/*

View File

@@ -1098,21 +1098,14 @@ win_split_ins(
/* set height and row of new window to full height */
wp->w_winrow = tabline_height();
win_new_height(wp, curfrp->fr_height - (p_ls > 0)
#ifdef FEAT_MENU
- wp->w_winbar_height
#endif
);
- WINBAR_HEIGHT(wp));
wp->w_status_height = (p_ls > 0);
}
else
{
/* height and row of new window is same as current window */
wp->w_winrow = oldwin->w_winrow;
win_new_height(wp, oldwin->w_height
#ifdef FEAT_MENU
+ oldwin->w_winbar_height
#endif
);
win_new_height(wp, oldwin->w_height + WINBAR_HEIGHT(oldwin));
wp->w_status_height = oldwin->w_status_height;
}
frp->fr_height = curfrp->fr_height;
@@ -1171,10 +1164,7 @@ win_split_ins(
if (flags & (WSP_TOP | WSP_BOT))
{
int new_fr_height = curfrp->fr_height - new_size
#ifdef FEAT_MENU
+ wp->w_winbar_height
#endif
;
+ WINBAR_HEIGHT(wp) ;
if (!((flags & WSP_BOT) && p_ls == 0))
new_fr_height -= STATUS_HEIGHT;
@@ -1190,7 +1180,8 @@ win_split_ins(
}
else /* new window below current one */
{
wp->w_winrow = oldwin->w_winrow + oldwin->w_height + STATUS_HEIGHT;
wp->w_winrow = oldwin->w_winrow + oldwin->w_height
+ STATUS_HEIGHT + WINBAR_HEIGHT(oldwin);
wp->w_status_height = oldwin->w_status_height;
if (!(flags & WSP_BOT))
oldwin->w_status_height = STATUS_HEIGHT;
@@ -2867,10 +2858,7 @@ frame_new_height(
/* Simple case: just one window. */
win_new_height(topfrp->fr_win,
height - topfrp->fr_win->w_status_height
#ifdef FEAT_MENU
- topfrp->fr_win->w_winbar_height
#endif
);
- WINBAR_HEIGHT(topfrp->fr_win));
}
else if (topfrp->fr_layout == FR_ROW)
{
@@ -3217,10 +3205,7 @@ frame_fix_width(win_T *wp)
frame_fix_height(win_T *wp)
{
wp->w_frame->fr_height = wp->w_height + wp->w_status_height
#ifdef FEAT_MENU
+ wp->w_winbar_height
#endif
;
+ WINBAR_HEIGHT(wp) ;
}
/*