Permalink
Browse files

Merged from the latest developing branch.

git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1528 2a77ed30-b011-0410-a7ad-c7884a0aa172
  • Loading branch information...
1 parent 07e11e4 commit 4f92679803e88231189bd1a1f45d99a06a2dac33 edyfox committed Jun 17, 2009
Showing with 644 additions and 205 deletions.
  1. +8 −0 runtime/doc/options.txt
  2. +11 −8 src/Make_mvc.mak
  3. +126 −65 src/fileio.c
  4. +8 −0 src/globals.h
  5. +15 −0 src/gui.c
  6. +69 −4 src/gui_gtk_x11.c
  7. +7 −1 src/gvim.exe.mnf
  8. +1 −1 src/if_perl.xs
  9. +140 −19 src/mbyte.c
  10. +1 −0 src/netbeans.c
  11. +9 −2 src/option.c
  12. +2 −1 src/os_unix.c
  13. +1 −0 src/proto/gui.pro
  14. +3 −0 src/proto/mbyte.pro
  15. +7 −0 src/proto/window.pro
  16. +12 −0 src/screen.c
  17. +13 −10 src/structs.h
  18. +1 −1 src/term.c
  19. +24 −0 src/version.c
  20. +5 −5 src/vim.h
  21. +176 −84 src/window.c
  22. +5 −4 src/xxd/xxd.c
