mirror of
https://github.com/zoriya/vim.git
synced 2025-12-19 21:55:18 +00:00
patch 8.1.0806: too many #ifdefs
Problem: Too many #ifdefs. Solution: Graduate FEAT_MBYTE, part 2.
This commit is contained in:
@@ -1266,7 +1266,6 @@ getvcol(
|
||||
#endif
|
||||
)
|
||||
{
|
||||
head = 0;
|
||||
for (;;)
|
||||
{
|
||||
head = 0;
|
||||
|
||||
@@ -5421,7 +5421,6 @@ get_mess_lang(void)
|
||||
#if (defined(FEAT_EVAL) && !((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
|
||||
&& defined(LC_MESSAGES))) \
|
||||
|| ((defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
|
||||
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE)) \
|
||||
&& !defined(LC_MESSAGES))
|
||||
/*
|
||||
* Get the language used for messages from the environment.
|
||||
@@ -5485,8 +5484,7 @@ set_lang_var(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
|
||||
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
|
||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE) \
|
||||
/*
|
||||
* ":language": Set the language (locale).
|
||||
*/
|
||||
|
||||
@@ -4300,8 +4300,7 @@ set_one_cmd_context(
|
||||
xp->xp_pattern = arg;
|
||||
break;
|
||||
|
||||
#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
|
||||
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
|
||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||
case CMD_language:
|
||||
p = skiptowhite(arg);
|
||||
if (*p == NUL)
|
||||
@@ -5963,8 +5962,7 @@ static struct
|
||||
#if defined(FEAT_CMDHIST)
|
||||
{EXPAND_HISTORY, "history"},
|
||||
#endif
|
||||
#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
|
||||
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
|
||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||
{EXPAND_LOCALES, "locale"},
|
||||
#endif
|
||||
{EXPAND_MAPCLEAR, "mapclear"},
|
||||
|
||||
@@ -5253,8 +5253,7 @@ ExpandFromContext(
|
||||
#ifdef FEAT_PROFILE
|
||||
{EXPAND_PROFILE, get_profile_name, TRUE, TRUE},
|
||||
#endif
|
||||
#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
|
||||
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
|
||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||
{EXPAND_LANGUAGE, get_lang_arg, TRUE, FALSE},
|
||||
{EXPAND_LOCALES, get_locales, TRUE, FALSE},
|
||||
#endif
|
||||
|
||||
236
src/gui_w32.c
236
src/gui_w32.c
@@ -30,9 +30,6 @@
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_DIRECTX)
|
||||
# ifndef FEAT_MBYTE
|
||||
# error FEAT_MBYTE is required for FEAT_DIRECTX.
|
||||
# endif
|
||||
static DWriteContext *s_dwc = NULL;
|
||||
static int s_directx_enabled = 0;
|
||||
static int s_directx_load_attempted = 0;
|
||||
@@ -318,9 +315,7 @@ static int destroying = FALSE; /* call DestroyWindow() ourselves */
|
||||
#ifdef MSWIN_FIND_REPLACE
|
||||
static UINT s_findrep_msg = 0; /* set in gui_w[16/32].c */
|
||||
static FINDREPLACE s_findrep_struct;
|
||||
# ifdef FEAT_MBYTE
|
||||
static FINDREPLACEW s_findrep_struct_w;
|
||||
# endif
|
||||
static HWND s_findrep_hwnd = NULL;
|
||||
static int s_findrep_is_find; /* TRUE for find dialog, FALSE
|
||||
for find/replace dialog */
|
||||
@@ -396,13 +391,8 @@ directx_binddc(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(GLOBAL_IME)
|
||||
/* use of WindowProc depends on wide_WindowProc */
|
||||
#define MyWindowProc vim_WindowProc
|
||||
#else
|
||||
/* use ordinary WindowProc */
|
||||
# define MyWindowProc DefWindowProc
|
||||
#endif
|
||||
|
||||
extern int current_font_height; /* this is in os_mswin.c */
|
||||
|
||||
@@ -724,7 +714,6 @@ char_to_string(int ch, char_u *string, int slen, int had_alt)
|
||||
{
|
||||
int len;
|
||||
int i;
|
||||
#ifdef FEAT_MBYTE
|
||||
WCHAR wstring[2];
|
||||
char_u *ws = NULL;
|
||||
|
||||
@@ -785,7 +774,6 @@ char_to_string(int ch, char_u *string, int slen, int had_alt)
|
||||
}
|
||||
|
||||
if (len == 0)
|
||||
#endif
|
||||
{
|
||||
string[0] = ch;
|
||||
len = 1;
|
||||
@@ -1118,7 +1106,6 @@ _OnMenu(
|
||||
#endif
|
||||
|
||||
#ifdef MSWIN_FIND_REPLACE
|
||||
# ifdef FEAT_MBYTE
|
||||
/*
|
||||
* copy useful data from structure LPFINDREPLACE to structure LPFINDREPLACEW
|
||||
*/
|
||||
@@ -1155,7 +1142,6 @@ findrep_wtoa(LPFINDREPLACE lpfr, LPFINDREPLACEW lpfrw)
|
||||
vim_strncpy((char_u *)lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
|
||||
vim_free(p);
|
||||
}
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Handle a Find/Replace window message.
|
||||
@@ -1166,14 +1152,12 @@ _OnFindRepl(void)
|
||||
int flags = 0;
|
||||
int down;
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
/* If the OS is Windows NT, and 'encoding' differs from active codepage:
|
||||
* convert text from wide string. */
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
{
|
||||
findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w);
|
||||
}
|
||||
# endif
|
||||
|
||||
if (s_findrep_struct.Flags & FR_DIALOGTERM)
|
||||
/* Give main window the focus back. */
|
||||
@@ -1318,9 +1302,6 @@ _TextAreaWndProc(
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(FEAT_MBYTE) \
|
||||
|| defined(GLOBAL_IME) \
|
||||
|| defined(PROTO)
|
||||
#ifdef PROTO
|
||||
typedef int WINAPI;
|
||||
#endif
|
||||
@@ -1336,7 +1317,6 @@ vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Called when the foreground or background color has been changed.
|
||||
@@ -1751,10 +1731,8 @@ gui_mch_draw_hollow_cursor(guicolor_T color)
|
||||
rc.left = FILL_X(gui.col);
|
||||
rc.top = FILL_Y(gui.row);
|
||||
rc.right = rc.left + gui.char_width;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (mb_lefthalve(gui.row, gui.col))
|
||||
rc.right += gui.char_width;
|
||||
#endif
|
||||
rc.bottom = rc.top + gui.char_height;
|
||||
hbr = CreateSolidBrush(color);
|
||||
FrameRect(s_hdc, &rc, hbr);
|
||||
@@ -2345,7 +2323,6 @@ GetTextWidth(HDC hdc, char_u *str, int len)
|
||||
return size.cx;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Return the width in pixels of the given text in the given DC, taking care
|
||||
* of 'encoding' to active codepage conversion.
|
||||
@@ -2374,9 +2351,6 @@ GetTextWidthEnc(HDC hdc, char_u *str, int len)
|
||||
|
||||
return GetTextWidth(hdc, str, len);
|
||||
}
|
||||
#else
|
||||
# define GetTextWidthEnc(h, s, l) GetTextWidth((h), (s), (l))
|
||||
#endif
|
||||
|
||||
static void get_work_area(RECT *spi_rect);
|
||||
|
||||
@@ -2451,7 +2425,6 @@ gui_mch_show_toolbar(int showit)
|
||||
|
||||
if (showit)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
# ifndef TB_SETUNICODEFORMAT
|
||||
/* For older compilers. We assume this never changes. */
|
||||
# define TB_SETUNICODEFORMAT 0x2005
|
||||
@@ -2459,7 +2432,6 @@ gui_mch_show_toolbar(int showit)
|
||||
/* Enable/disable unicode support */
|
||||
int uu = (enc_codepage >= 0 && (int)GetACP() != enc_codepage);
|
||||
SendMessage(s_toolbarhwnd, TB_SETUNICODEFORMAT, (WPARAM)uu, (LPARAM)0);
|
||||
# endif
|
||||
ShowWindow(s_toolbarhwnd, SW_SHOW);
|
||||
}
|
||||
else
|
||||
@@ -2475,7 +2447,6 @@ gui_mch_show_toolbar(int showit)
|
||||
static void
|
||||
add_tabline_popup_menu_entry(HMENU pmenu, UINT item_id, char_u *item_text)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
WCHAR *wn = NULL;
|
||||
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
@@ -2499,7 +2470,6 @@ add_tabline_popup_menu_entry(HMENU pmenu, UINT item_id, char_u *item_text)
|
||||
}
|
||||
|
||||
if (wn == NULL)
|
||||
#endif
|
||||
{
|
||||
MENUITEMINFO info;
|
||||
|
||||
@@ -2606,16 +2576,13 @@ gui_mch_update_tabline(void)
|
||||
int nr = 0;
|
||||
int curtabidx = 0;
|
||||
int tabadded = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
static int use_unicode = FALSE;
|
||||
int uu;
|
||||
WCHAR *wstr = NULL;
|
||||
#endif
|
||||
|
||||
if (s_tabhwnd == NULL)
|
||||
return;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
#ifndef CCM_SETUNICODEFORMAT
|
||||
/* For older compilers. We assume this never changes. */
|
||||
# define CCM_SETUNICODEFORMAT 0x2005
|
||||
@@ -2627,7 +2594,6 @@ gui_mch_update_tabline(void)
|
||||
SendMessage(s_tabhwnd, CCM_SETUNICODEFORMAT, (WPARAM)uu, (LPARAM)0);
|
||||
use_unicode = uu;
|
||||
}
|
||||
#endif
|
||||
|
||||
tie.mask = TCIF_TEXT;
|
||||
tie.iImage = -1;
|
||||
@@ -2651,7 +2617,6 @@ gui_mch_update_tabline(void)
|
||||
|
||||
get_tabline_label(tp, FALSE);
|
||||
tie.pszText = (LPSTR)NameBuff;
|
||||
#ifdef FEAT_MBYTE
|
||||
wstr = NULL;
|
||||
if (use_unicode)
|
||||
{
|
||||
@@ -2669,7 +2634,6 @@ gui_mch_update_tabline(void)
|
||||
}
|
||||
}
|
||||
if (wstr == NULL)
|
||||
#endif
|
||||
{
|
||||
TabCtrl_SetItem(s_tabhwnd, nr, &tie);
|
||||
}
|
||||
@@ -2770,7 +2734,6 @@ initialise_findrep(char_u *initial_string)
|
||||
static void
|
||||
set_window_title(HWND hwnd, char *title)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP())
|
||||
{
|
||||
WCHAR *wbuf;
|
||||
@@ -2784,7 +2747,6 @@ set_window_title(HWND hwnd, char *title)
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
(void)SetWindowText(hwnd, (LPCSTR)title);
|
||||
}
|
||||
|
||||
@@ -2800,7 +2762,6 @@ gui_mch_find_dialog(exarg_T *eap)
|
||||
if (!IsWindow(s_findrep_hwnd))
|
||||
{
|
||||
initialise_findrep(eap->arg);
|
||||
# ifdef FEAT_MBYTE
|
||||
/* If the OS is Windows NT, and 'encoding' differs from active
|
||||
* codepage: convert text and use wide function. */
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
@@ -2810,7 +2771,6 @@ gui_mch_find_dialog(exarg_T *eap)
|
||||
(LPFINDREPLACEW) &s_findrep_struct_w);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
|
||||
}
|
||||
|
||||
@@ -2835,7 +2795,6 @@ gui_mch_replace_dialog(exarg_T *eap)
|
||||
if (!IsWindow(s_findrep_hwnd))
|
||||
{
|
||||
initialise_findrep(eap->arg);
|
||||
# ifdef FEAT_MBYTE
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
{
|
||||
findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
|
||||
@@ -2843,7 +2802,6 @@ gui_mch_replace_dialog(exarg_T *eap)
|
||||
(LPFINDREPLACEW) &s_findrep_struct_w);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
s_findrep_hwnd = ReplaceText(
|
||||
(LPFINDREPLACE) &s_findrep_struct);
|
||||
}
|
||||
@@ -2931,7 +2889,6 @@ _OnPaint(
|
||||
out_flush(); /* make sure all output has been processed */
|
||||
(void)BeginPaint(hwnd, &ps);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* prevent multi-byte characters from misprinting on an invalid
|
||||
* rectangle */
|
||||
if (has_mbyte)
|
||||
@@ -2942,7 +2899,6 @@ _OnPaint(
|
||||
ps.rcPaint.left = rect.left;
|
||||
ps.rcPaint.right = rect.right;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!IsRectEmpty(&ps.rcPaint))
|
||||
{
|
||||
@@ -3255,7 +3211,6 @@ logfont2name(LOGFONT lf)
|
||||
char *font_name = lf.lfFaceName;
|
||||
|
||||
charset_name = charset_id2name((int)lf.lfCharSet);
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Convert a font name from the current codepage to 'encoding'.
|
||||
* TODO: Use Wide APIs (including LOGFONTW) instead of ANSI APIs. */
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
@@ -3264,7 +3219,6 @@ logfont2name(LOGFONT lf)
|
||||
acp_to_enc((char_u *)lf.lfFaceName, (int)strlen(lf.lfFaceName),
|
||||
(char_u **)&font_name, &len);
|
||||
}
|
||||
#endif
|
||||
quality_name = quality_id2name((int)lf.lfQuality);
|
||||
|
||||
res = (char *)alloc((unsigned)(strlen(font_name) + 20
|
||||
@@ -3301,10 +3255,8 @@ logfont2name(LOGFONT lf)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (font_name != lf.lfFaceName)
|
||||
vim_free(font_name);
|
||||
#endif
|
||||
return (char_u *)res;
|
||||
}
|
||||
|
||||
@@ -3329,7 +3281,6 @@ update_im_font(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Handler of gui.wide_font (p_guifontwide) changed notification.
|
||||
*/
|
||||
@@ -3370,7 +3321,6 @@ gui_mch_wide_font_changed(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialise vim to use the font with the given name.
|
||||
@@ -3573,13 +3523,6 @@ mch_set_mouse_shape(int shape)
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_BROWSE) || defined(PROTO)
|
||||
/*
|
||||
* The file browser exists in two versions: with "W" uses wide characters,
|
||||
* without "W" the current codepage. When FEAT_MBYTE is defined and on
|
||||
* Windows NT/2000/XP the "W" functions are used.
|
||||
*/
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Wide version of convert_filter().
|
||||
*/
|
||||
@@ -3600,10 +3543,17 @@ convert_filterW(char_u *s)
|
||||
}
|
||||
|
||||
/*
|
||||
* Wide version of gui_mch_browse(). Keep in sync!
|
||||
* Pop open a file browser and return the file selected, in allocated memory,
|
||||
* or NULL if Cancel is hit.
|
||||
* saving - TRUE if the file will be saved to, FALSE if it will be opened.
|
||||
* title - Title message for the file browser dialog.
|
||||
* dflt - Default name of file.
|
||||
* ext - Default extension to be added to files without extensions.
|
||||
* initdir - directory in which to open the browser (NULL = current dir)
|
||||
* filter - Filter for matched files to choose from.
|
||||
*/
|
||||
static char_u *
|
||||
gui_mch_browseW(
|
||||
gui_mch_browse(
|
||||
int saving,
|
||||
char_u *title,
|
||||
char_u *dflt,
|
||||
@@ -3718,7 +3668,6 @@ gui_mch_browseW(
|
||||
vim_free(p);
|
||||
return q;
|
||||
}
|
||||
# endif /* FEAT_MBYTE */
|
||||
|
||||
|
||||
/*
|
||||
@@ -3762,106 +3711,6 @@ gui_mch_browsedir(char_u *title, char_u *initdir)
|
||||
return gui_mch_browse(0, title, (char_u *)_("Not Used"), NULL,
|
||||
initdir, (char_u *)_("Directory\t*.nothing\n"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Pop open a file browser and return the file selected, in allocated memory,
|
||||
* or NULL if Cancel is hit.
|
||||
* saving - TRUE if the file will be saved to, FALSE if it will be opened.
|
||||
* title - Title message for the file browser dialog.
|
||||
* dflt - Default name of file.
|
||||
* ext - Default extension to be added to files without extensions.
|
||||
* initdir - directory in which to open the browser (NULL = current dir)
|
||||
* filter - Filter for matched files to choose from.
|
||||
*
|
||||
* Keep in sync with gui_mch_browseW() above!
|
||||
*/
|
||||
char_u *
|
||||
gui_mch_browse(
|
||||
int saving,
|
||||
char_u *title,
|
||||
char_u *dflt,
|
||||
char_u *ext,
|
||||
char_u *initdir,
|
||||
char_u *filter)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
return gui_mch_browseW(saving, title, dflt, ext, initdir, filter);
|
||||
# else
|
||||
OPENFILENAME fileStruct;
|
||||
char_u fileBuf[MAXPATHL];
|
||||
char_u *initdirp = NULL;
|
||||
char_u *filterp;
|
||||
char_u *p;
|
||||
|
||||
if (dflt == NULL)
|
||||
fileBuf[0] = NUL;
|
||||
else
|
||||
vim_strncpy(fileBuf, dflt, MAXPATHL - 1);
|
||||
|
||||
/* Convert the filter to Windows format. */
|
||||
filterp = convert_filter(filter);
|
||||
|
||||
vim_memset(&fileStruct, 0, sizeof(OPENFILENAME));
|
||||
# ifdef OPENFILENAME_SIZE_VERSION_400
|
||||
/* be compatible with Windows NT 4.0 */
|
||||
fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400;
|
||||
# else
|
||||
fileStruct.lStructSize = sizeof(fileStruct);
|
||||
# endif
|
||||
|
||||
fileStruct.lpstrTitle = (LPSTR)title;
|
||||
fileStruct.lpstrDefExt = (LPSTR)ext;
|
||||
|
||||
fileStruct.lpstrFile = (LPSTR)fileBuf;
|
||||
fileStruct.nMaxFile = MAXPATHL;
|
||||
fileStruct.lpstrFilter = (LPSTR)filterp;
|
||||
fileStruct.hwndOwner = s_hwnd; /* main Vim window is owner*/
|
||||
/* has an initial dir been specified? */
|
||||
if (initdir != NULL && *initdir != NUL)
|
||||
{
|
||||
/* Must have backslashes here, no matter what 'shellslash' says */
|
||||
initdirp = vim_strsave(initdir);
|
||||
if (initdirp != NULL)
|
||||
for (p = initdirp; *p != NUL; ++p)
|
||||
if (*p == '/')
|
||||
*p = '\\';
|
||||
fileStruct.lpstrInitialDir = (LPSTR)initdirp;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Allow selection of multiple files. Needs another arg to this
|
||||
* function to ask for it, and need to use OFN_ALLOWMULTISELECT below.
|
||||
* Also, should we use OFN_FILEMUSTEXIST when opening? Vim can edit on
|
||||
* files that don't exist yet, so I haven't put it in. What about
|
||||
* OFN_PATHMUSTEXIST?
|
||||
* Don't use OFN_OVERWRITEPROMPT, Vim has its own ":confirm" dialog.
|
||||
*/
|
||||
fileStruct.Flags = (OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY);
|
||||
# ifdef FEAT_SHORTCUT
|
||||
if (curbuf->b_p_bin)
|
||||
fileStruct.Flags |= OFN_NODEREFERENCELINKS;
|
||||
# endif
|
||||
if (saving)
|
||||
{
|
||||
if (!GetSaveFileName(&fileStruct))
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GetOpenFileName(&fileStruct))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vim_free(filterp);
|
||||
vim_free(initdirp);
|
||||
|
||||
/* Give focus back to main window (when using MDI). */
|
||||
SetFocus(s_hwnd);
|
||||
|
||||
/* Shorten the file name if possible */
|
||||
return vim_strsave(shorten_fname1((char_u *)fileBuf));
|
||||
# endif
|
||||
}
|
||||
#endif /* FEAT_BROWSE */
|
||||
|
||||
static void
|
||||
@@ -3871,9 +3720,7 @@ _OnDropFiles(
|
||||
{
|
||||
#define BUFPATHLEN _MAX_PATH
|
||||
#define DRAGQVAL 0xFFFFFFFF
|
||||
#ifdef FEAT_MBYTE
|
||||
WCHAR wszFile[BUFPATHLEN];
|
||||
#endif
|
||||
char szFile[BUFPATHLEN];
|
||||
UINT cFiles = DragQueryFile(hDrop, DRAGQVAL, NULL, 0);
|
||||
UINT i;
|
||||
@@ -3894,11 +3741,9 @@ _OnDropFiles(
|
||||
if (fnames != NULL)
|
||||
for (i = 0; i < cFiles; ++i)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
|
||||
fnames[i] = utf16_to_enc(wszFile, NULL);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
DragQueryFile(hDrop, i, szFile, BUFPATHLEN);
|
||||
fnames[i] = vim_strsave((char_u *)szFile);
|
||||
@@ -4060,13 +3905,11 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
|
||||
|
||||
*tofree = NULL;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Try using the Unicode version first, it takes care of conversion when
|
||||
* 'encoding' is changed. */
|
||||
argc = get_cmd_argsW(&argv);
|
||||
if (argc != 0)
|
||||
goto done;
|
||||
#endif
|
||||
|
||||
/* Handle the program name. Remove the ".exe" extension, and find the 1st
|
||||
* non-space. */
|
||||
@@ -4145,7 +3988,6 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
|
||||
{
|
||||
if (pnew != NULL)
|
||||
*pnew++ = *p;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Can't use mb_* functions, because 'encoding' is not
|
||||
* initialized yet here. */
|
||||
if (IsDBCSLeadByte(*p))
|
||||
@@ -4154,7 +3996,6 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
|
||||
if (pnew != NULL)
|
||||
*pnew++ = *p;
|
||||
}
|
||||
#endif
|
||||
++p;
|
||||
}
|
||||
}
|
||||
@@ -4178,9 +4019,7 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
done:
|
||||
#endif
|
||||
argv[argc] = NULL; /* NULL-terminated list */
|
||||
*argvp = argv;
|
||||
return argc;
|
||||
@@ -4381,7 +4220,6 @@ typedef struct tagNMTTDISPINFO_NEW
|
||||
LPARAM lParam;
|
||||
} NMTTDISPINFO_NEW;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
typedef struct tagTOOLINFOW_NEW
|
||||
{
|
||||
UINT cbSize;
|
||||
@@ -4405,7 +4243,6 @@ typedef struct tagNMTTDISPINFOW_NEW
|
||||
LPARAM lParam;
|
||||
} NMTTDISPINFOW_NEW;
|
||||
|
||||
#endif
|
||||
|
||||
typedef HRESULT (WINAPI* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
|
||||
#ifndef TTM_SETMAXTIPWIDTH
|
||||
@@ -4438,7 +4275,6 @@ typedef struct tagNMTTDISPINFOA {
|
||||
} NMTTDISPINFOA, *LPNMTTDISPINFOA;
|
||||
# define LPNMTTDISPINFO LPNMTTDISPINFOA
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
typedef struct tagNMTTDISPINFOW {
|
||||
NMHDR hdr;
|
||||
LPWSTR lpszText;
|
||||
@@ -4449,7 +4285,6 @@ typedef struct tagNMTTDISPINFOW {
|
||||
} NMTTDISPINFOW, *LPNMTTDISPINFOW;
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef TTN_GETDISPINFOW
|
||||
# define TTN_GETDISPINFOW (TTN_FIRST - 10)
|
||||
@@ -4970,9 +4805,7 @@ _WndProc(
|
||||
case WM_NOTIFY:
|
||||
switch (((LPNMHDR) lParam)->code)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
case TTN_GETDISPINFOW:
|
||||
# endif
|
||||
case TTN_GETDISPINFO:
|
||||
{
|
||||
LPNMHDR hdr = (LPNMHDR)lParam;
|
||||
@@ -5034,7 +4867,6 @@ _WndProc(
|
||||
# endif
|
||||
if (str != NULL)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
if (hdr->code == TTN_GETDISPINFOW)
|
||||
{
|
||||
LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
|
||||
@@ -5049,7 +4881,6 @@ _WndProc(
|
||||
/* can't show tooltip if failed */
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
LPNMTTDISPINFO lpdi = (LPNMTTDISPINFO)lParam;
|
||||
|
||||
@@ -5353,11 +5184,9 @@ gui_mch_init(void)
|
||||
const char szVimWndClass[] = VIM_CLASS;
|
||||
const char szTextAreaClass[] = "VimTextArea";
|
||||
WNDCLASS wndclass;
|
||||
#ifdef FEAT_MBYTE
|
||||
const WCHAR szVimWndClassW[] = VIM_CLASSW;
|
||||
const WCHAR szTextAreaClassW[] = L"VimTextArea";
|
||||
WNDCLASSW wndclassw;
|
||||
#endif
|
||||
#ifdef GLOBAL_IME
|
||||
ATOM atom;
|
||||
#endif
|
||||
@@ -5383,7 +5212,6 @@ gui_mch_init(void)
|
||||
|
||||
s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* First try using the wide version, so that we can use any title.
|
||||
* Otherwise only characters in the active codepage will work. */
|
||||
if (GetClassInfoW(s_hinst, szVimWndClassW, &wndclassw) == 0)
|
||||
@@ -5410,8 +5238,6 @@ gui_mch_init(void)
|
||||
}
|
||||
|
||||
if (!wide_WindowProc)
|
||||
#endif
|
||||
|
||||
if (GetClassInfo(s_hinst, szVimWndClass, &wndclass) == 0)
|
||||
{
|
||||
wndclass.style = CS_DBLCLKS;
|
||||
@@ -5503,7 +5329,6 @@ gui_mch_init(void)
|
||||
#endif
|
||||
|
||||
/* Create the text area window */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (wide_WindowProc)
|
||||
{
|
||||
if (GetClassInfoW(s_hinst, szTextAreaClassW, &wndclassw) == 0)
|
||||
@@ -5532,9 +5357,7 @@ gui_mch_init(void)
|
||||
s_hwnd, NULL,
|
||||
s_hinst, NULL);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (GetClassInfo(s_hinst, szTextAreaClass, &wndclass) == 0)
|
||||
else if (GetClassInfo(s_hinst, szTextAreaClass, &wndclass) == 0)
|
||||
{
|
||||
wndclass.style = CS_OWNDC;
|
||||
wndclass.lpfnWndProc = _TextAreaWndProc;
|
||||
@@ -5642,7 +5465,6 @@ gui_mch_init(void)
|
||||
s_findrep_struct.lpstrReplaceWith[0] = NUL;
|
||||
s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
|
||||
s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
|
||||
# ifdef FEAT_MBYTE
|
||||
s_findrep_struct_w.lStructSize = sizeof(s_findrep_struct_w);
|
||||
s_findrep_struct_w.lpstrFindWhat =
|
||||
(LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
|
||||
@@ -5653,7 +5475,6 @@ gui_mch_init(void)
|
||||
s_findrep_struct_w.wFindWhatLen = MSWIN_FR_BUFSIZE;
|
||||
s_findrep_struct_w.wReplaceWithLen = MSWIN_FR_BUFSIZE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
# if !defined(_MSC_VER) || (_MSC_VER < 1400)
|
||||
@@ -6149,7 +5970,7 @@ im_get_status(void)
|
||||
|
||||
#endif /* FEAT_MBYTE_IME */
|
||||
|
||||
#if defined(FEAT_MBYTE) && !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME)
|
||||
#if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME)
|
||||
/* Win32 with GLOBAL IME */
|
||||
|
||||
/*
|
||||
@@ -6186,7 +6007,6 @@ im_get_status(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Convert latin9 text "text[len]" to ucs-2 in "unicodebuf".
|
||||
*/
|
||||
@@ -6212,7 +6032,6 @@ latin9_to_ucs(char_u *text, int len, WCHAR *unicodebuf)
|
||||
*unicodebuf++ = c;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_RIGHTLEFT
|
||||
/*
|
||||
@@ -6319,12 +6138,10 @@ gui_mch_draw_string(
|
||||
int i;
|
||||
const RECT *pcliprect = NULL;
|
||||
UINT foptions = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
static WCHAR *unicodebuf = NULL;
|
||||
static int *unicodepdy = NULL;
|
||||
static int unibuflen = 0;
|
||||
int n = 0;
|
||||
#endif
|
||||
int y;
|
||||
|
||||
/*
|
||||
@@ -6354,14 +6171,12 @@ gui_mch_draw_string(
|
||||
*/
|
||||
rc.left = FILL_X(col);
|
||||
rc.top = FILL_Y(row);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
/* Compute the length in display cells. */
|
||||
rc.right = FILL_X(col + mb_string2cells(text, len));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
rc.right = FILL_X(col + len);
|
||||
rc.bottom = FILL_Y(row + 1);
|
||||
|
||||
@@ -6429,7 +6244,6 @@ gui_mch_draw_string(
|
||||
* No check for DRAW_BOLD, Windows will have done it already.
|
||||
*/
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Check if there are any UTF-8 characters. If not, use normal text
|
||||
* output to speed up output. */
|
||||
if (enc_utf8)
|
||||
@@ -6568,7 +6382,6 @@ gui_mch_draw_string(
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef FEAT_RIGHTLEFT
|
||||
/* Windows will mess up RL text, so we have to draw it character by
|
||||
@@ -6690,7 +6503,6 @@ gui_mch_add_menu(
|
||||
|
||||
if (menu_is_menubar(menu->name))
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
WCHAR *wn = NULL;
|
||||
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
@@ -6719,7 +6531,6 @@ gui_mch_add_menu(
|
||||
}
|
||||
|
||||
if (wn == NULL)
|
||||
#endif
|
||||
{
|
||||
MENUITEMINFO info;
|
||||
|
||||
@@ -6847,7 +6658,6 @@ gui_mch_add_menu_item(
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
WCHAR *wn = NULL;
|
||||
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
@@ -6865,7 +6675,6 @@ gui_mch_add_menu_item(
|
||||
}
|
||||
}
|
||||
if (wn == NULL)
|
||||
#endif
|
||||
InsertMenu(parent->submenu_id, (UINT)idx,
|
||||
(menu_is_separator(menu->name) ? MF_SEPARATOR : MF_STRING)
|
||||
| MF_BYPOSITION,
|
||||
@@ -7059,7 +6868,6 @@ dialog_callback(
|
||||
/* If the edit box exists, copy the string. */
|
||||
if (s_textfield != NULL)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
/* If the OS is Windows NT, and 'encoding' differs from active
|
||||
* codepage: use wide function and convert text. */
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
@@ -7074,7 +6882,6 @@ dialog_callback(
|
||||
vim_free(wp);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
|
||||
(LPSTR)s_textfield, IOSIZE);
|
||||
}
|
||||
@@ -7306,11 +7113,7 @@ gui_mch_dialog(
|
||||
last_white = NULL;
|
||||
for (pend = pstart; *pend != NUL && *pend != '\n'; )
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
l = (*mb_ptr2len)(pend);
|
||||
#else
|
||||
l = 1;
|
||||
#endif
|
||||
if (l == 1 && VIM_ISWHITE(*pend)
|
||||
&& textWidth > maxDialogWidth * 3 / 4)
|
||||
last_white = pend;
|
||||
@@ -7693,7 +7496,6 @@ nCopyAnsiToWideChar(
|
||||
BOOL use_enc)
|
||||
{
|
||||
int nChar = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
int len = lstrlen(lpAnsiIn) + 1; /* include NUL character */
|
||||
int i;
|
||||
WCHAR *wn;
|
||||
@@ -7719,16 +7521,6 @@ nCopyAnsiToWideChar(
|
||||
for (i = 0; i < nChar; ++i)
|
||||
if (lpWCStr[i] == (WORD)'\t') /* replace tabs with spaces */
|
||||
lpWCStr[i] = (WORD)' ';
|
||||
#else
|
||||
do
|
||||
{
|
||||
if (*lpAnsiIn == '\t')
|
||||
*lpWCStr++ = (WORD)' ';
|
||||
else
|
||||
*lpWCStr++ = (WORD)*lpAnsiIn;
|
||||
nChar++;
|
||||
} while (*lpAnsiIn++);
|
||||
#endif
|
||||
|
||||
return nChar;
|
||||
}
|
||||
@@ -8775,7 +8567,6 @@ multiline_balloon_available(void)
|
||||
return multiline_tip;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
static void
|
||||
make_tooltipw(BalloonEval *beval, char *text, POINT pt)
|
||||
{
|
||||
@@ -8845,7 +8636,6 @@ make_tooltipw(BalloonEval *beval, char *text, POINT pt)
|
||||
mouse_event(MOUSEEVENTF_MOVE, (DWORD)-1, (DWORD)-1, 0, 0);
|
||||
vim_free(pti);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
make_tooltip(BalloonEval *beval, char *text, POINT pt)
|
||||
@@ -8853,13 +8643,11 @@ make_tooltip(BalloonEval *beval, char *text, POINT pt)
|
||||
TOOLINFO *pti;
|
||||
int ToolInfoSize;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
{
|
||||
make_tooltipw(beval, text, pt);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (multiline_balloon_available() == TRUE)
|
||||
ToolInfoSize = sizeof(TOOLINFO_NEW);
|
||||
@@ -9072,7 +8860,6 @@ Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh)
|
||||
info->uFlags |= TTF_DI_SETITEM;
|
||||
}
|
||||
break;
|
||||
#ifdef FEAT_MBYTE
|
||||
case TTN_GETDISPINFOW:
|
||||
{
|
||||
// if we get here then we have new common controls
|
||||
@@ -9081,7 +8868,6 @@ Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh)
|
||||
info->uFlags |= TTF_DI_SETITEM;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -748,7 +748,7 @@ gui_x11_leave_cb(
|
||||
gui_focus_change(FALSE);
|
||||
}
|
||||
|
||||
#if defined(X_HAVE_UTF8_STRING) && defined(FEAT_MBYTE)
|
||||
#if defined(X_HAVE_UTF8_STRING)
|
||||
# if X_HAVE_UTF8_STRING
|
||||
# define USE_UTF8LOOKUP
|
||||
# endif
|
||||
@@ -810,7 +810,6 @@ gui_x11_key_hit_cb(
|
||||
if (status == XLookupNone || status == XLookupChars)
|
||||
key_sym = XK_VoidSymbol;
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
/* Do conversion from 'termencoding' to 'encoding'. When using
|
||||
* Xutf8LookupString() it has already been done. */
|
||||
if (len > 0 && input_conv.vc_type != CONV_NONE
|
||||
@@ -829,7 +828,6 @@ gui_x11_key_hit_cb(
|
||||
string_alloced = True;
|
||||
len = convert_input(p, len, maxlen);
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Translate CSI to K_CSI, otherwise it could be recognized as the
|
||||
* start of a special key. */
|
||||
@@ -901,10 +899,7 @@ gui_x11_key_hit_cb(
|
||||
&& (ev_press->state & Mod1Mask)
|
||||
&& !(key_sym == XK_BackSpace || key_sym == XK_Delete)
|
||||
&& (string[0] & 0x80) == 0
|
||||
#ifdef FEAT_MBYTE
|
||||
&& !enc_dbcs
|
||||
#endif
|
||||
)
|
||||
&& !enc_dbcs)
|
||||
{
|
||||
#if defined(FEAT_MENU) && defined(FEAT_GUI_MOTIF)
|
||||
/* Ignore ALT keys when they are used for the menu only */
|
||||
@@ -930,7 +925,6 @@ gui_x11_key_hit_cb(
|
||||
&& !(key_sym == XK_Tab && (ev_press->state & ShiftMask)))
|
||||
{
|
||||
string[0] |= 0x80;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8) /* convert to utf-8 */
|
||||
{
|
||||
string[1] = string[0] & 0xbf;
|
||||
@@ -944,7 +938,6 @@ gui_x11_key_hit_cb(
|
||||
else
|
||||
len = 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
ev_press->state |= Mod1Mask;
|
||||
@@ -983,10 +976,7 @@ gui_x11_key_hit_cb(
|
||||
if (len == -3 || key_sym == XK_space || key_sym == XK_Tab
|
||||
|| key_sym == XK_Return || key_sym == XK_Linefeed
|
||||
|| key_sym == XK_Escape
|
||||
#ifdef FEAT_MBYTE
|
||||
|| (enc_dbcs && len == 1 && (ev_press->state & Mod1Mask))
|
||||
#endif
|
||||
)
|
||||
|| (enc_dbcs && len == 1 && (ev_press->state & Mod1Mask)))
|
||||
{
|
||||
modifiers = 0;
|
||||
if (ev_press->state & ShiftMask)
|
||||
@@ -2375,7 +2365,6 @@ gui_mch_draw_string(
|
||||
int flags)
|
||||
{
|
||||
int cells = len;
|
||||
#ifdef FEAT_MBYTE
|
||||
static void *buf = NULL;
|
||||
static int buflen = 0;
|
||||
char_u *p;
|
||||
@@ -2431,8 +2420,6 @@ gui_mch_draw_string(
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_XFONTSET
|
||||
if (current_fontset != NULL)
|
||||
{
|
||||
@@ -2452,12 +2439,10 @@ gui_mch_draw_string(
|
||||
|
||||
if (flags & DRAW_TRANSP)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
XDrawString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col),
|
||||
TEXT_Y(row), buf, wlen);
|
||||
else
|
||||
#endif
|
||||
XDrawString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col),
|
||||
TEXT_Y(row), (char *)s, len);
|
||||
}
|
||||
@@ -2472,24 +2457,20 @@ gui_mch_draw_string(
|
||||
FILL_Y(row), gui.char_width * cells, gui.char_height);
|
||||
XSetForeground(gui.dpy, gui.text_gc, prev_fg_color);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
XDrawString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col),
|
||||
TEXT_Y(row), buf, wlen);
|
||||
else
|
||||
#endif
|
||||
XDrawString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col),
|
||||
TEXT_Y(row), (char *)s, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* XmbDrawImageString has bug, don't use it for fontset. */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
XDrawImageString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col),
|
||||
TEXT_Y(row), buf, wlen);
|
||||
else
|
||||
#endif
|
||||
XDrawImageString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col),
|
||||
TEXT_Y(row), (char *)s, len);
|
||||
}
|
||||
@@ -2497,12 +2478,10 @@ gui_mch_draw_string(
|
||||
/* Bold trick: draw the text again with a one-pixel offset. */
|
||||
if (flags & DRAW_BOLD)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
XDrawString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col) + 1,
|
||||
TEXT_Y(row), buf, wlen);
|
||||
else
|
||||
#endif
|
||||
XDrawString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col) + 1,
|
||||
TEXT_Y(row), (char *)s, len);
|
||||
}
|
||||
@@ -2628,10 +2607,8 @@ gui_mch_draw_hollow_cursor(guicolor_T color)
|
||||
{
|
||||
int w = 1;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (mb_lefthalve(gui.row, gui.col))
|
||||
w = 2;
|
||||
#endif
|
||||
gui_mch_set_fg_color(color);
|
||||
XDrawRectangle(gui.dpy, gui.wid, gui.text_gc, FILL_X(gui.col),
|
||||
FILL_Y(gui.row), w * gui.char_width - 1, gui.char_height - 1);
|
||||
|
||||
103
src/hardcopy.c
103
src/hardcopy.c
@@ -102,7 +102,7 @@ static long_u curr_bg;
|
||||
static long_u curr_fg;
|
||||
static int page_count;
|
||||
|
||||
#if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
|
||||
#if defined(FEAT_POSTSCRIPT)
|
||||
# define OPT_MBFONT_USECOURIER 0
|
||||
# define OPT_MBFONT_ASCII 1
|
||||
# define OPT_MBFONT_REGULAR 2
|
||||
@@ -149,7 +149,7 @@ parse_printoptions(void)
|
||||
return parse_list_options(p_popt, printer_opts, OPT_PRINT_NUM_OPTIONS);
|
||||
}
|
||||
|
||||
#if (defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)) || defined(PROTO)
|
||||
#if defined(FEAT_POSTSCRIPT) || defined(PROTO)
|
||||
/*
|
||||
* Parse 'printmbfont' and set the flags in "mbfont_opts".
|
||||
* Returns an error message or NULL;
|
||||
@@ -456,9 +456,7 @@ prt_header(
|
||||
int page_line;
|
||||
char_u *tbuf;
|
||||
char_u *p;
|
||||
#ifdef FEAT_MBYTE
|
||||
int l;
|
||||
#endif
|
||||
|
||||
/* Also use the space for the line number. */
|
||||
if (prt_use_number())
|
||||
@@ -513,24 +511,14 @@ prt_header(
|
||||
mch_print_start_line(TRUE, page_line);
|
||||
for (p = tbuf; *p != NUL; )
|
||||
{
|
||||
if (mch_print_text_out(p,
|
||||
#ifdef FEAT_MBYTE
|
||||
(l = (*mb_ptr2len)(p))
|
||||
#else
|
||||
1
|
||||
#endif
|
||||
))
|
||||
if (mch_print_text_out(p, (l = (*mb_ptr2len)(p))))
|
||||
{
|
||||
++page_line;
|
||||
if (page_line >= 0) /* out of room in header */
|
||||
break;
|
||||
mch_print_start_line(TRUE, page_line);
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
p += l;
|
||||
#else
|
||||
p++;
|
||||
#endif
|
||||
}
|
||||
|
||||
vim_free(tbuf);
|
||||
@@ -867,10 +855,8 @@ hardcopy_line(
|
||||
for (col = ppos->column; line[col] != NUL && !need_break; col += outputlen)
|
||||
{
|
||||
outputlen = 1;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && (outputlen = (*mb_ptr2len)(line + col)) < 1)
|
||||
outputlen = 1;
|
||||
#endif
|
||||
#ifdef FEAT_SYN_HL
|
||||
/*
|
||||
* syntax highlighting stuff.
|
||||
@@ -932,11 +918,9 @@ hardcopy_line(
|
||||
else
|
||||
{
|
||||
need_break = mch_print_text_out(line + col, outputlen);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
print_pos += (*mb_ptr2cells)(line + col);
|
||||
else
|
||||
#endif
|
||||
print_pos++;
|
||||
}
|
||||
}
|
||||
@@ -1046,7 +1030,6 @@ static struct prt_ps_font_S prt_ps_courier_font =
|
||||
{"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"}
|
||||
};
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Generic font metrics for multi-byte fonts */
|
||||
static struct prt_ps_font_S prt_ps_mb_font =
|
||||
{
|
||||
@@ -1055,7 +1038,6 @@ static struct prt_ps_font_S prt_ps_mb_font =
|
||||
-250, 805,
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Pointer to current font set being used */
|
||||
static struct prt_ps_font_S* prt_ps_font;
|
||||
@@ -1076,7 +1058,6 @@ struct prt_ps_charset_S
|
||||
int has_charset;
|
||||
};
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
|
||||
#define CS_JIS_C_1978 (0x01)
|
||||
#define CS_JIS_X_1983 (0x02)
|
||||
@@ -1261,7 +1242,6 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
|
||||
"KS_X_1992"
|
||||
}
|
||||
};
|
||||
#endif /* FEAT_MBYTE */
|
||||
|
||||
struct prt_ps_resource_S
|
||||
{
|
||||
@@ -1410,7 +1390,6 @@ static int prt_collate;
|
||||
static char_u prt_line_buffer[257];
|
||||
static garray_T prt_ps_buffer;
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
static int prt_do_conv;
|
||||
static vimconv_T prt_conv;
|
||||
|
||||
@@ -1422,7 +1401,6 @@ static int prt_in_ascii;
|
||||
static int prt_half_width;
|
||||
static char *prt_ascii_encoding;
|
||||
static char_u prt_hexchar[] = "0123456789abcdef";
|
||||
# endif
|
||||
|
||||
static void
|
||||
prt_write_file_raw_len(char_u *buffer, int bytes)
|
||||
@@ -1494,18 +1472,15 @@ prt_def_font(
|
||||
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
|
||||
"/_%s /VIM-%s /%s ref\n", new_name, encoding, font);
|
||||
prt_write_file(prt_line_buffer);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
sprintf((char *)prt_line_buffer, "/%s %d %f /_%s sffs\n",
|
||||
new_name, height, 500./prt_ps_courier_font.wx, new_name);
|
||||
else
|
||||
#endif
|
||||
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
|
||||
"/%s %d /_%s ffs\n", new_name, height, new_name);
|
||||
prt_write_file(prt_line_buffer);
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Write a line to define the CID font.
|
||||
*/
|
||||
@@ -1530,7 +1505,6 @@ prt_dup_cidfont(char *original_name, char *new_name)
|
||||
"/%s %s d\n", new_name, original_name);
|
||||
prt_write_file(prt_line_buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert a real value into an integer and fractional part as integers, with
|
||||
@@ -1659,18 +1633,14 @@ prt_flush_buffer(void)
|
||||
/* Draw the text
|
||||
* Note: we write text out raw - EBCDIC conversion is handled in the
|
||||
* PostScript world via the font encoding vector. */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
prt_write_string("<");
|
||||
else
|
||||
#endif
|
||||
prt_write_string("(");
|
||||
prt_write_file_raw_len(prt_ps_buffer.ga_data, prt_ps_buffer.ga_len);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
prt_write_string(">");
|
||||
else
|
||||
#endif
|
||||
prt_write_string(")");
|
||||
/* Add a moveto if need be and use the appropriate show procedure */
|
||||
if (prt_do_moveto)
|
||||
@@ -2150,7 +2120,6 @@ prt_dsc_docmedia(
|
||||
void
|
||||
mch_print_cleanup(void)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
{
|
||||
int i;
|
||||
@@ -2171,7 +2140,6 @@ mch_print_cleanup(void)
|
||||
convert_setup(&prt_conv, NULL, NULL);
|
||||
prt_do_conv = FALSE;
|
||||
}
|
||||
#endif
|
||||
if (prt_ps_fd != NULL)
|
||||
{
|
||||
fclose(prt_ps_fd);
|
||||
@@ -2250,13 +2218,11 @@ prt_get_cpl(void)
|
||||
if (prt_use_number())
|
||||
{
|
||||
prt_number_width = PRINT_NUMBER_WIDTH * prt_char_width;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* If we are outputting multi-byte characters then line numbers will be
|
||||
* printed with half width characters
|
||||
*/
|
||||
if (prt_out_mbyte)
|
||||
prt_number_width /= 2;
|
||||
#endif
|
||||
prt_left_margin += prt_number_width;
|
||||
}
|
||||
else
|
||||
@@ -2265,7 +2231,6 @@ prt_get_cpl(void)
|
||||
return (int)((prt_right_margin - prt_left_margin) / prt_char_width);
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
static int
|
||||
prt_build_cid_fontname(int font, char_u *name, int name_len)
|
||||
{
|
||||
@@ -2279,7 +2244,6 @@ prt_build_cid_fontname(int font, char_u *name, int name_len)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get number of lines of text that fit on a page (excluding the header).
|
||||
@@ -2315,7 +2279,6 @@ prt_get_lpp(void)
|
||||
return lpp - prt_header_height();
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
static int
|
||||
prt_match_encoding(
|
||||
char *p_encoding,
|
||||
@@ -2368,7 +2331,6 @@ prt_match_charset(
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
mch_print_init(
|
||||
@@ -2385,14 +2347,12 @@ mch_print_init(
|
||||
double right;
|
||||
double top;
|
||||
double bottom;
|
||||
#ifdef FEAT_MBYTE
|
||||
int props;
|
||||
int cmap = 0;
|
||||
char_u *p_encoding;
|
||||
struct prt_ps_encoding_S *p_mbenc;
|
||||
struct prt_ps_encoding_S *p_mbenc_first;
|
||||
struct prt_ps_charset_S *p_mbchar = NULL;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
@@ -2415,7 +2375,6 @@ mch_print_init(
|
||||
/*
|
||||
* Set up font and encoding.
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
p_encoding = enc_skip(p_penc);
|
||||
if (*p_encoding == NUL)
|
||||
p_encoding = enc_skip(p_enc);
|
||||
@@ -2542,11 +2501,8 @@ mch_print_init(
|
||||
prt_ps_font = &prt_ps_mb_font;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
prt_use_courier = FALSE;
|
||||
#endif
|
||||
prt_ps_font = &prt_ps_courier_font;
|
||||
}
|
||||
|
||||
@@ -2699,10 +2655,8 @@ mch_print_init(
|
||||
}
|
||||
|
||||
prt_bufsiz = psettings->chars_per_line;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
prt_bufsiz *= 2;
|
||||
#endif
|
||||
ga_init2(&prt_ps_buffer, (int)sizeof(char), prt_bufsiz);
|
||||
|
||||
prt_page_num = 0;
|
||||
@@ -2781,27 +2735,20 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
char buffer[256];
|
||||
char_u *p_encoding;
|
||||
char_u *p;
|
||||
#ifdef FEAT_MBYTE
|
||||
struct prt_ps_resource_S *res_cidfont;
|
||||
struct prt_ps_resource_S *res_cmap;
|
||||
#endif
|
||||
int retval = FALSE;
|
||||
|
||||
res_prolog = (struct prt_ps_resource_S *)
|
||||
alloc(sizeof(struct prt_ps_resource_S));
|
||||
res_encoding = (struct prt_ps_resource_S *)
|
||||
alloc(sizeof(struct prt_ps_resource_S));
|
||||
#ifdef FEAT_MBYTE
|
||||
res_cidfont = (struct prt_ps_resource_S *)
|
||||
alloc(sizeof(struct prt_ps_resource_S));
|
||||
res_cmap = (struct prt_ps_resource_S *)
|
||||
alloc(sizeof(struct prt_ps_resource_S));
|
||||
#endif
|
||||
if (res_prolog == NULL || res_encoding == NULL
|
||||
#ifdef FEAT_MBYTE
|
||||
|| res_cidfont == NULL || res_cmap == NULL
|
||||
#endif
|
||||
)
|
||||
|| res_cidfont == NULL || res_cmap == NULL)
|
||||
goto theend;
|
||||
|
||||
/*
|
||||
@@ -2863,11 +2810,8 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
prt_mediasize[prt_media].height,
|
||||
(double)0, NULL, NULL);
|
||||
/* Define fonts needed */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (!prt_out_mbyte || prt_use_courier)
|
||||
#endif
|
||||
prt_dsc_font_resource("DocumentNeededResources", &prt_ps_courier_font);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
{
|
||||
prt_dsc_font_resource((prt_use_courier ? NULL
|
||||
@@ -2875,7 +2819,6 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
if (!prt_custom_cmap)
|
||||
prt_dsc_resources(NULL, "cmap", prt_cmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Search for external resources VIM supplies */
|
||||
if (!prt_find_resource("prolog", res_prolog))
|
||||
@@ -2887,7 +2830,6 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
goto theend;
|
||||
if (!prt_check_resource(res_prolog, PRT_PROLOG_VERSION))
|
||||
goto theend;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
{
|
||||
/* Look for required version of multi-byte printing procset */
|
||||
@@ -2901,23 +2843,19 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
if (!prt_check_resource(res_cidfont, PRT_CID_PROLOG_VERSION))
|
||||
goto theend;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Find an encoding to use for printing.
|
||||
* Check 'printencoding'. If not set or not found, then use 'encoding'. If
|
||||
* that cannot be found then default to "latin1".
|
||||
* Note: VIM specific encoding header is always skipped.
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
if (!prt_out_mbyte)
|
||||
{
|
||||
#endif
|
||||
p_encoding = enc_skip(p_penc);
|
||||
if (*p_encoding == NUL
|
||||
|| !prt_find_resource((char *)p_encoding, res_encoding))
|
||||
{
|
||||
/* 'printencoding' not set or not supported - find alternate */
|
||||
#ifdef FEAT_MBYTE
|
||||
int props;
|
||||
|
||||
p_encoding = enc_skip(p_enc);
|
||||
@@ -2925,7 +2863,6 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
if (!(props & ENC_8BIT)
|
||||
|| !prt_find_resource((char *)p_encoding, res_encoding))
|
||||
/* 8-bit 'encoding' is not supported */
|
||||
#endif
|
||||
{
|
||||
/* Use latin1 as default printing encoding */
|
||||
p_encoding = (char_u *)"latin1";
|
||||
@@ -2941,7 +2878,6 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
goto theend;
|
||||
/* For the moment there are no checks on encoding resource files to
|
||||
* perform */
|
||||
#ifdef FEAT_MBYTE
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2989,14 +2925,12 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
if (!prt_open_resource(res_cmap))
|
||||
goto theend;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* List resources supplied */
|
||||
STRCPY(buffer, res_prolog->title);
|
||||
STRCAT(buffer, " ");
|
||||
STRCAT(buffer, res_prolog->version);
|
||||
prt_dsc_resources("DocumentSuppliedResources", "procset", buffer);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
{
|
||||
STRCPY(buffer, res_cidfont->title);
|
||||
@@ -3013,7 +2947,6 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
}
|
||||
}
|
||||
if (!prt_out_mbyte || prt_use_courier)
|
||||
#endif
|
||||
{
|
||||
STRCPY(buffer, res_encoding->title);
|
||||
STRCAT(buffer, " ");
|
||||
@@ -3035,11 +2968,8 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
prt_dsc_noarg("BeginDefaults");
|
||||
|
||||
/* List font resources most likely common to all pages */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (!prt_out_mbyte || prt_use_courier)
|
||||
#endif
|
||||
prt_dsc_font_resource("PageResources", &prt_ps_courier_font);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
{
|
||||
prt_dsc_font_resource((prt_use_courier ? NULL : "PageResources"),
|
||||
@@ -3047,7 +2977,6 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
if (!prt_custom_cmap)
|
||||
prt_dsc_resources(NULL, "cmap", prt_cmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Paper will be used for all pages */
|
||||
prt_dsc_textline("PageMedia", prt_mediasize[prt_media].name);
|
||||
@@ -3062,7 +2991,6 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
/* Add required procsets - NOTE: order is important! */
|
||||
if (!prt_add_resource(res_prolog))
|
||||
goto theend;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_out_mbyte)
|
||||
{
|
||||
/* Add CID font procset, and any user supplied CMap */
|
||||
@@ -3071,11 +2999,8 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
if (prt_custom_cmap && !prt_add_resource(res_cmap))
|
||||
goto theend;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (!prt_out_mbyte || prt_use_courier)
|
||||
#endif
|
||||
/* There will be only one Roman font encoding to be included in the PS
|
||||
* file. */
|
||||
if (!prt_add_resource(res_encoding))
|
||||
@@ -3102,14 +3027,12 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
prt_write_string("c\n");
|
||||
|
||||
/* Font resource inclusion and definition */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (!prt_out_mbyte || prt_use_courier)
|
||||
{
|
||||
/* When using Courier for ASCII range when printing multi-byte, need to
|
||||
* pick up ASCII encoding to use with it. */
|
||||
if (prt_use_courier)
|
||||
p_encoding = (char_u *)prt_ascii_encoding;
|
||||
#endif
|
||||
prt_dsc_resources("IncludeResource", "font",
|
||||
prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
|
||||
prt_def_font("F0", (char *)p_encoding, (int)prt_line_height,
|
||||
@@ -3126,7 +3049,6 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
|
||||
prt_def_font("F3", (char *)p_encoding, (int)prt_line_height,
|
||||
prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
|
||||
#ifdef FEAT_MBYTE
|
||||
}
|
||||
if (prt_out_mbyte)
|
||||
{
|
||||
@@ -3182,7 +3104,6 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
/* Use BOLD for BOLDOBLIQUE */
|
||||
prt_dup_cidfont("CF1", "CF3");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Misc constant vars used for underlining and background rects */
|
||||
prt_def_var("UO", PRT_PS_FONT_TO_USER(prt_line_height,
|
||||
@@ -3199,10 +3120,8 @@ mch_print_begin(prt_settings_T *psettings)
|
||||
theend:
|
||||
vim_free(res_prolog);
|
||||
vim_free(res_encoding);
|
||||
#ifdef FEAT_MBYTE
|
||||
vim_free(res_cidfont);
|
||||
vim_free(res_cmap);
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -3269,12 +3188,10 @@ mch_print_begin_page(char_u *str UNUSED)
|
||||
prt_dsc_noarg("BeginPageSetup");
|
||||
|
||||
prt_write_string("sv\n0 g\n");
|
||||
#ifdef FEAT_MBYTE
|
||||
prt_in_ascii = !prt_out_mbyte;
|
||||
if (prt_out_mbyte)
|
||||
prt_write_string("CF0 sf\n");
|
||||
else
|
||||
#endif
|
||||
prt_write_string("F0 sf\n");
|
||||
prt_fgcol = PRCOLOR_BLACK;
|
||||
prt_bgcol = PRCOLOR_WHITE;
|
||||
@@ -3318,9 +3235,7 @@ mch_print_start_line(int margin, int page_line)
|
||||
|
||||
prt_attribute_change = TRUE;
|
||||
prt_need_moveto = TRUE;
|
||||
#ifdef FEAT_MBYTE
|
||||
prt_half_width = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
@@ -3332,15 +3247,12 @@ mch_print_text_out(char_u *textp, int len UNUSED)
|
||||
char_u ch_buff[8];
|
||||
float char_width;
|
||||
float next_pos;
|
||||
#ifdef FEAT_MBYTE
|
||||
int in_ascii;
|
||||
int half_width;
|
||||
char_u *tofree = NULL;
|
||||
#endif
|
||||
|
||||
char_width = prt_char_width;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Ideally VIM would create a rearranged CID font to combine a Roman and
|
||||
* CJKV font to do what VIM is doing here - use a Roman font for characters
|
||||
* in the ASCII range, and the original CID font for everything else.
|
||||
@@ -3392,7 +3304,6 @@ mch_print_text_out(char_u *textp, int len UNUSED)
|
||||
prt_attribute_change = TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Output any required changes to the graphics state, after flushing any
|
||||
* text buffered so far.
|
||||
@@ -3413,11 +3324,9 @@ mch_print_text_out(char_u *textp, int len UNUSED)
|
||||
}
|
||||
if (prt_need_font)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (!prt_in_ascii)
|
||||
prt_write_string("CF");
|
||||
else
|
||||
#endif
|
||||
prt_write_string("F");
|
||||
prt_write_int(prt_font);
|
||||
prt_write_string("sf\n");
|
||||
@@ -3459,7 +3368,6 @@ mch_print_text_out(char_u *textp, int len UNUSED)
|
||||
prt_attribute_change = FALSE;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (prt_do_conv)
|
||||
{
|
||||
/* Convert from multi-byte to 8-bit encoding */
|
||||
@@ -3486,7 +3394,6 @@ mch_print_text_out(char_u *textp, int len UNUSED)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Add next character to buffer of characters to output.
|
||||
* Note: One printed character may require several PS characters to
|
||||
@@ -3528,10 +3435,8 @@ mch_print_text_out(char_u *textp, int len UNUSED)
|
||||
ga_append(&prt_ps_buffer, ch);
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Need to free any translated characters */
|
||||
vim_free(tofree);
|
||||
#endif
|
||||
|
||||
prt_text_run += char_width;
|
||||
prt_pos_x += char_width;
|
||||
|
||||
@@ -440,20 +440,11 @@ serverSendToVim(
|
||||
* comm window in the communication window.
|
||||
* Length must be computed exactly!
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
length = STRLEN(name) + STRLEN(p_enc) + STRLEN(cmd) + 14;
|
||||
#else
|
||||
length = STRLEN(name) + STRLEN(cmd) + 10;
|
||||
#endif
|
||||
property = (char_u *)alloc((unsigned)length + 30);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
sprintf((char *)property, "%c%c%c-n %s%c-E %s%c-s %s",
|
||||
0, asExpr ? 'c' : 'k', 0, name, 0, p_enc, 0, cmd);
|
||||
#else
|
||||
sprintf((char *)property, "%c%c%c-n %s%c-s %s",
|
||||
0, asExpr ? 'c' : 'k', 0, name, 0, cmd);
|
||||
#endif
|
||||
if (name == loosename)
|
||||
vim_free(loosename);
|
||||
/* Add a back reference to our comm window */
|
||||
@@ -758,20 +749,11 @@ serverSendReply(char_u *name, char_u *str)
|
||||
if (!WindowValid(dpy, win))
|
||||
return -1;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
length = STRLEN(p_enc) + STRLEN(str) + 14;
|
||||
#else
|
||||
length = STRLEN(str) + 10;
|
||||
#endif
|
||||
if ((property = (char_u *)alloc((unsigned)length + 30)) != NULL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x",
|
||||
0, 0, p_enc, 0, str, 0, (unsigned int)commWindow);
|
||||
#else
|
||||
sprintf((char *)property, "%cn%c-n %s%c-w %x",
|
||||
0, 0, str, 0, (unsigned int)commWindow);
|
||||
#endif
|
||||
/* Add length of what "%x" resulted in. */
|
||||
length += STRLEN(property + length);
|
||||
res = AppendPropCarefully(dpy, win, commProperty, property, length + 1);
|
||||
@@ -1334,17 +1316,10 @@ server_parse_message(
|
||||
|
||||
/* Initialize the result property. */
|
||||
ga_init2(&reply, 1, 100);
|
||||
#ifdef FEAT_MBYTE
|
||||
(void)ga_grow(&reply, 50 + STRLEN(p_enc));
|
||||
sprintf(reply.ga_data, "%cr%c-E %s%c-s %s%c-r ",
|
||||
0, 0, p_enc, 0, serial, 0);
|
||||
reply.ga_len = 14 + STRLEN(p_enc) + STRLEN(serial);
|
||||
#else
|
||||
(void)ga_grow(&reply, 50);
|
||||
sprintf(reply.ga_data, "%cr%c-s %s%c-r ",
|
||||
0, 0, serial, 0);
|
||||
reply.ga_len = 10 + STRLEN(serial);
|
||||
#endif
|
||||
|
||||
/* Evaluate the expression and return the result. */
|
||||
if (res != NULL)
|
||||
|
||||
33
src/json.c
33
src/json.c
@@ -96,7 +96,7 @@ write_string(garray_T *gap, char_u *str)
|
||||
ga_concat(gap, (char_u *)"\"\"");
|
||||
else
|
||||
{
|
||||
#if defined(FEAT_MBYTE) && defined(USE_ICONV)
|
||||
#if defined(USE_ICONV)
|
||||
vimconv_T conv;
|
||||
char_u *converted = NULL;
|
||||
|
||||
@@ -115,12 +115,8 @@ write_string(garray_T *gap, char_u *str)
|
||||
while (*res != NUL)
|
||||
{
|
||||
int c;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* always use utf-8 encoding, ignore 'encoding' */
|
||||
c = utf_ptr2char(res);
|
||||
#else
|
||||
c = *res;
|
||||
#endif
|
||||
|
||||
switch (c)
|
||||
{
|
||||
@@ -142,12 +138,7 @@ write_string(garray_T *gap, char_u *str)
|
||||
default:
|
||||
if (c >= 0x20)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
numbuf[utf_char2bytes(c, numbuf)] = NUL;
|
||||
#else
|
||||
numbuf[0] = c;
|
||||
numbuf[1] = NUL;
|
||||
#endif
|
||||
ga_concat(gap, numbuf);
|
||||
}
|
||||
else
|
||||
@@ -157,14 +148,10 @@ write_string(garray_T *gap, char_u *str)
|
||||
ga_concat(gap, numbuf);
|
||||
}
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
res += utf_ptr2len(res);
|
||||
#else
|
||||
++res;
|
||||
#endif
|
||||
}
|
||||
ga_append(gap, '"');
|
||||
#if defined(FEAT_MBYTE) && defined(USE_ICONV)
|
||||
#if defined(USE_ICONV)
|
||||
vim_free(converted);
|
||||
#endif
|
||||
}
|
||||
@@ -421,11 +408,7 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
|
||||
{
|
||||
/* The JSON is always expected to be utf-8, thus use utf functions
|
||||
* here. The string is converted below if needed. */
|
||||
if (*p == NUL || p[1] == NUL
|
||||
#ifdef FEAT_MBYTE
|
||||
|| utf_ptr2len(p) < utf_byte2len(*p)
|
||||
#endif
|
||||
)
|
||||
if (*p == NUL || p[1] == NUL || utf_ptr2len(p) < utf_byte2len(*p))
|
||||
{
|
||||
/* Not enough bytes to make a character or end of the string. Get
|
||||
* more if possible. */
|
||||
@@ -488,13 +471,9 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
|
||||
}
|
||||
if (res != NULL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u buf[NUMBUFLEN];
|
||||
buf[utf_char2bytes((int)nr, buf)] = NUL;
|
||||
ga_concat(&ga, buf);
|
||||
#else
|
||||
ga_append(&ga, (int)nr);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -511,11 +490,7 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
len = utf_ptr2len(p);
|
||||
#else
|
||||
len = 1;
|
||||
#endif
|
||||
if (res != NULL)
|
||||
{
|
||||
if (ga_grow(&ga, len) == FAIL)
|
||||
@@ -538,7 +513,7 @@ json_decode_string(js_read_T *reader, typval_T *res, int quote)
|
||||
{
|
||||
ga_append(&ga, NUL);
|
||||
res->v_type = VAR_STRING;
|
||||
#if defined(FEAT_MBYTE) && defined(USE_ICONV)
|
||||
#if defined(USE_ICONV)
|
||||
if (!enc_utf8)
|
||||
{
|
||||
vimconv_T conv;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
/* This file has to be included because the tested functions are static */
|
||||
#include "charset.c"
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Test the results of vim_iswordc() and vim_iswordp() are matched.
|
||||
*/
|
||||
@@ -73,13 +72,10 @@ test_isword_funcs_utf8(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
test_isword_funcs_utf8();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
20
src/main.c
20
src/main.c
@@ -119,7 +119,7 @@ main
|
||||
*/
|
||||
mch_early_init();
|
||||
|
||||
#if defined(WIN32) && defined(FEAT_MBYTE)
|
||||
#if defined(WIN32)
|
||||
/*
|
||||
* MinGW expands command line arguments, which confuses our code to
|
||||
* convert when 'encoding' changes. Get the unexpanded arguments.
|
||||
@@ -250,7 +250,7 @@ main
|
||||
params.fname = alist_name(&GARGLIST[0]);
|
||||
}
|
||||
|
||||
#if defined(WIN32) && defined(FEAT_MBYTE)
|
||||
#if defined(WIN32)
|
||||
{
|
||||
extern void set_alist_count(void);
|
||||
|
||||
@@ -592,9 +592,7 @@ vim_main2(void)
|
||||
{
|
||||
char_u *enc = NULL;
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
enc = p_menc;
|
||||
# endif
|
||||
if (params.use_ef != NULL)
|
||||
set_string_option_direct((char_u *)"ef", -1,
|
||||
params.use_ef, OPT_FREE, SID_CARG);
|
||||
@@ -813,7 +811,7 @@ vim_main2(void)
|
||||
/* Must come before the may_req_ calls. */
|
||||
starting = 0;
|
||||
|
||||
#if defined(FEAT_TERMRESPONSE) && defined(FEAT_MBYTE)
|
||||
#if defined(FEAT_TERMRESPONSE)
|
||||
/* Must be done before redrawing, puts a few characters on the screen. */
|
||||
may_req_ambiguous_char_width();
|
||||
#endif
|
||||
@@ -926,9 +924,7 @@ common_init(mparm_T *paramp)
|
||||
{
|
||||
cmdline_init();
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
(void)mb_init(); /* init mb_bytelen_tab[] to ones */
|
||||
#endif
|
||||
#ifdef FEAT_EVAL
|
||||
eval_init(); /* init global variables */
|
||||
#endif
|
||||
@@ -1549,7 +1545,7 @@ getout(int exitval)
|
||||
if (garbage_collect_at_exit)
|
||||
garbage_collect(FALSE);
|
||||
#endif
|
||||
#if defined(WIN32) && defined(FEAT_MBYTE)
|
||||
#if defined(WIN32)
|
||||
free_cmd_argsW();
|
||||
#endif
|
||||
|
||||
@@ -2501,7 +2497,7 @@ scripterror:
|
||||
#endif
|
||||
);
|
||||
|
||||
#if defined(FEAT_MBYTE) && defined(WIN32)
|
||||
#if defined(WIN32)
|
||||
{
|
||||
/* Remember this argument has been added to the argument list.
|
||||
* Needed when 'encoding' is changed. */
|
||||
@@ -2584,7 +2580,7 @@ check_tty(mparm_T *parmp)
|
||||
#if defined(WIN3264) && !defined(FEAT_GUI_W32)
|
||||
if (is_cygpty_used())
|
||||
{
|
||||
# if defined(FEAT_MBYTE) && defined(HAVE_BIND_TEXTDOMAIN_CODESET) \
|
||||
# if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \
|
||||
&& defined(FEAT_GETTEXT)
|
||||
char *s, *tofree = NULL;
|
||||
|
||||
@@ -3660,9 +3656,7 @@ exec_on_server(mparm_T *parmp)
|
||||
{
|
||||
cmdsrv_main(&parmp->argc, parmp->argv,
|
||||
parmp->serverName_arg, &parmp->serverStr);
|
||||
# ifdef FEAT_MBYTE
|
||||
parmp->serverStrEnc = vim_strsave(p_enc);
|
||||
# endif
|
||||
}
|
||||
|
||||
/* If we're still running, get the name to register ourselves.
|
||||
@@ -4281,7 +4275,6 @@ serverConvert(
|
||||
char_u *res = data;
|
||||
|
||||
*tofree = NULL;
|
||||
# ifdef FEAT_MBYTE
|
||||
if (client_enc != NULL && p_enc != NULL)
|
||||
{
|
||||
vimconv_T vimconv;
|
||||
@@ -4298,7 +4291,6 @@ serverConvert(
|
||||
}
|
||||
convert_setup(&vimconv, NULL, NULL);
|
||||
}
|
||||
# endif
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
23
src/mbyte.c
23
src/mbyte.c
@@ -136,8 +136,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
|
||||
static int dbcs_char2len(int c);
|
||||
static int dbcs_char2bytes(int c, char_u *buf);
|
||||
static int dbcs_ptr2len(char_u *p);
|
||||
@@ -211,9 +209,7 @@ xim_log(char *s, ...)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(FEAT_POSTSCRIPT) || defined(PROTO)
|
||||
/*
|
||||
* Canonical encoding names and their properties.
|
||||
* "iso-8859-n" is handled by enc_canonize() directly.
|
||||
@@ -456,9 +452,6 @@ enc_canon_search(char_u *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
|
||||
/*
|
||||
* Find canonical encoding "name" in the list and return its properties.
|
||||
@@ -4294,9 +4287,7 @@ mb_fix_col(int col, int row)
|
||||
return col - 1;
|
||||
return col;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(FEAT_POSTSCRIPT) || defined(PROTO)
|
||||
static int enc_alias_search(char_u *name);
|
||||
|
||||
/*
|
||||
@@ -4325,7 +4316,6 @@ enc_canonize(char_u *enc)
|
||||
char_u *p, *s;
|
||||
int i;
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
if (STRCMP(enc, "default") == 0)
|
||||
{
|
||||
/* Use the default encoding as it's found by set_init_1(). */
|
||||
@@ -4334,7 +4324,6 @@ enc_canonize(char_u *enc)
|
||||
r = (char_u *)"latin1";
|
||||
return vim_strsave(r);
|
||||
}
|
||||
# endif
|
||||
|
||||
/* copy "enc" to allocated memory, with room for two '-' */
|
||||
r = alloc((unsigned)(STRLEN(enc) + 3));
|
||||
@@ -4406,9 +4395,7 @@ enc_alias_search(char_u *name)
|
||||
return enc_alias_table[i].canon;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
|
||||
#ifdef HAVE_LANGINFO_H
|
||||
# include <langinfo.h>
|
||||
@@ -4800,7 +4787,6 @@ iconv_end(void)
|
||||
# endif /* DYNAMIC_ICONV */
|
||||
# endif /* USE_ICONV */
|
||||
|
||||
#endif /* FEAT_MBYTE */
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
# define USE_IMACTIVATEFUNC (!gui.in_use && *p_imaf != NUL)
|
||||
@@ -4810,8 +4796,7 @@ iconv_end(void)
|
||||
# define USE_IMSTATUSFUNC (*p_imsf != NUL)
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE) \
|
||||
&& (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM))
|
||||
#if defined(FEAT_EVAL) && (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM))
|
||||
static void
|
||||
call_imactivatefunc(int active)
|
||||
{
|
||||
@@ -6482,7 +6467,7 @@ static int im_was_set_active = FALSE;
|
||||
int
|
||||
im_get_status(void)
|
||||
{
|
||||
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
|
||||
# if defined(FEAT_EVAL)
|
||||
if (USE_IMSTATUSFUNC)
|
||||
return call_imstatusfunc();
|
||||
# endif
|
||||
@@ -6492,7 +6477,7 @@ im_get_status(void)
|
||||
void
|
||||
im_set_active(int active_arg)
|
||||
{
|
||||
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
|
||||
# if defined(FEAT_EVAL)
|
||||
int active = !p_imdisable && active_arg;
|
||||
|
||||
if (USE_IMACTIVATEFUNC && active != im_get_status())
|
||||
@@ -6513,7 +6498,6 @@ im_set_position(int row UNUSED, int col UNUSED)
|
||||
|
||||
#endif /* FEAT_XIM */
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
|
||||
/*
|
||||
* Setup "vcp" for conversion from "from" to "to".
|
||||
@@ -6958,4 +6942,3 @@ string_convert_ext(
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -240,9 +240,7 @@ static void ml_set_b0_crypt(buf_T *buf, ZERO_BL *b0p);
|
||||
static void ml_upd_block0(buf_T *buf, upd_block0_T what);
|
||||
static void set_b0_fname(ZERO_BL *, buf_T *buf);
|
||||
static void set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf);
|
||||
#ifdef FEAT_MBYTE
|
||||
static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf);
|
||||
#endif
|
||||
static time_t swapfile_info(char_u *);
|
||||
static int recov_file_names(char_u **, char_u *, int prepend_dot);
|
||||
static int ml_append_int(buf_T *, linenr_T, char_u *, colnr_T, int, int);
|
||||
@@ -1033,10 +1031,8 @@ set_b0_fname(ZERO_BL *b0p, buf_T *buf)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Also add the 'fileencoding' if there is room. */
|
||||
add_b0_fenc(b0p, curbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1054,7 +1050,6 @@ set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf)
|
||||
b0p->b0_flags &= ~B0_SAME_DIR;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* When there is room, add the 'fileencoding' to block zero.
|
||||
*/
|
||||
@@ -1085,7 +1080,6 @@ add_b0_fenc(
|
||||
b0p->b0_flags |= B0_HAS_FENC;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -5103,9 +5097,7 @@ ml_setflags(buf_T *buf)
|
||||
b0p->b0_dirty = buf->b_changed ? B0_DIRTY : 0;
|
||||
b0p->b0_flags = (b0p->b0_flags & ~B0_FF_MASK)
|
||||
| (get_fileformat(buf) + 1);
|
||||
#ifdef FEAT_MBYTE
|
||||
add_b0_fenc(b0p, buf);
|
||||
#endif
|
||||
hp->bh_flags |= BH_DIRTY;
|
||||
mf_sync(buf->b_ml.ml_mfp, MFS_ZERO);
|
||||
break;
|
||||
@@ -5682,10 +5674,8 @@ goto_byte(long cnt)
|
||||
}
|
||||
check_cursor();
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
/* Make sure the cursor is on the first byte of a multi-byte char. */
|
||||
if (has_mbyte)
|
||||
mb_adjust_cursor();
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
102
src/message.c
102
src/message.c
@@ -219,7 +219,6 @@ msg_strtrunc(
|
||||
room = (int)(Rows - msg_row - 1) * Columns + sc_col - 1;
|
||||
if (len > room && room > 0)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
/* may have up to 18 bytes per cell (6 per char, up to two
|
||||
* composing chars) */
|
||||
@@ -228,7 +227,6 @@ msg_strtrunc(
|
||||
/* may have up to 2 bytes per cell for euc-jp */
|
||||
len = (room + 2) * 2;
|
||||
else
|
||||
#endif
|
||||
len = room + 2;
|
||||
buf = alloc(len);
|
||||
if (buf != NULL)
|
||||
@@ -274,7 +272,6 @@ trunc_string(
|
||||
break;
|
||||
len += n;
|
||||
buf[e] = s[e];
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
for (n = (*mb_ptr2len)(s + e); --n > 0; )
|
||||
{
|
||||
@@ -282,12 +279,10 @@ trunc_string(
|
||||
break;
|
||||
buf[e] = s[e];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Last part: End of the string. */
|
||||
i = e;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_dbcs != 0)
|
||||
{
|
||||
/* For DBCS going backwards in a string is slow, but
|
||||
@@ -317,7 +312,6 @@ trunc_string(
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for (i = (int)STRLEN(s); len + (n = ptr2cells(s + i - 1)) <= room; --i)
|
||||
len += n;
|
||||
@@ -852,7 +846,6 @@ msg_may_trunc(int force, char_u *s)
|
||||
if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
|
||||
&& (n = (int)STRLEN(s) - room) > 0)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int size = vim_strsize(s);
|
||||
@@ -868,7 +861,6 @@ msg_may_trunc(int force, char_u *s)
|
||||
}
|
||||
--n;
|
||||
}
|
||||
#endif
|
||||
s += n;
|
||||
*s = '<';
|
||||
}
|
||||
@@ -1388,11 +1380,7 @@ msg_putchar(int c)
|
||||
void
|
||||
msg_putchar_attr(int c, int attr)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
#else
|
||||
char_u buf[4];
|
||||
#endif
|
||||
|
||||
if (IS_SPECIAL(c))
|
||||
{
|
||||
@@ -1402,14 +1390,7 @@ msg_putchar_attr(int c, int attr)
|
||||
buf[3] = NUL;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
buf[(*mb_char2bytes)(c, buf)] = NUL;
|
||||
#else
|
||||
buf[0] = c;
|
||||
buf[1] = NUL;
|
||||
#endif
|
||||
}
|
||||
msg_puts_attr((char *)buf, attr);
|
||||
}
|
||||
|
||||
@@ -1478,7 +1459,6 @@ msg_outtrans_len(char_u *str, int len)
|
||||
char_u *
|
||||
msg_outtrans_one(char_u *p, int attr)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
int l;
|
||||
|
||||
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
@@ -1486,7 +1466,6 @@ msg_outtrans_one(char_u *p, int attr)
|
||||
msg_outtrans_len_attr(p, l, attr);
|
||||
return p + l;
|
||||
}
|
||||
#endif
|
||||
msg_puts_attr((char *)transchar_byte(*p), attr);
|
||||
return p + 1;
|
||||
}
|
||||
@@ -1498,10 +1477,8 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
|
||||
char_u *str = msgstr;
|
||||
char_u *plain_start = msgstr;
|
||||
char_u *s;
|
||||
#ifdef FEAT_MBYTE
|
||||
int mb_l;
|
||||
int c;
|
||||
#endif
|
||||
|
||||
/* if MSG_HIST flag set, add message to history */
|
||||
if (attr & MSG_HIST)
|
||||
@@ -1510,12 +1487,10 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
|
||||
attr &= ~MSG_HIST;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* If the string starts with a composing character first draw a space on
|
||||
* which the composing char can be drawn. */
|
||||
if (enc_utf8 && utf_iscomposing(utf_ptr2char(msgstr)))
|
||||
msg_puts_attr(" ", attr);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Go over the string. Special characters are translated and printed.
|
||||
@@ -1523,7 +1498,6 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
|
||||
*/
|
||||
while (--len >= 0)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8)
|
||||
/* Don't include composing chars after the end. */
|
||||
mb_l = utfc_ptr2len_len(str, len + 1);
|
||||
@@ -1553,7 +1527,6 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
|
||||
str += mb_l;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
s = transchar_byte(*str);
|
||||
if (s[1] != NUL)
|
||||
@@ -1639,10 +1612,7 @@ msg_outtrans_special(
|
||||
len = vim_strsize((char_u *)text);
|
||||
/* Highlight special keys */
|
||||
msg_puts_attr(text, len > 1
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (*mb_ptr2len)((char_u *)text) <= 1
|
||||
#endif
|
||||
? attr : 0);
|
||||
&& (*mb_ptr2len)((char_u *)text) <= 1 ? attr : 0);
|
||||
retval += len;
|
||||
}
|
||||
return retval;
|
||||
@@ -1685,7 +1655,6 @@ str2special(
|
||||
int modifiers = 0;
|
||||
int special = FALSE;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
char_u *p;
|
||||
@@ -1696,7 +1665,6 @@ str2special(
|
||||
if (p != NULL)
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
|
||||
c = *str;
|
||||
if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL)
|
||||
@@ -1716,7 +1684,6 @@ str2special(
|
||||
special = TRUE;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && !IS_SPECIAL(c))
|
||||
{
|
||||
int len = (*mb_ptr2len)(str);
|
||||
@@ -1734,7 +1701,6 @@ str2special(
|
||||
*sp = str + len;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
*sp = str + 1;
|
||||
|
||||
/* Make unprintable characters in <> form, also <M-Space> and <Tab>.
|
||||
@@ -1778,10 +1744,8 @@ msg_prt_line(char_u *s, int list)
|
||||
int n;
|
||||
int attr = 0;
|
||||
char_u *trail = NULL;
|
||||
#ifdef FEAT_MBYTE
|
||||
int l;
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
#endif
|
||||
|
||||
if (curwin->w_p_list)
|
||||
list = TRUE;
|
||||
@@ -1811,7 +1775,6 @@ msg_prt_line(char_u *s, int list)
|
||||
else
|
||||
c = *p_extra++;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1)
|
||||
{
|
||||
col += (*mb_ptr2cells)(s);
|
||||
@@ -1831,7 +1794,6 @@ msg_prt_line(char_u *s, int list)
|
||||
s += l;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
attr = 0;
|
||||
@@ -1906,7 +1868,6 @@ msg_prt_line(char_u *s, int list)
|
||||
msg_clr_eos();
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Use screen_puts() to output one multi-byte character.
|
||||
* Return the pointer "s" advanced to the next character.
|
||||
@@ -1952,7 +1913,6 @@ screen_puts_mbyte(char_u *s, int l, int attr)
|
||||
}
|
||||
return s + l;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Output a string to the screen at position msg_row, msg_col.
|
||||
@@ -2069,10 +2029,8 @@ msg_puts_display(
|
||||
char_u *s = str;
|
||||
char_u *t_s = str; /* string from "t_s" to "s" is still todo */
|
||||
int t_col = 0; /* screen cells todo, 0 when "t_s" not used */
|
||||
#ifdef FEAT_MBYTE
|
||||
int l;
|
||||
int cw;
|
||||
#endif
|
||||
char_u *sb_str = str;
|
||||
int sb_col = msg_col;
|
||||
int wrap;
|
||||
@@ -2092,19 +2050,13 @@ msg_puts_display(
|
||||
? (
|
||||
msg_col <= 1
|
||||
|| (*s == TAB && msg_col <= 7)
|
||||
# ifdef FEAT_MBYTE
|
||||
|| (has_mbyte && (*mb_ptr2cells)(s) > 1 && msg_col <= 2)
|
||||
# endif
|
||||
)
|
||||
|| (has_mbyte && (*mb_ptr2cells)(s) > 1 && msg_col <= 2))
|
||||
:
|
||||
#endif
|
||||
(msg_col + t_col >= Columns - 1
|
||||
|| (*s == TAB && msg_col + t_col >= ((Columns - 1) & ~7))
|
||||
# ifdef FEAT_MBYTE
|
||||
|| (has_mbyte && (*mb_ptr2cells)(s) > 1
|
||||
&& msg_col + t_col >= Columns - 2)
|
||||
# endif
|
||||
))))
|
||||
&& msg_col + t_col >= Columns - 2)))))
|
||||
{
|
||||
/*
|
||||
* The screen is scrolled up when at the last row (some terminals
|
||||
@@ -2133,7 +2085,6 @@ msg_puts_display(
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
if (enc_utf8 && maxlen >= 0)
|
||||
@@ -2144,7 +2095,6 @@ msg_puts_display(
|
||||
s = screen_puts_mbyte(s, l, attr);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
msg_screen_putchar(*s++, attr);
|
||||
did_last_char = TRUE;
|
||||
}
|
||||
@@ -2188,11 +2138,8 @@ msg_puts_display(
|
||||
|
||||
wrap = *s == '\n'
|
||||
|| msg_col + t_col >= Columns
|
||||
#ifdef FEAT_MBYTE
|
||||
|| (has_mbyte && (*mb_ptr2cells)(s) > 1
|
||||
&& msg_col + t_col >= Columns - 1)
|
||||
#endif
|
||||
;
|
||||
&& msg_col + t_col >= Columns - 1);
|
||||
if (t_col > 0 && (wrap || *s == '\r' || *s == '\b'
|
||||
|| *s == '\t' || *s == BELL))
|
||||
/* output any postponed text */
|
||||
@@ -2233,7 +2180,6 @@ msg_puts_display(
|
||||
vim_beep(BO_SH);
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
cw = (*mb_ptr2cells)(s);
|
||||
@@ -2248,42 +2194,28 @@ msg_puts_display(
|
||||
cw = 1;
|
||||
l = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* When drawing from right to left or when a double-wide character
|
||||
* doesn't fit, draw a single character here. Otherwise collect
|
||||
* characters and draw them all at once later. */
|
||||
#if defined(FEAT_RIGHTLEFT) || defined(FEAT_MBYTE)
|
||||
if (
|
||||
# ifdef FEAT_RIGHTLEFT
|
||||
cmdmsg_rl
|
||||
# ifdef FEAT_MBYTE
|
||||
||
|
||||
cmdmsg_rl ||
|
||||
# endif
|
||||
# endif
|
||||
# ifdef FEAT_MBYTE
|
||||
(cw > 1 && msg_col + t_col >= Columns - 1)
|
||||
# endif
|
||||
)
|
||||
(cw > 1 && msg_col + t_col >= Columns - 1))
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
if (l > 1)
|
||||
s = screen_puts_mbyte(s, l, attr) - 1;
|
||||
else
|
||||
# endif
|
||||
msg_screen_putchar(*s, attr);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* postpone this character until later */
|
||||
if (t_col == 0)
|
||||
t_s = s;
|
||||
#ifdef FEAT_MBYTE
|
||||
t_col += cw;
|
||||
s += l - 1;
|
||||
#else
|
||||
++t_col;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
++s;
|
||||
@@ -2601,12 +2533,10 @@ t_puts(
|
||||
screen_puts_len(t_s, (int)(s - t_s), msg_row, msg_col, attr);
|
||||
msg_col += *t_col;
|
||||
*t_col = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* If the string starts with a composing character don't increment the
|
||||
* column position for it. */
|
||||
if (enc_utf8 && utf_iscomposing(utf_ptr2char(t_s)))
|
||||
--msg_col;
|
||||
#endif
|
||||
if (msg_col >= Columns)
|
||||
{
|
||||
msg_col = 0;
|
||||
@@ -2643,14 +2573,14 @@ msg_puts_printf(char_u *str, int maxlen)
|
||||
char_u buf[4];
|
||||
char_u *p;
|
||||
#ifdef WIN3264
|
||||
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
|
||||
# if !defined(FEAT_GUI_MSWIN)
|
||||
char_u *ccp = NULL;
|
||||
|
||||
# endif
|
||||
if (!(silent_mode && p_verbose == 0))
|
||||
mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */
|
||||
|
||||
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
|
||||
# if !defined(FEAT_GUI_MSWIN)
|
||||
if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage)
|
||||
{
|
||||
int inlen = (int)STRLEN(str);
|
||||
@@ -2708,7 +2638,7 @@ msg_puts_printf(char_u *str, int maxlen)
|
||||
msg_didout = TRUE; /* assume that line is not empty */
|
||||
|
||||
#ifdef WIN3264
|
||||
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
|
||||
# if !defined(FEAT_GUI_MSWIN)
|
||||
vim_free(ccp);
|
||||
# endif
|
||||
if (!(silent_mode && p_verbose == 0))
|
||||
@@ -3646,7 +3576,6 @@ do_dialog(
|
||||
retval = 1;
|
||||
for (i = 0; hotkeys[i]; ++i)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
if ((*mb_ptr2char)(hotkeys + i) == c)
|
||||
@@ -3654,7 +3583,6 @@ do_dialog(
|
||||
i += (*mb_ptr2len)(hotkeys + i) - 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (hotkeys[i] == c)
|
||||
break;
|
||||
++retval;
|
||||
@@ -3690,7 +3618,6 @@ copy_char(
|
||||
char_u *to,
|
||||
int lowercase) /* make character lower case */
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
int len;
|
||||
int c;
|
||||
|
||||
@@ -3709,7 +3636,6 @@ copy_char(
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (lowercase)
|
||||
*to = (char_u)TOLOWER_LOC(*from);
|
||||
@@ -3735,11 +3661,7 @@ msg_show_console_dialog(
|
||||
int dfltbutton)
|
||||
{
|
||||
int len = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
#define HOTK_LEN (has_mbyte ? MB_MAXBYTES : 1)
|
||||
#else
|
||||
# define HOTK_LEN 1
|
||||
#endif
|
||||
int lenhotkey = HOTK_LEN; /* count first button */
|
||||
char_u *hotk = NULL;
|
||||
char_u *msgp = NULL;
|
||||
@@ -3771,11 +3693,9 @@ msg_show_console_dialog(
|
||||
*msgp++ = ' '; /* '\n' -> ', ' */
|
||||
|
||||
/* advance to next hotkey and set default hotkey */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
hotkp += STRLEN(hotkp);
|
||||
else
|
||||
#endif
|
||||
++hotkp;
|
||||
hotkp[copy_char(r + 1, hotkp, TRUE)] = NUL;
|
||||
if (dfltbutton)
|
||||
@@ -4583,7 +4503,6 @@ vim_vsnprintf_typval(
|
||||
str_arg_l = (q == NULL) ? precision
|
||||
: (size_t)(q - str_arg);
|
||||
}
|
||||
# ifdef FEAT_MBYTE
|
||||
if (fmt_spec == 'S')
|
||||
{
|
||||
if (min_field_width != 0)
|
||||
@@ -4600,7 +4519,6 @@ vim_vsnprintf_typval(
|
||||
str_arg_l = precision = p1 - (char_u *)str_arg;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
106
src/misc1.c
106
src/misc1.c
@@ -843,11 +843,9 @@ open_line(
|
||||
p = saved_line + curwin->w_cursor.col;
|
||||
while (*p != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
p += replace_push_mb(p);
|
||||
else
|
||||
#endif
|
||||
replace_push(*p++);
|
||||
}
|
||||
saved_line[curwin->w_cursor.col] = NUL;
|
||||
@@ -1296,7 +1294,6 @@ open_line(
|
||||
;
|
||||
++p;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Compute the length of the replaced characters in
|
||||
* screen characters, not bytes. */
|
||||
{
|
||||
@@ -1317,12 +1314,6 @@ open_line(
|
||||
(size_t)((leader + lead_len) - endp));
|
||||
lead_len += l;
|
||||
}
|
||||
#else
|
||||
if (p < leader + lead_repl_len)
|
||||
p = leader;
|
||||
else
|
||||
p -= lead_repl_len;
|
||||
#endif
|
||||
mch_memmove(p, lead_repl, (size_t)lead_repl_len);
|
||||
if (p + lead_repl_len > leader + lead_len)
|
||||
p[lead_repl_len] = NUL;
|
||||
@@ -1330,7 +1321,6 @@ open_line(
|
||||
/* blank-out any other chars from the old leader. */
|
||||
while (--p >= leader)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
int l = mb_head_off(leader, p);
|
||||
|
||||
if (l > 1)
|
||||
@@ -1346,16 +1336,14 @@ open_line(
|
||||
lead_len -= l;
|
||||
*p = ' ';
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (!VIM_ISWHITE(*p))
|
||||
else if (!VIM_ISWHITE(*p))
|
||||
*p = ' ';
|
||||
}
|
||||
}
|
||||
else /* left adjusted leader */
|
||||
{
|
||||
p = skipwhite(leader);
|
||||
#ifdef FEAT_MBYTE
|
||||
|
||||
/* Compute the length of the replaced characters in
|
||||
* screen characters, not bytes. Move the part that is
|
||||
* not to be overwritten. */
|
||||
@@ -1378,7 +1366,6 @@ open_line(
|
||||
lead_len += lead_repl_len - i;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
mch_memmove(p, lead_repl, (size_t)lead_repl_len);
|
||||
|
||||
/* Replace any remaining non-white chars in the old
|
||||
@@ -1396,7 +1383,6 @@ open_line(
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
int l = (*mb_ptr2len)(p);
|
||||
|
||||
if (l > 1)
|
||||
@@ -1412,7 +1398,6 @@ open_line(
|
||||
(leader + lead_len) - p);
|
||||
lead_len -= l - 1;
|
||||
}
|
||||
#endif
|
||||
*p = ' ';
|
||||
}
|
||||
}
|
||||
@@ -1537,11 +1522,8 @@ open_line(
|
||||
if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES))
|
||||
{
|
||||
while ((*p_extra == ' ' || *p_extra == '\t')
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (!enc_utf8
|
||||
|| !utf_iscomposing(utf_ptr2char(p_extra + 1)))
|
||||
#endif
|
||||
)
|
||||
|| !utf_iscomposing(utf_ptr2char(p_extra + 1))))
|
||||
{
|
||||
if (REPLACE_NORMAL(State))
|
||||
replace_push(*p_extra);
|
||||
@@ -2320,7 +2302,6 @@ ins_bytes(char_u *p)
|
||||
ins_bytes_len(char_u *p, int len)
|
||||
{
|
||||
int i;
|
||||
#ifdef FEAT_MBYTE
|
||||
int n;
|
||||
|
||||
if (has_mbyte)
|
||||
@@ -2334,7 +2315,6 @@ ins_bytes_len(char_u *p, int len)
|
||||
ins_char_bytes(p + i, n);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
for (i = 0; i < len; ++i)
|
||||
ins_char(p[i]);
|
||||
}
|
||||
@@ -2350,18 +2330,12 @@ ins_bytes_len(char_u *p, int len)
|
||||
ins_char(int c)
|
||||
{
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
int n = 1;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
n = (*mb_char2bytes)(c, buf);
|
||||
int n = (*mb_char2bytes)(c, buf);
|
||||
|
||||
/* When "c" is 0x100, 0x200, etc. we don't want to insert a NUL byte.
|
||||
* Happens for CTRL-Vu9900. */
|
||||
if (buf[0] == 0)
|
||||
buf[0] = '\n';
|
||||
#else
|
||||
buf[0] = c;
|
||||
#endif
|
||||
|
||||
ins_char_bytes(buf, n);
|
||||
}
|
||||
@@ -2401,9 +2375,6 @@ ins_char_bytes(char_u *buf, int charlen)
|
||||
colnr_T new_vcol = 0; /* init for GCC */
|
||||
colnr_T vcol;
|
||||
int old_list;
|
||||
#ifndef FEAT_MBYTE
|
||||
char_u cbuf[2];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Disable 'list' temporarily, unless 'cpo' contains the 'L' flag.
|
||||
@@ -2421,13 +2392,7 @@ ins_char_bytes(char_u *buf, int charlen)
|
||||
* cells. May result in adding spaces to fill a gap.
|
||||
*/
|
||||
getvcol(curwin, &curwin->w_cursor, NULL, &vcol, NULL);
|
||||
#ifndef FEAT_MBYTE
|
||||
cbuf[0] = c;
|
||||
cbuf[1] = NUL;
|
||||
new_vcol = vcol + chartabsize(cbuf, vcol);
|
||||
#else
|
||||
new_vcol = vcol + chartabsize(buf, vcol);
|
||||
#endif
|
||||
while (oldp[col + oldlen] != NUL && vcol < new_vcol)
|
||||
{
|
||||
vcol += chartabsize(oldp + col + oldlen, vcol);
|
||||
@@ -2435,11 +2400,7 @@ ins_char_bytes(char_u *buf, int charlen)
|
||||
* position. */
|
||||
if (vcol > new_vcol && oldp[col + oldlen] == TAB)
|
||||
break;
|
||||
#ifdef FEAT_MBYTE
|
||||
oldlen += (*mb_ptr2len)(oldp + col + oldlen);
|
||||
#else
|
||||
++oldlen;
|
||||
#endif
|
||||
/* Deleted a bit too much, insert spaces. */
|
||||
if (vcol > new_vcol)
|
||||
newlen += vcol - new_vcol;
|
||||
@@ -2449,11 +2410,7 @@ ins_char_bytes(char_u *buf, int charlen)
|
||||
else if (oldp[col] != NUL)
|
||||
{
|
||||
/* normal replace */
|
||||
#ifdef FEAT_MBYTE
|
||||
oldlen = (*mb_ptr2len)(oldp + col);
|
||||
#else
|
||||
oldlen = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -2464,11 +2421,9 @@ ins_char_bytes(char_u *buf, int charlen)
|
||||
replace_push(NUL);
|
||||
for (i = 0; i < oldlen; ++i)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
i += replace_push_mb(oldp + col + i) - 1;
|
||||
else
|
||||
#endif
|
||||
replace_push(oldp[col + i]);
|
||||
}
|
||||
}
|
||||
@@ -2488,13 +2443,8 @@ ins_char_bytes(char_u *buf, int charlen)
|
||||
(size_t)(linelen - col - oldlen));
|
||||
|
||||
/* Insert or overwrite the new character. */
|
||||
#ifdef FEAT_MBYTE
|
||||
mch_memmove(p, buf, charlen);
|
||||
i = charlen;
|
||||
#else
|
||||
*p = c;
|
||||
i = 1;
|
||||
#endif
|
||||
|
||||
/* Fill with spaces when necessary. */
|
||||
while (i < newlen)
|
||||
@@ -2517,11 +2467,9 @@ ins_char_bytes(char_u *buf, int charlen)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
showmatch(mb_ptr2char(buf));
|
||||
else
|
||||
#endif
|
||||
showmatch(c);
|
||||
}
|
||||
|
||||
@@ -2530,11 +2478,7 @@ ins_char_bytes(char_u *buf, int charlen)
|
||||
#endif
|
||||
{
|
||||
/* Normal insert: move cursor right */
|
||||
#ifdef FEAT_MBYTE
|
||||
curwin->w_cursor.col += charlen;
|
||||
#else
|
||||
++curwin->w_cursor.col;
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* TODO: should try to update w_row here, to avoid recomputing it later.
|
||||
@@ -2586,7 +2530,6 @@ ins_str(char_u *s)
|
||||
int
|
||||
del_char(int fixpos)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
/* Make sure the cursor is at the start of a character. */
|
||||
@@ -2595,11 +2538,9 @@ del_char(int fixpos)
|
||||
return FAIL;
|
||||
return del_chars(1L, fixpos);
|
||||
}
|
||||
#endif
|
||||
return del_bytes(1L, fixpos, TRUE);
|
||||
}
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
/*
|
||||
* Like del_bytes(), but delete characters instead of bytes.
|
||||
*/
|
||||
@@ -2620,7 +2561,6 @@ del_chars(long count, int fixpos)
|
||||
}
|
||||
return del_bytes(bytes, fixpos, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Delete "count" bytes under the cursor.
|
||||
@@ -2662,7 +2602,6 @@ del_bytes(
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* If 'delcombine' is set and deleting (less than) one character, only
|
||||
* delete the last combining character. */
|
||||
if (p_deco && use_delcombine && enc_utf8
|
||||
@@ -2685,7 +2624,6 @@ del_bytes(
|
||||
fixpos = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When count is too big, reduce it.
|
||||
@@ -2708,11 +2646,9 @@ del_bytes(
|
||||
#ifdef FEAT_VIRTUALEDIT
|
||||
curwin->w_cursor.coladd = 0;
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
curwin->w_cursor.col -=
|
||||
(*mb_head_off)(oldp, oldp + curwin->w_cursor.col);
|
||||
#endif
|
||||
}
|
||||
count = oldlen - col;
|
||||
movelen = 1;
|
||||
@@ -2847,20 +2783,16 @@ gchar_pos(pos_T *pos)
|
||||
if (pos->col == MAXCOL)
|
||||
return NUL;
|
||||
ptr = ml_get_pos(pos);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
return (*mb_ptr2char)(ptr);
|
||||
#endif
|
||||
return (int)*ptr;
|
||||
}
|
||||
|
||||
int
|
||||
gchar_cursor(void)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
return (*mb_ptr2char)(ml_get_cursor());
|
||||
#endif
|
||||
return (int)*ml_get_cursor();
|
||||
}
|
||||
|
||||
@@ -3681,7 +3613,6 @@ get_keystroke(void)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
if (MB_BYTE2LEN(n) > len)
|
||||
@@ -3689,7 +3620,6 @@ get_keystroke(void)
|
||||
buf[len >= buflen ? buflen - 1 : len] = NUL;
|
||||
n = (*mb_ptr2char)(buf);
|
||||
}
|
||||
#endif
|
||||
#ifdef UNIX
|
||||
if (n == intr_char)
|
||||
n = ESC;
|
||||
@@ -4023,7 +3953,6 @@ init_homedir(void)
|
||||
if (var != NULL && *var == NUL) /* empty is same as not set */
|
||||
var = NULL;
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
if (enc_utf8 && var != NULL)
|
||||
{
|
||||
int len;
|
||||
@@ -4038,7 +3967,6 @@ init_homedir(void)
|
||||
return;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Default home dir is C:/
|
||||
@@ -4437,7 +4365,7 @@ vim_getenv(char_u *name, int *mustfree)
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
#if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
#if defined(WIN3264)
|
||||
if (enc_utf8)
|
||||
{
|
||||
int len;
|
||||
@@ -4481,7 +4409,7 @@ vim_getenv(char_u *name, int *mustfree)
|
||||
else
|
||||
p = mch_getenv((char_u *)"VIM");
|
||||
|
||||
#if defined(FEAT_MBYTE) && defined(WIN3264)
|
||||
#if defined(WIN3264)
|
||||
if (enc_utf8)
|
||||
{
|
||||
int len;
|
||||
@@ -5332,7 +5260,6 @@ shorten_dir(char_u *str)
|
||||
*d++ = *s; /* copy next char */
|
||||
if (*s != '~' && *s != '.') /* and leading "~" and "." */
|
||||
skip = TRUE;
|
||||
# ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int l = mb_ptr2len(s);
|
||||
@@ -5340,7 +5267,6 @@ shorten_dir(char_u *str)
|
||||
while (--l > 0)
|
||||
*d++ = *++s;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10155,10 +10081,8 @@ dos_expandpath(
|
||||
static int stardepth = 0; /* depth for "**" expansion */
|
||||
WIN32_FIND_DATA fb;
|
||||
HANDLE hFind = (HANDLE)0;
|
||||
# ifdef FEAT_MBYTE
|
||||
WIN32_FIND_DATAW wfb;
|
||||
WCHAR *wn = NULL; /* UCS-2 name, NULL when not used. */
|
||||
# endif
|
||||
char_u *matchname;
|
||||
int ok;
|
||||
|
||||
@@ -10170,8 +10094,8 @@ dos_expandpath(
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Make room for file name. When doing encoding conversion the actual
|
||||
* length may be quite a bit longer, thus use the maximum possible length. */
|
||||
// Make room for file name. When doing encoding conversion the actual
|
||||
// length may be quite a bit longer, thus use the maximum possible length.
|
||||
buf = alloc((int)MAXPATHL);
|
||||
if (buf == NULL)
|
||||
return 0;
|
||||
@@ -10199,7 +10123,6 @@ dos_expandpath(
|
||||
else if (path_end >= path + wildoff
|
||||
&& vim_strchr((char_u *)"*?[~", *path_end) != NULL)
|
||||
e = p;
|
||||
# ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
len = (*mb_ptr2len)(path_end);
|
||||
@@ -10208,7 +10131,6 @@ dos_expandpath(
|
||||
path_end += len;
|
||||
}
|
||||
else
|
||||
# endif
|
||||
*p++ = *path_end++;
|
||||
}
|
||||
e = p;
|
||||
@@ -10269,7 +10191,6 @@ dos_expandpath(
|
||||
|
||||
/* Scan all files in the directory with "dir/ *.*" */
|
||||
STRCPY(s, "*.*");
|
||||
# ifdef FEAT_MBYTE
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
{
|
||||
/* The active codepage differs from 'encoding'. Attempt using the
|
||||
@@ -10286,17 +10207,14 @@ dos_expandpath(
|
||||
}
|
||||
|
||||
if (wn == NULL)
|
||||
# endif
|
||||
hFind = FindFirstFile((LPCSTR)buf, &fb);
|
||||
ok = (hFind != INVALID_HANDLE_VALUE);
|
||||
|
||||
while (ok)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
if (wn != NULL)
|
||||
p = utf16_to_enc(wfb.cFileName, NULL); /* p is allocated here */
|
||||
else
|
||||
# endif
|
||||
p = (char_u *)fb.cFileName;
|
||||
/* Ignore entries starting with a dot, unless when asked for. Accept
|
||||
* all entries found with "matchname". */
|
||||
@@ -10341,14 +10259,12 @@ dos_expandpath(
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
if (wn != NULL)
|
||||
{
|
||||
vim_free(p);
|
||||
ok = FindNextFileW(hFind, &wfb);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
ok = FindNextFile(hFind, &fb);
|
||||
|
||||
/* If no more matches and no match was used, try expanding the name
|
||||
@@ -10357,7 +10273,6 @@ dos_expandpath(
|
||||
{
|
||||
STRCPY(s, matchname);
|
||||
FindClose(hFind);
|
||||
# ifdef FEAT_MBYTE
|
||||
if (wn != NULL)
|
||||
{
|
||||
vim_free(wn);
|
||||
@@ -10366,7 +10281,6 @@ dos_expandpath(
|
||||
hFind = FindFirstFileW(wn, &wfb);
|
||||
}
|
||||
if (wn == NULL)
|
||||
# endif
|
||||
hFind = FindFirstFile((LPCSTR)buf, &fb);
|
||||
ok = (hFind != INVALID_HANDLE_VALUE);
|
||||
VIM_CLEAR(matchname);
|
||||
@@ -10374,9 +10288,7 @@ dos_expandpath(
|
||||
}
|
||||
|
||||
FindClose(hFind);
|
||||
# ifdef FEAT_MBYTE
|
||||
vim_free(wn);
|
||||
# endif
|
||||
vim_free(buf);
|
||||
vim_regfree(regmatch.regprog);
|
||||
vim_free(matchname);
|
||||
@@ -10480,7 +10392,6 @@ unix_expandpath(
|
||||
|| (!p_fic && (flags & EW_ICASE)
|
||||
&& isalpha(PTR2CHAR(path_end)))))
|
||||
e = p;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
len = (*mb_ptr2len)(path_end);
|
||||
@@ -10489,7 +10400,6 @@ unix_expandpath(
|
||||
path_end += len;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
*p++ = *path_end++;
|
||||
}
|
||||
e = p;
|
||||
|
||||
53
src/misc2.c
53
src/misc2.c
@@ -73,7 +73,7 @@ coladvance_force(colnr_T wcol)
|
||||
* Get the screen position of character col with a coladd in the cursor line.
|
||||
*/
|
||||
int
|
||||
getviscol2(colnr_T col, colnr_T coladd)
|
||||
getviscol2(colnr_T col, colnr_T coladd UNUSED)
|
||||
{
|
||||
colnr_T x;
|
||||
pos_T pos;
|
||||
@@ -320,11 +320,9 @@ coladvance2(
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* prevent from moving onto a trail byte */
|
||||
if (has_mbyte)
|
||||
mb_adjustpos(curbuf, pos);
|
||||
#endif
|
||||
|
||||
if (col < wcol)
|
||||
return FAIL;
|
||||
@@ -358,7 +356,6 @@ inc(pos_T *lp)
|
||||
p = ml_get_pos(lp);
|
||||
if (*p != NUL) /* still within line, move to next char (may be NUL) */
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int l = (*mb_ptr2len)(p);
|
||||
@@ -366,7 +363,6 @@ inc(pos_T *lp)
|
||||
lp->col += l;
|
||||
return ((p[l] != NUL) ? 0 : 2);
|
||||
}
|
||||
#endif
|
||||
lp->col++;
|
||||
#ifdef FEAT_VIRTUALEDIT
|
||||
lp->coladd = 0;
|
||||
@@ -424,10 +420,8 @@ dec(pos_T *lp)
|
||||
/* past end of line */
|
||||
p = ml_get(lp->lnum);
|
||||
lp->col = (colnr_T)STRLEN(p);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
lp->col -= (*mb_head_off)(p, p + lp->col);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -435,13 +429,11 @@ dec(pos_T *lp)
|
||||
{
|
||||
/* still within line */
|
||||
lp->col--;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
p = ml_get(lp->lnum);
|
||||
lp->col -= (*mb_head_off)(p, p + lp->col);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -451,10 +443,8 @@ dec(pos_T *lp)
|
||||
lp->lnum--;
|
||||
p = ml_get(lp->lnum);
|
||||
lp->col = (colnr_T)STRLEN(p);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
lp->col -= (*mb_head_off)(p, p + lp->col);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -608,11 +598,9 @@ check_cursor_col_win(win_T *win)
|
||||
else
|
||||
{
|
||||
win->w_cursor.col = len - 1;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Move the cursor to the head byte. */
|
||||
if (has_mbyte)
|
||||
mb_adjustpos(win->w_buffer, &win->w_cursor);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (win->w_cursor.col < 0)
|
||||
@@ -1394,9 +1382,7 @@ vim_strsave_escaped_ext(
|
||||
char_u *p2;
|
||||
char_u *escaped_string;
|
||||
unsigned length;
|
||||
#ifdef FEAT_MBYTE
|
||||
int l;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* First count the number of backslashes required.
|
||||
@@ -1405,14 +1391,12 @@ vim_strsave_escaped_ext(
|
||||
length = 1; /* count the trailing NUL */
|
||||
for (p = string; *p; p++)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
{
|
||||
length += l; /* count a multibyte char */
|
||||
p += l - 1;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (vim_strchr(esc_chars, *p) != NULL || (bsl && rem_backslash(p)))
|
||||
++length; /* count a backslash */
|
||||
++length; /* count an ordinary char */
|
||||
@@ -1423,7 +1407,6 @@ vim_strsave_escaped_ext(
|
||||
p2 = escaped_string;
|
||||
for (p = string; *p; p++)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
{
|
||||
mch_memmove(p2, p, (size_t)l);
|
||||
@@ -1431,7 +1414,6 @@ vim_strsave_escaped_ext(
|
||||
p += l - 1; /* skip multibyte char */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (vim_strchr(esc_chars, *p) != NULL || (bsl && rem_backslash(p)))
|
||||
*p2++ = cc;
|
||||
*p2++ = *p;
|
||||
@@ -1642,7 +1624,6 @@ strup_save(char_u *orig)
|
||||
if (res != NULL)
|
||||
while (*p != NUL)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
int l;
|
||||
|
||||
if (enc_utf8)
|
||||
@@ -1685,7 +1666,6 @@ strup_save(char_u *orig)
|
||||
else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
p += l; /* skip multi-byte character */
|
||||
else
|
||||
# endif
|
||||
{
|
||||
*p = TOUPPER_LOC(*p); /* note that toupper() can be a macro */
|
||||
p++;
|
||||
@@ -1711,7 +1691,6 @@ strlow_save(char_u *orig)
|
||||
if (res != NULL)
|
||||
while (*p != NUL)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
int l;
|
||||
|
||||
if (enc_utf8)
|
||||
@@ -1754,7 +1733,6 @@ strlow_save(char_u *orig)
|
||||
else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
p += l; /* skip multi-byte character */
|
||||
else
|
||||
# endif
|
||||
{
|
||||
*p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */
|
||||
p++;
|
||||
@@ -1943,7 +1921,6 @@ vim_strchr(char_u *string, int c)
|
||||
int b;
|
||||
|
||||
p = string;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8 && c >= 0x80)
|
||||
{
|
||||
while (*p != NUL)
|
||||
@@ -1980,7 +1957,6 @@ vim_strchr(char_u *string, int c)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
while ((b = *p) != NUL)
|
||||
{
|
||||
if (b == c)
|
||||
@@ -2713,11 +2689,7 @@ get_special_key_name(int c, int modifiers)
|
||||
* When not a known special key, and not a printable character, try to
|
||||
* extract modifiers.
|
||||
*/
|
||||
if (c > 0
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (*mb_char2len)(c) == 1
|
||||
#endif
|
||||
)
|
||||
if (c > 0 && (*mb_char2len)(c) == 1)
|
||||
{
|
||||
if (table_idx < 0
|
||||
&& (!vim_isprintc(c) || (c & 0x7f) == ' ')
|
||||
@@ -2760,12 +2732,9 @@ get_special_key_name(int c, int modifiers)
|
||||
/* Not a special key, only modifiers, output directly */
|
||||
else
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && (*mb_char2len)(c) > 1)
|
||||
idx += (*mb_char2bytes)(c, string + idx);
|
||||
else
|
||||
#endif
|
||||
if (vim_isprintc(c))
|
||||
else if (vim_isprintc(c))
|
||||
string[idx++] = c;
|
||||
else
|
||||
{
|
||||
@@ -2825,10 +2794,8 @@ trans_special(
|
||||
dst[dlen++] = KEY2TERMCAP0(key);
|
||||
dst[dlen++] = KEY2TERMCAP1(key);
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
else if (has_mbyte && !keycode)
|
||||
dlen += (*mb_char2bytes)(key, dst + dlen);
|
||||
#endif
|
||||
else if (keycode)
|
||||
dlen = (int)(add_char2buf(key, dst + dlen) - dst);
|
||||
else
|
||||
@@ -2873,11 +2840,9 @@ find_special_key(
|
||||
last_dash = bp;
|
||||
if (bp[1] != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
l = mb_ptr2len(bp + 1);
|
||||
else
|
||||
#endif
|
||||
l = 1;
|
||||
/* Anything accepted, like <C-?>.
|
||||
* <C-"> or <M-"> are not special in strings as " is
|
||||
@@ -2935,11 +2900,9 @@ find_special_key(
|
||||
/* Modifier with single letter, or special key name. */
|
||||
if (in_string && last_dash[1] == '\\' && last_dash[2] == '"')
|
||||
off = 2;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
l = mb_ptr2len(last_dash + off);
|
||||
else
|
||||
#endif
|
||||
l = 1;
|
||||
if (modifiers != 0 && last_dash[l + off] == '>')
|
||||
key = PTR2CHAR(last_dash + off);
|
||||
@@ -3028,10 +2991,7 @@ extract_modifiers(int key, int *modp)
|
||||
if (!(modifiers & MOD_MASK_CMD))
|
||||
#endif
|
||||
if ((modifiers & MOD_MASK_ALT) && key < 0x80
|
||||
#ifdef FEAT_MBYTE
|
||||
&& !enc_dbcs /* avoid creating a lead byte */
|
||||
#endif
|
||||
)
|
||||
&& !enc_dbcs) // avoid creating a lead byte
|
||||
{
|
||||
key |= 0x80;
|
||||
modifiers &= ~MOD_MASK_ALT; /* remove the META modifier */
|
||||
@@ -3377,7 +3337,6 @@ get_real_state(void)
|
||||
return State;
|
||||
}
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
/*
|
||||
* Return TRUE if "p" points to just after a path separator.
|
||||
* Takes care of multi-byte characters.
|
||||
@@ -3389,7 +3348,6 @@ after_pathsep(char_u *b, char_u *p)
|
||||
return p > b && vim_ispathsep(p[-1])
|
||||
&& (!has_mbyte || (*mb_head_off)(b, p - 1) == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Return TRUE if file names "f1" and "f2" are in the same directory.
|
||||
@@ -6376,8 +6334,7 @@ time_to_bytes(time_T the_time, char_u *buf)
|
||||
|
||||
#endif
|
||||
|
||||
#if (defined(FEAT_MBYTE) && defined(FEAT_QUICKFIX)) \
|
||||
|| defined(FEAT_SPELL) || defined(PROTO)
|
||||
#if defined(FEAT_QUICKFIX) || defined(FEAT_SPELL) || defined(PROTO)
|
||||
/*
|
||||
* Return TRUE if string "s" contains a non-ASCII character (128 or higher).
|
||||
* When "s" is NULL FALSE is returned.
|
||||
|
||||
@@ -934,7 +934,7 @@ curwin_col_off2(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* compute curwin->w_wcol and curwin->w_virtcol.
|
||||
* Compute curwin->w_wcol and curwin->w_virtcol.
|
||||
* Also updates curwin->w_wrow and curwin->w_cline_row.
|
||||
* Also updates curwin->w_leftcol.
|
||||
*/
|
||||
@@ -2845,11 +2845,9 @@ do_check_cursorbind(void)
|
||||
validate_cursor();
|
||||
# endif
|
||||
restart_edit = restart_edit_save;
|
||||
# ifdef FEAT_MBYTE
|
||||
/* Correct cursor for multi-byte character. */
|
||||
if (has_mbyte)
|
||||
mb_adjust_cursor();
|
||||
# endif
|
||||
redraw_later(VALID);
|
||||
|
||||
/* Only scroll when 'scrollbind' hasn't done this. */
|
||||
|
||||
84
src/normal.c
84
src/normal.c
@@ -477,11 +477,9 @@ find_command(int cmdchar)
|
||||
int top, bot;
|
||||
int c;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* A multi-byte character is never a command. */
|
||||
if (cmdchar >= 0x100)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
/* We use the absolute value of the character. Special keys have a
|
||||
* negative value, but are sorted on their absolute value. */
|
||||
@@ -1036,7 +1034,6 @@ getcount:
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* When getting a text character and the next character is a
|
||||
* multi-byte character, it could be a composing character.
|
||||
* However, don't wait for it to arrive. Also, do enable mapping,
|
||||
@@ -1058,7 +1055,6 @@ getcount:
|
||||
ca.ncharC2 = c;
|
||||
}
|
||||
++no_mapping;
|
||||
#endif
|
||||
}
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
@@ -1255,10 +1251,8 @@ normal_end:
|
||||
checkpcmark(); /* check if we moved since setting pcmark */
|
||||
vim_free(ca.searchbuf);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
mb_adjust_cursor();
|
||||
#endif
|
||||
|
||||
if (curwin->w_p_scb && toplevel)
|
||||
{
|
||||
@@ -1745,7 +1739,6 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Include the trailing byte of a multi-byte char. */
|
||||
if (has_mbyte && oap->inclusive)
|
||||
{
|
||||
@@ -1755,7 +1748,6 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
|
||||
if (l > 1)
|
||||
oap->end.col += l - 1;
|
||||
}
|
||||
#endif
|
||||
curwin->w_set_curswant = TRUE;
|
||||
|
||||
/*
|
||||
@@ -3133,12 +3125,8 @@ do_mouse(
|
||||
{
|
||||
find_start_of_word(&VIsual);
|
||||
if (*p_sel == 'e' && *ml_get_cursor() != NUL)
|
||||
#ifdef FEAT_MBYTE
|
||||
curwin->w_cursor.col +=
|
||||
(*mb_ptr2len)(ml_get_cursor());
|
||||
#else
|
||||
++curwin->w_cursor.col;
|
||||
#endif
|
||||
find_end_of_word(&curwin->w_cursor);
|
||||
}
|
||||
}
|
||||
@@ -3180,9 +3168,7 @@ find_start_of_word(pos_T *pos)
|
||||
while (pos->col > 0)
|
||||
{
|
||||
col = pos->col - 1;
|
||||
#ifdef FEAT_MBYTE
|
||||
col -= (*mb_head_off)(line, line + col);
|
||||
#endif
|
||||
if (get_mouse_class(line + col) != cclass)
|
||||
break;
|
||||
pos->col = col;
|
||||
@@ -3204,18 +3190,12 @@ find_end_of_word(pos_T *pos)
|
||||
if (*p_sel == 'e' && pos->col > 0)
|
||||
{
|
||||
--pos->col;
|
||||
#ifdef FEAT_MBYTE
|
||||
pos->col -= (*mb_head_off)(line, line + pos->col);
|
||||
#endif
|
||||
}
|
||||
cclass = get_mouse_class(line + pos->col);
|
||||
while (line[pos->col] != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
col = pos->col + (*mb_ptr2len)(line + pos->col);
|
||||
#else
|
||||
col = pos->col + 1;
|
||||
#endif
|
||||
if (get_mouse_class(line + col) != cclass)
|
||||
{
|
||||
if (*p_sel == 'e')
|
||||
@@ -3238,10 +3218,8 @@ get_mouse_class(char_u *p)
|
||||
{
|
||||
int c;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && MB_BYTE2LEN(p[0]) > 1)
|
||||
return mb_get_class(p);
|
||||
#endif
|
||||
|
||||
c = *p;
|
||||
if (c == ' ' || c == '\t')
|
||||
@@ -3431,11 +3409,9 @@ find_ident_at_pos(
|
||||
char_u *ptr;
|
||||
int col = 0; /* init to shut up GCC */
|
||||
int i;
|
||||
#ifdef FEAT_MBYTE
|
||||
int this_class = 0;
|
||||
int prev_class;
|
||||
int prevcol;
|
||||
#endif
|
||||
int bn = 0; /* bracket nesting */
|
||||
|
||||
/*
|
||||
@@ -3449,7 +3425,6 @@ find_ident_at_pos(
|
||||
* 1. skip to start of identifier/string
|
||||
*/
|
||||
col = startcol;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
while (ptr[col] != NUL)
|
||||
@@ -3464,7 +3439,6 @@ find_ident_at_pos(
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
while (ptr[col] != NUL
|
||||
&& (i == 0 ? !vim_iswordc(ptr[col]) : VIM_ISWHITE(ptr[col]))
|
||||
&& (!(find_type & FIND_EVAL) || ptr[col] != ']')
|
||||
@@ -3477,7 +3451,6 @@ find_ident_at_pos(
|
||||
/*
|
||||
* 2. Back up to start of identifier/string.
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
/* Remember class of character under cursor. */
|
||||
@@ -3510,7 +3483,6 @@ find_ident_at_pos(
|
||||
break;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
while (col > 0
|
||||
&& ((i == 0
|
||||
@@ -3532,11 +3504,8 @@ find_ident_at_pos(
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr[col] == NUL || (i == 0 && (
|
||||
#ifdef FEAT_MBYTE
|
||||
has_mbyte ? this_class != 2 :
|
||||
#endif
|
||||
!vim_iswordc(ptr[col]))))
|
||||
if (ptr[col] == NUL || (i == 0
|
||||
&& (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col]))))
|
||||
{
|
||||
/*
|
||||
* didn't find an identifier or string
|
||||
@@ -3556,7 +3525,6 @@ find_ident_at_pos(
|
||||
bn = 0;
|
||||
startcol -= col;
|
||||
col = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
/* Search for point of changing multibyte character class. */
|
||||
@@ -3571,7 +3539,6 @@ find_ident_at_pos(
|
||||
col += (*mb_ptr2len)(ptr + col);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
while ((i == 0 ? vim_iswordc(ptr[col])
|
||||
: (ptr[col] != NUL && !VIM_ISWHITE(ptr[col])))
|
||||
|| ((find_type & FIND_EVAL)
|
||||
@@ -3787,11 +3754,7 @@ clear_showcmd(void)
|
||||
}
|
||||
while ((*p_sel != 'e') ? s <= e : s < e)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
l = (*mb_ptr2len)(s);
|
||||
# else
|
||||
l = (*s == NUL) ? 0 : 1;
|
||||
# endif
|
||||
if (l == 0)
|
||||
{
|
||||
++bytes;
|
||||
@@ -4558,7 +4521,6 @@ nv_screengo(oparg_T *oap, int dir, long dist)
|
||||
else
|
||||
coladvance(curwin->w_curswant);
|
||||
|
||||
#if defined(FEAT_LINEBREAK) || defined(FEAT_MBYTE)
|
||||
if (curwin->w_cursor.col > 0 && curwin->w_p_wrap)
|
||||
{
|
||||
colnr_T virtcol;
|
||||
@@ -4582,7 +4544,6 @@ nv_screengo(oparg_T *oap, int dir, long dist)
|
||||
> (colnr_T)width2 / 2)))
|
||||
--curwin->w_cursor.col;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (atend)
|
||||
curwin->w_curswant = MAXCOL; /* stick in the last column */
|
||||
@@ -5768,7 +5729,6 @@ nv_ident(cmdarg_T *cap)
|
||||
/* put a backslash before \ and some others */
|
||||
if (vim_strchr(aux_ptr, *ptr) != NULL)
|
||||
*p++ = '\\';
|
||||
#ifdef FEAT_MBYTE
|
||||
/* When current byte is a part of multibyte character, copy all
|
||||
* bytes of that character. */
|
||||
if (has_mbyte)
|
||||
@@ -5779,7 +5739,6 @@ nv_ident(cmdarg_T *cap)
|
||||
for (i = 0; i < len && n >= 1; ++i, --n)
|
||||
*p++ = *ptr++;
|
||||
}
|
||||
#endif
|
||||
*p++ = *ptr++;
|
||||
}
|
||||
*p = NUL;
|
||||
@@ -5790,11 +5749,9 @@ nv_ident(cmdarg_T *cap)
|
||||
*/
|
||||
if (cmdchar == '*' || cmdchar == '#')
|
||||
{
|
||||
if (!g_cmd && (
|
||||
#ifdef FEAT_MBYTE
|
||||
has_mbyte ? vim_iswordp(mb_prevptr(ml_get_curline(), ptr)) :
|
||||
#endif
|
||||
vim_iswordc(ptr[-1])))
|
||||
if (!g_cmd && (has_mbyte
|
||||
? vim_iswordp(mb_prevptr(ml_get_curline(), ptr))
|
||||
: vim_iswordc(ptr[-1])))
|
||||
STRCAT(buf, "\\>");
|
||||
#ifdef FEAT_CMDHIST
|
||||
/* put pattern in search history */
|
||||
@@ -5844,11 +5801,9 @@ get_visual_text(
|
||||
*pp = ml_get_pos(&VIsual);
|
||||
*lenp = curwin->w_cursor.col - VIsual.col + 1;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
/* Correct the length to include the whole last character. */
|
||||
*lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
|
||||
#endif
|
||||
}
|
||||
reset_VIsual_and_resel();
|
||||
return OK;
|
||||
@@ -6058,12 +6013,10 @@ nv_right(cmdarg_T *cap)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
curwin->w_cursor.col +=
|
||||
(*mb_ptr2len)(ml_get_cursor());
|
||||
else
|
||||
#endif
|
||||
++curwin->w_cursor.col;
|
||||
}
|
||||
}
|
||||
@@ -6129,11 +6082,9 @@ nv_left(cmdarg_T *cap)
|
||||
|
||||
if (*cp != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
curwin->w_cursor.col += (*mb_ptr2len)(cp);
|
||||
else
|
||||
#endif
|
||||
++curwin->w_cursor.col;
|
||||
}
|
||||
cap->retval |= CA_NO_ADJ_OP_END;
|
||||
@@ -7060,10 +7011,7 @@ nv_replace(cmdarg_T *cap)
|
||||
/* Abort if not enough characters to replace. */
|
||||
ptr = ml_get_cursor();
|
||||
if (STRLEN(ptr) < (unsigned)cap->count1
|
||||
#ifdef FEAT_MBYTE
|
||||
|| (has_mbyte && mb_charlen(ptr) < cap->count1)
|
||||
#endif
|
||||
)
|
||||
|| (has_mbyte && mb_charlen(ptr) < cap->count1))
|
||||
{
|
||||
clearopbeep(cap->oap);
|
||||
return;
|
||||
@@ -7098,11 +7046,7 @@ nv_replace(cmdarg_T *cap)
|
||||
* autoindent. The insert command depends on being on the last
|
||||
* character of a line or not.
|
||||
*/
|
||||
#ifdef FEAT_MBYTE
|
||||
(void)del_chars(cap->count1, FALSE); /* delete the characters */
|
||||
#else
|
||||
(void)del_bytes(cap->count1, FALSE, FALSE); /* delete the characters */
|
||||
#endif
|
||||
stuffcharReadbuff('\r');
|
||||
stuffcharReadbuff(ESC);
|
||||
|
||||
@@ -7115,7 +7059,6 @@ nv_replace(cmdarg_T *cap)
|
||||
NUL, 'r', NUL, had_ctrl_v, cap->nchar);
|
||||
|
||||
curbuf->b_op_start = curwin->w_cursor;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int old_State = State;
|
||||
@@ -7151,7 +7094,6 @@ nv_replace(cmdarg_T *cap)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
* Replace the characters within one line.
|
||||
@@ -7194,12 +7136,10 @@ nv_replace(cmdarg_T *cap)
|
||||
(colnr_T)(curwin->w_cursor.col - cap->count1));
|
||||
}
|
||||
--curwin->w_cursor.col; /* cursor on the last replaced char */
|
||||
#ifdef FEAT_MBYTE
|
||||
/* if the character on the left of the current cursor is a multi-byte
|
||||
* character, move two characters left */
|
||||
if (has_mbyte)
|
||||
mb_adjust_cursor();
|
||||
#endif
|
||||
curbuf->b_op_end = curwin->w_cursor;
|
||||
curwin->w_set_curswant = TRUE;
|
||||
set_last_insert(cap->nchar);
|
||||
@@ -8202,7 +8142,6 @@ nv_g_cmd(cmdarg_T *cap)
|
||||
validate_virtcol();
|
||||
curwin->w_curswant = curwin->w_virtcol;
|
||||
curwin->w_set_curswant = FALSE;
|
||||
#if defined(FEAT_LINEBREAK) || defined(FEAT_MBYTE)
|
||||
if (curwin->w_cursor.col > 0 && curwin->w_p_wrap)
|
||||
{
|
||||
/*
|
||||
@@ -8213,7 +8152,6 @@ nv_g_cmd(cmdarg_T *cap)
|
||||
if (curwin->w_virtcol > (colnr_T)i)
|
||||
--curwin->w_cursor.col;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == FAIL)
|
||||
clearopbeep(oap);
|
||||
@@ -8328,7 +8266,6 @@ nv_g_cmd(cmdarg_T *cap)
|
||||
do_ascii(NULL);
|
||||
break;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* "g8": Display the bytes used for the UTF-8 character under the
|
||||
* cursor. It is displayed in hex.
|
||||
@@ -8340,7 +8277,6 @@ nv_g_cmd(cmdarg_T *cap)
|
||||
else
|
||||
show_utf8();
|
||||
break;
|
||||
#endif
|
||||
|
||||
/* "g<": show scrollback text */
|
||||
case '<':
|
||||
@@ -8843,11 +8779,9 @@ adjust_cursor(oparg_T *oap)
|
||||
)
|
||||
{
|
||||
--curwin->w_cursor.col;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* prevent cursor from moving on the trail byte */
|
||||
if (has_mbyte)
|
||||
mb_adjust_cursor();
|
||||
#endif
|
||||
oap->inclusive = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -8879,11 +8813,9 @@ adjust_for_sel(cmdarg_T *cap)
|
||||
if (VIsual_active && cap->oap->inclusive && *p_sel == 'e'
|
||||
&& gchar_cursor() != NUL && LT_POS(VIsual, curwin->w_cursor))
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
inc_cursor();
|
||||
else
|
||||
#endif
|
||||
++curwin->w_cursor.col;
|
||||
cap->oap->inclusive = FALSE;
|
||||
}
|
||||
@@ -8913,9 +8845,7 @@ unadjust_for_sel(void)
|
||||
if (pp->col > 0)
|
||||
{
|
||||
--pp->col;
|
||||
#ifdef FEAT_MBYTE
|
||||
mb_adjustpos(curbuf, pp);
|
||||
#endif
|
||||
}
|
||||
else if (pp->lnum > 1)
|
||||
{
|
||||
@@ -9646,11 +9576,9 @@ get_op_vcol(
|
||||
|
||||
oap->block_mode = TRUE;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* prevent from moving onto a trail byte */
|
||||
if (has_mbyte)
|
||||
mb_adjustpos(curwin->w_buffer, &oap->end);
|
||||
#endif
|
||||
|
||||
getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol);
|
||||
|
||||
|
||||
100
src/ops.c
100
src/ops.c
@@ -97,9 +97,7 @@ static void put_reedit_in_typebuf(int silent);
|
||||
static int put_in_typebuf(char_u *s, int esc, int colon,
|
||||
int silent);
|
||||
static void stuffescaped(char_u *arg, int literally);
|
||||
#ifdef FEAT_MBYTE
|
||||
static void mb_adjust_opend(oparg_T *oap);
|
||||
#endif
|
||||
static void free_yank_all(void);
|
||||
static int yank_copy_line(struct block_def *bd, long y_idx);
|
||||
#ifdef FEAT_CLIPBOARD
|
||||
@@ -421,7 +419,6 @@ shift_block(oparg_T *oap, int amount)
|
||||
ws_vcol = bd.start_vcol - bd.pre_whitesp;
|
||||
if (bd.startspaces)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
if ((*mb_ptr2len)(bd.textstart) == 1)
|
||||
@@ -433,7 +430,6 @@ shift_block(oparg_T *oap, int amount)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
++bd.textstart;
|
||||
}
|
||||
for ( ; VIM_ISWHITE(*bd.textstart); )
|
||||
@@ -632,7 +628,6 @@ block_insert(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && spaces > 0)
|
||||
{
|
||||
int off;
|
||||
@@ -650,7 +645,6 @@ block_insert(
|
||||
spaces -= off;
|
||||
count -= off;
|
||||
}
|
||||
#endif
|
||||
|
||||
newp = alloc_check((unsigned)(STRLEN(oldp)) + s_len + count + 1);
|
||||
if (newp == NULL)
|
||||
@@ -1491,11 +1485,9 @@ stuffescaped(char_u *arg, int literally)
|
||||
/* stuff a single special character */
|
||||
if (*arg != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
c = mb_cptr2char_adv(&arg);
|
||||
else
|
||||
#endif
|
||||
c = *arg++;
|
||||
if (literally && ((c < ' ' && c != TAB) || c == DEL))
|
||||
stuffcharReadbuff(Ctrl_V);
|
||||
@@ -1774,10 +1766,8 @@ op_delete(oparg_T *oap)
|
||||
adjust_clip_reg(&oap->regname);
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
mb_adjust_opend(oap);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Imitate the strange Vi behaviour: If the delete spans more than one
|
||||
@@ -2109,7 +2099,6 @@ setmarks:
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Adjust end of operating area for ending on a multi-byte character.
|
||||
* Used for deletion.
|
||||
@@ -2125,10 +2114,7 @@ mb_adjust_opend(oparg_T *oap)
|
||||
oap->end.col += mb_tail_off(p, p + oap->end.col);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/*
|
||||
* Replace the character under the cursor with "c".
|
||||
* This takes care of multi-byte characters.
|
||||
@@ -2144,7 +2130,6 @@ replace_character(int c)
|
||||
/* Backup to the replaced character. */
|
||||
dec_cursor();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Replace a whole area with one character.
|
||||
@@ -2153,9 +2138,7 @@ replace_character(int c)
|
||||
op_replace(oparg_T *oap, int c)
|
||||
{
|
||||
int n, numc;
|
||||
#ifdef FEAT_MBYTE
|
||||
int num_chars;
|
||||
#endif
|
||||
char_u *newp, *oldp;
|
||||
size_t oldlen;
|
||||
struct block_def bd;
|
||||
@@ -2176,10 +2159,8 @@ op_replace(oparg_T *oap, int c)
|
||||
c = NL;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
mb_adjust_opend(oap);
|
||||
#endif
|
||||
|
||||
if (u_save((linenr_T)(oap->start.lnum - 1),
|
||||
(linenr_T)(oap->end.lnum + 1)) == FAIL)
|
||||
@@ -2230,7 +2211,6 @@ op_replace(oparg_T *oap, int c)
|
||||
if (bd.is_short && (!virtual_op || bd.is_MAX))
|
||||
numc -= (oap->end_vcol - bd.end_vcol) + 1;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* A double-wide character can be replaced only up to half the
|
||||
* times. */
|
||||
if ((*mb_char2cells)(c) > 1)
|
||||
@@ -2246,7 +2226,6 @@ op_replace(oparg_T *oap, int c)
|
||||
/* Compute bytes needed, move character count to num_chars. */
|
||||
num_chars = numc;
|
||||
numc *= (*mb_char2len)(c);
|
||||
#endif
|
||||
/* oldlen includes textlen, so don't double count */
|
||||
n += numc - bd.textlen;
|
||||
|
||||
@@ -2266,7 +2245,6 @@ op_replace(oparg_T *oap, int c)
|
||||
* literally. */
|
||||
if (had_ctrl_v_cr || (c != '\r' && c != '\n'))
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
n = (int)STRLEN(newp);
|
||||
@@ -2274,7 +2252,6 @@ op_replace(oparg_T *oap, int c)
|
||||
n += (*mb_char2bytes)(c, newp + n);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
vim_memset(newp + STRLEN(newp), c, (size_t)numc);
|
||||
if (!bd.is_short)
|
||||
{
|
||||
@@ -2324,7 +2301,6 @@ op_replace(oparg_T *oap, int c)
|
||||
n = gchar_cursor();
|
||||
if (n != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if ((*mb_char2len)(c) > 1 || (*mb_char2len)(n) > 1)
|
||||
{
|
||||
/* This is slow, but it handles replacing a single-byte
|
||||
@@ -2334,7 +2310,6 @@ op_replace(oparg_T *oap, int c)
|
||||
replace_character(c);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef FEAT_VIRTUALEDIT
|
||||
if (n == TAB)
|
||||
@@ -2372,11 +2347,9 @@ op_replace(oparg_T *oap, int c)
|
||||
curwin->w_cursor.col -= (virtcols + 1);
|
||||
for (; virtcols >= 0; virtcols--)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
if ((*mb_char2len)(c) > 1)
|
||||
replace_character(c);
|
||||
else
|
||||
# endif
|
||||
PBYTE(curwin->w_cursor, c);
|
||||
if (inc(&curwin->w_cursor) == -1)
|
||||
break;
|
||||
@@ -2530,7 +2503,6 @@ swapchars(int op_type, pos_T *pos, int length)
|
||||
|
||||
for (todo = length; todo > 0; --todo)
|
||||
{
|
||||
# ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int len = (*mb_ptr2len)(ml_get_pos(pos));
|
||||
@@ -2539,7 +2511,6 @@ swapchars(int op_type, pos_T *pos, int length)
|
||||
if (len > 0)
|
||||
todo -= len - 1;
|
||||
}
|
||||
# endif
|
||||
did_change |= swapchar(op_type, pos);
|
||||
if (inc(pos) == -1) /* at end of file */
|
||||
break;
|
||||
@@ -2566,7 +2537,6 @@ swapchar(int op_type, pos_T *pos)
|
||||
if (c >= 0x80 && op_type == OP_ROT13)
|
||||
return FALSE;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (op_type == OP_UPPER && c == 0xdf
|
||||
&& (enc_latin1like || STRCMP(p_enc, "iso-8859-2") == 0))
|
||||
{
|
||||
@@ -2583,7 +2553,6 @@ swapchar(int op_type, pos_T *pos)
|
||||
|
||||
if (enc_dbcs != 0 && c >= 0x100) /* No lower/uppercase letter */
|
||||
return FALSE;
|
||||
#endif
|
||||
nc = c;
|
||||
if (MB_ISLOWER(c))
|
||||
{
|
||||
@@ -2601,7 +2570,6 @@ swapchar(int op_type, pos_T *pos)
|
||||
}
|
||||
if (nc != c)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (enc_utf8 && (c >= 0x80 || nc >= 0x80))
|
||||
{
|
||||
pos_T sp = curwin->w_cursor;
|
||||
@@ -2613,7 +2581,6 @@ swapchar(int op_type, pos_T *pos)
|
||||
curwin->w_cursor = sp;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
PBYTE(*pos, nc);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -3216,13 +3183,10 @@ op_yank(oparg_T *oap, int deleting, int mess)
|
||||
{
|
||||
getvcol(curwin, &oap->end, &cs, NULL, &ce);
|
||||
if (p[endcol] == NUL || (cs + oap->end.coladd < ce
|
||||
# ifdef FEAT_MBYTE
|
||||
/* Don't add space for double-wide
|
||||
* char; endcol will be on last byte
|
||||
* of multi-byte char. */
|
||||
&& (*mb_head_off)(p, p + endcol) == 0
|
||||
# endif
|
||||
))
|
||||
&& (*mb_head_off)(p, p + endcol) == 0))
|
||||
{
|
||||
if (oap->start.lnum == oap->end.lnum
|
||||
&& oap->start.col == oap->end.col)
|
||||
@@ -3745,12 +3709,10 @@ do_put(
|
||||
#endif
|
||||
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
/* move to start of next multi-byte character */
|
||||
curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
|
||||
else
|
||||
#endif
|
||||
#ifdef FEAT_VIRTUALEDIT
|
||||
if (c != TAB || ve_flags != VE_ALL)
|
||||
#endif
|
||||
@@ -3820,10 +3782,8 @@ do_put(
|
||||
bd.startspaces = incr - bd.endspaces;
|
||||
--bd.textcol;
|
||||
delcount = 1;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
bd.textcol -= (*mb_head_off)(oldp, oldp + bd.textcol);
|
||||
#endif
|
||||
if (oldp[bd.textcol] != TAB)
|
||||
{
|
||||
/* Only a Tab can be split into spaces. Other
|
||||
@@ -3919,7 +3879,6 @@ do_put(
|
||||
* char */
|
||||
if (dir == FORWARD && gchar_cursor() != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int bytelen = (*mb_ptr2len)(ml_get_cursor());
|
||||
@@ -3933,7 +3892,6 @@ do_put(
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
++col;
|
||||
if (yanklen)
|
||||
@@ -4279,11 +4237,7 @@ ex_display(exarg_T *eap)
|
||||
int name;
|
||||
int attr;
|
||||
char_u *arg = eap->arg;
|
||||
#ifdef FEAT_MBYTE
|
||||
int clen;
|
||||
#else
|
||||
# define clen 1
|
||||
#endif
|
||||
|
||||
if (arg != NULL && *arg == NUL)
|
||||
arg = NULL;
|
||||
@@ -4344,13 +4298,9 @@ ex_display(exarg_T *eap)
|
||||
}
|
||||
for (p = yb->y_array[j]; *p && (n -= ptr2cells(p)) >= 0; ++p)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
clen = (*mb_ptr2len)(p);
|
||||
#endif
|
||||
msg_outtrans_len(p, clen);
|
||||
#ifdef FEAT_MBYTE
|
||||
p += clen - 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (n > 1 && yb->y_type == MLINE)
|
||||
@@ -4438,23 +4388,19 @@ dis_msg(
|
||||
int skip_esc) /* if TRUE, ignore trailing ESC */
|
||||
{
|
||||
int n;
|
||||
#ifdef FEAT_MBYTE
|
||||
int l;
|
||||
#endif
|
||||
|
||||
n = (int)Columns - 6;
|
||||
while (*p != NUL
|
||||
&& !(*p == ESC && skip_esc && *(p + 1) == NUL)
|
||||
&& (n -= ptr2cells(p)) >= 0)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
{
|
||||
msg_outtrans_len(p, l);
|
||||
p += l;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
msg_outtrans_len(p++, 1);
|
||||
}
|
||||
ui_breakcheck();
|
||||
@@ -4631,12 +4577,10 @@ do_join(
|
||||
{
|
||||
curr = skipwhite(curr);
|
||||
if (*curr != ')' && currsize != 0 && endcurr1 != TAB
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (!has_format_option(FO_MBYTE_JOIN)
|
||||
|| (mb_ptr2char(curr) < 0x100 && endcurr1 < 0x100))
|
||||
&& (!has_format_option(FO_MBYTE_JOIN2)
|
||||
|| mb_ptr2char(curr) < 0x100 || endcurr1 < 0x100)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
/* don't add a space if the line is ending in a space */
|
||||
@@ -4657,7 +4601,6 @@ do_join(
|
||||
endcurr1 = endcurr2 = NUL;
|
||||
if (insert_space && currsize > 0)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
cend = curr + currsize;
|
||||
@@ -4670,7 +4613,6 @@ do_join(
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
endcurr1 = *(curr + currsize - 1);
|
||||
if (currsize > 1)
|
||||
@@ -5715,20 +5657,16 @@ do_addsub(
|
||||
while (col > 0 && vim_isbdigit(ptr[col]))
|
||||
{
|
||||
--col;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
col -= (*mb_head_off)(ptr, ptr + col);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (dohex)
|
||||
while (col > 0 && vim_isxdigit(ptr[col]))
|
||||
{
|
||||
--col;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
col -= (*mb_head_off)(ptr, ptr + col);
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( dobin
|
||||
@@ -5737,10 +5675,8 @@ do_addsub(
|
||||
&& (ptr[col] == 'X'
|
||||
|| ptr[col] == 'x')
|
||||
&& ptr[col - 1] == '0'
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (!has_mbyte ||
|
||||
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||
#endif
|
||||
&& vim_isxdigit(ptr[col + 1]))))
|
||||
{
|
||||
|
||||
@@ -5751,10 +5687,8 @@ do_addsub(
|
||||
while (col > 0 && vim_isdigit(ptr[col]))
|
||||
{
|
||||
col--;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
col -= (*mb_head_off)(ptr, ptr + col);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5763,28 +5697,22 @@ do_addsub(
|
||||
&& (ptr[col] == 'X'
|
||||
|| ptr[col] == 'x')
|
||||
&& ptr[col - 1] == '0'
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (!has_mbyte ||
|
||||
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||
#endif
|
||||
&& vim_isxdigit(ptr[col + 1])) ||
|
||||
( dobin
|
||||
&& col > 0
|
||||
&& (ptr[col] == 'B'
|
||||
|| ptr[col] == 'b')
|
||||
&& ptr[col - 1] == '0'
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (!has_mbyte ||
|
||||
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||
#endif
|
||||
&& vim_isbdigit(ptr[col + 1])))
|
||||
{
|
||||
/* Found hexadecimal or binary number, move to its start. */
|
||||
--col;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
col -= (*mb_head_off)(ptr, ptr + col);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5803,10 +5731,8 @@ do_addsub(
|
||||
&& !(doalp && ASCII_ISALPHA(ptr[col])))
|
||||
{
|
||||
--col;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
col -= (*mb_head_off)(ptr, ptr + col);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5827,11 +5753,7 @@ do_addsub(
|
||||
goto theend;
|
||||
|
||||
if (col > pos->col && ptr[col - 1] == '-'
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (!has_mbyte ||
|
||||
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||
#endif
|
||||
)
|
||||
&& (!has_mbyte || !(*mb_head_off)(ptr, ptr + col - 1)))
|
||||
{
|
||||
negative = TRUE;
|
||||
was_positive = FALSE;
|
||||
@@ -5895,10 +5817,8 @@ do_addsub(
|
||||
else
|
||||
{
|
||||
if (col > 0 && ptr[col - 1] == '-'
|
||||
#ifdef FEAT_MBYTE
|
||||
&& (!has_mbyte ||
|
||||
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||
#endif
|
||||
&& !visual)
|
||||
{
|
||||
/* negative number */
|
||||
@@ -6539,7 +6459,6 @@ x11_export_final_selection(void)
|
||||
if (dpy != NULL && str != NULL && motion_type >= 0
|
||||
&& len < 1024*1024 && len > 0)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
int ok = TRUE;
|
||||
|
||||
/* The CUT_BUFFER0 is supposed to always contain latin1. Convert from
|
||||
@@ -6579,7 +6498,6 @@ x11_export_final_selection(void)
|
||||
/* Do not store the string if conversion failed. Better to use any
|
||||
* other selection than garbled text. */
|
||||
if (ok)
|
||||
#endif
|
||||
{
|
||||
XStoreBuffer(dpy, (char *)str, (int)len, 0);
|
||||
XFlush(dpy);
|
||||
@@ -7349,11 +7267,7 @@ line_count_info(
|
||||
else if (!vim_isspace(line[i]))
|
||||
is_word = 1;
|
||||
++chars;
|
||||
#ifdef FEAT_MBYTE
|
||||
i += (*mb_ptr2len)(line + i);
|
||||
#else
|
||||
++i;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (is_word)
|
||||
@@ -7384,9 +7298,7 @@ cursor_pos_info(dict_T *dict)
|
||||
char_u buf2[40];
|
||||
linenr_T lnum;
|
||||
varnumber_T byte_count = 0;
|
||||
#ifdef FEAT_MBYTE
|
||||
varnumber_T bom_count = 0;
|
||||
#endif
|
||||
varnumber_T byte_count_cursor = 0;
|
||||
varnumber_T char_count = 0;
|
||||
varnumber_T char_count_cursor = 0;
|
||||
@@ -7609,12 +7521,10 @@ cursor_pos_info(dict_T *dict)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
bom_count = bomb_size();
|
||||
if (bom_count > 0)
|
||||
vim_snprintf((char *)IObuff + STRLEN(IObuff), IOSIZE,
|
||||
_("(+%lld for BOM)"), (long_long_T)bom_count);
|
||||
#endif
|
||||
if (dict == NULL)
|
||||
{
|
||||
/* Don't shorten this message, the user asked for it. */
|
||||
@@ -7629,11 +7539,7 @@ cursor_pos_info(dict_T *dict)
|
||||
{
|
||||
dict_add_number(dict, "words", word_count);
|
||||
dict_add_number(dict, "chars", char_count);
|
||||
dict_add_number(dict, "bytes", byte_count
|
||||
# ifdef FEAT_MBYTE
|
||||
+ bom_count
|
||||
# endif
|
||||
);
|
||||
dict_add_number(dict, "bytes", byte_count + bom_count);
|
||||
dict_add_number(dict, VIsual_active ? "visual_bytes" : "cursor_bytes",
|
||||
byte_count_cursor);
|
||||
dict_add_number(dict, VIsual_active ? "visual_chars" : "cursor_chars",
|
||||
|
||||
194
src/option.c
194
src/option.c
@@ -66,9 +66,7 @@
|
||||
#endif
|
||||
#define PV_BIN OPT_BUF(BV_BIN)
|
||||
#define PV_BL OPT_BUF(BV_BL)
|
||||
#ifdef FEAT_MBYTE
|
||||
#define PV_BOMB OPT_BUF(BV_BOMB)
|
||||
#endif
|
||||
#define PV_CI OPT_BUF(BV_CI)
|
||||
#ifdef FEAT_CINDENT
|
||||
# define PV_CIN OPT_BUF(BV_CIN)
|
||||
@@ -101,9 +99,7 @@
|
||||
#define PV_FIXEOL OPT_BUF(BV_FIXEOL)
|
||||
#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
|
||||
#define PV_ET OPT_BUF(BV_ET)
|
||||
#ifdef FEAT_MBYTE
|
||||
#define PV_FENC OPT_BUF(BV_FENC)
|
||||
#endif
|
||||
#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
|
||||
# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
|
||||
#endif
|
||||
@@ -137,9 +133,7 @@
|
||||
# define PV_LISP OPT_BUF(BV_LISP)
|
||||
# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
#define PV_MENC OPT_BOTH(OPT_BUF(BV_MENC))
|
||||
#endif
|
||||
#define PV_MA OPT_BUF(BV_MA)
|
||||
#define PV_ML OPT_BUF(BV_ML)
|
||||
#define PV_MOD OPT_BUF(BV_MOD)
|
||||
@@ -281,9 +275,7 @@ typedef enum
|
||||
*/
|
||||
static int p_ai;
|
||||
static int p_bin;
|
||||
#ifdef FEAT_MBYTE
|
||||
static int p_bomb;
|
||||
#endif
|
||||
static char_u *p_bh;
|
||||
static char_u *p_bt;
|
||||
static int p_bl;
|
||||
@@ -312,9 +304,7 @@ static char_u *p_ofu;
|
||||
static int p_eol;
|
||||
static int p_fixeol;
|
||||
static int p_et;
|
||||
#ifdef FEAT_MBYTE
|
||||
static char_u *p_fenc;
|
||||
#endif
|
||||
static char_u *p_ff;
|
||||
static char_u *p_fo;
|
||||
static char_u *p_flp;
|
||||
@@ -554,13 +544,8 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
|
||||
{"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
|
||||
#if defined(FEAT_MBYTE)
|
||||
(char_u *)&p_ambw, PV_NONE,
|
||||
{(char_u *)"single", (char_u *)0L}
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"autochdir", "acd", P_BOOL|P_VI_DEF,
|
||||
#ifdef FEAT_AUTOCHDIR
|
||||
@@ -680,11 +665,7 @@ static struct vimoption options[] =
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
|
||||
{"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_bomb, PV_BOMB,
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
#endif
|
||||
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
|
||||
{"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
|
||||
#ifdef FEAT_LINEBREAK
|
||||
@@ -736,13 +717,8 @@ static struct vimoption options[] =
|
||||
{(char_u *)"", (char_u *)0L}
|
||||
SCTX_INIT},
|
||||
{"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_cmp, PV_NONE,
|
||||
{(char_u *)"internal,keepascii", (char_u *)0L}
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
|
||||
#ifdef FEAT_SEARCHPATH
|
||||
@@ -763,7 +739,7 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
|
||||
#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
|
||||
#if defined(FEAT_EVAL)
|
||||
(char_u *)&p_ccv, PV_NONE,
|
||||
{(char_u *)"", (char_u *)0L}
|
||||
#else
|
||||
@@ -1016,11 +992,7 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_deco, PV_NONE,
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
#endif
|
||||
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
|
||||
{"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
|
||||
#ifdef FEAT_INS_EXPAND
|
||||
@@ -1077,22 +1049,12 @@ static struct vimoption options[] =
|
||||
(char_u *)&p_ed, PV_NONE,
|
||||
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
|
||||
{"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
|
||||
#if defined(FEAT_MBYTE)
|
||||
(char_u *)&p_emoji, PV_NONE,
|
||||
{(char_u *)TRUE, (char_u *)0L}
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_enc, PV_NONE,
|
||||
{(char_u *)ENC_DFLT, (char_u *)0L}
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
|
||||
(char_u *)&p_eol, PV_EOL,
|
||||
@@ -1138,22 +1100,12 @@ static struct vimoption options[] =
|
||||
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
|
||||
{"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
|
||||
|P_NO_MKRC,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_fenc, PV_FENC,
|
||||
{(char_u *)"", (char_u *)0L}
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_fencs, PV_NONE,
|
||||
{(char_u *)"ucs-bom", (char_u *)0L}
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
|
||||
|P_CURSWANT,
|
||||
@@ -1416,7 +1368,7 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
|
||||
#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
|
||||
#if defined(FEAT_GUI)
|
||||
(char_u *)&p_guifontwide, PV_NONE,
|
||||
{(char_u *)"", (char_u *)0L}
|
||||
#else
|
||||
@@ -1533,7 +1485,7 @@ static struct vimoption options[] =
|
||||
(char_u *)&p_ic, PV_NONE,
|
||||
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
|
||||
{"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
|
||||
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
|
||||
#if defined(FEAT_EVAL)
|
||||
(char_u *)&p_imaf, PV_NONE,
|
||||
{(char_u *)"", (char_u *)NULL}
|
||||
# else
|
||||
@@ -1549,18 +1501,10 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
{(char_u *)"", (char_u *)0L} SCTX_INIT},
|
||||
{"imcmdline", "imc", P_BOOL|P_VI_DEF,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_imcmdline, PV_NONE,
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
#endif
|
||||
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
|
||||
{"imdisable", "imd", P_BOOL|P_VI_DEF,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_imdisable, PV_NONE,
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
#endif
|
||||
#ifdef __sgi
|
||||
{(char_u *)TRUE, (char_u *)0L}
|
||||
#else
|
||||
@@ -1576,7 +1520,7 @@ static struct vimoption options[] =
|
||||
{(char_u *)B_IMODE_USE_INSERT, (char_u *)0L}
|
||||
SCTX_INIT},
|
||||
{"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
|
||||
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
|
||||
#if defined(FEAT_EVAL)
|
||||
(char_u *)&p_imsf, PV_NONE,
|
||||
{(char_u *)"", (char_u *)NULL}
|
||||
#else
|
||||
@@ -1872,13 +1816,8 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"makeencoding","menc", P_STRING|P_VI_DEF,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_menc, PV_MENC,
|
||||
{(char_u *)"", (char_u *)0L}
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
|
||||
#ifdef FEAT_QUICKFIX
|
||||
@@ -1901,11 +1840,7 @@ static struct vimoption options[] =
|
||||
(char_u *)&p_mat, PV_NONE,
|
||||
{(char_u *)5L, (char_u *)0L} SCTX_INIT},
|
||||
{"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_mco, PV_NONE,
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
#endif
|
||||
{(char_u *)2, (char_u *)0L} SCTX_INIT},
|
||||
{"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
|
||||
#ifdef FEAT_EVAL
|
||||
@@ -2197,7 +2132,7 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
|
||||
#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
|
||||
#if defined(FEAT_POSTSCRIPT)
|
||||
(char_u *)&p_pmcs, PV_NONE,
|
||||
{(char_u *)"", (char_u *)0L}
|
||||
#else
|
||||
@@ -2206,7 +2141,7 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
|
||||
#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
|
||||
#if defined(FEAT_POSTSCRIPT)
|
||||
(char_u *)&p_pmfn, PV_NONE,
|
||||
{(char_u *)"", (char_u *)0L}
|
||||
#else
|
||||
@@ -2748,13 +2683,8 @@ static struct vimoption options[] =
|
||||
#endif
|
||||
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
|
||||
{"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
|
||||
#ifdef FEAT_MBYTE
|
||||
(char_u *)&p_tenc, PV_NONE,
|
||||
{(char_u *)"", (char_u *)0L}
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)0L, (char_u *)0L}
|
||||
#endif
|
||||
SCTX_INIT},
|
||||
{"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
|
||||
#ifdef FEAT_TERMGUICOLORS
|
||||
@@ -3238,9 +3168,7 @@ static struct vimoption options[] =
|
||||
|
||||
#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
static char *(p_ambw_values[]) = {"single", "double", NULL};
|
||||
#endif
|
||||
static char *(p_bg_values[]) = {"light", "dark", NULL};
|
||||
static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
|
||||
static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
|
||||
@@ -3643,7 +3571,6 @@ set_init_1(int clean_arg)
|
||||
|
||||
didset_options2();
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
# if defined(WIN3264) && defined(FEAT_GETTEXT)
|
||||
/*
|
||||
* If $LANG isn't set, try to get a good value for it. This makes the
|
||||
@@ -3751,7 +3678,7 @@ set_init_1(int clean_arg)
|
||||
p_tenc = empty_option;
|
||||
}
|
||||
#endif
|
||||
# if defined(WIN3264) && defined(FEAT_MBYTE)
|
||||
#if defined(WIN3264)
|
||||
/* $HOME may have characters in active code page. */
|
||||
init_homedir();
|
||||
#endif
|
||||
@@ -3762,7 +3689,6 @@ set_init_1(int clean_arg)
|
||||
p_enc = save_enc;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
/* Set the default for 'helplang'. */
|
||||
@@ -3859,19 +3785,13 @@ set_options_default(
|
||||
|
||||
for (i = 0; !istermoption(&options[i]); i++)
|
||||
if (!(options[i].flags & P_NODEFAULT)
|
||||
#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
|
||||
&& (opt_flags == 0
|
||||
|| (TRUE
|
||||
# if defined(FEAT_MBYTE)
|
||||
&& options[i].var != (char_u *)&p_enc
|
||||
# endif
|
||||
|| (options[i].var != (char_u *)&p_enc
|
||||
# if defined(FEAT_CRYPT)
|
||||
&& options[i].var != (char_u *)&p_cm
|
||||
&& options[i].var != (char_u *)&p_key
|
||||
# endif
|
||||
))
|
||||
#endif
|
||||
)
|
||||
)))
|
||||
set_option_default(i, opt_flags, p_cp);
|
||||
|
||||
/* The 'scroll' option must be computed for all windows. */
|
||||
@@ -5018,7 +4938,6 @@ do_set(
|
||||
#endif
|
||||
)
|
||||
++arg; /* remove backslash */
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte
|
||||
&& (i = (*mb_ptr2len)(arg)) > 1)
|
||||
{
|
||||
@@ -5028,7 +4947,6 @@ do_set(
|
||||
s += i;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
*s++ = *arg++;
|
||||
}
|
||||
*s = NUL;
|
||||
@@ -5596,9 +5514,7 @@ didset_options(void)
|
||||
/* initialize the table for 'iskeyword' et.al. */
|
||||
(void)init_chartab();
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
(void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
|
||||
#endif
|
||||
(void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
|
||||
(void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
|
||||
#ifdef FEAT_SESSION
|
||||
@@ -5689,9 +5605,7 @@ check_buf_options(buf_T *buf)
|
||||
{
|
||||
check_string_option(&buf->b_p_bh);
|
||||
check_string_option(&buf->b_p_bt);
|
||||
#ifdef FEAT_MBYTE
|
||||
check_string_option(&buf->b_p_fenc);
|
||||
#endif
|
||||
check_string_option(&buf->b_p_ff);
|
||||
#ifdef FEAT_FIND_ID
|
||||
check_string_option(&buf->b_p_def);
|
||||
@@ -5780,9 +5694,7 @@ check_buf_options(buf_T *buf)
|
||||
check_string_option(&buf->b_p_lw);
|
||||
#endif
|
||||
check_string_option(&buf->b_p_bkc);
|
||||
#ifdef FEAT_MBYTE
|
||||
check_string_option(&buf->b_p_menc);
|
||||
#endif
|
||||
#ifdef FEAT_VARTABS
|
||||
check_string_option(&buf->b_p_vsts);
|
||||
check_string_option(&buf->b_p_vts);
|
||||
@@ -6318,7 +6230,6 @@ did_set_string_option(
|
||||
}
|
||||
|
||||
/* 'ambiwidth' */
|
||||
#ifdef FEAT_MBYTE
|
||||
else if (varp == &p_ambw || varp == &p_emoji)
|
||||
{
|
||||
if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
|
||||
@@ -6328,7 +6239,6 @@ did_set_string_option(
|
||||
else if (set_chars_option(&p_fcs) != NULL)
|
||||
errmsg = _("E835: Conflicts with value of 'fillchars'");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 'background' */
|
||||
else if (varp == &p_bg)
|
||||
@@ -6404,7 +6314,6 @@ did_set_string_option(
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
|
||||
else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
|
||||
|| gvarp == &p_menc)
|
||||
@@ -6477,14 +6386,13 @@ did_set_string_option(
|
||||
}
|
||||
}
|
||||
|
||||
# if defined(WIN3264) && defined(FEAT_MBYTE)
|
||||
#if defined(WIN3264)
|
||||
/* $HOME may have characters in active code page. */
|
||||
if (varp == &p_enc)
|
||||
init_homedir();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_POSTSCRIPT)
|
||||
else if (varp == &p_penc)
|
||||
@@ -6684,7 +6592,6 @@ did_set_string_option(
|
||||
/* 'matchpairs' */
|
||||
else if (gvarp == &p_mps)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
for (p = *varp; *p != NUL; ++p)
|
||||
@@ -6711,7 +6618,6 @@ did_set_string_option(
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Check for "x:y,x:y" */
|
||||
for (p = *varp; *p != NUL; p += 4)
|
||||
@@ -6971,7 +6877,6 @@ did_set_string_option(
|
||||
redraw_gui_only = TRUE;
|
||||
}
|
||||
# endif
|
||||
# ifdef FEAT_MBYTE
|
||||
else if (varp == &p_guifontwide)
|
||||
{
|
||||
if (STRCMP(p_guifontwide, "*") == 0)
|
||||
@@ -6981,7 +6886,6 @@ did_set_string_option(
|
||||
redraw_gui_only = TRUE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CURSOR_SHAPE
|
||||
/* 'guicursor' */
|
||||
@@ -7001,7 +6905,7 @@ did_set_string_option(
|
||||
#ifdef FEAT_PRINTER
|
||||
else if (varp == &p_popt)
|
||||
errmsg = parse_printoptions();
|
||||
# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
|
||||
# if defined(FEAT_POSTSCRIPT)
|
||||
else if (varp == &p_pmfn)
|
||||
errmsg = parse_printmbfont();
|
||||
# endif
|
||||
@@ -7395,14 +7299,12 @@ did_set_string_option(
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* 'casemap' */
|
||||
else if (varp == &p_cmp)
|
||||
{
|
||||
if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_DIFF
|
||||
/* 'diffopt' */
|
||||
@@ -8022,33 +7924,21 @@ set_chars_option(char_u **varp)
|
||||
{
|
||||
c1 = c2 = c3 = 0;
|
||||
s = p + len + 1;
|
||||
#ifdef FEAT_MBYTE
|
||||
c1 = mb_ptr2char_adv(&s);
|
||||
if (mb_char2cells(c1) > 1)
|
||||
continue;
|
||||
#else
|
||||
c1 = *s++;
|
||||
#endif
|
||||
if (tab[i].cp == &lcs_tab2)
|
||||
{
|
||||
if (*s == NUL)
|
||||
continue;
|
||||
#ifdef FEAT_MBYTE
|
||||
c2 = mb_ptr2char_adv(&s);
|
||||
if (mb_char2cells(c2) > 1)
|
||||
continue;
|
||||
#else
|
||||
c2 = *s++;
|
||||
#endif
|
||||
if (!(*s == ',' || *s == NUL))
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
c3 = mb_ptr2char_adv(&s);
|
||||
if (mb_char2cells(c3) > 1)
|
||||
continue;
|
||||
#else
|
||||
c3 = *s++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8506,13 +8396,11 @@ set_bool_option(
|
||||
{
|
||||
redraw_titles();
|
||||
}
|
||||
# ifdef FEAT_MBYTE
|
||||
/* when 'bomb' is changed, redraw the window title and tab page text */
|
||||
else if ((int *)varp == &curbuf->b_p_bomb)
|
||||
{
|
||||
redraw_titles();
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* when 'bin' is set also set some other options */
|
||||
@@ -8891,10 +8779,8 @@ set_bool_option(
|
||||
#endif
|
||||
}
|
||||
|
||||
# ifdef FEAT_MBYTE
|
||||
/* set 'delcombine' */
|
||||
p_deco = TRUE;
|
||||
# endif
|
||||
|
||||
# ifdef FEAT_KEYMAP
|
||||
/* Force-set the necessary keymap for arabic */
|
||||
@@ -9210,7 +9096,6 @@ set_num_option(
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
/* 'maxcombine' */
|
||||
else if (pp == &p_mco)
|
||||
{
|
||||
@@ -9220,7 +9105,6 @@ set_num_option(
|
||||
p_mco = 0;
|
||||
screenclear(); /* will re-allocate the screen */
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (pp == &curbuf->b_p_iminsert)
|
||||
{
|
||||
@@ -10078,7 +9962,6 @@ get_highlight_default(void)
|
||||
return (char_u *)NULL;
|
||||
}
|
||||
|
||||
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
char_u *
|
||||
get_encoding_default(void)
|
||||
{
|
||||
@@ -10089,7 +9972,6 @@ get_encoding_default(void)
|
||||
return options[i].def_val[VI_DEFAULT];
|
||||
return (char_u *)NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
|
||||
@@ -10794,11 +10676,9 @@ unset_global_local_option(char_u *name, void *from)
|
||||
clear_string_option(&buf->b_p_lw);
|
||||
break;
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
case PV_MENC:
|
||||
clear_string_option(&buf->b_p_menc);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -10853,9 +10733,7 @@ get_varp_scope(struct vimoption *p, int opt_flags)
|
||||
case PV_LW: return (char_u *)&(curbuf->b_p_lw);
|
||||
#endif
|
||||
case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
|
||||
#ifdef FEAT_MBYTE
|
||||
case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
|
||||
#endif
|
||||
}
|
||||
return NULL; /* "cannot happen" */
|
||||
}
|
||||
@@ -10931,10 +10809,8 @@ get_varp(struct vimoption *p)
|
||||
case PV_LW: return *curbuf->b_p_lw != NUL
|
||||
? (char_u *)&(curbuf->b_p_lw) : p->var;
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
case PV_MENC: return *curbuf->b_p_menc != NUL
|
||||
? (char_u *)&(curbuf->b_p_menc) : p->var;
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_ARABIC
|
||||
case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
|
||||
@@ -11000,9 +10876,7 @@ get_varp(struct vimoption *p)
|
||||
|
||||
case PV_AI: return (char_u *)&(curbuf->b_p_ai);
|
||||
case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
|
||||
#ifdef FEAT_MBYTE
|
||||
case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
|
||||
#endif
|
||||
case PV_BH: return (char_u *)&(curbuf->b_p_bh);
|
||||
case PV_BT: return (char_u *)&(curbuf->b_p_bt);
|
||||
case PV_BL: return (char_u *)&(curbuf->b_p_bl);
|
||||
@@ -11031,9 +10905,7 @@ get_varp(struct vimoption *p)
|
||||
case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
|
||||
case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
|
||||
case PV_ET: return (char_u *)&(curbuf->b_p_et);
|
||||
#ifdef FEAT_MBYTE
|
||||
case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
|
||||
#endif
|
||||
case PV_FF: return (char_u *)&(curbuf->b_p_ff);
|
||||
case PV_FT: return (char_u *)&(curbuf->b_p_ft);
|
||||
case PV_FO: return (char_u *)&(curbuf->b_p_fo);
|
||||
@@ -11378,9 +11250,7 @@ buf_copy_options(buf_T *buf, int flags)
|
||||
free_buf_options(buf, TRUE);
|
||||
buf->b_p_ro = FALSE; /* don't copy readonly */
|
||||
buf->b_p_tx = p_tx;
|
||||
#ifdef FEAT_MBYTE
|
||||
buf->b_p_fenc = vim_strsave(p_fenc);
|
||||
#endif
|
||||
switch (*p_ffs)
|
||||
{
|
||||
case 'm':
|
||||
@@ -11410,9 +11280,7 @@ buf_copy_options(buf_T *buf, int flags)
|
||||
buf->b_p_wm_nopaste = p_wm_nopaste;
|
||||
buf->b_p_wm_nobin = p_wm_nobin;
|
||||
buf->b_p_bin = p_bin;
|
||||
#ifdef FEAT_MBYTE
|
||||
buf->b_p_bomb = p_bomb;
|
||||
#endif
|
||||
buf->b_p_fixeol = p_fixeol;
|
||||
buf->b_p_et = p_et;
|
||||
buf->b_p_et_nobin = p_et_nobin;
|
||||
@@ -11549,9 +11417,7 @@ buf_copy_options(buf_T *buf, int flags)
|
||||
#ifdef FEAT_LISP
|
||||
buf->b_p_lw = empty_option;
|
||||
#endif
|
||||
#ifdef FEAT_MBYTE
|
||||
buf->b_p_menc = empty_option;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Don't copy the options set by ex_help(), use the saved values,
|
||||
@@ -12137,13 +12003,10 @@ wc_use_keyname(char_u *varp, long *wcp)
|
||||
*
|
||||
* langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
|
||||
* commands.
|
||||
* When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
|
||||
* langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
|
||||
* 256.
|
||||
*/
|
||||
# if defined(FEAT_MBYTE) || defined(PROTO)
|
||||
/*
|
||||
* With multi-byte support use growarray for 'langmap' chars >= 256
|
||||
* langmap_mapga.ga_data is a sorted table of langmap_entry_T. This does the
|
||||
* same as langmap_mapchar[] for characters >= 256.
|
||||
*
|
||||
* Use growarray for 'langmap' chars >= 256
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -12217,7 +12080,6 @@ langmap_adjust_mb(int c)
|
||||
}
|
||||
return c; /* no entry found, return "c" unmodified */
|
||||
}
|
||||
# endif
|
||||
|
||||
static void
|
||||
langmap_init(void)
|
||||
@@ -12226,9 +12088,7 @@ langmap_init(void)
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
langmap_mapchar[i] = i; /* we init with a one-to-one map */
|
||||
# ifdef FEAT_MBYTE
|
||||
ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
|
||||
# endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -12242,9 +12102,7 @@ langmap_set(void)
|
||||
char_u *p2;
|
||||
int from, to;
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
ga_clear(&langmap_mapga); /* clear the previous map first */
|
||||
#endif
|
||||
langmap_init(); /* back to one-to-one map */
|
||||
|
||||
for (p = p_langmap; p[0] != NUL; )
|
||||
@@ -12268,11 +12126,7 @@ langmap_set(void)
|
||||
}
|
||||
if (p[0] == '\\' && p[1] != NUL)
|
||||
++p;
|
||||
#ifdef FEAT_MBYTE
|
||||
from = (*mb_ptr2char)(p);
|
||||
#else
|
||||
from = p[0];
|
||||
#endif
|
||||
to = NUL;
|
||||
if (p2 == NULL)
|
||||
{
|
||||
@@ -12281,11 +12135,7 @@ langmap_set(void)
|
||||
{
|
||||
if (p[0] == '\\')
|
||||
++p;
|
||||
#ifdef FEAT_MBYTE
|
||||
to = (*mb_ptr2char)(p);
|
||||
#else
|
||||
to = p[0];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -12294,11 +12144,7 @@ langmap_set(void)
|
||||
{
|
||||
if (p2[0] == '\\')
|
||||
++p2;
|
||||
#ifdef FEAT_MBYTE
|
||||
to = (*mb_ptr2char)(p2);
|
||||
#else
|
||||
to = p2[0];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (to == NUL)
|
||||
@@ -12308,11 +12154,9 @@ langmap_set(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (from >= 256)
|
||||
langmap_set_entry(from, to);
|
||||
else
|
||||
#endif
|
||||
langmap_mapchar[from & 255] = to;
|
||||
|
||||
/* Advance to next pair */
|
||||
@@ -12813,7 +12657,6 @@ save_file_ff(buf_T *buf)
|
||||
{
|
||||
buf->b_start_ffc = *buf->b_p_ff;
|
||||
buf->b_start_eol = buf->b_p_eol;
|
||||
#ifdef FEAT_MBYTE
|
||||
buf->b_start_bomb = buf->b_p_bomb;
|
||||
|
||||
/* Only use free/alloc when necessary, they take time. */
|
||||
@@ -12823,7 +12666,6 @@ save_file_ff(buf_T *buf)
|
||||
vim_free(buf->b_start_fenc);
|
||||
buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -12850,15 +12692,11 @@ file_ff_differs(buf_T *buf, int ignore_empty)
|
||||
return TRUE;
|
||||
if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
|
||||
return TRUE;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
|
||||
return TRUE;
|
||||
if (buf->b_start_fenc == NULL)
|
||||
return (*buf->b_p_fenc != NUL);
|
||||
return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -13244,7 +13082,6 @@ find_mps_values(
|
||||
ptr = curbuf->b_p_mps;
|
||||
while (*ptr != NUL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
char_u *prev;
|
||||
@@ -13284,7 +13121,6 @@ find_mps_values(
|
||||
ptr += mb_ptr2len(ptr);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (*ptr == *initc)
|
||||
{
|
||||
|
||||
@@ -791,6 +791,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
806,
|
||||
/**/
|
||||
805,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user