Compare commits

..

15 Commits

Author SHA1 Message Date
a45ff6caba patch 8.0.1355: cursor keys don't work in MS-Windows console
Problem:    Cursor keys don't work in MS-Windows console.
Solution:   Revert the previous patch.  Also delete dead code.
2017-11-28 20:06:10 +01:00
3660a10c73 patch 8.0.1354: Shift-Insert doesn't always work in MS-Windows console
Problem:    Shift-Insert doesn't always work in MS-Windows console.
Solution:   Handle K_NUL differently. (Yasuhiro Matsumoto, closes #2381)
2017-11-28 18:07:59 +01:00
1ed2276fd5 patch 8.0.1353: QuickFixCmdPost is not used consistently
Problem:    QuickFixCmdPost is not used consistently.
Solution:   Invoke QuickFixCmdPost consistently after QuickFixCmdPre.
            (Yegappan Lakshmanan, closes #2377)
2017-11-28 18:03:44 +01:00
f38c86eb6b patch 8.0.1352: dead URLs in the help go unnoticed
Problem:    Dead URLs in the help go unnoticed.
Solution:   Add a script to check URLs in the help files. (Christian Brabandt)
2017-11-28 14:19:07 +01:00
bdb8139098 patch 8.0.1351: warning for unused variables building with MinGW
Problem:    Warning for unused variables building with MinGW.
Solution:   Change a few #ifdefs (suggested by John Marriott). Remove
            superfluous checks of FEAT_MBYTE.
2017-11-27 23:24:08 +01:00
1355aad2b9 patch 8.0.1350: cannot build with +eval and -multi_byte
Problem:    Cannot build with +eval and -multi_byte.
Solution:   Adjust #ifdefs. (John Marriott)  Always include the multi_byte
            feature when an input method feature is enabled.
2017-11-27 22:49:01 +01:00
17471e84a7 patch 8.0.1349: options test fails when using Motif or GTK GUI
Problem:    Options test fails when using Motif or GTK GUI.
Solution:   Use "fixed" instead of "fixedsys" for Unix. Don't try "xxx" for
            guifonteset.  Don't set 'termencoding' to anything but "utf-8" for
            GTK.  Give an error if 'termencoding' can't be converted.
2017-11-26 23:47:18 +01:00
c8c75796a6 patch 8.0.1348: make testclean deletes script file on MS-Windows
Problem:    Make testclean deletes script file on MS-Windows.
Solution:   Rename file to avoid it starting with an "x".
2017-11-26 17:18:06 +01:00
e0aa23f7e3 patch 8.0.1347: MS-Windows: build broken by misplaced curly
Problem:    MS-Windows: build broken by misplaced curly.
Solution:   Move curly after #endif
2017-11-26 17:08:03 +01:00
a3571ebef5 patch 8.0.1346: crash when passing 50 char string to balloon_split()
Problem:    Crash when passing 50 char string to balloon_split().
Solution:   Fix off-by-one error.
2017-11-26 16:53:16 +01:00
c41838aa01 patch 8.0.1345: race condition between stat() and open() for viminfo
Problem:    Race condition between stat() and open() for the viminfo temp
            file. (Simon Ruderich)
Solution:   use open() with O_EXCL to atomically check if the file exists.
            Don't try using a temp file, renaming it will fail anyway.
2017-11-26 16:50:41 +01:00
2877d334ad patch 8.0.1344: using 'imactivatefunc' in the GUI does not work
Problem:    Using 'imactivatefunc' in the GUI does not work.
Solution:   Do not use 'imactivatefunc' and 'imstatusfunc' in the GUI.
2017-11-26 14:56:16 +01:00
d7ccc4d81d patch 8.0.1343: MS-Windows: does not show colored emojis
Problem:    MS-Windows: does not show colored emojis.
Solution:   Implement colored emojis. Improve drawing speed. Make 'taamode'
            work. (Taro Muraoka, Yasuhiro Matsumoto, Ken Takata, close #2375)
2017-11-26 14:29:32 +01:00
fb1db0e355 patch 8.0.1342: cannot build with Motif and multi-byte
Problem:    Cannot build with Motif and multi-byte. (Mohamed Boughaba)
Solution:   Use the right input method status flag. (closes #2374)
2017-11-25 21:07:46 +01:00
be5d998d0e patch 8.0.1341: 'imactivatefunc' test fails on MS-Windows
Problem:    'imactivatefunc' test fails on MS-Windows.
Solution:   Skip the text.
2017-11-25 17:58:28 +01:00
21 changed files with 1003 additions and 516 deletions

View File

@ -119,7 +119,6 @@ SRC_ALL = \
src/testdir/test[0-9]*a.ok \
src/testdir/test_[a-z]*.ok \
src/testdir/test49.vim \
src/testdir/test60.vim \
src/testdir/test83-tags? \
src/testdir/test77a.com \
src/testdir/test_*.vim \
@ -138,7 +137,7 @@ SRC_ALL = \
src/testdir/samples/*.txt \
src/testdir/samples/test000 \
src/testdir/if_ver*.vim \
src/testdir/xterm_ramp.vim \
src/testdir/color_ramp.vim \
src/proto.h \
src/proto/arabic.pro \
src/proto/beval.pro \
@ -585,6 +584,7 @@ RT_ALL = \
runtime/doc/*.txt \
runtime/doc/Makefile \
runtime/doc/doctags.c \
runtime/doc/test_urls.vim \
runtime/doc/vim.1 \
runtime/doc/evim.1 \
runtime/doc/vimdiff.1 \

View File

@ -16,6 +16,7 @@ matrix:
before_build:
- '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 /release'
- 'set INCLUDE=%INCLUDE%C:\Program Files (x86)\Windows Kits\8.1\Include\um'
build_script:
- src/appveyor.bat

View File

@ -4258,7 +4258,8 @@ A jump table for the options with a short description can be found at |Q_op|.
{not in Vi}
{only available when compiled with |+mbyte|}
This option specifies a function that will be called to
activate/inactivate Input Method.
activate or deactivate the Input Method.
It is not used in the GUI.
Example: >
function ImActivateFunc(active)
@ -4374,6 +4375,7 @@ A jump table for the options with a short description can be found at |Q_op|.
{only available when compiled with |+mbyte|}
This option specifies a function that is called to obtain the status
of Input Method. It must return a positive number when IME is active.
It is not used in the GUI.
Example: >
function ImStatusFunc()
@ -6152,11 +6154,34 @@ A jump table for the options with a short description can be found at |Q_op|.
Example: >
set encoding=utf-8
set gfn=Ricty_Diminished:h12:cSHIFTJIS
set gfn=Ricty_Diminished:h12
set rop=type:directx
<
If select a raster font (Courier, Terminal or FixedSys) to
'guifont', it fallbacks to be drawn by GDI automatically.
If select a raster font (Courier, Terminal or FixedSys which
have ".fon" extension in file name) to 'guifont', it will be
drawn by GDI as a fallback. This fallback will cause
significant slow down on drawing.
NOTE: It is known that some fonts and options combination
causes trouble on drawing glyphs.
- 'rendmode:5' and 'renmode:6' will not work with some
special made fonts (True-Type fonts which includes only
bitmap glyphs).
- 'taamode:3' will not work with some vector fonts.
NOTE: With this option, you can display colored emoji
(emoticon) in Windows 8.1 or later. To display colored emoji,
there are some conditions which you should notice.
- If your font includes non-colored emoji already, it will
be used.
- If your font doesn't have emoji, the system chooses an
alternative symbol font. On Windows 10, "Segoe UI Emoji"
will be used.
- When this alternative font didn't have fixed width glyph,
emoji might be rendered beyond the bounding box of drawing
cell.
Other render types are currently not supported.

68
runtime/doc/test_urls.vim Normal file
View File

@ -0,0 +1,68 @@
" Test for URLs in help documents.
"
" Opens a new window with all found URLS followed by return code from curl
" (anything other than 0 means unreachable)
"
" Written by Christian Brabandt.
func Test_check_URLs()
if has("win32")
echoerr "Doesn't work on MS-Windows"
return
endif
if executable('curl')
" Note: does not follow redirects!
let s:command = 'curl --silent --fail --output /dev/null --head '
elseif executable('wget')
" Note: only allow a couple of redirects
let s:command = 'wget --quiet -S --spider --max-redirect=2 --timeout=5 --tries=2 -O /dev/null '
else
echoerr 'Only works when "curl" or "wget" is available'
return
endif
let pat='\(https\?\|ftp\)://[^\t* ]\+'
exe 'helpgrep' pat
helpclose
let urls = map(getqflist(), 'v:val.text')
" do not use submatch(1)!
let urls = map(urls, {key, val -> matchstr(val, pat)})
" remove examples like user@host (invalid urls)
let urls = filter(urls, 'v:val !~ "@"')
" Remove example URLs which are invalid
let urls = filter(urls, {key, val -> val !~ '\<\(\(my\|some\)\?host\|machine\|hostname\|file\)\>'})
new
put =urls
" remove some more invalid items
" empty lines
v/./d
" remove # anchors
%s/#.*$//e
" remove trailing stuff (parenthesis, dot, comma, quotes), but only for HTTP
" links
g/^h/s#[.,)'"/>][:.]\?$##
g#^[hf]t\?tp:/\(/\?\.*\)$#d
silent! g/ftp://,$/d
silent! g/=$/d
let a = getline(1,'$')
let a = uniq(sort(a))
%d
call setline(1, a)
" Do the testing.
set nomore
%s/.*/\=TestURL(submatch(0))/
" highlight the failures
/.* \([0-9]*[1-9]\|[0-9]\{2,}\)$
endfunc
func TestURL(url)
" Relies on the return code to determine whether a page is valid
echom printf("Testing URL: %d/%d %s", line('.'), line('$'), a:url)
call system(s:command . shellescape(a:url))
return printf("%s %d", a:url, v:shell_error)
endfunc
call Test_check_URLs()

View File

@ -1825,7 +1825,6 @@ write_viminfo(char_u *file, int forceit)
FILE *fp_out = NULL; /* output viminfo file */
char_u *tempname = NULL; /* name of temp viminfo file */
stat_T st_new; /* mch_stat() of potential new file */
char_u *wp;
#if defined(UNIX) || defined(VMS)
mode_t umask_save;
#endif
@ -1847,27 +1846,29 @@ write_viminfo(char_u *file, int forceit)
fp_in = mch_fopen((char *)fname, READBIN);
if (fp_in == NULL)
{
int fd;
/* if it does exist, but we can't read it, don't try writing */
if (mch_stat((char *)fname, &st_new) == 0)
goto end;
#if defined(UNIX) || defined(VMS)
/*
* For Unix we create the .viminfo non-accessible for others,
* because it may contain text from non-accessible documents.
*/
umask_save = umask(077);
#endif
fp_out = mch_fopen((char *)fname, WRITEBIN);
#if defined(UNIX) || defined(VMS)
(void)umask(umask_save);
#endif
/* Create the new .viminfo non-accessible for others, because it may
* contain text from non-accessible documents. It is up to the user to
* widen access (e.g. to a group). This may also fail if there is a
* race condition, then just give up. */
fd = mch_open((char *)fname,
O_CREAT|O_EXTRA|O_EXCL|O_WRONLY|O_NOFOLLOW, 0600);
if (fd < 0)
goto end;
fp_out = fdopen(fd, WRITEBIN);
}
else
{
/*
* There is an existing viminfo file. Create a temporary file to
* write the new viminfo into, in the same directory as the
* existing viminfo file, which will be renamed later.
* existing viminfo file, which will be renamed once all writing is
* successful.
*/
#ifdef UNIX
/*
@ -1901,12 +1902,18 @@ write_viminfo(char_u *file, int forceit)
#endif
/*
* Make tempname.
* Make tempname, find one that does not exist yet.
* Beware of a race condition: If someone logs out and all Vim
* instances exit at the same time a temp file might be created between
* stat() and open(). Use mch_open() with O_EXCL to avoid that.
* May try twice: Once normal and once with shortname set, just in
* case somebody puts his viminfo file in an 8.3 filesystem.
*/
for (;;)
{
int next_char = 'z';
char_u *wp;
tempname = buf_modname(
#ifdef UNIX
shortname,
@ -1924,126 +1931,128 @@ write_viminfo(char_u *file, int forceit)
break;
/*
* Check if tempfile already exists. Never overwrite an
* existing file!
* Try a series of names. Change one character, just before
* the extension. This should also work for an 8.3
* file name, when after adding the extension it still is
* the same file as the original.
*/
if (mch_stat((char *)tempname, &st_new) == 0)
wp = tempname + STRLEN(tempname) - 5;
if (wp < gettail(tempname)) /* empty file name? */
wp = gettail(tempname);
for (;;)
{
/*
* Check if tempfile already exists. Never overwrite an
* existing file!
*/
if (mch_stat((char *)tempname, &st_new) == 0)
{
#ifdef UNIX
/*
* Check if tempfile is same as original file. May happen
* when modname() gave the same file back. E.g. silly
* link, or file name-length reached. Try again with
* shortname set.
*/
if (!shortname && st_new.st_dev == st_old.st_dev
&& st_new.st_ino == st_old.st_ino)
{
vim_free(tempname);
tempname = NULL;
shortname = TRUE;
continue;
}
#endif
/*
* Try another name. Change one character, just before
* the extension. This should also work for an 8.3
* file name, when after adding the extension it still is
* the same file as the original.
*/
wp = tempname + STRLEN(tempname) - 5;
if (wp < gettail(tempname)) /* empty file name? */
wp = gettail(tempname);
for (*wp = 'z'; mch_stat((char *)tempname, &st_new) == 0;
--*wp)
{
/*
* They all exist? Must be something wrong! Don't
* write the viminfo file then.
* Check if tempfile is same as original file. May happen
* when modname() gave the same file back. E.g. silly
* link, or file name-length reached. Try again with
* shortname set.
*/
if (*wp == 'a')
if (!shortname && st_new.st_dev == st_old.st_dev
&& st_new.st_ino == st_old.st_ino)
{
EMSG2(_("E929: Too many viminfo temp files, like %s!"),
tempname);
vim_free(tempname);
tempname = NULL;
shortname = TRUE;
break;
}
#endif
}
else
{
/* Try creating the file exclusively. This may fail if
* another Vim tries to do it at the same time. */
#ifdef VMS
/* fdopen() fails for some reason */
umask_save = umask(077);
fp_out = mch_fopen((char *)tempname, WRITEBIN);
(void)umask(umask_save);
#else
int fd;
/* Use mch_open() to be able to use O_NOFOLLOW and set file
* protection:
* Unix: same as original file, but strip s-bit. Reset
* umask to avoid it getting in the way.
* Others: r&w for user only. */
# ifdef UNIX
umask_save = umask(0);
fd = mch_open((char *)tempname,
O_CREAT|O_EXTRA|O_EXCL|O_WRONLY|O_NOFOLLOW,
(int)((st_old.st_mode & 0777) | 0600));
(void)umask(umask_save);
# else
fd = mch_open((char *)tempname,
O_CREAT|O_EXTRA|O_EXCL|O_WRONLY|O_NOFOLLOW, 0600);
# endif
if (fd < 0)
{
fp_out = NULL;
# ifdef EEXIST
/* Avoid trying lots of names while the problem is lack
* of premission, only retry if the file already
* exists. */
if (errno != EEXIST)
break;
# endif
}
else
fp_out = fdopen(fd, WRITEBIN);
#endif /* VMS */
if (fp_out != NULL)
break;
}
/* Assume file exists, try again with another name. */
if (next_char == 'a' - 1)
{
/* They all exist? Must be something wrong! Don't write
* the viminfo file then. */
EMSG2(_("E929: Too many viminfo temp files, like %s!"),
tempname);
break;
}
*wp = next_char;
--next_char;
}
break;
if (tempname != NULL)
break;
/* continue if shortname was set */
}
if (tempname != NULL)
{
#ifdef VMS
/* fdopen() fails for some reason */
umask_save = umask(077);
fp_out = mch_fopen((char *)tempname, WRITEBIN);
(void)umask(umask_save);
#else
int fd;
/* Use mch_open() to be able to use O_NOFOLLOW and set file
* protection:
* Unix: same as original file, but strip s-bit. Reset umask to
* avoid it getting in the way.
* Others: r&w for user only. */
# ifdef UNIX
umask_save = umask(0);
fd = mch_open((char *)tempname,
O_CREAT|O_EXTRA|O_EXCL|O_WRONLY|O_NOFOLLOW,
(int)((st_old.st_mode & 0777) | 0600));
(void)umask(umask_save);
# else
fd = mch_open((char *)tempname,
O_CREAT|O_EXTRA|O_EXCL|O_WRONLY|O_NOFOLLOW, 0600);
# endif
if (fd < 0)
fp_out = NULL;
else
fp_out = fdopen(fd, WRITEBIN);
#endif /* VMS */
/*
* If we can't create in the same directory, try creating a
* "normal" temp file. This is just an attempt, renaming the temp
* file might fail as well.
*/
if (fp_out == NULL)
{
vim_free(tempname);
if ((tempname = vim_tempname('o', TRUE)) != NULL)
fp_out = mch_fopen((char *)tempname, WRITEBIN);
}
#if defined(UNIX) && defined(HAVE_FCHOWN)
if (tempname != NULL && fp_out != NULL)
{
stat_T tmp_st;
/*
* Make sure the original owner can read/write the tempfile and
* otherwise preserve permissions, making sure the group matches.
*/
if (fp_out != NULL)
if (mch_stat((char *)tempname, &tmp_st) >= 0)
{
stat_T tmp_st;
if (mch_stat((char *)tempname, &tmp_st) >= 0)
{
if (st_old.st_uid != tmp_st.st_uid)
/* Changing the owner might fail, in which case the
* file will now owned by the current user, oh well. */
ignored = fchown(fileno(fp_out), st_old.st_uid, -1);
if (st_old.st_gid != tmp_st.st_gid
&& fchown(fileno(fp_out), -1, st_old.st_gid) == -1)
/* can't set the group to what it should be, remove
* group permissions */
(void)mch_setperm(tempname, 0600);
}
else
/* can't stat the file, set conservative permissions */
if (st_old.st_uid != tmp_st.st_uid)
/* Changing the owner might fail, in which case the
* file will now owned by the current user, oh well. */
ignored = fchown(fileno(fp_out), st_old.st_uid, -1);
if (st_old.st_gid != tmp_st.st_gid
&& fchown(fileno(fp_out), -1, st_old.st_gid) == -1)
/* can't set the group to what it should be, remove
* group permissions */
(void)mch_setperm(tempname, 0600);
}
#endif
else
/* can't stat the file, set conservative permissions */
(void)mch_setperm(tempname, 0600);
}
#endif
}
/*

View File

@ -635,7 +635,8 @@
/* #define FEAT_MBYTE_IME */
# endif
#if defined(FEAT_MBYTE_IME) && !defined(FEAT_MBYTE)
/* Input methods are only useful with +multi_byte. */
#if (defined(FEAT_MBYTE_IME) || defined(FEAT_XIM)) && !defined(FEAT_MBYTE)
# define FEAT_MBYTE
#endif

View File

@ -4,6 +4,7 @@
*
* Contributors:
* - Ken Takata
* - Yasuhiro Matsumoto
*
* Copyright (C) 2013 MURAOKA Taro <koron.kaoriya@gmail.com>
* THIS FILE IS DISTRIBUTED UNDER THE VIM LICENSE.
@ -23,7 +24,21 @@
#include <math.h>
#include <d2d1.h>
#include <d2d1helper.h>
#include <dwrite.h>
// Disable these macros to compile with old VC and newer SDK (V8.1 or later).
#if defined(_MSC_VER) && (_MSC_VER < 1700)
# define _COM_Outptr_ __out
# define _In_reads_(s)
# define _In_reads_opt_(s)
# define _Maybenull_
# define _Out_writes_(s)
# define _Out_writes_opt_(s)
# define _Out_writes_to_(x, y)
# define _Out_writes_to_opt_(x, y)
# define _Outptr_
#endif
#include <dwrite_2.h>
#include "gui_dwrite.h"
@ -79,16 +94,6 @@ template <class T> inline void SafeRelease(T **ppT)
}
}
struct GdiTextRendererContext
{
// const fields.
COLORREF color;
FLOAT cellWidth;
// working fields.
FLOAT offsetX;
};
static DWRITE_PIXEL_GEOMETRY
ToPixelGeometry(int value)
{
@ -184,17 +189,151 @@ ToInt(DWRITE_RENDERING_MODE value)
}
}
class FontCache {
public:
struct Item {
HFONT hFont;
IDWriteTextFormat* pTextFormat;
DWRITE_FONT_WEIGHT fontWeight;
DWRITE_FONT_STYLE fontStyle;
Item() : hFont(NULL), pTextFormat(NULL) {}
};
private:
int mSize;
Item *mItems;
public:
FontCache(int size = 2) :
mSize(size),
mItems(new Item[size])
{
}
~FontCache()
{
for (int i = 0; i < mSize; ++i)
SafeRelease(&mItems[i].pTextFormat);
delete[] mItems;
}
bool get(HFONT hFont, Item &item)
{
int n = find(hFont);
if (n < 0)
return false;
item = mItems[n];
slide(n);
return true;
}
void put(const Item& item)
{
int n = find(item.hFont);
if (n < 0)
n = mSize - 1;
if (mItems[n].pTextFormat != item.pTextFormat)
{
SafeRelease(&mItems[n].pTextFormat);
item.pTextFormat->AddRef();
}
mItems[n] = item;
slide(n);
}
private:
int find(HFONT hFont)
{
for (int i = 0; i < mSize; ++i)
{
if (mItems[i].hFont == hFont)
return i;
}
return -1;
}
void slide(int nextTop)
{
if (nextTop == 0)
return;
Item tmp = mItems[nextTop];
for (int i = nextTop - 1; i >= 0; --i)
mItems[i + 1] = mItems[i];
mItems[0] = tmp;
}
};
struct DWriteContext {
HDC mHDC;
bool mDrawing;
bool mFallbackDC;
ID2D1Factory *mD2D1Factory;
ID2D1DCRenderTarget *mRT;
ID2D1SolidColorBrush *mBrush;
IDWriteFactory *mDWriteFactory;
IDWriteFactory2 *mDWriteFactory2;
IDWriteGdiInterop *mGdiInterop;
IDWriteRenderingParams *mRenderingParams;
FontCache mFontCache;
IDWriteTextFormat *mTextFormat;
DWRITE_FONT_WEIGHT mFontWeight;
DWRITE_FONT_STYLE mFontStyle;
D2D1_TEXT_ANTIALIAS_MODE mTextAntialiasMode;
// METHODS
DWriteContext();
virtual ~DWriteContext();
HRESULT CreateTextFormatFromLOGFONT(const LOGFONTW &logFont,
IDWriteTextFormat **ppTextFormat);
HRESULT SetFontByLOGFONT(const LOGFONTW &logFont);
void SetFont(HFONT hFont);
void BindDC(HDC hdc, RECT *rect);
void AssureDrawing();
ID2D1Brush* SolidBrush(COLORREF color);
void DrawText(const WCHAR* text, int len,
int x, int y, int w, int h, int cellWidth, COLORREF color,
UINT fuOptions, CONST RECT *lprc, CONST INT * lpDx);
void FillRect(RECT *rc, COLORREF color);
void Flush();
void SetRenderingParams(
const DWriteRenderingParams *params);
DWriteRenderingParams *GetRenderingParams(
DWriteRenderingParams *params);
};
class AdjustedGlyphRun : public DWRITE_GLYPH_RUN
{
private:
FLOAT &mAccum;
FLOAT mDelta;
FLOAT *mAdjustedAdvances;
public:
AdjustedGlyphRun(
const DWRITE_GLYPH_RUN *glyphRun,
FLOAT cellWidth) :
FLOAT cellWidth,
FLOAT &accum) :
DWRITE_GLYPH_RUN(*glyphRun),
mAccum(accum),
mDelta(0.0f),
mAdjustedAdvances(new FLOAT[glyphRun->glyphCount])
{
@ -209,45 +348,44 @@ public:
glyphAdvances = mAdjustedAdvances;
}
~AdjustedGlyphRun(void)
~AdjustedGlyphRun()
{
mAccum += mDelta;
delete[] mAdjustedAdvances;
}
FLOAT getDelta(void) const
{
return mDelta;
}
static FLOAT adjustToCell(FLOAT value, FLOAT cellWidth)
{
int cellCount = (int)floor(value / cellWidth + 0.5f);
int cellCount = int(floor(value / cellWidth + 0.5f));
if (cellCount < 1)
cellCount = 1;
return cellCount * cellWidth;
}
};
class GdiTextRenderer FINAL : public IDWriteTextRenderer
struct TextRendererContext {
// const fields.
COLORREF color;
FLOAT cellWidth;
// working fields.
FLOAT offsetX;
};
class TextRenderer FINAL : public IDWriteTextRenderer
{
public:
GdiTextRenderer(
IDWriteBitmapRenderTarget* bitmapRenderTarget,
IDWriteRenderingParams* renderingParams) :
TextRenderer(
DWriteContext* pDWC) :
cRefCount_(0),
pRenderTarget_(bitmapRenderTarget),
pRenderingParams_(renderingParams)
pDWC_(pDWC)
{
pRenderTarget_->AddRef();
pRenderingParams_->AddRef();
AddRef();
}
// add "virtual" to avoid a compiler warning
virtual ~GdiTextRenderer()
virtual ~TextRenderer()
{
SafeRelease(&pRenderTarget_);
SafeRelease(&pRenderingParams_);
}
IFACEMETHOD(IsPixelSnappingDisabled)(
@ -263,7 +401,8 @@ public:
__out DWRITE_MATRIX* transform)
{
// forward the render target's transform
pRenderTarget_->GetCurrentTransform(transform);
pDWC_->mRT->GetTransform(
reinterpret_cast<D2D1_MATRIX_3X2_F*>(transform));
return S_OK;
}
@ -271,43 +410,12 @@ public:
__maybenull void* clientDrawingContext,
__out FLOAT* pixelsPerDip)
{
*pixelsPerDip = pRenderTarget_->GetPixelsPerDip();
float dpiX, unused;
pDWC_->mRT->GetDpi(&dpiX, &unused);
*pixelsPerDip = dpiX / 96.0f;
return S_OK;
}
IFACEMETHOD(DrawGlyphRun)(
__maybenull void* clientDrawingContext,
FLOAT baselineOriginX,
FLOAT baselineOriginY,
DWRITE_MEASURING_MODE measuringMode,
__in DWRITE_GLYPH_RUN const* glyphRun,
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
IUnknown* clientDrawingEffect)
{
HRESULT hr = S_OK;
GdiTextRendererContext *context =
reinterpret_cast<GdiTextRendererContext*>(clientDrawingContext);
AdjustedGlyphRun adjustedGlyphRun(glyphRun, context->cellWidth);
// Pass on the drawing call to the render target to do the real work.
RECT dirtyRect = {0};
hr = pRenderTarget_->DrawGlyphRun(
baselineOriginX + context->offsetX,
baselineOriginY,
measuringMode,
&adjustedGlyphRun,
pRenderingParams_,
context->color,
&dirtyRect);
context->offsetX += adjustedGlyphRun.getDelta();
return hr;
}
IFACEMETHOD(DrawUnderline)(
__maybenull void* clientDrawingContext,
FLOAT baselineOriginX,
@ -340,6 +448,69 @@ public:
return E_NOTIMPL;
}
IFACEMETHOD(DrawGlyphRun)(
__maybenull void* clientDrawingContext,
FLOAT baselineOriginX,
FLOAT baselineOriginY,
DWRITE_MEASURING_MODE measuringMode,
__in DWRITE_GLYPH_RUN const* glyphRun,
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
IUnknown* clientDrawingEffect)
{
TextRendererContext *context =
reinterpret_cast<TextRendererContext*>(clientDrawingContext);
AdjustedGlyphRun adjustedGlyphRun(glyphRun, context->cellWidth,
context->offsetX);
if (pDWC_->mDWriteFactory2 != NULL)
{
IDWriteColorGlyphRunEnumerator *enumerator = NULL;
HRESULT hr = pDWC_->mDWriteFactory2->TranslateColorGlyphRun(
baselineOriginX + context->offsetX,
baselineOriginY,
&adjustedGlyphRun,
NULL,
DWRITE_MEASURING_MODE_GDI_NATURAL,
NULL,
0,
&enumerator);
if (SUCCEEDED(hr))
{
// Draw by IDWriteFactory2 for color emoji
BOOL hasRun = TRUE;
enumerator->MoveNext(&hasRun);
while (hasRun)
{
const DWRITE_COLOR_GLYPH_RUN* colorGlyphRun;
enumerator->GetCurrentRun(&colorGlyphRun);
pDWC_->mBrush->SetColor(colorGlyphRun->runColor);
pDWC_->mRT->DrawGlyphRun(
D2D1::Point2F(
colorGlyphRun->baselineOriginX,
colorGlyphRun->baselineOriginY),
&colorGlyphRun->glyphRun,
pDWC_->mBrush,
DWRITE_MEASURING_MODE_NATURAL);
enumerator->MoveNext(&hasRun);
}
SafeRelease(&enumerator);
return S_OK;
}
}
// Draw by IDWriteFactory (without color emoji)
pDWC_->mRT->DrawGlyphRun(
D2D1::Point2F(
baselineOriginX + context->offsetX,
baselineOriginY),
&adjustedGlyphRun,
pDWC_->SolidBrush(context->color),
DWRITE_MEASURING_MODE_NATURAL);
return S_OK;
}
public:
IFACEMETHOD_(unsigned long, AddRef) ()
{
@ -385,80 +556,28 @@ public:
private:
long cRefCount_;
IDWriteBitmapRenderTarget* pRenderTarget_;
IDWriteRenderingParams* pRenderingParams_;
};
struct DWriteContext {
FLOAT mDpiScaleX;
FLOAT mDpiScaleY;
bool mDrawing;
ID2D1Factory *mD2D1Factory;
ID2D1DCRenderTarget *mRT;
ID2D1SolidColorBrush *mBrush;
IDWriteFactory *mDWriteFactory;
IDWriteGdiInterop *mGdiInterop;
IDWriteRenderingParams *mRenderingParams;
IDWriteTextFormat *mTextFormat;
HFONT mLastHFont;
DWRITE_FONT_WEIGHT mFontWeight;
DWRITE_FONT_STYLE mFontStyle;
D2D1_TEXT_ANTIALIAS_MODE mTextAntialiasMode;
// METHODS
DWriteContext();
virtual ~DWriteContext();
HRESULT SetLOGFONT(const LOGFONTW &logFont, float fontSize);
void SetFont(HFONT hFont);
void SetFont(const LOGFONTW &logFont);
void DrawText(HDC hdc, const WCHAR* text, int len,
int x, int y, int w, int h, int cellWidth, COLORREF color);
float PixelsToDipsX(int x);
float PixelsToDipsY(int y);
void SetRenderingParams(
const DWriteRenderingParams *params);
DWriteRenderingParams *GetRenderingParams(
DWriteRenderingParams *params);
DWriteContext* pDWC_;
};
DWriteContext::DWriteContext() :
mDpiScaleX(1.f),
mDpiScaleY(1.f),
mHDC(NULL),
mDrawing(false),
mFallbackDC(false),
mD2D1Factory(NULL),
mRT(NULL),
mBrush(NULL),
mDWriteFactory(NULL),
mDWriteFactory2(NULL),
mGdiInterop(NULL),
mRenderingParams(NULL),
mFontCache(8),
mTextFormat(NULL),
mLastHFont(NULL),
mFontWeight(DWRITE_FONT_WEIGHT_NORMAL),
mFontStyle(DWRITE_FONT_STYLE_NORMAL),
mTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_DEFAULT)
{
HRESULT hr;
HDC screen = ::GetDC(0);
mDpiScaleX = ::GetDeviceCaps(screen, LOGPIXELSX) / 96.0f;
mDpiScaleY = ::GetDeviceCaps(screen, LOGPIXELSY) / 96.0f;
::ReleaseDC(0, screen);
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
__uuidof(ID2D1Factory), NULL,
reinterpret_cast<void**>(&mD2D1Factory));
@ -495,6 +614,15 @@ DWriteContext::DWriteContext() :
mDWriteFactory);
}
if (SUCCEEDED(hr))
{
DWriteCreateFactory(
DWRITE_FACTORY_TYPE_SHARED,
__uuidof(IDWriteFactory2),
reinterpret_cast<IUnknown**>(&mDWriteFactory2));
_RPT1(_CRT_WARN, "IDWriteFactory2: %s\n", SUCCEEDED(hr) ? "available" : "not available");
}
if (SUCCEEDED(hr))
{
hr = mDWriteFactory->GetGdiInterop(&mGdiInterop);
@ -515,20 +643,24 @@ DWriteContext::~DWriteContext()
SafeRelease(&mRenderingParams);
SafeRelease(&mGdiInterop);
SafeRelease(&mDWriteFactory);
SafeRelease(&mDWriteFactory2);
SafeRelease(&mBrush);
SafeRelease(&mRT);
SafeRelease(&mD2D1Factory);
}
HRESULT
DWriteContext::SetLOGFONT(const LOGFONTW &logFont, float fontSize)
DWriteContext::CreateTextFormatFromLOGFONT(const LOGFONTW &logFont,
IDWriteTextFormat **ppTextFormat)
{
// Most of this function is copy from: http://msdn.microsoft.com/en-us/library/windows/desktop/dd941783(v=vs.85).aspx
// Most of this function is copied from: https://github.com/Microsoft/Windows-classic-samples/blob/master/Samples/Win7Samples/multimedia/DirectWrite/RenderTest/TextHelpers.cpp
HRESULT hr = S_OK;
IDWriteTextFormat *pTextFormat = NULL;
IDWriteFont *font = NULL;
IDWriteFontFamily *fontFamily = NULL;
IDWriteLocalizedStrings *localizedFamilyNames = NULL;
float fontSize = 0;
if (SUCCEEDED(hr))
{
@ -561,33 +693,30 @@ DWriteContext::SetLOGFONT(const LOGFONTW &logFont, float fontSize)
if (SUCCEEDED(hr))
{
// If no font size was passed in use the lfHeight of the LOGFONT.
if (fontSize == 0)
// Use lfHeight of the LOGFONT as font size.
fontSize = float(logFont.lfHeight);
if (fontSize < 0)
{
// Convert from pixels to DIPs.
fontSize = PixelsToDipsY(logFont.lfHeight);
if (fontSize < 0)
{
// Negative lfHeight represents the size of the em unit.
fontSize = -fontSize;
}
else
{
// Positive lfHeight represents the cell height (ascent +
// descent).
DWRITE_FONT_METRICS fontMetrics;
font->GetMetrics(&fontMetrics);
// Negative lfHeight represents the size of the em unit.
fontSize = -fontSize;
}
else
{
// Positive lfHeight represents the cell height (ascent +
// descent).
DWRITE_FONT_METRICS fontMetrics;
font->GetMetrics(&fontMetrics);
// Convert the cell height (ascent + descent) from design units
// to ems.
float cellHeight = static_cast<float>(
fontMetrics.ascent + fontMetrics.descent)
/ fontMetrics.designUnitsPerEm;
// Convert the cell height (ascent + descent) from design units
// to ems.
float cellHeight = static_cast<float>(
fontMetrics.ascent + fontMetrics.descent)
/ fontMetrics.designUnitsPerEm;
// Divide the font size by the cell height to get the font em
// size.
fontSize /= cellHeight;
}
// Divide the font size by the cell height to get the font em
// size.
fontSize /= cellHeight;
}
}
@ -612,123 +741,165 @@ DWriteContext::SetLOGFONT(const LOGFONTW &logFont, float fontSize)
font->GetStretch(),
fontSize,
localeName,
&mTextFormat);
&pTextFormat);
}
if (SUCCEEDED(hr))
{
mFontWeight = static_cast<DWRITE_FONT_WEIGHT>(logFont.lfWeight);
mFontStyle = logFont.lfItalic ? DWRITE_FONT_STYLE_ITALIC
: DWRITE_FONT_STYLE_NORMAL;
}
hr = pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
if (SUCCEEDED(hr))
hr = pTextFormat->SetParagraphAlignment(
DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
if (SUCCEEDED(hr))
hr = pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
SafeRelease(&localizedFamilyNames);
SafeRelease(&fontFamily);
SafeRelease(&font);
if (SUCCEEDED(hr))
*ppTextFormat = pTextFormat;
else
SafeRelease(&pTextFormat);
return hr;
}
HRESULT
DWriteContext::SetFontByLOGFONT(const LOGFONTW &logFont)
{
HRESULT hr = S_OK;
IDWriteTextFormat *pTextFormat = NULL;
hr = CreateTextFormatFromLOGFONT(logFont, &pTextFormat);
if (SUCCEEDED(hr))
{
SafeRelease(&mTextFormat);
mTextFormat = pTextFormat;
mFontWeight = static_cast<DWRITE_FONT_WEIGHT>(logFont.lfWeight);
mFontStyle = logFont.lfItalic ? DWRITE_FONT_STYLE_ITALIC
: DWRITE_FONT_STYLE_NORMAL;
}
return hr;
}
void
DWriteContext::SetFont(HFONT hFont)
{
if (mLastHFont != hFont)
FontCache::Item item;
if (mFontCache.get(hFont, item))
{
LOGFONTW lf;
if (GetObjectW(hFont, sizeof(lf), &lf))
if (item.pTextFormat != NULL)
{
SetFont(lf);
mLastHFont = hFont;
item.pTextFormat->AddRef();
SafeRelease(&mTextFormat);
mTextFormat = item.pTextFormat;
mFontWeight = item.fontWeight;
mFontStyle = item.fontStyle;
mFallbackDC = false;
}
else
mFallbackDC = true;
return;
}
HRESULT hr = E_FAIL;
LOGFONTW lf;
if (GetObjectW(hFont, sizeof(lf), &lf))
hr = SetFontByLOGFONT(lf);
item.hFont = hFont;
if (SUCCEEDED(hr))
{
item.pTextFormat = mTextFormat;
item.fontWeight = mFontWeight;
item.fontStyle = mFontStyle;
}
mFontCache.put(item);
}
void
DWriteContext::SetFont(const LOGFONTW &logFont)
DWriteContext::BindDC(HDC hdc, RECT *rect)
{
SafeRelease(&mTextFormat);
mLastHFont = NULL;
HRESULT hr = SetLOGFONT(logFont, 0.f);
if (SUCCEEDED(hr))
hr = mTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
if (SUCCEEDED(hr))
hr = mTextFormat->SetParagraphAlignment(
DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
if (SUCCEEDED(hr))
hr = mTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
Flush();
mRT->BindDC(hdc, rect);
mRT->SetTransform(D2D1::IdentityMatrix());
mHDC = hdc;
}
void
DWriteContext::DrawText(HDC hdc, const WCHAR* text, int len,
int x, int y, int w, int h, int cellWidth, COLORREF color)
DWriteContext::AssureDrawing()
{
HRESULT hr = S_OK;
IDWriteBitmapRenderTarget *bmpRT = NULL;
if (mDrawing == false)
{
mRT->BeginDraw();
mDrawing = true;
}
}
// Skip when any fonts are not set.
if (mTextFormat == NULL)
ID2D1Brush*
DWriteContext::SolidBrush(COLORREF color)
{
mBrush->SetColor(D2D1::ColorF(UINT32(GetRValue(color)) << 16 |
UINT32(GetGValue(color)) << 8 | UINT32(GetBValue(color))));
return mBrush;
}
void
DWriteContext::DrawText(const WCHAR* text, int len,
int x, int y, int w, int h, int cellWidth, COLORREF color,
UINT fuOptions, CONST RECT *lprc, CONST INT * lpDx)
{
if (mFallbackDC)
{
Flush();
ExtTextOutW(mHDC, x, y, fuOptions, lprc, text, len, lpDx);
return;
}
// Check possibility of zero divided error.
if (cellWidth == 0 || mDpiScaleX == 0.0f || mDpiScaleY == 0.0f)
return;
AssureDrawing();
if (SUCCEEDED(hr))
hr = mGdiInterop->CreateBitmapRenderTarget(hdc, w, h, &bmpRT);
HRESULT hr;
IDWriteTextLayout *textLayout = NULL;
hr = mDWriteFactory->CreateTextLayout(text, len, mTextFormat,
FLOAT(w), FLOAT(h), &textLayout);
if (SUCCEEDED(hr))
{
IDWriteTextLayout *textLayout = NULL;
DWRITE_TEXT_RANGE textRange = { 0, UINT32(len) };
textLayout->SetFontWeight(mFontWeight, textRange);
textLayout->SetFontStyle(mFontStyle, textRange);
HDC memdc = bmpRT->GetMemoryDC();
BitBlt(memdc, 0, 0, w, h, hdc, x, y, SRCCOPY);
hr = mDWriteFactory->CreateGdiCompatibleTextLayout(
text, len, mTextFormat, PixelsToDipsX(w),
PixelsToDipsY(h), mDpiScaleX, NULL, TRUE, &textLayout);
if (SUCCEEDED(hr))
{
DWRITE_TEXT_RANGE textRange = { 0, (UINT32)len };
textLayout->SetFontWeight(mFontWeight, textRange);
textLayout->SetFontStyle(mFontStyle, textRange);
}
if (SUCCEEDED(hr))
{
GdiTextRenderer *renderer = new GdiTextRenderer(bmpRT,
mRenderingParams);
GdiTextRendererContext data = {
color,
PixelsToDipsX(cellWidth),
0.0f
};
textLayout->Draw(&data, renderer, 0, 0);
SafeRelease(&renderer);
}
BitBlt(hdc, x, y, w, h, memdc, 0, 0, SRCCOPY);
SafeRelease(&textLayout);
TextRenderer renderer(this);
TextRendererContext context = { color, FLOAT(cellWidth), 0.0f };
textLayout->Draw(&context, &renderer, FLOAT(x), FLOAT(y));
}
SafeRelease(&bmpRT);
SafeRelease(&textLayout);
}
float
DWriteContext::PixelsToDipsX(int x)
void
DWriteContext::FillRect(RECT *rc, COLORREF color)
{
return x / mDpiScaleX;
AssureDrawing();
mRT->FillRectangle(
D2D1::RectF(FLOAT(rc->left), FLOAT(rc->top),
FLOAT(rc->right), FLOAT(rc->bottom)),
SolidBrush(color));
}
float
DWriteContext::PixelsToDipsY(int y)
void
DWriteContext::Flush()
{
return y / mDpiScaleY;
if (mDrawing)
{
mRT->EndDraw();
mDrawing = false;
}
}
void
@ -757,6 +928,10 @@ DWriteContext::SetRenderingParams(
SafeRelease(&mRenderingParams);
mRenderingParams = renderingParams;
mTextAntialiasMode = textAntialiasMode;
Flush();
mRT->SetTextRenderingParams(mRenderingParams);
mRT->SetTextAntialiasMode(mTextAntialiasMode);
}
}
@ -824,40 +999,23 @@ DWriteContext_Open(void)
return new DWriteContext();
}
void
DWriteContext_BeginDraw(DWriteContext *ctx)
{
if (ctx != NULL && ctx->mRT != NULL)
{
ctx->mRT->BeginDraw();
ctx->mRT->SetTransform(D2D1::IdentityMatrix());
ctx->mDrawing = true;
}
}
void
DWriteContext_BindDC(DWriteContext *ctx, HDC hdc, RECT *rect)
{
if (ctx != NULL && ctx->mRT != NULL)
{
ctx->mRT->BindDC(hdc, rect);
ctx->mRT->SetTextAntialiasMode(ctx->mTextAntialiasMode);
}
if (ctx != NULL)
ctx->BindDC(hdc, rect);
}
void
DWriteContext_SetFont(DWriteContext *ctx, HFONT hFont)
{
if (ctx != NULL)
{
ctx->SetFont(hFont);
}
}
void
DWriteContext_DrawText(
DWriteContext *ctx,
HDC hdc,
const WCHAR* text,
int len,
int x,
@ -865,20 +1023,28 @@ DWriteContext_DrawText(
int w,
int h,
int cellWidth,
COLORREF color)
COLORREF color,
UINT fuOptions,
CONST RECT *lprc,
CONST INT * lpDx)
{
if (ctx != NULL)
ctx->DrawText(hdc, text, len, x, y, w, h, cellWidth, color);
ctx->DrawText(text, len, x, y, w, h, cellWidth, color,
fuOptions, lprc, lpDx);
}
void
DWriteContext_EndDraw(DWriteContext *ctx)
DWriteContext_FillRect(DWriteContext *ctx, RECT *rc, COLORREF color)
{
if (ctx != NULL && ctx->mRT != NULL)
{
ctx->mRT->EndDraw();
ctx->mDrawing = false;
}
if (ctx != NULL)
ctx->FillRect(rc, color);
}
void
DWriteContext_Flush(DWriteContext *ctx)
{
if (ctx != NULL)
ctx->Flush();
}
void