View
8 runtime/doc/options.txt
@@ -1443,6 +1443,14 @@ A jump table for the options with a short description can be found at |Q_op|.
autoselectml Like "autoselect", but for the modeless selection
only. Compare to the 'A' flag in 'guioptions'.
+ html When the clipboard contains HTML, use this when
+ pasting. When putting text on the clipboard, mark it
+ as HTML. This works to copy rendered HTML from
+ Firefox, paste it as raw HTML in Vim, select the HTML
+ in Vim and paste it in a rich edit box in Firefox.
+ Only supported for GTK version 2 and later.
+ Only available with the |+multi_byte| feature.
+
exclude:{pattern}
Defines a pattern that is matched against the name of
the terminal 'term'. If there is a match, no
View
19 src/Make_mvc.mak
@@ -1,18 +1,18 @@
# Makefile for Vim on Win32 (Windows NT/2000/XP/2003 and Windows 95/98/Me)
# and Win64, using the Microsoft Visual C++ compilers. Known to work with
# VC5, VC6 (VS98), VC7.0 (VS2002), VC7.1 (VS2003), VC8 (VS2005),
-# and VC9 (VS2008).
+# VC9 (VS2008), and VC10 (VS2010).
#
# To build using other Windows compilers, see INSTALLpc.txt
#
# This makefile can build the console, GUI, OLE-enable, Perl-enabled and
-# Python-enabled versions of vim for Win32 platforms.
+# Python-enabled versions of Vim for Win32 platforms.
#
-# The basic command line to build vim is:
+# The basic command line to build Vim is:
#
# nmake -f Make_mvc.mak
#
-# This will build the console version of vim with no additional interfaces.
+# This will build the console version of Vim with no additional interfaces.
# To add features, define any of the following:
#
# !!!! After changing features do "nmake clean" first !!!!
@@ -358,6 +358,9 @@ MSVCVER = 9.0
!if "$(_NMAKE_VER)" == "9.00.30729.01"
MSVCVER = 9.0
!endif
+!if "$(_NMAKE_VER)" == "10.00.20506.01"
+MSVCVER = 10.0
+!endif
!endif
# Abort bulding VIM if version of VC is unrecognised.
@@ -372,7 +375,7 @@ MSVCVER = 9.0
!endif
# Convert processor ID to MVC-compatible number
-!if ("$(MSVCVER)" != "8.0") && ("$(MSVCVER)" != "9.0")
+!if ("$(MSVCVER)" != "8.0") && ("$(MSVCVER)" != "9.0") && ("$(MSVCVER)" != "10.0")
!if "$(CPUNR)" == "i386"
CPUARG = /G3
!elseif "$(CPUNR)" == "i486"
@@ -405,7 +408,7 @@ OPTFLAG = /O2
!else # MAXSPEED
OPTFLAG = /Ox
!endif
-!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0")
+!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0") || ("$(MSVCVER)" == "10.0")
# Use link time code generation if not worried about size
!if "$(OPTIMIZE)" != "SPACE"
OPTFLAG = $(OPTFLAG) /GL
@@ -793,7 +796,7 @@ LINKARGS2 = $(CON_LIB) $(GUI_LIB) $(LIBC) $(OLE_LIB) user32.lib $(SNIFF_LIB) \
# Report link time code generation progress if used.
!ifdef NODEBUG
-!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0")
+!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0") || ("$(MSVCVER)" == "10.0")
!if "$(OPTIMIZE)" != "SPACE"
LINKARGS1 = $(LINKARGS1) /LTCG:STATUS
!endif
@@ -1037,7 +1040,7 @@ $(OUTDIR)/window.obj: $(OUTDIR) window.c $(INCL)
$(OUTDIR)/xpm_w32.obj: $(OUTDIR) xpm_w32.c
$(CC) $(CFLAGS) $(XPM_INC) xpm_w32.c
-$(OUTDIR)/vim.res: $(OUTDIR) vim.rc version.h tools.bmp tearoff.bmp \
+$(OUTDIR)/vim.res: $(OUTDIR) vim.rc gvim.exe.mnf version.h tools.bmp tearoff.bmp \
vim.ico vim_error.ico vim_alert.ico vim_info.ico vim_quest.ico
$(RC) /l 0x409 /Fo$(OUTDIR)/vim.res $(RCFLAGS) vim.rc
View
191 src/fileio.c
@@ -4824,6 +4824,8 @@ set_rw_fname(fname, sfname)
char_u *sfname;
{
#ifdef FEAT_AUTOCMD
+ buf_T *buf = curbuf;
+
/* It's like the unnamed buffer is deleted.... */
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
@@ -4832,6 +4834,12 @@ set_rw_fname(fname, sfname)
if (aborting()) /* autocmds may abort script processing */
return FAIL;
# endif
+ if (curbuf != buf)
+ {
+ /* We are in another buffer now, don't do the renaming. */
+ EMSG(_(e_auchangedbuf));
+ return FAIL;
+ }
#endif
if (setfname(curbuf, fname, sfname, FALSE) == OK)
@@ -8357,7 +8365,7 @@ ex_doautoall(eap)
/* Execute the modeline settings, but don't set window-local
* options if we are using the current window for another buffer. */
- do_modelines(aco.save_curwin == NULL ? OPT_NOWIN : 0);
+ do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
/* restore the current window */
aucmd_restbuf(&aco);
@@ -8373,8 +8381,8 @@ ex_doautoall(eap)
/*
* Prepare for executing autocommands for (hidden) buffer "buf".
- * Search a window for the current buffer. Save the cursor position and
- * screen offset.
+ * Search for a visible window containing the current buffer. If there isn't
+ * one then use "aucmd_win".
* Set "curbuf" and "curwin" to match "buf".
* When FEAT_AUTOCMD is not defined another version is used, see below.
*/
@@ -8384,8 +8392,9 @@ aucmd_prepbuf(aco, buf)
buf_T *buf; /* new curbuf */
{
win_T *win;
-
- aco->new_curbuf = buf;
+#ifdef FEAT_WINDOWS
+ int save_ea;
+#endif
/* Find a window that is for the new buffer */
if (buf == curbuf) /* be quick when buf is curbuf */
@@ -8399,42 +8408,53 @@ aucmd_prepbuf(aco, buf)
win = NULL;
#endif
- /*
- * Prefer to use an existing window for the buffer, it has the least side
- * effects (esp. if "buf" is curbuf).
- * Otherwise, use curwin for "buf". It might make some items in the
- * window invalid. At least save the cursor and topline.
- */
+ /* Allocate "aucmd_win" when needed. If this fails (out of memory) fall
+ * back to using the current window. */
+ if (win == NULL && aucmd_win == NULL)
+ {
+ win_alloc_aucmd_win();
+ if (aucmd_win == NULL)
+ win = curwin;
+ }
+
+ aco->save_curwin = curwin;
+ aco->save_curbuf = curbuf;
if (win != NULL)
{
- /* there is a window for "buf", make it the curwin */
- aco->save_curwin = curwin;
+ /* There is a window for "buf" in the current tab page, make it the
+ * curwin. This is preferred, it has the least side effects (esp. if
+ * "buf" is curbuf). */
curwin = win;
- aco->save_buf = win->w_buffer;
- aco->new_curwin = win;
}
else
{
- /* there is no window for "buf", use curwin */
- aco->save_curwin = NULL;
- aco->save_buf = curbuf;
- --curbuf->b_nwindows;
+ /* There is no window for "buf", use "aucmd_win". To minimize the side
+ * effects, insert it in a the current tab page.
+ * Anything related to a window (e.g., setting folds) may have
+ * unexpected results. */
+ curwin = aucmd_win;
curwin->w_buffer = buf;
++buf->b_nwindows;
- /* save cursor and topline, set them to safe values */
- aco->save_cursor = curwin->w_cursor;
- curwin->w_cursor.lnum = 1;
- curwin->w_cursor.col = 0;
- aco->save_topline = curwin->w_topline;
- curwin->w_topline = 1;
-#ifdef FEAT_DIFF
- aco->save_topfill = curwin->w_topfill;
- curwin->w_topfill = 0;
+#ifdef FEAT_WINDOWS
+ /* Split the current window, put the aucmd_win in the upper half. */
+ make_snapshot(SNAP_AUCMD_IDX);
+ save_ea = p_ea;
+ p_ea = FALSE;
+ (void)win_split_ins(0, WSP_TOP, aucmd_win, 0);
+ (void)win_comp_pos(); /* recompute window positions */
+ p_ea = save_ea;
+#endif
+ /* set cursor and topline to safe values */
+ curwin_init();
+#ifdef FEAT_VERTSPLIT
+ curwin->w_wincol = 0;
+ curwin->w_width = Columns;
#endif
}
-
curbuf = buf;
+ aco->new_curwin = curwin;
+ aco->new_curbuf = curbuf;
}
/*
@@ -8446,21 +8466,86 @@ aucmd_prepbuf(aco, buf)
aucmd_restbuf(aco)
aco_save_T *aco; /* structure holding saved values */
{
- if (aco->save_curwin != NULL)
+#ifdef FEAT_WINDOWS
+ int dummy;
+#endif
+
+ if (aco->new_curwin == aucmd_win)
+ {
+ --curbuf->b_nwindows;
+#ifdef FEAT_WINDOWS
+ /* Find "aucmd_win", it can't be closed, but it may be in another tab
+ * page. */
+ if (curwin != aucmd_win)
+ {
+ tabpage_T *tp;
+ win_T *wp;
+
+ FOR_ALL_TAB_WINDOWS(tp, wp)
+ {
+ if (wp == aucmd_win)
+ {
+ if (tp != curtab)
+ goto_tabpage_tp(tp);
+ win_goto(aucmd_win);
+ break;
+ }
+ }
+ }
+
+ /* Remove the window and frame from the tree of frames. */
+ (void)winframe_remove(curwin, &dummy, NULL);
+ win_remove(curwin, NULL);
+ last_status(FALSE); /* may need to remove last status line */
+ restore_snapshot(SNAP_AUCMD_IDX, FALSE);
+ (void)win_comp_pos(); /* recompute window positions */
+
+ if (win_valid(aco->save_curwin))
+ curwin = aco->save_curwin;
+ else
+ /* Hmm, original window disappeared. Just use the first one. */
+ curwin = firstwin;
+# ifdef FEAT_EVAL
+ vars_clear(&aucmd_win->w_vars.dv_hashtab); /* free all w: variables */
+# endif
+#else
+ curwin = aco->save_curwin;
+#endif
+ curbuf = curwin->w_buffer;
+
+ /* the buffer contents may have changed */
+ check_cursor();
+ if (curwin->w_topline > curbuf->b_ml.ml_line_count)
+ {
+ curwin->w_topline = curbuf->b_ml.ml_line_count;
+#ifdef FEAT_DIFF
+ curwin->w_topfill = 0;
+#endif
+ }
+#if defined(FEAT_GUI)
+ /* Hide the scrollbars from the aucmd_win and update. */
+ gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_LEFT], FALSE);
+ gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_RIGHT], FALSE);
+ gui_may_update_scrollbars();
+#endif
+ }
+ else
{
/* restore curwin */
#ifdef FEAT_WINDOWS
if (win_valid(aco->save_curwin))
#endif
{
- /* restore the buffer which was previously edited by curwin, if
- * it's still the same window and it's valid */
+ /* Restore the buffer which was previously edited by curwin, if
+ * it was chagned, we are still the same window and the buffer is
+ * valid. */
if (curwin == aco->new_curwin
- && buf_valid(aco->save_buf)
- && aco->save_buf->b_ml.ml_mfp != NULL)
+ && curbuf != aco->new_curbuf
+ && buf_valid(aco->new_curbuf)
+ && aco->new_curbuf->b_ml.ml_mfp != NULL)
{
--curbuf->b_nwindows;
- curbuf = aco->save_buf;
+ curbuf = aco->new_curbuf;
curwin->w_buffer = curbuf;
++curbuf->b_nwindows;
}
@@ -8469,34 +8554,6 @@ aucmd_restbuf(aco)
curbuf = curwin->w_buffer;
}
}
- else
- {
- /* restore buffer for curwin if it still exists and is loaded */
- if (buf_valid(aco->save_buf) && aco->save_buf->b_ml.ml_mfp != NULL)
- {
- --curbuf->b_nwindows;
- curbuf = aco->save_buf;
- curwin->w_buffer = curbuf;
- ++curbuf->b_nwindows;
- curwin->w_cursor = aco->save_cursor;
- check_cursor();
- /* check topline < line_count, in case lines got deleted */
- if (aco->save_topline <= curbuf->b_ml.ml_line_count)
- {
- curwin->w_topline = aco->save_topline;
-#ifdef FEAT_DIFF
- curwin->w_topfill = aco->save_topfill;
-#endif
- }
- else
- {
- curwin->w_topline = curbuf->b_ml.ml_line_count;
-#ifdef FEAT_DIFF
- curwin->w_topfill = 0;
-#endif
- }
- }
- }
}
static int autocmd_nested = FALSE;
@@ -9411,9 +9468,11 @@ aucmd_prepbuf(aco, buf)
aco_save_T *aco; /* structure to save values in */
buf_T *buf; /* new curbuf */
{
- aco->save_buf = curbuf;
+ aco->save_curbuf = curbuf;
+ --curbuf->b_nwindows;
curbuf = buf;
curwin->w_buffer = buf;
+ ++curbuf->b_nwindows;
}
/*
@@ -9424,8 +9483,10 @@ aucmd_prepbuf(aco, buf)
aucmd_restbuf(aco)
aco_save_T *aco; /* structure holding saved values */
{
- curbuf = aco->save_buf;
+ --curbuf->b_nwindows;
+ curbuf = aco->save_curbuf;
curwin->w_buffer = curbuf;
+ ++curbuf->b_nwindows;
}
#endif /* FEAT_AUTOCMD */
View
8 src/globals.h
@@ -509,6 +509,7 @@ EXTERN VimClipboard clip_plus; /* CLIPBOARD selection in X11 */
EXTERN int clip_unnamed INIT(= FALSE);
EXTERN int clip_autoselect INIT(= FALSE);
EXTERN int clip_autoselectml INIT(= FALSE);
+EXTERN int clip_html INIT(= FALSE);
EXTERN regprog_T *clip_exclude_prog INIT(= NULL);
#endif
@@ -538,6 +539,10 @@ EXTERN win_T *prevwin INIT(= NULL); /* previous window */
EXTERN win_T *curwin; /* currently active window */
+#ifdef FEAT_AUTOCMD
+EXTERN win_T *aucmd_win; /* window used in aucmd_prepbuf() */
+#endif
+
/*
* The window layout is kept in a tree of frames. topframe points to the top
* of the tree.
@@ -810,11 +815,14 @@ EXTERN vimconv_T output_conv; /* type of output conversion */
*/
/* length of char in bytes, including following composing chars */
EXTERN int (*mb_ptr2len) __ARGS((char_u *p)) INIT(= latin_ptr2len);
+/* idem, with limit on string length */
+EXTERN int (*mb_ptr2len_len) __ARGS((char_u *p, int size)) INIT(= latin_ptr2len_len);
/* byte length of char */
EXTERN int (*mb_char2len) __ARGS((int c)) INIT(= latin_char2len);
/* convert char to bytes, return the length */
EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
+EXTERN int (*mb_ptr2cells_len) __ARGS((char_u *p, int size)) INIT(= latin_ptr2cells_len);
EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
EXTERN int (*mb_off2cells) __ARGS((unsigned off, unsigned max_off)) INIT(= latin_off2cells);
EXTERN int (*mb_ptr2char) __ARGS((char_u *p)) INIT(= latin_ptr2char);
View
15 src/gui.c
@@ -3879,6 +3879,21 @@ gui_drag_scrollbar(sb, value, still_dragging)
* Scrollbar stuff:
*/
+/*
+ * Called when something in the window layout has changed.
+ */
+ void
+gui_may_update_scrollbars()
+{
+ if (gui.in_use && starting == 0)
+ {
+ out_flush();
+ gui_init_which_components(NULL);
+ gui_update_scrollbars(TRUE);
+ }
+ need_mouse_correct = TRUE;
+}
+
void
gui_update_scrollbars(force)
int force; /* Force all scrollbars to get updated */
View
73 src/gui_gtk_x11.c
@@ -107,6 +107,7 @@ enum
TARGET_UTF8_STRING,
TARGET_STRING,
TARGET_COMPOUND_TEXT,
+ TARGET_HTML,
TARGET_TEXT,
TARGET_TEXT_URI_LIST,
TARGET_TEXT_PLAIN,
@@ -123,6 +124,7 @@ static const GtkTargetEntry selection_targets[] =
{VIMENC_ATOM_NAME, 0, TARGET_VIMENC},
{VIM_ATOM_NAME, 0, TARGET_VIM},
#ifdef FEAT_MBYTE
+ {"text/html", 0, TARGET_HTML},
{"UTF8_STRING", 0, TARGET_UTF8_STRING},
#endif
{"COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT},
@@ -140,6 +142,7 @@ static const GtkTargetEntry dnd_targets[] =
{
{"text/uri-list", 0, TARGET_TEXT_URI_LIST},
# ifdef FEAT_MBYTE
+ {"text/html", 0, TARGET_HTML},
{"UTF8_STRING", 0, TARGET_UTF8_STRING},
# endif
{"STRING", 0, TARGET_STRING},
@@ -178,6 +181,7 @@ static GdkAtom save_yourself_atom = GDK_NONE;
* Atoms used to control/reference X11 selections.
*/
#ifdef FEAT_MBYTE
+static GdkAtom html_atom = GDK_NONE;
static GdkAtom utf8_string_atom = GDK_NONE;
#endif
#ifndef HAVE_GTK2
@@ -1364,6 +1368,24 @@ selection_received_cb(GtkWidget *widget UNUSED,
else
text = tmpbuf_utf8;
}
+ else if (len >= 2 && text[0] == 0xff && text[1] == 0xfe)
+ {
+ vimconv_T conv;
+
+ /* UTF-16, we get this for HTML */
+ conv.vc_type = CONV_NONE;
+ convert_setup_ext(&conv, (char_u *)"utf-16le", FALSE, p_enc, TRUE);
+
+ if (conv.vc_type != CONV_NONE)
+ {
+ text += 2;
+ len -= 2;
+ tmpbuf = string_convert(&conv, text, &len);
+ convert_setup(&conv, NULL, NULL);
+ }
+ if (tmpbuf != NULL)
+ text = tmpbuf;
+ }
}
#else /* !HAVE_GTK2 */
# ifdef FEAT_MBYTE
@@ -1451,6 +1473,7 @@ selection_get_cb(GtkWidget *widget UNUSED,
if (info != (guint)TARGET_STRING
#ifdef FEAT_MBYTE
+ && (!clip_html || info != (guint)TARGET_HTML)
&& info != (guint)TARGET_UTF8_STRING
&& info != (guint)TARGET_VIMENC
#endif
@@ -1486,6 +1509,40 @@ selection_get_cb(GtkWidget *widget UNUSED,
}
#ifdef FEAT_MBYTE
+ else if (info == (guint)TARGET_HTML)
+ {
+ vimconv_T conv;
+
+ /* Since we get utf-16, we probably should set it as well. */
+ conv.vc_type = CONV_NONE;
+ convert_setup_ext(&conv, p_enc, TRUE, (char_u *)"utf-16le", FALSE);
+ if (conv.vc_type != CONV_NONE)
+ {
+ tmpbuf = string_convert(&conv, string, &length);
+ convert_setup(&conv, NULL, NULL);
+ vim_free(string);
+ string = tmpbuf;
+ }
+
+ /* Prepend the BOM: "fffe" */
+ if (string != NULL)
+ {
+ tmpbuf = alloc(length + 2);
+ tmpbuf[0] = 0xff;
+ tmpbuf[1] = 0xfe;
+ mch_memmove(tmpbuf + 2, string, (size_t)length);
+ vim_free(string);
+ string = tmpbuf;
+ length += 2;
+
+ selection_data->type = selection_data->target;
+ selection_data->format = 16; /* 16 bits per char */
+ gtk_selection_data_set(selection_data, html_atom, 16,
+ string, length);
+ vim_free(string);
+ }
+ return;
+ }
else if (info == (guint)TARGET_VIMENC)
{
int l = STRLEN(p_enc);
@@ -3464,6 +3521,7 @@ gui_mch_init(void)
/* Initialise atoms */
#ifdef FEAT_MBYTE
+ html_atom = gdk_atom_intern("text/html", FALSE);
utf8_string_atom = gdk_atom_intern("UTF8_STRING", FALSE);
#endif
#ifndef HAVE_GTK2
@@ -6077,12 +6135,15 @@ gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
# ifdef FEAT_MBYTE
if (enc_utf8)
{
- c = utf_ptr2char(p);
+ int pcc[MAX_MCO];
+
+ /* TODO: use the composing characters */
+ c = utfc_ptr2char_len(p, &pcc, len - (p - s));
if (c >= 0x10000) /* show chars > 0xffff as ? */
c = 0xbf;
buf[textlen].byte1 = c >> 8;
buf[textlen].byte2 = c;
- p += utf_ptr2len(p);
+ p += utfc_ptr2len_len(p, len - (p - s));
width += utf_char2cells(c);
}
else
@@ -6106,8 +6167,8 @@ gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
if (has_mbyte)
{
width = 0;
- for (p = s; p < s + len; p += (*mb_ptr2len)(p))
- width += (*mb_ptr2cells)(p);
+ for (p = s; p < s + len; p += (*mb_ptr2len_len)(p, len - (p - s)))
+ width += (*mb_ptr2cells_len)(p, len - (p - s));
}
else
# endif
@@ -6662,6 +6723,10 @@ clip_mch_request_selection(VimClipboard *cbd)
for (i = 0; i < N_SELECTION_TARGETS; ++i)
{
+#ifdef FEAT_MBYTE
+ if (!clip_html && selection_targets[i].info == TARGET_HTML)
+ continue;
+#endif
received_selection = RS_NONE;
target = gdk_atom_intern(selection_targets[i].target, FALSE);
View
8 src/gvim.exe.mnf
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<assemblyIdentity
processorArchitecture="*"
version="7.2.0.0"
@@ -29,4 +29,10 @@
</requestedPrivileges>
</security>
</trustInfo>
+ <!-- Vista High DPI aware -->
+ <asmv3:application>
+ <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
+ <dpiAware>true</dpiAware>
+ </asmv3:windowsSettings>
+ </asmv3:application>
</assembly>
View
2 src/if_perl.xs
@@ -1234,7 +1234,7 @@ Delete(vimbuf, ...)
{
ml_delete(lnum, 0);
deleted_lines_mark(lnum, 1L);
- if (aco.save_buf == curbuf)
+ if (aco.save_curbuf == curbuf)
check_cursor();
}
View
159 src/mbyte.c
@@ -127,7 +127,10 @@ static int enc_canon_search __ARGS((char_u *name));
static int dbcs_char2len __ARGS((int c));
static int dbcs_char2bytes __ARGS((int c, char_u *buf));
static int dbcs_ptr2len __ARGS((char_u *p));
+static int dbcs_ptr2len_len __ARGS((char_u *p, int size));
+static int utf_ptr2cells_len __ARGS((char_u *p, int size));
static int dbcs_char2cells __ARGS((int c));
+static int dbcs_ptr2cells_len __ARGS((char_u *p, int size));
static int dbcs_ptr2char __ARGS((char_u *p));
/* Lookup table to quickly get the length in bytes of a UTF-8 character from
@@ -606,9 +609,11 @@ mb_init()
if (enc_utf8)
{
mb_ptr2len = utfc_ptr2len;
+ mb_ptr2len_len = utfc_ptr2len_len;
mb_char2len = utf_char2len;
mb_char2bytes = utf_char2bytes;
mb_ptr2cells = utf_ptr2cells;
+ mb_ptr2cells_len = utf_ptr2cells_len;
mb_char2cells = utf_char2cells;
mb_off2cells = utf_off2cells;
mb_ptr2char = utf_ptr2char;
@@ -617,9 +622,11 @@ mb_init()
else if (enc_dbcs != 0)
{
mb_ptr2len = dbcs_ptr2len;
+ mb_ptr2len_len = dbcs_ptr2len_len;
mb_char2len = dbcs_char2len;
mb_char2bytes = dbcs_char2bytes;
mb_ptr2cells = dbcs_ptr2cells;
+ mb_ptr2cells_len = dbcs_ptr2cells_len;
mb_char2cells = dbcs_char2cells;
mb_off2cells = dbcs_off2cells;
mb_ptr2char = dbcs_ptr2char;
@@ -628,9 +635,11 @@ mb_init()
else
{
mb_ptr2len = latin_ptr2len;
+ mb_ptr2len_len = latin_ptr2len_len;
mb_char2len = latin_char2len;
mb_char2bytes = latin_char2bytes;
mb_ptr2cells = latin_ptr2cells;
+ mb_ptr2cells_len = latin_ptr2cells_len;
mb_char2cells = latin_char2cells;
mb_off2cells = latin_off2cells;
mb_ptr2char = latin_ptr2char;
@@ -1069,7 +1078,6 @@ dbcs_char2bytes(c, buf)
* Get byte length of character at "*p" but stop at a NUL.
* For UTF-8 this includes following composing characters.
* Returns 0 when *p is NUL.
- *
*/
int
latin_ptr2len(p)
@@ -1091,6 +1099,40 @@ dbcs_ptr2len(p)
return len;
}
+/*
+ * mb_ptr2len_len() function pointer.
+ * Like mb_ptr2len(), but limit to read "size" bytes.
+ * Returns 0 for an empty string.
+ * Returns 1 for an illegal char or an incomplete byte sequence.
+ */
+ int
+latin_ptr2len_len(p, size)
+ char_u *p;
+ int size;
+{
+ if (size < 1 || *p == NUL)
+ return 0;
+ return 1;
+}
+
+ static int
+dbcs_ptr2len_len(p, size)
+ char_u *p;
+ int size;
+{
+ int len;
+
+ if (size < 1 || *p == NUL)
+ return 0;
+ if (size == 1)
+ return 1;
+ /* Check that second byte is not missing. */
+ len = MB_BYTE2LEN(*p);
+ if (len == 2 && p[1] == NUL)
+ len = 1;
+ return len;
+}
+
struct interval
{
unsigned short first;
@@ -1287,6 +1329,55 @@ dbcs_ptr2cells(p)
}
/*
+ * mb_ptr2cells_len() function pointer.
+ * Like mb_ptr2cells(), but limit string length to "size".
+ * For an empty string or truncated character returns 1.
+ */
+ int
+latin_ptr2cells_len(p, size)
+ char_u *p UNUSED;
+ int size UNUSED;
+{
+ return 1;
+}
+
+ static int
+utf_ptr2cells_len(p, size)
+ char_u *p;
+ int size;
+{
+ int c;
+
+ /* Need to convert to a wide character. */
+ if (size > 0 && *p >= 0x80)
+ {
+ if (utf_ptr2len_len(p, size) < utf8len_tab[*p])
+ return 1;
+ c = utf_ptr2char(p);
+ /* An illegal byte is displayed as <xx>. */
+ if (utf_ptr2len(p) == 1 || c == NUL)
+ return 4;
+ /* If the char is ASCII it must be an overlong sequence. */
+ if (c < 0x80)
+ return char2cells(c);
+ return utf_char2cells(c);
+ }
+ return 1;
+}
+
+ static int
+dbcs_ptr2cells_len(p, size)
+ char_u *p;
+ int size;
+{
+ /* Number of cells is equal to number of bytes, except for euc-jp when
+ * the first byte is 0x8e. */
+ if (size <= 1 || (enc_dbcs == DBCS_JPNU && *p == 0x8e))
+ return 1;
+ return MB_BYTE2LEN(*p);
+}
+
+/*
* mb_char2cells() function pointer.
* Return the number of display cells character "c" occupies.
* Only takes care of multi-byte chars, not "^C" and such.
@@ -1716,6 +1807,7 @@ utfc_ptr2len(p)
/*
* Return the number of bytes the UTF-8 encoding of the character at "p[size]"
* takes. This includes following composing characters.
+ * Returns 0 for an empty string.
* Returns 1 for an illegal char or an incomplete byte sequence.
*/
int
@@ -1728,7 +1820,7 @@ utfc_ptr2len_len(p, size)
int prevlen;
#endif
- if (*p == NUL)
+ if (size < 1 || *p == NUL)
return 0;
if (p[0] < 0x80 && (size == 1 || p[1] < 0x80)) /* be quick for ASCII */
return 1;
@@ -3173,7 +3265,7 @@ encname2codepage(name)
# if defined(USE_ICONV) || defined(PROTO)
-static char_u *iconv_string __ARGS((vimconv_T *vcp, char_u *str, int slen, int *unconvlenp));
+static char_u *iconv_string __ARGS((vimconv_T *vcp, char_u *str, int slen, int *unconvlenp, int *resultlenp));
/*
* Call iconv_open() with a check if iconv() works properly (there are broken
@@ -3234,13 +3326,15 @@ my_iconv_open(to, from)
* If "unconvlenp" is not NULL handle the string ending in an incomplete
* sequence and set "*unconvlenp" to the length of it.
* Returns the converted string in allocated memory. NULL for an error.
+ * If resultlenp is not NULL, sets it to the result length in bytes.
*/
static char_u *
-iconv_string(vcp, str, slen, unconvlenp)
+iconv_string(vcp, str, slen, unconvlenp, resultlenp)
vimconv_T *vcp;
char_u *str;
int slen;
int *unconvlenp;
+ int *resultlenp;
{
const char *from;
size_t fromlen;
@@ -3326,6 +3420,9 @@ iconv_string(vcp, str, slen, unconvlenp)
/* Not enough room or skipping illegal sequence. */
done = to - (char *)result;
}
+
+ if (resultlenp != NULL)
+ *resultlenp = (int)(to - (char *)result);
return result;
}
@@ -5745,8 +5842,25 @@ convert_setup(vcp, from, to)
char_u *from;
char_u *to;
{
+ return convert_setup_ext(vcp, from, TRUE, to, TRUE);
+}
+
+/*
+ * As convert_setup(), but only when from_unicode_is_utf8 is TRUE will all
+ * "from" unicode charsets be considered utf-8. Same for "to".
+ */
+ int
+convert_setup_ext(vcp, from, from_unicode_is_utf8, to, to_unicode_is_utf8)
+ vimconv_T *vcp;
+ char_u *from;
+ int from_unicode_is_utf8;
+ char_u *to;
+ int to_unicode_is_utf8;
+{
int from_prop;
int to_prop;
+ int from_is_utf8;
+ int to_is_utf8;
/* Reset to no conversion. */
# ifdef USE_ICONV
@@ -5764,45 +5878,54 @@ convert_setup(vcp, from, to)
from_prop = enc_canon_props(from);
to_prop = enc_canon_props(to);
- if ((from_prop & ENC_LATIN1) && (to_prop & ENC_UNICODE))
+ if (from_unicode_is_utf8)
+ from_is_utf8 = from_prop & ENC_UNICODE;
+ else
+ from_is_utf8 = from_prop == ENC_UNICODE;
+ if (to_unicode_is_utf8)
+ to_is_utf8 = to_prop & ENC_UNICODE;
+ else
+ to_is_utf8 = to_prop == ENC_UNICODE;
+
+ if ((from_prop & ENC_LATIN1) && to_is_utf8)
{
/* Internal latin1 -> utf-8 conversion. */
vcp->vc_type = CONV_TO_UTF8;
vcp->vc_factor = 2; /* up to twice as long */
}
- else if ((from_prop & ENC_LATIN9) && (to_prop & ENC_UNICODE))
+ else if ((from_prop & ENC_LATIN9) && to_is_utf8)
{
/* Internal latin9 -> utf-8 conversion. */
vcp->vc_type = CONV_9_TO_UTF8;
vcp->vc_factor = 3; /* up to three as long (euro sign) */
}
- else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_LATIN1))
+ else if (from_is_utf8 && (to_prop & ENC_LATIN1))
{
/* Internal utf-8 -> latin1 conversion. */
vcp->vc_type = CONV_TO_LATIN1;
}
- else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_LATIN9))
+ else if (from_is_utf8 && (to_prop & ENC_LATIN9))
{
/* Internal utf-8 -> latin9 conversion. */
vcp->vc_type = CONV_TO_LATIN9;
}
#ifdef WIN3264
/* Win32-specific codepage <-> codepage conversion without iconv. */
- else if (((from_prop & ENC_UNICODE) || encname2codepage(from) > 0)
- && ((to_prop & ENC_UNICODE) || encname2codepage(to) > 0))
+ else if ((from_is_utf8 || encname2codepage(from) > 0)
+ && (to_is_utf8 || encname2codepage(to) > 0))
{
vcp->vc_type = CONV_CODEPAGE;
vcp->vc_factor = 2; /* up to twice as long */
- vcp->vc_cpfrom = (from_prop & ENC_UNICODE) ? 0 : encname2codepage(from);
- vcp->vc_cpto = (to_prop & ENC_UNICODE) ? 0 : encname2codepage(to);
+ vcp->vc_cpfrom = from_is_utf8 ? 0 : encname2codepage(from);
+ vcp->vc_cpto = to_is_utf8 ? 0 : encname2codepage(to);
}
#endif
#ifdef MACOS_X
else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_LATIN1))
{
vcp->vc_type = CONV_MAC_LATIN1;
}
- else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_UNICODE))
+ else if ((from_prop & ENC_MACROMAN) && to_is_utf8)
{
vcp->vc_type = CONV_MAC_UTF8;
vcp->vc_factor = 2; /* up to twice as long */
@@ -5811,7 +5934,7 @@ convert_setup(vcp, from, to)
{
vcp->vc_type = CONV_LATIN1_MAC;
}
- else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_MACROMAN))
+ else if (from_is_utf8 && (to_prop & ENC_MACROMAN))
{
vcp->vc_type = CONV_UTF8_MAC;
}
@@ -5821,8 +5944,8 @@ convert_setup(vcp, from, to)
{
/* Use iconv() for conversion. */
vcp->vc_fd = (iconv_t)my_iconv_open(
- (to_prop & ENC_UNICODE) ? (char_u *)"utf-8" : to,
- (from_prop & ENC_UNICODE) ? (char_u *)"utf-8" : from);
+ to_is_utf8 ? (char_u *)"utf-8" : to,
+ from_is_utf8 ? (char_u *)"utf-8" : from);
if (vcp->vc_fd != (iconv_t)-1)
{
vcp->vc_type = CONV_ICONV;
@@ -6078,9 +6201,7 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp)
# ifdef USE_ICONV
case CONV_ICONV: /* conversion with output_conv.vc_fd */
- retval = iconv_string(vcp, ptr, len, unconvlenp);
- if (retval != NULL && lenp != NULL)
- *lenp = (int)STRLEN(retval);
+ retval = iconv_string(vcp, ptr, len, unconvlenp, lenp);
break;
# endif
# ifdef WIN3264
View
1 src/netbeans.c
@@ -32,6 +32,7 @@
/* WinSock API is separated from C API, thus we can't use read(), write(),
* errno... */
# define sock_errno WSAGetLastError()
+# undef ECONNREFUSED
# define ECONNREFUSED WSAECONNREFUSED
# ifdef EINTR
# undef EINTR
View
11 src/option.c
@@ -4006,7 +4006,7 @@ do_set(arg, opt_flags)
else
{
prefix = 1;
- if (STRNCMP(arg, "no", 2) == 0)
+ if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
{
prefix = 0;
arg += 2;
@@ -7024,6 +7024,7 @@ check_clipboard_option()
int new_unnamed = FALSE;
int new_autoselect = FALSE;
int new_autoselectml = FALSE;
+ int new_html = FALSE;
regprog_T *new_exclude_prog = NULL;
char_u *errmsg = NULL;
char_u *p;
@@ -7047,6 +7048,11 @@ check_clipboard_option()
new_autoselectml = TRUE;
p += 12;
}
+ else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
+ {
+ new_html = TRUE;
+ p += 4;
+ }
else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
{
p += 8;
@@ -7068,6 +7074,7 @@ check_clipboard_option()
clip_unnamed = new_unnamed;
clip_autoselect = new_autoselect;
clip_autoselectml = new_autoselectml;
+ clip_html = new_html;
vim_free(clip_exclude_prog);
clip_exclude_prog = new_exclude_prog;
}
@@ -9750,7 +9757,7 @@ set_context_in_set_cmd(xp, arg, opt_flags)
}
--p;
}
- if (STRNCMP(p, "no", 2) == 0)
+ if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
{
xp->xp_context = EXPAND_BOOL_SETTINGS;
p += 2;
View
3 src/os_unix.c
@@ -4305,7 +4305,8 @@ mch_call_shell(cmd, options)
ta_buf[i] = '\n';
# ifdef FEAT_MBYTE
if (has_mbyte)
- i += (*mb_ptr2len)(ta_buf + i) - 1;
+ i += (*mb_ptr2len_len)(ta_buf + i,
+ ta_len + len - i) - 1;
# endif
}
View
1 src/proto/gui.pro
@@ -43,6 +43,7 @@ void gui_remove_scrollbars __ARGS((void));
void gui_create_scrollbar __ARGS((scrollbar_T *sb, int type, win_T *wp));
scrollbar_T *gui_find_scrollbar __ARGS((long ident));
void gui_drag_scrollbar __ARGS((scrollbar_T *sb, long value, int still_dragging));
+void gui_may_update_scrollbars __ARGS((void));
void gui_update_scrollbars __ARGS((int force));
int gui_do_scroll __ARGS((void));
int gui_do_horiz_scroll __ARGS((void));
View
3 src/proto/mbyte.pro
@@ -7,10 +7,12 @@ int dbcs_class __ARGS((unsigned lead, unsigned trail));
int latin_char2len __ARGS((int c));
int latin_char2bytes __ARGS((int c, char_u *buf));
int latin_ptr2len __ARGS((char_u *p));
+int latin_ptr2len_len __ARGS((char_u *p, int size));
int utf_char2cells __ARGS((int c));
int latin_ptr2cells __ARGS((char_u *p));
int utf_ptr2cells __ARGS((char_u *p));
int dbcs_ptr2cells __ARGS((char_u *p));
+int latin_ptr2cells_len __ARGS((char_u *p, int size));
int latin_char2cells __ARGS((int c));
int latin_off2cells __ARGS((unsigned off, unsigned max_off));
int dbcs_off2cells __ARGS((unsigned off, unsigned max_off));
@@ -85,6 +87,7 @@ int im_get_status __ARGS((void));
int preedit_get_status __ARGS((void));
int im_is_preediting __ARGS((void));
int convert_setup __ARGS((vimconv_T *vcp, char_u *from, char_u *to));
+int convert_setup_ext __ARGS((vimconv_T *vcp, char_u *from, int from_unicode_is_utf8, char_u *to, int to_unicode_is_utf8));
int convert_input __ARGS((char_u *ptr, int len, int maxlen));
int convert_input_safe __ARGS((char_u *ptr, int len, int maxlen, char_u **restp, int *restlenp));
char_u *string_convert __ARGS((vimconv_T *vcp, char_u *ptr, int *lenp));
View
7 src/proto/window.pro
@@ -1,6 +1,7 @@
/* window.c */
void do_window __ARGS((int nchar, long Prenum, int xchar));
int win_split __ARGS((int size, int flags));
+int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
int win_valid __ARGS((win_T *win));
int win_count __ARGS((void));
int make_windows __ARGS((int count, int vertical));
@@ -10,9 +11,11 @@ void close_windows __ARGS((buf_T *buf, int keep_curwin));
void win_close __ARGS((win_T *win, int free_buf));
void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp));
void win_free_all __ARGS((void));
+win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
void close_others __ARGS((int message, int forceit));
void curwin_init __ARGS((void));
int win_alloc_first __ARGS((void));
+void win_alloc_aucmd_win __ARGS((void));
void win_init_size __ARGS((void));
void free_tabpage __ARGS((tabpage_T *tp));
int win_new_tabpage __ARGS((int after));
@@ -30,6 +33,8 @@ win_T *win_find_nr __ARGS((int winnr));
void win_enter __ARGS((win_T *wp, int undo_sync));
win_T *buf_jump_open_win __ARGS((buf_T *buf));
win_T *buf_jump_open_tab __ARGS((buf_T *buf));
+void win_append __ARGS((win_T *after, win_T *wp));
+void win_remove __ARGS((win_T *wp, tabpage_T *tp));
int win_alloc_lines __ARGS((win_T *wp));
void win_free_lsize __ARGS((win_T *wp));
void shell_new_rows __ARGS((void));
@@ -58,6 +63,8 @@ int vim_FullName __ARGS((char_u *fname, char_u *buf, int len, int force));
int min_rows __ARGS((void));
int only_one_window __ARGS((void));
void check_lnums __ARGS((int do_curwin));
+void make_snapshot __ARGS((int idx));
+void restore_snapshot __ARGS((int idx, int close_curwin));
int win_hasvertsplit __ARGS((void));
int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
int match_delete __ARGS((win_T *wp, int id, int perr));
View
12 src/screen.c
@@ -5743,6 +5743,13 @@ win_redr_status(wp)
int fillchar;
int attr;
int this_ru_col;
+ static int busy = FALSE;
+
+ /* It's possible to get here recursively when 'statusline' (indirectly)
+ * invokes ":redrawstatus". Simply ignore the call then. */
+ if (busy)
+ return;
+ busy = TRUE;
wp->w_redr_status = FALSE;
if (wp->w_status_height == 0)
@@ -5881,6 +5888,7 @@ win_redr_status(wp)
attr);
}
#endif
+ busy = FALSE;
}
#ifdef FEAT_STL_OPT
@@ -7495,6 +7503,10 @@ screenalloc(clear)
#endif
}
}
+#ifdef FEAT_AUTOCMD
+ if (aucmd_win != NULL && win_alloc_lines(aucmd_win) == FAIL)
+ outofmem = TRUE;
+#endif
#ifdef FEAT_WINDOWS
give_up:
#endif
View
23 src/structs.h
@@ -1621,6 +1621,14 @@ struct diffblock_S
};
#endif
+#define SNAP_HELP_IDX 0
+#ifdef FEAT_AUTOCMD
+# define SNAP_AUCMD_IDX 1
+# define SNAP_COUNT 2
+#else
+# define SNAP_COUNT 1
+#endif
+
/*
* Tab pages point to the top frame of each tab page.
* Note: Most values are NOT valid for the current tab page! Use "curwin",
@@ -1649,7 +1657,7 @@ struct tabpage_S
buf_T *(tp_diffbuf[DB_COUNT]);
int tp_diff_invalid; /* list of diffs is outdated */
#endif
- frame_T *tp_snapshot; /* window layout snapshot */
+ frame_T *(tp_snapshot[SNAP_COUNT]); /* window layout snapshots */
#ifdef FEAT_EVAL
dictitem_T tp_winvar; /* variable for "t:" Dictionary */
dict_T tp_vars; /* internal variables, local to tab page */
@@ -2276,16 +2284,11 @@ typedef int vimmenu_T;
*/
typedef struct
{
- buf_T *save_buf; /* saved curbuf */
+ buf_T *save_curbuf; /* saved curbuf */
#ifdef FEAT_AUTOCMD
- buf_T *new_curbuf; /* buffer to be used */
- win_T *save_curwin; /* saved curwin, NULL if it didn't change */
- win_T *new_curwin; /* new curwin if save_curwin != NULL */
- pos_T save_cursor; /* saved cursor pos of save_curwin */
- linenr_T save_topline; /* saved topline of save_curwin */
-# ifdef FEAT_DIFF
- int save_topfill; /* saved topfill of save_curwin */
-# endif
+ win_T *save_curwin; /* saved curwin */
+ win_T *new_curwin; /* new curwin */
+ buf_T *new_curbuf; /* new curbuf */
#endif
} aco_save_T;
View
2 src/term.c
@@ -5555,7 +5555,7 @@ check_for_codes_from_term()
* respects the current B/k/< settings of 'cpoption'.
*
* This function is called when expanding mappings/abbreviations on the
- * command-line, and for building the "Ambiguous mapping..." error mess�ge.
+ * command-line, and for building the "Ambiguous mapping..." error message.
*
* It uses a growarray to build the translation string since the
* latter can be wider than the original description. The caller has to
View
24 src/version.c
@@ -677,6 +677,30 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 209,
+/**/
+ 208,
+/**/
+ 207,
+/**/
+ 206,
+/**/
+ 205,
+/**/
+ 204,
+/**/
+ 203,
+/**/
+ 202,
+/**/
+ 201,
+/**/
+ 200,
+/**/
+ 199,
+/**/
+ 198,
+/**/
197,
/**/
196,
View
10 src/vim.h
@@ -1345,11 +1345,11 @@ typedef enum
# define MSG_BUF_CLEN MSG_BUF_LEN /* cell length */
#endif
-#if defined(AMIGA) || defined(__linux__) || defined(__QNX__) || defined(__CYGWIN32__) || defined(_AIX)
-# define TBUFSZ 2048 /* buffer size for termcap entry */
-#else
-# define TBUFSZ 1024 /* buffer size for termcap entry */
-#endif
+/* Size of the buffer used for tgetent(). Unfortunately this is largely
+ * undocumented, some systems use 1024. Using a buffer that is too small
+ * causes a buffer overrun and a crash. Use the maximum known value to stay
+ * on the safe side. */
+#define TBUFSZ 2048 /* buffer size for termcap entry */
/*
* Maximum length of key sequence to be mapped.
View
260 src/window.c
@@ -11,8 +11,8 @@
static int path_is_url __ARGS((char_u *p));
#if defined(FEAT_WINDOWS) || defined(PROTO)
-static int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
+static void win_init_some __ARGS((win_T *newp, win_T *oldp));
static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
static void frame_setheight __ARGS((frame_T *curfrp, int height));
#ifdef FEAT_VERTSPLIT
@@ -23,8 +23,8 @@ static void win_rotate __ARGS((int, int));
static void win_totop __ARGS((int size, int flags));
static void win_equal_rec __ARGS((win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height));
static int last_window __ARGS((void));
+static int one_window __ARGS((void));
static win_T *win_free_mem __ARGS((win_T *win, int *dirp, tabpage_T *tp));
-static win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
static frame_T *win_altframe __ARGS((win_T *win, tabpage_T *tp));
static tabpage_T *alt_tabpage __ARGS((void));
static win_T *frame2win __ARGS((frame_T *frp));
@@ -41,6 +41,7 @@ static void frame_fix_width __ARGS((win_T *wp));
#endif
#endif
static int win_alloc_firstwin __ARGS((win_T *oldwin));
+static void new_frame __ARGS((win_T *wp));
#if defined(FEAT_WINDOWS) || defined(PROTO)
static tabpage_T *alloc_tabpage __ARGS((void));
static int leave_tabpage __ARGS((buf_T *new_curbuf));
@@ -49,8 +50,6 @@ static void frame_fix_height __ARGS((win_T *wp));
static int frame_minheight __ARGS((frame_T *topfrp, win_T *next_curwin));
static void win_enter_ext __ARGS((win_T *wp, int undo_sync, int no_curwin));
static void win_free __ARGS((win_T *wp, tabpage_T *tp));
-static void win_append __ARGS((win_T *, win_T *));
-static void win_remove __ARGS((win_T *, tabpage_T *tp));
static void frame_append __ARGS((frame_T *after, frame_T *frp));
static void frame_insert __ARGS((frame_T *before, frame_T *frp));
static void frame_remove __ARGS((frame_T *frp));
@@ -62,17 +61,15 @@ static void win_goto_hor __ARGS((int left, long count));
static void frame_add_height __ARGS((frame_T *frp, int n));
static void last_status_rec __ARGS((frame_T *fr, int statusline));
-static void make_snapshot __ARGS((void));
static void make_snapshot_rec __ARGS((frame_T *fr, frame_T **frp));
-static void clear_snapshot __ARGS((tabpage_T *tp));
+static void clear_snapshot __ARGS((tabpage_T *tp, int idx));
static void clear_snapshot_rec __ARGS((frame_T *fr));
-static void restore_snapshot __ARGS((int close_curwin));
static int check_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
#endif /* FEAT_WINDOWS */
-static win_T *win_alloc __ARGS((win_T *after));
+static win_T *win_alloc __ARGS((win_T *after, int hidden));
static void win_new_height __ARGS((win_T *, int));
#define URL_SLASH 1 /* path_is_url() has found "://" */
@@ -259,7 +256,7 @@ do_window(nchar, Prenum, xchar)
/* cursor to previous window with wrap around */
case 'W':
CHECK_CMDWIN
- if (lastwin == firstwin && Prenum != 1) /* just one window */
+ if (firstwin == lastwin && Prenum != 1) /* just one window */
beep_flush();
else
{
@@ -343,7 +340,7 @@ do_window(nchar, Prenum, xchar)
/* move window to new tab page */
case 'T':
- if (firstwin == lastwin)
+ if (one_window())
MSG(_(m_onlyone));
else
{
@@ -679,9 +676,9 @@ win_split(size, flags)
/* When creating the help window make a snapshot of the window layout.
* Otherwise clear the snapshot, it's now invalid. */
if (flags & WSP_HELP)
- make_snapshot();
+ make_snapshot(SNAP_HELP_IDX);
else
- clear_snapshot(curtab);
+ clear_snapshot(curtab, SNAP_HELP_IDX);
return win_split_ins(size, flags, NULL, 0);
}
@@ -692,7 +689,7 @@ win_split(size, flags)
* top/left/right/bottom.
* return FAIL for failure, OK otherwise
*/
- static int
+ int
win_split_ins(size, flags, newwin, dir)
int size;
int flags;
@@ -893,14 +890,14 @@ win_split_ins(size, flags, newwin, dir)
{
/* new window below/right of current one */
if (newwin == NULL)
- wp = win_alloc(oldwin);
+ wp = win_alloc(oldwin, FALSE);
else
win_append(oldwin, wp);
}
else
{
if (newwin == NULL)
- wp = win_alloc(oldwin->w_prev);
+ wp = win_alloc(oldwin->w_prev, FALSE);
else
win_append(oldwin->w_prev, wp);
}
@@ -910,6 +907,13 @@ win_split_ins(size, flags, newwin, dir)
if (wp == NULL)
return FAIL;
+ new_frame(wp);
+ if (wp->w_frame == NULL)
+ {
+ win_free(wp, NULL);
+ return FAIL;
+ }
+
/* make the contents of the new window the same as the current one */
win_init(wp, curwin, flags);
}
@@ -970,13 +974,7 @@ win_split_ins(size, flags, newwin, dir)
}
if (newwin == NULL)
- {
- /* Create a frame for the new window. */
- frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
- frp->fr_layout = FR_LEAF;
- frp->fr_win = wp;
- wp->w_frame = frp;
- }
+ frp = wp->w_frame;
else
frp = newwin->w_frame;
frp->fr_parent = curfrp->fr_parent;
@@ -1156,6 +1154,7 @@ win_split_ins(size, flags, newwin, dir)
return OK;
}
+
/*
* Initialize window "newp" from window "oldp".
* Used when splitting a window and when creating a new tab page.
@@ -1204,14 +1203,7 @@ win_init(newp, oldp, flags)
if (oldp->w_localdir != NULL)
newp->w_localdir = vim_strsave(oldp->w_localdir);
- /* Use the same argument list. */
- newp->w_alist = oldp->w_alist;
- ++newp->w_alist->al_refcount;
- newp->w_arg_idx = oldp->w_arg_idx;
-
- /*
- * copy tagstack and options from existing window
- */
+ /* copy tagstack and folds */
for (i = 0; i < oldp->w_tagstacklen; i++)
{
newp->w_tagstack[i] = oldp->w_tagstack[i];
@@ -1221,10 +1213,29 @@ win_init(newp, oldp, flags)
}
newp->w_tagstackidx = oldp->w_tagstackidx;
newp->w_tagstacklen = oldp->w_tagstacklen;
- win_copy_options(oldp, newp);
# ifdef FEAT_FOLDING
copyFoldingState(oldp, newp);
# endif
+
+ win_init_some(newp, oldp);
+}
+
+/*
+ * Initialize window "newp" from window"old".
+ * Only the essential things are copied.
+ */
+ static void
+win_init_some(newp, oldp)
+ win_T *newp;
+ win_T *oldp;
+{
+ /* Use the same argument list. */
+ newp->w_alist = oldp->w_alist;
+ ++newp->w_alist->al_refcount;
+ newp->w_arg_idx = oldp->w_arg_idx;
+
+ /* copy options from existing window */
+ win_copy_options(oldp, newp);
}
#endif /* FEAT_WINDOWS */
@@ -1565,15 +1576,8 @@ win_totop(size, flags)
#if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
/* When 'guioptions' includes 'L' or 'R' may have to remove or add
* scrollbars. Have to update them anyway. */
- if (gui.in_use)
- {
- out_flush();
- gui_init_which_components(NULL);
- gui_update_scrollbars(TRUE);
- }
- need_mouse_correct = TRUE;
+ gui_may_update_scrollbars();
#endif
-
}
/*
@@ -2048,13 +2052,40 @@ close_windows(buf, keep_curwin)
}
/*
- * Return TRUE if the current window is the only window that exists.
+ * Return TRUE if the current window is the only window that exists (ignoring
+ * "aucmd_win").
* Returns FALSE if there is a window, possibly in another tab page.
*/
static int
last_window()
{
- return (lastwin == firstwin && first_tabpage->tp_next == NULL);
+ return (one_window() && first_tabpage->tp_next == NULL);
+}
+
+/*
+ * Return TRUE if there is only one window other than "aucmd_win" in the
+ * current tab page.
+ */
+ static int
+one_window()
+{
+#ifdef FEAT_AUTOCMD
+ win_T *wp;
+ int seen_one = FALSE;
+
+ FOR_ALL_WINDOWS(wp)
+ {
+ if (wp != aucmd_win)
+ {
+ if (seen_one)
+ return FALSE;
+ seen_one = TRUE;
+ }
+ }
+ return TRUE;
+#else
+ return firstwin == lastwin;
+#endif
}
/*
@@ -2083,6 +2114,19 @@ win_close(win, free_buf)
return;
}
+#ifdef FEAT_AUTOCMD
+ if (win == aucmd_win)
+ {
+ EMSG(_("E813: Cannot close autocmd window"));
+ return;
+ }
+ if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
+ {
+ EMSG(_("E814: Cannot close window, only autocmd window would remain"));
+ return;
+ }
+#endif
+
/*
* When closing the last window in a tab page first go to another tab
* page and then close the window and the tab page. This avoids that
@@ -2112,7 +2156,7 @@ win_close(win, free_buf)
if (win->w_buffer->b_help)
help_window = TRUE;
else
- clear_snapshot(curtab);
+ clear_snapshot(curtab, SNAP_HELP_IDX);
#ifdef FEAT_AUTOCMD
if (win == curwin)
@@ -2229,7 +2273,7 @@ win_close(win, free_buf)
/* After closing the help window, try restoring the window layout from
* before it was opened. */
if (help_window)
- restore_snapshot(close_curwin);
+ restore_snapshot(SNAP_HELP_IDX, close_curwin);
#if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
/* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */
@@ -2344,14 +2388,22 @@ win_free_all()
while (firstwin != NULL)
(void)win_free_mem(firstwin, &dummy, NULL);
+
+# ifdef FEAT_AUTOCMD
+ if (aucmd_win != NULL)
+ {
+ (void)win_free_mem(aucmd_win, &dummy, NULL);
+ aucmd_win = NULL;
+ }
+# endif
}
#endif
/*
* Remove a window and its frame from the tree of frames.
* Returns a pointer to the window that got the freed up space.
*/
- static win_T *
+ win_T *
winframe_remove(win, dirp, tp)
win_T *win;
int *dirp UNUSED; /* set to 'v' or 'h' for direction if 'ea' */
@@ -3090,7 +3142,7 @@ close_others(message, forceit)
win_T *nextwp;
int r;
- if (lastwin == firstwin)
+ if (one_window())
{
if (message
#ifdef FEAT_AUTOCMD
@@ -3194,9 +3246,30 @@ win_alloc_first()
first_tabpage->tp_topframe = topframe;
curtab = first_tabpage;
#endif
+
return OK;
}
+#if defined(FEAT_AUTOCMD) || defined(PROTO)
+/*
+ * Init "aucmd_win". This can only be done after the first
+ * window is fully initialized, thus it can't be in win_alloc_first().
+ */
+ void
+win_alloc_aucmd_win()
+{
+ aucmd_win = win_alloc(NULL, TRUE);
+ if (aucmd_win != NULL)
+ {
+ win_init_some(aucmd_win, curwin);
+# ifdef FEAT_SCROLLBIND
+ aucmd_win->w_p_scb = FALSE;
+# endif
+ new_frame(aucmd_win);
+ }
+}
+#endif
+
/*
* Allocate the first window or the first window in a new tab page.
* When "oldwin" is NULL create an empty buffer for it.
@@ -3208,7 +3281,7 @@ win_alloc_first()
win_alloc_firstwin(oldwin)
win_T *oldwin;
{
- curwin = win_alloc(NULL);
+ curwin = win_alloc(NULL, FALSE);
if (oldwin == NULL)
{
/* Very first window, need to create an empty buffer for it and
@@ -3236,21 +3309,36 @@ win_alloc_firstwin(oldwin)
}
#endif
- topframe = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
- if (topframe == NULL)
+ new_frame(curwin);
+ if (curwin->w_frame == NULL)
return FAIL;
- topframe->fr_layout = FR_LEAF;
+ topframe = curwin->w_frame;
#ifdef FEAT_VERTSPLIT
topframe->fr_width = Columns;
#endif
topframe->fr_height = Rows - p_ch;
topframe->fr_win = curwin;
- curwin->w_frame = topframe;
return OK;
}
/*
+ * Create a frame for window "wp".
+ */
+ static void
+new_frame(win_T *wp)
+{
+ frame_T *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
+
+ wp->w_frame = frp;
+ if (frp != NULL)
+ {
+ frp->fr_layout = FR_LEAF;
+ frp->fr_win = wp;
+ }
+}
+
+/*
* Initialize the window and frame size to the maximum.
*/
void
@@ -3300,10 +3388,13 @@ alloc_tabpage()
free_tabpage(tp)
tabpage_T *tp;
{
+ int idx;
+
# ifdef FEAT_DIFF
diff_clear(tp);
# endif
- clear_snapshot(tp);
+ for (idx = 0; idx < SNAP_COUNT; ++idx)
+ clear_snapshot(tp, idx);
#ifdef FEAT_EVAL
vars_clear(&tp->tp_vars.dv_hashtab); /* free all t: variables */
#endif
@@ -3370,12 +3461,7 @@ win_new_tabpage(after)
#if defined(FEAT_GUI)
/* When 'guioptions' includes 'L' or 'R' may have to remove or add
* scrollbars. Have to update them anyway. */
- if (gui.in_use && starting == 0)
- {
- gui_init_which_components(NULL);
- gui_update_scrollbars(TRUE);
- }
- need_mouse_correct = TRUE;
+ gui_may_update_scrollbars();
#endif
redraw_all_later(CLEAR);
@@ -3593,12 +3679,7 @@ enter_tabpage(tp, old_curbuf)
#if defined(FEAT_GUI)
/* When 'guioptions' includes 'L' or 'R' may have to remove or add
* scrollbars. Have to update them anyway. */
- if (gui.in_use && starting == 0)
- {
- gui_init_which_components(NULL);
- gui_update_scrollbars(TRUE);
- }
- need_mouse_correct = TRUE;
+ gui_may_update_scrollbars();
#endif
redraw_all_later(CLEAR);
@@ -4150,11 +4231,13 @@ buf_jump_open_tab(buf)
#endif
/*
- * allocate a window structure and link it in the window list
+ * Allocate a window structure and link it in the window list when "hidden" is
+ * FALSE.
*/
static win_T *
-win_alloc(after)
+win_alloc(after, hidden)
win_T *after UNUSED;
+ int hidden UNUSED;
{
win_T *newwin;
@@ -4180,7 +4263,8 @@ win_alloc(after)
* link the window in the window list
*/
#ifdef FEAT_WINDOWS
- win_append(after, newwin);
+ if (!hidden)
+ win_append(after, newwin);
#endif
#ifdef FEAT_VERTSPLIT
newwin->w_wincol = 0;
@@ -4314,7 +4398,7 @@ win_free(wp, tp)
/*
* Append window "wp" in the window list after window "after".
*/
- static void
+ void
win_append(after, wp)
win_T *after, *wp;
{
@@ -4340,7 +4424,7 @@ win_append(after, wp)
/*
* Remove a window from the window list.
*/
- static void
+ void
win_remove(wp, tp)
win_T *wp;
tabpage_T *tp; /* tab page "win" is in, NULL for current */
@@ -6040,6 +6124,7 @@ min_rows()
/*
* Return TRUE if there is only one window (in the current tab page), not
* counting a help or preview window, unless it is the current window.
+ * Does not count "aucmd_win".
*/
int
only_one_window()
@@ -6053,11 +6138,15 @@ only_one_window()
return FALSE;
for (wp = firstwin; wp != NULL; wp = wp->w_next)
- if (!((wp->w_buffer->b_help && !curbuf->b_help)
+ if ((!((wp->w_buffer->b_help && !curbuf->b_help)
# ifdef FEAT_QUICKFIX
|| wp->w_p_pvw
# endif
) || wp == curwin)
+# ifdef FEAT_AUTOCMD
+ && wp != aucmd_win
+# endif
+ )
++count;
return (count <= 1);
#else
@@ -6112,11 +6201,12 @@ check_lnums(do_curwin)
/*
* Create a snapshot of the current frame sizes.
*/
- static void
-make_snapshot()
+ void
+make_snapshot(idx)
+ int idx;
{
- clear_snapshot(curtab);
- make_snapshot_rec(topframe, &curtab->tp_snapshot);
+ clear_snapshot(curtab, idx);
+ make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]);
}
static void
@@ -6144,11 +6234,12 @@ make_snapshot_rec(fr, frp)
* Remove any existing snapshot.
*/
static void
-clear_snapshot(tp)
+clear_snapshot(tp, idx)
tabpage_T *tp;
+ int idx;
{
- clear_snapshot_rec(tp->tp_snapshot);
- tp->tp_snapshot = NULL;
+ clear_snapshot_rec(tp->tp_snapshot[idx]);
+ tp->tp_snapshot[idx] = NULL;
}
static void
@@ -6168,26 +6259,27 @@ clear_snapshot_rec(fr)
* This is only done if the screen size didn't change and the window layout is
* still the same.
*/
- static void
-restore_snapshot(close_curwin)
+ void
+restore_snapshot(idx, close_curwin)
+ int idx;
int close_curwin; /* closing current window */
{
win_T *wp;
- if (curtab->tp_snapshot != NULL
+ if (curtab->tp_snapshot[idx] != NULL
# ifdef FEAT_VERTSPLIT
- && curtab->tp_snapshot->fr_width == topframe->fr_width
+ && curtab->tp_snapshot[idx]->fr_width == topframe->fr_width
# endif
- && curtab->tp_snapshot->fr_height == topframe->fr_height
- && check_snapshot_rec(curtab->tp_snapshot, topframe) == OK)
+ && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height
+ && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK)
{
- wp = restore_snapshot_rec(curtab->tp_snapshot, topframe);
+ wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe);
win_comp_pos();
if (wp != NULL && close_curwin)
win_goto(wp);
redraw_all_later(CLEAR);
}
- clear_snapshot(curtab);
+ clear_snapshot(curtab, idx);
}
/*
View
9 src/xxd/xxd.c
@@ -64,6 +64,9 @@
# define _CRT_SECURE_NO_DEPRECATE
# define _CRT_NONSTDC_NO_DEPRECATE
#endif
+#if !defined(CYGWIN) && (defined(CYGWIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__))
+# define CYGWIN
+#endif
#include <stdio.h>
#ifdef VAXC
@@ -77,7 +80,8 @@
#if !defined(OS2) && defined(__EMX__)
# define OS2
#endif
-#if defined(MSDOS) || defined(WIN32) || defined(OS2) || defined(__BORLANDC__)
+#if defined(MSDOS) || defined(WIN32) || defined(OS2) || defined(__BORLANDC__) \
+ || defined(CYGWIN)
# include <io.h> /* for setmode() */
#else
# ifdef UNIX
@@ -150,9 +154,6 @@ char osver[] = "";
# endif
#endif
-#if !defined(CYGWIN) && (defined(CYGWIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__))
-# define CYGWIN
-#endif
#if defined(MSDOS) || defined(WIN32) || defined(OS2)
# define BIN_READ(yes) ((yes) ? "rb" : "rt")
# define BIN_WRITE(yes) ((yes) ? "wb" : "wt")

0 comments on commit 4f92679

Please sign in to comment.