summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-02-05 21:39:53 +0000
committerBram Moolenaar <Bram@vim.org>2005-02-05 21:39:53 +0000
commit3a7c85bc13c2094042d00eb56ace3445d5dfd5bc (patch)
tree3307cbe01fed7b1ca77f06c82409fd6589eb7b79
parent8089cae03baf229b28bb850297da874024ca9f26 (diff)
updated for version 7.0048
-rw-r--r--runtime/doc/eval.txt70
-rw-r--r--runtime/doc/tags2
-rw-r--r--runtime/doc/usr_41.txt4
-rw-r--r--runtime/menu.vim31
-rwxr-xr-xruntime/tools/vimspell.sh19
-rw-r--r--src/gui_w32.c103
-rw-r--r--src/gui_xmebw.c11
-rw-r--r--src/os_unix.c2
-rw-r--r--src/testdir/test49.vim2
-rw-r--r--src/version.h4
10 files changed, 192 insertions, 56 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 034276b133..c0031e8531 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 7.0aa. Last change: 2005 Feb 02
+*eval.txt* For Vim version 7.0aa. Last change: 2005 Feb 05
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1476,6 +1476,8 @@ match( {expr}, {pat}[, {start}[, {count}]])
Number position where {pat} matches in {expr}
matchend( {expr}, {pat}[, {start}[, {count}]])
Number position where {pat} ends in {expr}
+matchlist( {expr}, {pat}[, {start}[, {count}]])
+ List match and submatches of {pat} in {expr}
matchstr( {expr}, {pat}[, {start}[, {count}]])
String {count}'th match of {pat} in {expr}
max({list}) Number maximum value of items in {list}
@@ -1486,6 +1488,7 @@ nr2char( {expr}) String single char with ASCII value {expr}
prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum}
range( {expr} [, {max} [, {stride}]])
List items from {expr} to {max}
+readfile({fname} [, {binary}]) List get list of lines from file {fname}
remote_expr( {server}, {string} [, {idvar}])
String send expression
remote_foreground( {server}) Number bring Vim server to the foreground
@@ -1548,6 +1551,8 @@ winline() Number window line of the cursor
winnr() Number number of current window
winrestcmd() String returns command to restore window sizes
winwidth( {nr}) Number width of window {nr}
+writefile({list}, {fname} [, {binary}])
+ Number write list of lines to file {fname}
add({list}, {expr}) *add()*
Append the item {expr} to List {list}. Returns the resulting
@@ -2004,8 +2009,12 @@ exists({expr}) The result is a Number, which is non-zero if {expr} is
or user defined function (see
|user-functions|).
varname internal variable (see
- |internal-variables|). Does not work
- for |curly-braces-names|.
+ |internal-variables|). Also works
+ for |curly-braces-names|, Dictionary
+ entries, List items, etc. Beware that
+ this may cause functions to be
+ invoked cause an error message for an
+ invalid expression.
:cmdname Ex command: built-in command, user
command or command modifier |:command|.
Returns:
@@ -2939,9 +2948,10 @@ map({expr}, {string}) *map()*
:call map(mylist, '"> " . v:val . " <"')
< This puts "> " before and " <" after each item in "mylist".
- Note that {string} is the result of expression and is then
+ Note that {string} is the result of an expression and is then
used as an expression again. Often it is good to use a
- |literal-string| to avoid having to double backslashes.
+ |literal-string| to avoid having to double backslashes. You
+ still have to double ' quotes
The operation is done in-place. If you want a List or
Dictionary to remain unmodified make a copy first: >
@@ -3050,6 +3060,13 @@ matchend({expr}, {pat}[, {start}[, {count}]]) *matchend()*
< result is "-1".
When {expr} is a List the result is equal to match().
+matchlist({expr}, {pat}[, {start}[, {count}]]) *matchlist()*
+ Same as match(), but return a List. The first item in the
+ list is the matched string, same as what matchstr() would
+ return. Following items are submatches, like "\1", "\2", etc.
+ in |:substitute|.
+ When there is no match an empty list is returned.
+
matchstr({expr}, {pat}[, {start}[, {count}]]) *matchstr()*
Same as match(), but return the matched string. Example: >
:echo matchstr("testing", "ing")
@@ -3133,6 +3150,27 @@ range({expr} [, {max} [, {stride}]]) *range()*
range(2, 9, 3) " [2, 5, 8]
range(2, -2, -1) " [2, 1, 0, -1, -2]
<
+ *readfile()*
+readfile({fname} [, {binary}])
+ Read file {fname} and return a List, each line of the file as
+ an item. Lines broken at NL characters. Macintosh files
+ separated with CR will result in a single long line (unless a
+ NL appears somewhere).
+ When {binary} is equal to "b" binary mode is used:
+ - When the last line ends in a NL an extra empty list item is
+ added.
+ - No CR characters are removed.
+ Otherwise:
+ - CR characters that appear before a NL are removed.
+ - Whether the last line ends in a NL or not does not matter.
+ All NUL characters are replaced with a NL character.
+ Note that the whole file is read into memory and there is no
+ recognition of encoding. Read a file into a buffer if you
+ need to.
+ When the file can't be opened an error message is given and
+ the result is an empty list.
+ Also see |writefile()|.
+
*remote_expr()* *E449*
remote_expr({server}, {string} [, {idvar}])
Send the {string} to {server}. The string is sent as an
@@ -3879,6 +3917,26 @@ winwidth({nr}) *winwidth()*
: exe "normal 50\<C-W>|"
:endif
<
+ *writefile()*
+writefile({list}, {fname} [, {binary}])
+ Write List {list} to file {fname}. Each list item is
+ separated with a NL. Each list item must be a String or
+ Number.
+ When {binary} is equal to "b" binary mode is used: There will
+ not be a NL after the last list item. An empty item at the
+ end does cause the last line in the file to end in a NL.
+ All NL characters are replaced with a NUL character.
+ Inserting CR characters needs to be done before passing {list}
+ to writefile().
+ An existing file is overwritten, if possible.
+ When the write fails -1 is returned, otherwise 0. There is an
+ error message if the file can't be created or when writing
+ fails.
+ Also see |readfile()|.
+ To copy a file byte for byte: >
+ :let fl = readfile("foo", "b")
+ :call writefile(fl, "foocopy", "b")
+<
*feature-list*
There are three types of features:
@@ -4597,7 +4655,7 @@ This would call the function "my_func_whizz(parameter)".
:for {var} in {list} *:for* *E690* *E732*
:endfo[r] *:endfo* *:endfor*
Repeat the commands between ":for" and ":endfor" for
- each item in {list}. variable {var} is set to the
+ each item in {list}. Variable {var} is set to the
value of each item.
When an error is detected for a command inside the
loop, execution continues after the "endfor".
diff --git a/runtime/doc/tags b/runtime/doc/tags
index c8e765fcc8..8ad645313d 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -5937,6 +5937,7 @@ rcp pi_netrw.txt /*rcp*
read-messages insert.txt /*read-messages*
read-only-share editing.txt /*read-only-share*
read-stdin version5.txt /*read-stdin*
+readfile() eval.txt /*readfile()*
readline-syntax syntax.txt /*readline-syntax*
readline.vim syntax.txt /*readline.vim*
recording repeat.txt /*recording*
@@ -6863,6 +6864,7 @@ write-local-help usr_41.txt /*write-local-help*
write-plugin usr_41.txt /*write-plugin*
write-quit editing.txt /*write-quit*
write-readonly editing.txt /*write-readonly*
+writefile() eval.txt /*writefile()*
writing editing.txt /*writing*
www intro.txt /*www*
x change.txt /*x*
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 4a7f3d1985..d90c24abfd 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1,4 +1,4 @@
-*usr_41.txt* For Vim version 7.0aa. Last change: 2005 Jan 25
+*usr_41.txt* For Vim version 7.0aa. Last change: 2005 Feb 04
VIM USER MANUAL - by Bram Moolenaar
@@ -653,6 +653,8 @@ System functions and manipulation of files:
rename() rename a file
system() get the result of a shell command
hostname() name of the system
+ readfile() read a file into a List of lines
+ writefile() write a List of lines into a file
Buffers, windows and the argument list:
argc() number of entries in the argument list
diff --git a/runtime/menu.vim b/runtime/menu.vim
index e89291b16f..6f300185f4 100644
--- a/runtime/menu.vim
+++ b/runtime/menu.vim
@@ -2,7 +2,7 @@
" You can also use this as a start for your own set of menus.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2005 Jan 30
+" Last Change: 2005 Feb 03
" Note that ":an" (short for ":anoremenu") is often used to make a menu work
" in all modes and avoid side effects from mappings defined by the user.
@@ -136,7 +136,7 @@ an 10.620 &File.E&xit<Tab>:qa :confirm qa<CR>
" the right position, also for "gi".
" Note: the same stuff appears in mswin.vim.
if has("virtualedit")
- nnoremap <silent> <script> <SID>Paste :call <SID>Paste()<CR>
+ let s:paste_cmd = ":call <SID>Paste()<CR>"
func! <SID>Paste()
let ove = &ve
set ve=all
@@ -152,16 +152,17 @@ if has("virtualedit")
let &ve = ove
endfunc
else
- nnoremap <silent> <script> <SID>Paste "=@+.'xy'<CR>gPFx"_2x
+ let s:paste_cmd = "\"=@+.'xy'<CR>gPFx\"_2x"
endif
-" Use maps for items that are present both in Edit, Popup and Toolbar menu.
+" Define the string to use for items that are present both in Edit, Popup and
+" Toolbar menu.
if has("virtualedit")
- vnoremap <script> <SID>vPaste "-c<Esc><SID>Paste
- inoremap <script> <SID>iPaste <Esc><SID>Pastegi
+ let s:paste_v_cmd = '"-c<Esc>' . s:paste_cmd
+ let s:paste_i_cmd = '<Esc>' . s:paste_cmd . 'gi'
else
- vnoremap <script> <SID>vPaste "-c<Esc>gix<Esc><SID>Paste"_x
- inoremap <script> <SID>iPaste x<Esc><SID>Paste"_s
+ let s:paste_v_cmd = '"-c<Esc>gix<Esc>' . s:paste_cmd . '"_x'
+ let s:paste_i_cmd = 'x<Esc>' . s:paste_cmd . '"_s'
endif
func! <SID>SelectAll()
@@ -180,8 +181,8 @@ vnoremenu 20.350 &Edit.&Copy<Tab>"+y "+y
cnoremenu 20.350 &Edit.&Copy<Tab>"+y <C-Y>
nnoremenu 20.360 &Edit.&Paste<Tab>"+gP "+gP
cnoremenu &Edit.&Paste<Tab>"+gP <C-R>+
-vnoremenu <script> &Edit.&Paste<Tab>"+gP <SID>vPaste
-inoremenu <script> &Edit.&Paste<Tab>"+gP <SID>iPaste
+exe 'vnoremenu <script> &Edit.&Paste<Tab>"+gP ' . s:paste_v_cmd
+exe 'inoremenu <script> &Edit.&Paste<Tab>"+gP ' . s:paste_i_cmd
nnoremenu 20.370 &Edit.Put\ &Before<Tab>[p [p
inoremenu &Edit.Put\ &Before<Tab>[p <C-O>[p
nnoremenu 20.380 &Edit.Put\ &After<Tab>]p ]p
@@ -781,8 +782,8 @@ vnoremenu 1.30 PopUp.&Copy "+y
cnoremenu 1.30 PopUp.&Copy <C-Y>
nnoremenu 1.40 PopUp.&Paste "+gP
cnoremenu 1.40 PopUp.&Paste <C-R>+
-vnoremenu <script> 1.40 PopUp.&Paste <SID>vPaste
-inoremenu <script> 1.40 PopUp.&Paste <SID>iPaste
+exe 'vnoremenu <script> 1.40 PopUp.&Paste ' . s:paste_v_cmd
+exe 'inoremenu <script> 1.40 PopUp.&Paste ' . s:paste_i_cmd
vnoremenu 1.50 PopUp.&Delete x
an 1.55 PopUp.-SEP2- <Nop>
vnoremenu 1.60 PopUp.Select\ Blockwise <C-V>
@@ -848,8 +849,8 @@ if has("toolbar")
cnoremenu 1.80 ToolBar.Copy <C-Y>
nnoremenu 1.90 ToolBar.Paste "+gP
cnoremenu ToolBar.Paste <C-R>+
- vnoremenu <script> ToolBar.Paste <SID>vPaste
- inoremenu <script> ToolBar.Paste <SID>iPaste
+ exe 'vnoremenu <script> ToolBar.Paste ' . s:paste_v_cmd
+ exe 'inoremenu <script> ToolBar.Paste ' . s:paste_i_cmd
if !has("gui_athena")
an 1.95 ToolBar.-sep3- <Nop>
@@ -996,6 +997,8 @@ an 50.730 &Syntax.&Convert\ to\ HTML :runtime syntax/2html.vim<CR>
endif " !exists("did_install_syntax_menu")
+unlet! s:paste_i_cmd s:paste_v_cmd s:paste_cmd
+
" Restore the previous value of 'cpoptions'.
let &cpo = s:cpo_save
unlet s:cpo_save
diff --git a/runtime/tools/vimspell.sh b/runtime/tools/vimspell.sh
index 42072222c9..b405b7ad59 100755
--- a/runtime/tools/vimspell.sh
+++ b/runtime/tools/vimspell.sh
@@ -11,11 +11,24 @@
#
# Neil Schemenauer <nascheme@ucalgary.ca>
# March 1999
+#
+# Safe method for the temp file by Javier Fernández-Sanguino_Peña
INFILE=$1
-OUTFILE=/tmp/vimspell.$$
-# if you have "tempfile", use the following line
-#OUTFILE=`tempfile`
+tmp="${TMPDIR-/tmp}"
+OUTFILE=`mktemp -t vimspellXXXXXX || tempfile -p vimspell || echo none`
+# If the standard commands failed then create the file
+# since we cannot create a directory (we cannot remove it on exit)
+# create a file in the safest way possible.
+if test "$OUTFILE" = none; then
+ OUTFILE=$tmp/vimspell$$
+ [ -e $OUTFILE ] && { echo "Cannot use temporary file $OUTFILE, it already exists!; exit 1 ; }
+ (umask 077; touch $OUTFILE)
+fi
+# Note the copy of vimspell cannot be deleted on exit since it is
+# used by vim, otherwise it should do this:
+# trap "rm -f $OUTFILE" 0 1 2 3 9 11 13 15
+
#
# local spellings
diff --git a/src/gui_w32.c b/src/gui_w32.c
index a29de9d265..23feb6fb3d 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -2532,6 +2532,7 @@ gui_mch_dialog(
int msgheight;
char_u *pstart;
char_u *pend;
+ char_u *last_white;
char_u *tbuffer;
RECT rect;
HWND hwnd;
@@ -2550,6 +2551,8 @@ gui_mch_dialog(
LOGFONT lfSysmenu;
int use_lfSysmenu = FALSE;
#endif
+ garray_T ga;
+ int l;
#ifndef NO_CONSOLE
/* Don't output anything in silent mode ("ex -s") */
@@ -2571,7 +2574,8 @@ gui_mch_dialog(
/* allocate some memory for dialog template */
/* TODO should compute this really */
- pdlgtemplate = p = (PWORD)LocalAlloc(LPTR, DLG_ALLOC_SIZE);
+ pdlgtemplate = p = (PWORD)LocalAlloc(LPTR,
+ DLG_ALLOC_SIZE + STRLEN(message));
if (p == NULL)
return -1;
@@ -2641,43 +2645,92 @@ gui_mch_dialog(
minButtonWidth = GetTextWidth(hdc, "Cancel", 6);
/* Maximum width of a dialog, if possible */
- GetWindowRect(s_hwnd, &rect);
- maxDialogWidth = rect.right - rect.left
- - GetSystemMetrics(SM_CXFRAME) * 2;
- if (maxDialogWidth < DLG_MIN_MAX_WIDTH)
- maxDialogWidth = DLG_MIN_MAX_WIDTH;
-
- maxDialogHeight = rect.bottom - rect.top - GetSystemMetrics(SM_CXFRAME) * 2;
- if (maxDialogHeight < DLG_MIN_MAX_HEIGHT)
- maxDialogHeight = DLG_MIN_MAX_HEIGHT;
+ if (s_hwnd == NULL)
+ {
+ RECT workarea_rect;
+
+ /* We don't have a window, use the desktip area. */
+ get_work_area(&workarea_rect);
+ maxDialogWidth = workarea_rect.right - workarea_rect.left - 100;
+ if (maxDialogWidth > 600)
+ maxDialogWidth = 600;
+ maxDialogHeight = workarea_rect.bottom - workarea_rect.top - 100;
+ }
+ else
+ {
+ /* Use our own window for the size, unless it's very small. */
+ GetWindowRect(s_hwnd, &rect);
+ maxDialogWidth = rect.right - rect.left
+ - GetSystemMetrics(SM_CXFRAME) * 2;
+ if (maxDialogWidth < DLG_MIN_MAX_WIDTH)
+ maxDialogWidth = DLG_MIN_MAX_WIDTH;
+
+ maxDialogHeight = rect.bottom - rect.top
+ - GetSystemMetrics(SM_CXFRAME) * 2;
+ if (maxDialogHeight < DLG_MIN_MAX_HEIGHT)
+ maxDialogHeight = DLG_MIN_MAX_HEIGHT;
+ }
- /* Set dlgwidth to width of message */
+ /* Set dlgwidth to width of message.
+ * Copy the message into "ga", changing NL to CR-NL and inserting line
+ * breaks where needed. */
pstart = message;
messageWidth = 0;
- msgheight = fontHeight;
+ msgheight = 0;
+ ga_init2(&ga, sizeof(char), 500);
do
{
- pend = vim_strchr(pstart, DLG_BUTTON_SEP);
- if (pend == NULL)
- pend = pstart + STRLEN(pstart); /* Last line of message. */
- msgheight += fontHeight;
- textWidth = GetTextWidth(hdc, pstart, (int)(pend - pstart));
- if (textWidth >= maxDialogWidth)
+ msgheight += fontHeight; /* at least one line */
+
+ /* Need to figure out where to break the string. The system does it
+ * at a word boundary, which would mean we can't compute the number of
+ * wrapped lines. */
+ textWidth = 0;
+ last_white = NULL;
+ for (pend = pstart; *pend != NUL && *pend != '\n'; )
{
- /* Line will wrap. This doesn't work correctly, because the wrap
- * happens at a word boundary! */
- messageWidth = maxDialogWidth;
- while (textWidth >= maxDialogWidth)
+#ifdef FEAT_MBYTE
+ l = mb_ptr2len_check(pend);
+#else
+ l = 1;
+#endif
+ if (l == 1 && vim_iswhite(*pend)
+ && textWidth > maxDialogWidth * 3 / 4)
+ last_white = pend;
+ textWidth += GetTextWidth(hdc, pend, l);
+ if (textWidth >= maxDialogWidth)
{
+ /* Line will wrap. */
+ messageWidth = maxDialogWidth;
msgheight += fontHeight;
- textWidth -= maxDialogWidth;
+ textWidth = 0;
+
+ if (last_white != NULL)
+ {
+ /* break the line just after a space */
+ ga.ga_len -= pend - (last_white + 1);
+ pend = last_white + 1;
+ last_white = NULL;
+ }
+ ga_append(&ga, '\r');
+ ga_append(&ga, '\n');
+ continue;
}
+
+ while (--l >= 0)
+ ga_append(&ga, *pend++);
}
- else if (textWidth > messageWidth)
+ if (textWidth > messageWidth)
messageWidth = textWidth;
+
+ ga_append(&ga, '\r');
+ ga_append(&ga, '\n');
pstart = pend + 1;
} while (*pend != NUL);
+ if (ga.ga_data != NULL)
+ message = ga.ga_data;
+
messageWidth += 10; /* roundoff space */
/* Restrict the size to a maximum. Causes a scrollbar to show up. */
@@ -2685,6 +2738,7 @@ gui_mch_dialog(
{
msgheight = maxDialogHeight;
scroll_flag = WS_VSCROLL;
+ messageWidth += GetSystemMetrics(SM_CXVSCROLL);
}
/* Add width of icon to dlgwidth, and some space */
@@ -2933,6 +2987,7 @@ gui_mch_dialog(
vim_free(tbuffer);
vim_free(buttonWidths);
vim_free(buttonPositions);
+ vim_free(ga.ga_data);
/* Focus back to our window (for when MDI is used). */
(void)SetFocus(s_hwnd);
diff --git a/src/gui_xmebw.c b/src/gui_xmebw.c
index 648eeb3183..aa22a88b18 100644
--- a/src/gui_xmebw.c
+++ b/src/gui_xmebw.c
@@ -18,13 +18,12 @@
*/
/*
- * Enhanced Motif PushButton widget with move over behaviour.
+ * Enhanced Motif PushButton widget with move over behavior.
*/
-#include <ctype.h>
-#include <stdio.h>
-#include <assert.h>
-#include <auto/config.h>
+#include "vim.h"
+
+#ifdef FEAT_TOOLBAR
#include <Xm/XmP.h>
#include <Xm/DrawP.h>
@@ -1407,3 +1406,5 @@ BorderUnhighlight(Widget w)
(*(xmPushButtonClassRec.primitive_class.border_unhighlight))(w);
draw_pixmap(eb, NULL, NULL);
}
+
+#endif /* FEAT_TOOLBAR */
diff --git a/src/os_unix.c b/src/os_unix.c
index abfcdcc6f5..4dd38ce7e0 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1974,6 +1974,7 @@ mch_restore_title(which)
/*
* Return TRUE if "name" looks like some xterm name.
+ * Seiichi Sato mentioned that "mlterm" works like xterm.
*/
int
vim_is_xterm(name)
@@ -1984,6 +1985,7 @@ vim_is_xterm(name)
return (STRNICMP(name, "xterm", 5) == 0
|| STRNICMP(name, "nxterm", 6) == 0
|| STRNICMP(name, "kterm", 5) == 0
+ || STRNICMP(name, "mlterm", 6) == 0
|| STRNICMP(name, "rxvt", 4) == 0
|| STRCMP(name, "builtin_xterm") == 0);
}
diff --git a/src/testdir/test49.vim b/src/testdir/test49.vim
index 97db66d331..46a29ff513 100644
--- a/src/testdir/test49.vim
+++ b/src/testdir/test49.vim
@@ -1,6 +1,6 @@
" Vim script language tests
" Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com>
-" Last Change: 2005 Jan 18
+" Last Change: 2005 Feb 03
"-------------------------------------------------------------------------------
" Test environment {{{1
diff --git a/src/version.h b/src/version.h
index 5b2e7d3632..187babb41b 100644
--- a/src/version.h
+++ b/src/version.h
@@ -36,5 +36,5 @@
#define VIM_VERSION_NODOT "vim70aa"
#define VIM_VERSION_SHORT "7.0aa"
#define VIM_VERSION_MEDIUM "7.0aa ALPHA"
-#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 2)"
-#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 2, compiled "
+#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 5)"
+#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 5, compiled "