View File

@ -4,6 +4,7 @@
*
* Contributors:
* - Ken Takata
* - Yasuhiro Matsumoto
*
* Copyright (C) 2013 MURAOKA Taro <koron.kaoriya@gmail.com>
* THIS FILE IS DISTRIBUTED UNDER THE VIM LICENSE.
@ -54,12 +55,10 @@ void DWrite_Init(void);
void DWrite_Final(void);
DWriteContext *DWriteContext_Open(void);
void DWriteContext_BeginDraw(DWriteContext *ctx);
void DWriteContext_BindDC(DWriteContext *ctx, HDC hdc, RECT *rect);
void DWriteContext_SetFont(DWriteContext *ctx, HFONT hFont);
void DWriteContext_DrawText(
DWriteContext *ctx,
HDC hdc,
const WCHAR* text,
int len,
int x,
@ -67,8 +66,12 @@ void DWriteContext_DrawText(
int w,
int h,
int cellWidth,
COLORREF color);
void DWriteContext_EndDraw(DWriteContext *ctx);
COLORREF color,
UINT fuOptions,
CONST RECT *lprc,
CONST INT * lpDx);
void DWriteContext_FillRect(DWriteContext *ctx, RECT *rc, COLORREF color);
void DWriteContext_Flush(DWriteContext *ctx);
void DWriteContext_Close(DWriteContext *ctx);
void DWriteContext_SetRenderingParams(

View File

@ -34,28 +34,14 @@ static DWriteContext *s_dwc = NULL;
static int s_directx_enabled = 0;
static int s_directx_load_attempted = 0;
# define IS_ENABLE_DIRECTX() (s_directx_enabled && s_dwc != NULL)
static int directx_enabled(void);
static void directx_binddc(void);
#endif
#ifdef FEAT_MENU
static int gui_mswin_get_menu_height(int fix_window);
#endif
#if defined(FEAT_DIRECTX) || defined(PROTO)
int
directx_enabled(void)
{
if (s_dwc != NULL)
return 1;
else if (s_directx_load_attempted)
return 0;
/* load DirectX */
DWrite_Init();
s_directx_load_attempted = 1;
s_dwc = DWriteContext_Open();
return s_dwc != NULL ? 1 : 0;
}
#endif
#if defined(FEAT_RENDER_OPTIONS) || defined(PROTO)
int
gui_mch_set_rendering_options(char_u *s)
@ -369,6 +355,34 @@ static int allow_scrollbar = FALSE;
# define MyTranslateMessage(x) TranslateMessage(x)
#endif
#if defined(FEAT_DIRECTX)
static int
directx_enabled(void)
{
if (s_dwc != NULL)
return 1;
else if (s_directx_load_attempted)
return 0;
/* load DirectX */
DWrite_Init();
s_directx_load_attempted = 1;
s_dwc = DWriteContext_Open();
directx_binddc();
return s_dwc != NULL ? 1 : 0;
}
static void
directx_binddc(void)
{
if (s_textArea != NULL)
{
RECT rect;
GetClientRect(s_textArea, &rect);
DWriteContext_BindDC(s_dwc, s_hdc, &rect);
}
}
#endif
#if defined(FEAT_MBYTE) || defined(GLOBAL_IME)
/* use of WindowProc depends on wide_WindowProc */
# define MyWindowProc vim_WindowProc
@ -484,9 +498,11 @@ static void TrackUserActivity(UINT uMsg);
*
* These LOGFONT used for IME.
*/
#ifdef FEAT_MBYTE
#if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)
/* holds LOGFONT for 'guifontwide' if available, otherwise 'guifont' */
static LOGFONT norm_logfont;
#endif
#ifdef FEAT_MBYTE_IME
/* holds LOGFONT for 'guifont' always. */
static LOGFONT sub_logfont;
#endif
@ -589,6 +605,10 @@ _OnBlinkTimer(
blink_timer = (UINT) SetTimer(NULL, 0, (UINT)blink_ontime,
(TIMERPROC)_OnBlinkTimer);
}
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
}
static void
@ -1000,6 +1020,19 @@ _OnMouseMoveOrRelease(
_OnMouseEvent(button, x, y, FALSE, keyFlags);
}
static void
_OnSizeTextArea(
HWND hwnd UNUSED,
UINT state UNUSED,
int cx UNUSED,
int cy UNUSED)
{
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
directx_binddc();
#endif
}
#ifdef FEAT_MENU
/*
* Find the vimmenu_T with the given id
@ -1234,6 +1267,7 @@ _TextAreaWndProc(
HANDLE_MSG(hwnd, WM_XBUTTONDBLCLK,_OnMouseButtonDown);
HANDLE_MSG(hwnd, WM_XBUTTONDOWN,_OnMouseButtonDown);
HANDLE_MSG(hwnd, WM_XBUTTONUP, _OnMouseMoveOrRelease);
HANDLE_MSG(hwnd, WM_SIZE, _OnSizeTextArea);
#ifdef FEAT_BEVAL_GUI
case WM_NOTIFY: Handle_WM_Notify(hwnd, (LPNMHDR)lParam);
@ -1633,6 +1667,11 @@ gui_mch_invert_rectangle(
{
RECT rc;
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
/*
* Note: InvertRect() excludes right and bottom of rectangle.
*/
@ -1661,6 +1700,11 @@ gui_mch_draw_hollow_cursor(guicolor_T color)
HBRUSH hbr;
RECT rc;
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
/*
* Note: FrameRect() excludes right and bottom of rectangle.
*/
@ -1701,6 +1745,12 @@ gui_mch_draw_part_cursor(
rc.top = FILL_Y(gui.row) + gui.char_height - h;
rc.right = rc.left + w;
rc.bottom = rc.top + h;
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
hbr = CreateSolidBrush(color);
FillRect(s_hdc, &rc, hbr);
DeleteBrush(hbr);
@ -2856,10 +2906,6 @@ _OnPaint(
out_flush(); /* make sure all output has been processed */
(void)BeginPaint(hwnd, &ps);
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_BeginDraw(s_dwc);
#endif
#ifdef FEAT_MBYTE
/* prevent multi-byte characters from misprinting on an invalid
@ -2876,19 +2922,11 @@ _OnPaint(
if (!IsRectEmpty(&ps.rcPaint))
{
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_BindDC(s_dwc, s_hdc, &ps.rcPaint);
#endif
gui_redraw(ps.rcPaint.left, ps.rcPaint.top,
ps.rcPaint.right - ps.rcPaint.left + 1,
ps.rcPaint.bottom - ps.rcPaint.top + 1);
}
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_EndDraw(s_dwc);
#endif
EndPaint(hwnd, &ps);
}
}
@ -3010,6 +3048,11 @@ gui_mch_flash(int msec)
{
RECT rc;
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
/*
* Note: InvertRect() excludes right and bottom of rectangle.
*/
@ -3082,6 +3125,12 @@ gui_mch_delete_lines(
intel_gpu_workaround();
#if defined(FEAT_DIRECTX)
// Commit drawing queue before ScrollWindowEx.
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
rc.left = FILL_X(gui.scroll_region_left);
rc.right = FILL_X(gui.scroll_region_right + 1);
rc.top = FILL_Y(row);
@ -3115,6 +3164,12 @@ gui_mch_insert_lines(
intel_gpu_workaround();
#if defined(FEAT_DIRECTX)
// Commit drawing queue before ScrollWindowEx.
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
rc.left = FILL_X(gui.scroll_region_left);
rc.right = FILL_X(gui.scroll_region_right + 1);
rc.top = FILL_Y(row);
@ -3308,6 +3363,8 @@ gui_mch_init_font(char_u *font_name, int fontset UNUSED)
font_name = (char_u *)lf.lfFaceName;
#if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)
norm_logfont = lf;
#endif
#ifdef FEAT_MBYTE_IME
sub_logfont = lf;
#endif
#ifdef FEAT_MBYTE_IME
@ -5741,15 +5798,15 @@ gui_mch_set_sp_color(guicolor_T color)
gui.currSpColor = color;
}
#if defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)
#ifdef FEAT_MBYTE_IME
/*
* Multi-byte handling, originally by Sung-Hoon Baek.
* First static functions (no prototypes generated).
*/
#ifdef _MSC_VER
# include <ime.h> /* Apparently not needed for Cygwin, MingW or Borland. */
#endif
#include <imm.h>
# ifdef _MSC_VER
# include <ime.h> /* Apparently not needed for Cygwin, MingW or Borland. */
# endif
# include <imm.h>
/*
* handle WM_IME_NOTIFY message
@ -5901,7 +5958,7 @@ GetResultStr(HWND hwnd, int GCS, int *lenp)
#endif
/* For global functions we need prototypes. */
#if (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) || defined(PROTO)
#if defined(FEAT_MBYTE_IME) || defined(PROTO)
/*
* set font to IM.
@ -6026,7 +6083,7 @@ im_get_status(void)
return status;
}
#endif /* FEAT_MBYTE && FEAT_MBYTE_IME */
#endif /* FEAT_MBYTE_IME */
#if defined(FEAT_MBYTE) && !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME)
/* Win32 with GLOBAL IME */
@ -6145,9 +6202,6 @@ gui_mch_draw_string(
#endif
HPEN hpen, old_pen;
int y;
#ifdef FEAT_DIRECTX
int font_is_ttf_or_vector = 0;
#endif
/*
* Italic and bold text seems to have an extra row of pixels at the bottom
@ -6208,6 +6262,11 @@ gui_mch_draw_string(
hbr = hbr_cache[brush_lru];
brush_lru = !brush_lru;
}
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_FillRect(s_dwc, &rc, gui.currBgColor);
#endif
FillRect(s_hdc, &rc, hbr);
SetBkMode(s_hdc, TRANSPARENT);
@ -6227,16 +6286,7 @@ gui_mch_draw_string(
#ifdef FEAT_DIRECTX
if (IS_ENABLE_DIRECTX())
{
TEXTMETRIC tm;
GetTextMetrics(s_hdc, &tm);
if (tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR))
{
font_is_ttf_or_vector = 1;
DWriteContext_SetFont(s_dwc, (HFONT)gui.currFont);
}
}
DWriteContext_SetFont(s_dwc, (HFONT)gui.currFont);
#endif
if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
@ -6347,12 +6397,13 @@ gui_mch_draw_string(
++clen;
}
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX() && font_is_ttf_or_vector)
if (IS_ENABLE_DIRECTX())
{
/* Add one to "cells" for italics. */
DWriteContext_DrawText(s_dwc, s_hdc, unicodebuf, wlen,
DWriteContext_DrawText(s_dwc, unicodebuf, wlen,
TEXT_X(col), TEXT_Y(row), FILL_X(cells + 1), FILL_Y(1),
gui.char_width, gui.currFgColor);
gui.char_width, gui.currFgColor,
foptions, pcliprect, unicodepdy);
}
else
#endif
@ -6411,6 +6462,12 @@ gui_mch_draw_string(
foptions, pcliprect, (char *)text, len, padding);
}
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX() &&
(flags & (DRAW_UNDERL | DRAW_STRIKE | DRAW_UNDERC | DRAW_CURSOR)))
DWriteContext_Flush(s_dwc);
#endif
/* Underline */
if (flags & DRAW_UNDERL)
{
@ -6473,6 +6530,11 @@ gui_mch_flush(void)
BOOL __stdcall GdiFlush(void);
# endif
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
GdiFlush();
}
@ -6481,6 +6543,14 @@ clear_rect(RECT *rcp)
{
HBRUSH hbr;
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
{
DWriteContext_FillRect(s_dwc, rcp, gui.back_pixel);
return;
}
#endif
hbr = CreateSolidBrush(gui.back_pixel);
FillRect(s_hdc, rcp, hbr);
DeleteBrush(hbr);
@ -8386,6 +8456,11 @@ gui_mch_drawsign(int row, int col, int typenr)
if (!gui.in_use || (sign = (signicon_t *)sign_get_image(typenr)) == NULL)
return;
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
x = TEXT_X(col);
y = TEXT_Y(row);
w = gui.char_width * 2;
@ -8865,6 +8940,11 @@ netbeans_draw_multisign_indicator(int row)
x = 0;
y = TEXT_Y(row);
#if defined(FEAT_DIRECTX)
if (IS_ENABLE_DIRECTX())
DWriteContext_Flush(s_dwc);
#endif
for (i = 0; i < gui.char_height - 3; i++)
SetPixel(s_hdc, x+2, y++, gui.currFgColor);

View File

@ -4782,7 +4782,15 @@ iconv_end(void)
#endif /* FEAT_MBYTE */
#ifdef FEAT_EVAL
#ifdef FEAT_GUI
# define USE_IMACTIVATEFUNC (!gui.in_use && *p_imaf != NUL)
# define USE_IMSTATUSFUNC (!gui.in_use && *p_imsf != NUL)
#else
# define USE_IMACTIVATEFUNC (*p_imaf != NUL)
# define USE_IMSTATUSFUNC (*p_imsf != NUL)
#endif
#if defined(FEAT_EVAL) && defined(FEAT_MBYTE)
static void
call_imactivatefunc(int active)
{
@ -5689,7 +5697,7 @@ im_synthesize_keypress(unsigned int keyval, unsigned int state)
xim_reset(void)
{
#ifdef FEAT_EVAL
if (p_imaf[0] != NUL)
if (USE_IMACTIVATEFUNC)
call_imactivatefunc(im_is_active);
else
#endif
@ -5868,7 +5876,7 @@ xim_queue_key_press_event(GdkEventKey *event, int down)
im_get_status(void)
{
# ifdef FEAT_EVAL
if (p_imsf[0] != NUL)
if (USE_IMSTATUSFUNC)
return call_imstatusfunc();
# endif
return im_is_active;
@ -5908,21 +5916,19 @@ im_set_active(int active_arg)
/* If 'imdisable' is set, XIM is never active. */
if (p_imdisable)
active = FALSE;
# if !defined(FEAT_GUI_GTK)
else if (input_style & XIMPreeditPosition)
/* There is a problem in switching XIM off when preediting is used,
* and it is not clear how this can be solved. For now, keep XIM on
* all the time, like it was done in Vim 5.8. */
active = TRUE;
# endif
# if defined(FEAT_EVAL)
if (p_imaf[0] != NUL)
if (USE_IMACTIVATEFUNC)
{
if (active != im_get_status())
{
call_imactivatefunc(active);
im_is_active = active;
xim_has_focus = active;
}
return;
}
@ -6328,7 +6334,8 @@ xim_real_init(Window x11_window, Display *x11_display)
}
else
{
EMSG(_(e_xim));
if (!is_not_a_term())
EMSG(_(e_xim));
XCloseIM(xim);
return FALSE;
}
@ -6348,7 +6355,7 @@ xim_real_init(Window x11_window, Display *x11_display)
im_get_status(void)
{
# ifdef FEAT_EVAL
if (p_imsf[0] != NUL)
if (USE_IMSTATUSFUNC)
return call_imstatusfunc();
# endif
return xim_has_focus;
@ -6479,8 +6486,8 @@ static int im_was_set_active = FALSE;
int
im_get_status()
{
# ifdef FEAT_EVAL
if (p_imsf[0] != NUL)
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
if (USE_IMSTATUSFUNC)
return call_imstatusfunc();
# endif
return im_was_set_active;
@ -6492,7 +6499,7 @@ im_set_active(int active_arg)
# if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
int active = !p_imdisable && active_arg;
if (p_imaf[0] != NUL && active != im_get_status())
if (USE_IMACTIVATEFUNC && active != im_get_status())
{
call_imactivatefunc(active);
im_was_set_active = active;

View File

@ -6369,8 +6369,13 @@ did_set_string_option(
* display output conversion. */
if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
{
convert_setup(&input_conv, p_tenc, p_enc);
convert_setup(&output_conv, p_enc, p_tenc);
if (convert_setup(&input_conv, p_tenc, p_enc) == FAIL
|| convert_setup(&output_conv, p_enc, p_tenc) == FAIL)
{
EMSG3(_("E950: Cannot convert between %s and %s"),
p_tenc, p_enc);
errmsg = e_invarg;
}
}
# if defined(WIN3264) && defined(FEAT_MBYTE)

View File

@ -1789,7 +1789,6 @@ mch_inchar(
#endif
{
int n = 1;
int conv = FALSE;
#ifdef FEAT_MBYTE
if (ch2 == NUL)
@ -1822,28 +1821,6 @@ mch_inchar(
n += 2;
}
if (conv)
{
char_u *p = typeahead + typeaheadlen;
if (*p != K_NUL)
{
char_u *e = typeahead + TYPEAHEADLEN;
while (*p && p < e)
{
if (*p == K_NUL)
{
++p;
mch_memmove(p + 1, p, ((size_t)(e - p)) - 1);
*p = 3;
++n;
}
++p;
}
}
}
/* Use the ALT key to set the 8th bit of the character
* when it's one byte, the 8th bit isn't set yet and not
* using a double-byte encoding (would become a lead

View File

@ -836,7 +836,7 @@ split_message(char_u *mesg, pumitem_T **array)
item->bytelen = p - item->start;
if (item->cells > max_cells)
max_cells = item->cells;
long_item_count += item->cells / BALLOON_MIN_WIDTH;
long_item_count += (item->cells - 1) / BALLOON_MIN_WIDTH;
}
height = 2 + ga.ga_len;

View File

@ -1,5 +1,4 @@
/* gui_w32.c */
int directx_enabled(void);
int gui_mch_set_rendering_options(char_u *s);
int gui_mch_is_blinking(void);
int gui_mch_is_blink_off(void);

View File

@ -4055,6 +4055,7 @@ ex_cfile(exarg_T *eap)
#ifdef FEAT_AUTOCMD
char_u *au_name = NULL;
#endif
int res;
if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
|| eap->cmdidx == CMD_laddfile)
@ -4102,28 +4103,18 @@ ex_cfile(exarg_T *eap)
* :caddfile adds to an existing quickfix list. If there is no
* quickfix list then a new list is created.
*/
if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
&& eap->cmdidx != CMD_laddfile),
*eap->cmdlinep, enc) > 0
&& (eap->cmdidx == CMD_cfile
|| eap->cmdidx == CMD_lfile))
{
res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
&& eap->cmdidx != CMD_laddfile), *eap->cmdlinep, enc);
#ifdef FEAT_AUTOCMD
if (au_name != NULL)
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
if (au_name != NULL)
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
#endif
if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile))
{
if (wp != NULL)
qi = GET_LOC_LIST(wp);
qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
else
{
#ifdef FEAT_AUTOCMD
if (au_name != NULL)
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
#endif
}
}
/*
@ -5450,6 +5441,7 @@ ex_cbuffer(exarg_T *eap)
#ifdef FEAT_AUTOCMD
char_u *au_name = NULL;
#endif
int res;
if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
|| eap->cmdidx == CMD_laddbuffer)
@ -5509,20 +5501,19 @@ ex_cbuffer(exarg_T *eap)
qf_title = IObuff;
}
if (qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm,
res = qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm,
(eap->cmdidx != CMD_caddbuffer
&& eap->cmdidx != CMD_laddbuffer),
eap->line1, eap->line2,
qf_title, NULL) > 0)
{
qf_title, NULL);
#ifdef FEAT_AUTOCMD
if (au_name != NULL)
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
curbuf->b_fname, TRUE, curbuf);
if (au_name != NULL)
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
curbuf->b_fname, TRUE, curbuf);
#endif
if (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer)
qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
if (res > 0 && (eap->cmdidx == CMD_cbuffer ||
eap->cmdidx == CMD_lbuffer))
qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
}
}
@ -5540,6 +5531,7 @@ ex_cexpr(exarg_T *eap)
#ifdef FEAT_AUTOCMD
char_u *au_name = NULL;
#endif
int res;
if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr
|| eap->cmdidx == CMD_laddexpr)
@ -5578,20 +5570,19 @@ ex_cexpr(exarg_T *eap)
if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL)
|| (tv->v_type == VAR_LIST && tv->vval.v_list != NULL))
{
if (qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm,
res = qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm,
(eap->cmdidx != CMD_caddexpr
&& eap->cmdidx != CMD_laddexpr),
(linenr_T)0, (linenr_T)0, *eap->cmdlinep,
NULL) > 0)
{
NULL);
#ifdef FEAT_AUTOCMD
if (au_name != NULL)
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
curbuf->b_fname, TRUE, curbuf);
if (au_name != NULL)
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
curbuf->b_fname, TRUE, curbuf);
#endif
if (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr)
qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
if (res > 0 && (eap->cmdidx == CMD_cexpr ||
eap->cmdidx == CMD_lexpr))
qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
else
EMSG(_("E777: String or List expected"));

View File

@ -11,7 +11,8 @@ endfor
for nr in range(8, 15)
let s .= "\033[10" . (nr - 8) . "m "
endfor
let s .= "\033[107m|"
" Add | in original color pair to see white background.
let s .= "\033[m|"
call setline(2, s)
" 6 x 6 x 6 color cube
@ -22,7 +23,7 @@ for high in range(0, 5)
let nr = low + high * 36
let s .= "\033[48;5;" . (nr + 16) . "m "
endfor
let s .= "\033[107m|"
let s .= "\033[m|"
call setline(high + 4, s)
endfor
@ -32,9 +33,9 @@ let s = ''
for nr in range(0, 23)
let s .= "\033[48;5;" . (nr + 232) . "m "
endfor
let s .= "\033[107m|"
let s .= "\033[m|"
call setline(11, s)
set binary
write! <sfile>:h/xterm_ramp.txt
write! <sfile>:h/color_ramp.txt
quit

View File

@ -19,6 +19,9 @@ let script = [
/#define p_term
let end = line('.')
" font name that works everywhere (hopefully)
let fontname = has('win32') ? 'fixedsys' : 'fixed'
" Two lists with values: values that work and values that fail.
" When not listed, "othernum" or "otherstring" is used.
let test_values = {
@ -93,8 +96,9 @@ let test_values = {
\ 'foldmarker': [['((,))'], ['', 'xxx']],
\ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
\ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
\ 'guifont': [['', 'fixedsys'], []],
\ 'guifontwide': [['', 'fixedsys'], []],
\ 'guifont': [['', fontname], []],
\ 'guifontwide': [['', fontname], []],
\ 'guifontset': [['', fontname], []],
\ 'helplang': [['', 'de', 'de,it'], ['xxx']],
\ 'highlight': [['', 'e:Error'], ['xxx']],
\ 'imactivatekey': [['', 'S-space'], ['xxx']],
@ -126,6 +130,7 @@ let test_values = {
\ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
\ 'term': [[], []],
\ 'termsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
\ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
\ 'toolbar': [['', 'icons', 'text'], ['xxx']],
\ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
\ 'ttymouse': [['', 'xterm'], ['xxx']],
@ -189,8 +194,11 @@ while 1
call add(script, "endif")
endif
call add(script, 'set ' . name . '&')
call add(script, 'set ' . shortname . '&')
" cannot change 'termencoding' in GTK
if name != 'termencoding' || !has('gui_gtk')
call add(script, 'set ' . name . '&')
call add(script, 'set ' . shortname . '&')
endif
if name == 'verbosefile'
call add(script, 'call delete("xxx")')
endif

View File

@ -24,6 +24,8 @@ func Test_iminsert2()
set iminsert=0
set imactivatefunc=
set imstatusfunc=
call assert_equal(1, s:imactivatefunc_called)
call assert_equal(1, s:imstatusfunc_called)
let expected = has('gui_running') ? 0 : 1
call assert_equal(expected, s:imactivatefunc_called)
call assert_equal(expected, s:imstatusfunc_called)
endfunc

View File

@ -707,6 +707,10 @@ func Test_balloon_split()
if !exists('*balloon_split')
return
endif
call assert_equal([
\ 'tempname: 0x555555e380a0 "/home/mool/.viminfz.tmp"',
\ ], balloon_split(
\ 'tempname: 0x555555e380a0 "/home/mool/.viminfz.tmp"'))
call assert_equal([
\ 'one two three four one two three four one two thre',
\ 'e four',

View File

@ -1966,26 +1966,136 @@ func Test_Autocmd()
cexpr "F1:10:Line 10"
caddexpr "F1:20:Line 20"
cgetexpr "F1:30:Line 30"
enew! | call append(0, "F2:10:Line 10")
cbuffer!
enew! | call append(0, "F2:20:Line 20")
cgetbuffer
enew! | call append(0, "F2:30:Line 30")
caddbuffer
cexpr ""
caddexpr ""
cgetexpr ""
silent! cexpr non_existing_func()
silent! caddexpr non_existing_func()
silent! cgetexpr non_existing_func()
let l = ['precexpr',
\ 'postcexpr',
\ 'precaddexpr',
\ 'postcaddexpr',
\ 'precgetexpr',
\ 'postcgetexpr',
\ 'precbuffer',
\ 'precexpr',
\ 'postcexpr',
\ 'precaddexpr',
\ 'postcaddexpr',
\ 'precgetexpr',
\ 'postcgetexpr',
\ 'precexpr',
\ 'precaddexpr',
\ 'precgetexpr']
call assert_equal(l, g:acmds)
let g:acmds = []
enew! | call append(0, "F2:10:Line 10")
cbuffer!
enew! | call append(0, "F2:20:Line 20")
cgetbuffer
enew! | call append(0, "F2:30:Line 30")
caddbuffer
new
let bnum = bufnr('%')
bunload
exe 'silent! cbuffer! ' . bnum
exe 'silent! cgetbuffer ' . bnum
exe 'silent! caddbuffer ' . bnum
enew!
let l = ['precbuffer',
\ 'postcbuffer',
\ 'precgetbuffer',
\ 'postcgetbuffer',
\ 'precaddbuffer',
\ 'postcaddbuffer']
\ 'postcaddbuffer',
\ 'precbuffer',
\ 'precgetbuffer',
\ 'precaddbuffer']
call assert_equal(l, g:acmds)
call writefile(['Xtest:1:Line1'], 'Xtest')
call writefile([], 'Xempty')
let g:acmds = []
cfile Xtest
caddfile Xtest
cgetfile Xtest
cfile Xempty
caddfile Xempty
cgetfile Xempty
silent! cfile do_not_exist
silent! caddfile do_not_exist
silent! cgetfile do_not_exist
let l = ['precfile',
\ 'postcfile',
\ 'precaddfile',
\ 'postcaddfile',
\ 'precgetfile',
\ 'postcgetfile',
\ 'precfile',
\ 'postcfile',
\ 'precaddfile',
\ 'postcaddfile',
\ 'precgetfile',
\ 'postcgetfile',
\ 'precfile',
\ 'postcfile',
\ 'precaddfile',
\ 'postcaddfile',
\ 'precgetfile',
\ 'postcgetfile']
call assert_equal(l, g:acmds)
let g:acmds = []
helpgrep quickfix
silent! helpgrep non_existing_help_topic
vimgrep test Xtest
vimgrepadd test Xtest
silent! vimgrep non_existing_test Xtest
silent! vimgrepadd non_existing_test Xtest
set makeprg=
silent! make
set makeprg&
let l = ['prehelpgrep',
\ 'posthelpgrep',
\ 'prehelpgrep',
\ 'posthelpgrep',
\ 'previmgrep',
\ 'postvimgrep',
\ 'previmgrepadd',
\ 'postvimgrepadd',
\ 'previmgrep',
\ 'postvimgrep',
\ 'previmgrepadd',
\ 'postvimgrepadd',
\ 'premake',
\ 'postmake']
call assert_equal(l, g:acmds)
if has('unix')
" Run this test only on Unix-like systems. The grepprg may not be set on
" non-Unix systems.
" The following lines are used for the grep test. Don't remove.
" Grep_Autocmd_Text: Match 1
" GrepAdd_Autocmd_Text: Match 2
let g:acmds = []
silent grep Grep_Autocmd_Text test_quickfix.vim
silent grepadd GrepAdd_Autocmd_Text test_quickfix.vim
silent grep abc123def Xtest
silent grepadd abc123def Xtest
let l = ['pregrep',
\ 'postgrep',
\ 'pregrepadd',
\ 'postgrepadd',
\ 'pregrep',
\ 'postgrep',
\ 'pregrepadd',
\ 'postgrepadd']
call assert_equal(l, g:acmds)
endif
call delete('Xtest')
call delete('Xempty')
endfunc
func Test_Autocmd_Exception()

View File

@ -771,6 +771,36 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1355,
/**/
1354,
/**/
1353,
/**/
1352,
/**/
1351,
/**/
1350,
/**/
1349,
/**/
1348,
/**/
1347,
/**/
1346,
/**/
1345,
/**/
1344,
/**/
1343,
/**/
1342,
/**/
1341,
/**/
1340,
/**/