summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvimboss <devnull@localhost>2005-01-04 21:52:38 +0000
committervimboss <devnull@localhost>2005-01-04 21:52:38 +0000
commit77aa3ebaf07ab4abd78371ca38cc75925a99cbdb (patch)
tree53e7eff8250fab363a7670cf916b38a3daf198b5
parent23cece59c21f1011c4faba9bd2c32ddadbc37041 (diff)
downloadvim-77aa3ebaf07ab4abd78371ca38cc75925a99cbdb.tar.gz
updated for version 7.0030v7.0030v7-0030
-rw-r--r--src/Make_agui.mak356
-rw-r--r--src/Make_aros.mak29
-rw-r--r--src/Make_morph.mak12
-rw-r--r--src/eval.c3452
-rw-r--r--src/gui_amiga.c1812
-rw-r--r--src/gui_amiga.h52
-rw-r--r--src/gui_beos.cc3358
-rw-r--r--src/gui_beos.h49
-rw-r--r--src/proto/gui_amiga.pro69
-rw-r--r--src/proto/gui_beos.pro14
-rw-r--r--src/proto/os_beos.pro4
11 files changed, 1842 insertions, 7365 deletions
diff --git a/src/Make_agui.mak b/src/Make_agui.mak
deleted file mode 100644
index 7b30a197..00000000
--- a/src/Make_agui.mak
+++ /dev/null
@@ -1,356 +0,0 @@
-#
-# Makefile for VIM on the Amiga, using SAS/Lattice C 6.0 to 6.56
-#
-# Do NOT use the peephole optimizer with a version before 6.55!
-# It messes up all kinds of things:
-# For 6.0 and 6.1, expand_env() will not work correctly.
-# For 6.2 and 6.3 the call to free_line in u_freeentry is wrong.
-# Don't know about 6.50, might work...
-# Version 6.56 seems to be working fine.
-# You should use Manx Aztec C whenever possible.
-#
-# The prototypes from Manx and SAS are incompatible. If the prototypes
-# were generated by Manx, first do "touch *.c; make proto" before "make".
-# The prototypes generated on Unix work for both.
-#
-# Note: Not all dependencies are included. This was done to avoid having
-# to compile everything when a global variable or function is added.
-
-#>>>>> choose options:
-
-#ANSI CODES
-ANSIOFF = *e[0m
-BBOLD = *e[1m
-WBOLD = *e[2m
-ITALIC = *e[3m
-UNDERLI = *e[4m
-ANSIOFF = *e[0m
-FCOL1 = *e[31m
-FCOL2 = *e[32m
-FCOL3 = *e[33m
-FCOL4 = *e[34m
-BCOL1 = *e[41m
-BCOL2 = *e[42m
-BCOL3 = *e[43m
-BCOL4 = *e[44m
-
-
-### See feature.h for a list of optionals.
-### Any other defines can be included here.
-
-DEFINES = DEF=NO_ARP DEF=AMIGA DEF=NEWSASC DEF=FEAT_GUI_AMIGA \
- DEF="SASC=658" #" this fixes a bug in the syntax highlighting
-
-#>>>>> if HAVE_TGETENT is defined termlib.o has to be used
-#TERMLIB = termlib.o
-TERMLIB =
-
-#>>>>> choose NODEBUG for normal compiling, the other for debugging and
-# profiling
-# don't switch on debugging when generating proto files, it crashes the
-# compiler.
-DBG = NODEBUG
-#DBG = DBG=FULLFLUSH
-#DBG = DBG=LINE
-
-#>>>>> choose NOOPTPEEP for 6.0 to 6.3, NOOPT for debugging
-#OPTIMIZE=NOOPTPEEP OPT
-
-# for 6.58 you can use the line below, but be warned it takes a loooonnnggg time
-#OPTIMIZE=OPT OPTIMIZERSCHEDULER OPTIMIZERTIME NoOPTIMIZERALIAS \
-# OptimizerComplexity=10 OptimizerDepth=10 OptimizerRecurDepth=10 \
-# OptimizerInLocal OPTPEEP
-OPTIMIZE=OPT OPTIMIZERTIME NoOPTIMIZERALIAS \
- OptimizerComplexity=10 OptimizerDepth=10 OptimizerRecurDepth=10 \
- OptimizerInLocal OPTPEEP
-#OPTIMIZE = NOOPT
-
-# no optimization, (works on all platforms)
-#OPTIMIZE=NOOPT
-
-#generate code for your processor - note however, that the 060 selection will work for 040's
-# as well.
-#CPU=68000
-#CPU=68020
-#CPU=68030
-#CPU=68040
-CPU=68060
-
-
-#Error reporting - I use rexx for reporting, but console reporting may be more
-#useful for some people.
-#ERROR = ERRORCONSOLE ERRORSOURCE ERRORHIGHLIGHT
-ERROR = ERRORREXX ERRORCONSOLE ERRORSOURCE ERRORHIGHLIGHT
-
-
-#memory types, if you have fast use it :->,
-# ANY = will work on all machines
-# FAST = this is the best option, for speed
-# CHIP = not necessary for this application.
-#MEMORYTYPE=FAST
-MEMORYTYPE=ANY
-
-#MEMSIZE - this is for compile time only for speed of compilation
-#default is LARGE
-MEMSIZE=HUGE
-#MEMSIZE=LARGE
-#MEMSIZE=SMALL
-
-#>>>>> end of choices
-###########################################################################
-
-CC = sc
-
-GST=vim.gst
-DEP = $(GST)
-
-
-CFLAGS = NOLINK $(DBG) CPU=$(CPU) NOSTACKCHECK
-CFLAGS2 = $(OPTIMIZE) $(ERROR) GSTIMMEDIATE GST=$(GST)
-CFLAGS3 =NOSINT SCODE SDATA STRINGMERGE MEMSIZE=$(MEMSIZE)
-CFLAGS4 = $(DEFINES) DATAMEMORY=$(MEMORYTYPE)
-
-PROPT = DEF=PROTO GPROTO GPPARM MAXIMUMERRORS=999 GENPROTOSTATICS GENPROTOPARAMETERS
-
-SRC = \
- buffer.c \
- charset.c \
- diff.c \
- digraph.c \
- edit.c \
- eval.c \
- ex_cmds.c \
- ex_cmds2.c \
- ex_docmd.c \
- ex_eval.c \
- ex_getln.c \
- fileio.c \
- fold.c \
- getchar.c \
- main.c \
- mark.c \
- memfile.c \
- memline.c \
- menu.c \
- message.c \
- misc1.c \
- misc2.c \
- move.c \
- normal.c \
- ops.c \
- option.c \
- os_amiga.c \
- quickfix.c \
- regexp.c \
- screen.c \
- search.c \
- syntax.c \
- tag.c \
- term.c \
- ui.c \
- undo.c \
- window.c \
- version.c \
- gui_amiga.c \
- gui.c
-
-OBJ = buffer.o charset.o diff.o digraph.o edit.o eval.o ex_cmds.o ex_cmds2.o ex_docmd.o ex_eval.o ex_getln.o \
- fileio.o fold.o getchar.o main.o mark.o memfile.o memline.o menu.o message.o misc1.o misc2.o move.o \
- normal.o ops.o option.o os_amiga.o quickfix.o regexp.o screen.o search.o syntax.o \
- tag.o term.o ui.o undo.o window.o gui_amiga.o gui.o $(TERMLIB)
-
-PRO = \
- buffer.pro \
- charset.pro \
- diff.pro \
- digraph.pro \
- edit.pro \
- eval.pro \
- ex_cmds.pro \
- ex_cmds2.pro \
- ex_docmd.pro \
- ex_eval.pro \
- ex_getln.pro \
- fileio.pro \
- fold.pro \
- getchar.pro \
- main.pro \
- mark.pro \
- memfile.pro \
- memline.pro \
- menu.pro \
- message.pro \
- misc1.pro \
- misc2.pro \
- move.pro \
- normal.pro \
- ops.pro \
- option.pro \
- os_amiga.pro \
- quickfix.pro \
- regexp.pro \
- screen.pro \
- search.pro \
- syntax.pro \
- tag.pro \
- term.pro \
- termlib.pro \
- ui.pro \
- undo.pro \
- window.pro \
- version.pro \
- gui_amiga.pro \
- gui.pro
-
-all:
- @echo "$(BCOL2)building prototypes, this may take some time$(ANSIOFF)"
- @smake proto
- @echo "$(BCOL2)building vim production version$(ANSIOFF)"
- @smake vim
-
-Vim: scoptions proto $(OBJ) version.c version.h
- $(CC) $(CFLAGS) version.c
- $(CC) LINK $(OPT) $(COPTS) $(OBJ) version.o $(DBG) PNAME=Vim
-
-debug: scoption protos $(OBJ) version.c version.h
- $(CC) $(CFLAGS) version.c
- $(CC) LINK $(COPTS) $(OBJ) version.o $(DBG) PNAME=Vim
-
-proto: $(PRO)
-
-tags: $(SRC)
- spat ctags $(SRC) *.h
- #csh -c ctags $(SRC) *.h
-
-# can't use delete here, too many file names
-clean:
- @echo removing all object files
- -delete $(OBJ) >nil:
-
-clobber: clean
- @echo removing all prototype files
- -delete $(PRO) SCOPTIONS vim $(GST) > NIL:
-
-
-# generate an options file, as there is no way the amiga command line can handle the
-# lengths that this makefile will impose on the shell.
-scoptions: smakefile
- @echo "$(BCOL2)Generating $(ANSIOFF)$(FCOL4)- $@$(ANSIOFF)"
- @echo $(CFLAGS) > scoptions
- @echo $(CFLAGS1) >> scoptions
- @echo $(CFLAGS2) >> scoptions
- @echo $(CFLAGS3) >> scoptions
- @echo $(CFLAGS4) >> scoptions
- @echo $(COPTS) >>scoptions
- @echo scoptions has been built
-
-
-#generate GlobalSymbolTable, which both speeds up the compile time, but also
-#solves some problems with prototypes, and types that are defined in a unixy
-#manner.
-#
-#I use a preprocessing stage here to work arounda bug in the GST generator, in
-#that it does not handle nested makefiles properly in this stage.
-$(GST): scoptions vim.h keymap.h macros.h ascii.h term.h structs.h gui.h gui_amiga.h
- @echo "$(BCOL2)Generating Global Symbol Table $(ANSIOFF)$(FCOL4) $(GST) $(ANSIOFF)"
- $(CC) PREPROCESSORONLY gui_amiga.h objectname pre.h
- $(CC) MGST=$(GST) pre.h ignore=105,316
- del pre.h
-
-
-###########################################################################
-
-.c.o:
- @echo "$(BCOL2)Generating object for $(ANSIOFF)$(FCOL4) $*.c -> $@$(ANSIOFF)"
- $(CC) $*.c
-
-.c.pro:
- @echo "$(BCOL2)Generating prototypes for $(ANSIOFF)$(FCOL4) $*.c -> $@$(ANSIOFF)"
- @$(CC) NOERRORREXX GPFILE=$*.pro $(PROPT) $*.c ignore=306,316,317,304
-
-$(PRO): $(GST)
-$(OBJ): $(GST)
-
-# dependancies
-buffer.o: buffer.c $(DEP)
-buffer.pro: buffer.c $(DEP)
-charset.o: charset.c $(DEP)
-charset.pro: charset.c $(DEP)
-diff.o: diff.c $(DEP)
-diff.pro: diff.c $(DEP)
-digraph.o: digraph.c $(DEP)
-digraph.pro: digraph.c $(DEP)
-edit.o: edit.c $(DEP)
-edit.pro: edit.c $(DEP)
-eval.o: eval.c $(DEP)
-eval.pro: eval.c $(DEP)
-ex_cmds.o: ex_cmds.c $(DEP)
-ex_cmds.pro: ex_cmds.c $(DEP)
-ex_cmds2.o: ex_cmds2.c $(DEP)
-ex_cmds2.pro: ex_cmds2.c $(DEP)
-ex_docmd.o: ex_docmd.c ex_cmds.h $(DEP)
-ex_docmd.pro: ex_docmd.c ex_cmds.h $(DEP)
-ex_eval.o: ex_eval.c ex_cmds.h $(DEP)
-ex_eval.pro: ex_eval.c ex_cmds.h $(DEP)
-ex_getln.o: ex_getln.c $(DEP)
-ex_getln.pro: ex_getln.c $(DEP)
-fileio.o: fileio.c $(DEP)
-fileio.pro: fileio.c $(DEP)
-fold.o: fold.c $(DEP)
-fold.pro: fold.c $(DEP)
-getchar.o: getchar.c $(DEP)
-getchar.pro: getchar.c $(DEP)
-main.o: main.c globals.h $(DEP)
-main.pro: main.c globals.h $(DEP)
-mark.o: mark.c $(DEP)
-mark.pro: mark.c $(DEP)
-memfile.o: memfile.c $(DEP)
-memfile.pro: memfile.c $(DEP)
-memline.o: memline.c $(DEP)
-memline.pro: memline.c $(DEP)
-menu.o: menu.c $(DEP)
-menu.pro: menu.c $(DEP)
-message.o: message.c $(DEP)
-message.pro: message.c $(DEP)
-misc1.o: misc1.c $(DEP)
-misc1.pro: misc1.c $(DEP)
-misc2.o: misc2.c $(DEP)
-misc2.pro: misc2.c $(DEP)
-move.o: move.c $(DEP)
-move.pro: move.c $(DEP)
-normal.o: normal.c $(DEP)
-normal.pro: normal.c $(DEP)
-ops.o: ops.c $(DEP)
-ops.pro: ops.c $(DEP)
-option.o: option.c $(DEP)
-option.pro: option.c $(DEP)
-os_amiga.o: os_amiga.c $(DEP)
-os_amiga.pro: os_amiga.c $(DEP)
-quickfix.o: quickfix.c $(DEP)
-quickfix.pro: quickfix.c $(DEP)
-regexp.o: regexp.c $(DEP)
-regexp.pro: regexp.c $(DEP)
-screen.o: screen.c $(DEP)
-screen.pro: screen.c $(DEP)
-search.o: search.c $(DEP)
-search.pro: search.c $(DEP)
-syntax.o: syntax.c $(DEP)
-syntax.pro: syntax.c $(DEP)
-tag.o: tag.c $(DEP)
-tag.pro: tag.c $(DEP)
-term.o: term.c $(DEP)
-term.pro: term.c $(DEP)
-termlib.o: termlib.c $(DEP)
-termlib.pro: termlib.c $(DEP)
-ui.o: ui.c $(DEP)
-ui.pro: ui.c $(DEP)
-undo.o: undo.c $(DEP)
-undo.pro: undo.c $(DEP)
-window.o: window.c $(DEP)
-window.pro: window.c $(DEP)
-gui_amiga.o: gui_amiga.c $(DEP) amiga.h
-#gui_amiga.pro: gui_amiga.c $(DEP) amiga.h
-amiga.o: amiga.c $(DEP) amiga.h
-amiga.pro: amiga.c $(DEP) amiga.h
-gui.o: gui.c $(DEP)
-gui.pro: gui.c $(DEP)
diff --git a/src/Make_aros.mak b/src/Make_aros.mak
deleted file mode 100644
index 5d26eef0..00000000
--- a/src/Make_aros.mak
+++ /dev/null
@@ -1,29 +0,0 @@
-# Makefile for AROS
-
-CFLAGS = -pipe -O2 -Wall -Iproto \
- -DNO_ARP -DUSE_TMPNAM -DFEAT_GUI_AMIGA
-
-PRG = VIM
-LIBS =
-CC = i386-linux-aros-gcc
-LD = i386-linux-aros-gcc
-RM = rm
-
-SRCS = buffer.c charset.c diff.c digraph.c edit.c eval.c ex_cmds.c \
- ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c fileio.c fold.c getchar.c \
- main.c mark.c mbyte.c memfile.c memline.c menu.c message.c misc1.c \
- misc2.c move.c normal.c ops.c option.c os_amiga.c quickfix.c \
- regexp.c screen.c search.c syntax.c tag.c term.c ui.c undo.c \
- version.c window.c gui_amiga.c gui.c
-
-OBJS = $(SRCS:.c=.o)
-
-
-$(PRG): $(OBJS)
- ${LD} -o $(PRG) $(OBJS) $(LIBS)
-
-.c.o:
- ${CC} -c ${CFLAGS} $< -o $@
-
-clean:
- $(RM) -fv $(OBJS) $(PRG)
diff --git a/src/Make_morph.mak b/src/Make_morph.mak
index f9ceb50c..ffcb8145 100644
--- a/src/Make_morph.mak
+++ b/src/Make_morph.mak
@@ -2,16 +2,6 @@
# Makefile for VIM, using MorphOS SDK (gcc 2.95.3)
#
-# Uncomment the following two lines and comment the two after in
-# case you want to play with GVIM MorphOS. But it's still known
-# to not work at all. So meanwhile it's better to stick with VIM.
-
-# GVIM = -DFEAT_GUI_AMIGA
-# GVIMSRC = gui_amiga.c gui.c
-
-GVIM =
-GVIMSRC =
-
CFLAGS = -c \
-pipe \
-O2 \
@@ -19,7 +9,6 @@ CFLAGS = -c \
\
-DNO_ARP \
-DUSE_TMPNAM \
- ${GVIM} \
\
-I proto \
\
@@ -74,7 +63,6 @@ SRC = buffer.c \
undo.c \
version.c \
window.c \
- ${GVIMSRC}
OBJ = $(SRC:.c=.o)
diff --git a/src/eval.c b/src/eval.c
index 82d1c69c..e812e532 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -94,7 +94,11 @@ struct listvar_S
typedef struct listvar_S listvar;
#define VAR_LIST_MAXNEST 100 /* maximum nesting of lists */
-static char_u *e_listidx = (char_u *)N_("E999: list index out of range: %ld");
+static char *e_letunexp = N_("E18: Unexpected characters in :let");
+static char *e_listidx = N_("E999: list index out of range: %ld");
+static char *e_undefvar = N_("E121: Undefined variable: %s");
+static char *e_missbrac = N_("E111: Missing ']'");
+static char *e_intern2 = N_("E999: Internal error: %s");
/*
* All user-defined global variables are stored in "variables".
@@ -159,7 +163,7 @@ struct funccall
var firstline; /* "a:firstline" variable */
var lastline; /* "a:lastline" variable */
garray_T l_vars; /* local function variables */
- typeval *retvar; /* return value variable */
+ typeval *rettv; /* return value */
linenr_T breakpoint; /* next line with breakpoint or zero */
int dbg_tick; /* debug_tick when breakpoint was set */
int level; /* top nesting level of executed function */
@@ -275,19 +279,19 @@ struct vimvar
{"insertmode", sizeof("insertmode") - 1, NULL, VAR_STRING, VV_RO},
};
-static int eval0 __ARGS((char_u *arg, VAR retvar, char_u **nextcmd, int evaluate));
-static int eval1 __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int eval2 __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int eval3 __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int eval4 __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int eval5 __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int eval6 __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int eval7 __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int eval_index __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int get_option_vartv __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int get_string_vartv __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int get_lit_string_vartv __ARGS((char_u **arg, typeval *retvar, int evaluate));
-static int get_list_vartv __ARGS((char_u **arg, typeval *retvar, int evaluate));
+static int eval0 __ARGS((char_u *arg, typeval *rettv, char_u **nextcmd, int evaluate));
+static int eval1 __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int eval2 __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int eval3 __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int eval4 __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int eval5 __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int eval6 __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int eval7 __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int eval_index __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int get_option_tv __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int get_string_tv __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int get_lit_string_tv __ARGS((char_u **arg, typeval *rettv, int evaluate));
+static int get_list_tv __ARGS((char_u **arg, typeval *rettv, int evaluate));
static listvar *list_alloc __ARGS((void));
static void list_unref __ARGS((listvar *l));
static void list_free __ARGS((listvar *l));
@@ -301,180 +305,180 @@ static listvar *list_copy __ARGS((listvar *orig, int deep));
static listitem *list_getrem __ARGS((listvar *l, long n));
static char_u *list2string __ARGS((typeval *tv));
static char_u *tv2string __ARGS((typeval *tv, char_u **tofree));
-static int get_env_vartv __ARGS((char_u **arg, typeval *retvar, int evaluate));
+static int get_env_tv __ARGS((char_u **arg, typeval *rettv, int evaluate));
static int find_internal_func __ARGS((char_u *name));
static char_u *deref_func_name __ARGS((char_u *name, int *lenp));
-static int get_func_vartv __ARGS((char_u *name, int len, typeval *retvar, char_u **arg, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate));
-static int call_func __ARGS((char_u *name, int len, typeval *retvar, int argcount, typeval *argvars, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate));
-static void f_append __ARGS((typeval *argvars, typeval *retvar));
-static void f_argc __ARGS((typeval *argvars, typeval *retvar));
-static void f_argidx __ARGS((typeval *argvars, typeval *retvar));
-static void f_argv __ARGS((typeval *argvars, typeval *retvar));
-static void f_browse __ARGS((typeval *argvars, typeval *retvar));
-static void f_browsedir __ARGS((typeval *argvars, typeval *retvar));
+static int get_func_tv __ARGS((char_u *name, int len, typeval *rettv, char_u **arg, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate));
+static int call_func __ARGS((char_u *name, int len, typeval *rettv, int argcount, typeval *argvars, linenr_T firstline, linenr_T lastline, int *doesrange, int evaluate));
+static void f_append __ARGS((typeval *argvars, typeval *rettv));
+static void f_argc __ARGS((typeval *argvars, typeval *rettv));
+static void f_argidx __ARGS((typeval *argvars, typeval *rettv));
+static void f_argv __ARGS((typeval *argvars, typeval *rettv));
+static void f_browse __ARGS((typeval *argvars, typeval *rettv));
+static void f_browsedir __ARGS((typeval *argvars, typeval *rettv));
static buf_T *find_buffer __ARGS((typeval *avar));
-static void f_bufexists __ARGS((typeval *argvars, typeval *retvar));
-static void f_buflisted __ARGS((typeval *argvars, typeval *retvar));
-static void f_bufloaded __ARGS((typeval *argvars, typeval *retvar));
-static buf_T *get_buf_vartv __ARGS((typeval *avar));
-static void f_bufname __ARGS((typeval *argvars, typeval *retvar));
-static void f_bufnr __ARGS((typeval *argvars, typeval *retvar));
-static void f_bufwinnr __ARGS((typeval *argvars, typeval *retvar));
-static void f_byte2line __ARGS((typeval *argvars, typeval *retvar));
-static void f_byteidx __ARGS((typeval *argvars, typeval *retvar));
-static void f_char2nr __ARGS((typeval *argvars, typeval *retvar));
-static void f_cindent __ARGS((typeval *argvars, typeval *retvar));
-static void f_col __ARGS((typeval *argvars, typeval *retvar));
-static void f_confirm __ARGS((typeval *argvars, typeval *retvar));
-static void f_copy __ARGS((typeval *argvars, typeval *retvar));
-static void f_cscope_connection __ARGS((typeval *argvars, typeval *retvar));
-static void f_cursor __ARGS((typeval *argsvars, typeval *retvar));
-static void f_deepcopy __ARGS((typeval *argvars, typeval *retvar));
-static void f_delete __ARGS((typeval *argvars, typeval *retvar));
-static void f_did_filetype __ARGS((typeval *argvars, typeval *retvar));
-static void f_diff_filler __ARGS((typeval *argvars, typeval *retvar));
-static void f_diff_hlID __ARGS((typeval *argvars, typeval *retvar));
-static void f_escape __ARGS((typeval *argvars, typeval *retvar));
-static void f_eventhandler __ARGS((typeval *argvars, typeval *retvar));
-static void f_executable __ARGS((typeval *argvars, typeval *retvar));
-static void f_exists __ARGS((typeval *argvars, typeval *retvar));
-static void f_expand __ARGS((typeval *argvars, typeval *retvar));
-static void f_filereadable __ARGS((typeval *argvars, typeval *retvar));
-static void f_filewritable __ARGS((typeval *argvars, typeval *retvar));
-static void f_finddir __ARGS((typeval *argvars, typeval *retvar));
-static void f_findfile __ARGS((typeval *argvars, typeval *retvar));
-static void f_findfilendir __ARGS((typeval *argvars, typeval *retvar, int dir));
-static void f_fnamemodify __ARGS((typeval *argvars, typeval *retvar));
-static void f_foldclosed __ARGS((typeval *argvars, typeval *retvar));
-static void f_foldclosedend __ARGS((typeval *argvars, typeval *retvar));
-static void foldclosed_both __ARGS((typeval *argvars, typeval *retvar, int end));
-static void f_foldlevel __ARGS((typeval *argvars, typeval *retvar));
-static void f_foldtext __ARGS((typeval *argvars, typeval *retvar));
-static void f_foldtextresult __ARGS((typeval *argvars, typeval *retvar));
-static void f_foreground __ARGS((typeval *argvars, typeval *retvar));
-static void f_function __ARGS((typeval *argvars, typeval *retvar));
-static void f_getbufvar __ARGS((typeval *argvars, typeval *retvar));
-static void f_getchar __ARGS((typeval *argvars, typeval *retvar));
-static void f_getcharmod __ARGS((typeval *argvars, typeval *retvar));
-static void f_getcmdline __ARGS((typeval *argvars, typeval *retvar));
-static void f_getcmdpos __ARGS((typeval *argvars, typeval *retvar));
-static void f_getcwd __ARGS((typeval *argvars, typeval *retvar));
-static void f_getfontname __ARGS((typeval *argvars, typeval *retvar));
-static void f_getfperm __ARGS((typeval *argvars, typeval *retvar));
-static void f_getfsize __ARGS((typeval *argvars, typeval *retvar));
-static void f_getftime __ARGS((typeval *argvars, typeval *retvar));
-static void f_getftype __ARGS((typeval *argvars, typeval *retvar));
-static void f_getline __ARGS((typeval *argvars, typeval *retvar));
-static void f_getreg __ARGS((typeval *argvars, typeval *retvar));
-static void f_getregtype __ARGS((typeval *argvars, typeval *retvar));
-static void f_getwinposx __ARGS((typeval *argvars, typeval *retvar));
-static void f_getwinposy __ARGS((typeval *argvars, typeval *retvar));
-static void f_getwinvar __ARGS((typeval *argvars, typeval *retvar));
-static void f_glob __ARGS((typeval *argvars, typeval *retvar));
-static void f_globpath __ARGS((typeval *argvars, typeval *retvar));
-static void f_has __ARGS((typeval *argvars, typeval *retvar));
-static void f_hasmapto __ARGS((typeval *argvars, typeval *retvar));
-static void f_histadd __ARGS((typeval *argvars, typeval *retvar));
-static void f_histdel __ARGS((typeval *argvars, typeval *retvar));
-static void f_histget __ARGS((typeval *argvars, typeval *retvar));
-static void f_histnr __ARGS((typeval *argvars, typeval *retvar));
-static void f_hlexists __ARGS((typeval *argvars, typeval *retvar));
-static void f_hlID __ARGS((typeval *argvars, typeval *retvar));
-static void f_hostname __ARGS((typeval *argvars, typeval *retvar));
-static void f_iconv __ARGS((typeval *argvars, typeval *retvar));
-static void f_indent __ARGS((typeval *argvars, typeval *retvar));
-static void f_insert __ARGS((typeval *argvars, typeval *retvar));
-static void f_isdirectory __ARGS((typeval *argvars, typeval *retvar));
-static void f_input __ARGS((typeval *argvars, typeval *retvar));
-static void f_inputdialog __ARGS((typeval *argvars, typeval *retvar));
-static void f_inputrestore __ARGS((typeval *argvars, typeval *retvar));
-static void f_inputsave __ARGS((typeval *argvars, typeval *retvar));
-static void f_inputsecret __ARGS((typeval *argvars, typeval *retvar));
-static void f_last_buffer_nr __ARGS((typeval *argvars, typeval *retvar));
-static void f_len __ARGS((typeval *argvars, typeval *retvar));
-static void f_libcall __ARGS((typeval *argvars, typeval *retvar));
-static void f_libcallnr __ARGS((typeval *argvars, typeval *retvar));
-static void libcall_common __ARGS((typeval *argvars, typeval *retvar, int type));
-static void f_line __ARGS((typeval *argvars, typeval *retvar));
-static void f_line2byte __ARGS((typeval *argvars, typeval *retvar));
-static void f_lispindent __ARGS((typeval *argvars, typeval *retvar));
-static void f_localtime __ARGS((typeval *argvars, typeval *retvar));
-static void f_maparg __ARGS((typeval *argvars, typeval *retvar));
-static void f_mapcheck __ARGS((typeval *argvars, typeval *retvar));
-static void get_maparg __ARGS((typeval *argvars, typeval *retvar, int exact));
-static void f_match __ARGS((typeval *argvars, typeval *retvar));
-static void f_matchend __ARGS((typeval *argvars, typeval *retvar));
-static void f_matchstr __ARGS((typeval *argvars, typeval *retvar));
-static void f_mode __ARGS((typeval *argvars, typeval *retvar));
-static void f_nextnonblank __ARGS((typeval *argvars, typeval *retvar));
-static void f_nr2char __ARGS((typeval *argvars, typeval *retvar));
-static void f_prevnonblank __ARGS((typeval *argvars, typeval *retvar));
-static void f_setbufvar __ARGS((typeval *argvars, typeval *retvar));
-static void f_setcmdpos __ARGS((typeval *argvars, typeval *retvar));
-static void f_setwinvar __ARGS((typeval *argvars, typeval *retvar));
-static void f_remove __ARGS((typeval *argvars, typeval *retvar));
-static void f_rename __ARGS((typeval *argvars, typeval *retvar));
-static void f_resolve __ARGS((typeval *argvars, typeval *retvar));
-static void f_search __ARGS((typeval *argvars, typeval *retvar));
-static void f_searchpair __ARGS((typeval *argvars, typeval *retvar));
+static void f_bufexists __ARGS((typeval *argvars, typeval *rettv));
+static void f_buflisted __ARGS((typeval *argvars, typeval *rettv));
+static void f_bufloaded __ARGS((typeval *argvars, typeval *rettv));
+static buf_T *get_buf_tv __ARGS((typeval *tv));
+static void f_bufname __ARGS((typeval *argvars, typeval *rettv));
+static void f_bufnr __ARGS((typeval *argvars, typeval *rettv));
+static void f_bufwinnr __ARGS((typeval *argvars, typeval *rettv));
+static void f_byte2line __ARGS((typeval *argvars, typeval *rettv));
+static void f_byteidx __ARGS((typeval *argvars, typeval *rettv));
+static void f_char2nr __ARGS((typeval *argvars, typeval *rettv));
+static void f_cindent __ARGS((typeval *argvars, typeval *rettv));
+static void f_col __ARGS((typeval *argvars, typeval *rettv));
+static void f_confirm __ARGS((typeval *argvars, typeval *rettv));
+static void f_copy __ARGS((typeval *argvars, typeval *rettv));
+static void f_cscope_connection __ARGS((typeval *argvars, typeval *rettv));
+static void f_cursor __ARGS((typeval *argsvars, typeval *rettv));
+static void f_deepcopy __ARGS((typeval *argvars, typeval *rettv));
+static void f_delete __ARGS((typeval *argvars, typeval *rettv));
+static void f_did_filetype __ARGS((typeval *argvars, typeval *rettv));
+static void f_diff_filler __ARGS((typeval *argvars, typeval *rettv));
+static void f_diff_hlID __ARGS((typeval *argvars, typeval *rettv));
+static void f_escape __ARGS((typeval *argvars, typeval *rettv));
+static void f_eventhandler __ARGS((typeval *argvars, typeval *rettv));
+static void f_executable __ARGS((typeval *argvars, typeval *rettv));
+static void f_exists __ARGS((typeval *argvars, typeval *rettv));
+static void f_expand __ARGS((typeval *argvars, typeval *rettv));
+static void f_filereadable __ARGS((typeval *argvars, typeval *rettv));
+static void f_filewritable __ARGS((typeval *argvars, typeval *rettv));
+static void f_finddir __ARGS((typeval *argvars, typeval *rettv));
+static void f_findfile __ARGS((typeval *argvars, typeval *rettv));
+static void f_findfilendir __ARGS((typeval *argvars, typeval *rettv, int dir));
+static void f_fnamemodify __ARGS((typeval *argvars, typeval *rettv));
+static void f_foldclosed __ARGS((typeval *argvars, typeval *rettv));
+static void f_foldclosedend __ARGS((typeval *argvars, typeval *rettv));
+static void foldclosed_both __ARGS((typeval *argvars, typeval *rettv, int end));
+static void f_foldlevel __ARGS((typeval *argvars, typeval *rettv));
+static void f_foldtext __ARGS((typeval *argvars, typeval *rettv));
+static void f_foldtextresult __ARGS((typeval *argvars, typeval *rettv));
+static void f_foreground __ARGS((typeval *argvars, typeval *rettv));
+static void f_function __ARGS((typeval *argvars, typeval *rettv));
+static void f_getbufvar __ARGS((typeval *argvars, typeval *rettv));
+static void f_getchar __ARGS((typeval *argvars, typeval *rettv));
+static void f_getcharmod __ARGS((typeval *argvars, typeval *rettv));
+static void f_getcmdline __ARGS((typeval *argvars, typeval *rettv));
+static void f_getcmdpos __ARGS((typeval *argvars, typeval *rettv));
+static void f_getcwd __ARGS((typeval *argvars, typeval *rettv));
+static void f_getfontname __ARGS((typeval *argvars, typeval *rettv));
+static void f_getfperm __ARGS((typeval *argvars, typeval *rettv));
+static void f_getfsize __ARGS((typeval *argvars, typeval *rettv));
+static void f_getftime __ARGS((typeval *argvars, typeval *rettv));
+static void f_getftype __ARGS((typeval *argvars, typeval *rettv));
+static void f_getline __ARGS((typeval *argvars, typeval *rettv));
+static void f_getreg __ARGS((typeval *argvars, typeval *rettv));
+static void f_getregtype __ARGS((typeval *argvars, typeval *rettv));
+static void f_getwinposx __ARGS((typeval *argvars, typeval *rettv));
+static void f_getwinposy __ARGS((typeval *argvars, typeval *rettv));
+static void f_getwinvar __ARGS((typeval *argvars, typeval *rettv));
+static void f_glob __ARGS((typeval *argvars, typeval *rettv));
+static void f_globpath __ARGS((typeval *argvars, typeval *rettv));
+static void f_has __ARGS((typeval *argvars, typeval *rettv));
+static void f_hasmapto __ARGS((typeval *argvars, typeval *rettv));
+static void f_histadd __ARGS((typeval *argvars, typeval *rettv));
+static void f_histdel __ARGS((typeval *argvars, typeval *rettv));
+static void f_histget __ARGS((typeval *argvars, typeval *rettv));
+static void f_histnr __ARGS((typeval *argvars, typeval *rettv));
+static void f_hlexists __ARGS((typeval *argvars, typeval *rettv));
+static void f_hlID __ARGS((typeval *argvars, typeval *rettv));
+static void f_hostname __ARGS((typeval *argvars, typeval *rettv));
+static void f_iconv __ARGS((typeval *argvars, typeval *rettv));
+static void f_indent __ARGS((typeval *argvars, typeval *rettv));
+static void f_insert __ARGS((typeval *argvars, typeval *rettv));
+static void f_isdirectory __ARGS((typeval *argvars, typeval *rettv));
+static void f_input __ARGS((typeval *argvars, typeval *rettv));
+static void f_inputdialog __ARGS((typeval *argvars, typeval *rettv));
+static void f_inputrestore __ARGS((typeval *argvars, typeval *rettv));
+static void f_inputsave __ARGS((typeval *argvars, typeval *rettv));
+static void f_inputsecret __ARGS((typeval *argvars, typeval *rettv));
+static void f_last_buffer_nr __ARGS((typeval *argvars, typeval *rettv));
+static void f_len __ARGS((typeval *argvars, typeval *rettv));
+static void f_libcall __ARGS((typeval *argvars, typeval *rettv));
+static void f_libcallnr __ARGS((typeval *argvars, typeval *rettv));
+static void libcall_common __ARGS((typeval *argvars, typeval *rettv, int type));
+static void f_line __ARGS((typeval *argvars, typeval *rettv));
+static void f_line2byte __ARGS((typeval *argvars, typeval *rettv));
+static void f_lispindent __ARGS((typeval *argvars, typeval *rettv));
+static void f_localtime __ARGS((typeval *argvars, typeval *rettv));
+static void f_maparg __ARGS((typeval *argvars, typeval *rettv));
+static void f_mapcheck __ARGS((typeval *argvars, typeval *rettv));
+static void get_maparg __ARGS((typeval *argvars, typeval *rettv, int exact));
+static void f_match __ARGS((typeval *argvars, typeval *rettv));
+static void f_matchend __ARGS((typeval *argvars, typeval *rettv));
+static void f_matchstr __ARGS((typeval *argvars, typeval *rettv));
+static void f_mode __ARGS((typeval *argvars, typeval *rettv));
+static void f_nextnonblank __ARGS((typeval *argvars, typeval *rettv));
+static void f_nr2char __ARGS((typeval *argvars, typeval *rettv));
+static void f_prevnonblank __ARGS((typeval *argvars, typeval *rettv));
+static void f_setbufvar __ARGS((typeval *argvars, typeval *rettv));
+static void f_setcmdpos __ARGS((typeval *argvars, typeval *rettv));
+static void f_setwinvar __ARGS((typeval *argvars, typeval *rettv));
+static void f_remove __ARGS((typeval *argvars, typeval *rettv));
+static void f_rename __ARGS((typeval *argvars, typeval *rettv));
+static void f_resolve __ARGS((typeval *argvars, typeval *rettv));
+static void f_search __ARGS((typeval *argvars, typeval *rettv));
+static void f_searchpair __ARGS((typeval *argvars, typeval *rettv));
static int get_search_arg __ARGS((typeval *varp, int *flagsp));
-static void f_remote_expr __ARGS((typeval *argvars, typeval *retvar));
-static void f_remote_foreground __ARGS((typeval *argvars, typeval *retvar));
-static void f_remote_peek __ARGS((typeval *argvars, typeval *retvar));
-static void f_remote_read __ARGS((typeval *argvars, typeval *retvar));
-static void f_remote_send __ARGS((typeval *argvars, typeval *retvar));
-static void f_repeat __ARGS((typeval *argvars, typeval *retvar));
-static void f_server2client __ARGS((typeval *argvars, typeval *retvar));
-static void f_serverlist __ARGS((typeval *argvars, typeval *retvar));
-static void f_setline __ARGS((typeval *argvars, typeval *retvar));
-static void f_setreg __ARGS((typeval *argvars, typeval *retvar));
-static void f_simplify __ARGS((typeval *argvars, typeval *retvar));
-static void find_some_match __ARGS((typeval *argvars, typeval *retvar, int start));
-static void f_strftime __ARGS((typeval *argvars, typeval *retvar));
-static void f_stridx __ARGS((typeval *argvars, typeval *retvar));
-static void f_string __ARGS((typeval *argvars, typeval *retvar));
-static void f_strlen __ARGS((typeval *argvars, typeval *retvar));
-static void f_strpart __ARGS((typeval *argvars, typeval *retvar));
-static void f_strridx __ARGS((typeval *argvars, typeval *retvar));
-static void f_strtrans __ARGS((typeval *argvars, typeval *retvar));
-static void f_synID __ARGS((typeval *argvars, typeval *retvar));
-static void f_synIDattr __ARGS((typeval *argvars, typeval *retvar));
-static void f_synIDtrans __ARGS((typeval *argvars, typeval *retvar));
-static void f_system __ARGS((typeval *argvars, typeval *retvar));
-static void f_submatch __ARGS((typeval *argvars, typeval *retvar));
-static void f_substitute __ARGS((typeval *argvars, typeval *retvar));
-static void f_tempname __ARGS((typeval *argvars, typeval *retvar));
-static void f_tolower __ARGS((typeval *argvars, typeval *retvar));
-static void f_toupper __ARGS((typeval *argvars, typeval *retvar));
-static void f_tr __ARGS((typeval *argvars, typeval *retvar));
-static void f_type __ARGS((typeval *argvars, typeval *retvar));
-static void f_virtcol __ARGS((typeval *argvars, typeval *retvar));
-static void f_visualmode __ARGS((typeval *argvars, typeval *retvar));
-static void f_winbufnr __ARGS((typeval *argvars, typeval *retvar));
-static void f_wincol __ARGS((typeval *argvars, typeval *retvar));
-static void f_winheight __ARGS((typeval *argvars, typeval *retvar));
-static void f_winline __ARGS((typeval *argvars, typeval *retvar));
-static void f_winnr __ARGS((typeval *argvars, typeval *retvar));
-static void f_winrestcmd __ARGS((typeval *argvars, typeval *retvar));
-static void f_winwidth __ARGS((typeval *argvars, typeval *retvar));
+static void f_remote_expr __ARGS((typeval *argvars, typeval *rettv));
+static void f_remote_foreground __ARGS((typeval *argvars, typeval *rettv));
+static void f_remote_peek __ARGS((typeval *argvars, typeval *rettv));
+static void f_remote_read __ARGS((typeval *argvars, typeval *rettv));
+static void f_remote_send __ARGS((typeval *argvars, typeval *rettv));
+static void f_repeat __ARGS((typeval *argvars, typeval *rettv));
+static void f_server2client __ARGS((typeval *argvars, typeval *rettv));
+static void f_serverlist __ARGS((typeval *argvars, typeval *rettv));
+static void f_setline __ARGS((typeval *argvars, typeval *rettv));
+static void f_setreg __ARGS((typeval *argvars, typeval *rettv));
+static void f_simplify __ARGS((typeval *argvars, typeval *rettv));
+static void find_some_match __ARGS((typeval *argvars, typeval *rettv, int start));
+static void f_strftime __ARGS((typeval *argvars, typeval *rettv));
+static void f_stridx __ARGS((typeval *argvars, typeval *rettv));
+static void f_string __ARGS((typeval *argvars, typeval *rettv));
+static void f_strlen __ARGS((typeval *argvars, typeval *rettv));
+static void f_strpart __ARGS((typeval *argvars, typeval *rettv));
+static void f_strridx __ARGS((typeval *argvars, typeval *rettv));
+static void f_strtrans __ARGS((typeval *argvars, typeval *rettv));
+static void f_synID __ARGS((typeval *argvars, typeval *rettv));
+static void f_synIDattr __ARGS((typeval *argvars, typeval *rettv));
+static void f_synIDtrans __ARGS((typeval *argvars, typeval *rettv));
+static void f_system __ARGS((typeval *argvars, typeval *rettv));
+static void f_submatch __ARGS((typeval *argvars, typeval *rettv));
+static void f_substitute __ARGS((typeval *argvars, typeval *rettv));
+static void f_tempname __ARGS((typeval *argvars, typeval *rettv));
+static void f_tolower __ARGS((typeval *argvars, typeval *rettv));
+static void f_toupper __ARGS((typeval *argvars, typeval *rettv));
+static void f_tr __ARGS((typeval *argvars, typeval *rettv));
+static void f_type __ARGS((typeval *argvars, typeval *rettv));
+static void f_virtcol __ARGS((typeval *argvars, typeval *rettv));
+static void f_visualmode __ARGS((typeval *argvars, typeval *rettv));
+static void f_winbufnr __ARGS((typeval *argvars, typeval *rettv));
+static void f_wincol __ARGS((typeval *argvars, typeval *rettv));
+static void f_winheight __ARGS((typeval *argvars, typeval *rettv));
+static void f_winline __ARGS((typeval *argvars, typeval *rettv));
+static void f_winnr __ARGS((typeval *argvars, typeval *rettv));
+static void f_winrestcmd __ARGS((typeval *argvars, typeval *rettv));
+static void f_winwidth __ARGS((typeval *argvars, typeval *rettv));
static win_T *find_win_by_nr __ARGS((typeval *vp));
static pos_T *var2fpos __ARGS((typeval *varp, int lnum));
static int get_env_len __ARGS((char_u **arg));
static int get_id_len __ARGS((char_u **arg));
static int get_func_len __ARGS((char_u **arg, char_u **alias, int evaluate));
-static char_u *find_name_end __ARGS((char_u *arg, char_u **expr_start, char_u **expr_end));
+static char_u *find_name_end __ARGS((char_u *arg, char_u **expr_start, char_u **expr_end, int incl_br));
static int eval_isnamec __ARGS((int c));
static int find_vim_var __ARGS((char_u *name, int len));
-static int get_var_vartv __ARGS((char_u *name, int len, typeval *retvar));
-static VAR alloc_var __ARGS((void));
-static typeval *alloc_vartv __ARGS((void));
-static typeval *alloc_string_vartv __ARGS((char_u *string));
-static void free_vartv __ARGS((typeval *varp));
-static void clear_vartv __ARGS((typeval *varp));
-static long get_vartv_number __ARGS((typeval *varp));
-static linenr_T get_vartv_lnum __ARGS((typeval *argvars));
-static char_u *get_vartv_string __ARGS((typeval *varp));
-static char_u *get_vartv_string_buf __ARGS((typeval *varp, char_u *buf));
+static int get_var_tv __ARGS((char_u *name, int len, typeval *rettv));
+static typeval *alloc_tv __ARGS((void));
+static typeval *alloc_string_tv __ARGS((char_u *string));
+static void free_tv __ARGS((typeval *varp));
+static void clear_tv __ARGS((typeval *varp));
+static void init_tv __ARGS((typeval *varp));
+static long get_tv_number __ARGS((typeval *varp));
+static linenr_T get_tv_lnum __ARGS((typeval *argvars));
+static char_u *get_tv_string __ARGS((typeval *varp));
+static char_u *get_tv_string_buf __ARGS((typeval *varp, char_u *buf));
static VAR find_var __ARGS((char_u *name, int writing));
static VAR find_var_in_ga __ARGS((garray_T *gap, char_u *varname));
static garray_T *find_var_ga __ARGS((char_u *name, char_u **varname));
@@ -483,7 +487,7 @@ static void list_one_var __ARGS((VAR v, char_u *prefix));
static void list_vim_var __ARGS((int i));
static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string));
static void set_var __ARGS((char_u *name, typeval *varp, int copy));
-static void copy_vartv __ARGS((typeval *from, typeval *to));
+static void copy_tv __ARGS((typeval *from, typeval *to));
static char_u *find_option_end __ARGS((char_u **arg, int *opt_flags));
static char_u *trans_function_name __ARGS((char_u **pp, int skip, int internal));
static int eval_fname_script __ARGS((char_u *p));
@@ -492,19 +496,18 @@ static void list_func_head __ARGS((ufunc_T *fp, int indent));
static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
static ufunc_T *find_func __ARGS((char_u *name));
static int function_exists __ARGS((char_u *name));
-static void call_user_func __ARGS((ufunc_T *fp, int argcount, typeval *argvars, typeval *retvar, linenr_T firstline, linenr_T lastline));
+static void call_user_func __ARGS((ufunc_T *fp, int argcount, typeval *argvars, typeval *rettv, linenr_T firstline, linenr_T lastline));
-#define get_var_string(p) get_vartv_string(&(p)->tv)
-#define get_var_string_buf(p, b) get_vartv_string_buf(&(p)->tv, (b))
-#define get_var_number(p) get_vartv_number(&((p)->tv))
+#define get_var_string(p) get_tv_string(&(p)->tv)
+#define get_var_string_buf(p, b) get_tv_string_buf(&(p)->tv, (b))
+#define get_var_number(p) get_tv_number(&((p)->tv))
-/* Magic braces are always enabled, otherwise Vim scripts would not be
- * portable. */
-#define FEAT_MAGIC_BRACES
-
-#ifdef FEAT_MAGIC_BRACES
static char_u * make_expanded_name __ARGS((char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end));
-#endif
+
+static void list_all_vars __ARGS((void));
+static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg));
+static char_u *ex_let_one __ARGS((char_u *arg, typeval *tv, int copy, char_u *endchars));
+static char_u *set_var_idx __ARGS((char_u *name, char_u *ip, typeval *rettv, int copy, char_u *endchars));
/*
* Set an internal variable to a string value. Creates the variable if it does
@@ -521,11 +524,11 @@ set_internal_string_var(name, value)
val = vim_strsave(value);
if (val != NULL)
{
- tvp = alloc_string_vartv(val);
+ tvp = alloc_string_tv(val);
if (tvp != NULL)
{
set_var(name, tvp, FALSE);
- free_vartv(tvp);
+ free_tv(tvp);
}
}
}
@@ -629,22 +632,20 @@ eval_to_bool(arg, error, nextcmd, skip)
char_u **nextcmd;
int skip; /* only parse, don't execute */
{
- var retvar;
+ typeval tv;
int retval = FALSE;
if (skip)
++emsg_skip;
- if (eval0(arg, &retvar, nextcmd, !skip) == FAIL)
- {
+ if (eval0(arg, &tv, nextcmd, !skip) == FAIL)
*error = TRUE;
- }
else
{
*error = FALSE;
if (!skip)
{
- retval = (get_var_number(&retvar) != 0);
- clear_vartv(&retvar.tv);
+ retval = (get_tv_number(&tv) != 0);
+ clear_tv(&tv);
}
}
if (skip)
@@ -664,17 +665,17 @@ eval_to_string_skip(arg, nextcmd, skip)
char_u **nextcmd;
int skip; /* only parse, don't execute */
{
- var retvar;
+ typeval tv;
char_u *retval;
if (skip)
++emsg_skip;
- if (eval0(arg, &retvar, nextcmd, !skip) == FAIL || skip)
+ if (eval0(arg, &tv, nextcmd, !skip) == FAIL || skip)
retval = NULL;
else
{
- retval = vim_strsave(get_var_string(&retvar));
- clear_vartv(&retvar.tv);
+ retval = vim_strsave(get_tv_string(&tv));
+ clear_tv(&tv);
}
if (skip)
--emsg_skip;
@@ -690,10 +691,10 @@ eval_to_string_skip(arg, nextcmd, skip)
skip_expr(pp)
char_u **pp;
{
- typeval retvar;
+ typeval rettv;
*pp = skipwhite(*pp);
- return eval1(pp, &retvar, FALSE);
+ return eval1(pp, &rettv, FALSE);
}
/*
@@ -705,15 +706,15 @@ eval_to_string(arg, nextcmd)
char_u *arg;
char_u **nextcmd;
{
- var retvar;
+ typeval tv;
char_u *retval;
- if (eval0(arg, &retvar, nextcmd, TRUE) == FAIL)
+ if (eval0(arg, &tv, nextcmd, TRUE) == FAIL)
retval = NULL;
else
{
- retval = vim_strsave(get_var_string(&retvar));
- clear_vartv(&retvar.tv);
+ retval = vim_strsave(get_tv_string(&tv));
+ clear_tv(&tv);
}
return retval;
@@ -749,19 +750,19 @@ eval_to_string_safe(arg, nextcmd)
eval_arg_to_string(arg)
char_u **arg;
{
- typeval retvar;
+ typeval rettv;
char_u *retval;
int ret;
++emsg_off;
- ret = eval1(arg, &retvar, TRUE);
+ ret = eval1(arg, &rettv, TRUE);
if (ret == FAIL)
retval = NULL;
else
{
- retval = vim_strsave(get_vartv_string(&retvar));
- clear_vartv(&retvar);
+ retval = vim_strsave(get_tv_string(&rettv));
+ clear_tv(&rettv);
}
--emsg_off;
@@ -779,18 +780,18 @@ eval_arg_to_string(arg)
eval_to_number(expr)
char_u *expr;
{
- typeval retvar;
+ typeval rettv;
int retval;
char_u *p = expr;
++emsg_off;
- if (eval1(&p, &retvar, TRUE) == FAIL)
+ if (eval1(&p, &rettv, TRUE) == FAIL)
retval = -1;
else
{
- retval = get_vartv_number(&retvar);
- clear_vartv(&retvar);
+ retval = get_tv_number(&rettv);
+ clear_tv(&rettv);
}
--emsg_off;
@@ -810,7 +811,7 @@ call_vim_function(func, argc, argv, safe)
int safe; /* use the sandbox */
{
char_u *retval = NULL;
- var retvar;
+ typeval rettv;
typeval *argvars;
long n;
int len;
@@ -852,13 +853,13 @@ call_vim_function(func, argc, argv, safe)
++sandbox;
}
- retvar.tv.v_type = VAR_UNKNOWN; /* clear_vartv() uses this */
- if (call_func(func, (int)STRLEN(func), &retvar.tv, argc, argvars,
+ rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */
+ if (call_func(func, (int)STRLEN(func), &rettv, argc, argvars,
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
&doesrange, TRUE) == OK)
- retval = vim_strsave(get_var_string(&retvar));
+ retval = vim_strsave(get_tv_string(&rettv));
- clear_vartv(&retvar.tv);
+ clear_tv(&rettv);
vim_free(argvars);
if (safe)
@@ -901,33 +902,33 @@ eval_foldexpr(arg, cp)
char_u *arg;
int *cp;
{
- var retvar;
+ typeval tv;
int retval;
char_u *s;
++emsg_off;
++sandbox;
*cp = NUL;
- if (eval0(arg, &retvar, NULL, TRUE) == FAIL)
+ if (eval0(arg, &tv, NULL, TRUE) == FAIL)
retval = 0;
else
{
/* If the result is a number, just return the number. */
- if (retvar.tv.v_type == VAR_NUMBER)
- retval = retvar.tv.vval.v_number;
- else if (retvar.tv.v_type == VAR_UNKNOWN
- || retvar.tv.vval.v_string == NULL)
+ if (tv.v_type == VAR_NUMBER)
+ retval = tv.vval.v_number;
+ else if (tv.v_type == VAR_UNKNOWN
+ || tv.vval.v_string == NULL)
retval = 0;
else
{
/* If the result is a string, check if there is a non-digit before
* the number. */
- s = retvar.tv.vval.v_string;
+ s = tv.vval.v_string;
if (!VIM_ISDIGIT(*s) && *s != '-')
*cp = *s++;
retval = atol((char *)s);
}
- clear_vartv(&retvar.tv);
+ clear_tv(&tv);
}
--emsg_off;
--sandbox;
@@ -936,7 +937,6 @@ eval_foldexpr(arg, cp)
}
#endif
-#ifdef FEAT_MAGIC_BRACES
/*
* Expands out the 'magic' {}'s in a variable/function name.
* Note that this can call itself recursively, to deal with
@@ -990,7 +990,7 @@ make_expanded_name(in_start, expr_start, expr_end, in_end)
if (retval != NULL)
{
- temp_result = find_name_end(retval, &expr_start, &expr_end);
+ temp_result = find_name_end(retval, &expr_start, &expr_end, FALSE);
if (expr_start != NULL)
{
/* Further expansion! */
@@ -1004,307 +1004,525 @@ make_expanded_name(in_start, expr_start, expr_end, in_end)
return retval;
}
-#endif /* FEAT_MAGIC_BRACES */
/*
- * ":let var = expr" assignment command.
- * ":let var" list one variable value
- * ":let" list all variable values
+ * ":let" list all variable values
+ * ":let var1 var2" list variable values
+ * ":let var = expr" assignment command.
+ * ":let [var1, var2] = expr" unpack list.
*/
void
ex_let(eap)
exarg_T *eap;
{
char_u *arg = eap->arg;
- char_u *expr;
- char_u *name;
- VAR varp;
- var retvar;
- char_u *p;
- int c1 = 0, c2;
+ char_u *expr = NULL;
+ typeval rettv;
int i;
- char_u *expr_start;
- char_u *expr_end;
- char_u *name_end;
+ int var_count = 0;
+ int semicolon = 0;
+ listvar *l;
+ listitem *item;
- name_end = find_name_end(arg, &expr_start, &expr_end);
- expr = vim_strchr(name_end, '=');
- if (expr == NULL)
+ if (*arg != '[')
+ expr = vim_strchr(find_name_end(arg, NULL, NULL, TRUE), '=');
+ if (*arg != '[' && expr == NULL)
{
- if (ends_excmd(*arg))
- {
- if (!eap->skip)
- {
- /*
- * List all variables.
- */
- for (i = 0; i < variables.ga_len && !got_int; ++i)
- if (VAR_ENTRY(i).v_name != NULL)
- list_one_var(&VAR_ENTRY(i), (char_u *)"");
- for (i = 0; i < curbuf->b_vars.ga_len && !got_int; ++i)
- if (BVAR_ENTRY(i).v_name != NULL)
- list_one_var(&BVAR_ENTRY(i), (char_u *)"b:");
- for (i = 0; i < curwin->w_vars.ga_len && !got_int; ++i)
- if (WVAR_ENTRY(i).v_name != NULL)
- list_one_var(&WVAR_ENTRY(i), (char_u *)"w:");
- for (i = 0; i < VV_LEN && !got_int; ++i)
- if (vimvars[i].type == VAR_NUMBER || vimvars[i].val != NULL)
- list_vim_var(i);
- }
- }
- else
+ if (!ends_excmd(*arg))
+ /* ":let var1 var2" */
+ arg = list_arg_vars(eap, arg);
+ else if (!eap->skip)
+ /* ":let" */
+ list_all_vars();
+ eap->nextcmd = check_nextcmd(arg);
+ }
+ else
+ {
+ if (*arg == '[')
{
- int error = FALSE;
-
- /*
- * List variables.
- */
- while (!ends_excmd(*arg) && !got_int)
+ /* ":let [a, b] = expr": find the matching ']' to get to the
+ * expression. */
+ while (1)
{
- char_u *temp_string = NULL;
- int arg_len;
-
- /* Find the end of the name. */
- name_end = find_name_end(arg, &expr_start, &expr_end);
-
- if (!vim_iswhite(*name_end) && !ends_excmd(*name_end))
+ arg = skipwhite(arg + 1);
+ if (vim_strchr((char_u *)"$@&", *arg) != NULL)
+ ++arg;
+ expr = find_name_end(arg, NULL, NULL, TRUE);
+ if (expr == arg)
{
- emsg_severe = TRUE;
- EMSG(_(e_trailing));
- break;
+ EMSG2(_(e_invarg2), arg);
+ return;
}
- if (!error && !eap->skip)
- {
-#ifdef FEAT_MAGIC_BRACES
- if (expr_start != NULL)
- {
- temp_string = make_expanded_name(arg, expr_start,
- expr_end, name_end);
- if (temp_string == NULL)
- {
- /*
- * Report an invalid expression in braces, unless
- * the expression evaluation has been cancelled due
- * to an aborting error, an interrupt, or an
- * exception.
- */
- if (!aborting())
- {
- emsg_severe = TRUE;
- EMSG2(_(e_invarg2), arg);
- break;
- }
- error = TRUE;
- arg = skipwhite(name_end);
- continue;
- }
- arg = temp_string;
- arg_len = STRLEN(temp_string);
- }
- else
-#endif
- {
- c1 = *name_end;
- *name_end = NUL;
- arg_len = (int)(name_end - arg);
- }
- i = find_vim_var(arg, arg_len);
- if (i >= 0)
- list_vim_var(i);
- else if (STRCMP("b:changedtick", arg) == 0)
- {
- char_u numbuf[NUMBUFLEN];
+ ++var_count;
- sprintf((char *)numbuf, "%ld",
- (long)curbuf->b_changedtick);
- list_one_var_a((char_u *)"b:", (char_u *)"changedtick",
- VAR_NUMBER, numbuf);
- }
- else
+ arg = skipwhite(expr);
+ if (*arg == ']')
+ break;
+ else if (*arg == ';')
+ {
+ if (semicolon == 1)
{
- varp = find_var(arg, FALSE);
- if (varp == NULL)
- {
- /* Skip further arguments but do continue to
- * search for a trailing command. */
- EMSG2(_("E106: Unknown variable: \"%s\""), arg);
- error = TRUE;
- }
- else
- {
- name = vim_strchr(arg, ':');
- if (name != NULL)
- {
- /* "a:" vars have no name stored, use whole
- * arg */
- if (arg[0] == 'a' && arg[1] == ':')
- c2 = NUL;
- else
- {
- c2 = *++name;
- *name = NUL;
- }
- list_one_var(varp, arg);
- if (c2 != NUL)
- *name = c2;
- }
- else
- list_one_var(varp, (char_u *)"");
- }
+ EMSG(_("Double ; in :let"));
+ return;
}
-#ifdef FEAT_MAGIC_BRACES
- if (expr_start != NULL)
- vim_free(temp_string);
- else
-#endif
- *name_end = c1;
+ semicolon = 1;
+ }
+ else if (*arg != ',')
+ {
+ EMSG2(_(e_invarg2), arg);
+ return;
}
- arg = skipwhite(name_end);
+ }
+
+ /* check for '=' after the ']' */
+ expr = skipwhite(arg + 1);
+ if (*expr != '=')
+ {
+ EMSG(_(e_letunexp));
+ return;
}
}
- eap->nextcmd = check_nextcmd(arg);
- }
- else
- {
+
if (eap->skip)
++emsg_skip;
- i = eval0(expr + 1, &retvar, &eap->nextcmd, !eap->skip);
+ i = eval0(expr + 1, &rettv, &eap->nextcmd, !eap->skip);
if (eap->skip)
{
if (i != FAIL)
- clear_vartv(&retvar.tv);
+ clear_tv(&rettv);
--emsg_skip;
}
else if (i != FAIL)
{
- /*
- * ":let $VAR = expr": Set environment variable.
- */
- if (*arg == '$')
+ /* Move "arg" back to the variable name(s). */
+ arg = eap->arg;
+ if (*arg != '[')
{
- int len;
- int cc;
-
- /* Find the end of the name. */
- ++arg;
- name = arg;
- len = get_env_len(&arg);
- if (len == 0)
- EMSG2(_(e_invarg2), name - 1);
+ /* ":let var = expr" */
+ (void)ex_let_one(arg, &rettv, FALSE, (char_u *)"=");
+ }
+ else
+ {
+ /* ":let [v1, v2] = list" */
+ l = rettv.vval.v_list;
+ if (rettv.v_type != VAR_LIST || l == NULL)
+ EMSG(_("E999: List required"));
else
{
- if (*skipwhite(arg) != '=')
- EMSG(_(e_letunexp));
+ i = list_len(l);
+ if (semicolon == 0 && var_count < i)
+ EMSG(_("E999: Less targets than List items"));
+ else if (var_count - semicolon > i)
+ EMSG(_("E999: More targets than List items"));
else
{
- cc = name[len];
- name[len] = NUL;
- p = get_var_string(&retvar);
- vim_setenv(name, p);
- if (STRICMP(name, "HOME") == 0)
- init_homedir();
- else if (didset_vim && STRICMP(name, "VIM") == 0)
- didset_vim = FALSE;
- else if (didset_vimruntime
- && STRICMP(name, "VIMRUNTIME") == 0)
- didset_vimruntime = FALSE;
- name[len] = cc;
+ item = l->lv_first;
+ while (*arg != ']')
+ {
+ arg = skipwhite(arg + 1);
+ arg = ex_let_one(arg, &item->li_tv,
+ TRUE, (char_u *)",;]");
+ item = item->li_next;
+ if (arg == NULL)
+ break;
+
+ arg = skipwhite(arg);
+ if (*arg == ';')
+ {
+ /* Put the rest of the list (may be empty) in
+ * the var after ';'. */
+ l = list_alloc();
+ if (l == NULL)
+ break;
+ while (item != NULL)
+ {
+ list_append_tv(l, &item->li_tv);
+ item = item->li_next;
+ }
+ list_unref(rettv.vval.v_list);
+ rettv.vval.v_list = l;
+ l->lv_refcount = 1;
+ (void)ex_let_one(skipwhite(arg + 1), &rettv,
+ FALSE, (char_u *)"]");
+ break;
+ }
+ else if (*arg != ',' && *arg != ']')
+ {
+ EMSG2(_(e_intern2), "ex_let()");
+ break;
+ }
+ }
}
}
}
+ clear_tv(&rettv);
+ }
+ }
+}
- /*
- * ":let &option = expr": Set option value.
- * ":let &l:option = expr": Set local option value.
- * ":let &g:option = expr": Set global option value.
- */
- else if (*arg == '&')
- {
- int opt_flags;
+ static void
+list_all_vars()
+{
+ int i;
- /*
- * Find the end of the name;
- */
- p = find_option_end(&arg, &opt_flags);
- if (p == NULL || *skipwhite(p) != '=')
- EMSG(_(e_letunexp));
- else
+ /*
+ * List all variables.
+ */
+ for (i = 0; i < variables.ga_len && !got_int; ++i)
+ if (VAR_ENTRY(i).v_name != NULL)
+ list_one_var(&VAR_ENTRY(i), (char_u *)"");
+ for (i = 0; i < curbuf->b_vars.ga_len && !got_int; ++i)
+ if (BVAR_ENTRY(i).v_name != NULL)
+ list_one_var(&BVAR_ENTRY(i), (char_u *)"b:");
+ for (i = 0; i < curwin->w_vars.ga_len && !got_int; ++i)
+ if (WVAR_ENTRY(i).v_name != NULL)
+ list_one_var(&WVAR_ENTRY(i), (char_u *)"w:");
+ for (i = 0; i < VV_LEN && !got_int; ++i)
+ if (vimvars[i].type == VAR_NUMBER || vimvars[i].val != NULL)
+ list_vim_var(i);
+}
+
+/*
+ * List variables in "arg".
+ */
+ static char_u *
+list_arg_vars(eap, arg)
+ exarg_T *eap;
+ char_u *arg;
+{
+ int error = FALSE;
+ char_u *temp_string = NULL;
+ int arg_len;
+ char_u *expr_start;
+ char_u *expr_end;
+ char_u *name_end;
+ int c1 = 0, c2;
+ int i;
+ VAR varp;
+ char_u *name;
+
+ while (!ends_excmd(*arg) && !got_int)
+ {
+ /* Find the end of the name. */
+ name_end = find_name_end(arg, &expr_start, &expr_end, FALSE);
+
+ if (!vim_iswhite(*name_end) && !ends_excmd(*name_end))
+ {
+ emsg_severe = TRUE;
+ EMSG(_(e_trailing));
+ break;
+ }
+ if (!error && !eap->skip)
+ {
+ if (expr_start != NULL)
+ {
+ temp_string = make_expanded_name(arg, expr_start,
+ expr_end, name_end);
+ if (temp_string == NULL)
{
- c1 = *p;
- *p = NUL;
- set_option_value(arg, get_var_number(&retvar),
- get_var_string(&retvar), opt_flags);
- *p = c1; /* put back for error messages */
+ /*
+ * Report an invalid expression in braces, unless
+ * the expression evaluation has been cancelled due
+ * to an aborting error, an interrupt, or an
+ * exception.
+ */
+ if (!aborting())
+ {
+ emsg_severe = TRUE;
+ EMSG2(_(e_invarg2), arg);
+ break;
+ }
+ error = TRUE;
+ arg = skipwhite(name_end);
+ continue;
}
+ arg = temp_string;
+ arg_len = STRLEN(temp_string);
}
-
- /*
- * ":let @r = expr": Set register contents.
- */
- else if (*arg == '@')
+ else
{
- ++arg;
- if (*skipwhite(arg + 1) != '=')
- EMSG(_(e_letunexp));
- else
- write_reg_contents(*arg == '@' ? '"' : *arg,
- get_var_string(&retvar), -1, FALSE);
+ c1 = *name_end;
+ *name_end = NUL;
+ arg_len = (int)(name_end - arg);
}
+ i = find_vim_var(arg, arg_len);
+ if (i >= 0)
+ list_vim_var(i);
+ else if (STRCMP("b:changedtick", arg) == 0)
+ {
+ char_u numbuf[NUMBUFLEN];
- /*
- * ":let var = expr": Set internal variable.
- */
- else if (eval_isnamec(*arg) && !VIM_ISDIGIT(*arg))
+ sprintf((char *)numbuf, "%ld",
+ (long)curbuf->b_changedtick);
+ list_one_var_a((char_u *)"b:", (char_u *)"changedtick",
+ VAR_NUMBER, numbuf);
+ }
+ else
{
- /* Find the end of the name. */
- p = find_name_end(arg, &expr_start, &expr_end);
-
- if (*skipwhite(p) != '=')
- EMSG(_(e_letunexp));
- else if (p - arg == 13
- && STRNCMP(arg, "b:changedtick", 13) == 0)
- EMSG2(_(e_readonlyvar), arg);
-#ifdef FEAT_MAGIC_BRACES
- else if (expr_start != NULL)
+ varp = find_var(arg, FALSE);
+ if (varp == NULL)
{
- char_u *temp_string;
-
- temp_string = make_expanded_name(arg, expr_start,
- expr_end, p);
- if (temp_string == NULL)
- {
- /*
- * Report an invalid expression in braces, unless the
- * expression evaluation has been cancelled due to an
- * aborting error, an interrupt, or an exception.
- */
- if (!aborting())
- EMSG2(_(e_invarg2), arg);
- }
- else
- {
- set_var(temp_string, &retvar.tv, TRUE);
- vim_free(temp_string);
- }
+ /* Skip further arguments but do continue to
+ * search for a trailing command. */
+ EMSG2(_("E106: Unknown variable: \"%s\""), arg);
+ error = TRUE;
}
-#endif
else
{
- c1 = *p;
- *p = NUL;
- set_var(arg, &retvar.tv, TRUE);
- *p = c1; /* put char back for error messages */
+ name = vim_strchr(arg, ':');
+ if (name != NULL)
+ {
+ /* "a:" vars have no name stored, use whole arg */
+ if (arg[0] == 'a' && arg[1] == ':')
+ c2 = NUL;
+ else
+ {
+ c2 = *++name;
+ *name = NUL;
+ }
+ list_one_var(varp, arg);
+ if (c2 != NUL)
+ *name = c2;
+ }
+ else
+ list_one_var(varp, (char_u *)"");
}
}
+ if (expr_start != NULL)
+ vim_free(temp_string);
+ else
+ *name_end = c1;
+ }
+ arg = skipwhite(name_end);
+ }
+
+ return arg;
+}
+
+/*
+ * Set one item of ":let var = expr" or ":let [v1, v2] = list" to its value.
+ * Returns a pointer to the char just after the var name.
+ * Returns NULL if there is an error.
+ */
+ static char_u *
+ex_let_one(arg, tv, copy, endchars)
+ char_u *arg; /* points to variable name */
+ typeval *tv; /* value to assign to variable */
+ int copy; /* copy value from "tv" */
+ char_u *endchars; /* valid chars after variable name */
+{
+ int c1;
+ char_u *name;
+ char_u *p;
+ char_u *arg_end = NULL;
+ int len;
+ int opt_flags;
+ /*
+ * ":let $VAR = expr": Set environment variable.
+ */
+ if (*arg == '$')
+ {
+ /* Find the end of the name. */
+ ++arg;
+ name = arg;
+ len = get_env_len(&arg);
+ if (len == 0)
+ EMSG2(_(e_invarg2), name - 1);
+ else
+ {
+ if (vim_strchr(endchars, *skipwhite(arg)) == NULL)
+ EMSG(_(e_letunexp));
else
{
- EMSG2(_(e_invarg2), arg);
+ c1 = name[len];
+ name[len] = NUL;
+ p = get_tv_string(tv);
+ vim_setenv(name, p);
+ if (STRICMP(name, "HOME") == 0)
+ init_homedir();
+ else if (didset_vim && STRICMP(name, "VIM") == 0)
+ didset_vim = FALSE;
+ else if (didset_vimruntime && STRICMP(name, "VIMRUNTIME") == 0)
+ didset_vimruntime = FALSE;
+ name[len] = c1;
+ arg_end = arg;
}
+ }
+ }
- clear_vartv(&retvar.tv);
+ /*
+ * ":let &option = expr": Set option value.
+ * ":let &l:option = expr": Set local option value.
+ * ":let &g:option = expr": Set global option value.
+ */
+ else if (*arg == '&')
+ {
+ /* Find the end of the name. */
+ p = find_option_end(&arg, &opt_flags);
+ if (p == NULL || vim_strchr(endchars, *skipwhite(p)) == NULL)
+ EMSG(_(e_letunexp));
+ else
+ {
+ c1 = *p;
+ *p = NUL;
+ set_option_value(arg, get_tv_number(tv),
+ get_tv_string(tv), opt_flags);
+ *p = c1;
+ arg_end = p;
}
}
+
+ /*
+ * ":let @r = expr": Set register contents.
+ */
+ else if (*arg == '@')
+ {
+ ++arg;
+ if (vim_strchr(endchars, *skipwhite(arg + 1)) == NULL)
+ EMSG(_(e_letunexp));
+ else
+ {
+ write_reg_contents(*arg == '@' ? '"' : *arg,
+ get_tv_string(tv), -1, FALSE);
+ arg_end = arg + 1;
+ }
+ }
+
+ /*
+ * ":let var = expr": Set internal variable.
+ */
+ else if (eval_isnamec(*arg) && !VIM_ISDIGIT(*arg))
+ {
+ char_u *exp_name = NULL;
+ char_u *expr_start, *expr_end;
+
+ /* Find the end of the name. */
+ p = find_name_end(arg, &expr_start, &expr_end, FALSE);
+ if (expr_start != NULL)
+ {
+ exp_name = make_expanded_name(arg, expr_start, expr_end, p);
+ arg = exp_name;
+ }
+
+ if (arg == NULL)
+ {
+ /* Report an invalid expression in braces, unless the
+ * expression evaluation has been cancelled due to an
+ * aborting error, an interrupt, or an exception. */
+ if (!aborting())
+ EMSG2(_(e_invarg2), arg);
+ }
+ else if (*p == '[')
+ arg_end = set_var_idx(arg, p, tv, copy, endchars);
+ else if (vim_strchr(endchars, *skipwhite(p)) == NULL)
+ EMSG(_(e_letunexp));
+ else if (STRNCMP(arg, "b:changedtick", 13) == 0
+ && !eval_isnamec(arg[13]))
+ EMSG2(_(e_readonlyvar), arg);
+ else
+ {
+ c1 = *p;
+ *p = NUL;
+ set_var(arg, tv, copy);
+ *p = c1;
+ arg_end = p;
+ }
+
+ vim_free(exp_name);
+ }
+
+ else
+ EMSG2(_(e_invarg2), arg);
+
+ return arg_end;
+}
+
+/*
+ * Set a variable with an index: "name[expr]", "name[expr][expr]", etc.
+ * Only works if "name" is an existing List.
+ * "ip" points to the first '['.
+ * Returns a pointer to just after the last used ']'; NULL for error.
+ */
+ static char_u *
+set_var_idx(name, ip, rettv, copy, endchars)
+ char_u *name;
+ char_u *ip;
+ typeval *rettv;
+ int copy;
+ char_u *endchars;
+{
+ VAR v;
+ int c1;
+ char_u *p;
+ typeval var1;
+ typeval *tv;
+ long n;
+ listitem *item;
+
+ c1 = *ip;
+ *ip = NUL;
+ v = find_var(name, TRUE);
+ if (v == NULL)
+ EMSG2(_(e_undefvar), name);
+ *ip = c1;
+ if (v == NULL)
+ return NULL;
+
+ tv = &v->tv;
+ for (p = ip; *p == '['; p = skipwhite(p + 1))
+ {
+ if (tv->v_type != VAR_LIST || tv->vval.v_list == NULL)
+ {
+ EMSG(_("E999: Can only index a List"));
+ p = NULL;
+ break;
+ }
+ p = skipwhite(p + 1);
+ if (eval1(&p, &var1, TRUE) == FAIL) /* recursive! */
+ {
+ p = NULL;
+ break;
+ }
+ if (*p != ']')
+ {
+ EMSG(_(e_missbrac));
+ clear_tv(&var1);
+ p = NULL;
+ break;
+ }
+ n = get_tv_number(&var1);
+ clear_tv(&var1);
+ item = list_find(tv->vval.v_list, n);
+ if (item == NULL)
+ {
+ EMSGN(_(e_listidx), n);
+ p = NULL;
+ break;
+ }
+ tv = &item->li_tv;
+ }
+
+ if (p != NULL)
+ {
+ if (vim_strchr(endchars, *p) == NULL)
+ {
+ EMSG(_(e_letunexp));
+ p = NULL;
+ }
+ else
+ {
+ clear_tv(tv);
+ if (copy)
+ copy_tv(tv, rettv);
+ else
+ {
+ *tv = *rettv;
+ init_tv(rettv);
+ }
+ }
+ }
+ return p;
}
#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
@@ -1405,7 +1623,7 @@ ex_call(eap)
char_u *startarg;
char_u *alias;
char_u *name;
- var retvar;
+ typeval rettv;
int len;
linenr_T lnum;
int doesrange;
@@ -1419,7 +1637,7 @@ ex_call(eap)
name = alias;
startarg = arg;
- retvar.tv.v_type = VAR_UNKNOWN; /* clear_vartv() uses this */
+ rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */
if (*startarg != '(')
{
@@ -1448,18 +1666,18 @@ ex_call(eap)
curwin->w_cursor.col = 0;
}
arg = startarg;
- if (get_func_vartv(name, len, &retvar.tv, &arg,
+ if (get_func_tv(name, len, &rettv, &arg,
eap->line1, eap->line2, &doesrange, !eap->skip) == FAIL)
{
failed = TRUE;
break;
}
- clear_vartv(&retvar.tv);
+ clear_tv(&rettv);
if (doesrange || eap->skip)
break;
/* Stop when immediately aborting on error, or when an interrupt
* occurred or an exception was thrown but not caught.
- * get_func_vartv() returned OK, so that the check for trailing
+ * get_func_tv() returned OK, so that the check for trailing
* characters below is executed. */
if (aborting())
break;
@@ -1501,7 +1719,7 @@ ex_unlet(eap)
do
{
/* Find the end of the name. */
- name_end = find_name_end(arg, &expr_start, &expr_end);
+ name_end = find_name_end(arg, &expr_start, &expr_end, FALSE);
if (!vim_iswhite(*name_end) && !ends_excmd(*name_end))
{
@@ -1512,7 +1730,6 @@ ex_unlet(eap)
if (!error && !eap->skip)
{
-#ifdef FEAT_MAGIC_BRACES
if (expr_start != NULL)
{
char_u *temp_string;
@@ -1545,7 +1762,6 @@ ex_unlet(eap)
}
}
else
-#endif
{
cc = *name_end;
*name_end = NUL;
@@ -1722,19 +1938,20 @@ typedef enum
/*
* The "evaluate" argument: When FALSE, the argument is only parsed but not
- * executed. The function may return OK, but the retvar will be of type
+ * executed. The function may return OK, but the rettv will be of type
* VAR_UNKNOWN. The function still returns FAIL for a syntax error.
*/
/*
* Handle zero level expression.
* This calls eval1() and handles error message and nextcmd.
+ * Put the result in "rettv" when returning OK and "evaluate" is TRUE.
* Return OK or FAIL.
*/
static int
-eval0(arg, retvar, nextcmd, evaluate)
+eval0(arg, rettv, nextcmd, evaluate)
char_u *arg;
- VAR retvar;
+ typeval *rettv;
char_u **nextcmd;
int evaluate;
{
@@ -1742,11 +1959,11 @@ eval0(arg, retvar, nextcmd, evaluate)
char_u *p;
p = skipwhite(arg);
- ret = eval1(&p, &retvar->tv, evaluate);
+ ret = eval1(&p, rettv, evaluate);
if (ret == FAIL || !ends_excmd(*p))
{
if (ret != FAIL)
- clear_vartv(&retvar->tv);
+ clear_tv(rettv);
/*
* Report the invalid expression unless the expression evaluation has
* been cancelled due to an aborting error, an interrupt, or an
@@ -1772,9 +1989,9 @@ eval0(arg, retvar, nextcmd, evaluate)
* Return OK or FAIL.
*/
static int
-eval1(arg, retvar, evaluate)
+eval1(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
int result;
@@ -1783,7 +2000,7 @@ eval1(arg, retvar, evaluate)
/*
* Get the first variable.
*/
- if (eval2(arg, retvar, evaluate) == FAIL)
+ if (eval2(arg, rettv, evaluate) == FAIL)
return FAIL;
if ((*arg)[0] == '?')
@@ -1791,16 +2008,16 @@ eval1(arg, retvar, evaluate)
result = FALSE;
if (evaluate)
{
- if (get_vartv_number(retvar) != 0)
+ if (get_tv_number(rettv) != 0)
result = TRUE;
- clear_vartv(retvar);
+ clear_tv(rettv);
}
/*
* Get the second variable.
*/
*arg = skipwhite(*arg + 1);
- if (eval1(arg, retvar, evaluate && result) == FAIL) /* recursive! */
+ if (eval1(arg, rettv, evaluate && result) == FAIL) /* recursive! */
return FAIL;
/*
@@ -1810,7 +2027,7 @@ eval1(arg, retvar, evaluate)
{
EMSG(_("E109: Missing ':' after '?'"));
if (evaluate && result)
- clear_vartv(retvar);
+ clear_tv(rettv);
return FAIL;
}
@@ -1821,11 +2038,11 @@ eval1(arg, retvar, evaluate)
if (eval1(arg, &var2, evaluate && !result) == FAIL) /* recursive! */
{
if (evaluate && result)
- clear_vartv(retvar);
+ clear_tv(rettv);
return FAIL;
}
if (evaluate && !result)
- *retvar = var2;
+ *rettv = var2;
}
return OK;
@@ -1841,9 +2058,9 @@ eval1(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-eval2(arg, retvar, evaluate)
+eval2(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
typeval var2;
@@ -1853,7 +2070,7 @@ eval2(arg, retvar, evaluate)
/*
* Get the first variable.
*/
- if (eval3(arg, retvar, evaluate) == FAIL)
+ if (eval3(arg, rettv, evaluate) == FAIL)
return FAIL;
/*
@@ -1865,9 +2082,9 @@ eval2(arg, retvar, evaluate)
{
if (evaluate && first)
{
- if (get_vartv_number(retvar) != 0)
+ if (get_tv_number(rettv) != 0)
result = TRUE;
- clear_vartv(retvar);
+ clear_tv(rettv);
first = FALSE;
}
@@ -1883,14 +2100,14 @@ eval2(arg, retvar, evaluate)
*/
if (evaluate && !result)
{
- if (get_vartv_number(&var2) != 0)
+ if (get_tv_number(&var2) != 0)
result = TRUE;
- clear_vartv(&var2);
+ clear_tv(&var2);
}
if (evaluate)
{
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = result;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = result;
}
}
@@ -1907,9 +2124,9 @@ eval2(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-eval3(arg, retvar, evaluate)
+eval3(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
typeval var2;
@@ -1919,7 +2136,7 @@ eval3(arg, retvar, evaluate)
/*
* Get the first variable.
*/
- if (eval4(arg, retvar, evaluate) == FAIL)
+ if (eval4(arg, rettv, evaluate) == FAIL)
return FAIL;
/*
@@ -1931,9 +2148,9 @@ eval3(arg, retvar, evaluate)
{
if (evaluate && first)
{
- if (get_vartv_number(retvar) == 0)
+ if (get_tv_number(rettv) == 0)
result = FALSE;
- clear_vartv(retvar);
+ clear_tv(rettv);
first = FALSE;
}
@@ -1949,14 +2166,14 @@ eval3(arg, retvar, evaluate)
*/
if (evaluate && result)
{
- if (get_vartv_number(&var2) == 0)
+ if (get_tv_number(&var2) == 0)
result = FALSE;
- clear_vartv(&var2);
+ clear_tv(&var2);
}
if (evaluate)
{
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = result;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = result;
}
}
@@ -1980,9 +2197,9 @@ eval3(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-eval4(arg, retvar, evaluate)
+eval4(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
typeval var2;
@@ -2000,7 +2217,7 @@ eval4(arg, retvar, evaluate)
/*
* Get the first variable.
*/
- if (eval5(arg, retvar, evaluate) == FAIL)
+ if (eval5(arg, rettv, evaluate) == FAIL)
return FAIL;
p = *arg;
@@ -2061,7 +2278,7 @@ eval4(arg, retvar, evaluate)
*arg = skipwhite(p + len);
if (eval5(arg, &var2, evaluate) == FAIL)
{
- clear_vartv(retvar);
+ clear_tv(rettv);
return FAIL;
}
@@ -2071,11 +2288,11 @@ eval4(arg, retvar, evaluate)
* If one of the two variables is a number, compare as a number.
* When using "=~" or "!~", always compare as string.
*/
- if ((retvar->v_type == VAR_NUMBER || var2.v_type == VAR_NUMBER)
+ if ((rettv->v_type == VAR_NUMBER || var2.v_type == VAR_NUMBER)
&& type != TYPE_MATCH && type != TYPE_NOMATCH)
{
- n1 = get_vartv_number(retvar);
- n2 = get_vartv_number(&var2);
+ n1 = get_tv_number(rettv);
+ n2 = get_tv_number(&var2);
switch (type)
{
case TYPE_EQUAL: n1 = (n1 == n2); break;
@@ -2091,8 +2308,8 @@ eval4(arg, retvar, evaluate)
}
else
{
- s1 = get_vartv_string_buf(retvar, buf1);
- s2 = get_vartv_string_buf(&var2, buf2);
+ s1 = get_tv_string_buf(rettv, buf1);
+ s2 = get_tv_string_buf(&var2, buf2);
if (type != TYPE_MATCH && type != TYPE_NOMATCH)
i = ic ? MB_STRICMP(s1, s2) : STRCMP(s1, s2);
else
@@ -2128,10 +2345,10 @@ eval4(arg, retvar, evaluate)
case TYPE_UNKNOWN: break; /* avoid gcc warning */
}
}
- clear_vartv(retvar);
- clear_vartv(&var2);
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = n1;
+ clear_tv(rettv);
+ clear_tv(&var2);
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = n1;
}
}
@@ -2150,9 +2367,9 @@ eval4(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-eval5(arg, retvar, evaluate)
+eval5(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
typeval var2;
@@ -2165,7 +2382,7 @@ eval5(arg, retvar, evaluate)
/*
* Get the first variable.
*/
- if (eval6(arg, retvar, evaluate) == FAIL)
+ if (eval6(arg, rettv, evaluate) == FAIL)
return FAIL;
/*
@@ -2183,7 +2400,7 @@ eval5(arg, retvar, evaluate)
*arg = skipwhite(*arg + 1);
if (eval6(arg, &var2, evaluate) == FAIL)
{
- clear_vartv(retvar);
+ clear_tv(rettv);
return FAIL;
}
@@ -2194,8 +2411,8 @@ eval5(arg, retvar, evaluate)
*/
if (op == '.')
{
- s1 = get_vartv_string_buf(retvar, buf1);
- s2 = get_vartv_string_buf(&var2, buf2);
+ s1 = get_tv_string_buf(rettv, buf1);
+ s2 = get_tv_string_buf(&var2, buf2);
op = (int)STRLEN(s1);
p = alloc((unsigned)(op + STRLEN(s2) + 1));
if (p != NULL)
@@ -2203,23 +2420,23 @@ eval5(arg, retvar, evaluate)
STRCPY(p, s1);
STRCPY(p + op, s2);
}
- clear_vartv(retvar);
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = p;
+ clear_tv(rettv);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = p;
}
else
{
- n1 = get_vartv_number(retvar);
- n2 = get_vartv_number(&var2);
- clear_vartv(retvar);
+ n1 = get_tv_number(rettv);
+ n2 = get_tv_number(&var2);
+ clear_tv(rettv);
if (op == '+')
n1 = n1 + n2;
else
n1 = n1 - n2;
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = n1;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = n1;
}
- clear_vartv(&var2);
+ clear_tv(&var2);
}
}
return OK;
@@ -2237,9 +2454,9 @@ eval5(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-eval6(arg, retvar, evaluate)
+eval6(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
typeval var2;
@@ -2249,7 +2466,7 @@ eval6(arg, retvar, evaluate)
/*
* Get the first variable.
*/
- if (eval7(arg, retvar, evaluate) == FAIL)
+ if (eval7(arg, rettv, evaluate) == FAIL)
return FAIL;
/*
@@ -2263,8 +2480,8 @@ eval6(arg, retvar, evaluate)
if (evaluate)
{
- n1 = get_vartv_number(retvar);
- clear_vartv(retvar);
+ n1 = get_tv_number(rettv);
+ clear_tv(rettv);
}
else
n1 = 0;
@@ -2278,8 +2495,8 @@ eval6(arg, retvar, evaluate)
if (evaluate)
{
- n2 = get_vartv_number(&var2);
- clear_vartv(&var2);
+ n2 = get_tv_number(&var2);
+ clear_tv(&var2);
/*
* Compute the result.
@@ -2300,8 +2517,8 @@ eval6(arg, retvar, evaluate)
else
n1 = n1 % n2;
}
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = n1;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = n1;
}
}
@@ -2332,9 +2549,9 @@ eval6(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-eval7(arg, retvar, evaluate)
+eval7(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
long n;
@@ -2346,10 +2563,10 @@ eval7(arg, retvar, evaluate)
char_u *alias;
/*
- * Initialise variable so that clear_vartv() can't mistake this for a
+ * Initialise variable so that clear_tv() can't mistake this for a
* string and free a string that isn't there.
*/
- retvar->v_type = VAR_UNKNOWN;
+ rettv->v_type = VAR_UNKNOWN;
/*
* Skip '!' and '-' characters. They are handled later.
@@ -2378,39 +2595,39 @@ eval7(arg, retvar, evaluate)
*arg += len;
if (evaluate)
{
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = n;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = n;
}
break;
/*
* String constant: "string".
*/
- case '"': ret = get_string_vartv(arg, retvar, evaluate);
+ case '"': ret = get_string_tv(arg, rettv, evaluate);
break;
/*
* Literal string constant: 'string'.
*/
- case '\'': ret = get_lit_string_vartv(arg, retvar, evaluate);
+ case '\'': ret = get_lit_string_tv(arg, rettv, evaluate);
break;
/*
* List: [expr, expr]
*/
- case '[': ret = get_list_vartv(arg, retvar, evaluate);
+ case '[': ret = get_list_tv(arg, rettv, evaluate);
break;
/*
* Option value: &name
*/
- case '&': ret = get_option_vartv(arg, retvar, evaluate);
+ case '&': ret = get_option_tv(arg, rettv, evaluate);
break;
/*
* Environment variable: $VAR.
*/
- case '$': ret = get_env_vartv(arg, retvar, evaluate);
+ case '$': ret = get_env_tv(arg, rettv, evaluate);
break;
/*
@@ -2419,8 +2636,8 @@ eval7(arg, retvar, evaluate)
case '@': ++*arg;
if (evaluate)
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = get_reg_contents(**arg, FALSE);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = get_reg_contents(**arg, FALSE);
}
if (**arg != NUL)
++*arg;
@@ -2430,13 +2647,13 @@ eval7(arg, retvar, evaluate)
* nested expression: (expression).
*/
case '(': *arg = skipwhite(*arg + 1);
- ret = eval1(arg, retvar, evaluate); /* recursive! */
+ ret = eval1(arg, rettv, evaluate); /* recursive! */
if (**arg == ')')
++*arg;
else if (ret == OK)
{
EMSG(_("E110: Missing ')'"));
- clear_vartv(retvar);
+ clear_tv(rettv);
ret = FAIL;
}
break;
@@ -2460,7 +2677,7 @@ eval7(arg, retvar, evaluate)
s = deref_func_name(s, &len);
/* Invoke the function. */
- ret = get_func_vartv(s, len, retvar, arg,
+ ret = get_func_tv(s, len, rettv, arg,
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
&len, evaluate);
/* Stop the expression evaluation when immediately
@@ -2469,12 +2686,12 @@ eval7(arg, retvar, evaluate)
if (aborting())
{
if (ret == OK)
- clear_vartv(retvar);
+ clear_tv(rettv);
ret = FAIL;
}
}
else if (evaluate)
- ret = get_var_vartv(s, len, retvar);
+ ret = get_var_tv(s, len, rettv);
}
if (alias != NULL)
@@ -2489,9 +2706,9 @@ eval7(arg, retvar, evaluate)
*/
while (**arg == '[' && ret == OK)
{
- if (eval_index(arg, retvar, evaluate) == FAIL)
+ if (eval_index(arg, rettv, evaluate) == FAIL)
{
- clear_vartv(retvar);
+ clear_tv(rettv);
return FAIL;
}
}
@@ -2501,7 +2718,7 @@ eval7(arg, retvar, evaluate)
*/
if (ret == OK && evaluate && end_leader > start_leader)
{
- val = get_vartv_number(retvar);
+ val = get_tv_number(rettv);
while (end_leader > start_leader)
{
--end_leader;
@@ -2510,9 +2727,9 @@ eval7(arg, retvar, evaluate)
else if (*end_leader == '-')
val = -val;
}
- clear_vartv(retvar);
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = val;
+ clear_tv(rettv);
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = val;
}
return ret;
@@ -2524,9 +2741,9 @@ eval7(arg, retvar, evaluate)
* Returns FAIL or OK. "*arg" is advanced to after the ']'.
*/
static int
-eval_index(arg, retvar, evaluate)
+eval_index(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
int empty1 = FALSE, empty2 = FALSE;
@@ -2536,7 +2753,7 @@ eval_index(arg, retvar, evaluate)
int range;
char_u *s;
- if (retvar->v_type == VAR_FUNC)
+ if (rettv->v_type == VAR_FUNC)
{
EMSG(_("E999: Cannot index a Funcref"));
return FAIL;
@@ -2562,7 +2779,7 @@ eval_index(arg, retvar, evaluate)
empty2 = TRUE;
else if (eval1(arg, &var2, evaluate) == FAIL) /* recursive! */
{
- clear_vartv(&var1);
+ clear_tv(&var1);
return FAIL;
}
}
@@ -2572,10 +2789,10 @@ eval_index(arg, retvar, evaluate)
/* Check for the ']'. */
if (**arg != ']')
{
- EMSG(_("E111: Missing ']'"));
- clear_vartv(&var1);
+ EMSG(_(e_missbrac));
+ clear_tv(&var1);
if (range)
- clear_vartv(&var2);
+ clear_tv(&var2);
return FAIL;
}
@@ -2585,8 +2802,8 @@ eval_index(arg, retvar, evaluate)
n1 = 0;
else
{
- n1 = get_vartv_number(&var1);
- clear_vartv(&var1);
+ n1 = get_tv_number(&var1);
+ clear_tv(&var1);
}
if (range)
{
@@ -2594,16 +2811,16 @@ eval_index(arg, retvar, evaluate)
n2 = -1;
else
{
- n2 = get_vartv_number(&var2);
- clear_vartv(&var2);
+ n2 = get_tv_number(&var2);
+ clear_tv(&var2);
}
}
- switch (retvar->v_type)
+ switch (rettv->v_type)
{
case VAR_NUMBER:
case VAR_STRING:
- s = get_vartv_string(retvar);
+ s = get_tv_string(rettv);
len = (long)STRLEN(s);
if (range)
{
@@ -2634,13 +2851,13 @@ eval_index(arg, retvar, evaluate)
else
s = vim_strnsave(s + n1, 1);
}
- clear_vartv(retvar);
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = s;
+ clear_tv(rettv);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = s;
break;
case VAR_LIST:
- len = list_len(retvar->vval.v_list);
+ len = list_len(rettv->vval.v_list);
if (n1 < 0)
n1 = len + n1;
if (!empty1 && (n1 < 0 || n1 >= len))
@@ -2663,7 +2880,7 @@ eval_index(arg, retvar, evaluate)
l = list_alloc();
if (l == NULL)
return FAIL;
- for (item = list_find(retvar->vval.v_list, n1);
+ for (item = list_find(rettv->vval.v_list, n1);
n1 <= n2; ++n1)
{
if (list_append_tv(l, &item->li_tv) == FAIL)
@@ -2673,16 +2890,16 @@ eval_index(arg, retvar, evaluate)
}
item = item->li_next;
}
- clear_vartv(retvar);
- retvar->v_type = VAR_LIST;
- retvar->vval.v_list = l;
+ clear_tv(rettv);
+ rettv->v_type = VAR_LIST;
+ rettv->vval.v_list = l;
}
else
{
- copy_vartv(&list_find(retvar->vval.v_list, n1)->li_tv,
+ copy_tv(&list_find(rettv->vval.v_list, n1)->li_tv,
&var1);
- clear_vartv(retvar);
- *retvar = var1;
+ clear_tv(rettv);
+ *rettv = var1;
}
break;
}
@@ -2699,9 +2916,9 @@ eval_index(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-get_option_vartv(arg, retvar, evaluate)
+get_option_tv(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar; /* when NULL, only check if option exists */
+ typeval *rettv; /* when NULL, only check if option exists */
int evaluate;
{
char_u *option_end;
@@ -2719,7 +2936,7 @@ get_option_vartv(arg, retvar, evaluate)
option_end = find_option_end(arg, &opt_flags);
if (option_end == NULL)
{
- if (retvar != NULL)
+ if (rettv != NULL)
EMSG2(_("E112: Option name missing: %s"), *arg);
return FAIL;
}
@@ -2733,35 +2950,35 @@ get_option_vartv(arg, retvar, evaluate)
c = *option_end;
*option_end = NUL;
opt_type = get_option_value(*arg, &numval,
- retvar == NULL ? NULL : &stringval, opt_flags);
+ rettv == NULL ? NULL : &stringval, opt_flags);
if (opt_type == -3) /* invalid name */
{
- if (retvar != NULL)
+ if (rettv != NULL)
EMSG2(_("E113: Unknown option: %s"), *arg);
ret = FAIL;
}
- else if (retvar != NULL)
+ else if (rettv != NULL)
{
if (opt_type == -2) /* hidden string option */
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
}
else if (opt_type == -1) /* hidden number option */
{
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = 0;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = 0;
}
else if (opt_type == 1) /* number option */
{
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = numval;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = numval;
}
else /* string option */
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = stringval;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = stringval;
}
}
else if (working && (opt_type == -2 || opt_type == -1))
@@ -2778,9 +2995,9 @@ get_option_vartv(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-get_string_vartv(arg, retvar, evaluate)
+get_string_tv(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
char_u *p;
@@ -2923,8 +3140,8 @@ get_string_vartv(arg, retvar, evaluate)
name[i] = NUL;
*arg = p + 1;
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = name;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = name;
return OK;
}
@@ -2934,9 +3151,9 @@ get_string_vartv(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-get_lit_string_vartv(arg, retvar, evaluate)
+get_lit_string_tv(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
char_u *p;
@@ -2961,8 +3178,8 @@ get_lit_string_vartv(arg, retvar, evaluate)
if (name == NULL)
return FAIL;
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = name;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = name;
}
*arg = p + 1;
@@ -2975,9 +3192,9 @@ get_lit_string_vartv(arg, retvar, evaluate)
* Return OK or FAIL.
*/
static int
-get_list_vartv(arg, retvar, evaluate)
+get_list_tv(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
listvar *l = NULL;
@@ -3028,8 +3245,8 @@ failret:
*arg = skipwhite(*arg + 1);
if (evaluate)
{
- retvar->v_type = VAR_LIST;
- retvar->vval.v_list = l;
+ rettv->v_type = VAR_LIST;
+ rettv->vval.v_list = l;
++l->lv_refcount;
}
@@ -3092,7 +3309,7 @@ listitem_alloc()
listitem_free(item)
listitem *item;
{
- clear_vartv(&item->li_tv);
+ clear_tv(&item->li_tv);
vim_free(item);
}
@@ -3181,7 +3398,7 @@ list_append_tv(l, tv)
if (ni == NULL)
return FAIL;
- copy_vartv(tv, &ni->li_tv);
+ copy_tv(tv, &ni->li_tv);
list_append(l, ni);
return OK;
}
@@ -3230,7 +3447,7 @@ list_copy(orig, deep)
}
}
else
- copy_vartv(&item->li_tv, &ni->li_tv);
+ copy_tv(&item->li_tv, &ni->li_tv);
list_append(copy, ni);
}
++copy->lv_refcount;
@@ -3323,11 +3540,14 @@ tv2string(tv, tofree)
case VAR_LIST:
*tofree = list2string(tv);
return *tofree;
- default:
+ case VAR_STRING:
+ case VAR_NUMBER:
break;
+ default:
+ EMSG2(_(e_intern2), "tv2string()");
}
*tofree = NULL;
- return get_vartv_string(tv);
+ return get_tv_string(tv);
}
/*
@@ -3337,9 +3557,9 @@ tv2string(tv, tofree)
* Always return OK.
*/
static int
-get_env_vartv(arg, retvar, evaluate)
+get_env_tv(arg, rettv, evaluate)
char_u **arg;
- typeval *retvar;
+ typeval *rettv;
int evaluate;
{
char_u *string = NULL;
@@ -3372,8 +3592,8 @@ get_env_vartv(arg, retvar, evaluate)
}
name[len] = cc;
}
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = string;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = string;
}
return OK;
@@ -3670,10 +3890,10 @@ deref_func_name(name, lenp)
* Return OK or FAIL.
*/
static int
-get_func_vartv(name, len, retvar, arg, firstline, lastline, doesrange, evaluate)
+get_func_tv(name, len, rettv, arg, firstline, lastline, doesrange, evaluate)
char_u *name; /* name of the function */
int len; /* length of "name" */
- typeval *retvar;
+ typeval *rettv;
char_u **arg; /* argument, pointing to the '(' */
linenr_T firstline; /* first line of range */
linenr_T lastline; /* last line of range */
@@ -3710,13 +3930,13 @@ get_func_vartv(name, len, retvar, arg, firstline, lastline, doesrange, evaluate)
ret = FAIL;
if (ret == OK)
- ret = call_func(name, len, retvar, argcount, argvars,
+ ret = call_func(name, len, rettv, argcount, argvars,
firstline, lastline, doesrange, evaluate);
else if (!aborting())
EMSG2(_("E116: Invalid arguments for function %s"), name);
while (--argcount >= 0)
- clear_vartv(&argvars[argcount]);
+ clear_tv(&argvars[argcount]);
*arg = skipwhite(argp);
return ret;
@@ -3728,11 +3948,11 @@ get_func_vartv(name, len, retvar, arg, firstline, lastline, doesrange, evaluate)
* Return OK or FAIL.
*/
static int
-call_func(name, len, retvar, argcount, argvars, firstline, lastline,
+call_func(name, len, rettv, argcount, argvars, firstline, lastline,
doesrange, evaluate)
char_u *name; /* name of the function */
int len; /* length of "name" */
- typeval *retvar; /* return value goes here */
+ typeval *rettv; /* return value goes here */
int argcount; /* number of "argvars" */
typeval *argvars; /* vars for arguments */
linenr_T firstline; /* first line of range */
@@ -3812,7 +4032,7 @@ call_func(name, len, retvar, argcount, argvars, firstline, lastline,
/* execute the function if no errors detected and executing */
if (evaluate && error == ERROR_NONE)
{
- retvar->v_type = VAR_NUMBER; /* default is number retvar */
+ rettv->v_type = VAR_NUMBER; /* default is number rettv */
error = ERROR_UNKNOWN;
if (!ASCII_ISLOWER(fname[0]))
@@ -3851,7 +4071,7 @@ call_func(name, len, retvar, argcount, argvars, firstline, lastline,
save_search_patterns();
saveRedobuff();
++fp->calls;
- call_user_func(fp, argcount, argvars, retvar,
+ call_user_func(fp, argcount, argvars, rettv,
firstline, lastline);
--fp->calls;
restoreRedobuff();
@@ -3875,7 +4095,7 @@ call_func(name, len, retvar, argcount, argvars, firstline, lastline,
else
{
argvars[argcount].v_type = VAR_UNKNOWN;
- functions[i].f_func(argvars, retvar);
+ functions[i].f_func(argvars, rettv);
error = ERROR_NONE;
}
}
@@ -3918,31 +4138,31 @@ call_func(name, len, retvar, argcount, argvars, firstline, lastline,
* or "append(list, item)" function
*/
static void
-f_append(argvars, retvar)
+f_append(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
long lnum;
- retvar->vval.v_number = 1; /* Default: Failed */
+ rettv->vval.v_number = 1; /* Default: Failed */
if (argvars[0].v_type == VAR_LIST)
{
if (argvars[0].vval.v_list != NULL
&& list_append_tv(argvars[0].vval.v_list, &argvars[1]) == OK)
- copy_vartv(&argvars[0], retvar);
+ copy_tv(&argvars[0], rettv);
}
else
{
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
if (lnum >= 0
&& lnum <= curbuf->b_ml.ml_line_count
&& u_save(lnum, lnum + 1) == OK)
{
- ml_append(lnum, get_vartv_string(&argvars[1]), (colnr_T)0, FALSE);
+ ml_append(lnum, get_tv_string(&argvars[1]), (colnr_T)0, FALSE);
if (curwin->w_cursor.lnum > lnum)
++curwin->w_cursor.lnum;
appended_lines_mark(lnum, 1L);
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
}
}
}
@@ -3952,11 +4172,11 @@ f_append(argvars, retvar)
*/
/* ARGSUSED */
static void
-f_argc(argvars, retvar)
+f_argc(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = ARGCOUNT;
+ rettv->vval.v_number = ARGCOUNT;
}
/*
@@ -3964,29 +4184,29 @@ f_argc(argvars, retvar)
*/
/* ARGSUSED */
static void
-f_argidx(argvars, retvar)
+f_argidx(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = curwin->w_arg_idx;
+ rettv->vval.v_number = curwin->w_arg_idx;
}
/*
* "argv(nr)" function
*/
static void
-f_argv(argvars, retvar)
+f_argv(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
int idx;
- idx = get_vartv_number(&argvars[0]);
+ idx = get_tv_number(&argvars[0]);
if (idx >= 0 && idx < ARGCOUNT)
- retvar->vval.v_string = vim_strsave(alist_name(&ARGLIST[idx]));
+ rettv->vval.v_string = vim_strsave(alist_name(&ARGLIST[idx]));
else
- retvar->vval.v_string = NULL;
- retvar->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
}
/*
@@ -3994,9 +4214,9 @@ f_argv(argvars, retvar)
*/
/* ARGSUSED */
static void
-f_browse(argvars, retvar)
+f_browse(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_BROWSE
int save;
@@ -4006,18 +4226,18 @@ f_browse(argvars, retvar)
char_u buf[NUMBUFLEN];
char_u buf2[NUMBUFLEN];
- save = get_vartv_number(&argvars[0]);
- title = get_vartv_string(&argvars[1]);
- initdir = get_vartv_string_buf(&argvars[2], buf);
- defname = get_vartv_string_buf(&argvars[3], buf2);
+ save = get_tv_number(&argvars[0]);
+ title = get_tv_string(&argvars[1]);
+ initdir = get_tv_string_buf(&argvars[2], buf);
+ defname = get_tv_string_buf(&argvars[3], buf2);
- retvar->vval.v_string =
+ rettv->vval.v_string =
do_browse(save ? BROWSE_SAVE : 0,
title, defname, NULL, initdir, NULL, curbuf);
#else
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
#endif
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
}
/*
@@ -4025,24 +4245,24 @@ f_browse(argvars, retvar)
*/
/* ARGSUSED */
static void
-f_browsedir(argvars, retvar)
+f_browsedir(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_BROWSE
char_u *title;
char_u *initdir;
char_u buf[NUMBUFLEN];
- title = get_vartv_string(&argvars[0]);
- initdir = get_vartv_string_buf(&argvars[1], buf);
+ title = get_tv_string(&argvars[0]);
+ initdir = get_tv_string_buf(&argvars[1], buf);
- retvar->vval.v_string = do_browse(BROWSE_DIR,
+ rettv->vval.v_string = do_browse(BROWSE_DIR,
title, NULL, NULL, initdir, NULL, curbuf);
#else
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
#endif
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
}
/*
@@ -4081,55 +4301,55 @@ find_buffer(avar)
* "bufexists(expr)" function
*/
static void
-f_bufexists(argvars, retvar)
+f_bufexists(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = (find_buffer(&argvars[0]) != NULL);
+ rettv->vval.v_number = (find_buffer(&argvars[0]) != NULL);
}
/*
* "buflisted(expr)" function
*/
static void
-f_buflisted(argvars, retvar)
+f_buflisted(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
buf_T *buf;
buf = find_buffer(&argvars[0]);
- retvar->vval.v_number = (buf != NULL && buf->b_p_bl);
+ rettv->vval.v_number = (buf != NULL && buf->b_p_bl);
}
/*
* "bufloaded(expr)" function
*/
static void
-f_bufloaded(argvars, retvar)
+f_bufloaded(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
buf_T *buf;
buf = find_buffer(&argvars[0]);
- retvar->vval.v_number = (buf != NULL && buf->b_ml.ml_mfp != NULL);
+ rettv->vval.v_number = (buf != NULL && buf->b_ml.ml_mfp != NULL);
}
/*
* Get buffer by number or pattern.
*/
static buf_T *
-get_buf_vartv(avar)
- typeval *avar;
+get_buf_tv(tv)
+ typeval *tv;
{
- char_u *name = avar->vval.v_string;
+ char_u *name = tv->vval.v_string;
int save_magic;
char_u *save_cpo;
buf_T *buf;
- if (avar->v_type == VAR_NUMBER)
- return buflist_findnr((int)avar->vval.v_number);
+ if (tv->v_type == VAR_NUMBER)
+ return buflist_findnr((int)tv->vval.v_number);
if (name == NULL || *name == NUL)
return curbuf;
if (name[0] == '$' && name[1] == NUL)
@@ -4149,7 +4369,7 @@ get_buf_vartv(avar)
/* If not found, try expanding the name, like done for bufexists(). */
if (buf == NULL)
- buf = find_buffer(avar);
+ buf = find_buffer(tv);
return buf;
}
@@ -4158,19 +4378,19 @@ get_buf_vartv(avar)
* "bufname(expr)" function
*/
static void
-f_bufname(argvars, retvar)
+f_bufname(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
buf_T *buf;
++emsg_off;
- buf = get_buf_vartv(&argvars[0]);
- retvar->v_type = VAR_STRING;
+ buf = get_buf_tv(&argvars[0]);
+ rettv->v_type = VAR_STRING;
if (buf != NULL && buf->b_fname != NULL)
- retvar->vval.v_string = vim_strsave(buf->b_fname);
+ rettv->vval.v_string = vim_strsave(buf->b_fname);
else
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
--emsg_off;
}
@@ -4178,18 +4398,18 @@ f_bufname(argvars, retvar)
* "bufnr(expr)" function
*/
static void
-f_bufnr(argvars, retvar)
+f_bufnr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
buf_T *buf;
++emsg_off;
- buf = get_buf_vartv(&argvars[0]);
+ buf = get_buf_tv(&argvars[0]);
if (buf != NULL)
- retvar->vval.v_number = buf->b_fnum;
+ rettv->vval.v_number = buf->b_fnum;
else
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
--emsg_off;
}
@@ -4197,9 +4417,9 @@ f_bufnr(argvars, retvar)
* "bufwinnr(nr)" function
*/
static void
-f_bufwinnr(argvars, retvar)
+f_bufwinnr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_WINDOWS
win_T *wp;
@@ -4208,7 +4428,7 @@ f_bufwinnr(argvars, retvar)
buf_T *buf;
++emsg_off;
- buf = get_buf_vartv(&argvars[0]);
+ buf = get_buf_tv(&argvars[0]);
#ifdef FEAT_WINDOWS
for (wp = firstwin; wp; wp = wp->w_next)
{
@@ -4216,9 +4436,9 @@ f_bufwinnr(argvars, retvar)
if (wp->w_buffer == buf)
break;
}
- retvar->vval.v_number = (wp != NULL ? winnr : -1);
+ rettv->vval.v_number = (wp != NULL ? winnr : -1);
#else
- retvar->vval.v_number = (curwin->w_buffer == buf ? 1 : -1);
+ rettv->vval.v_number = (curwin->w_buffer == buf ? 1 : -1);
#endif
--emsg_off;
}
@@ -4228,20 +4448,20 @@ f_bufwinnr(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_byte2line(argvars, retvar)
+f_byte2line(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifndef FEAT_BYTEOFF
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
#else
long boff = 0;
- boff = get_vartv_number(&argvars[0]) - 1;
+ boff = get_tv_number(&argvars[0]) - 1;
if (boff < 0)
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
- retvar->vval.v_number = ml_find_line_or_offset(curbuf,
+ rettv->vval.v_number = ml_find_line_or_offset(curbuf,
(linenr_T)0, &boff);
#endif
}
@@ -4251,9 +4471,9 @@ f_byte2line(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_byteidx(argvars, retvar)
+f_byteidx(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_MBYTE
char_u *t;
@@ -4261,9 +4481,9 @@ f_byteidx(argvars, retvar)
char_u *str;
long idx;
- str = get_vartv_string(&argvars[0]);
- idx = get_vartv_number(&argvars[1]);
- retvar->vval.v_number = -1;
+ str = get_tv_string(&argvars[0]);
+ idx = get_tv_number(&argvars[1]);
+ rettv->vval.v_number = -1;
if (idx < 0)
return;
@@ -4275,10 +4495,10 @@ f_byteidx(argvars, retvar)
return;
t += mb_ptr2len_check(t);
}
- retvar->vval.v_number = t - str;
+ rettv->vval.v_number = t - str;
#else
if (idx <= STRLEN(str))
- retvar->vval.v_number = idx;
+ rettv->vval.v_number = idx;
#endif
}
@@ -4286,51 +4506,51 @@ f_byteidx(argvars, retvar)
* "char2nr(string)" function
*/
static void
-f_char2nr(argvars, retvar)
+f_char2nr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- retvar->vval.v_number =
- (*mb_ptr2char)(get_vartv_string(&argvars[0]));
+ rettv->vval.v_number =
+ (*mb_ptr2char)(get_tv_string(&argvars[0]));
else
#endif
- retvar->vval.v_number = get_vartv_string(&argvars[0])[0];
+ rettv->vval.v_number = get_tv_string(&argvars[0])[0];
}
/*
* "cindent(lnum)" function
*/
static void
-f_cindent(argvars, retvar)
+f_cindent(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_CINDENT
pos_T pos;
linenr_T lnum;
pos = curwin->w_cursor;
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
{
curwin->w_cursor.lnum = lnum;
- retvar->vval.v_number = get_c_indent();
+ rettv->vval.v_number = get_c_indent();
curwin->w_cursor = pos;
}
else
#endif
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
}
/*
* "col(string)" function
*/
static void
-f_col(argvars, retvar)
+f_col(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
colnr_T col = 0;
pos_T *fp;
@@ -4373,7 +4593,7 @@ f_col(argvars, retvar)
#endif
}
}
- retvar->vval.v_number = col;
+ rettv->vval.v_number = col;
}
/*
@@ -4381,9 +4601,9 @@ f_col(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_confirm(argvars, retvar)
+f_confirm(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
char_u *message;
@@ -4394,17 +4614,17 @@ f_confirm(argvars, retvar)
int type = VIM_GENERIC;
int c;
- message = get_vartv_string(&argvars[0]);
+ message = get_tv_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
{
- buttons = get_vartv_string_buf(&argvars[1], buf);
+ buttons = get_tv_string_buf(&argvars[1], buf);
if (argvars[2].v_type != VAR_UNKNOWN)
{
- def = get_vartv_number(&argvars[2]);
+ def = get_tv_number(&argvars[2]);
if (argvars[3].v_type != VAR_UNKNOWN)
{
/* avoid that TOUPPER_ASC calls get_var_string_buf() twice */
- c = *get_vartv_string_buf(&argvars[3], buf2);
+ c = *get_tv_string_buf(&argvars[3], buf2);
switch (TOUPPER_ASC(c))
{
case 'E': type = VIM_ERROR; break;
@@ -4420,10 +4640,10 @@ f_confirm(argvars, retvar)
if (buttons == NULL || *buttons == NUL)
buttons = (char_u *)_("&Ok");
- retvar->vval.v_number = do_dialog(type, NULL, message, buttons,
+ rettv->vval.v_number = do_dialog(type, NULL, message, buttons,
def, NULL);
#else
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
#endif
}
@@ -4431,17 +4651,17 @@ f_confirm(argvars, retvar)
* "copy()" function
*/
static void
-f_copy(argvars, retvar)
+f_copy(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
if (argvars[0].v_type == VAR_LIST)
{
- retvar->v_type = VAR_LIST;
- retvar->vval.v_list = list_copy(argvars[0].vval.v_list, FALSE);
+ rettv->v_type = VAR_LIST;
+ rettv->vval.v_list = list_copy(argvars[0].vval.v_list, FALSE);
}
else
- copy_vartv(&argvars[0], retvar);
+ copy_tv(&argvars[0], rettv);
}
/*
@@ -4451,9 +4671,9 @@ f_copy(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_cscope_connection(argvars, retvar)
+f_cscope_connection(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_CSCOPE
int num = 0;
@@ -4464,15 +4684,15 @@ f_cscope_connection(argvars, retvar)
if (argvars[0].v_type != VAR_UNKNOWN
&& argvars[1].v_type != VAR_UNKNOWN)
{
- num = (int)get_vartv_number(&argvars[0]);
- dbpath = get_vartv_string(&argvars[1]);
+ num = (int)get_tv_number(&argvars[0]);
+ dbpath = get_tv_string(&argvars[1]);
if (argvars[2].v_type != VAR_UNKNOWN)
- prepend = get_vartv_string_buf(&argvars[2], buf);
+ prepend = get_tv_string_buf(&argvars[2], buf);
}
- retvar->vval.v_number = cs_connection(num, dbpath, prepend);
+ rettv->vval.v_number = cs_connection(num, dbpath, prepend);
#else
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
#endif
}
@@ -4483,16 +4703,16 @@ f_cscope_connection(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_cursor(argvars, retvar)
+f_cursor(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
long line, col;
- line = get_vartv_lnum(argvars);
+ line = get_tv_lnum(argvars);
if (line > 0)
curwin->w_cursor.lnum = line;
- col = get_vartv_number(&argvars[1]);
+ col = get_tv_number(&argvars[1]);
if (col > 0)
curwin->w_cursor.col = col - 1;
#ifdef FEAT_VIRTUALEDIT
@@ -4514,31 +4734,31 @@ f_cursor(argvars, retvar)
* "deepcopy()" function
*/
static void
-f_deepcopy(argvars, retvar)
+f_deepcopy(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
if (argvars[0].v_type == VAR_LIST)
{
- retvar->v_type = VAR_LIST;
- retvar->vval.v_list = list_copy(argvars[0].vval.v_list, TRUE);
+ rettv->v_type = VAR_LIST;
+ rettv->vval.v_list = list_copy(argvars[0].vval.v_list, TRUE);
}
else
- copy_vartv(&argvars[0], retvar);
+ copy_tv(&argvars[0], rettv);
}
/*
* "delete()" function
*/
static void
-f_delete(argvars, retvar)
+f_delete(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
if (check_restricted() || check_secure())
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
- retvar->vval.v_number = mch_remove(get_vartv_string(&argvars[0]));
+ rettv->vval.v_number = mch_remove(get_tv_string(&argvars[0]));
}
/*
@@ -4546,14 +4766,14 @@ f_delete(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_did_filetype(argvars, retvar)
+f_did_filetype(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_AUTOCMD
- retvar->vval.v_number = did_filetype;
+ rettv->vval.v_number = did_filetype;
#else
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
#endif
}
@@ -4562,12 +4782,12 @@ f_did_filetype(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_diff_filler(argvars, retvar)
+f_diff_filler(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_DIFF
- retvar->vval.v_number = diff_check_fill(curwin, get_vartv_lnum(argvars));
+ rettv->vval.v_number = diff_check_fill(curwin, get_tv_lnum(argvars));
#endif
}
@@ -4576,12 +4796,12 @@ f_diff_filler(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_diff_hlID(argvars, retvar)
+f_diff_hlID(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_DIFF
- linenr_T lnum = get_vartv_lnum(argvars);
+ linenr_T lnum = get_tv_lnum(argvars);
static linenr_T prev_lnum = 0;
static int changedtick = 0;
static int fnum = 0;
@@ -4620,13 +4840,13 @@ f_diff_hlID(argvars, retvar)
if (hlID == HLF_CHD || hlID == HLF_TXD)
{
- col = get_vartv_number(&argvars[1]) - 1;
+ col = get_tv_number(&argvars[1]) - 1;
if (col >= change_start && col <= change_end)
hlID = HLF_TXD; /* changed text */
else
hlID = HLF_CHD; /* changed line */
}
- retvar->vval.v_number = hlID == (enum hlf_value)0 ? 0 : (int)hlID;
+ rettv->vval.v_number = hlID == (enum hlf_value)0 ? 0 : (int)hlID;
#endif
}
@@ -4634,16 +4854,16 @@ f_diff_hlID(argvars, retvar)
* "escape({string}, {chars})" function
*/
static void
-f_escape(argvars, retvar)
+f_escape(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u buf[NUMBUFLEN];
- retvar->vval.v_string =
- vim_strsave_escaped(get_vartv_string(&argvars[0]),
- get_vartv_string_buf(&argvars[1], buf));
- retvar->v_type = VAR_STRING;
+ rettv->vval.v_string =
+ vim_strsave_escaped(get_tv_string(&argvars[0]),
+ get_tv_string_buf(&argvars[1], buf));
+ rettv->v_type = VAR_STRING;
}
/*
@@ -4651,38 +4871,38 @@ f_escape(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_eventhandler(argvars, retvar)
+f_eventhandler(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = vgetc_busy;
+ rettv->vval.v_number = vgetc_busy;
}
/*
* "executable()" function
*/
static void
-f_executable(argvars, retvar)
+f_executable(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = mch_can_exe(get_vartv_string(&argvars[0]));
+ rettv->vval.v_number = mch_can_exe(get_tv_string(&argvars[0]));
}
/*
* "exists()" function
*/
static void
-f_exists(argvars, retvar)
+f_exists(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *p;
char_u *name;
int n = FALSE;
int len = 0;
- p = get_vartv_string(&argvars[0]);
+ p = get_tv_string(&argvars[0]);
if (*p == '$') /* environment variable */
{
/* first try "normal" environment variables (fast) */
@@ -4698,7 +4918,7 @@ f_exists(argvars, retvar)
}
}
else if (*p == '&' || *p == '+') /* option */
- n = (get_option_vartv(&p, NULL, TRUE) == OK);
+ n = (get_option_tv(&p, NULL, TRUE) == OK);
else if (*p == '*') /* internal or user defined function */
{
n = function_exists(p + 1);
@@ -4720,17 +4940,14 @@ f_exists(argvars, retvar)
}
else /* internal variable */
{
-#ifdef FEAT_MAGIC_BRACES
char_u *expr_start;
char_u *expr_end;
char_u *temp_string = NULL;
char_u *s;
-#endif
name = p;
-#ifdef FEAT_MAGIC_BRACES
/* Find the end of the name. */
- s = find_name_end(name, &expr_start, &expr_end);
+ s = find_name_end(name, &expr_start, &expr_end, FALSE);
if (expr_start != NULL)
{
temp_string = make_expanded_name(name, expr_start, expr_end, s);
@@ -4740,27 +4957,24 @@ f_exists(argvars, retvar)
name = temp_string;
}
}
-#endif
if (len == 0)
len = get_id_len(&p);
if (len != 0)
- n = (get_var_vartv(name, len, NULL) == OK);
+ n = (get_var_tv(name, len, NULL) == OK);
-#ifdef FEAT_MAGIC_BRACES
vim_free(temp_string);
-#endif
}
- retvar->vval.v_number = n;
+ rettv->vval.v_number = n;
}
/*
* "expand()" function
*/
static void
-f_expand(argvars, retvar)
+f_expand(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *s;
int len;
@@ -4768,23 +4982,23 @@ f_expand(argvars, retvar)
int flags = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND;
expand_T xpc;
- retvar->v_type = VAR_STRING;
- s = get_vartv_string(&argvars[0]);
+ rettv->v_type = VAR_STRING;
+ s = get_tv_string(&argvars[0]);
if (*s == '%' || *s == '#' || *s == '<')
{
++emsg_off;
- retvar->vval.v_string = eval_vars(s, &len, NULL, &errormsg, s);
+ rettv->vval.v_string = eval_vars(s, &len, NULL, &errormsg, s);
--emsg_off;
}
else
{
/* When the optional second argument is non-zero, don't remove matches
* for 'suffixes' and 'wildignore' */
- if (argvars[1].v_type != VAR_UNKNOWN && get_vartv_number(&argvars[1]))
+ if (argvars[1].v_type != VAR_UNKNOWN && get_tv_number(&argvars[1]))
flags |= WILD_KEEP_ALL;
ExpandInit(&xpc);
xpc.xp_context = EXPAND_FILES;
- retvar->vval.v_string = ExpandOne(&xpc, s, NULL, flags, WILD_ALL);
+ rettv->vval.v_string = ExpandOne(&xpc, s, NULL, flags, WILD_ALL);
ExpandCleanup(&xpc);
}
}
@@ -4793,15 +5007,15 @@ f_expand(argvars, retvar)
* "filereadable()" function
*/
static void
-f_filereadable(argvars, retvar)
+f_filereadable(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
FILE *fd;
char_u *p;
int n;
- p = get_vartv_string(&argvars[0]);
+ p = get_tv_string(&argvars[0]);
if (*p && !mch_isdir(p) && (fd = mch_fopen((char *)p, "r")) != NULL)
{
n = TRUE;
@@ -4810,7 +5024,7 @@ f_filereadable(argvars, retvar)
else
n = FALSE;
- retvar->vval.v_number = n;
+ rettv->vval.v_number = n;
}
/*
@@ -4818,9 +5032,9 @@ f_filereadable(argvars, retvar)
* rights to write into.
*/
static void
-f_filewritable(argvars, retvar)
+f_filewritable(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *p;
int retval = 0;
@@ -4828,7 +5042,7 @@ f_filewritable(argvars, retvar)
int perm = 0;
#endif
- p = get_vartv_string(&argvars[0]);
+ p = get_tv_string(&argvars[0]);
#if defined(UNIX) || defined(VMS)
perm = mch_getperm(p);
#endif
@@ -4849,35 +5063,35 @@ f_filewritable(argvars, retvar)
if (mch_isdir(p))
++retval;
}
- retvar->vval.v_number = retval;
+ rettv->vval.v_number = retval;
}
/*
* "finddir({fname}[, {path}[, {count}]])" function
*/
static void
-f_finddir(argvars, retvar)
+f_finddir(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- f_findfilendir(argvars, retvar, TRUE);
+ f_findfilendir(argvars, rettv, TRUE);
}
/*
* "findfile({fname}[, {path}[, {count}]])" function
*/
static void
-f_findfile(argvars, retvar)
+f_findfile(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- f_findfilendir(argvars, retvar, FALSE);
+ f_findfilendir(argvars, rettv, FALSE);
}
static void
-f_findfilendir(argvars, retvar, dir)
+f_findfilendir(argvars, rettv, dir)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
int dir;
{
#ifdef FEAT_SEARCHPATH
@@ -4889,16 +5103,16 @@ f_findfilendir(argvars, retvar, dir)
int count = 1;
int first = TRUE;
- fname = get_vartv_string(&argvars[0]);
+ fname = get_tv_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
{
- p = get_vartv_string_buf(&argvars[1], pathbuf);
+ p = get_tv_string_buf(&argvars[1], pathbuf);
if (*p != NUL)
path = p;
if (argvars[2].v_type != VAR_UNKNOWN)
- count = get_vartv_number(&argvars[2]);
+ count = get_tv_number(&argvars[2]);
}
do
@@ -4910,20 +5124,20 @@ f_findfilendir(argvars, retvar, dir)
first = FALSE;
} while (--count > 0 && fresult != NULL);
- retvar->vval.v_string = fresult;
+ rettv->vval.v_string = fresult;
#else
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
#endif
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
}
/*
* "fnamemodify({fname}, {mods})" function
*/
static void
-f_fnamemodify(argvars, retvar)
+f_fnamemodify(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *fname;
char_u *mods;
@@ -4932,17 +5146,17 @@ f_fnamemodify(argvars, retvar)
char_u *fbuf = NULL;
char_u buf[NUMBUFLEN];
- fname = get_vartv_string(&argvars[0]);
- mods = get_vartv_string_buf(&argvars[1], buf);
+ fname = get_tv_string(&argvars[0]);
+ mods = get_tv_string_buf(&argvars[1], buf);
len = (int)STRLEN(fname);
(void)modify_fname(mods, &usedlen, &fname, &fbuf, &len);
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
if (fname == NULL)
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
else
- retvar->vval.v_string = vim_strnsave(fname, len);
+ rettv->vval.v_string = vim_strnsave(fname, len);
vim_free(fbuf);
}
@@ -4950,70 +5164,70 @@ f_fnamemodify(argvars, retvar)
* "foldclosed()" function
*/
static void
-f_foldclosed(argvars, retvar)
+f_foldclosed(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- foldclosed_both(argvars, retvar, FALSE);
+ foldclosed_both(argvars, rettv, FALSE);
}
/*
* "foldclosedend()" function
*/
static void
-f_foldclosedend(argvars, retvar)
+f_foldclosedend(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- foldclosed_both(argvars, retvar, TRUE);
+ foldclosed_both(argvars, rettv, TRUE);
}
/*
* "foldclosed()" function
*/
static void
-foldclosed_both(argvars, retvar, end)
+foldclosed_both(argvars, rettv, end)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
int end;
{
#ifdef FEAT_FOLDING
linenr_T lnum;
linenr_T first, last;
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
{
if (hasFoldingWin(curwin, lnum, &first, &last, FALSE, NULL))
{
if (end)
- retvar->vval.v_number = (varnumber_T)last;
+ rettv->vval.v_number = (varnumber_T)last;
else
- retvar->vval.v_number = (varnumber_T)first;
+ rettv->vval.v_number = (varnumber_T)first;
return;
}
}
#endif
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
}
/*
* "foldlevel()" function
*/
static void
-f_foldlevel(argvars, retvar)
+f_foldlevel(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_FOLDING
linenr_T lnum;
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
- retvar->vval.v_number = foldLevel(lnum);
+ rettv->vval.v_number = foldLevel(lnum);
else
#endif
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
}
/*
@@ -5021,9 +5235,9 @@ f_foldlevel(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_foldtext(argvars, retvar)
+f_foldtext(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_FOLDING
linenr_T lnum;
@@ -5033,8 +5247,8 @@ f_foldtext(argvars, retvar)
char *txt;
#endif
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
#ifdef FEAT_FOLDING
if ((linenr_T)vimvars[VV_FOLDSTART].val > 0
&& (linenr_T)vimvars[VV_FOLDEND].val <= curbuf->b_ml.ml_line_count
@@ -5077,7 +5291,7 @@ f_foldtext(argvars, retvar)
STRCAT(r, s);
/* remove 'foldmarker' and 'commentstring' */
foldtext_cleanup(r + len);
- retvar->vval.v_string = r;
+ rettv->vval.v_string = r;
}
}
#endif
@@ -5088,9 +5302,9 @@ f_foldtext(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_foldtextresult(argvars, retvar)
+f_foldtextresult(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_FOLDING
linenr_T lnum;
@@ -5100,10 +5314,10 @@ f_foldtextresult(argvars, retvar)
int fold_count;
#endif
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
#ifdef FEAT_FOLDING
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
fold_count = foldedCount(curwin, lnum, &foldinfo);
if (fold_count > 0)
{
@@ -5111,7 +5325,7 @@ f_foldtextresult(argvars, retvar)
&foldinfo, buf);
if (text == buf)
text = vim_strsave(text);
- retvar->vval.v_string = text;
+ rettv->vval.v_string = text;
}
#endif
}
@@ -5121,11 +5335,11 @@ f_foldtextresult(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_foreground(argvars, retvar)
+f_foreground(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
#ifdef FEAT_GUI
if (gui.in_use)
gui_mch_set_foreground();
@@ -5141,21 +5355,21 @@ f_foreground(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_function(argvars, retvar)
+f_function(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *s;
- s = get_vartv_string(&argvars[0]);
+ s = get_tv_string(&argvars[0]);
if (s == NULL || *s == NUL || isdigit(*s))
EMSG2(_(e_invarg2), s);
else if (!function_exists(s))
EMSG2(_("E999: Unknown function: %s"), s);
else
{
- retvar->vval.v_string = vim_strsave(s);
- retvar->v_type = VAR_FUNC;
+ rettv->vval.v_string = vim_strsave(s);
+ rettv->v_type = VAR_FUNC;
}
}
@@ -5163,9 +5377,9 @@ f_function(argvars, retvar)
* "getchar()" function
*/
static void
-f_getchar(argvars, retvar)
+f_getchar(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
varnumber_T n;
@@ -5174,7 +5388,7 @@ f_getchar(argvars, retvar)
if (argvars[0].v_type == VAR_UNKNOWN)
/* getchar(): blocking wait. */
n = safe_vgetc();
- else if (get_vartv_number(&argvars[0]) == 1)
+ else if (get_tv_number(&argvars[0]) == 1)
/* getchar(1): only check if char avail */
n = vpeekc();
else if (vpeekc() == NUL)
@@ -5186,7 +5400,7 @@ f_getchar(argvars, retvar)
--no_mapping;
--allow_keys;
- retvar->vval.v_number = n;
+ rettv->vval.v_number = n;
if (IS_SPECIAL(n) || mod_mask != 0)
{
char_u temp[10]; /* modifier: 3, mbyte-char: 6, NUL: 1 */
@@ -5212,8 +5426,8 @@ f_getchar(argvars, retvar)
else
temp[i++] = n;
temp[i++] = NUL;
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = vim_strsave(temp);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_strsave(temp);
}
}
@@ -5222,11 +5436,11 @@ f_getchar(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_getcharmod(argvars, retvar)
+f_getcharmod(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = mod_mask;
+ rettv->vval.v_number = mod_mask;
}
/*
@@ -5234,12 +5448,12 @@ f_getcharmod(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_getcmdline(argvars, retvar)
+f_getcmdline(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = get_cmdline_str();
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = get_cmdline_str();
}
/*
@@ -5247,20 +5461,20 @@ f_getcmdline(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_getcmdpos(argvars, retvar)
+f_getcmdpos(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = get_cmdline_pos() + 1;
+ rettv->vval.v_number = get_cmdline_pos() + 1;
}
/*
* "getbufvar()" function
*/
static void
-f_getbufvar(argvars, retvar)
+f_getbufvar(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
buf_T *buf;
buf_T *save_curbuf;
@@ -5268,11 +5482,11 @@ f_getbufvar(argvars, retvar)
VAR v;
++emsg_off;
- buf = get_buf_vartv(&argvars[0]);
- varname = get_vartv_string(&argvars[1]);
+ buf = get_buf_tv(&argvars[0]);
+ varname = get_tv_string(&argvars[1]);
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
if (buf != NULL && varname != NULL)
{
@@ -5282,7 +5496,7 @@ f_getbufvar(argvars, retvar)
save_curbuf = curbuf;
curbuf = buf;
- get_option_vartv(&varname, retvar, TRUE);
+ get_option_tv(&varname, rettv, TRUE);
/* restore previous notion of curbuf */
curbuf = save_curbuf;
@@ -5292,7 +5506,7 @@ f_getbufvar(argvars, retvar)
/* look up the variable */
v = find_var_in_ga(&buf->b_vars, varname);
if (v != NULL)
- copy_vartv(&v->tv, retvar);
+ copy_tv(&v->tv, rettv);
}
}
@@ -5304,20 +5518,20 @@ f_getbufvar(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_getcwd(argvars, retvar)
+f_getcwd(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u cwd[MAXPATHL];
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
if (mch_dirname(cwd, MAXPATHL) == FAIL)
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
else
{
- retvar->vval.v_string = vim_strsave(cwd);
+ rettv->vval.v_string = vim_strsave(cwd);
#ifdef BACKSLASH_IN_FILENAME
- slash_adjust(retvar->vval.v_string);
+ slash_adjust(rettv->vval.v_string);
#endif
}
}
@@ -5327,12 +5541,12 @@ f_getcwd(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_getfontname(argvars, retvar)
+f_getfontname(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
#ifdef FEAT_GUI
if (gui.in_use)
{
@@ -5348,14 +5562,14 @@ f_getfontname(argvars, retvar)
}
else
{
- name = get_vartv_string(&argvars[0]);
+ name = get_tv_string(&argvars[0]);
if (STRCMP(name, "*") == 0) /* don't use font dialog */
return;
font = gui_mch_get_font(name, FALSE);
if (font == NOFONT)
return; /* Invalid font name, return empty string. */
}
- retvar->vval.v_string = gui_mch_get_fontname(font, name);
+ rettv->vval.v_string = gui_mch_get_fontname(font, name);
if (argvars[0].v_type != VAR_UNKNOWN)
gui_mch_free_font(font);
}
@@ -5366,9 +5580,9 @@ f_getfontname(argvars, retvar)
* "getfperm({fname})" function
*/
static void
-f_getfperm(argvars, retvar)
+f_getfperm(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *fname;
struct stat st;
@@ -5376,9 +5590,9 @@ f_getfperm(argvars, retvar)
char_u flags[] = "rwx";
int i;
- fname = get_vartv_string(&argvars[0]);
+ fname = get_tv_string(&argvars[0]);
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
if (mch_stat((char *)fname, &st) >= 0)
{
perm = vim_strsave((char_u *)"---------");
@@ -5391,70 +5605,70 @@ f_getfperm(argvars, retvar)
}
}
}
- retvar->vval.v_string = perm;
+ rettv->vval.v_string = perm;
}
/*
* "getfsize({fname})" function
*/
static void
-f_getfsize(argvars, retvar)
+f_getfsize(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *fname;
struct stat st;
- fname = get_vartv_string(&argvars[0]);
+ fname = get_tv_string(&argvars[0]);
- retvar->v_type = VAR_NUMBER;
+ rettv->v_type = VAR_NUMBER;
if (mch_stat((char *)fname, &st) >= 0)
{
if (mch_isdir(fname))
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
else
- retvar->vval.v_number = (varnumber_T)st.st_size;
+ rettv->vval.v_number = (varnumber_T)st.st_size;
}
else
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
}
/*
* "getftime({fname})" function
*/
static void
-f_getftime(argvars, retvar)
+f_getftime(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *fname;
struct stat st;
- fname = get_vartv_string(&argvars[0]);
+ fname = get_tv_string(&argvars[0]);
if (mch_stat((char *)fname, &st) >= 0)
- retvar->vval.v_number = (varnumber_T)st.st_mtime;
+ rettv->vval.v_number = (varnumber_T)st.st_mtime;
else
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
}
/*
* "getftype({fname})" function
*/
static void
-f_getftype(argvars, retvar)
+f_getftype(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *fname;
struct stat st;
char_u *type = NULL;
char *t;
- fname = get_vartv_string(&argvars[0]);
+ fname = get_tv_string(&argvars[0]);
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
if (mch_lstat((char *)fname, &st) >= 0)
{
#ifdef S_ISREG
@@ -5516,39 +5730,39 @@ f_getftype(argvars, retvar)
#endif
type = vim_strsave((char_u *)t);
}
- retvar->vval.v_string = type;
+ rettv->vval.v_string = type;
}
/*
* "getreg()" function
*/
static void
-f_getreg(argvars, retvar)
+f_getreg(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *strregname;
int regname;
if (argvars[0].v_type != VAR_UNKNOWN)
- strregname = get_vartv_string(&argvars[0]);
+ strregname = get_tv_string(&argvars[0]);
else
strregname = vimvars[VV_REG].val;
regname = (strregname == NULL ? '"' : *strregname);
if (regname == 0)
regname = '"';
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = get_reg_contents(regname, TRUE);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = get_reg_contents(regname, TRUE);
}
/*
* "getregtype()" function
*/
static void
-f_getregtype(argvars, retvar)
+f_getregtype(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *strregname;
int regname;
@@ -5556,7 +5770,7 @@ f_getregtype(argvars, retvar)
long reglen = 0;
if (argvars[0].v_type != VAR_UNKNOWN)
- strregname = get_vartv_string(&argvars[0]);
+ strregname = get_tv_string(&argvars[0]);
else
/* Default to v:register */
strregname = vimvars[VV_REG].val;
@@ -5578,30 +5792,30 @@ f_getregtype(argvars, retvar)
break;
#endif
}
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = vim_strsave(buf);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_strsave(buf);
}
/*
* "getline(lnum)" function
*/
static void
-f_getline(argvars, retvar)
+f_getline(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
linenr_T lnum;
char_u *p;
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
p = ml_get(lnum);
else
p = (char_u *)"";
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = vim_strsave(p);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_strsave(p);
}
/*
@@ -5609,18 +5823,18 @@ f_getline(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_getwinposx(argvars, retvar)
+f_getwinposx(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
#ifdef FEAT_GUI
if (gui.in_use)
{
int x, y;
if (gui_mch_get_winpos(&x, &y) == OK)
- retvar->vval.v_number = x;
+ rettv->vval.v_number = x;
}
#endif
}
@@ -5630,18 +5844,18 @@ f_getwinposx(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_getwinposy(argvars, retvar)
+f_getwinposy(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
#ifdef FEAT_GUI
if (gui.in_use)
{
int x, y;
if (gui_mch_get_winpos(&x, &y) == OK)
- retvar->vval.v_number = y;
+ rettv->vval.v_number = y;
}
#endif
}
@@ -5650,9 +5864,9 @@ f_getwinposy(argvars, retvar)
* "getwinvar()" function
*/
static void
-f_getwinvar(argvars, retvar)
+f_getwinvar(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
win_T *win, *oldcurwin;
char_u *varname;
@@ -5660,10 +5874,10 @@ f_getwinvar(argvars, retvar)
++emsg_off;
win = find_win_by_nr(&argvars[0]);
- varname = get_vartv_string(&argvars[1]);
+ varname = get_tv_string(&argvars[1]);
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
if (win != NULL && varname != NULL)
{
@@ -5673,7 +5887,7 @@ f_getwinvar(argvars, retvar)
oldcurwin = curwin;
curwin = win;
- get_option_vartv(&varname, retvar, 1);
+ get_option_tv(&varname, rettv, 1);
/* restore previous notion of curwin */
curwin = oldcurwin;
@@ -5683,7 +5897,7 @@ f_getwinvar(argvars, retvar)
/* look up the variable */
v = find_var_in_ga(&win->w_vars, varname);
if (v != NULL)
- copy_vartv(&v->tv, retvar);
+ copy_tv(&v->tv, rettv);
}
}
@@ -5694,16 +5908,16 @@ f_getwinvar(argvars, retvar)
* "glob()" function
*/
static void
-f_glob(argvars, retvar)
+f_glob(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
expand_T xpc;
ExpandInit(&xpc);
xpc.xp_context = EXPAND_FILES;
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = ExpandOne(&xpc, get_vartv_string(&argvars[0]),
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL);
ExpandCleanup(&xpc);
}
@@ -5712,24 +5926,24 @@ f_glob(argvars, retvar)
* "globpath()" function
*/
static void
-f_globpath(argvars, retvar)
+f_globpath(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u buf1[NUMBUFLEN];
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = globpath(get_vartv_string(&argvars[0]),
- get_vartv_string_buf(&argvars[1], buf1));
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = globpath(get_tv_string(&argvars[0]),
+ get_tv_string_buf(&argvars[1], buf1));
}
/*
* "has()" function
*/
static void
-f_has(argvars, retvar)
+f_has(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
int i;
char_u *name;
@@ -5892,9 +6106,6 @@ f_has(argvars, retvar)
"gui_athena",
# endif
#endif
-#ifdef FEAT_GUI_BEOS
- "gui_beos",
-#endif
#ifdef FEAT_GUI_KDE
"gui_kde",
#endif
@@ -6157,7 +6368,7 @@ f_has(argvars, retvar)
NULL
};
- name = get_vartv_string(&argvars[0]);
+ name = get_tv_string(&argvars[0]);
for (i = 0; has_list[i] != NULL; ++i)
if (STRICMP(name, has_list[i]) == 0)
{
@@ -6217,31 +6428,31 @@ f_has(argvars, retvar)
#endif
}
- retvar->vval.v_number = n;
+ rettv->vval.v_number = n;
}
/*
* "hasmapto()" function
*/
static void
-f_hasmapto(argvars, retvar)
+f_hasmapto(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *name;
char_u *mode;
char_u buf[NUMBUFLEN];
- name = get_vartv_string(&argvars[0]);
+ name = get_tv_string(&argvars[0]);
if (argvars[1].v_type == VAR_UNKNOWN)
mode = (char_u *)"nvo";
else
- mode = get_vartv_string_buf(&argvars[1], buf);
+ mode = get_tv_string_buf(&argvars[1], buf);
if (map_to_exists(name, mode))
- retvar->vval.v_number = TRUE;
+ rettv->vval.v_number = TRUE;
else
- retvar->vval.v_number = FALSE;
+ rettv->vval.v_number = FALSE;
}
/*
@@ -6249,9 +6460,9 @@ f_hasmapto(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_histadd(argvars, retvar)
+f_histadd(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_CMDHIST
int histype;
@@ -6259,18 +6470,18 @@ f_histadd(argvars, retvar)
char_u buf[NUMBUFLEN];
#endif
- retvar->vval.v_number = FALSE;
+ rettv->vval.v_number = FALSE;
if (check_restricted() || check_secure())
return;
#ifdef FEAT_CMDHIST
- histype = get_histtype(get_vartv_string(&argvars[0]));
+ histype = get_histtype(get_tv_string(&argvars[0]));
if (histype >= 0)
{
- str = get_vartv_string_buf(&argvars[1], buf);
+ str = get_tv_string_buf(&argvars[1], buf);
if (*str != NUL)
{
add_to_history(histype, str, FALSE, NUL);
- retvar->vval.v_number = TRUE;
+ rettv->vval.v_number = TRUE;
return;
}
}
@@ -6282,9 +6493,9 @@ f_histadd(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_histdel(argvars, retvar)
+f_histdel(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_CMDHIST
int n;
@@ -6292,18 +6503,18 @@ f_histdel(argvars, retvar)
if (argvars[1].v_type == VAR_UNKNOWN)
/* only one argument: clear entire history */
- n = clr_history(get_histtype(get_vartv_string(&argvars[0])));
+ n = clr_history(get_histtype(get_tv_string(&argvars[0])));
else if (argvars[1].v_type == VAR_NUMBER)
/* index given: remove that entry */
- n = del_history_idx(get_histtype(get_vartv_string(&argvars[0])),
- (int)get_vartv_number(&argvars[1]));
+ n = del_history_idx(get_histtype(get_tv_string(&argvars[0])),
+ (int)get_tv_number(&argvars[1]));
else
/* string given: remove all matching entries */
- n = del_history_entry(get_histtype(get_vartv_string(&argvars[0])),
- get_vartv_string_buf(&argvars[1], buf));
- retvar->vval.v_number = n;
+ n = del_history_entry(get_histtype(get_tv_string(&argvars[0])),
+ get_tv_string_buf(&argvars[1], buf));
+ rettv->vval.v_number = n;
#else
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
#endif
}
@@ -6312,24 +6523,24 @@ f_histdel(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_histget(argvars, retvar)
+f_histget(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_CMDHIST
int type;
int idx;
- type = get_histtype(get_vartv_string(&argvars[0]));
+ type = get_histtype(get_tv_string(&argvars[0]));
if (argvars[1].v_type == VAR_UNKNOWN)
idx = get_history_idx(type);
else
- idx = (int)get_vartv_number(&argvars[1]);
- retvar->vval.v_string = vim_strsave(get_history_entry(type, idx));
+ idx = (int)get_tv_number(&argvars[1]);
+ rettv->vval.v_string = vim_strsave(get_history_entry(type, idx));
#else
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
#endif
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
}
/*
@@ -6337,42 +6548,42 @@ f_histget(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_histnr(argvars, retvar)
+f_histnr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
int i;
#ifdef FEAT_CMDHIST
- i = get_histtype(get_vartv_string(&argvars[0]));
+ i = get_histtype(get_tv_string(&argvars[0]));
if (i >= HIST_CMD && i < HIST_COUNT)
i = get_history_idx(i);
else
#endif
i = -1;
- retvar->vval.v_number = i;
+ rettv->vval.v_number = i;
}
/*
* "highlight_exists()" function
*/
static void
-f_hlexists(argvars, retvar)
+f_hlexists(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = highlight_exists(get_vartv_string(&argvars[0]));
+ rettv->vval.v_number = highlight_exists(get_tv_string(&argvars[0]));
}
/*
* "highlightID(name)" function
*/
static void
-f_hlID(argvars, retvar)
+f_hlID(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = syn_name2id(get_vartv_string(&argvars[0]));
+ rettv->vval.v_number = syn_name2id(get_tv_string(&argvars[0]));
}
/*
@@ -6380,15 +6591,15 @@ f_hlID(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_hostname(argvars, retvar)
+f_hostname(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u hostname[256];
mch_get_host_name(hostname, 256);
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = vim_strsave(hostname);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_strsave(hostname);
}
/*
@@ -6396,9 +6607,9 @@ f_hostname(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_iconv(argvars, retvar)
+f_iconv(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_MBYTE
char_u buf1[NUMBUFLEN];
@@ -6407,21 +6618,21 @@ f_iconv(argvars, retvar)
vimconv_T vimconv;
#endif
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
#ifdef FEAT_MBYTE
- str = get_vartv_string(&argvars[0]);
- from = enc_canonize(enc_skip(get_vartv_string_buf(&argvars[1], buf1)));
- to = enc_canonize(enc_skip(get_vartv_string_buf(&argvars[2], buf2)));
+ str = get_tv_string(&argvars[0]);
+ from = enc_canonize(enc_skip(get_tv_string_buf(&argvars[1], buf1)));
+ to = enc_canonize(enc_skip(get_tv_string_buf(&argvars[2], buf2)));
vimconv.vc_type = CONV_NONE;
convert_setup(&vimconv, from, to);
/* If the encodings are equal, no conversion needed. */
if (vimconv.vc_type == CONV_NONE)
- retvar->vval.v_string = vim_strsave(str);
+ rettv->vval.v_string = vim_strsave(str);
else
- retvar->vval.v_string = string_convert(&vimconv, str, NULL);
+ rettv->vval.v_string = string_convert(&vimconv, str, NULL);
convert_setup(&vimconv, NULL, NULL);
vim_free(from);
@@ -6433,17 +6644,17 @@ f_iconv(argvars, retvar)
* "indent()" function
*/
static void
-f_indent(argvars, retvar)
+f_indent(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
linenr_T lnum;
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
- retvar->vval.v_number = get_indent_lnum(lnum);
+ rettv->vval.v_number = get_indent_lnum(lnum);
else
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
}
static int inputsecret_flag = 0;
@@ -6453,23 +6664,23 @@ static int inputsecret_flag = 0;
* Also handles inputsecret() when inputsecret is set.
*/
static void
-f_input(argvars, retvar)
+f_input(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- char_u *prompt = get_vartv_string(&argvars[0]);
+ char_u *prompt = get_tv_string(&argvars[0]);
char_u *p = NULL;
int c;
char_u buf[NUMBUFLEN];
int cmd_silent_save = cmd_silent;
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
#ifdef NO_CONSOLE_INPUT
/* While starting up, there is no place to enter text. */
if (no_console_input())
{
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
return;
}
#endif
@@ -6498,9 +6709,9 @@ f_input(argvars, retvar)
}
if (argvars[1].v_type != VAR_UNKNOWN)
- stuffReadbuffSpec(get_vartv_string_buf(&argvars[1], buf));
+ stuffReadbuffSpec(get_tv_string_buf(&argvars[1], buf));
- retvar->vval.v_string =
+ rettv->vval.v_string =
getcmdline_prompt(inputsecret_flag ? NUL : '@', p, echo_attr);
/* since the user typed this, no need to wait for return */
@@ -6513,9 +6724,9 @@ f_input(argvars, retvar)
* "inputdialog()" function
*/
static void
-f_inputdialog(argvars, retvar)
+f_inputdialog(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#if defined(FEAT_GUI_TEXTDIALOG)
/* Use a GUI dialog if the GUI is running and 'c' is not in 'guioptions' */
@@ -6524,31 +6735,31 @@ f_inputdialog(argvars, retvar)
char_u *message;
char_u buf[NUMBUFLEN];
- message = get_vartv_string(&argvars[0]);
+ message = get_tv_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
{
- STRNCPY(IObuff, get_vartv_string_buf(&argvars[1], buf), IOSIZE);
+ STRNCPY(IObuff, get_tv_string_buf(&argvars[1], buf), IOSIZE);
IObuff[IOSIZE - 1] = NUL;
}
else
IObuff[0] = NUL;
if (do_dialog(VIM_QUESTION, NULL, message, (char_u *)_("&OK\n&Cancel"),
1, IObuff) == 1)
- retvar->vval.v_string = vim_strsave(IObuff);
+ rettv->vval.v_string = vim_strsave(IObuff);
else
{
if (argvars[1].v_type != VAR_UNKNOWN
&& argvars[2].v_type != VAR_UNKNOWN)
- retvar->vval.v_string = vim_strsave(
- get_vartv_string_buf(&argvars[2], buf));
+ rettv->vval.v_string = vim_strsave(
+ get_tv_string_buf(&argvars[2], buf));
else
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
}
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
}
else
#endif
- f_input(argvars, retvar);
+ f_input(argvars, rettv);
}
static garray_T ga_userinput = {0, 0, sizeof(tasave_T), 4, NULL};
@@ -6558,21 +6769,21 @@ static garray_T ga_userinput = {0, 0, sizeof(tasave_T), 4, NULL};
*/
/*ARGSUSED*/
static void
-f_inputrestore(argvars, retvar)
+f_inputrestore(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
if (ga_userinput.ga_len > 0)
{
--ga_userinput.ga_len;
restore_typeahead((tasave_T *)(ga_userinput.ga_data)
+ ga_userinput.ga_len);
- retvar->vval.v_number = 0; /* OK */
+ rettv->vval.v_number = 0; /* OK */
}
else if (p_verbose > 1)
{
msg((char_u *)_("called inputrestore() more often than inputsave()"));
- retvar->vval.v_number = 1; /* Failed */
+ rettv->vval.v_number = 1; /* Failed */
}
}
@@ -6581,9 +6792,9 @@ f_inputrestore(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_inputsave(argvars, retvar)
+f_inputsave(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
/* Add an entry to the stack of typehead storage. */
if (ga_grow(&ga_userinput, 1) == OK)
@@ -6591,23 +6802,23 @@ f_inputsave(argvars, retvar)
save_typeahead((tasave_T *)(ga_userinput.ga_data)
+ ga_userinput.ga_len);
++ga_userinput.ga_len;
- retvar->vval.v_number = 0; /* OK */
+ rettv->vval.v_number = 0; /* OK */
}
else
- retvar->vval.v_number = 1; /* Failed */
+ rettv->vval.v_number = 1; /* Failed */
}
/*
* "inputsecret()" function
*/
static void
-f_inputsecret(argvars, retvar)
+f_inputsecret(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
++cmdline_star;
++inputsecret_flag;
- f_input(argvars, retvar);
+ f_input(argvars, rettv);
--cmdline_star;
--inputsecret_flag;
}
@@ -6616,9 +6827,9 @@ f_inputsecret(argvars, retvar)
* "insert()" function
*/
static void
-f_insert(argvars, retvar)
+f_insert(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
long before = 0;
long n;
@@ -6631,7 +6842,7 @@ f_insert(argvars, retvar)
else if ((l = argvars[0].vval.v_list) != NULL)
{
if (argvars[2].v_type != VAR_UNKNOWN)
- before = get_vartv_number(&argvars[2]);
+ before = get_tv_number(&argvars[2]);
if (before < 0)
{
@@ -6656,7 +6867,7 @@ f_insert(argvars, retvar)
ni = listitem_alloc();
if (ni != NULL)
{
- copy_vartv(&argvars[1], &ni->li_tv);
+ copy_tv(&argvars[1], &ni->li_tv);
if (item == NULL)
/* Append new item at end of list. */
list_append(l, ni);
@@ -6671,7 +6882,7 @@ f_insert(argvars, retvar)
item->li_prev->li_next = ni;
item->li_prev = ni;
}
- copy_vartv(&argvars[0], retvar);
+ copy_tv(&argvars[0], rettv);
}
}
}
@@ -6681,11 +6892,11 @@ f_insert(argvars, retvar)
* "isdirectory()" function
*/
static void
-f_isdirectory(argvars, retvar)
+f_isdirectory(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = mch_isdir(get_vartv_string(&argvars[0]));
+ rettv->vval.v_number = mch_isdir(get_tv_string(&argvars[0]));
}
/*
@@ -6693,9 +6904,9 @@ f_isdirectory(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_last_buffer_nr(argvars, retvar)
+f_last_buffer_nr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
int n = 0;
buf_T *buf;
@@ -6704,26 +6915,26 @@ f_last_buffer_nr(argvars, retvar)
if (n < buf->b_fnum)
n = buf->b_fnum;
- retvar->vval.v_number = n;
+ rettv->vval.v_number = n;
}
/*
* "len()" function
*/
static void
-f_len(argvars, retvar)
+f_len(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
switch (argvars[0].v_type)
{
case VAR_STRING:
case VAR_NUMBER:
- retvar->vval.v_number = (varnumber_T)STRLEN(
- get_vartv_string(&argvars[0]));
+ rettv->vval.v_number = (varnumber_T)STRLEN(
+ get_tv_string(&argvars[0]));
break;
case VAR_LIST:
- retvar->vval.v_number = list_len(argvars[0].vval.v_list);
+ rettv->vval.v_number = list_len(argvars[0].vval.v_list);
break;
default:
EMSG(_("E999: Invalid type for len()"));
@@ -6735,28 +6946,28 @@ f_len(argvars, retvar)
* "libcall()" function
*/
static void
-f_libcall(argvars, retvar)
+f_libcall(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- libcall_common(argvars, retvar, VAR_STRING);
+ libcall_common(argvars, rettv, VAR_STRING);
}
/*
* "libcallnr()" function
*/
static void
-f_libcallnr(argvars, retvar)
+f_libcallnr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- libcall_common(argvars, retvar, VAR_NUMBER);
+ libcall_common(argvars, rettv, VAR_NUMBER);
}
static void
-libcall_common(argvars, retvar, type)
+libcall_common(argvars, rettv, type)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
int type;
{
#ifdef FEAT_LIBCALL
@@ -6765,11 +6976,11 @@ libcall_common(argvars, retvar, type)
int nr_result;
#endif
- retvar->v_type = type;
+ rettv->v_type = type;
if (type == VAR_NUMBER)
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
else
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
if (check_restricted() || check_secure())
return;
@@ -6785,7 +6996,7 @@ libcall_common(argvars, retvar, type)
if (type == VAR_NUMBER)
string_result = NULL;
else
- string_result = &retvar->vval.v_string;
+ string_result = &rettv->vval.v_string;
if (mch_libcall(argvars[0].vval.v_string,
argvars[1].vval.v_string,
string_in,
@@ -6793,7 +7004,7 @@ libcall_common(argvars, retvar, type)
string_result,
&nr_result) == OK
&& type == VAR_NUMBER)
- retvar->vval.v_number = nr_result;
+ rettv->vval.v_number = nr_result;
}
#endif
}
@@ -6802,9 +7013,9 @@ libcall_common(argvars, retvar, type)
* "line(string)" function
*/
static void
-f_line(argvars, retvar)
+f_line(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
linenr_T lnum = 0;
pos_T *fp;
@@ -6812,7 +7023,7 @@ f_line(argvars, retvar)
fp = var2fpos(&argvars[0], TRUE);
if (fp != NULL)
lnum = fp->lnum;
- retvar->vval.v_number = lnum;
+ rettv->vval.v_number = lnum;
}
/*
@@ -6820,22 +7031,22 @@ f_line(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_line2byte(argvars, retvar)
+f_line2byte(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifndef FEAT_BYTEOFF
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
#else
linenr_T lnum;
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1)
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
- retvar->vval.v_number = ml_find_line_or_offset(curbuf, lnum, NULL);
- if (retvar->vval.v_number >= 0)
- ++retvar->vval.v_number;
+ rettv->vval.v_number = ml_find_line_or_offset(curbuf, lnum, NULL);
+ if (rettv->vval.v_number >= 0)
+ ++rettv->vval.v_number;
#endif
}
@@ -6843,25 +7054,25 @@ f_line2byte(argvars, retvar)
* "lispindent(lnum)" function
*/
static void
-f_lispindent(argvars, retvar)
+f_lispindent(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_LISP
pos_T pos;
linenr_T lnum;
pos = curwin->w_cursor;
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
{
curwin->w_cursor.lnum = lnum;
- retvar->vval.v_number = get_lisp_indent();
+ rettv->vval.v_number = get_lisp_indent();
curwin->w_cursor = pos;
}
else
#endif
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
}
/*
@@ -6869,39 +7080,39 @@ f_lispindent(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_localtime(argvars, retvar)
+f_localtime(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = (varnumber_T)time(NULL);
+ rettv->vval.v_number = (varnumber_T)time(NULL);
}
/*
* "maparg()" function
*/
static void
-f_maparg(argvars, retvar)
+f_maparg(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- get_maparg(argvars, retvar, TRUE);
+ get_maparg(argvars, rettv, TRUE);
}
/*
* "mapcheck()" function
*/
static void
-f_mapcheck(argvars, retvar)
+f_mapcheck(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- get_maparg(argvars, retvar, FALSE);
+ get_maparg(argvars, rettv, FALSE);
}
static void
-get_maparg(argvars, retvar, exact)
+get_maparg(argvars, rettv, exact)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
int exact;
{
char_u *keys;
@@ -6913,15 +7124,15 @@ get_maparg(argvars, retvar, exact)
garray_T ga;
/* return empty string for failure */
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
- keys = get_vartv_string(&argvars[0]);
+ keys = get_tv_string(&argvars[0]);
if (*keys == NUL)
return;
if (argvars[1].v_type != VAR_UNKNOWN)
- which = get_vartv_string_buf(&argvars[1], buf);
+ which = get_tv_string_buf(&argvars[1], buf);
else
which = (char_u *)"";
mode = get_map_mode(&which, 0);
@@ -6939,7 +7150,7 @@ get_maparg(argvars, retvar, exact)
ga_concat(&ga, str2special(&rhs, FALSE));
ga_append(&ga, NUL);
- retvar->vval.v_string = (char_u *)ga.ga_data;
+ rettv->vval.v_string = (char_u *)ga.ga_data;
}
}
@@ -6947,39 +7158,39 @@ get_maparg(argvars, retvar, exact)
* "match()" function
*/
static void
-f_match(argvars, retvar)
+f_match(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- find_some_match(argvars, retvar, 1);
+ find_some_match(argvars, rettv, 1);
}
/*
* "matchend()" function
*/
static void
-f_matchend(argvars, retvar)
+f_matchend(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- find_some_match(argvars, retvar, 0);
+ find_some_match(argvars, rettv, 0);
}
/*
* "matchstr()" function
*/
static void
-f_matchstr(argvars, retvar)
+f_matchstr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- find_some_match(argvars, retvar, 2);
+ find_some_match(argvars, rettv, 2);
}
static void
-find_some_match(argvars, retvar, type)
+find_some_match(argvars, rettv, type)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
int type;
{
char_u *str;
@@ -6996,20 +7207,20 @@ find_some_match(argvars, retvar, type)
save_cpo = p_cpo;
p_cpo = (char_u *)"";
- expr = str = get_vartv_string(&argvars[0]);
- pat = get_vartv_string_buf(&argvars[1], patbuf);
+ expr = str = get_tv_string(&argvars[0]);
+ pat = get_tv_string_buf(&argvars[1], patbuf);
if (type == 2)
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
}
else
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
if (argvars[2].v_type != VAR_UNKNOWN)
{
- start = get_vartv_number(&argvars[2]);
+ start = get_tv_number(&argvars[2]);
if (start < 0)
start = 0;
if (start > (long)STRLEN(str))
@@ -7017,7 +7228,7 @@ find_some_match(argvars, retvar, type)
str += start;
if (argvars[3].v_type != VAR_UNKNOWN)
- nth = get_vartv_number(&argvars[3]);
+ nth = get_tv_number(&argvars[3]);
}
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
@@ -7041,17 +7252,17 @@ find_some_match(argvars, retvar, type)
if (match)
{
if (type == 2)
- retvar->vval.v_string = vim_strnsave(regmatch.startp[0],
+ rettv->vval.v_string = vim_strnsave(regmatch.startp[0],
(int)(regmatch.endp[0] - regmatch.startp[0]));
else
{
if (type != 0)
- retvar->vval.v_number =
+ rettv->vval.v_number =
(varnumber_T)(regmatch.startp[0] - str);
else
- retvar->vval.v_number =
+ rettv->vval.v_number =
(varnumber_T)(regmatch.endp[0] - str);
- retvar->vval.v_number += str - expr;
+ rettv->vval.v_number += str - expr;
}
}
vim_free(regmatch.regprog);
@@ -7066,9 +7277,9 @@ theend:
*/
/*ARGSUSED*/
static void
-f_mode(argvars, retvar)
+f_mode(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u buf[2];
@@ -7097,40 +7308,40 @@ f_mode(argvars, retvar)
buf[0] = 'n';
buf[1] = NUL;
- retvar->vval.v_string = vim_strsave(buf);
- retvar->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_strsave(buf);
+ rettv->v_type = VAR_STRING;
}
/*
* "nr2char()" function
*/
static void
-f_nr2char(argvars, retvar)
+f_nr2char(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u buf[NUMBUFLEN];
#ifdef FEAT_MBYTE
if (has_mbyte)
- buf[(*mb_char2bytes)((int)get_vartv_number(&argvars[0]), buf)] = NUL;
+ buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
else
#endif
{
- buf[0] = (char_u)get_vartv_number(&argvars[0]);
+ buf[0] = (char_u)get_tv_number(&argvars[0]);
buf[1] = NUL;
}
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = vim_strsave(buf);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_strsave(buf);
}
/*
* "remove({list}, {idx})" function
*/
static void
-f_remove(argvars, retvar)
+f_remove(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
listvar *l;
listitem *item;
@@ -7140,13 +7351,13 @@ f_remove(argvars, retvar)
EMSG(_("E999: First argument of remove() must be a list"));
else if ((l = argvars[0].vval.v_list) != NULL)
{
- idx = get_vartv_number(&argvars[1]);
+ idx = get_tv_number(&argvars[1]);
item = list_getrem(l, idx);
if (item == NULL)
EMSGN(_(e_listidx), idx);
else
{
- *retvar = item->li_tv;
+ *rettv = item->li_tv;
vim_free(item);
}
}
@@ -7156,39 +7367,39 @@ f_remove(argvars, retvar)
* "rename({from}, {to})" function
*/
static void
-f_rename(argvars, retvar)
+f_rename(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u buf[NUMBUFLEN];
if (check_restricted() || check_secure())
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
- retvar->vval.v_number = vim_rename(get_vartv_string(&argvars[0]),
- get_vartv_string_buf(&argvars[1], buf));
+ rettv->vval.v_number = vim_rename(get_tv_string(&argvars[0]),
+ get_tv_string_buf(&argvars[1], buf));
}
/*
* "resolve()" function
*/
static void
-f_resolve(argvars, retvar)
+f_resolve(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *p;
- p = get_vartv_string(&argvars[0]);
+ p = get_tv_string(&argvars[0]);
#ifdef FEAT_SHORTCUT
{
char_u *v = NULL;
v = mch_resolve_shortcut(p);
if (v != NULL)
- retvar->vval.v_string = v;
+ rettv->vval.v_string = v;
else
- retvar->vval.v_string = vim_strsave(p);
+ rettv->vval.v_string = vim_strsave(p);
}
#else
# ifdef HAVE_READLINK
@@ -7235,7 +7446,7 @@ f_resolve(argvars, retvar)
vim_free(p);
vim_free(remain);
EMSG(_("E655: Too many symbolic links (cycle?)"));
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
goto fail;
}
@@ -7355,35 +7566,35 @@ f_resolve(argvars, retvar)
*gettail_sep(p) = NUL;
}
- retvar->vval.v_string = p;
+ rettv->vval.v_string = p;
}
# else
- retvar->vval.v_string = vim_strsave(p);
+ rettv->vval.v_string = vim_strsave(p);
# endif
#endif
- simplify_filename(retvar->vval.v_string);
+ simplify_filename(rettv->vval.v_string);
#ifdef HAVE_READLINK
fail:
#endif
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
}
/*
* "simplify()" function
*/
static void
-f_simplify(argvars, retvar)
+f_simplify(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *p;
- p = get_vartv_string(&argvars[0]);
- retvar->vval.v_string = vim_strsave(p);
- simplify_filename(retvar->vval.v_string); /* simplify in place */
- retvar->v_type = VAR_STRING;
+ p = get_tv_string(&argvars[0]);
+ rettv->vval.v_string = vim_strsave(p);
+ simplify_filename(rettv->vval.v_string); /* simplify in place */
+ rettv->v_type = VAR_STRING;
}
#define SP_NOMOVE 1 /* don't move cursor */
@@ -7394,9 +7605,9 @@ f_simplify(argvars, retvar)
* "search()" function
*/
static void
-f_search(argvars, retvar)
+f_search(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *pat;
pos_T pos;
@@ -7405,15 +7616,15 @@ f_search(argvars, retvar)
int dir;
int flags = 0;
- retvar->vval.v_number = 0; /* default: FAIL */
+ rettv->vval.v_number = 0; /* default: FAIL */
- pat = get_vartv_string(&argvars[0]);
+ pat = get_tv_string(&argvars[0]);
dir = get_search_arg(&argvars[1], &flags); /* may set p_ws */
if (dir == 0)
goto theend;
if ((flags & ~SP_NOMOVE) != 0)
{
- EMSG2(_(e_invarg2), get_vartv_string(&argvars[1]));
+ EMSG2(_(e_invarg2), get_tv_string(&argvars[1]));
goto theend;
}
@@ -7421,7 +7632,7 @@ f_search(argvars, retvar)
if (searchit(curwin, curbuf, &pos, dir, pat, 1L,
SEARCH_KEEP, RE_SEARCH) != FAIL)
{
- retvar->vval.v_number = pos.lnum;
+ rettv->vval.v_number = pos.lnum;
curwin->w_cursor = pos;
/* "/$" will put the cursor after the end of the line, may need to
* correct that here */
@@ -7439,9 +7650,9 @@ theend:
* "searchpair()" function
*/
static void
-f_searchpair(argvars, retvar)
+f_searchpair(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *spat, *mpat, *epat;
char_u *skip;
@@ -7462,16 +7673,16 @@ f_searchpair(argvars, retvar)
int nest = 1;
int err;
- retvar->vval.v_number = 0; /* default: FAIL */
+ rettv->vval.v_number = 0; /* default: FAIL */
/* Make 'cpoptions' empty, the 'l' flag should not be used here. */
save_cpo = p_cpo;
p_cpo = (char_u *)"";
/* Get the three pattern arguments: start, middle, end. */
- spat = get_vartv_string(&argvars[0]);
- mpat = get_vartv_string_buf(&argvars[1], nbuf1);
- epat = get_vartv_string_buf(&argvars[2], nbuf2);
+ spat = get_tv_string(&argvars[0]);
+ mpat = get_tv_string_buf(&argvars[1], nbuf1);
+ epat = get_tv_string_buf(&argvars[2], nbuf2);
/* Make two search patterns: start/end (pat2, for in nested pairs) and
* start/middle/end (pat3, for the top pair). */
@@ -7496,7 +7707,7 @@ f_searchpair(argvars, retvar)
|| argvars[4].v_type == VAR_UNKNOWN)
skip = (char_u *)"";
else
- skip = get_vartv_string_buf(&argvars[4], nbuf3);
+ skip = get_tv_string_buf(&argvars[4], nbuf3);
save_cursor = curwin->w_cursor;
pos = curwin->w_cursor;
@@ -7524,7 +7735,7 @@ f_searchpair(argvars, retvar)
{
/* Evaluating {skip} caused an error, break here. */
curwin->w_cursor = save_cursor;
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
break;
}
if (r)
@@ -7550,9 +7761,9 @@ f_searchpair(argvars, retvar)
{
/* Found the match: return matchcount or line number. */
if (flags & SP_RETCOUNT)
- ++retvar->vval.v_number;
+ ++rettv->vval.v_number;
else
- retvar->vval.v_number = pos.lnum;
+ rettv->vval.v_number = pos.lnum;
curwin->w_cursor = pos;
if (!(flags & SP_REPEAT))
break;
@@ -7561,7 +7772,7 @@ f_searchpair(argvars, retvar)
}
/* If 'n' flag is used or search failed: restore cursor position. */
- if ((flags & SP_NOMOVE) || retvar->vval.v_number == 0)
+ if ((flags & SP_NOMOVE) || rettv->vval.v_number == 0)
curwin->w_cursor = save_cursor;
theend:
@@ -7588,7 +7799,7 @@ get_search_arg(varp, flagsp)
if (varp->v_type != VAR_UNKNOWN)
{
- flags = get_vartv_string_buf(varp, nbuf);
+ flags = get_tv_string_buf(varp, nbuf);
while (*flags != NUL)
{
switch (*flags)
@@ -7625,9 +7836,9 @@ get_search_arg(varp, flagsp)
*/
/*ARGSUSED*/
static void
-f_setbufvar(argvars, retvar)
+f_setbufvar(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
buf_T *buf;
#ifdef FEAT_AUTOCMD
@@ -7642,8 +7853,8 @@ f_setbufvar(argvars, retvar)
if (check_restricted() || check_secure())
return;
++emsg_off;
- buf = get_buf_vartv(&argvars[0]);
- varname = get_vartv_string(&argvars[1]);
+ buf = get_buf_tv(&argvars[0]);
+ varname = get_tv_string(&argvars[1]);
varp = &argvars[2];
if (buf != NULL && varname != NULL && varp != NULL)
@@ -7659,8 +7870,8 @@ f_setbufvar(argvars, retvar)
if (*varname == '&')
{
++varname;
- set_option_value(varname, get_vartv_number(varp),
- get_vartv_string_buf(varp, nbuf), OPT_LOCAL);
+ set_option_value(varname, get_tv_number(varp),
+ get_tv_string_buf(varp, nbuf), OPT_LOCAL);
}
else
{
@@ -7688,28 +7899,28 @@ f_setbufvar(argvars, retvar)
* "setcmdpos()" function
*/
static void
-f_setcmdpos(argvars, retvar)
+f_setcmdpos(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = set_cmdline_pos(
- (int)get_vartv_number(&argvars[0]) - 1);
+ rettv->vval.v_number = set_cmdline_pos(
+ (int)get_tv_number(&argvars[0]) - 1);
}
/*
* "setline()" function
*/
static void
-f_setline(argvars, retvar)
+f_setline(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
linenr_T lnum;
char_u *line;
- lnum = get_vartv_lnum(argvars);
- line = get_vartv_string(&argvars[1]);
- retvar->vval.v_number = 1; /* FAIL is default */
+ lnum = get_tv_lnum(argvars);
+ line = get_tv_string(&argvars[1]);
+ rettv->vval.v_number = 1; /* FAIL is default */
if (lnum >= 1
&& lnum <= curbuf->b_ml.ml_line_count
@@ -7718,7 +7929,7 @@ f_setline(argvars, retvar)
{
changed_bytes(lnum, 0);
check_cursor_col();
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
}
}
@@ -7726,9 +7937,9 @@ f_setline(argvars, retvar)
* "setreg()" function
*/
static void
-f_setreg(argvars, retvar)
+f_setreg(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
int regname;
char_u *strregname;
@@ -7741,8 +7952,8 @@ f_setreg(argvars, retvar)
yank_type = MAUTO;
append = FALSE;
- strregname = get_vartv_string(argvars);
- retvar->vval.v_number = 1; /* FAIL is default */
+ strregname = get_tv_string(argvars);
+ rettv->vval.v_number = 1; /* FAIL is default */
regname = (strregname == NULL ? '"' : *strregname);
if (regname == 0 || regname == '@')
@@ -7752,7 +7963,7 @@ f_setreg(argvars, retvar)
if (argvars[2].v_type != VAR_UNKNOWN)
{
- for (stropt = get_vartv_string(&argvars[2]); *stropt != NUL; ++stropt)
+ for (stropt = get_tv_string(&argvars[2]); *stropt != NUL; ++stropt)
switch (*stropt)
{
case 'a': case 'A': /* append */
@@ -7778,9 +7989,9 @@ f_setreg(argvars, retvar)
}
}
- write_reg_contents_ex(regname, get_vartv_string(&argvars[1]), -1,
+ write_reg_contents_ex(regname, get_tv_string(&argvars[1]), -1,
append, yank_type, block_len);
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
}
@@ -7789,9 +8000,9 @@ f_setreg(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_setwinvar(argvars, retvar)
+f_setwinvar(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
win_T *win;
#ifdef FEAT_WINDOWS
@@ -7805,7 +8016,7 @@ f_setwinvar(argvars, retvar)
return;
++emsg_off;
win = find_win_by_nr(&argvars[0]);
- varname = get_vartv_string(&argvars[1]);
+ varname = get_tv_string(&argvars[1]);
varp = &argvars[2];
if (win != NULL && varname != NULL && varp != NULL)
@@ -7820,8 +8031,8 @@ f_setwinvar(argvars, retvar)
if (*varname == '&')
{
++varname;
- set_option_value(varname, get_vartv_number(varp),
- get_vartv_string_buf(varp, nbuf), OPT_LOCAL);
+ set_option_value(varname, get_tv_number(varp),
+ get_tv_string_buf(varp, nbuf), OPT_LOCAL);
}
else
{
@@ -7852,13 +8063,13 @@ f_setwinvar(argvars, retvar)
* "nextnonblank()" function
*/
static void
-f_nextnonblank(argvars, retvar)
+f_nextnonblank(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
linenr_T lnum;
- for (lnum = get_vartv_lnum(argvars); ; ++lnum)
+ for (lnum = get_tv_lnum(argvars); ; ++lnum)
{
if (lnum > curbuf->b_ml.ml_line_count)
{
@@ -7868,26 +8079,26 @@ f_nextnonblank(argvars, retvar)
if (*skipwhite(ml_get(lnum)) != NUL)
break;
}
- retvar->vval.v_number = lnum;
+ rettv->vval.v_number = lnum;
}
/*
* "prevnonblank()" function
*/
static void
-f_prevnonblank(argvars, retvar)
+f_prevnonblank(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
linenr_T lnum;
- lnum = get_vartv_lnum(argvars);
+ lnum = get_tv_lnum(argvars);
if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count)
lnum = 0;
else
while (lnum >= 1 && *skipwhite(ml_get(lnum)) == NUL)
--lnum;
- retvar->vval.v_number = lnum;
+ rettv->vval.v_number = lnum;
}
#if defined(FEAT_CLIENTSERVER) && defined(FEAT_X11)
@@ -7924,9 +8135,9 @@ check_connection()
/*ARGSUSED*/
static void
-f_serverlist(argvars, retvar)
+f_serverlist(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *r = NULL;
@@ -7939,15 +8150,15 @@ f_serverlist(argvars, retvar)
r = serverGetVimNames(X_DISPLAY);
# endif
#endif
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = r;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = r;
}
/*ARGSUSED*/
static void
-f_remote_peek(argvars, retvar)
+f_remote_peek(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_CLIENTSERVER
var v;
@@ -7958,44 +8169,44 @@ f_remote_peek(argvars, retvar)
if (check_restricted() || check_secure())
{
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
return;
}
# ifdef WIN32
- sscanf(get_vartv_string(&argvars[0]), "%x", &n);
+ sscanf(get_tv_string(&argvars[0]), "%x", &n);
if (n == 0)
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
{
s = serverGetReply((HWND)n, FALSE, FALSE, FALSE);
- retvar->vval.v_number = (s != NULL);
+ rettv->vval.v_number = (s != NULL);
}
# else
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
if (check_connection() == FAIL)
return;
- retvar->vval.v_number = serverPeekReply(X_DISPLAY,
- serverStrToWin(get_vartv_string(&argvars[0])), &s);
+ rettv->vval.v_number = serverPeekReply(X_DISPLAY,
+ serverStrToWin(get_tv_string(&argvars[0])), &s);
# endif
- if (argvars[1].v_type != VAR_UNKNOWN && retvar->vval.v_number > 0)
+ if (argvars[1].v_type != VAR_UNKNOWN && rettv->vval.v_number > 0)
{
v.tv.v_type = VAR_STRING;
v.tv.vval.v_string = vim_strsave(s);
- set_var(get_vartv_string(&argvars[1]), &v.tv, FALSE);
+ set_var(get_tv_string(&argvars[1]), &v.tv, FALSE);
vim_free(v.tv.vval.v_string);
}
#else
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
#endif
}
/*ARGSUSED*/
static void
-f_remote_read(argvars, retvar)
+f_remote_read(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *r = NULL;
@@ -8006,33 +8217,33 @@ f_remote_read(argvars, retvar)
/* The server's HWND is encoded in the 'id' parameter */
int n = 0;
- sscanf(get_vartv_string(&argvars[0]), "%x", &n);
+ sscanf(get_tv_string(&argvars[0]), "%x", &n);
if (n != 0)
r = serverGetReply((HWND)n, FALSE, TRUE, TRUE);
if (r == NULL)
# else
if (check_connection() == FAIL || serverReadReply(X_DISPLAY,
- serverStrToWin(get_vartv_string(&argvars[0])), &r, FALSE) < 0)
+ serverStrToWin(get_tv_string(&argvars[0])), &r, FALSE) < 0)
# endif
EMSG(_("E277: Unable to read a server reply"));
}
#endif
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = r;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = r;
}
/*ARGSUSED*/
static void
-f_server2client(argvars, retvar)
+f_server2client(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_CLIENTSERVER
char_u buf[NUMBUFLEN];
- char_u *server = get_vartv_string(&argvars[0]);
- char_u *reply = get_vartv_string_buf(&argvars[1], buf);
+ char_u *server = get_tv_string(&argvars[0]);
+ char_u *reply = get_tv_string_buf(&argvars[1], buf);
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
if (check_restricted() || check_secure())
return;
# ifdef FEAT_X11
@@ -8045,19 +8256,19 @@ f_server2client(argvars, retvar)
EMSG(_("E258: Unable to send to client"));
return;
}
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
#else
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
#endif
}
#ifdef FEAT_CLIENTSERVER
-static void remote_common __ARGS((typeval *argvars, typeval *retvar, int expr));
+static void remote_common __ARGS((typeval *argvars, typeval *rettv, int expr));
static void
-remote_common(argvars, retvar, expr)
+remote_common(argvars, rettv, expr)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
int expr;
{
char_u *server_name;
@@ -8078,8 +8289,8 @@ remote_common(argvars, retvar, expr)
return;
# endif
- server_name = get_vartv_string(&argvars[0]);
- keys = get_vartv_string_buf(&argvars[1], buf);
+ server_name = get_tv_string(&argvars[0]);
+ keys = get_tv_string_buf(&argvars[1], buf);
# ifdef WIN32
if (serverSendToVim(server_name, keys, &r, &w, expr, TRUE) < 0)
# else
@@ -8094,7 +8305,7 @@ remote_common(argvars, retvar, expr)
return;
}
- retvar->vval.v_string = r;
+ rettv->vval.v_string = r;
if (argvars[2].v_type != VAR_UNKNOWN)
{
@@ -8104,7 +8315,7 @@ remote_common(argvars, retvar, expr)
sprintf((char *)str, "0x%x", (unsigned int)w);
v.tv.v_type = VAR_STRING;
v.tv.vval.v_string = vim_strsave(str);
- set_var(get_vartv_string(&argvars[2]), &v.tv, FALSE);
+ set_var(get_tv_string(&argvars[2]), &v.tv, FALSE);
vim_free(v.tv.vval.v_string);
}
}
@@ -8115,14 +8326,14 @@ remote_common(argvars, retvar, expr)
*/
/*ARGSUSED*/
static void
-f_remote_expr(argvars, retvar)
+f_remote_expr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
#ifdef FEAT_CLIENTSERVER
- remote_common(argvars, retvar, TRUE);
+ remote_common(argvars, rettv, TRUE);
#endif
}
@@ -8131,14 +8342,14 @@ f_remote_expr(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_remote_send(argvars, retvar)
+f_remote_send(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
#ifdef FEAT_CLIENTSERVER
- remote_common(argvars, retvar, FALSE);
+ remote_common(argvars, rettv, FALSE);
#endif
}
@@ -8147,21 +8358,21 @@ f_remote_send(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_remote_foreground(argvars, retvar)
+f_remote_foreground(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
#ifdef FEAT_CLIENTSERVER
# ifdef WIN32
/* On Win32 it's done in this application. */
- serverForeground(get_vartv_string(&argvars[0]));
+ serverForeground(get_tv_string(&argvars[0]));
# else
/* Send a foreground() expression to the server. */
argvars[1].v_type = VAR_STRING;
argvars[1].vval.v_string = vim_strsave((char_u *)"foreground()");
argvars[2].v_type = VAR_UNKNOWN;
- remote_common(argvars, retvar, TRUE);
+ remote_common(argvars, rettv, TRUE);
vim_free(argvars[1].vval.v_string);
# endif
#endif
@@ -8172,9 +8383,9 @@ f_remote_foreground(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_repeat(argvars, retvar)
+f_repeat(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *p;
int n;
@@ -8183,11 +8394,11 @@ f_repeat(argvars, retvar)
char_u *r;
int i;
- p = get_vartv_string(&argvars[0]);
- n = get_vartv_number(&argvars[1]);
+ p = get_tv_string(&argvars[0]);
+ n = get_tv_number(&argvars[1]);
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
slen = (int)STRLEN(p);
len = slen * n;
@@ -8203,7 +8414,7 @@ f_repeat(argvars, retvar)
r[len] = NUL;
}
- retvar->vval.v_string = r;
+ rettv->vval.v_string = r;
}
#ifdef HAVE_STRFTIME
@@ -8211,26 +8422,26 @@ f_repeat(argvars, retvar)
* "strftime({format}[, {time}])" function
*/
static void
-f_strftime(argvars, retvar)
+f_strftime(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u result_buf[256];
struct tm *curtime;
time_t seconds;
char_u *p;
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
- p = get_vartv_string(&argvars[0]);
+ p = get_tv_string(&argvars[0]);
if (argvars[1].v_type == VAR_UNKNOWN)
seconds = time(NULL);
else
- seconds = (time_t)get_vartv_number(&argvars[1]);
+ seconds = (time_t)get_tv_number(&argvars[1]);
curtime = localtime(&seconds);
/* MSVC returns NULL for an invalid value of seconds. */
if (curtime == NULL)
- retvar->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
+ rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
else
{
# ifdef FEAT_MBYTE
@@ -8254,10 +8465,10 @@ f_strftime(argvars, retvar)
vim_free(p);
convert_setup(&conv, enc, p_enc);
if (conv.vc_type != CONV_NONE)
- retvar->vval.v_string = string_convert(&conv, result_buf, NULL);
+ rettv->vval.v_string = string_convert(&conv, result_buf, NULL);
else
# endif
- retvar->vval.v_string = vim_strsave(result_buf);
+ rettv->vval.v_string = vim_strsave(result_buf);
# ifdef FEAT_MBYTE
/* Release conversion descriptors */
@@ -8272,32 +8483,32 @@ f_strftime(argvars, retvar)
* "stridx()" function
*/
static void
-f_stridx(argvars, retvar)
+f_stridx(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u buf[NUMBUFLEN];
char_u *needle;
char_u *haystack;
char_u *pos;
- needle = get_vartv_string(&argvars[1]);
- haystack = get_vartv_string_buf(&argvars[0], buf);
+ needle = get_tv_string(&argvars[1]);
+ haystack = get_tv_string_buf(&argvars[0], buf);
pos = (char_u *)strstr((char *)haystack, (char *)needle);
if (pos == NULL)
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
- retvar->vval.v_number = (varnumber_T) (pos - haystack);
+ rettv->vval.v_number = (varnumber_T) (pos - haystack);
}
/*
* "strridx()" function
*/
static void
-f_strridx(argvars, retvar)
+f_strridx(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u buf[NUMBUFLEN];
char_u *needle;
@@ -8305,8 +8516,8 @@ f_strridx(argvars, retvar)
char_u *rest;
char_u *lastmatch = NULL;
- needle = get_vartv_string(&argvars[1]);
- haystack = get_vartv_string_buf(&argvars[0], buf);
+ needle = get_tv_string(&argvars[1]);
+ haystack = get_tv_string_buf(&argvars[0], buf);
if (*needle == NUL)
/* Empty string matches past the end. */
lastmatch = haystack + STRLEN(haystack);
@@ -8320,58 +8531,58 @@ f_strridx(argvars, retvar)
}
if (lastmatch == NULL)
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
- retvar->vval.v_number = (varnumber_T)(lastmatch - haystack);
+ rettv->vval.v_number = (varnumber_T)(lastmatch - haystack);
}
/*
* "string()" function
*/
static void
-f_string(argvars, retvar)
+f_string(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *tofree;
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = tv2string(&argvars[0], &tofree);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = tv2string(&argvars[0], &tofree);
if (tofree == NULL)
- retvar->vval.v_string = vim_strsave(retvar->vval.v_string);
+ rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
}
/*
* "strlen()" function
*/
static void
-f_strlen(argvars, retvar)
+f_strlen(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->vval.v_number = (varnumber_T)(STRLEN(
- get_vartv_string(&argvars[0])));
+ rettv->vval.v_number = (varnumber_T)(STRLEN(
+ get_tv_string(&argvars[0])));
}
/*
* "strpart()" function
*/
static void
-f_strpart(argvars, retvar)
+f_strpart(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *p;
int n;
int len;
int slen;
- p = get_vartv_string(&argvars[0]);
+ p = get_tv_string(&argvars[0]);
slen = (int)STRLEN(p);
- n = get_vartv_number(&argvars[1]);
+ n = get_tv_number(&argvars[1]);
if (argvars[2].v_type != VAR_UNKNOWN)
- len = get_vartv_number(&argvars[2]);
+ len = get_tv_number(&argvars[2]);
else
len = slen - n; /* default len: all bytes that are available. */
@@ -8391,20 +8602,20 @@ f_strpart(argvars, retvar)
else if (n + len > slen)
len = slen - n;
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = vim_strnsave(p + n, len);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_strnsave(p + n, len);
}
/*
* "strtrans()" function
*/
static void
-f_strtrans(argvars, retvar)
+f_strtrans(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = transstr(get_vartv_string(&argvars[0]));
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = transstr(get_tv_string(&argvars[0]));
}
/*
@@ -8412,9 +8623,9 @@ f_strtrans(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_synID(argvars, retvar)
+f_synID(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
int id = 0;
#ifdef FEAT_SYN_HL
@@ -8422,16 +8633,16 @@ f_synID(argvars, retvar)
long col;
int trans;
- line = get_vartv_lnum(argvars);
- col = get_vartv_number(&argvars[1]) - 1;
- trans = get_vartv_number(&argvars[2]);
+ line = get_tv_lnum(argvars);
+ col = get_tv_number(&argvars[1]) - 1;
+ trans = get_tv_number(&argvars[2]);
if (line >= 1 && line <= curbuf->b_ml.ml_line_count
&& col >= 0 && col < (long)STRLEN(ml_get(line)))
id = syn_get_id(line, col, trans);
#endif
- retvar->vval.v_number = id;
+ rettv->vval.v_number = id;
}
/*
@@ -8439,9 +8650,9 @@ f_synID(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_synIDattr(argvars, retvar)
+f_synIDattr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *p = NULL;
#ifdef FEAT_SYN_HL
@@ -8451,11 +8662,11 @@ f_synIDattr(argvars, retvar)
char_u modebuf[NUMBUFLEN];
int modec;
- id = get_vartv_number(&argvars[0]);
- what = get_vartv_string(&argvars[1]);
+ id = get_tv_number(&argvars[0]);
+ what = get_tv_string(&argvars[1]);
if (argvars[2].v_type != VAR_UNKNOWN)
{
- mode = get_vartv_string_buf(&argvars[2], modebuf);
+ mode = get_tv_string_buf(&argvars[2], modebuf);
modec = TOLOWER_ASC(mode[0]);
if (modec != 't' && modec != 'c'
#ifdef FEAT_GUI
@@ -8518,8 +8729,8 @@ f_synIDattr(argvars, retvar)
if (p != NULL)
p = vim_strsave(p);
#endif
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = p;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = p;
}
/*
@@ -8527,14 +8738,14 @@ f_synIDattr(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_synIDtrans(argvars, retvar)
+f_synIDtrans(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
int id;
#ifdef FEAT_SYN_HL
- id = get_vartv_number(&argvars[0]);
+ id = get_tv_number(&argvars[0]);
if (id > 0)
id = syn_get_final_id(id);
@@ -8542,16 +8753,16 @@ f_synIDtrans(argvars, retvar)
#endif
id = 0;
- retvar->vval.v_number = id;
+ rettv->vval.v_number = id;
}
/*
* "system()" function
*/
static void
-f_system(argvars, retvar)
+f_system(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *res = NULL;
char_u *p;
@@ -8578,7 +8789,7 @@ f_system(argvars, retvar)
EMSG2(_(e_notopen), infile);
goto done;
}
- p = get_vartv_string_buf(&argvars[1], buf);
+ p = get_tv_string_buf(&argvars[1], buf);
if (fwrite(p, STRLEN(p), 1, fd) != 1)
err = TRUE;
if (fclose(fd) != 0)
@@ -8590,7 +8801,7 @@ f_system(argvars, retvar)
}
}
- res = get_cmd_output(get_vartv_string(&argvars[0]), infile, SHELL_SILENT);
+ res = get_cmd_output(get_tv_string(&argvars[0]), infile, SHELL_SILENT);
#ifdef USE_CR
/* translate <CR> into <NL> */
@@ -8629,40 +8840,40 @@ done:
mch_remove(infile);
vim_free(infile);
}
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = res;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = res;
}
/*
* "submatch()" function
*/
static void
-f_submatch(argvars, retvar)
+f_submatch(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = reg_submatch((int)get_vartv_number(&argvars[0]));
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = reg_submatch((int)get_tv_number(&argvars[0]));
}
/*
* "substitute()" function
*/
static void
-f_substitute(argvars, retvar)
+f_substitute(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u patbuf[NUMBUFLEN];
char_u subbuf[NUMBUFLEN];
char_u flagsbuf[NUMBUFLEN];
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = do_string_sub(
- get_vartv_string(&argvars[0]),
- get_vartv_string_buf(&argvars[1], patbuf),
- get_vartv_string_buf(&argvars[2], subbuf),
- get_vartv_string_buf(&argvars[3], flagsbuf));
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = do_string_sub(
+ get_tv_string(&argvars[0]),
+ get_tv_string_buf(&argvars[1], patbuf),
+ get_tv_string_buf(&argvars[2], subbuf),
+ get_tv_string_buf(&argvars[3], flagsbuf));
}
/*
@@ -8670,14 +8881,14 @@ f_substitute(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_tempname(argvars, retvar)
+f_tempname(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
static int x = 'A';
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = vim_tempname(x);
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = vim_tempname(x);
/* Advance 'x' to use A-Z and 0-9, so that there are at least 34 different
* names. Skip 'I' and 'O', they are used for shell redirection. */
@@ -8705,15 +8916,15 @@ f_tempname(argvars, retvar)
* "tolower(string)" function
*/
static void
-f_tolower(argvars, retvar)
+f_tolower(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *p;
- p = vim_strsave(get_vartv_string(&argvars[0]));
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = p;
+ p = vim_strsave(get_tv_string(&argvars[0]));
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = p;
if (p != NULL)
while (*p != NUL)
@@ -8748,15 +8959,15 @@ f_tolower(argvars, retvar)
* "toupper(string)" function
*/
static void
-f_toupper(argvars, retvar)
+f_toupper(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *p;
- p = vim_strsave(get_vartv_string(&argvars[0]));
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = p;
+ p = vim_strsave(get_tv_string(&argvars[0]));
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = p;
if (p != NULL)
while (*p != NUL)
@@ -8791,9 +9002,9 @@ f_toupper(argvars, retvar)
* "tr(string, fromstr, tostr)" function
*/
static void
-f_tr(argvars, retvar)
+f_tr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
char_u *instr;
char_u *fromstr;
@@ -8812,13 +9023,13 @@ f_tr(argvars, retvar)
char_u buf2[NUMBUFLEN];
garray_T ga;
- instr = get_vartv_string(&argvars[0]);
- fromstr = get_vartv_string_buf(&argvars[1], buf);
- tostr = get_vartv_string_buf(&argvars[2], buf2);
+ instr = get_tv_string(&argvars[0]);
+ fromstr = get_tv_string_buf(&argvars[1], buf);
+ tostr = get_tv_string_buf(&argvars[2], buf2);
/* Default return value: empty string. */
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = NULL;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
ga_init2(&ga, (int)sizeof(char), 80);
#ifdef FEAT_MBYTE
@@ -8901,30 +9112,30 @@ error:
}
}
- retvar->vval.v_string = ga.ga_data;
+ rettv->vval.v_string = ga.ga_data;
}
/*
* "type(expr)" function
*/
static void
-f_type(argvars, retvar)
+f_type(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
if (argvars[0].v_type == VAR_NUMBER)
- retvar->vval.v_number = 0;
+ rettv->vval.v_number = 0;
else
- retvar->vval.v_number = 1;
+ rettv->vval.v_number = 1;
}
/*
* "virtcol(string)" function
*/
static void
-f_virtcol(argvars, retvar)
+f_virtcol(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
colnr_T vcol = 0;
pos_T *fp;
@@ -8936,7 +9147,7 @@ f_virtcol(argvars, retvar)
++vcol;
}
- retvar->vval.v_number = vcol;
+ rettv->vval.v_number = vcol;
}
/*
@@ -8944,26 +9155,26 @@ f_virtcol(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_visualmode(argvars, retvar)
+f_visualmode(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_VISUAL
char_u str[2];
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
str[0] = curbuf->b_visual_mode_eval;
str[1] = NUL;
- retvar->vval.v_string = vim_strsave(str);
+ rettv->vval.v_string = vim_strsave(str);
/* A non-zero number or non-empty string argument: reset mode. */
if ((argvars[0].v_type == VAR_NUMBER
&& argvars[0].vval.v_number != 0)
|| (argvars[0].v_type == VAR_STRING
- && *get_vartv_string(&argvars[0]) != NUL))
+ && *get_tv_string(&argvars[0]) != NUL))
curbuf->b_visual_mode_eval = NUL;
#else
- retvar->vval.v_number = 0; /* return anything, it won't work anyway */
+ rettv->vval.v_number = 0; /* return anything, it won't work anyway */
#endif
}
@@ -8971,17 +9182,17 @@ f_visualmode(argvars, retvar)
* "winbufnr(nr)" function
*/
static void
-f_winbufnr(argvars, retvar)
+f_winbufnr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
win_T *wp;
wp = find_win_by_nr(&argvars[0]);
if (wp == NULL)
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
- retvar->vval.v_number = wp->w_buffer->b_fnum;
+ rettv->vval.v_number = wp->w_buffer->b_fnum;
}
/*
@@ -8989,29 +9200,29 @@ f_winbufnr(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_wincol(argvars, retvar)
+f_wincol(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
validate_cursor();
- retvar->vval.v_number = curwin->w_wcol + 1;
+ rettv->vval.v_number = curwin->w_wcol + 1;
}
/*
* "winheight(nr)" function
*/
static void
-f_winheight(argvars, retvar)
+f_winheight(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
win_T *wp;
wp = find_win_by_nr(&argvars[0]);
if (wp == NULL)
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
- retvar->vval.v_number = wp->w_height;
+ rettv->vval.v_number = wp->w_height;
}
/*
@@ -9019,12 +9230,12 @@ f_winheight(argvars, retvar)
*/
/*ARGSUSED*/
static void
-f_winline(argvars, retvar)
+f_winline(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
validate_cursor();
- retvar->vval.v_number = curwin->w_wrow + 1;
+ rettv->vval.v_number = curwin->w_wrow + 1;
}
/*
@@ -9032,9 +9243,9 @@ f_winline(argvars, retvar)
*/
/* ARGSUSED */
static void
-f_winnr(argvars, retvar)
+f_winnr(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
int nr = 1;
#ifdef FEAT_WINDOWS
@@ -9044,7 +9255,7 @@ f_winnr(argvars, retvar)
if (argvars[0].v_type != VAR_UNKNOWN)
{
- arg = get_vartv_string(&argvars[0]);
+ arg = get_tv_string(&argvars[0]);
if (STRCMP(arg, "$") == 0)
twin = lastwin;
else if (STRCMP(arg, "#") == 0)
@@ -9064,7 +9275,7 @@ f_winnr(argvars, retvar)
for (wp = firstwin; wp != twin; wp = wp->w_next)
++nr;
#endif
- retvar->vval.v_number = nr;
+ rettv->vval.v_number = nr;
}
/*
@@ -9072,9 +9283,9 @@ f_winnr(argvars, retvar)
*/
/* ARGSUSED */
static void
-f_winrestcmd(argvars, retvar)
+f_winrestcmd(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
#ifdef FEAT_WINDOWS
win_T *wp;
@@ -9095,31 +9306,31 @@ f_winrestcmd(argvars, retvar)
}
ga_append(&ga, NUL);
- retvar->vval.v_string = ga.ga_data;
+ rettv->vval.v_string = ga.ga_data;
#else
- retvar->vval.v_string = NULL;
+ rettv->vval.v_string = NULL;
#endif
- retvar->v_type = VAR_STRING;
+ rettv->v_type = VAR_STRING;
}
/*
* "winwidth(nr)" function
*/
static void
-f_winwidth(argvars, retvar)
+f_winwidth(argvars, rettv)
typeval *argvars;
- typeval *retvar;
+ typeval *rettv;
{
win_T *wp;
wp = find_win_by_nr(&argvars[0]);
if (wp == NULL)
- retvar->vval.v_number = -1;
+ rettv->vval.v_number = -1;
else
#ifdef FEAT_VERTSPLIT
- retvar->vval.v_number = wp->w_width;
+ rettv->vval.v_number = wp->w_width;
#else
- retvar->vval.v_number = Columns;
+ rettv->vval.v_number = Columns;
#endif
}
@@ -9132,7 +9343,7 @@ find_win_by_nr(vp)
#endif
int nr;
- nr = get_vartv_number(vp);
+ nr = get_tv_number(vp);
#ifdef FEAT_WINDOWS
if (nr == 0)
@@ -9161,7 +9372,7 @@ var2fpos(varp, lnum)
static pos_T pos;
pos_T *pp;
- name = get_vartv_string(varp);
+ name = get_tv_string(varp);
if (name[0] == '.') /* cursor */
return &curwin->w_cursor;
if (name[0] == '\'') /* mark */
@@ -9248,11 +9459,9 @@ get_func_len(arg, alias, evaluate)
int evaluate;
{
int len;
-#ifdef FEAT_MAGIC_BRACES
char_u *p;
char_u *expr_start;
char_u *expr_end;
-#endif
*alias = NULL; /* default to no alias */
@@ -9270,12 +9479,10 @@ get_func_len(arg, alias, evaluate)
*arg += len;
}
-#ifdef FEAT_MAGIC_BRACES
/*
- * Find the end of the name;
+ * Find the end of the name; check for {} construction.
*/
- p = find_name_end(*arg, &expr_start, &expr_end);
- /* check for {} construction */
+ p = find_name_end(*arg, &expr_start, &expr_end, FALSE);
if (expr_start != NULL)
{
char_u *temp_string;
@@ -9298,7 +9505,6 @@ get_func_len(arg, alias, evaluate)
*arg = skipwhite(p);
return (int)STRLEN(temp_string);
}
-#endif
len += get_id_len(arg);
if (len == 0)
@@ -9307,34 +9513,58 @@ get_func_len(arg, alias, evaluate)
return len;
}
+/*
+ * Find the end of a variable or function name, taking care of magic braces.
+ * If "expr_start" is not NULL then "expr_start" and "expr_end" are set to the
+ * start and end of the first magic braces item.
+ * Return a pointer to just after the name. Equal to "arg" if there is no
+ * valid name.
+ */
static char_u *
-find_name_end(arg, expr_start, expr_end)
+find_name_end(arg, expr_start, expr_end, incl_br)
char_u *arg;
char_u **expr_start;
char_u **expr_end;
+ int incl_br; /* Include [] indexes */
{
- int nesting = 0;
+ int mb_nest = 0;
+ int br_nest = 0;
char_u *p;
- *expr_start = NULL;
- *expr_end = NULL;
+ if (expr_start != NULL)
+ {
+ *expr_start = NULL;
+ *expr_end = NULL;
+ }
- for (p = arg; (*p != NUL && (eval_isnamec(*p) || nesting != 0)); ++p)
+ for (p = arg; *p != NUL
+ && (eval_isnamec(*p)
+ || (*p == '[' && incl_br)
+ || mb_nest != 0
+ || br_nest != 0); ++p)
{
-#ifdef FEAT_MAGIC_BRACES
- if (*p == '{')
+ if (mb_nest == 0)
{
- nesting++;
- if (*expr_start == NULL)
- *expr_start = p;
+ if (*p == '[')
+ ++br_nest;
+ else if (*p == ']')
+ --br_nest;
}
- else if (*p == '}')
+ if (br_nest == 0)
{
- nesting--;
- if (nesting == 0 && *expr_end == NULL)
- *expr_end = p;
+ if (*p == '{')
+ {
+ mb_nest++;
+ if (expr_start != NULL && *expr_start == NULL)
+ *expr_start = p;
+ }
+ else if (*p == '}')
+ {
+ mb_nest--;
+ if (expr_start != NULL && mb_nest == 0 && *expr_end == NULL)
+ *expr_end = p;
+ }
}
-#endif
}
return p;
@@ -9347,11 +9577,7 @@ find_name_end(arg, expr_start, expr_end)
eval_isnamec(c)
int c;
{
- return (ASCII_ISALNUM(c) || c == '_' || c == ':'
-#ifdef FEAT_MAGIC_BRACES
- || c == '{' || c == '}'
-#endif
- );
+ return (ASCII_ISALNUM(c) || c == '_' || c == ':' || c == '{' || c == '}');
}
/*
@@ -9556,10 +9782,10 @@ set_cmdarg(eap, oldarg)
* Return OK or FAIL.
*/
static int
-get_var_vartv(name, len, retvar)
+get_var_tv(name, len, rettv)
char_u *name;
int len; /* length of "name" */
- typeval *retvar; /* NULL when only checking existence */
+ typeval *rettv; /* NULL when only checking existence */
{
int ret = OK;
typeval tv;
@@ -9606,12 +9832,12 @@ get_var_vartv(name, len, retvar)
if (tv.v_type == VAR_UNKNOWN)
{
- if (retvar != NULL)
- EMSG2(_("E121: Undefined variable: %s"), name);
+ if (rettv != NULL)
+ EMSG2(_(e_undefvar), name);
ret = FAIL;
}
- else if (retvar != NULL)
- copy_vartv(&tv, retvar);
+ else if (rettv != NULL)
+ copy_tv(&tv, rettv);
name[len] = cc;
@@ -9619,20 +9845,11 @@ get_var_vartv(name, len, retvar)
}
/*
- * Allocate memory for a variable, and make it emtpy (0 or NULL value).
- */
- static VAR
-alloc_var()
-{
- return (VAR)alloc_clear((unsigned)sizeof(var));
-}
-
-/*
* Allocate memory for a variable type-value, and make it emtpy (0 or NULL
* value).
*/
static typeval *
-alloc_vartv()
+alloc_tv()
{
return (typeval *)alloc_clear((unsigned)sizeof(typeval));
}
@@ -9643,27 +9860,27 @@ alloc_vartv()
* Return NULL for out of memory, the variable otherwise.
*/
static typeval *
-alloc_string_vartv(s)
+alloc_string_tv(s)
char_u *s;
{
- typeval *retvar;
+ typeval *rettv;
- retvar = alloc_vartv();
- if (retvar != NULL)
+ rettv = alloc_tv();
+ if (rettv != NULL)
{
- retvar->v_type = VAR_STRING;
- retvar->vval.v_string = s;
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = s;
}
else
vim_free(s);
- return retvar;
+ return rettv;
}
/*
* Free the memory for a variable type-value.
*/
static void
-free_vartv(varp)
+free_tv(varp)
typeval *varp;
{
if (varp != NULL)
@@ -9688,7 +9905,7 @@ free_vartv(varp)
* Free the memory for a variable value and set the value to NULL or 0.
*/
static void
-clear_vartv(varp)
+clear_tv(varp)
typeval *varp;
{
if (varp != NULL)
@@ -9703,19 +9920,34 @@ clear_vartv(varp)
case VAR_LIST:
list_unref(varp->vval.v_list);
break;
- default:
+ case VAR_NUMBER:
varp->vval.v_number = 0;
break;
+ case VAR_UNKNOWN:
+ break;
+ default:
+ EMSG2(_(e_intern2), "clear_tv()");
}
}
}
/*
+ * Set the value of a variable to NULL without freeing items.
+ */
+ static void
+init_tv(varp)
+ typeval *varp;
+{
+ if (varp != NULL)
+ vim_memset(varp, 0, sizeof(typeval));
+}
+
+/*
* Get the number value of a variable.
* If it is a String variable, uses vim_str2nr().
*/
static long
-get_vartv_number(varp)
+get_tv_number(varp)
typeval *varp;
{
long n = 0L;
@@ -9743,19 +9975,19 @@ get_vartv_number(varp)
* Get the lnum from the first argument. Also accepts ".", "$", etc.
*/
static linenr_T
-get_vartv_lnum(argvars)
+get_tv_lnum(argvars)
typeval *argvars;
{
- typeval retvar;
+ typeval rettv;
linenr_T lnum;
- lnum = get_vartv_number(&argvars[0]);
+ lnum = get_tv_number(&argvars[0]);
if (lnum == 0) /* no valid number, try using line() */
{
- retvar.v_type = VAR_NUMBER;
- f_line(argvars, &retvar);
- lnum = retvar.vval.v_number;
- clear_vartv(&retvar);
+ rettv.v_type = VAR_NUMBER;
+ f_line(argvars, &rettv);
+ lnum = rettv.vval.v_number;
+ clear_tv(&rettv);
}
return lnum;
}
@@ -9769,16 +10001,16 @@ get_vartv_lnum(argvars)
* Never returns NULL;
*/
static char_u *
-get_vartv_string(varp)
+get_tv_string(varp)
typeval *varp;
{
static char_u mybuf[NUMBUFLEN];
- return get_vartv_string_buf(varp, mybuf);
+ return get_tv_string_buf(varp, mybuf);
}
static char_u *
-get_vartv_string_buf(varp, buf)
+get_tv_string_buf(varp, buf)
typeval *varp;
char_u *buf;
{
@@ -9798,7 +10030,7 @@ get_vartv_string_buf(varp, buf)
return varp->vval.v_string;
break;
default:
- EMSG(_("E999: Internal error: get_vartv_string_buf()"));
+ EMSG2(_(e_intern2), "get_tv_string_buf()");
break;
}
return (char_u *)"";
@@ -9971,7 +10203,7 @@ clear_var(v)
{
vim_free(v->v_name);
v->v_name = NULL;
- clear_vartv(&v->tv);
+ clear_tv(&v->tv);
}
/*
@@ -10046,15 +10278,15 @@ list_one_var_a(prefix, name, type, string)
}
/*
- * Set variable "name" to value in "varp".
+ * Set variable "name" to value in "tv".
* If the variable already exists, the value is updated.
* Otherwise the variable is created.
*/
static void
-set_var(name, varp, copy)
+set_var(name, tv, copy)
char_u *name;
- typeval *varp;
- int copy; /* make copy of value in "varp" */
+ typeval *tv;
+ int copy; /* make copy of value in "tv" */
{
int i;
VAR v;
@@ -10076,22 +10308,22 @@ set_var(name, varp, copy)
if (vimvars[i].type == VAR_STRING)
{
vim_free(vimvars[i].val);
- if (copy || varp->v_type != VAR_STRING)
- vimvars[i].val = vim_strsave(get_vartv_string(varp));
+ if (copy || tv->v_type != VAR_STRING)
+ vimvars[i].val = vim_strsave(get_tv_string(tv));
else
{
/* Take over the string to avoid an extra alloc/free. */
- vimvars[i].val = varp->vval.v_string;
- varp->vval.v_string = NULL;
+ vimvars[i].val = tv->vval.v_string;
+ tv->vval.v_string = NULL;
}
}
else
- vimvars[i].val = (char_u *)get_vartv_number(varp);
+ vimvars[i].val = (char_u *)get_tv_number(tv);
}
return;
}
- if (varp->v_type == VAR_FUNC)
+ if (tv->v_type == VAR_FUNC)
{
if (!(vim_strchr((char_u *)"wbs", name[0]) != NULL && name[1] == ':')
&& !ASCII_ISUPPER((name[0] != NUL && name[1] == ':')
@@ -10110,17 +10342,16 @@ set_var(name, varp, copy)
v = find_var(name, TRUE);
if (v != NULL) /* existing variable, only need to free string */
{
- if (v->tv.v_type != varp->v_type
+ if (v->tv.v_type != tv->v_type
&& !((v->tv.v_type == VAR_STRING
|| v->tv.v_type == VAR_NUMBER)
- && (varp->v_type == VAR_STRING
- || varp->v_type == VAR_NUMBER)))
+ && (tv->v_type == VAR_STRING
+ || tv->v_type == VAR_NUMBER)))
{
EMSG2(_("E999: Variable type mismatch for: %s"), name);
return;
}
- if (v->tv.v_type == VAR_STRING || v->tv.v_type == VAR_FUNC)
- vim_free(v->tv.vval.v_string);
+ clear_tv(&v->tv);
}
else /* add a new variable */
{
@@ -10147,13 +10378,12 @@ set_var(name, varp, copy)
if (i == gap->ga_len)
++gap->ga_len;
}
- if (copy || (varp->v_type != VAR_STRING && varp->v_type != VAR_FUNC))
- copy_vartv(varp, &v->tv);
+ if (copy || tv->v_type == VAR_NUMBER)
+ copy_tv(tv, &v->tv);
else
{
- v->tv.v_type = varp->v_type;
- v->tv.vval.v_string = varp->vval.v_string;
- varp->vval.v_string = NULL;
+ v->tv = *tv;
+ init_tv(tv);
}
}
@@ -10163,7 +10393,7 @@ set_var(name, varp, copy)
* Does not make a copy of a list!
*/
static void
-copy_vartv(from, to)
+copy_tv(from, to)
typeval *from;
typeval *to;
{
@@ -10190,7 +10420,7 @@ copy_vartv(from, to)
}
break;
default:
- EMSG(_("E999: Internal error: copy_vartv()"));
+ EMSG2(_(e_intern2), "copy_tv()");
break;
}
}
@@ -10205,7 +10435,7 @@ ex_echo(eap)
exarg_T *eap;
{
char_u *arg = eap->arg;
- typeval retvar;
+ typeval rettv;
char_u *tofree;
char_u *p;
int needclr = TRUE;
@@ -10216,7 +10446,7 @@ ex_echo(eap)
while (*arg != NUL && *arg != '|' && *arg != '\n' && !got_int)
{
p = arg;
- if (eval1(&arg, &retvar, !eap->skip) == FAIL)
+ if (eval1(&arg, &rettv, !eap->skip) == FAIL)
{
/*
* Report the invalid expression unless the expression evaluation
@@ -10239,7 +10469,7 @@ ex_echo(eap)
}
else if (eap->cmdidx == CMD_echo)
msg_puts_attr((char_u *)" ", echo_attr);
- for (p = tv2string(&retvar, &tofree); *p != NUL && !got_int; ++p)
+ for (p = tv2string(&rettv, &tofree); *p != NUL && !got_int; ++p)
if (*p == '\n' || *p == '\r' || *p == TAB)
{
if (*p != TAB && needclr)
@@ -10266,7 +10496,7 @@ ex_echo(eap)
}
vim_free(tofree);
}
- clear_vartv(&retvar);
+ clear_tv(&rettv);
arg = skipwhite(arg);
}
eap->nextcmd = check_nextcmd(arg);
@@ -10311,7 +10541,7 @@ ex_execute(eap)
exarg_T *eap;
{
char_u *arg = eap->arg;
- typeval retvar;
+ typeval rettv;
int ret = OK;
char_u *p;
garray_T ga;
@@ -10325,7 +10555,7 @@ ex_execute(eap)
while (*arg != NUL && *arg != '|' && *arg != '\n')
{
p = arg;
- if (eval1(&arg, &retvar, !eap->skip) == FAIL)
+ if (eval1(&arg, &rettv, !eap->skip) == FAIL)
{
/*
* Report the invalid expression unless the expression evaluation
@@ -10340,11 +10570,11 @@ ex_execute(eap)
if (!eap->skip)
{
- p = get_vartv_string(&retvar);
+ p = get_tv_string(&rettv);
len = (int)STRLEN(p);
if (ga_grow(&ga, len + 2) == FAIL)
{
- clear_vartv(&retvar);
+ clear_tv(&rettv);
ret = FAIL;
break;
}
@@ -10354,7 +10584,7 @@ ex_execute(eap)
ga.ga_len += len;
}
- clear_vartv(&retvar);
+ clear_tv(&rettv);
arg = skipwhite(arg);
}
@@ -10432,9 +10662,7 @@ ex_function(eap)
char_u *theline;
int j;
int c;
-#ifdef FEAT_MAGIC_BRACES
int saved_did_emsg;
-#endif
char_u *name = NULL;
char_u *p;
char_u *arg;
@@ -10476,12 +10704,10 @@ ex_function(eap)
else
eap->skip = TRUE;
}
-#ifdef FEAT_MAGIC_BRACES
/* An error in a function call during evaluation of an expression in magic
* braces should not cause the function not to be defined. */
saved_did_emsg = did_emsg;
did_emsg = FALSE;
-#endif
/*
* ":function func" with only function name: list function.
@@ -10784,9 +11010,7 @@ ex_function(eap)
fp->flags = flags;
fp->calls = 0;
fp->script_ID = current_SID;
-#ifdef FEAT_MAGIC_BRACES
did_emsg |= saved_did_emsg;
-#endif
vim_free(skip_until);
return;
@@ -10796,9 +11020,7 @@ erret:
ga_clear_strings(&newlines);
erret_name:
vim_free(name);
-#ifdef FEAT_MAGIC_BRACES
did_emsg |= saved_did_emsg;
-#endif
}
/*
@@ -10826,14 +11048,13 @@ trans_function_name(pp, skip, internal)
lead = eval_fname_script(start);
if (lead > 0)
start += lead;
- end = find_name_end(start, &expr_start, &expr_end);
+ end = find_name_end(start, &expr_start, &expr_end, FALSE);
if (end == start)
{
if (!skip)
EMSG(_("E129: Function name required"));
return NULL;
}
-#ifdef FEAT_MAGIC_BRACES
if (expr_start != NULL && !skip)
{
/* expand magic curlies */
@@ -10855,7 +11076,6 @@ trans_function_name(pp, skip, internal)
len = (int)STRLEN(temp_string);
}
else
-#endif
len = (int)(end - start);
/*
@@ -11129,11 +11349,11 @@ ex_delfunction(eap)
* Call a user function.
*/
static void
-call_user_func(fp, argcount, argvars, retvar, firstline, lastline)
+call_user_func(fp, argcount, argvars, rettv, firstline, lastline)
ufunc_T *fp; /* pointer to function */
int argcount; /* nr of args */
typeval *argvars; /* arguments */
- typeval *retvar; /* return value */
+ typeval *rettv; /* return value */
linenr_T firstline; /* first line of range */
linenr_T lastline; /* last line of range */
{
@@ -11149,8 +11369,8 @@ call_user_func(fp, argcount, argvars, retvar, firstline, lastline)
if (depth >= p_mfd)
{
EMSG(_("E132: Function call depth is higher than 'maxfuncdepth'"));
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = -1;
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = -1;
return;
}
++depth;
@@ -11162,8 +11382,8 @@ call_user_func(fp, argcount, argvars, retvar, firstline, lastline)
fc.func = fp;
fc.argcount = argcount;
fc.argvars = argvars;
- fc.retvar = retvar;
- retvar->vval.v_number = 0;
+ fc.rettv = rettv;
+ rettv->vval.v_number = 0;
fc.linenr = 0;
fc.returned = FALSE;
fc.level = ex_nesting_level;
@@ -11216,7 +11436,7 @@ call_user_func(fp, argcount, argvars, retvar, firstline, lastline)
msg_outnum((long)argvars[i].vval.v_number);
else
{
- trunc_string(get_vartv_string(&argvars[i]),
+ trunc_string(get_tv_string(&argvars[i]),
buf, MSG_BUF_LEN);
msg_puts((char_u *)"\"");
msg_puts(buf);
@@ -11242,11 +11462,11 @@ call_user_func(fp, argcount, argvars, retvar, firstline, lastline)
--RedrawingDisabled;
/* when the function was aborted because of an error, return -1 */
- if ((did_emsg && (fp->flags & FC_ABORT)) || retvar->v_type == VAR_UNKNOWN)
+ if ((did_emsg && (fp->flags & FC_ABORT)) || rettv->v_type == VAR_UNKNOWN)
{
- clear_vartv(retvar);
- retvar->v_type = VAR_NUMBER;
- retvar->vval.v_number = -1;
+ clear_tv(rettv);
+ rettv->v_type = VAR_NUMBER;
+ rettv->vval.v_number = -1;
}
/* when being verbose, mention the return value */
@@ -11264,12 +11484,12 @@ call_user_func(fp, argcount, argvars, retvar, firstline, lastline)
if (aborting())
smsg((char_u *)_("%s aborted"), sn);
- else if (fc.retvar->v_type == VAR_NUMBER)
+ else if (fc.rettv->v_type == VAR_NUMBER)
smsg((char_u *)_("%s returning #%ld"), sn,
- (long)fc.retvar->vval.v_number);
- else if (fc.retvar->v_type == VAR_STRING)
+ (long)fc.rettv->vval.v_number);
+ else if (fc.rettv->v_type == VAR_STRING)
{
- val = get_vartv_string(fc.retvar);
+ val = get_tv_string(fc.rettv);
if (STRLEN(val) > IOSIZE / 2 - 50)
val = val + STRLEN(val) - (IOSIZE / 2 - 50);
smsg((char_u *)_("%s returning \"%s\""), sn, val);
@@ -11309,7 +11529,7 @@ ex_return(eap)
exarg_T *eap;
{
char_u *arg = eap->arg;
- var retvar;
+ typeval rettv;
int returning = FALSE;
if (current_funccal == NULL)
@@ -11323,12 +11543,12 @@ ex_return(eap)
eap->nextcmd = NULL;
if ((*arg != NUL && *arg != '|' && *arg != '\n')
- && eval0(arg, &retvar, &eap->nextcmd, !eap->skip) != FAIL)
+ && eval0(arg, &rettv, &eap->nextcmd, !eap->skip) != FAIL)
{
if (!eap->skip)
- returning = do_return(eap, FALSE, TRUE, &retvar);
+ returning = do_return(eap, FALSE, TRUE, &rettv);
else
- clear_vartv(&retvar.tv);
+ clear_tv(&rettv);
}
/* It's safer to return also on error. */
else if (!eap->skip)
@@ -11357,16 +11577,16 @@ ex_return(eap)
* Return from a function. Possibly makes the return pending. Also called
* for a pending return at the ":endtry" or after returning from an extra
* do_cmdline(). "reanimate" is used in the latter case. "is_cmd" is set
- * when called due to a ":return" command. "value" may point to a variable
- * with the return value. Returns TRUE when the return can be carried out,
+ * when called due to a ":return" command. "rettv" may point to a typeval
+ * with the return rettv. Returns TRUE when the return can be carried out,
* FALSE when the return gets pending.
*/
int
-do_return(eap, reanimate, is_cmd, value)
+do_return(eap, reanimate, is_cmd, rettv)
exarg_T *eap;
int reanimate;
int is_cmd;
- void *value;
+ void *rettv;
{
int idx;
struct condstack *cstack = eap->cstack;
@@ -11387,38 +11607,38 @@ do_return(eap, reanimate, is_cmd, value)
cstack->cs_pending[idx] = CSTP_RETURN;
if (!is_cmd && !reanimate)
- /* A pending return again gets pending. "value" points to an
- * allocated variable with the value of the original ":return"'s
+ /* A pending return again gets pending. "rettv" points to an
+ * allocated variable with the rettv of the original ":return"'s
* argument if present or is NULL else. */
- cstack->cs_retvar[idx] = value;
+ cstack->cs_rettv[idx] = rettv;
else
{
/* When undoing a return in order to make it pending, get the stored
- * return value. */
+ * return rettv. */
if (reanimate)
- value = current_funccal->retvar;
+ rettv = current_funccal->rettv;
- if (value != NULL)
+ if (rettv != NULL)
{
/* Store the value of the pending return. */
- if ((cstack->cs_retvar[idx] = alloc_var()) != NULL)
- *(typeval *)cstack->cs_retvar[idx] = *(typeval *)value;
+ if ((cstack->cs_rettv[idx] = alloc_tv()) != NULL)
+ *(typeval *)cstack->cs_rettv[idx] = *(typeval *)rettv;
else
EMSG(_(e_outofmem));
}
else
- cstack->cs_retvar[idx] = NULL;
+ cstack->cs_rettv[idx] = NULL;
if (reanimate)
{
/* The pending return value could be overwritten by a ":return"
* without argument in a finally clause; reset the default
* return value. */
- current_funccal->retvar->v_type = VAR_NUMBER;
- current_funccal->retvar->vval.v_number = 0;
+ current_funccal->rettv->v_type = VAR_NUMBER;
+ current_funccal->rettv->vval.v_number = 0;
}
}
- report_make_pending(CSTP_RETURN, value);
+ report_make_pending(CSTP_RETURN, rettv);
}
else
{
@@ -11427,12 +11647,12 @@ do_return(eap, reanimate, is_cmd, value)
/* If the return is carried out now, store the return value. For
* a return immediately after reanimation, the value is already
* there. */
- if (!reanimate && value != NULL)
+ if (!reanimate && rettv != NULL)
{
- clear_vartv(current_funccal->retvar);
- *current_funccal->retvar = *(typeval *)value;
+ clear_tv(current_funccal->rettv);
+ *current_funccal->rettv = *(typeval *)rettv;
if (!is_cmd)
- vim_free(value);
+ vim_free(rettv);
}
}
@@ -11443,34 +11663,34 @@ do_return(eap, reanimate, is_cmd, value)
* Free the variable with a pending return value.
*/
void
-discard_pending_return(retvar)
- void *retvar;
+discard_pending_return(rettv)
+ void *rettv;
{
- /* The variable was copied from one with an undefined v_name. So we can't
- * use free_vartv() to clear and free it. */
- clear_vartv(&((VAR)retvar)->tv);
- vim_free(retvar);
+ free_tv((typeval *)rettv);
}
/*
- * Generate a return command for producing the value of "retvar". The result
+ * Generate a return command for producing the value of "rettv". The result
* is an allocated string. Used by report_pending() for verbose messages.
*/
char_u *
-get_return_cmd(retvar)
- void *retvar;
+get_return_cmd(rettv)
+ void *rettv;
{
- char_u *s = IObuff;
+ char_u *s;
+ char_u *tofree = NULL;
- if (retvar == NULL || ((VAR)retvar)->tv.v_type == VAR_UNKNOWN)
- s = (char_u *)":return";
- else if (((VAR)retvar)->tv.v_type == VAR_STRING)
- sprintf((char *)IObuff, ":return \"%s\"",
- ((VAR)retvar)->tv.vval.v_string);
+ if (rettv == NULL)
+ s = (char_u *)"";
else
- sprintf((char *)IObuff, ":return %ld",
- (long)(((VAR)retvar)->tv.vval.v_number));
- return vim_strsave(s);
+ s = tv2string((typeval *)rettv, &tofree);
+
+ STRCPY(IObuff, ":return ");
+ STRNCPY(IObuff + 8, s, IOSIZE - 8);
+ if (STRLEN(s) + 8 >= IOSIZE)
+ STRCPY(IObuff + IOSIZE - 4, "...");
+ vim_free(tofree);
+ return vim_strsave(IObuff);
}
/*
@@ -11586,7 +11806,7 @@ read_viminfo_varlist(virp, writing)
{
char_u *tab;
int is_string = FALSE;
- typeval *vartvp = NULL;
+ typeval *tvp = NULL;
char_u *val;
if (!writing && (find_viminfo_parameter('!') != NULL))
@@ -11601,28 +11821,28 @@ read_viminfo_varlist(virp, writing)
tab = vim_strchr(tab, '\t');
if (tab != NULL)
{
- /* create a nameless variable to hold the value */
+ /* create a typeval to hold the value */
if (is_string)
{
val = viminfo_readstring(virp,
(int)(tab - virp->vir_line + 1), TRUE);
if (val != NULL)
- vartvp = alloc_string_vartv(val);
+ tvp = alloc_string_tv(val);
}
else
{
- vartvp = alloc_vartv();
- if (vartvp != NULL)
+ tvp = alloc_tv();
+ if (tvp != NULL)
{
- vartvp->v_type = VAR_NUMBER;
- vartvp->vval.v_number = atol((char *)tab + 1);
+ tvp->v_type = VAR_NUMBER;
+ tvp->vval.v_number = atol((char *)tab + 1);
}
}
/* assign the value to the variable */
- if (vartvp != NULL)
+ if (tvp != NULL)
{
- set_var(virp->vir_line + 1, vartvp, FALSE);
- free_vartv(vartvp);
+ set_var(virp->vir_line + 1, tvp, FALSE);
+ free_tv(tvp);
}
}
}
@@ -11641,6 +11861,8 @@ write_viminfo_varlist(fp)
garray_T *gap = &variables; /* global variable */
VAR this_var;
int i;
+ char *s;
+ char_u *tofree;
if (find_viminfo_parameter('!') == NULL)
return;
@@ -11652,9 +11874,19 @@ write_viminfo_varlist(fp)
if (this_var->v_name != NULL
&& var_flavour(this_var->v_name) == VAR_FLAVOUR_VIMINFO)
{
- fprintf(fp, "!%s\t%s\t", this_var->v_name,
- (this_var->tv.v_type == VAR_STRING) ? "STR" : "NUM");
- viminfo_writestring(fp, get_var_string(this_var));
+ switch (this_var->tv.v_type)
+ {
+ case VAR_STRING: s = "STR"; break;
+ case VAR_NUMBER: s = "NUM"; break;
+ case VAR_LIST: s = "LST"; break;
+ case VAR_FUNC: s = "FUN"; break;
+ default:
+ EMSGN(_("E999: Internal error: write_viminfo_varlist(): %ld"), (long)this_var->tv.v_type);
+ s = "ERR";
+ }
+ fprintf(fp, "!%s\t%s\t", this_var->v_name, s);
+ viminfo_writestring(fp, tv2string(&this_var->tv, &tofree));
+ vim_free(tofree);
}
}
}
diff --git a/src/gui_amiga.c b/src/gui_amiga.c
deleted file mode 100644
index 0b76245f..00000000
--- a/src/gui_amiga.c
+++ /dev/null
@@ -1,1812 +0,0 @@
-/* vi:set ts=8 sts=4 sw=4:
- *
- * VIM - Vi IMproved by Bram Moolenaar
- * Amiga GUI support by Michael Nielsen
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <exec/types.h>
-#include <intuition/intuition.h>
-#include <utility/tagitem.h>
-#include <graphics/text.h>
-#include <graphics/rastport.h>
-#include <graphics/layers.h>
-#include <proto/intuition.h>
-#include <proto/graphics.h>
-#include <proto/layers.h>
-#include <devices/timer.h>
-#include <assert.h>
-#include "vim.h"
-#include "gui_amiga.h"
-#include <math.h>
-#include <limits.h>
-
-#ifdef __AROS__
-#include <aros/debug.h>
-#endif
-
-#include "version.h"
-
-#if defined(FEAT_GUI_AMIGA) || defined(PROTO)
-
-#define KEYUP 76
-#define KEYDOWN 77
-#define KEYRIGHT 78
-#define KEYLEFT 79
-#define KEYBACKSPACE 0x41
-#define KEYDELETE 0x46
-#define KEYINSERT 0x47
-#define KEYHOME 0x70
-#define KEYEND 0x71
-#define KEYWHEELUP 0x7A
-#define KEYWHEELDOWN 0x7B
-
-/* When generating prototypes on Unix, these need to be defined */
-#ifdef PROTO
-# define STRPTR char *
-# define BOOL int
-# define UBYTE int
-#endif
-
-static struct PropInfo Gadget2SInfo = { AUTOKNOB+PROPBORDERLESS+FREEVERT+PROPNEWLOOK, 0, 0, MAXBODY, MAXBODY, };
-//static struct Image Image1 = { 0, 0, 10, 397, 0, NULL, 0x0000, 0x0000, NULL };
-static struct Gadget propGadget = { NULL, -12, 15, 10, -28,
- GFLG_RELRIGHT+GFLG_RELHEIGHT,
- GACT_RELVERIFY+GACT_RIGHTBORDER+GACT_IMMEDIATE,
- GTYP_PROPGADGET+GTYP_GZZGADGET,
- NULL, NULL,
- NULL, NULL, (APTR)&Gadget2SInfo, NULL, NULL };
-
-static struct timerequest *TimerIO;
-static struct MsgPort *TimerMP;
-static BOOL TimerSent;
-
-struct GFXBase *gfxBase;
-struct ExecBase *execBase;
-struct LayersBase *layersBase;
-
-struct MyColor
-{
- WORD pen;
- BOOL alloced;
-};
-
-struct MyColor MyColorTable[256];
-
-struct TagItem tags[] =
-{
- {WA_Left, 0},
- {WA_Top, 0},
- {WA_Width, 400},
- {WA_Height, 400},
- {WA_Title, (ULONG)VIM_VERSION_SHORT},
- {WA_ScreenTitle, (ULONG)VIM_VERSION_LONG},
- {WA_DragBar, TRUE}, /* enable dragging of the window */
- {WA_DepthGadget, TRUE}, /* enable the depth gadget */
- {WA_CloseGadget, TRUE}, /* enable the close gadget*/
- {WA_SizeGadget, TRUE}, /* enable the size gadget */
- {WA_SizeBBottom, TRUE}, /* sizegadget contained in bottom border */
- {WA_SmartRefresh, TRUE}, /* choose smart refresh, saves us doing a lot of work */
- {WA_ReportMouse, TRUE}, /* Report the position of the mouse */
- {WA_GimmeZeroZero, TRUE},
- {WA_Activate, TRUE}, /* Activate window on startup */
- {WA_Activate, TRUE}, /* Activate window on startup */
- {WA_NoCareRefresh, TRUE}, /* Refresh screen, don't tell us */
- {WA_NewLookMenus, TRUE}, /* use the new options for the menu */
- {WA_AutoAdjust, TRUE}, /* If window is too big for screen adjust size*/
- {WA_NoCareRefresh, TRUE}, /* If window is too big for screen adjust size*/
- {WA_MouseQueue, 1}, /* Limit number of pending mouse movement*/
- {WA_RptQueue, 10}, /* Limit number of pending keystrokes*/
- {WA_IDCMP, /* IDCMP, what events interest us */
- IDCMP_NEWSIZE /* Notify us about size change of window*/
- |IDCMP_REFRESHWINDOW /* Notify us when the window needs refreshing */
- |IDCMP_MOUSEBUTTONS /* Notify us when the mouse buttons have been used */
- |IDCMP_MOUSEMOVE /* Notify us when the mouse is moving */
- |IDCMP_GADGETDOWN /* Notify us when a gadget has been selected */
- |IDCMP_GADGETUP /* Notify us when a gadget has been released */
- |IDCMP_MENUPICK /* Notify us when a menu has been picked */
- |IDCMP_CLOSEWINDOW /* Notify us when the user tries to close the window */
- |IDCMP_VANILLAKEY /* Notify us about keystrokes */
- |IDCMP_RAWKEY /* Notify us when raw key events have been used, ie cursor*/
- |IDCMP_INTUITICKS /* Simpler timer for the blink option */
- |IDCMP_MENUHELP /* Allow the help key to be used during menu events */
- |IDCMP_GADGETHELP /* Allow the help key to be used during gadget events */
- |IDCMP_INACTIVEWINDOW /* notify of inactive window */
- |IDCMP_ACTIVEWINDOW /* notify of inactive window */
- },
- {TAG_DONE, NULL}
-};
-
-#if defined(D)
-#undef D
-#endif
-
-/*#define D(_msg) fprintf(stderr, "%s\n", _msg)*/
-
-#define D(_A)
-#define kprintf(s, ...)
-
-static void AmigaError(const char *string);
-
-void HandleEvent(unsigned long * object);
-static UBYTE getrealcolor(guicolor_T i);
-
-static struct NewWindow vimNewWindow =
-{
- 0, 0, /* window XY origin relative to TopLeft of screen */
- 0, 0, /* window width and height */
- 0, 1, /* detail and block pens */
- NULL, /* IDCMP flags */
- NULL, /* other window flags */
- &propGadget, /* first gadget in gadget list */
- NULL, /* custom CHECKMARK imagery */
- "Amiga Vim gui", /* window title */
- NULL, /* custom screen pointer */
- NULL, /* custom bitmap */
- 50, 50, /* minimum width and height */
- (unsigned short)-1, (unsigned short)-1, /* maximum width and height */
- WBENCHSCREEN /* destination screen type */
-};
-
-static struct
-{
- unsigned int key_sym;
- char_u vim_code0;
- char_u vim_code1;
-} special_keys[] =
-{
- {0, 0, 0}
-};
-
-#if 0
- /* not used? */
- static int
-hex_digit(int c)
-{
- if (isdigit(c))
- return c - '0';
- c = TOLOWER_ASC(c);
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- return -1000;
-}
-#endif
-
-static int characterWidth = -1;
-static int characterHeight = -1;
-static struct
-{
- BOOL active;
- enum
- {
- CursorOff,
- CursorOn,
- CursorWait
- } state;
- int onTime;
- int offTime;
- int waitTime;
- int current;
-} cursor =
-{
- TRUE,
- CursorWait,
- 10,
- 10,
- 7,
- 0
-};
-
-enum DrawBoxMode
-{
- DB_Filled,
- DB_NotFilled
-};
-
- static void
-TextDimensions(void)
-{
- struct TextExtent textExt;
-
- TextExtent(gui.window->RPort, "s", 1, &textExt);
-
- characterWidth = textExt.te_Width;
- characterHeight = textExt.te_Height;
-}
-
- static int
-posWidthCharToPoint(int width)
-{
- return (width)*characterWidth;
-}
-
- static int
-posHeightCharToPoint(int height)
-{
- return (int)(height)*characterHeight;
-}
-
- static int
-posWidthPointToChar(int width)
-{
- //return (int)floor((float)width/(float)characterWidth)-1;
- return width /characterWidth;
-}
-
- static int
-posHeightPointToChar(int height)
-{
- //return (int)floor((float)height/(float)characterHeight)-2;
- return height / characterHeight;
-}
-
- static int
-widthCharToPoint(int width)
-{
- return (width)*(characterWidth);
-}
-
- static int
-heightCharToPoint(int height)
-{
- return (height)*characterHeight;
-}
-
- static int
-widthPointToChar(int width)
-{
- return (width)/characterWidth;
-}
-
- static int
-heightPointToChar(int height)
-{
- return (height)/characterHeight;
-}
-
- static void
-refreshBorder(void)
-{
- /*WaitBOVP(gui.window->);*/
- RefreshWindowFrame(gui.window);
-}
-
- static void
-drawBox(enum DrawBoxMode mode, unsigned short col, unsigned short row, int w, int h, guicolor_T color)
-{
- LONG apen = GetAPen(gui.window->RPort);
- LONG x1, y1, x2, y2;
-
-kprintf(" drawbox %d,%d color %d\n", col, row, color);
-
- SetAPen(gui.window->RPort, getrealcolor(color));
-
- x1 = posWidthCharToPoint(col);
- y1 = posHeightCharToPoint(row + 1) - h;
- x2 = x1 + w - 1;
- y2 = posHeightCharToPoint(row + 1) - 1;
-
- switch(mode)
- {
- case DB_Filled:
- RectFill(gui.window->RPort, x1, y1, x2, y2);
- break;
-
- case DB_NotFilled:
- Move(gui.window->RPort, x1, y1);
- Draw(gui.window->RPort, x2, y1);
- Draw(gui.window->RPort, x2, y2);
- Draw(gui.window->RPort, x1, y2);
- Draw(gui.window->RPort, x1, y1);
- break;
- }
-
- SetAPen(gui.window->RPort, apen);
-
-}
-
- static enum event
-EventHandler(void)
-{
- struct IntuiMessage *msg;
- enum event returnEvent = ev_Ignore;
- int class, code;
- static int dragging = 0;
- static int mouseX, mouseY;
- char_u string[40];
- BOOL quit_request = FALSE;
-
- msg = (struct IntuiMessage *)GetMsg(gui.window->UserPort);
-
- if (!msg)
- {
- returnEvent = ev_NullEvent;
- }
- else
- {
-
- class = msg->Class;
- code = msg->Code;
-
- switch(class)
- {
- case IDCMP_INTUITICKS:
- /*
- if (cursor.active)
- {
- cursor.current ++;
- if (cursor.state == CursorOff)
- {
- printf("cursor turned on\n");
- if (cursor.offTime < cursor.current)
- {
- gui_undraw_cursor();
- cursor.state = CursorOn;
- cursor.current = 0;
- }
- }
- else if (cursor.state == CursorOn)
- {
- printf("cursor turned off\n");
- if (cursor.onTime < cursor.current)
- {
- cursor.state = CursorOff;
- gui_update_cursor(FALSE);
- cursor.current = 0;
- }
- }
- else if (cursor.state == CursorWait)
- {
- printf("cursor turned Wait\n");
- if (cursor.waitTime < cursor.current)
- {
- cursor.state = CursorOn;
- cursor.current = 0;
- }
- }
- }
- else
- {
- }
- returnEvent = ev_IntuiTicks;
- */
- break;
-
- case IDCMP_MOUSEBUTTONS:
- {
- int vim_modifiers=0;
- D("Mouse button event detected");
- switch (msg->Qualifier )
- {
- case IEQUALIFIER_LALT:
- case IEQUALIFIER_RALT:
- D("detected a Alt key");
- vim_modifiers|=MOUSE_ALT;
- break;
-
- case IEQUALIFIER_LSHIFT:
- case IEQUALIFIER_RSHIFT:
- D("detected a Shift key");
- vim_modifiers|=MOUSE_SHIFT;
- break;
- case IEQUALIFIER_CONTROL:
- D("detected a Control key");
- vim_modifiers |= MOUSE_CTRL;
- break;
- }
- if (code == SELECTDOWN)
- {
- D("Select Down detected\n");
- dragging = 1;
- gui_send_mouse_event(MOUSE_LEFT,
- mouseX = msg->MouseX - gui.window->BorderLeft,
- mouseY = msg->MouseY - gui.window->BorderTop,
- FALSE,
- vim_modifiers);
- /*gui_start_highlight(HL_ALL);*/
- }
- else if (code == SELECTUP)
- {
- D("Select UP detected\n");
- dragging = 0;
- gui_send_mouse_event(MOUSE_RELEASE,
- msg->MouseX - gui.window->BorderLeft,
- msg->MouseY - gui.window->BorderTop,
- FALSE, vim_modifiers);
- /*gui_stop_highlight(mask);*/
- }
- returnEvent = ev_MouseButtons;
- break;
- }
- case IDCMP_MOUSEMOVE:
- if ((abs(mouseX-(msg->MouseX - gui.window->BorderLeft)) > characterWidth) ||
- (abs(mouseY-(msg->MouseY - gui.window->BorderTop))>characterHeight))
- {
- int vim_modifiers=0;
-
- switch (msg->Qualifier )
- {
- case IEQUALIFIER_LALT:
- case IEQUALIFIER_RALT:
- D("detected a Alt key");
- vim_modifiers|=MOUSE_ALT;
- break;
-
- case IEQUALIFIER_LSHIFT:
- case IEQUALIFIER_RSHIFT:
- D("detected a Shift key");
- vim_modifiers|=MOUSE_SHIFT;
- break;
- case IEQUALIFIER_CONTROL:
- D("detected a Control key");
- vim_modifiers |= MOUSE_CTRL;
- break;
- }
-
- mouseX = msg->MouseX - gui.window->BorderLeft;
- mouseY = msg->MouseY - gui.window->BorderTop;
- if (!dragging)
- {
- gui_send_mouse_event(MOUSE_SETPOS, mouseX, mouseY, FALSE, vim_modifiers);
- break;
- }
- else
- {
- D("dragging\n");
- gui_send_mouse_event(MOUSE_DRAG, mouseX, mouseY, FALSE, vim_modifiers);
- }
- }
- returnEvent = ev_MouseMove;
- break;
- case IDCMP_VANILLAKEY:
-kprintf("===vanillakey %d\n", code);
- {
- string[0] = (char_u)code;
- if (code == CSI)
- {
- /* Insert CSI as K_CSI. Untested! */
- string[1] = KS_EXTRA;
- string[2] = (int)KE_CSI;
- add_to_input_buf(string, 3);
- }
- else if (code == 8)
- {
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'b';
- add_to_input_buf(string, 3);
- }
- else if (code == 127)
- {
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'D';
- add_to_input_buf(string, 3);
- }
- else
- {
- int len = 1;
-
- if (input_conv.vc_type != CONV_NONE)
- len = convert_input(string, 1, sizeof(string));
- add_to_input_buf(string, len);
- }
- returnEvent = ev_KeyStroke;
- break;
-
- case IDCMP_RAWKEY:
- if (msg->Qualifier & IEQUALIFIER_LSHIFT)
- {
- }
- else if (msg->Qualifier & IEQUALIFIER_RSHIFT)
- {
- }
- else if (msg->Qualifier & IEQUALIFIER_CONTROL)
- {
- if (code == 33)
- {
- trash_input_buf();
- }
- }
- else if (msg->Code == KEYUP)
- {
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'u';
- add_to_input_buf(string, 3);
- }
- else if (msg->Code == KEYLEFT)
- {
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'l';
- add_to_input_buf(string, 3);
- }
- else if (msg->Code == KEYRIGHT)
- {
-kprintf("## keyright");
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'r';
- add_to_input_buf(string, 3);
- }
- else if (msg->Code == KEYDOWN)
- {
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'd';
- add_to_input_buf(string, 3);
- }
- else if (msg->Code == KEYBACKSPACE)
- {
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'b';
- add_to_input_buf(string, 3);
- }
- else if (msg->Code == KEYDELETE)
- {
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'D';
- add_to_input_buf(string, 3);
- }
- else if (msg->Code == KEYINSERT)
- {
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'I';
- add_to_input_buf(string, 3);
- }
- else if (msg->Code == KEYHOME)
- {
- string[0] = CSI;
- string[1] = 'k';
- string[2] = 'h';
- add_to_input_buf(string, 3);
- }
- else if (msg->Code == KEYEND)
- {
- string[0] = CSI;
- string[1] = '@';
- string[2] = '7';
- add_to_input_buf(string, 3);
- }
- else if (msg->Code == KEYWHEELUP)
- {
- int vim_modifiers=0;
-
- switch (msg->Qualifier )
- {
- case IEQUALIFIER_LALT:
- case IEQUALIFIER_RALT:
- D("detected a Alt key");
- vim_modifiers|=MOUSE_ALT;
- break;
-
- case IEQUALIFIER_LSHIFT:
- case IEQUALIFIER_RSHIFT:
- D("detected a Shift key");
- vim_modifiers|=MOUSE_SHIFT;
- break;
- case IEQUALIFIER_CONTROL:
- D("detected a Control key");
- vim_modifiers |= MOUSE_CTRL;
- break;
- }
- gui_send_mouse_event(MOUSE_4, 0, 1, FALSE, vim_modifiers);
-
- }
- else if (msg->Code == KEYWHEELDOWN)
- {
- int vim_modifiers=0;
-
- switch (msg->Qualifier )
- {
- case IEQUALIFIER_LALT:
- case IEQUALIFIER_RALT:
- D("detected a Alt key");
- vim_modifiers|=MOUSE_ALT;
- break;
-
- case IEQUALIFIER_LSHIFT:
- case IEQUALIFIER_RSHIFT:
- D("detected a Shift key");
- vim_modifiers|=MOUSE_SHIFT;
- break;
- case IEQUALIFIER_CONTROL:
- D("detected a Control key");
- vim_modifiers |= MOUSE_CTRL;
- break;
- }
- gui_send_mouse_event(MOUSE_5, 0, 1, FALSE, vim_modifiers);
- }
-
- returnEvent = ev_KeyStroke;
- break;
- }
- case IDCMP_MENUVERIFY:
- returnEvent = ev_MenuVerify;
- /* Menu verification requested */
- switch (code)
- {
- case MENUWAITING:
- /*
- ** It's not for us, the user is accessing another
- ** programs menu, this is a good time to do some
- ** cleanup etc
- */
- break;
- case MENUHOT:
- /*
- ** It is our menu that is going hot, we have kontrol
- ** Menu action can be cancelled by
- ** msg->Code = MENUCANCEL;
- */
- break;
- default:
- break;
- }
- break;
- case IDCMP_MENUPICK:
- returnEvent = ev_MenuPick;
- {
- /*
- ** one of our menu's have been selected, let's find out which
- */
- union myMenuItemUnion *item;
- int menuNumber;
-
- menuNumber = code;
-
- item = (union myMenuItemUnion *) ItemAddress(gui.menu, menuNumber);
-
-
- if (item)
- {
- gui_menu_cb(item->myMenuItem.guiMenu);
- }
- }
- break;
- case IDCMP_CLOSEWINDOW:
- quit_request = TRUE;
- break;
-
- case IDCMP_NEWSIZE:
- {
- int cx, cy;
- //cx = widthPointToChar(gui.window->GZZWidth);
- //cy = heightPointToChar(gui.window->GZZHeight);
-
- cx = gui.window->GZZWidth;
- cy = gui.window->GZZHeight - characterHeight;
-
- gui_resize_shell(cx, cy);
-
- returnEvent = ev_NewSize;
- break;
- }
- case IDCMP_REFRESHWINDOW:
- refreshBorder();
- returnEvent = ev_RefreshWindow;
- break;
- case IDCMP_GADGETDOWN:
- returnEvent = ev_GadgetDown;
- break;
- case IDCMP_GADGETUP:
- returnEvent = ev_GadgetUp;
- break;
- case IDCMP_MENUHELP:
- returnEvent = ev_MenuHelp;
- break;
- case IDCMP_GADGETHELP:
- returnEvent = ev_GadgetHelp;
- break;
- case IDCMP_INACTIVEWINDOW:
- gui.in_focus = FALSE;
- gui_update_cursor(TRUE, FALSE);
- break;
-
- case IDCMP_ACTIVEWINDOW:
- gui.in_focus = TRUE;
- gui_update_cursor(TRUE, FALSE);
- break;
- default:
- break;
- }
- ReplyMsg((struct Message*)msg);
- }
-
- if (quit_request)
- {
- getout(0); // gui_mch_exit(1);
- }
-
- return returnEvent;
- /* mouse positin gui.window->MoseY, gui.window->MouseX) */
-}
-
- static int
-checkEventHandler(void)
-{
- enum event happened;
-
- do
- {
- happened = EventHandler() ;
- }
- while (happened != ev_NullEvent);
-
- return OK;
-}
-
- static int
-charEventHandler(int wtime)
-{
- enum event happened;
- int rc;
-
- do
- {
- Wait(1<<gui.window->UserPort->mp_SigBit);
-
- happened = EventHandler() ;
- }
- while ((happened != ev_IntuiTicks) && (happened != ev_KeyStroke) && (happened != ev_MenuPick) && (happened != ev_MouseMove) &&(happened != ev_MouseButtons) );
-
- if (happened == ev_KeyStroke || happened == ev_MenuPick)
- rc = OK;
- else
- rc = FAIL;
-
- return rc;
-}
-
-
-/*
- * add primary menu
- */
- void
-gui_mch_add_menu_item(vimmenu_T *menu, int idx)
-{
- union myMenuItemUnion *menuItemUnion = NULL;
- struct IntuiText *menutext = NULL;
- vimmenu_T *parent;
-
- assert(menu != NULL);
- assert(menu->parent != NULL);
- parent = menu->parent;
-
- /* Don't add menu separator */
- if (menu_is_separator(menu->name))
- return;
-
- if (parent->menuItemPtr == NULL)
- return;
-
- /* TODO: use menu->mnemonic and menu->actext */
- menutext = (struct IntuiText *) malloc(sizeof(struct IntuiText));
-
- SetAttrib(menutext, FrontPen, 3);
- SetAttrib(menutext, BackPen, 1);
- SetAttrib(menutext, DrawMode, COMPLEMENT);
- SetAttrib(menutext, LeftEdge, 0);
- SetAttrib(menutext, TopEdge, 0);
- SetAttrib(menutext, ITextFont, NULL);
- SetAttrib(menutext, NextText, NULL);
-
- menuItemUnion = malloc(sizeof(*menuItemUnion));
-
- SetAttrib(&menuItemUnion->menuItem, NextItem, parent->menuItemPtr);
- SetAttrib(&menuItemUnion->menuItem, LeftEdge, 0);
- SetAttrib(&menuItemUnion->menuItem, Width, characterWidth*strlen(menu->dname));
- SetAttrib(&menuItemUnion->menuItem, Height, characterHeight+2);
- SetAttrib(&menuItemUnion->menuItem, Flags, ITEMTEXT+ITEMENABLED+HIGHCOMP);
- SetAttrib(&menuItemUnion->menuItem, MutualExclude, 0);
- SetAttrib(&menuItemUnion->menuItem, ItemFill, (APTR)menutext);
- SetAttrib(&menuItemUnion->menuItem, SelectFill, NULL);
- SetAttrib(&menuItemUnion->menuItem, Command, NULL);
- SetAttrib(&menuItemUnion->menuItem, SubItem, NULL);
- SetAttrib(&menuItemUnion->menuItem, NextSelect, MENUNULL);
-
- menutext->IText = malloc(strlen(menu->dname) + 1);
-
- strcpy(menutext->IText, menu->dname);
-
- menuItemUnion->menuItem.NextItem = NULL;
-
-
- if (parent)
- {
- if (!parent->menuItemPtr)
- {
- D("Adding first subElement");
- SetAttrib(&menuItemUnion->menuItem, TopEdge, 0);
- parent->menuPtr->FirstItem = &menuItemUnion->menuItem;
- parent->menuItemPtr = &menuItemUnion->menuItem;
- }
- else
- {
- struct MenuItem *tmpMenuItem;
- tmpMenuItem = parent->menuItemPtr;
- while (tmpMenuItem->NextItem)
- {
- tmpMenuItem = tmpMenuItem->NextItem;
- }
- tmpMenuItem->NextItem = &menuItemUnion->menuItem;
- SetAttrib(&menuItemUnion->menuItem, TopEdge, tmpMenuItem->TopEdge+tmpMenuItem->Height);
- }
- }
- menu->menuPtr= NULL;
- menu->menuItemPtr = &menuItemUnion->menuItem;
- menuItemUnion->myMenuItem.guiMenu = menu;
-}
-
-
- static struct Menu *
-getMenu(struct RastPort *rast, int left, STRPTR name)
-{
- struct Menu *menu;
- struct TextExtent textExt;
-
- menu = malloc(sizeof(*menu));
- menu->NextMenu = NULL;
- menu->LeftEdge = left;
-
- TextExtent(rast, name, strlen(name), &textExt);
-
- menu->TopEdge = 0;
- menu->Width = textExt.te_Width;
- menu->Height = textExt.te_Height;
- menu->Flags = ITEMTEXT+HIGHCOMP+MENUENABLED;
- menu->MenuName = name;
- menu->FirstItem = NULL;
-
- return menu;
-}
-
-/*
- * add 1st level submenu item
- */
- void
-gui_mch_add_menu(vimmenu_T *menu, int idx)
-{
- struct Menu *newMenu;
- int pos = 0;
-
- if (!menu_is_menubar(menu->name))
- return;
-
- menu->menuPtr = newMenu = getMenu(gui.window->RPort, 0, menu->dname);
- menu->menuItemPtr = NULL;
- newMenu->NextMenu = NULL;
-
- if (!gui.menu)
- {
- D("Adding head menu");
- gui.menu = newMenu ;
- }
- else
- {
- struct Menu *tmpMenu;
-
- tmpMenu = gui.menu;
- while (tmpMenu->NextMenu)
- tmpMenu = tmpMenu->NextMenu;
- tmpMenu->NextMenu = newMenu;
- pos = tmpMenu->LeftEdge +
- TextLength(gui.window->RPort, tmpMenu->MenuName,
- strlen(tmpMenu->MenuName));
- newMenu->LeftEdge = pos;
- }
-}
-
- void
-gui_mch_toggle_tearoffs(enable)
- int enable;
-{
- /* no tearoff menus */
-}
-
- int
-gui_mch_set_blinking(long wait, long on, long off)
-{
- cursor.waitTime = wait/100;
- cursor.onTime = on/100;
- cursor.offTime = off/100;
- return OK;
-}
-
- void
-gui_mch_prepare(int *argc, char **argv)
-{
- D("gui_mch_prepare");
-
- execBase = (struct ExecBase *)OpenLibrary("exec.library", NULL);
- gfxBase = (struct GFXBase *)OpenLibrary("graphics.library", NULL);
- layersBase = (struct LayersBase *)OpenLibrary("layers.library", NULL);
-
- if (!execBase)
- {
- D("Cannot open exec.library, aborting");
- }
- if (!gfxBase)
- {
- D("Cannot open graphics.library, aborting");
- }
- if (!layersBase)
- {
- D("Cannot open graphics.library, aborting");
- }
- D("gui_mch_prepare done ");
-}
-
- void
-atexitDoThis(void)
-{
-kprintf("atexitdothis###\n");
- gui_mch_exit(-1);
-}
-
-/*
- * Check if the GUI can be started. Called before gvimrc is sourced.
- * Return OK or FAIL.
- */
- int
-gui_mch_init_check(void)
-{
- if (execBase && gfxBase && layersBase)
- return OK;
- return FAIL;
-}
-
- int
-gui_mch_init(void)
-{
- int returnCode = FAIL; /* assume failure*/
-
- TimerMP = CreateMsgPort();
- if (!TimerMP) return FAIL;
-
- TimerIO = (struct timerequest *)CreateIORequest(TimerMP, sizeof(*TimerIO));
- if (!TimerIO) return FAIL;
-
- if (OpenDevice("timer.device", UNIT_VBLANK, &TimerIO->tr_node, 0)) return FAIL;
-
- gui.window = OpenWindowTagList(&vimNewWindow, tags);
- if (gui.window)
- {
- gui.in_use = TRUE;
- gui.in_focus=TRUE;
- gui.norm_pixel = gui.def_norm_pixel = 1;
- gui.back_pixel = gui.def_back_pixel = 0;
-
- set_normal_colors();
- gui_check_colors();
-
- SetDrMd(gui.window->RPort, JAM2);
- gui_mch_set_colors(gui.norm_pixel, gui.back_pixel);
-
- atexit(atexitDoThis);
-
- TextDimensions();
- returnCode = OK; /* we've had success */
- if (gui_win_x != -1 && gui_win_y != -1)
- gui_mch_set_winpos(gui_win_x, gui_win_y);
-
- gui_mch_clear_all();
-
- }
- gui.menu = NULL;
-
- return returnCode;
-}
-
- void
-gui_mch_new_colors(void)
-{
-kprintf("### gui_mch_new_colors\n");
- SetAPen(gui.window->RPort, getrealcolor(gui.norm_pixel));
- SetBPen(gui.window->RPort, getrealcolor(gui.back_pixel));
-
- D("gui_mch_new_colors");
-}
-
- int
-gui_mch_open(void)
-{
- D("gui_mch_open");
-
- highlight_gui_started();
- return OK;
-}
-
- void
-gui_mch_exit(int returnCode)
-{
-kprintf("###gui_mch_exit\n");
- D("****gui_mch_exit");
-
- if (TimerSent)
- {
- if (!CheckIO(&TimerIO->tr_node)) AbortIO(&TimerIO->tr_node);
- WaitIO(&TimerIO->tr_node);
- TimerSent = FALSE;
- }
-
- if (TimerIO)
- {
- CloseDevice(&TimerIO->tr_node);
- DeleteIORequest(&TimerIO->tr_node);
- TimerIO = NULL;
- }
-
- if (TimerMP)
- {
- DeleteMsgPort(TimerMP);
- TimerMP = NULL;
- }
-
- if (gui.window)
- {
- int i;
-
- for(i = 0; i < sizeof(MyColorTable) / sizeof(MyColorTable[0]); i++)
- {
- if (MyColorTable[i].alloced)
- {
- ReleasePen(gui.window->WScreen->ViewPort.ColorMap, MyColorTable[i].pen);
- MyColorTable[i].alloced = FALSE;
- }
- }
-
- D("Closeing window ");
- CloseWindow(gui.window);
- CloseLibrary((struct Library*)execBase);
- CloseLibrary((struct Library*)gfxBase);
- gui.window = NULL;
- gui.in_use = FALSE;
- //getout(1);
- }
-}
-
-/*
- * Get the position of the top left corner of the window.
- */
- int
-gui_mch_get_winpos(int *x, int *y)
-{
- if (gui.window)
- {
- *x = gui.window->LeftEdge;
- *y = gui.window->TopEdge;
- }
- else
- {
- return FAIL;
- }
-
- return OK;
-}
-
-/*
- * Set the position of the top left corner of the window to the given
- * coordinates.
- */
- void
-gui_mch_set_winpos(int x, int y)
-{
- if (gui.window)
- {
- ChangeWindowBox(gui.window, x, y, gui.window->Width, gui.window->Height);
- }
-}
-
- void
-gui_mch_set_shellsize(int width, int height,
- int min_width, int min_height, int base_width, int base_height)
-{
- D("gui_mch_set_shellsize");
-
- ChangeWindowBox(gui.window, gui.window->LeftEdge,
- gui.window->TopEdge, widthCharToPoint(width) + gui.window->BorderLeft + gui.window->BorderRight,
- heightCharToPoint(height) + gui.window->BorderTop + gui.window->BorderBottom);
- checkEventHandler();
-}
-
- void
-gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
-{
-// *screen_w = widthPointToChar(gui.window->GZZWidth);
-// *screen_h = heightPointToChar(gui.window->GZZHeight);
- *screen_w = gui.window->GZZWidth;
- *screen_h = gui.window->GZZHeight - characterHeight;
-
-
-kprintf("=== get_screen_dimensions: screen %d,%d character %d,%d console %d,%d\n",
-gui.window->GZZWidth,
-gui.window->GZZHeight,
-characterWidth,
-characterHeight,
-*screen_w,
-*screen_h);
-
-}
-
- void
-gui_mch_set_text_area_pos(int x, int y, int w, int h)
-{
- D("gui_mch_set_text_area_pos");
-}
-
- void
-gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
-{
- /* done by default */
- /* TODO: disable scrollbar when it's too small */
-}
-
- void
-gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max)
-{
- ULONG total = max;
- ULONG visible = size;
- ULONG top = val;
- ULONG hidden;
- ULONG overlap = 0;
- UWORD body, pot;
-
-kprintf("__set_scrollbar_thumb val %d size %d max %d\n", val, size, max);
-
- if (total > visible)
- hidden = total - visible;
- else
- hidden = 0;
-
- if (top > hidden)
- top = hidden;
-
- body = (hidden > 0) ?
- (UWORD)(((ULONG)(visible - overlap) * MAXBODY) / (total - overlap)) :
- MAXBODY;
-
- pot = (hidden > 0) ? (UWORD)(((ULONG) top * MAXPOT) / hidden) : 0;
-
-kprintf("__pot %x body %x\n", pot, body);
-
- NewModifyProp(&propGadget, gui.window, NULL,
- Gadget2SInfo.Flags,
- MAXPOT, pot,
- MAXBODY, body,
- 1);
- return;
-
-}
-
- void
-gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h)
-{
- D("gui_mch_set_scrollbar_pos");
- /*NewModifyProp(&propGadget, gui.window, NULL, MAXPOT, MAXPOT/sb->max*y, MAXPOT, MAXBODY/sb->max/sb->size, 1);*/
-}
-
- void
-gui_mch_create_scrollbar(scrollbar_T *sb, int orient)
-{
- /* this is done by default */
-}
-
-#if defined(FEAT_WINDOWS) || defined(PROTO)
- void
-gui_mch_destroy_scrollbar(scrollbar_T *sb)
-{
- /* this is done by default */
-}
-#endif
-
-char_u *gui_mch_getfontname(GuiFont font)
-{
- return vim_strsave((char_u *)"default");
-}
-
-int gui_mch_init_font(char_u *font_name, int fontset)
-{
- /*D("gui_mch_init_font");*/
-
- gui.char_width = characterWidth;
- gui.char_height = characterHeight;
- gui.char_ascent = gui.window->RPort->TxBaseline;
-
- return OK;
-}
-
- int
-gui_mch_adjust_charsize()
-{
- return FAIL;
-}
-
- GuiFont
-gui_mch_get_font(char_u *name, int giveErrorIfMissing)
-{
- /*D("gui_mch_get_font");*/
- return NULL;
-}
-
-#if defined(FEAT_EVAL) || defined(PROTO)
-/*
- * Return the name of font "font" in allocated memory.
- * We always use the default font.
- */
- char_u *
-gui_mch_get_fontname(GuiFont font, char_u *name)
-{
- return vim_strsave((char_u *)"default");
-}
-#endif
-
- void
-gui_mch_set_font(GuiFont font)
-{
- /*D("gui_mch_set_font");*/
-}
-
-#if 0 /* not used */
- int
-gui_mch_same_font(GuiFont f1, GuiFont f2)
-{
- D("gui_mch_same_font");
-}
-#endif
-
- void
-gui_mch_free_font(GuiFont font)
-{
- if (font)
- D("gui_mch_free_font");
-}
-
-#define RGB(a, b, c) ((a && 0xff) * 0x10000 + (b * 0xff) * 0x100 + (c & 0xff))
-
-/*
- * Get color handle for color "name".
- * Return INVALCOLOR when not possible.
- */
-
- typedef struct guicolor_tTable
- {
- char *name;
- unsigned long color;
- UBYTE red;
- UBYTE green;
- UBYTE blue;
- } guicolor_tTable;
-
- static guicolor_tTable table[] =
- {
- {"Grey", 0, 190,190,190},
- {"Black", 1, 0, 0, 0},
- {"DarkBlue", 2, 0, 0, 139},
- {"DarkGreen", 3, 0, 100, 0},
- {"DarkCyan", 4, 0, 139, 139},
- {"DarkRed", 5, 139, 0, 0},
- {"DarkMagenta", 6, 139, 0, 139},
- {"Brown", 7, 165, 42, 42},
- {"Gray", 8, 190, 190, 190},
- {"Grey", 9, 190, 190, 190},
- {"LightGray", 10, 211, 211, 211},
- {"LightGrey", 11, 211, 211, 211},
- {"DarkGray", 12, 169, 169, 169},
- {"DarkGrey", 13, 169, 169, 169},
- {"Blue", 14, 0, 0, 255},
- {"LightBlue", 15, 173, 216, 230},
- {"Green", 16, 0, 255, 0},
- {"LightGreen", 17, 144, 238, 144},
- {"Cyan", 18, 0, 255, 255},
- {"LightCyan", 19, 224, 255, 255},
- {"Red", 20, 255, 0, 0},
- {"LightRed", 21, 255, 0, 0}, /*?*/
- {"Magenta", 22, 255, 0, 255},
- {"LightMagenta",23, 255, 0, 255}, /*?*/
- {"Yellow", 24, 255, 255, 0},
- {"LightYellow", 25, 255, 255, 224}, /* TODO: add DarkYellow */
- {"White", 26, 255, 255, 255},
- {"SeaGreen", 27, 46, 139, 87},
- {"Orange", 28, 255, 165, 0},
- {"Purple", 30, 160, 32, 240},
- {"SlateBlue", 31, 106, 90, 205},
- {"grey90", 32, 229, 229, 229},
- {"grey95", 33, 242, 242, 242},
- {"grey80", 34, 204, 204, 204},
- {NULL, NULL},
- };
-
- guicolor_T
-gui_mch_get_color(char_u *name)
-{
-
- guicolor_T color = INVALCOLOR;
-
- int i;
-
- for (i = 0; table[i].name != NULL;i++)
- {
- if (stricmp(name, table[i].name) == 0)
- {
- //color = table[i].color;
- color = i;
- }
- }
-
-#if 0
- if (color == INVALCOLOR)
- {
- char *looky = NULL;
-
- color = strtol((char*)name, &looky, 10);
- if (*looky != NUL)
- color = INVALCOLOR;
- }
-#endif
-
- kprintf("gui_mch_get_color[%s] = %s\n", name, table[color].name);
-
- return color;
-}
-
-static UBYTE getrealcolor(guicolor_T i)
-{
- if (!MyColorTable[i].alloced)
- {
- MyColorTable[i].pen = ObtainBestPen(gui.window->WScreen->ViewPort.ColorMap,
- table[i].red * 0x01010101,
- table[i].green * 0x01010101,
- table[i].blue * 0x01010101,
- OBP_FailIfBad, FALSE,
- OBP_Precision, PRECISION_GUI,
- TAG_DONE);
- if (MyColorTable[i].pen != -1)
- {
- MyColorTable[i].alloced = TRUE;
- }
- }
-
- return MyColorTable[i].pen;
-}
-
-
- void
-gui_mch_set_colors(guicolor_T fg, guicolor_T bg)
-{
-#if 0
- if (fg == 0)
- {
- fg = 1;
- }
-#endif
- SetABPenDrMd(gui.window->RPort, getrealcolor(fg), getrealcolor(bg), JAM2);
-
-kprintf("gui_mch_set_colors %s,%s\n", table[fg].name, table[bg].name);
-}
-
- void
-gui_mch_set_fg_color(guicolor_T color)
-{
-#if 0
- if (color == 0)
- {
- color = 1; /* vim sends 0 as default color which is ALWAYS the
- background on the amiga scrolling with colours as the
- background is a very bad idea on slow machines*/
- }
-#endif
- SetAPen(gui.window->RPort, getrealcolor(color));
- SetDrMd(gui.window->RPort, JAM2);
-
-kprintf("gui_mch_set_fg_color %s\n", table[color].name);
-
-}
-
- void
-gui_mch_set_bg_color(guicolor_T color)
-{
- SetBPen(gui.window->RPort, getrealcolor(color));
-kprintf("gui_mch_set_bg_color %s\n", table[color].name);
-
-}
-
- void
-gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
-{
-#if 1
- char tempstring[300];
-
- memcpy(tempstring, s, len);
- tempstring[len] = '\0';
-
- kprintf("gui_mch_draw_string(%s) flags %x\n", tempstring, flags);
-#endif
-
- if (flags & DRAW_TRANSP)
- {
- SetDrMd(gui.window->RPort, JAM1);
- Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row) + gui.window->RPort->TxBaseline);
- Text(gui.window->RPort, s, len);
- }
- else
- {
- SetDrMd(gui.window->RPort, JAM2);
- Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row) + gui.window->RPort->TxBaseline);
- Text(gui.window->RPort, s, len);
- }
-
- if (flags & DRAW_BOLD)
- {
- SetDrMd(gui.window->RPort, JAM1);
- Move(gui.window->RPort, posWidthCharToPoint(col)+1, posHeightCharToPoint(row) + gui.window->RPort->TxBaseline);
- Text(gui.window->RPort, s, len);
- }
-
- if (flags & DRAW_UNDERL)
- {
- Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row + 1) - 1);
- Draw(gui.window->RPort, posWidthCharToPoint(col+len) - 1, posHeightCharToPoint(row + 1) - 1);
- }
-
- SetDrMd(gui.window->RPort, JAM2);
-}
-
- int
-gui_mch_haskey(char_u *name)
-{
- int i;
-
- D("gui_mch_haskey");
-
- for (i = 0; special_keys[i].vim_code1 != NUL; i++)
- if (name[0] == special_keys[i].vim_code0 &&
- name[1] == special_keys[i].vim_code1)
- return OK;
- return FAIL;
-}
-
- void
-gui_mch_beep(void)
-{
- D("gui_mch_beep");
-}
-
- void
-gui_mch_flash(int msec)
-{
- D("gui_mch_flash");
-
- SetDrMd(gui.window->RPort, COMPLEMENT);
- RectFill(gui.window->RPort, 0, 0, gui.window->GZZWidth - 1, gui.window->GZZHeight - 1);
- Delay(msec * 50 / 1000);
- RectFill(gui.window->RPort, 0, 0, gui.window->GZZWidth - 1, gui.window->GZZHeight - 1);
- SetDrMd(gui.window->RPort, JAM2);
-}
-
- void
-gui_mch_invert_rectangle( int r, int c, int nr, int nc)
-{
- printf("gui_mch_invert_rectangle %d %d %d %d\n", r, c, nr, nc);
-}
-
- void
-gui_mch_iconify(void)
-{
- D("gui_mch_iconify");
-}
-
-#if defined(FEAT_EVAL) || defined(PROTO)
-/*
- * Bring the Vim window to the foreground.
- */
- void
-gui_mch_set_foreground()
-{
- WindowToFront(gui.window);
- D("gui_mch_set_foreground");
-}
-#endif
-
- void
-gui_mch_settitle(char_u *title, char_u *icon)
-{
- SetWindowTitles(gui.window, title, (STRPTR)~0);
- D("gui_mch_settitle");
-}
-
- void
-gui_mch_stop_blink(void)
-{
- gui_undraw_cursor();
- D("gui_mch_stop_blink");
-}
-
- void
-gui_mch_start_blink(void)
-{
- gui_update_cursor(FALSE, FALSE);
- D("gui_mch_start_blink");
-}
-
- void
-gui_mch_draw_hollow_cursor(guicolor_T color)
-{
- drawBox(DB_NotFilled, gui.col, gui.row, characterWidth, characterHeight, color);
-}
-
- void
-gui_mch_draw_part_cursor( int w, int h, guicolor_T color)
-{
- D("gui_mch_part_cursor");
- drawBox(DB_Filled, gui.col, gui.row, w, h, color);
-}
-
- void
-gui_mch_update(void)
-{
- checkEventHandler();
- return ;
-}
-
- int
-gui_mch_wait_for_chars(int wtime)
-{
- ULONG timermask = 1L << TimerMP->mp_SigBit;
- ULONG winmask = 1L << gui.window->UserPort->mp_SigBit;
- int retval = FAIL;
-
- kprintf("========== gui_mch_wait_for_chars %d\n", wtime);
-
- if (wtime == -1) wtime = 1000000000;
- if (wtime < 20) wtime = 20;
-
- SetSignal(0, timermask);
- TimerIO->tr_node.io_Command = TR_ADDREQUEST;
- TimerIO->tr_time.tv_secs = wtime / 1000;
- TimerIO->tr_time.tv_micro = (wtime % 1000) * 1000;
- SendIO(&TimerIO->tr_node);
- TimerSent = TRUE;
-
- for(;;)
- {
- ULONG sigs = Wait(winmask | timermask);
-
- if (sigs & winmask)
- {
- checkEventHandler();
- if (!vim_is_input_buf_empty())
- {
- retval = OK;
- if (!CheckIO(&TimerIO->tr_node)) AbortIO(&TimerIO->tr_node);
- WaitIO(&TimerIO->tr_node);
- TimerSent = FALSE;
- break;
- }
- }
-
- if (sigs & timermask)
- {
- struct Message *msg;
-
- if ((msg = GetMsg(TimerMP)))
- {
- ReplyMsg(msg);
- TimerSent = FALSE;
- retval = FAIL;
- break;
- }
- }
- }
-
- return retval;
-
-// assert(wtime != 0);
-// return charEventHandler(wtime);
-}
-
- void
-gui_mch_flush(void)
-{
-}
-
- void
-gui_mch_clear_block(int row1, int col1, int row2, int col2)
-{
- UBYTE apen = GetAPen(gui.window->RPort);
-
- SetAPen(gui.window->RPort, getrealcolor(gui.back_pixel));
- RectFill(gui.window->RPort,
- posWidthCharToPoint(col1),
- posHeightCharToPoint(row1),
- posWidthCharToPoint(col2 + 1) - 1,
- posHeightCharToPoint(row2 + 1) - 1);
- SetAPen(gui.window->RPort, apen);
-
-}
-
- void
-gui_mch_clear_all(void)
-{
- SetRast(gui.window->RPort, GetBPen(gui.window->RPort));
- refreshBorder();
- D("gui_mch_clear_all");
-}
-
- void
-gui_mch_delete_lines(int row, int num_lines)
-{
- ScrollWindowRaster(gui.window,
- 0,
- characterHeight * num_lines,
- posWidthCharToPoint(gui.scroll_region_left),
- posHeightCharToPoint(row),
- posWidthCharToPoint(gui.scroll_region_right + 1) - 1,
- posHeightCharToPoint(gui.scroll_region_bot + 1) - 1);
-
- gui_clear_block(gui.scroll_region_bot - num_lines + 1,
- gui.scroll_region_left,
- gui.scroll_region_bot,
- gui.scroll_region_right);
-
-}
-
- void
-gui_mch_insert_lines(int row, int num_lines)
-{
- ScrollWindowRaster(gui.window,
- 0,
- -characterHeight*num_lines,
- posWidthCharToPoint(gui.scroll_region_left),
- posHeightCharToPoint(row),
- posWidthCharToPoint(gui.scroll_region_right + 1) - 1,
- posHeightCharToPoint(gui.scroll_region_bot +1 ) - 1);
-
- gui_clear_block(row, gui.scroll_region_left,
- row + num_lines - 1, gui.scroll_region_right);
-
-}
-
- void
-gui_mch_enable_menu(int flag)
-{
- D("gui_mch_enable_menu");
-}
-
- void
-gui_mch_set_menu_pos(int x, int y, int w, int h)
-{
- D("gui_mch_set_menu_pos");
-}
-
- void
-gui_mch_destroy_menu(vimmenu_T *menu)
-{
- D("gui_mch_destroy_menu");
- ClearMenuStrip(gui.window);
-}
-
- void
-gui_mch_menu_grey(vimmenu_T *menu, int grey)
-{
- D("gui_mch_menu_grey");
-}
-
- void
-gui_mch_menu_hidden(vimmenu_T *menu, int hidden)
-{
- D("gui_mch_menu_hidden");
- ClearMenuStrip(gui.window);
-}
-
- void
-gui_mch_draw_menubar(void)
-{
- D("gui_mch_draw_menubar");
- SetMenuStrip(gui.window, gui.menu);
-}
-
- static void
-AmigaError(const char *string)
-{
- static struct IntuiText pos = { 3, 0, JAM2, 17, 5, NULL, "Cancel", NULL} ;
- static struct IntuiText neg = { 3, 0, JAM2, 17, 5, NULL, "Cancel", NULL} ;
- static struct IntuiText message = { 3, 0, JAM2, 17, 5, NULL, NULL, NULL} ;
- static char *strptr = 0;
-
- if (strptr)
- free(strptr);
- strptr = malloc(strlen(string)+1);
-
- message.IText = strptr;
- strcpy(strptr, string);
-
- AutoRequest(NULL, &message, &pos, &neg, 0, 0, 300, 300);
-}
-
- int
-clip_mch_own_selection(VimClipboard *cbd)
-{
- D("clib_mch_own_selection");
- return OK;
-}
-
- void
-mch_setmouse(int on)
-{
-}
-
-/*
- * Get current y mouse coordinate in text window.
- * Return -1 when unknown.
- */
- int
-gui_mch_get_mouse_x()
-{
- return gui.window->GZZMouseX;
-}
-
- int
-gui_mch_get_mouse_y()
-{
- return gui.window->GZZMouseY;
-}
-
- void
-gui_mch_setmouse(x, y)
- int x;
- int y;
-{
- /* TODO */
-}
-
- void
-gui_mch_show_popupmenu(vimmenu_T *menu)
-{
- /* TODO */
-}
-
- void
-clip_mch_lose_selection(VimClipboard *cbd)
-{
- D("clip_mch_lose_selecction");
-}
-
- void
-clip_mch_request_selection(VimClipboard *cbd)
-{
- D("clip_mch_requst_selection");
-}
-
- void
-clip_mch_set_selection(VimClipboard *cbd)
-{
-}
-
- long_u
-gui_mch_get_rgb(guicolor_T pixel)
-{
- ULONG coltable[3], color;
-
- GetRGB32(gui.window->WScreen->ViewPort.ColorMap,
- getrealcolor(pixel),
- 1,
- coltable);
-
- color = ((coltable[0] & 0xFF000000) >> 8) |
- ((coltable[1] & 0xFF000000) >> 16) |
- ((coltable[2] & 0xFF000000) >> 24);
-
- return color;
-}
-
-#endif /* USE_AMIGA_GUI*/
diff --git a/src/gui_amiga.h b/src/gui_amiga.h
deleted file mode 100644
index f70122d7..00000000
--- a/src/gui_amiga.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* vi:set ts=8 sts=4 sw=4:
- *
- * VIM - Vi IMproved by Bram Moolenaar
- * Amiga GUI support by Michael Nielsen
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- *
- * Amiga GUI header file.
- */
-
-#if !defined(__GUI_AMIGA__H)
-#define __GUI_AMIGA__H
-
-#define SetAttrib(_ptr,_attrib,_value) ((_ptr)->_attrib=(_value))
-
-#if defined(FEAT_GUI_AMIGA)
-
-#include <intuition/intuition.h>
-
-enum event {
- ev_NullEvent,
- ev_MenuVerify,
- ev_MenuPick,
- ev_CloseWindow,
- ev_NewSize,
- ev_RefreshWindow,
- ev_MouseButtons,
- ev_MouseMove,
- ev_GadgetDown,
- ev_GadgetUp,
- ev_KeyStroke,
- ev_IntuiTicks,
- ev_MenuHelp,
- ev_GadgetHelp,
-
- ev_Ignore
-};
-
-struct MyMenuItem {
- struct MenuItem menuItem;
- vimmenu_T *guiMenu;
-};
-
-union myMenuItemUnion {
- struct MenuItem menuItem;
- struct MyMenuItem myMenuItem;
-};
-
-#endif /* FEAT_GUI_AMIGA*/
-#endif /* __GUI_AMIGA__H */
-
diff --git a/src/gui_beos.cc b/src/gui_beos.cc
deleted file mode 100644
index 31513655..00000000
--- a/src/gui_beos.cc
+++ /dev/null
@@ -1,3358 +0,0 @@
-/* vi:set ts=8 sts=4 sw=4:
- *
- * VIM - Vi IMproved by Bram Moolenaar
- * BeBox GUI support Copyright 1998 by Olaf Seibert.
- * All Rights Reserved.
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- *
- * BeOS GUI.
- *
- * GUI support for the Buzzword Enhanced Operating System.
- *
- * Ported to R4 by Richard Offer <richard@whitequeen.com> Jul 99
- *
- */
-
-/*
- * Structure of the BeOS GUI code:
- *
- * There are 3 threads.
- * 1. The initial thread. In gui_mch_prepare() this gets to run the
- * BApplication message loop. But before it starts doing that,
- * it creates thread 2:
- * 2. The main() thread. This thread is created in gui_mch_prepare()
- * and its purpose in life is to call main(argc, argv) again.
- * This thread is doing the bulk of the work.
- * 3. Sooner or later, a window is opened by the main() thread. This
- * causes a second message loop to be created: the window thread.
- *
- * == alternatively ===
- *
- * #if RUN_BAPPLICATION_IN_NEW_THREAD...
- *
- * 1. The initial thread. In gui_mch_prepare() this gets to spawn
- * thread 2. After doing that, it returns to main() to do the
- * bulk of the work, being the main() thread.
- * 2. Runs the BApplication.
- * 3. The window thread, just like in the first case.
- *
- * This second alternative is cleaner from Vim's viewpoint. However,
- * the BeBook seems to assume everywhere that the BApplication *must*
- * run in the initial thread. So perhaps doing otherwise is very wrong.
- *
- * However, from a B_SINGLE_LAUNCH viewpoint, the first is better.
- * If Vim is marked "Single Launch" in its application resources,
- * and a file is dropped on the Vim icon, and another Vim is already
- * running, the file is passed on to the earlier Vim. This happens
- * in BApplication::Run(). So we want Vim to terminate if
- * BApplication::Run() terminates. (See the BeBook, on BApplication.
- * However, it seems that the second copy of Vim isn't even started
- * in this case... which is for the better since I wouldn't know how
- * to detect this case.)
- *
- * Communication between these threads occurs mostly by translating
- * BMessages that come in and posting an appropriate translation on
- * the VDCMP (Vim Direct Communication Message Port). Therefore the
- * actions required for keypresses and window resizes, etc, are mostly
- * performed in the main() thread.
- *
- * A notable exception to this is the Draw() event. The redrawing of
- * the window contents is performed asynchronously from the window
- * thread. To make this work correctly, a locking protocol is used when
- * any thread is accessing the essential variables that are used by
- * the window thread.
- *
- * This locking protocol consists of locking Vim's window. This is both
- * convenient and necessary.
- */
-extern "C" {
-
-#define new xxx_new_xxx
-
-#include <float.h>
-#include <assert.h>
-#include "vim.h"
-#include "globals.h"
-#include "proto.h"
-#include "option.h"
-
-#undef new
-
-} /* extern "C" */
-
-/* ---------------- start of header part ---------------- */
-
-#include <be/app/MessageQueue.h>
-#include <be/app/Clipboard.h>
-#include <be/kernel/OS.h>
-#include <be/support/Beep.h>
-#include <be/interface/View.h>
-#include <be/interface/Window.h>
-#include <be/interface/MenuBar.h>
-#include <be/interface/MenuItem.h>
-#include <be/interface/ScrollBar.h>
-#include <be/interface/Region.h>
-#include <be/interface/Screen.h>
-#include <be/storage/Path.h>
-#include <be/storage/Directory.h>
-#include <be/storage/Entry.h>
-#include <be/app/Application.h>
-#include <be/support/Debug.h>
-
-/*
- * The macro B_PIXEL_ALIGNMENT shows us which version
- * of the header files we're using.
- */
-#if defined(B_PIXEL_ALIGNMENT)
-#define HAVE_R3_OR_LATER 1
-#else
-#define HAVE_R3_OR_LATER 0
-#endif
-
-class VimApp;
-class VimFormView;
-class VimTextAreaView;
-class VimWindow;
-
-extern key_map *keyMap;
-extern char *keyMapChars;
-
-extern int main(int argc, char **argv);
-
-#ifndef B_MAX_PORT_COUNT
-#define B_MAX_PORT_COUNT 100
-#endif
-
-/*
- * VimApp seems comparable to the X "vimShell"
- */
-class VimApp: public BApplication
-{
- typedef BApplication Inherited;
-public:
- VimApp(const char *appsig);
- ~VimApp();
-
- // callbacks:
-#if 0
- virtual void DispatchMessage(BMessage *m, BHandler *h)
- {
- m->PrintToStream();
- Inherited::DispatchMessage(m, h);
- }
-#endif
- virtual void ReadyToRun();
- virtual void ArgvReceived(int32 argc, char **argv);
- virtual void RefsReceived(BMessage *m);
- virtual bool QuitRequested();
-
- static void SendRefs(BMessage *m, bool changedir);
-private:
-};
-
-class VimWindow: public BWindow
-{
- typedef BWindow Inherited;
-public:
- VimWindow();
- ~VimWindow();
-
- virtual void DispatchMessage(BMessage *m, BHandler *h);
- virtual void WindowActivated(bool active);
- virtual bool QuitRequested();
-
- VimFormView *formView;
-
-private:
- void init();
-
-};
-
-class VimFormView: public BView
-{
- typedef BView Inherited;
-public:
- VimFormView(BRect frame);
- ~VimFormView();
-
- // callbacks:
- virtual void AllAttached();
- virtual void FrameResized(float new_width, float new_height);
-
-#define MENUBAR_MARGIN 1
- float MenuHeight() const
- { return menuBar ? menuBar->Frame().Height() + MENUBAR_MARGIN: 0; }
- BMenuBar *MenuBar() const
- { return menuBar; }
-
-private:
- void init(BRect);
-
- BMenuBar *menuBar;
- VimTextAreaView *textArea;
-};
-
-class VimTextAreaView: public BView
-{
- typedef BView Inherited;
-public:
- VimTextAreaView(BRect frame);
- ~VimTextAreaView();
-
- // callbacks:
- virtual void Draw(BRect updateRect);
- virtual void KeyDown(const char *bytes, int32 numBytes);
- virtual void MouseDown(BPoint point);
- virtual void MouseUp(BPoint point);
- virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
- virtual void MessageReceived(BMessage *m);
-
- // own functions:
- int mchInitFont(char_u *name);
- void mchDrawString(int row, int col, char_u *s, int len, int flags);
- void mchClearBlock(int row1, int col1, int row2, int col2);
- void mchClearAll();
- void mchDeleteLines(int row, int num_lines);
- void mchInsertLines(int row, int num_lines);
-
- static void guiSendMouseEvent(int button, int x, int y, int repeated_click, int_u modifiers);
- static void guiBlankMouse(bool should_hide);
- static int_u mouseModifiersToVim(int32 beModifiers);
-
- int32 mouseDragEventCount;
-
-private:
- void init(BRect);
-
- int_u vimMouseButton;
- int_u vimMouseModifiers;
-};
-
-class VimScrollBar: public BScrollBar
-{
- typedef BScrollBar Inherited;
-public:
- VimScrollBar(scrollbar_T *gsb, orientation posture);
- ~VimScrollBar();
-
- virtual void ValueChanged(float newValue);
- virtual void MouseUp(BPoint where);
- void SetValue(float newval);
- scrollbar_T *getGsb()
- { return gsb; }
-
- int32 scrollEventCount;
-
-private:
- scrollbar_T *gsb;
- float ignoreValue;
-};
-
-
-/*
- * For caching the fonts that are used;
- * Vim seems rather sloppy in this regard.
- */
-class VimFont: public BFont
-{
- typedef BFont Inherited;
-public:
- VimFont();
- VimFont(const VimFont *rhs);
- VimFont(const BFont *rhs);
- VimFont(const VimFont &rhs);
- ~VimFont();
-
- VimFont *next;
- int refcount;
- char_u *name;
-
-private:
- void init();
-};
-
-/* ---------------- end of GUI classes ---------------- */
-
-struct MainArgs {
- int argc;
- char **argv;
-};
-
-/*
- * These messages are copied through the VDCMP.
- * Therefore they ought not to have anything fancy.
- * They must be of POD type (Plain Old Data)
- * as the C++ standard calls them.
- */
-
-#define KEY_MSG_BUFSIZ 7
-#if KEY_MSG_BUFSIZ < MAX_KEY_CODE_LEN
-#error Increase KEY_MSG_BUFSIZ!
-#endif
-
-struct VimKeyMsg {
- char_u length;
- char_u chars[KEY_MSG_BUFSIZ]; /* contains Vim encoding */
-};
-
-struct VimResizeMsg {
- int width;
- int height;
-};
-
-struct VimScrollBarMsg {
- VimScrollBar *sb;
- long value;
- int stillDragging;
-};
-
-struct VimMenuMsg {
- vimmenu_T *guiMenu;
-};
-
-struct VimMouseMsg {
- int button;
- int x;
- int y;
- int repeated_click;
- int_u modifiers;
-};
-
-struct VimFocusMsg {
- bool active;
-};
-
-struct VimRefsMsg {
- BMessage *message;
- bool changedir;
-};
-
-struct VimMsg {
- enum VimMsgType {
- Key, Resize, ScrollBar, Menu, Mouse, Focus, Refs
- };
-
- union {
- struct VimKeyMsg Key;
- struct VimResizeMsg NewSize;
- struct VimScrollBarMsg Scroll;
- struct VimMenuMsg Menu;
- struct VimMouseMsg Mouse;
- struct VimFocusMsg Focus;
- struct VimRefsMsg Refs;
- } u;
-};
-
-#define RGB(r, g, b) ((char_u)(r) << 16 | (char_u)(g) << 8 | (char_u)(b) << 0)
-#define GUI_TO_RGB(g) { (g) >> 16, (g) >> 8, (g) >> 0, 255 }
-
-/* ---------------- end of header part ---------------- */
-
-static struct specialkey
-{
- uint16 BeKeys;
-#define KEY(a,b) ((a)<<8|(b))
-#define K(a) KEY(0,a) // for ASCII codes
-#define F(b) KEY(1,b) // for scancodes
- char_u vim_code0;
- char_u vim_code1;
-} special_keys[] =
-{
- {K(B_UP_ARROW), 'k', 'u'},
- {K(B_DOWN_ARROW), 'k', 'd'},
- {K(B_LEFT_ARROW), 'k', 'l'},
- {K(B_RIGHT_ARROW), 'k', 'r'},
- {K(B_BACKSPACE), 'k', 'b'},
- {K(B_INSERT), 'k', 'I'},
- {K(B_DELETE), 'k', 'D'},
- {K(B_HOME), 'k', 'h'},
- {K(B_END), '@', '7'},
- {K(B_PAGE_UP), 'k', 'P'}, /* XK_Prior */
- {K(B_PAGE_DOWN), 'k', 'N'}, /* XK_Next, */
-
-#define FIRST_FUNCTION_KEY 11
- {F(B_F1_KEY), 'k', '1'},
- {F(B_F2_KEY), 'k', '2'},
- {F(B_F3_KEY), 'k', '3'},
- {F(B_F4_KEY), 'k', '4'},
- {F(B_F5_KEY), 'k', '5'},
- {F(B_F6_KEY), 'k', '6'},
- {F(B_F7_KEY), 'k', '7'},
- {F(B_F8_KEY), 'k', '8'},
- {F(B_F9_KEY), 'k', '9'},
- {F(B_F10_KEY), 'k', ';'},
-
- {F(B_F11_KEY), 'F', '1'},
- {F(B_F12_KEY), 'F', '2'},
-// {XK_F13, 'F', '3'}, /* would be print screen/ */
- /* sysreq */
- {F(0x0F), 'F', '4'}, /* scroll lock */
- {F(0x10), 'F', '5'}, /* pause/break */
-// {XK_F16, 'F', '6'},
-// {XK_F17, 'F', '7'},
-// {XK_F18, 'F', '8'},
-// {XK_F19, 'F', '9'},
-// {XK_F20, 'F', 'A'},
-//
-// {XK_F21, 'F', 'B'},
-// {XK_F22, 'F', 'C'},
-// {XK_F23, 'F', 'D'},
-// {XK_F24, 'F', 'E'},
-// {XK_F25, 'F', 'F'},
-// {XK_F26, 'F', 'G'},
-// {XK_F27, 'F', 'H'},
-// {XK_F28, 'F', 'I'},
-// {XK_F29, 'F', 'J'},
-// {XK_F30, 'F', 'K'},
-//
-// {XK_F31, 'F', 'L'},
-// {XK_F32, 'F', 'M'},
-// {XK_F33, 'F', 'N'},
-// {XK_F34, 'F', 'O'},
-// {XK_F35, 'F', 'P'}, /* keysymdef.h defines up to F35 */
-
-// {XK_Help, '%', '1'}, /* XK_Help */
- {F(B_PRINT_KEY), '%', '9'},
-
-#if 0
- /* Keypad keys: */
- {F(0x48), 'k', 'l'}, /* XK_KP_Left */
- {F(0x4A), 'k', 'r'}, /* XK_KP_Right */
- {F(0x38), 'k', 'u'}, /* XK_KP_Up */
- {F(0x59), 'k', 'd'}, /* XK_KP_Down */
- {F(0x64), 'k', 'I'}, /* XK_KP_Insert */
- {F(0x65), 'k', 'D'}, /* XK_KP_Delete */
- {F(0x37), 'k', 'h'}, /* XK_KP_Home */
- {F(0x58), '@', '7'}, /* XK_KP_End */
- {F(0x39), 'k', 'P'}, /* XK_KP_Prior */
- {F(0x60), 'k', 'N'}, /* XK_KP_Next */
- {F(0x49), '&', '8'}, /* XK_Undo, keypad 5 */
-#endif
-
- /* End of list marker: */
- {0, 0, 0}
-};
-
-#define NUM_SPECIAL_KEYS (sizeof(special_keys)/sizeof(special_keys[0]))
-
-/* ---------------- VimApp ---------------- */
-
- static void
-docd(BPath &path)
-{
- mch_chdir(path.Path());
- /* Do this to get the side effects of a :cd command */
- do_cmdline_cmd((char_u *)"cd .");
-}
-
-/*
- * Really handle dropped files and folders.
- */
- static void
-RefsReceived(BMessage *m, bool changedir)
-{
- uint32 type;
- int32 count;
-
- //m->PrintToStream();
- switch (m->what) {
- case B_REFS_RECEIVED:
- case B_SIMPLE_DATA:
- m->GetInfo("refs", &type, &count);
- if (type != B_REF_TYPE)
- goto bad;
- break;
- case B_ARGV_RECEIVED:
- m->GetInfo("argv", &type, &count);
- if (type != B_STRING_TYPE)
- goto bad;
- if (changedir) {
- char *dirname;
- if (m->FindString("cwd", (const char **) &dirname) == B_OK) {
- chdir(dirname);
- do_cmdline_cmd((char_u *)"cd .");
- }
- }
- break;
- default:
- bad:
- //fprintf(stderr, "bad!\n");
- delete m;
- return;
- }
-
-#ifdef FEAT_VISUAL
- reset_VIsual();
-#endif
-
- char_u **fnames;
- fnames = (char_u **) alloc(count * sizeof(char_u *));
- int fname_index = 0;
-
- switch (m->what) {
- case B_REFS_RECEIVED:
- case B_SIMPLE_DATA:
- //fprintf(stderr, "case B_REFS_RECEIVED\n");
- for (int i = 0; i < count; ++i)
- {
- entry_ref ref;
- if (m->FindRef("refs", i, &ref) == B_OK) {
- BEntry entry(&ref, false);
- BPath path;
- entry.GetPath(&path);
-
- /* Change to parent directory? */
- if (changedir) {
- BPath parentpath;
- path.GetParent(&parentpath);
- docd(parentpath);
- }
-
- /* Is it a directory? If so, cd into it. */
- BDirectory bdir(&ref);
- if (bdir.InitCheck() == B_OK) {
- /* don't cd if we already did it */
- if (!changedir)
- docd(path);
- } else {
- mch_dirname(IObuff, IOSIZE);
- char_u *fname = shorten_fname((char_u *)path.Path(), IObuff);
- if (fname == NULL)
- fname = (char_u *)path.Path();
- fnames[fname_index++] = vim_strsave(fname);
- //fprintf(stderr, "%s\n", fname);
- }
-
- /* Only do it for the first file/dir */
- changedir = false;
- }
- }
- break;
- case B_ARGV_RECEIVED:
- //fprintf(stderr, "case B_ARGV_RECEIVED\n");
- for (int i = 1; i < count; ++i)
- {
- char *fname;
-
- if (m->FindString("argv", i, (const char **) &fname) == B_OK) {
- fnames[fname_index++] = vim_strsave((char_u *)fname);
- }
- }
- break;
- default:
- //fprintf(stderr, "case default\n");
- break;
- }
-
- delete m;
-
- /* Handle the drop, :edit to get to the file */
- if (fname_index > 0) {
- handle_drop(fname_index, fnames, FALSE);
-
- /* Update the screen display */
- update_screen(NOT_VALID);
- setcursor();
- out_flush();
- } else {
- vim_free(fnames);
- }
-}
-
-VimApp::VimApp(const char *appsig):
- BApplication(appsig)
-{
-}
-
-VimApp::~VimApp()
-{
-}
-
- void
-VimApp::ReadyToRun()
-{
- /*
- * Apparently signals are inherited by the created thread -
- * disable the most annoying ones.
- */
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
-}
-
- void
-VimApp::ArgvReceived(int32 arg_argc, char **arg_argv)
-{
- if (!IsLaunching()) {
- /*
- * This can happen if we are set to Single or Exclusive
- * Launch. Be nice and open the file(s).
- */
- if (gui.vimWindow)
- gui.vimWindow->Minimize(false);
- BMessage *m = CurrentMessage();
- DetachCurrentMessage();
- SendRefs(m, true);
- }
-}
-
- void
-VimApp::RefsReceived(BMessage *m)
-{
- /* Horrible hack!!! XXX XXX XXX
- * The real problem is that b_start_ffc is set too late for
- * the initial empty buffer. As a result the window will be
- * split instead of abandoned.
- */
- int limit = 15;
- while (--limit >= 0 && (curbuf == NULL || curbuf->b_start_ffc == 0))
- snooze(100000); // 0.1 s
- if (gui.vimWindow)
- gui.vimWindow->Minimize(false);
- DetachCurrentMessage();
- SendRefs(m, true);
-}
-
-/*
- * Pass a BMessage on to the main() thread.
- * Caller must have detached the message.
- */
- void
-VimApp::SendRefs(BMessage *m, bool changedir)
-{
- VimRefsMsg rm;
- rm.message = m;
- rm.changedir = changedir;
-
- write_port(gui.vdcmp, VimMsg::Refs, &rm, sizeof(rm));
- // calls ::RefsReceived
-}
-
- bool
-VimApp::QuitRequested()
-{
- (void)Inherited::QuitRequested();
- return false;
-}
-
-/* ---------------- VimWindow ---------------- */
-
-VimWindow::VimWindow():
- BWindow(BRect(40, 40, 150, 150),
- "Vim",
- B_TITLED_WINDOW,
- 0,
- B_CURRENT_WORKSPACE)
-
-{
- init();
-}
-
-VimWindow::~VimWindow()
-{
- if (formView) {
- RemoveChild(formView);
- delete formView;
- }
- gui.vimWindow = NULL;
-}
-
- void
-VimWindow::init()
-{
- /* Attach the VimFormView */
- formView = new VimFormView(Bounds());
- if (formView != NULL) {
- AddChild(formView);
- }
-}
-
- void
-VimWindow::DispatchMessage(BMessage *m, BHandler *h)
-{
- /*
- * Route B_MOUSE_UP messages to MouseUp(), in
- * a manner that should be compatible with the
- * intended future system behaviour.
- */
- switch (m->what) {
- case B_MOUSE_UP:
- // if (!h) h = PreferredHandler();
-// gcc isn't happy without this extra set of braces, complains about
-// jump to case label crosses init of 'class BView * v'
-// richard@whitequeen.com jul 99
- {
- BView *v = dynamic_cast<BView *>(h);
- if (v) {
- //m->PrintToStream();
- BPoint where;
- m->FindPoint("where", &where);
- v->MouseUp(where);
- } else {
- Inherited::DispatchMessage(m, h);
- }
- }
- break;
- default:
- Inherited::DispatchMessage(m, h);
- }
-}
-
- void
-VimWindow::WindowActivated(bool active)
-{
- Inherited::WindowActivated(active);
- /* the textArea gets the keyboard action */
- if (active && gui.vimTextArea)
- gui.vimTextArea->MakeFocus(true);
-
- struct VimFocusMsg fm;
- fm.active = active;
-
- write_port(gui.vdcmp, VimMsg::Focus, &fm, sizeof(fm));
-}
-
- bool
-VimWindow::QuitRequested()
-{
- struct VimKeyMsg km;
- km.length = 5;
- memcpy((char *)km.chars, "\033:qa\r", km.length);
-
- write_port(gui.vdcmp, VimMsg::Key, &km, sizeof(km));
-
- return false;
-}
-
-/* ---------------- VimFormView ---------------- */
-
-VimFormView::VimFormView(BRect frame):
- BView(frame, "VimFormView", B_FOLLOW_ALL_SIDES,
- B_WILL_DRAW | B_FRAME_EVENTS),
- menuBar(NULL),
- textArea(NULL)
-{
- init(frame);
-}
-
-VimFormView::~VimFormView()
-{
- if (menuBar) {
- RemoveChild(menuBar);
-#ifdef never
- // deleting the menuBar leads to SEGV on exit
- // richard@whitequeen.com Jul 99
- delete menuBar;
-#endif
- }
- if (textArea) {
- RemoveChild(textArea);
- delete textArea;
- }
- gui.vimForm = NULL;
-}
-
- void
-VimFormView::init(BRect frame)
-{
- menuBar = new BMenuBar(BRect(0,0,-MENUBAR_MARGIN,-MENUBAR_MARGIN),
- "VimMenuBar");
-
- AddChild(menuBar);
-
- BRect remaining = frame;
- textArea = new VimTextAreaView(remaining);
- AddChild(textArea);
- /* The textArea will be resized later when menus are added */
-
- gui.vimForm = this;
-}
-
- void
-VimFormView::AllAttached()
-{
- /*
- * Apparently signals are inherited by the created thread -
- * disable the most annoying ones.
- */
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
-
- if (menuBar && textArea) {
- /*
- * Resize the textArea to fill the space left over by the menu.
- * This is somewhat futile since it will be done again once
- * menus are added to the menu bar.
- */
- BRect remaining = Bounds();
- remaining.top = MenuHeight();
- textArea->ResizeTo(remaining.Width(), remaining.Height());
- textArea->MoveTo(remaining.left, remaining.top);
-
-#ifdef FEAT_MENU
- menuBar->ResizeTo(remaining.right, remaining.top);
- gui.menu_height = (int) remaining.top;
-#endif
- }
- Inherited::AllAttached();
-}
-
- void
-VimFormView::FrameResized(float new_width, float new_height)
-{
- BWindow *w = Window();
-#if 1
- /*
- * Look if there are more resize messages in the queue.
- * If so, ignore this one. The later one will be handled
- * eventually.
- */
- BMessageQueue *q = w->MessageQueue();
- if (q->FindMessage(B_VIEW_RESIZED, 0) != NULL) {
- return;
- }
-#endif
- new_width += 1; // adjust from width to number of pixels occupied
- new_height += 1;
-
-#if !HAVE_R3_OR_LATER
- int adjust_h, adjust_w;
-
- adjust_w = ((int)new_width - gui_get_base_width()) % gui.char_width;
- adjust_h = ((int)new_height - gui_get_base_height()) % gui.char_height;
-
- if (adjust_w > 0 || adjust_h > 0) {
- /*
- * This will generate a new FrameResized() message.
- * If we're running R3 or later, SetWindowAlignment() should make
- * sure that this does not happen.
- */
- w->ResizeBy(-adjust_w, -adjust_h);
-
- return;
- }
-#endif
-
- struct VimResizeMsg sm;
- sm.width = (int) new_width;
- sm.height = (int) new_height;
-
- write_port(gui.vdcmp, VimMsg::Resize, &sm, sizeof(sm));
- // calls gui_resize_shell(new_width, new_height);
-
- return;
-
- /*
- * The area below the vertical scrollbar is erased to the colour
- * set with SetViewColor() automatically, because we had set
- * B_WILL_DRAW. Resizing the window tight around the vertical
- * scroll bar also helps to avoid debris.
- */
-}
-
-/* ---------------- VimTextAreaView ---------------- */
-
-VimTextAreaView::VimTextAreaView(BRect frame):
- BView(frame, "VimTextAreaView", B_FOLLOW_ALL_SIDES,
- B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
- mouseDragEventCount(0)
-{
- init(frame);
-}
-
-VimTextAreaView::~VimTextAreaView()
-{
- gui.vimTextArea = NULL;
-}
-
- void
-VimTextAreaView::init(BRect frame)
-{
- /* set up global var for fast access */
- gui.vimTextArea = this;
-
- /*
- * Tell the app server not to erase the view: we will
- * fill it in completely by ourselves.
- * (Does this really work? Even if not, it won't harm either.)
- */
- SetViewColor(B_TRANSPARENT_32_BIT);
-#define PEN_WIDTH 1
- SetPenSize(PEN_WIDTH);
-}
-
- void
-VimTextAreaView::Draw(BRect updateRect)
-{
- /*
- * XXX Other ports call here:
- * out_flush(); * make sure all output has been processed *
- * but we can't do that, since it involves too much information
- * that is owned by other threads...
- */
-
- /*
- * No need to use gui.vimWindow->Lock(): we are locked already.
- * However, it would not hurt.
- */
- gui_redraw((int) updateRect.left, (int) updateRect.top,
- (int) (updateRect.Width() + PEN_WIDTH), (int) (updateRect.Height() + PEN_WIDTH));
-
- /* Clear the border areas if needed */
- rgb_color rgb = GUI_TO_RGB(gui.back_pixel);
- SetLowColor(rgb);
-
- if (updateRect.left < FILL_X(0)) // left border
- FillRect(BRect(updateRect.left, updateRect.top,
- FILL_X(0)-PEN_WIDTH, updateRect.bottom), B_SOLID_LOW);
- if (updateRect.top < FILL_Y(0)) // top border
- FillRect(BRect(updateRect.left, updateRect.top,
- updateRect.right, FILL_Y(0)-PEN_WIDTH), B_SOLID_LOW);
- if (updateRect.right >= FILL_X(Columns)) // right border
- FillRect(BRect(FILL_X((int)Columns), updateRect.top,
- updateRect.right, updateRect.bottom), B_SOLID_LOW);
- if (updateRect.bottom >= FILL_Y(Rows)) // bottom border
- FillRect(BRect(updateRect.left, FILL_Y((int)Rows),
- updateRect.right, updateRect.bottom), B_SOLID_LOW);
-}
-
- void
-VimTextAreaView::KeyDown(const char *bytes, int32 numBytes)
-{
- struct VimKeyMsg km;
- char_u *dest = km.chars;
-
- BMessage *msg = Window()->CurrentMessage();
- assert(msg);
- //msg->PrintToStream();
-
- /*
- * Convert special keys to Vim codes.
- * I think it is better to do it in the window thread
- * so we use at least a little bit of the potential
- * of our 2 CPUs. Besides, due to the fantastic mapping
- * of special keys to UTF-8, we have quite some work to
- * do...
- * TODO: I'm not quite happy with detection of special
- * keys. Perhaps I should use scan codes after all...
- */
- if (numBytes > 1) {
- /* This cannot be a special key */
- if (numBytes > KEY_MSG_BUFSIZ)
- numBytes = KEY_MSG_BUFSIZ; // should never happen... ???
- km.length = numBytes;
- memcpy((char *)dest, bytes, numBytes);
- } else {
- int32 scancode = 0;
- msg->FindInt32("key", &scancode);
-
- int32 beModifiers = 0;
- msg->FindInt32("modifiers", &beModifiers);
-
- char_u string[3];
- int len = 0;
- km.length = 0;
-
- bool canHaveVimModifiers = false;
-
- /*
- * For normal, printable ASCII characters, don't look them up
- * to check if they might be a special key. They aren't.
- */
- assert(B_BACKSPACE <= 0x20);
- assert(B_DELETE == 0x7F);
- if (((char_u)bytes[0] <= 0x20 || (char_u)bytes[0] == 0x7F) &&
- numBytes == 1) {
- /*
- * Due to the great nature of Be's mapping of special keys,
- * viz. into the range of the control characters,
- * we can only be sure it is *really* a special key if
- * if it is special without using ctrl. So, only if ctrl is
- * used, we need to check it unmodified.
- */
- if (beModifiers & B_CONTROL_KEY) {
- int index = keyMap->normal_map[scancode];
- int newNumBytes = keyMapChars[index];
- char_u *newBytes = (char_u *)&keyMapChars[index + 1];
-
- /*
- * Check if still special without the control key.
- * This is needed for BACKSPACE: that key does produce
- * different values with modifiers (DEL).
- * Otherwise we could simply have checked for equality.
- */
- if (newNumBytes != 1 || (*newBytes > 0x20 &&
- *newBytes != 0x7F )) {
- goto notspecial;
- }
- bytes = (char *)newBytes;
- }
- canHaveVimModifiers = true;
-
- uint16 beoskey;
- int first, last;
-
- /*
- * If numBytes == 0 that probably always indicates a special key.
- * (does not happen yet)
- */
- if (numBytes == 0 || bytes[0] == B_FUNCTION_KEY) {
- beoskey = F(scancode);
- first = FIRST_FUNCTION_KEY;
- last = NUM_SPECIAL_KEYS;
- } else if (*bytes == '\n' && scancode == 0x47) {
- /* remap the (non-keypad) ENTER key from \n to \r. */
- string[0] = '\r';
- len = 1;
- first = last = 0;
- } else {
- beoskey = K(bytes[0]);
- first = 0;
- last = FIRST_FUNCTION_KEY;
- }
-
- for (int i = first; i < last; i++) {
- if (special_keys[i].BeKeys == beoskey) {
- string[0] = CSI;
- string[1] = special_keys[i].vim_code0;
- string[2] = special_keys[i].vim_code1;
- len = 3;
- }
- }
- }
- notspecial:
- if (len == 0) {
- string[0] = bytes[0];
- len = 1;
- }
-
- /* Special keys (and a few others) may have modifiers */
-#if 0
- if (len == 3 ||
- bytes[0] == B_SPACE || bytes[0] == B_TAB ||
- bytes[0] == B_RETURN || bytes[0] == '\r' ||
- bytes[0] == B_ESCAPE)
-#else
- if (canHaveVimModifiers)
-#endif
- {
- int modifiers;
- modifiers = 0;
- if (beModifiers & B_SHIFT_KEY)
- modifiers |= MOD_MASK_SHIFT;
- if (beModifiers & B_CONTROL_KEY)
- modifiers |= MOD_MASK_CTRL;
- if (beModifiers & B_OPTION_KEY)
- modifiers |= MOD_MASK_ALT;
-
- /*
- * For some keys a shift modifier is translated into another key
- * code. Do we need to handle the case where len != 1 and
- * string[0] != CSI? (Not for BeOS, since len == 3 implies
- * string[0] == CSI...)
- */
- int key;
- if (string[0] == CSI && len == 3)
- key = TO_SPECIAL(string[1], string[2]);
- else
- key = string[0];
- key = simplify_key(key, &modifiers);
- if (IS_SPECIAL(key))
- {
- string[0] = CSI;
- string[1] = K_SECOND(key);
- string[2] = K_THIRD(key);
- len = 3;
- }
- else
- {
- string[0] = key;
- len = 1;
- }
-
- if (modifiers)
- {
- *dest++ = CSI;
- *dest++ = KS_MODIFIER;
- *dest++ = modifiers;
- km.length = 3;
- }
- }
- memcpy((char *)dest, string, len);
- km.length += len;
- }
-
- write_port(gui.vdcmp, VimMsg::Key, &km, sizeof(km));
-
- /*
- * blank out the pointer if necessary
- */
- if (p_mh && !gui.pointer_hidden)
- {
- guiBlankMouse(true);
- gui.pointer_hidden = TRUE;
- }
-}
- void
-VimTextAreaView::guiSendMouseEvent(
- int button,
- int x,
- int y,
- int repeated_click,
- int_u modifiers)
-{
- VimMouseMsg mm;
-
- mm.button = button;
- mm.x = x;
- mm.y = y;
- mm.repeated_click = repeated_click;
- mm.modifiers = modifiers;
-
- write_port(gui.vdcmp, VimMsg::Mouse, &mm, sizeof(mm));
- // calls gui_send_mouse_event()
-
- /*
- * if our pointer is currently hidden, then we should show it.
- */
- if (gui.pointer_hidden)
- {
- guiBlankMouse(false);
- gui.pointer_hidden = FALSE;
- }
-}
-
- void
-VimTextAreaView::guiBlankMouse(bool should_hide)
-{
- if (should_hide) {
- //gui.vimApp->HideCursor();
- gui.vimApp->ObscureCursor();
- /*
- * ObscureCursor() would even be easier, but then
- * Vim's idea of mouse visibility does not necessarily
- * correspond to reality.
- */
- } else {
- //gui.vimApp->ShowCursor();
- }
-}
-
- int_u
-VimTextAreaView::mouseModifiersToVim(int32 beModifiers)
-{
- int_u vim_modifiers = 0x0;
-
- if (beModifiers & B_SHIFT_KEY)
- vim_modifiers |= MOUSE_SHIFT;
- if (beModifiers & B_CONTROL_KEY)
- vim_modifiers |= MOUSE_CTRL;
- if (beModifiers & B_OPTION_KEY) /* Alt or Meta key */
- vim_modifiers |= MOUSE_ALT;
-
- return vim_modifiers;
-}
-
- void
-VimTextAreaView::MouseDown(BPoint point)
-{
- BMessage *m = Window()->CurrentMessage();
- assert(m);
-
- int32 buttons = 0;
- m->FindInt32("buttons", &buttons);
-
- int vimButton;
-
- if (buttons & B_PRIMARY_MOUSE_BUTTON)
- vimButton = MOUSE_LEFT;
- else if (buttons & B_SECONDARY_MOUSE_BUTTON)
- vimButton = MOUSE_RIGHT;
- else if (buttons & B_TERTIARY_MOUSE_BUTTON)
- vimButton = MOUSE_MIDDLE;
- else
- return; /* Unknown button */
-
- vimMouseButton = 1; /* don't care which one */
-
- /* Handle multiple clicks */
- int32 clicks = 0;
- m->FindInt32("clicks", &clicks);
-
- int32 modifiers = 0;
- m->FindInt32("modifiers", &modifiers);
-
- vimMouseModifiers = mouseModifiersToVim(modifiers);
-
- guiSendMouseEvent(vimButton, point.x, point.y,
- clicks > 1 /* = repeated_click*/, vimMouseModifiers);
-}
-
- void
-VimTextAreaView::MouseUp(BPoint point)
-{
- vimMouseButton = 0;
-
- BMessage *m = Window()->CurrentMessage();
- assert(m);
- //m->PrintToStream();
-
- int32 modifiers = 0;
- m->FindInt32("modifiers", &modifiers);
-
- vimMouseModifiers = mouseModifiersToVim(modifiers);
-
- guiSendMouseEvent(MOUSE_RELEASE, point.x, point.y,
- 0 /* = repeated_click*/, vimMouseModifiers);
-
- Inherited::MouseUp(point);
-}
-
- void
-VimTextAreaView::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
-{
- /*
- * if our pointer is currently hidden, then we should show it.
- */
- if (gui.pointer_hidden)
- {
- guiBlankMouse(false);
- gui.pointer_hidden = FALSE;
- }
-
- if (!vimMouseButton) /* could also check m->"buttons" */
- return;
-
- atomic_add(&mouseDragEventCount, 1);
-
- /* Don't care much about "transit" */
- guiSendMouseEvent(MOUSE_DRAG, point.x, point.y, 0, vimMouseModifiers);
-}
-
- void
-VimTextAreaView::MessageReceived(BMessage *m)
-{
- switch (m->what) {
- case 'menu':
- {
- VimMenuMsg mm;
- mm.guiMenu = NULL; /* in case no pointer in msg */
- m->FindPointer("VimMenu", (void **)&mm.guiMenu);
-
- write_port(gui.vdcmp, VimMsg::Menu, &mm, sizeof(mm));
- }
- break;
- default:
- if (m->WasDropped()) {
- BWindow *w = Window();
- w->DetachCurrentMessage();
- w->Minimize(false);
- VimApp::SendRefs(m, (modifiers() & B_SHIFT_KEY) != 0);
- } else {
- Inherited::MessageReceived(m);
- }
- break;
- }
-}
-
- int
-VimTextAreaView::mchInitFont(char_u *name)
-{
- VimFont *newFont = (VimFont *)gui_mch_get_font(name, 0);
-
- gui.norm_font = (GuiFont)newFont;
- gui_mch_set_font((GuiFont)newFont);
- if (name)
- hl_set_font_name(name);
-
- SetDrawingMode(B_OP_COPY);
-
- /*
- * Try to load other fonts for bold, italic, and bold-italic.
- * We should also try to work out what font to use for these when they are
- * not specified by X resources, but we don't yet.
- */
-
- return OK;
-}
-
- void
-VimTextAreaView::mchDrawString(int row, int col, char_u *s, int len, int flags)
-{
- /*
- * First we must erase the area, because DrawString won't do
- * that for us. XXX Most of the time this is a waste of effort
- * since the bachground has been erased already... DRAW_TRANSP
- * should be set when appropriate!!!
- * (Rectangles include the bottom and right edge)
- */
- if (!(flags & DRAW_TRANSP)) {
- BRect r(FILL_X(col), FILL_Y(row),
- FILL_X(col + len) - PEN_WIDTH, FILL_Y(row + 1) - PEN_WIDTH);
- FillRect(r, B_SOLID_LOW);
- }
- BPoint where(TEXT_X(col), TEXT_Y(row));
- DrawString((char *)s, len, where);
-
- if (flags & DRAW_BOLD) {
- where.x += 1.0;
- SetDrawingMode(B_OP_BLEND);
- DrawString((char *)s, len, where);
- SetDrawingMode(B_OP_COPY);
- }
- if (flags & DRAW_UNDERL) {
- BPoint start(FILL_X(col), FILL_Y(row + 1) - PEN_WIDTH);
- BPoint end(FILL_X(col + len) - PEN_WIDTH, start.y);
-
- StrokeLine(start, end);
- }
-}
-
- void
-VimTextAreaView::mchClearBlock(
- int row1,
- int col1,
- int row2,
- int col2)
-{
- BRect r(FILL_X(col1), FILL_Y(row1),
- FILL_X(col2 + 1) - PEN_WIDTH, FILL_Y(row2 + 1) - PEN_WIDTH);
- gui_mch_set_bg_color(gui.back_pixel);
- FillRect(r, B_SOLID_LOW);
-}
-
- void
-VimTextAreaView::mchClearAll()
-{
- gui_mch_set_bg_color(gui.back_pixel);
- FillRect(Bounds(), B_SOLID_LOW);
-}
-
-/*
- * mchDeleteLines() Lock()s the window by itself.
- */
- void
-VimTextAreaView::mchDeleteLines(int row, int num_lines)
-{
- if (row + num_lines > gui.scroll_region_bot)
- {
- /* Scrolled out of region, just blank the lines out */
- gui_clear_block(row, gui.scroll_region_left,
- gui.scroll_region_bot, gui.scroll_region_right);
- }
- else
- {
- /* copy one extra pixel, for when bold has spilled over */
- int width = gui.char_width * (gui.scroll_region_right
- - gui.scroll_region_left + 1) + 1 - PEN_WIDTH;
- int height = gui.char_height *
- (gui.scroll_region_bot - row - num_lines + 1) - PEN_WIDTH;
-
- BRect source, dest;
-
- source.left = FILL_X(gui.scroll_region_left);
- source.top = FILL_Y(row + num_lines);
- source.right = source.left + width;
- source.bottom = source.top + height;
-
- dest.left = FILL_X(gui.scroll_region_left);
- dest.top = FILL_Y(row);
- dest.right = dest.left + width;
- dest.bottom = dest.top + height;
-
- /* XXX Attempt at a hack: */
- gui.vimWindow->UpdateIfNeeded();
-#if 0
- /* XXX Attempt at a hack: */
- if (gui.vimWindow->NeedsUpdate()) {
- fprintf(stderr, "mchDeleteLines: NeedsUpdate!\n");
- gui.vimWindow->UpdateIfNeeded();
- while (gui.vimWindow->NeedsUpdate()) {
- if (false && gui.vimWindow->Lock()) {
- Sync();
- gui.vimWindow->Unlock();
- }
- snooze(2);
- }
- }
-#endif
-
- if (gui.vimWindow->Lock()) {
- Sync();
- CopyBits(source, dest);
- //Sync();
-
- /* Update gui.cursor_row if the cursor scrolled or copied over */
- if (gui.cursor_row >= row
- && gui.cursor_col >= gui.scroll_region_left
- && gui.cursor_col <= gui.scroll_region_right)
- {
- if (gui.cursor_row < row + num_lines)
- gui.cursor_is_valid = FALSE;
- else if (gui.cursor_row <= gui.scroll_region_bot)
- gui.cursor_row -= num_lines;
- }
-
- /* Clear one column more for when bold has spilled over */
- gui_clear_block(gui.scroll_region_bot - num_lines + 1,
- gui.scroll_region_left,
- gui.scroll_region_bot, gui.scroll_region_right);
-
- gui.vimWindow->Unlock();
- /*
- * The Draw() callback will be called now if some of the source
- * bits were not in the visible region.
- */
-
- //gui_x11_check_copy_area();
- }
- }
-}
-
-/*
- * mchInsertLines() Lock()s the window by itself.
- */
- void
-VimTextAreaView::mchInsertLines(int row, int num_lines)
-{
- if (row + num_lines > gui.scroll_region_bot)
- {
- /* Scrolled out of region, just blank the lines out */
- gui_clear_block(row, gui.scroll_region_left,
- gui.scroll_region_bot, gui.scroll_region_right);
- }
- else
- {
- /* copy one extra pixel, for when bold has spilled over */
- int width = gui.char_width * (gui.scroll_region_right
- - gui.scroll_region_left + 1) + 1 - PEN_WIDTH;
- int height = gui.char_height *
- (gui.scroll_region_bot - row - num_lines + 1) - PEN_WIDTH;
-
- BRect source, dest;
-
- source.left = FILL_X(gui.scroll_region_left);
- source.top = FILL_Y(row);
- source.right = source.left + width;
- source.bottom = source.top + height;
-
- dest.left = FILL_X(gui.scroll_region_left);
- dest.top = FILL_Y(row + num_lines);
- dest.right = dest.left + width;
- dest.bottom = dest.top + height;
-
- /* XXX Attempt at a hack: */
- gui.vimWindow->UpdateIfNeeded();
-#if 0
- /* XXX Attempt at a hack: */
- if (gui.vimWindow->NeedsUpdate())
- fprintf(stderr, "mchInsertLines: NeedsUpdate!\n");
- gui.vimWindow->UpdateIfNeeded();
- while (gui.vimWindow->NeedsUpdate())
- snooze(2);
-#endif
-
- if (gui.vimWindow->Lock()) {
- Sync();
- CopyBits(source, dest);
- //Sync();
-
- /* Update gui.cursor_row if the cursor scrolled or copied over */
- if (gui.cursor_row >= gui.row
- && gui.cursor_col >= gui.scroll_region_left
- && gui.cursor_col <= gui.scroll_region_right)
- {
- if (gui.cursor_row <= gui.scroll_region_bot - num_lines)
- gui.cursor_row += num_lines;
- else if (gui.cursor_row <= gui.scroll_region_bot)
- gui.cursor_is_valid = FALSE;
- }
- /* Clear one column more for when bold has spilled over */
- gui_clear_block(row, gui.scroll_region_left,
- row + num_lines - 1, gui.scroll_region_right);
-
- gui.vimWindow->Unlock();
- /*
- * The Draw() callback will be called now if some of the source
- * bits were not in the visible region.
- * However, if we scroll too fast it can't keep up and the
- * update region gets messed up. This seems to be because copying
- * un-Draw()n bits does not generate Draw() calls for the copy...
- * I moved the hack to before the CopyBits() to reduce the
- * amount of additional waiting needed.
- */
-
- //gui_x11_check_copy_area();
- }
- }
-
-}
-
-/* ---------------- VimScrollBar ---------------- */
-
-/* BUG: XXX
- * It seems that BScrollBar determine their direction not from
- * "posture" but from if they are "tall" or "wide" in shape...
- *
- * Also, place them out of sight, because Vim enables them before
- * they are positioned.
- */
-VimScrollBar::VimScrollBar(scrollbar_T *g, orientation posture):
- BScrollBar(posture == B_HORIZONTAL ? BRect(-100,-100,-10,-90) :
- BRect(-100,-100,-90,-10),
- "vim scrollbar", (BView *)NULL,
- 0.0, 10.0, posture),
- ignoreValue(-1),
- scrollEventCount(0)
-{
- gsb = g;
- SetResizingMode(B_FOLLOW_NONE);
-}
-
-VimScrollBar::~VimScrollBar()
-{
-}
-
- void
-VimScrollBar::ValueChanged(float newValue)
-{
- if (ignoreValue >= 0.0 && newValue == ignoreValue) {
- ignoreValue = -1;
- return;
- }
- ignoreValue = -1;
- /*
- * We want to throttle the amount of scroll messages generated.
- * Normally I presume you won't get a new message before we've
- * handled the previous one, but because we're passing them on this
- * happens very quickly. So instead we keep a counter of how many
- * scroll events there are (or will be) in the VDCMP, and the
- * throttling happens at the receiving end.
- */
- atomic_add(&scrollEventCount, 1);
-
- struct VimScrollBarMsg sm;
-
- sm.sb = this;
- sm.value = (long) newValue;
- sm.stillDragging = TRUE;
-
- write_port(gui.vdcmp, VimMsg::ScrollBar, &sm, sizeof(sm));
-
- // calls gui_drag_scrollbar(sb, newValue, TRUE);
-}
-
-/*
- * When the mouse goes up, report that scrolling has stopped.
- * MouseUp() is NOT called when the mouse-up occurs outside
- * the window, even though the thumb does move while the mouse
- * is outside... This has some funny effects... XXX
- * So we do special processing when the window de/activates.
- */
- void
-VimScrollBar::MouseUp(BPoint where)
-{
- //BMessage *m = Window()->CurrentMessage();
- //m->PrintToStream();
-
- atomic_add(&scrollEventCount, 1);
-
- struct VimScrollBarMsg sm;
-
- sm.sb = this;
- sm.value = (long) Value();
- sm.stillDragging = FALSE;
-
- write_port(gui.vdcmp, VimMsg::ScrollBar, &sm, sizeof(sm));
-
- // calls gui_drag_scrollbar(sb, newValue, FALSE);
-
- Inherited::MouseUp(where);
-}
-
- void
-VimScrollBar::SetValue(float newValue)
-{
- if (newValue == Value())
- return;
-
- ignoreValue = newValue;
- Inherited::SetValue(newValue);
-}
-
-/* ---------------- VimFont ---------------- */
-
-VimFont::VimFont(): BFont()
-{
- init();
-}
-
-VimFont::VimFont(const VimFont *rhs): BFont(rhs)
-{
- init();
-}
-
-VimFont::VimFont(const BFont *rhs): BFont(rhs)
-{
- init();
-}
-
-VimFont::VimFont(const VimFont &rhs): BFont(rhs)
-{
- init();
-}
-
-VimFont::~VimFont()
-{
-}
-
- void
-VimFont::init()
-{
- next = NULL;
- refcount = 1;
- name = NULL;
-}
-
-/* ---------------- ---------------- */
-
-// some global variables
-static char appsig[] = "application/x-vnd.Rhialto-Vim-5";
-key_map *keyMap;
-char *keyMapChars;
-int main_exitcode = 127;
-
- status_t
-gui_beos_process_event(bigtime_t timeout)
-{
- struct VimMsg vm;
- long what;
- ssize_t size;
-
- size = read_port_etc(gui.vdcmp, &what, &vm, sizeof(vm),
- B_TIMEOUT, timeout);
-
- if (size >= 0) {
- switch (what) {
- case VimMsg::Key:
- {
- char_u *string = vm.u.Key.chars;
- int len = vm.u.Key.length;
- if (len == 1 && string[0] == Ctrl_chr('C')) {
- trash_input_buf();
- got_int = TRUE;
- }
- add_to_input_buf(string, len);
- }
- break;
- case VimMsg::Resize:
- gui_resize_shell(vm.u.NewSize.width, vm.u.NewSize.height);
- break;
- case VimMsg::ScrollBar:
- {
- /*
- * If loads of scroll messages queue up, use only the last
- * one. Always report when the scrollbar stops dragging.
- * This is not perfect yet anyway: these events are queued
- * yet again, this time in the keyboard input buffer.
- */
- int32 oldCount =
- atomic_add(&vm.u.Scroll.sb->scrollEventCount, -1);
- if (oldCount <= 1 || !vm.u.Scroll.stillDragging)
- gui_drag_scrollbar(vm.u.Scroll.sb->getGsb(),
- vm.u.Scroll.value, vm.u.Scroll.stillDragging);
- }
- break;
- case VimMsg::Menu:
- gui_menu_cb(vm.u.Menu.guiMenu);
- break;
- case VimMsg::Mouse:
- {
- int32 oldCount;
- if (vm.u.Mouse.button == MOUSE_DRAG)
- oldCount =
- atomic_add(&gui.vimTextArea->mouseDragEventCount, -1);
- else
- oldCount = 0;
- if (oldCount <= 1)
- gui_send_mouse_event(vm.u.Mouse.button, vm.u.Mouse.x,
- vm.u.Mouse.y, vm.u.Mouse.repeated_click,
- vm.u.Mouse.modifiers);
- }
- break;
- case VimMsg::Focus:
- gui.in_focus = vm.u.Focus.active;
- /* XXX Signal that scrollbar dragging has stopped?
- * This is needed because we don't get a MouseUp if
- * that happens while outside the window... :-(
- */
- if (gui.dragged_sb) {
- gui.dragged_sb = SBAR_NONE;
- }
- gui_update_cursor(TRUE, FALSE);
- break;
- case VimMsg::Refs:
- ::RefsReceived(vm.u.Refs.message, vm.u.Refs.changedir);
- break;
- default:
- // unrecognised message, ignore it
- break;
- }
- }
-
- /*
- * If size < B_OK, it is an error code.
- */
- return size;
-}
-
-/*
- * Here are some functions to protect access to ScreenLines[] and
- * LineOffset[]. These are used from the window thread to respond
- * to a Draw() callback. When that occurs, the window is already
- * locked by the system.
- *
- * Other code that needs to lock is any code that changes these
- * variables. Other read-only access, or access merely to the
- * contents of the screen buffer, need not be locked.
- *
- * If there is no window, don't call Lock() but do succeed.
- */
-
- int
-vim_lock_screen()
-{
- return !gui.vimWindow || gui.vimWindow->Lock();
-}
-
- void
-vim_unlock_screen()
-{
- if (gui.vimWindow)
- gui.vimWindow->Unlock();
-}
-
-#define RUN_BAPPLICATION_IN_NEW_THREAD 0
-
-#if RUN_BAPPLICATION_IN_NEW_THREAD
-
- int32
-run_vimapp(void *args)
-{
- VimApp app(appsig);
-
- gui.vimApp = &app;
- app.Run(); /* Run until Quit() called */
-
- return 0;
-}
-
-#else
-
- int32
-call_main(void *args)
-{
- struct MainArgs *ma = (MainArgs *)args;
-
- return main(ma->argc, ma->argv);
-}
-#endif
-
-extern "C" {
-
-/*
- * Parse the GUI related command-line arguments. Any arguments used are
- * deleted from argv, and *argc is decremented accordingly. This is called
- * when vim is started, whether or not the GUI has been started.
- */
- void
-gui_mch_prepare(
- int *argc,
- char **argv)
-{
- /*
- * We don't have any command line arguments for the BeOS GUI yet,
- * but this is an excellent place to create our Application object.
- */
- if (!gui.vimApp) {
- thread_info tinfo;
- get_thread_info(find_thread(NULL), &tinfo);
-
- /* May need the port very early on to process RefsReceived() */
- gui.vdcmp = create_port(B_MAX_PORT_COUNT, "vim VDCMP");
-
-#if RUN_BAPPLICATION_IN_NEW_THREAD
- thread_id tid = spawn_thread(run_vimapp, "vim VimApp",
- tinfo.priority, NULL);
- if (tid >= B_OK) {
- resume_thread(tid);
- } else {
- getout(1);
- }
-#else
- MainArgs ma = { *argc, argv };
- thread_id tid = spawn_thread(call_main, "vim main()",
- tinfo.priority, &ma);
- if (tid >= B_OK) {
- VimApp app(appsig);
-
- gui.vimApp = &app;
- resume_thread(tid);
- /*
- * This is rather horrible.
- * call_main will call main() again...
- * There will be no infinite recursion since
- * gui.vimApp is set now.
- */
- app.Run(); /* Run until Quit() called */
- //fprintf(stderr, "app.Run() returned...\n");
- status_t dummy_exitcode;
- (void)wait_for_thread(tid, &dummy_exitcode);
-
- /*
- * This path should be the normal one taken to exit Vim.
- * The main() thread calls mch_exit() which calls
- * gui_mch_exit() which terminates its thread.
- */
- exit(main_exitcode);
- }
-#endif
- }
- /* Don't fork() when starting the GUI. Spawned threads are not
- * duplicated with a fork(). The result is a mess.
- */
- gui.dofork = FALSE;
- /*
- * XXX Try to determine whether we were started from
- * the Tracker or the terminal.
- * It would be nice to have this work, because the Tracker
- * follows symlinks, so even if you double-click on gvim,
- * when it is a link to vim it will still pass a command name
- * of vim...
- * We try here to see if stdin comes from /dev/null. If so,
- * (or if there is an error, which should never happen) start the GUI.
- * This does the wrong thing for vim - </dev/null, and we're
- * too early to see the command line parsing. Tough.
- * On the other hand, it starts the gui for vim file & which is nice.
- */
- if (!isatty(0)) {
- struct stat stat_stdin, stat_dev_null;
-
- if (fstat(0, &stat_stdin) == -1 ||
- stat("/dev/null", &stat_dev_null) == -1 ||
- (stat_stdin.st_dev == stat_dev_null.st_dev &&
- stat_stdin.st_ino == stat_dev_null.st_ino))
- gui.starting = TRUE;
- }
-}
-
-/*
- * Check if the GUI can be started. Called before gvimrc is sourced.
- * Return OK or FAIL.
- */
- int
-gui_mch_init_check(void)
-{
- return OK; /* TODO: GUI can always be started? */
-}
-
-/*
- * Initialise the GUI. Create all the windows, set up all the call-backs
- * etc.
- */
- int
-gui_mch_init()
-{
- gui.def_norm_pixel = RGB(0x00, 0x00, 0x00); // black
- gui.def_back_pixel = RGB(0xFF, 0xFF, 0xFF); // white
- gui.norm_pixel = gui.def_norm_pixel;
- gui.back_pixel = gui.def_back_pixel;
-
- gui.scrollbar_width = (int) B_V_SCROLL_BAR_WIDTH;
- gui.scrollbar_height = (int) B_H_SCROLL_BAR_HEIGHT;
-#ifdef FEAT_MENU
- gui.menu_height = 19; // initial guess -
- // correct for my default settings
-#endif
- gui.border_offset = 3; // coordinates are inside window borders
-
- if (gui.vdcmp < B_OK)
- return FAIL;
- get_key_map(&keyMap, &keyMapChars);
-
- gui.vimWindow = new VimWindow(); /* hidden and locked */
- if (!gui.vimWindow)
- return FAIL;
-
- gui.vimWindow->Run(); /* Run() unlocks but does not show */
-
- /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc
- * file) */
- set_normal_colors();
-
- /*
- * Check that none of the colors are the same as the background color
- */
- gui_check_colors();
-
- /* Get the colors for the highlight groups (gui_check_colors() might have
- * changed them) */
- highlight_gui_started(); /* re-init colors and fonts */
-
- gui_mch_new_colors(); /* window must exist for this */
-
- return OK;
-}
-
-/*
- * Called when the foreground or background color has been changed.
- */
- void
-gui_mch_new_colors()
-{
- rgb_color rgb = GUI_TO_RGB(gui.back_pixel);
-
- if (gui.vimWindow->Lock()) {
- gui.vimForm->SetViewColor(rgb);
- // Does this not have too much effect for those small rectangles?
- gui.vimForm->Invalidate();
- gui.vimWindow->Unlock();
- }
-}
-
-/*
- * Open the GUI window which was created by a call to gui_mch_init().
- */
- int
-gui_mch_open()
-{
- if (gui_win_x != -1 && gui_win_y != -1)
- gui_mch_set_winpos(gui_win_x, gui_win_y);
-
- /* Actually open the window */
- if (gui.vimWindow->Lock()) {
- gui.vimWindow->Show();
- gui.vimWindow->Unlock();
-
-#if USE_THREAD_FOR_INPUT_WITH_TIMEOUT
- /* Kill the thread that may have been created for the Terminal */
- beos_cleanup_read_thread();
-#endif
-
- return OK;
- }
-
- return FAIL;
-}
-
- void
-gui_mch_exit(int vim_exitcode)
-{
- if (gui.vimWindow) {
- thread_id tid = gui.vimWindow->Thread();
- gui.vimWindow->Lock();
- gui.vimWindow->Quit();
- /* Wait until it is truely gone */
- int32 exitcode;
- wait_for_thread(tid, &exitcode);
- }
- delete_port(gui.vdcmp);
-#if !RUN_BAPPLICATION_IN_NEW_THREAD
- /*
- * We are in the main() thread - quit the App thread and
- * quit ourselves (passing on the exitcode). Use a global since the
- * value from exit_thread() is only used if wait_for_thread() is
- * called in time (race condition).
- */
-#endif
- if (gui.vimApp) {
- VimTextAreaView::guiBlankMouse(false);
-
- main_exitcode = vim_exitcode;
-#if RUN_BAPPLICATION_IN_NEW_THREAD
- thread_id tid = gui.vimApp->Thread();
- int32 exitcode;
- gui.vimApp->Lock();
- gui.vimApp->Quit();
- gui.vimApp->Unlock();
- wait_for_thread(tid, &exitcode);
-#else
- gui.vimApp->Lock();
- gui.vimApp->Quit();
- gui.vimApp->Unlock();
- /* suicide */
- exit_thread(vim_exitcode);
-#endif
- }
- /* If we are somehow still here, let mch_exit() handle things. */
-}
-
-/*
- * Get the position of the top left corner of the window.
- */
- int
-gui_mch_get_winpos(int *x, int *y)
-{
- /* TODO */
- return FAIL;
-}
-
-/*
- * Set the position of the top left corner of the window to the given
- * coordinates.
- */
- void
-gui_mch_set_winpos(int x, int y)
-{
- /* TODO */
-}
-
-/*
- * Set the size of the window to the given width and height in pixels.
- */
- void
-gui_mch_set_shellsize(
- int width,
- int height,
- int min_width,
- int min_height,
- int base_width,
- int base_height)
-{
- /*
- * We are basically given the size of the VimForm, if I understand
- * correctly. Since it fills the window completely, this will also
- * be the size of the window.
- */
- if (gui.vimWindow->Lock()) {
- gui.vimWindow->ResizeTo(width - PEN_WIDTH, height - PEN_WIDTH);
-
- /* set size limits */
- float minWidth, maxWidth, minHeight, maxHeight;
-
- gui.vimWindow->GetSizeLimits(&minWidth, &maxWidth,
- &minHeight, &maxHeight);
- gui.vimWindow->SetSizeLimits(min_width, maxWidth,
- min_height, maxHeight);
-
-#if HAVE_R3_OR_LATER
- /*
- * Set the resizing alignment depending on font size.
- * XXX This is untested, since I don't have R3 yet.
- */
- SetWindowAlignment(
- B_PIXEL_ALIGNMENT, // window_alignment mode,
- 1, // int32 h,
- 0, // int32 hOffset = 0,
- gui.char_width, // int32 width = 0,
- base_width, // int32 widthOffset = 0,
- 1, // int32 v = 0,
- 0, // int32 vOffset = 0,
- gui.char_height, // int32 height = 0,
- base_height // int32 heightOffset = 0
- );
-#else
- /* don't know what to do with base_{width,height}. */
-#endif
-
- gui.vimWindow->Unlock();
- }
-}
-
- void
-gui_mch_get_screen_dimensions(
- int *screen_w,
- int *screen_h)
-{
- BRect frame;
-
- {
- BScreen screen(gui.vimWindow);
-
- if (screen.IsValid()) {
- frame = screen.Frame();
- } else {
- frame.right = 640;
- frame.bottom = 480;
- }
- }
-
- /* XXX approximations... */
- *screen_w = (int) frame.right - 2 * gui.scrollbar_width - 20;
- *screen_h = (int) frame.bottom - gui.scrollbar_height
-#ifdef FEAT_MENU
- - gui.menu_height
-#endif
- - 30;
-}
-
- void
-gui_mch_set_text_area_pos(
- int x,
- int y,
- int w,
- int h)
-{
- if (!gui.vimTextArea)
- return;
-
- if (gui.vimWindow->Lock()) {
- gui.vimTextArea->MoveTo(x, y);
- gui.vimTextArea->ResizeTo(w - PEN_WIDTH, h - PEN_WIDTH);
- gui.vimWindow->Unlock();
- }
-}
-
-
-/*
- * Scrollbar stuff:
- */
-
- void
-gui_mch_enable_scrollbar(
- scrollbar_T *sb,
- int flag)
-{
- VimScrollBar *vsb = sb->id;
- if (gui.vimWindow->Lock()) {
- /*
- * This function is supposed to be idempotent, but Show()/Hide()
- * is not. Therefore we test if they are needed.
- */
- if (flag) {
- if (vsb->IsHidden()) {
- vsb->Show();
- }
- } else {
- if (!vsb->IsHidden()) {
- vsb->Hide();
- }
- }
- gui.vimWindow->Unlock();
- }
-}
-
- void
-gui_mch_set_scrollbar_thumb(
- scrollbar_T *sb,
- int val,
- int size,
- int max)
-{
- if (gui.vimWindow->Lock()) {
- VimScrollBar *s = sb->id;
- if (max == 0) {
- s->SetValue(0);
- s->SetRange(0.0, 0.0);
- } else {
- s->SetProportion((float)size / (max + 1.0));
- s->SetSteps(1.0, size > 5 ? size - 2 : size);
-#ifndef SCROLL_PAST_END // really only defined in gui.c...
- max = max + 1 - size;
-#endif
- if (max < s->Value()) {
- /*
- * If the new maximum is lower than the current value,
- * setting it would cause the value to be clipped and
- * therefore a ValueChanged() call.
- * We avoid this by setting the value first, because
- * it presumably is <= max.
- */
- s->SetValue(val);
- s->SetRange(0.0, max);
- } else {
- /*
- * In the other case, set the range first, since the
- * new value might be higher than the current max.
- */
- s->SetRange(0.0, max);
- s->SetValue(val);
- }
- }
- gui.vimWindow->Unlock();
- }
-}
-
- void
-gui_mch_set_scrollbar_pos(
- scrollbar_T *sb,
- int x,
- int y,
- int w,
- int h)
-{
- if (gui.vimWindow->Lock()) {
- VimScrollBar *vsb = sb->id;
- vsb->MoveTo(x, y);
- vsb->ResizeTo(w - PEN_WIDTH, h - PEN_WIDTH);
- gui.vimWindow->Unlock();
- }
-}
-
- void
-gui_mch_create_scrollbar(
- scrollbar_T *sb,
- int orient) /* SBAR_VERT or SBAR_HORIZ */
-{
- orientation posture =
- (orient == SBAR_HORIZ) ? B_HORIZONTAL : B_VERTICAL;
-
- VimScrollBar *vsb = sb->id = new VimScrollBar(sb, posture);
- if (gui.vimWindow->Lock()) {
- vsb->SetTarget(gui.vimTextArea);
- vsb->Hide();
- gui.vimForm->AddChild(vsb);
- gui.vimWindow->Unlock();
- }
-}
-
-#if defined(FEAT_WINDOWS) || defined(PROTO)
- void
-gui_mch_destroy_scrollbar(
- scrollbar_T *sb)
-{
- if (gui.vimWindow->Lock()) {
- sb->id->RemoveSelf();
- delete sb->id;
- gui.vimWindow->Unlock();
- }
-}
-#endif
-
-/*
- * Cursor blink functions.
- *
- * This is a simple state machine:
- * BLINK_NONE not blinking at all
- * BLINK_OFF blinking, cursor is not shown
- * BLINK_ON blinking, cursor is shown
- */
-
-#define BLINK_NONE 0
-#define BLINK_OFF 1
-#define BLINK_ON 2
-
-static int blink_state = BLINK_NONE;
-static long_u blink_waittime = 700;
-static long_u blink_ontime = 400;
-static long_u blink_offtime = 250;
-static int blink_timer = 0;
-
- void
-gui_mch_set_blinking(
- long waittime,
- long on,
- long off)
-{
- /* TODO */
- blink_waittime = waittime;
- blink_ontime = on;
- blink_offtime = off;
-}
-
-/*
- * Stop the cursor blinking. Show the cursor if it wasn't shown.
- */
- void
-gui_mch_stop_blink()
-{
- /* TODO */
- if (blink_timer != 0)
- {
- //XtRemoveTimeOut(blink_timer);
- blink_timer = 0;
- }
- if (blink_state == BLINK_OFF)
- gui_update_cursor(TRUE, FALSE);
- blink_state = BLINK_NONE;
-}
-
-/*
- * Start the cursor blinking. If it was already blinking, this restarts the
- * waiting time and shows the cursor.
- */
- void
-gui_mch_start_blink()
-{
- /* TODO */
- if (blink_timer != 0)
- ;//XtRemoveTimeOut(blink_timer);
- /* Only switch blinking on if none of the times is zero */
- if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus)
- {
- blink_timer = 1; //XtAppAddTimeOut(app_context, blink_waittime,
- blink_state = BLINK_ON;
- gui_update_cursor(TRUE, FALSE);
- }
-}
-
-/*
- * Initialise vim to use the font with the given name. Return FAIL if the font
- * could not be loaded, OK otherwise.
- */
- int
-gui_mch_init_font(
- char_u *font_name,
- int fontset)
-{
- if (gui.vimWindow->Lock())
- {
- int rc = gui.vimTextArea->mchInitFont(font_name);
- gui.vimWindow->Unlock();
-
- return rc;
- }
-
- return FAIL;
-}
-
- int
-gui_mch_adjust_charsize()
-{
- return FAIL;
-}
-
- GuiFont
-gui_mch_get_font(
- char_u *name,
- int giveErrorIfMissing)
-{
- VimFont *font = 0;
- static VimFont *fontList = NULL;
-
- if (!gui.in_use) /* can't do this when GUI not running */
- return NOFONT;
-
- if (!name)
- name = (char_u *)"be_fixed_font";
-
- VimFont *flp;
- for (flp = fontList; flp; flp = flp->next) {
- if (STRCMP(name, flp->name) == 0) {
- flp->refcount++;
- return (GuiFont)flp;
- }
- }
-
- font = new VimFont(be_fixed_font);
-
- /* Set some universal features: */
- font->SetSpacing(B_FIXED_SPACING);
- font->SetEncoding(B_ISO_8859_1);
-
- /* Remember font for later use */
- font->name = vim_strsave(name);
- font->next = fontList;
- fontList = font;
-
- font_family family;
- font_style style;
- int size;
- int len;
- char_u *end;
-
-#ifdef never
- // This leads to SEGV/BUS on R4+
- // Replace underscores with spaces, and I can't see why ?
- // richard@whitequeen.com jul 99
- while (end = (char_u *)strchr((char *)name, '_'))
- *end = ' ';
-#endif
- /*
- * Parse font names as Family/Style/Size.
- * On errors, just keep the be_fixed_font.
- */
- end = (char_u *)strchr((char *)name, '/');
- if (!end)
- goto error;
- strncpy(family, (char *)name, len = end - name);
- family[len] = '\0';
-
- name = end + 1;
- end = (char_u *)strchr((char *)name, '/');
- if (!end)
- goto error;
- strncpy(style, (char *)name, len = end - name);
- style[len] = '\0';
-
- name = end + 1;
- size = atoi((char *)name);
- if (size <= 0)
- goto error;
-
- font->SetFamilyAndStyle(family, style);
- font->SetSize(size);
- font->SetSpacing(B_FIXED_SPACING);
- font->SetEncoding(B_ISO_8859_1);
- //font->PrintToStream();
-
- return (GuiFont)font;
-
-error:
- if (giveErrorIfMissing)
- EMSG2("(fe0) Unknown font: %s", name);
-
- return (GuiFont)font;
-}
-
-#if defined(FEAT_EVAL) || defined(PROTO)
-/*
- * Return the name of font "font" in allocated memory.
- */
- char_u *
-gui_mch_get_fontname(GuiFont font, char_u *name)
-{
- return vim_strsave(((VimFont *)font)->name);
-}
-#endif
-
-/*
- * Set the current text font.
- */
- void
-gui_mch_set_font(
- GuiFont font)
-{
- if (gui.vimWindow->Lock()) {
- VimFont *vf = (VimFont *)font;
-
- gui.vimTextArea->SetFont(vf);
-
- gui.char_width = (int) vf->StringWidth("n");
- font_height fh;
- vf->GetHeight(&fh);
- gui.char_height = (int)(fh.ascent + 0.9999)
- + (int)(fh.descent + 0.9999) + (int)(fh.leading + 0.9999);
- gui.char_ascent = (int)(fh.ascent + 0.9999);
-
- gui.vimWindow->Unlock();
- }
-}
-
-#if 0 /* not used */
-/*
- * Return TRUE if the two fonts given are equivalent.
- */
- int
-gui_mch_same_font(
- GuiFont f1,
- GuiFont f2)
-{
- VimFont *vf1 = (VimFont *)f1;
- VimFont *vf2 = (VimFont *)f2;
-
- return f1 == f2 ||
- (vf1->FamilyAndStyle() == vf2->FamilyAndStyle() &&
- vf1->Size() == vf2->Size());
-}
-#endif
-
-/* XXX TODO This is apparently never called... */
- void
-gui_mch_free_font(
- GuiFont font)
-{
- VimFont *f = (VimFont *)font;
- if (--f->refcount <= 0) {
- if (f->refcount < 0)
- fprintf(stderr, "VimFont: refcount < 0\n");
- delete f;
- }
-}
-
- static int
-hex_digit(int c)
-{
- if (isdigit(c))
- return c - '0';
- c = TOLOWER_ASC(c);
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- return -1000;
-}
-
-/*
- * This function has been lifted from gui_w32.c and extended a bit.
- *
- * Return the Pixel value (color) for the given color name.
- * Return INVALCOLOR for error.
- */
- guicolor_T
-gui_mch_get_color(
- char_u *name)
-{
- typedef struct GuiColourTable
- {
- char *name;
- guicolor_T colour;
- } GuiColourTable;
-
-#define NSTATIC_COLOURS 32
-#define NDYNAMIC_COLOURS 33
-#define NCOLOURS (NSTATIC_COLOURS + NDYNAMIC_COLOURS)
-
- static GuiColourTable table[NCOLOURS] =
- {
- {"Black", RGB(0x00, 0x00, 0x00)},
- {"DarkGray", RGB(0x80, 0x80, 0x80)},
- {"DarkGrey", RGB(0x80, 0x80, 0x80)},
- {"Gray", RGB(0xC0, 0xC0, 0xC0)},
- {"Grey", RGB(0xC0, 0xC0, 0xC0)},
- {"LightGray", RGB(0xD3, 0xD3, 0xD3)},
- {"LightGrey", RGB(0xD3, 0xD3, 0xD3)},
- {"White", RGB(0xFF, 0xFF, 0xFF)},
- {"DarkRed", RGB(0x80, 0x00, 0x00)},
- {"Red", RGB(0xFF, 0x00, 0x00)},
- {"LightRed", RGB(0xFF, 0xA0, 0xA0)},
- {"DarkBlue", RGB(0x00, 0x00, 0x80)},
- {"Blue", RGB(0x00, 0x00, 0xFF)},
- {"LightBlue", RGB(0xA0, 0xA0, 0xFF)},
- {"DarkGreen", RGB(0x00, 0x80, 0x00)},
- {"Green", RGB(0x00, 0xFF, 0x00)},
- {"LightGreen", RGB(0xA0, 0xFF, 0xA0)},
- {"DarkCyan", RGB(0x00, 0x80, 0x80)},
- {"Cyan", RGB(0x00, 0xFF, 0xFF)},
- {"LightCyan", RGB(0xA0, 0xFF, 0xFF)},
- {"DarkMagenta", RGB(0x80, 0x00, 0x80)},
- {"Magenta", RGB(0xFF, 0x00, 0xFF)},
- {"LightMagenta", RGB(0xFF, 0xA0, 0xFF)},
- {"Brown", RGB(0x80, 0x40, 0x40)},
- {"Yellow", RGB(0xFF, 0xFF, 0x00)},
- {"LightYellow", RGB(0xFF, 0xFF, 0xA0)},
- {"DarkYellow", RGB(0xBB, 0xBB, 0x00)},
- {"SeaGreen", RGB(0x2E, 0x8B, 0x57)},
- {"Orange", RGB(0xFF, 0xA5, 0x00)},
- {"Purple", RGB(0xA0, 0x20, 0xF0)},
- {"SlateBlue", RGB(0x6A, 0x5A, 0xCD)},
- {"Violet", RGB(0xEE, 0x82, 0xEE)},
- };
-
- static int endColour = NSTATIC_COLOURS;
- static int newColour = NSTATIC_COLOURS;
-
- int r, g, b;
- int i;
-
- if (name[0] == '#' && STRLEN(name) == 7)
- {
- /* Name is in "#rrggbb" format */
- r = hex_digit(name[1]) * 16 + hex_digit(name[2]);
- g = hex_digit(name[3]) * 16 + hex_digit(name[4]);
- b = hex_digit(name[5]) * 16 + hex_digit(name[6]);
- if (r < 0 || g < 0 || b < 0)
- return INVALCOLOR;
- return RGB(r, g, b);
- }
- else
- {
- /* Check if the name is one of the colours we know */
- for (i = 0; i < endColour; i++)
- if (STRICMP(name, table[i].name) == 0)
- return table[i].colour;
- }
-
- /*
- * Last attempt. Look in the file "$VIM/rgb.txt".
- */
- {
-#define LINE_LEN 100
- FILE *fd;
- char line[LINE_LEN];
- char_u *fname;
-
- fname = expand_env_save((char_u *)"$VIM/rgb.txt");
- if (fname == NULL)
- return INVALCOLOR;
-
- fd = fopen((char *)fname, "rt");
- vim_free(fname);
- if (fd == NULL)
- return INVALCOLOR;
-
- while (!feof(fd))
- {
- int len;
- int pos;
- char *colour;
-
- fgets(line, LINE_LEN, fd);
- len = strlen(line);
-
- if (len <= 1 || line[len-1] != '\n')
- continue;
-
- line[len-1] = '\0';
-
- i = sscanf(line, "%d %d %d %n", &r, &g, &b, &pos);
- if (i != 3)
- continue;
-
- colour = line + pos;
-
- if (STRICMP(colour, name) == 0)
- {
- fclose(fd);
- /*
- * Now remember this colour in the table.
- * A LRU scheme might be better but this is simpler.
- * Or could use a growing array.
- */
- guicolor_T gcolour = RGB(r,g,b);
-
- vim_free(table[newColour].name);
- table[newColour].name = (char *)vim_strsave((char_u *)colour);
- table[newColour].colour = gcolour;
-
- newColour++;
- if (newColour >= NCOLOURS)
- newColour = NSTATIC_COLOURS;
- if (endColour < NCOLOURS)
- endColour = newColour;
-
- return gcolour;
- }
- }
-
- fclose(fd);
- }
-
- return INVALCOLOR;
-}
-
-/*
- * Set the current text foreground color.
- */
- void
-gui_mch_set_fg_color(
- guicolor_T color)
-{
- rgb_color rgb = GUI_TO_RGB(color);
- if (gui.vimWindow->Lock()) {
- gui.vimTextArea->SetHighColor(rgb);
- gui.vimWindow->Unlock();
- }
-}
-
-/*
- * Set the current text background color.
- */
- void
-gui_mch_set_bg_color(
- guicolor_T color)
-{
- rgb_color rgb = GUI_TO_RGB(color);
- if (gui.vimWindow->Lock()) {
- gui.vimTextArea->SetLowColor(rgb);
- gui.vimWindow->Unlock();
- }
-}
-
- void
-gui_mch_draw_string(
- int row,
- int col,
- char_u *s,
- int len,
- int flags)
-{
- if (gui.vimWindow->Lock()) {
- gui.vimTextArea->mchDrawString(row, col, s, len, flags);
- gui.vimWindow->Unlock();
- }
-}
-
-/*
- * Return OK if the key with the termcap name "name" is supported.
- */
- int
-gui_mch_haskey(
- char_u *name)
-{
- int i;
-
- for (i = 0; special_keys[i].BeKeys != 0; i++)
- if (name[0] == special_keys[i].vim_code0 &&
- name[1] == special_keys[i].vim_code1)
- return OK;
- return FAIL;
-}
-
- void
-gui_mch_beep()
-{
- ::beep();
-}
-
- void
-gui_mch_flash(int msec)
-{
- /* Do a visual beep by reversing the foreground and background colors */
-
- if (gui.vimWindow->Lock()) {
- BRect rect = gui.vimTextArea->Bounds();
-
- gui.vimTextArea->SetDrawingMode(B_OP_INVERT);
- gui.vimTextArea->FillRect(rect);
- gui.vimTextArea->Sync();
- snooze(msec * 1000); /* wait for a few msec */
- gui.vimTextArea->FillRect(rect);
- gui.vimTextArea->SetDrawingMode(B_OP_COPY);
- gui.vimTextArea->Flush();
- gui.vimWindow->Unlock();
- }
-}
-
-/*
- * Invert a rectangle from row r, column c, for nr rows and nc columns.
- */
- void
-gui_mch_invert_rectangle(
- int r,
- int c,
- int nr,
- int nc)
-{
- BRect rect;
- rect.left = FILL_X(c);
- rect.top = FILL_Y(r);
- rect.right = rect.left + nc * gui.char_width - PEN_WIDTH;
- rect.bottom = rect.top + nr * gui.char_height - PEN_WIDTH;
-
- if (gui.vimWindow->Lock()) {
- gui.vimTextArea->SetDrawingMode(B_OP_INVERT);
- gui.vimTextArea->FillRect(rect);
- gui.vimTextArea->SetDrawingMode(B_OP_COPY);
- gui.vimWindow->Unlock();
- }
-}
-
-/*
- * Iconify the GUI window.
- */
- void
-gui_mch_iconify()
-{
- if (gui.vimWindow->Lock()) {
- gui.vimWindow->Minimize(true);
- gui.vimWindow->Unlock();
- }
-}
-
-#if defined(FEAT_EVAL) || defined(PROTO)
-/*
- * Bring the Vim window to the foreground.
- */
- void
-gui_mch_set_foreground()
-{
- /* TODO */
-}
-#endif
-
-/*
- * Set the window title
- */
- void
-gui_mch_settitle(
- char_u *title,
- char_u *icon)
-{
- if (gui.vimWindow->Lock()) {
- gui.vimWindow->SetTitle((char *)title);
- gui.vimWindow->Unlock();
- }
-}
-
-/*
- * Draw a cursor without focus.
- */
- void
-gui_mch_draw_hollow_cursor(guicolor_T color)
-{
- gui_mch_set_fg_color(color);
-
- BRect r;
- r.left = FILL_X(gui.col);
- r.top = FILL_Y(gui.row);
- r.right = r.left + gui.char_width - PEN_WIDTH;
- r.bottom = r.top + gui.char_height - PEN_WIDTH;
-
- if (gui.vimWindow->Lock()) {
- gui.vimTextArea->StrokeRect(r);
- gui.vimWindow->Unlock();
- //gui_mch_flush();
- }
-}
-
-/*
- * Draw part of a cursor, only w pixels wide, and h pixels high.
- */
- void
-gui_mch_draw_part_cursor(
- int w,
- int h,
- guicolor_T color)
-{
- gui_mch_set_fg_color(color);
-
- BRect r;
- r.left =
-#ifdef FEAT_RIGHTLEFT
- /* vertical line should be on the right of current point */
- CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w :
-#endif
- FILL_X(gui.col);
- r.right = r.left + w - PEN_WIDTH;
- r.bottom = FILL_Y(gui.row + 1) - PEN_WIDTH;
- r.top = r.bottom - h + PEN_WIDTH;
-
- if (gui.vimWindow->Lock()) {
- gui.vimTextArea->FillRect(r);
- gui.vimWindow->Unlock();
- //gui_mch_flush();
- }
-}
-
-/*
- * Catch up with any queued events. This may put keyboard input into the
- * input buffer, call resize call-backs, trigger timers etc. If there is
- * nothing in the event queue (& no timers pending), then we return
- * immediately.
- */
- void
-gui_mch_update()
-{
- gui_mch_flush();
- while (port_count(gui.vdcmp) > 0 &&
- !vim_is_input_buf_full() &&
- gui_beos_process_event(0) >= B_OK)
- /* nothing */ ;
-}
-
-/*
- * GUI input routine called by gui_wait_for_chars(). Waits for a character
- * from the keyboard.
- * wtime == -1 Wait forever.
- * wtime == 0 This should never happen.
- * wtime > 0 Wait wtime milliseconds for a character.
- * Returns OK if a character was found to be available within the given time,
- * or FAIL otherwise.
- */
- int
-gui_mch_wait_for_chars(
- int wtime)
-{
- int focus;
- bigtime_t until, timeout;
- status_t st;
-
- if (wtime >= 0) {
- timeout = wtime * 1000;
- until = system_time() + timeout;
- } else {
- timeout = B_INFINITE_TIMEOUT;
- }
-
- focus = gui.in_focus;
- for (;;)
- {
- /* Stop or start blinking when focus changes */
- if (gui.in_focus != focus)
- {
- if (gui.in_focus)
- gui_mch_start_blink();
- else
- gui_mch_stop_blink();
- focus = gui.in_focus;
- }
-
- gui_mch_flush();
- /*
- * Don't use gui_mch_update() because then we will spin-lock until a
- * char arrives, instead we use gui_beos_process_event() to hang until
- * an event arrives. No need to check for input_buf_full because we
- * are returning as soon as it contains a single char.
- */
- st = gui_beos_process_event(timeout);
-
- if (input_available())
- return OK;
- if (st < B_OK) /* includes B_TIMED_OUT */
- return FAIL;
-
- /*
- * Calculate how much longer we're willing to wait for the
- * next event.
- */
- if (wtime >= 0) {
- timeout = until - system_time();
- if (timeout < 0)
- break;
- }
- }
- return FAIL;
-
-}
-
-/*
- * Output routines.
- */
-
-/*
- * Flush any output to the screen. This is typically called before
- * the app goes to sleep.
- */
- void
-gui_mch_flush()
-{
- // does this need to lock the window? Apparently not but be safe.
- if (gui.vimWindow->Lock()) {
- gui.vimWindow->Flush();
- gui.vimWindow->Unlock();
- }
- return;
-}
-
-/*
- * Clear a rectangular region of the screen from text pos (row1, col1) to
- * (row2, col2) inclusive.
- */
- void
-gui_mch_clear_block(
- int row1,
- int col1,
- int row2,
- int col2)
-{
- if (gui.vimWindow->Lock()) {
- gui.vimTextArea->mchClearBlock(row1, col1, row2, col2);
- gui.vimWindow->Unlock();
- }
-}
-
- void
-gui_mch_clear_all()
-{
- if (gui.vimWindow->Lock()) {
- gui.vimTextArea->mchClearAll();
- gui.vimWindow->Unlock();
- }
-}
-
-/*
- * Delete the given number of lines from the given row, scrolling up any
- * text further down within the scroll region.
- */
- void
-gui_mch_delete_lines(
- int row,
- int num_lines)
-{
- gui.vimTextArea->mchDeleteLines(row, num_lines);
-}
-
-/*
- * Insert the given number of lines before the given row, scrolling down any
- * following text within the scroll region.
- */
- void
-gui_mch_insert_lines(
- int row,
- int num_lines)
-{
- gui.vimTextArea->mchInsertLines(row, num_lines);
-}
-
-#if defined(FEAT_MENU) || defined(PROTO)
-/*
- * Menu stuff.
- */
-
- void
-gui_mch_enable_menu(
- int flag)
-{
- if (gui.vimWindow->Lock())
- {
- BMenuBar *menubar = gui.vimForm->MenuBar();
- menubar->SetEnabled(flag);
- gui.vimWindow->Unlock();
- }
-}
-
- void
-gui_mch_set_menu_pos(
- int x,
- int y,
- int w,
- int h)
-{
- /* It will be in the right place anyway */
-}
-
-/*
- * Add a sub menu to the menu bar.
- */
- void
-gui_mch_add_menu(
- vimmenu_T *menu,
- int idx)
-{
- vimmenu_T *parent = menu->parent;
-
- if (!menu_is_menubar(menu->name)
- || (parent != NULL && parent->submenu_id == NULL))
- return;
-
- if (gui.vimWindow->Lock())
- {
-/* Major re-write of the menu code, it was failing with memory corruption when
- * we started loading multiple files (the Buffer menu)
- *
- * Note we don't use the preference values yet, all are inserted into the
- * menubar on a first come-first served basis...
- *
- * richard@whitequeen.com jul 99
- */
-
- BMenu *tmp;
-
- if ( parent )
- tmp = parent->submenu_id;
- else
- tmp = gui.vimForm->MenuBar();
-// make sure we don't try and add the same menu twice. The Buffers menu tries to
-// do this and Be starts to crash...
-
- if ( ! tmp->FindItem((const char *) menu->dname)) {
-
- BMenu *bmenu = new BMenu((char *)menu->dname);
-
- menu->submenu_id = bmenu;
-
-// when we add a BMenu to another Menu, it creates the interconnecting BMenuItem
- tmp->AddItem(bmenu);
-
-// Now its safe to query the menu for the associated MenuItem....
- menu->id = tmp->FindItem((const char *) menu->dname);
-
- }
- gui.vimWindow->Unlock();
- }
-}
-
- void
-gui_mch_toggle_tearoffs(int enable)
-{
- /* no tearoff menus */
-}
-
- static BMessage *
-MenuMessage(vimmenu_T *menu)
-{
- BMessage *m = new BMessage('menu');
- m->AddPointer("VimMenu", (void *)menu);
-
- return m;
-}
-
-/*
- * Add a menu item to a menu
- */
- void
-gui_mch_add_menu_item(
- vimmenu_T *menu,
- int idx)
-{
- int mnemonic = 0;
- vimmenu_T *parent = menu->parent;
-
- if (parent->submenu_id == NULL)
- return;
-
-#ifdef never
- /* why not add separators ?
- * richard
- */
- /* Don't add menu separator */
- if (menu_is_separator(menu->name))
- return;
-#endif
-
- /* TODO: use menu->actext */
- /* This is difficult, since on Be, an accelerator must be a single char
- * and a lot of Vim ones are the standard VI commands.
- *
- * Punt for Now...
- * richard@whiequeen.com jul 99
- */
- if (gui.vimWindow->Lock())
- {
- if ( menu_is_separator(menu->name)) {
- BSeparatorItem *item = new BSeparatorItem();
- parent->submenu_id->AddItem(item);
- menu->id = item;
- menu->submenu_id = NULL;
- }
- else {
- BMenuItem *item = new BMenuItem((char *)menu->dname,
- MenuMessage(menu));
- item->SetTarget(gui.vimTextArea);
- item->SetTrigger((char) menu->mnemonic);
- parent->submenu_id->AddItem(item);
- menu->id = item;
- menu->submenu_id = NULL;
- }
- gui.vimWindow->Unlock();
- }
-}
-
-/*
- * Destroy the machine specific menu widget.
- */
- void
-gui_mch_destroy_menu(
- vimmenu_T *menu)
-{
- if (gui.vimWindow->Lock())
- {
- assert(menu->submenu_id == NULL || menu->submenu_id->CountItems() == 0);
- /*
- * Detach this menu from its parent, so that it is not deleted
- * twice once we get to delete that parent.
- * Deleting a BMenuItem also deletes the associated BMenu, if any
- * (which does not have any items anymore since they were
- * removed and deleted before).
- */
- BMenu *bmenu = menu->id->Menu();
- if (bmenu)
- {
- bmenu->RemoveItem(menu->id);
- /*
- * If we removed the last item from the menu bar,
- * resize it out of sight.
- */
- if (bmenu == gui.vimForm->MenuBar() && bmenu->CountItems() == 0)
- {
- bmenu->ResizeTo(-MENUBAR_MARGIN, -MENUBAR_MARGIN);
- }
- }
- delete menu->id;
- menu->id = NULL;
- menu->submenu_id = NULL;
-
- gui.menu_height = (int) gui.vimForm->MenuHeight();
- gui.vimWindow->Unlock();
- }
-}
-
-/*
- * Make a menu either grey or not grey.
- */
- void
-gui_mch_menu_grey(
- vimmenu_T *menu,
- int grey)
-{
- if (menu->id != NULL)
- menu->id->SetEnabled(!grey);
-}
-
-/*
- * Make menu item hidden or not hidden
- */
- void
-gui_mch_menu_hidden(
- vimmenu_T *menu,
- int hidden)
-{
- if (menu->id != NULL)
- menu->id->SetEnabled(!hidden);
-}
-
-/*
- * This is called after setting all the menus to grey/hidden or not.
- */
- void
-gui_mch_draw_menubar()
-{
- /* Nothing to do in BeOS */
-}
-
-#endif /* FEAT_MENU */
-
-/* Mouse stuff */
-
-#ifdef FEAT_CLIPBOARD
-/*
- * Clipboard stuff, for cutting and pasting text to other windows.
- */
-char textplain[] = "text/plain";
-char vimselectiontype[] = "application/x-vnd.Rhialto-Vim-selectiontype";
-
-/*
- * Get the current selection and put it in the clipboard register.
- */
- void
-clip_mch_request_selection(VimClipboard *cbd)
-{
- if (be_clipboard->Lock())
- {
- BMessage *m = be_clipboard->Data();
- //m->PrintToStream();
-
- char_u *string = NULL;
- ssize_t stringlen = -1;
-
- if (m->FindData(textplain, B_MIME_TYPE,
- (const void **)&string, &stringlen) == B_OK
- || m->FindString("text", (const char **)&string) == B_OK)
- {
- if (stringlen == -1)
- stringlen = STRLEN(string);
-
- int type;
- char *seltype;
- ssize_t seltypelen;
-
- /*
- * Try to get the special vim selection type first
- */
- if (m->FindData(vimselectiontype, B_MIME_TYPE,
- (const void **)&seltype, &seltypelen) == B_OK)
- {
- switch (*seltype)
- {
- default:
- case 'L': type = MLINE; break;
- case 'C': type = MCHAR; break;
-#ifdef FEAT_VISUAL
- case 'B': type = MBLOCK; break;
-#endif
- }
- }
- else
- {
- /* Otherwise use heuristic as documented */
- type = memchr(string, stringlen, '\n') ? MLINE : MCHAR;
- }
- clip_yank_selection(type, string, (long)stringlen, cbd);
- }
- be_clipboard->Unlock();
- }
-}
-/*
- * Make vim the owner of the current selection.
- */
- void
-clip_mch_lose_selection(VimClipboard *cbd)
-{
- /* Nothing needs to be done here */
-}
-
-/*
- * Make vim the owner of the current selection. Return OK upon success.
- */
- int
-clip_mch_own_selection(VimClipboard *cbd)
-{
- /*
- * Never actually own the clipboard. If another application sets the
- * clipboard, we don't want to think that we still own it.
- */
- return FAIL;
-}
-
-/*
- * Send the current selection to the clipboard.
- */
- void
-clip_mch_set_selection(VimClipboard *cbd)
-{
- if (be_clipboard->Lock())
- {
- be_clipboard->Clear();
- BMessage *m = be_clipboard->Data();
- assert(m);
-
- /* If the '*' register isn't already filled in, fill it in now */
- cbd->owned = TRUE;
- clip_get_selection(cbd);
- cbd->owned = FALSE;
-
- char_u *str = NULL;
- long_u count;
- int type;
-
- type = clip_convert_selection(&str, &count, cbd);
-
- if (type < 0)
- return;
-
- m->AddData(textplain, B_MIME_TYPE, (void *)str, count);
-
- /* Add type of selection */
- char vtype;
- switch (type)
- {
- default:
- case MLINE: vtype = 'L'; break;
- case MCHAR: vtype = 'C'; break;
-#ifdef FEAT_VISUAL
- case MBLOCK: vtype = 'B'; break;
-#endif
- }
- m->AddData(vimselectiontype, B_MIME_TYPE, (void *)&vtype, 1);
-
- vim_free(str);
-
- be_clipboard->Commit();
- be_clipboard->Unlock();
- }
-}
-
-#endif /* FEAT_CLIPBOARD */
-
-/*
- * Return the RGB value of a pixel as long.
- */
- long_u
-gui_mch_get_rgb(guicolor_T pixel)
-{
- rgb_color rgb = GUI_TO_RGB(pixel);
-
- return ((rgb.red & 0xff) << 16) + ((rgb.green & 0xff) << 8)
- + (rgb.blue & 0xff);
-}
-
- void
-gui_mch_setmouse(int x, int y)
-{
- TRACE();
- /* TODO */
-}
-
- void
-gui_mch_show_popupmenu(vimmenu_T *menu)
-{
- TRACE();
- /* TODO */
-}
-
-int
-gui_mch_get_mouse_x()
-{
- TRACE();
- return 0;
-}
-
-
-int
-gui_mch_get_mouse_y()
-{
- TRACE();
- return 0;
-}
-
-} /* extern "C" */
diff --git a/src/gui_beos.h b/src/gui_beos.h
deleted file mode 100644
index b2fc4585..00000000
--- a/src/gui_beos.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* vi:set ts=8 sts=4 sw=4:
- *
- * VIM - Vi IMproved by Bram Moolenaar
- * GUI support by Olaf "Rhialto" Seibert
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- *
- * BeOS GUI.
- *
- * GUI support for the Buzzword Enhanced Operating System for PPC.
- *
- */
-
-/*
- * This file must be acceptable both as C and C++.
- * The BeOS API is defined in terms of C++, but some classes
- * should be somewhat known in the common C code.
- */
-
-/* System classes */
-
-struct BMenu;
-struct BMenuItem;
-
-/* Our own Vim-related classes */
-
-struct VimApp;
-struct VimFormView;
-struct VimTextAreaView;
-struct VimWindow;
-struct VimScrollBar;
-
-/* Locking functions */
-
-extern int vim_lock_screen();
-extern void vim_unlock_screen();
-
-#ifndef __cplusplus
-
-typedef struct BMenu BMenu;
-typedef struct BMenuItem BMenuItem;
-typedef struct VimWindow VimWindow;
-typedef struct VimFormView VimFormView;
-typedef struct VimTextAreaView VimTextAreaView;
-typedef struct VimApp VimApp;
-typedef struct VimScrollBar VimScrollBar;
-
-#endif
diff --git a/src/proto/gui_amiga.pro b/src/proto/gui_amiga.pro
deleted file mode 100644
index 2f8d2ac5..00000000
--- a/src/proto/gui_amiga.pro
+++ /dev/null
@@ -1,69 +0,0 @@
-/* gui_amiga.c */
-void gui_mch_add_menu_item __ARGS((vimmenu_T *menu, int idx));
-void gui_mch_add_menu __ARGS((vimmenu_T *menu, int idx));
-void gui_mch_toggle_tearoffs __ARGS((int enable));
-int gui_mch_set_blinking __ARGS((long wait, long on, long off));
-void gui_mch_prepare __ARGS((int *argc, char **argv));
-void atexitDoThis __ARGS((void));
-int gui_mch_init_check __ARGS((void));
-int gui_mch_init __ARGS((void));
-void gui_mch_new_colors __ARGS((void));
-int gui_mch_open __ARGS((void));
-void gui_mch_exit __ARGS((int returnCode));
-int gui_mch_get_winpos __ARGS((int *x, int *y));
-void gui_mch_set_winpos __ARGS((int x, int y));
-void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height));
-void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h));
-void gui_mch_set_text_area_pos __ARGS((int x, int y, int w, int h));
-void gui_mch_enable_scrollbar __ARGS((scrollbar_T *sb, int flag));
-void gui_mch_set_scrollbar_thumb __ARGS((scrollbar_T *sb, long val, long size, long max));
-void gui_mch_set_scrollbar_pos __ARGS((scrollbar_T *sb, int x, int y, int w, int h));
-void gui_mch_create_scrollbar __ARGS((scrollbar_T *sb, int orient));
-void gui_mch_destroy_scrollbar __ARGS((scrollbar_T *sb));
-char_u *gui_mch_getfontname __ARGS((GuiFont font));
-int gui_mch_init_font __ARGS((char_u *font_name, int fontset));
-int gui_mch_adjust_charsize __ARGS((void));
-GuiFont gui_mch_get_font __ARGS((char_u *name, int giveErrorIfMissing));
-char_u *gui_mch_get_fontname __ARGS((GuiFont font, char_u *name));
-void gui_mch_set_font __ARGS((GuiFont font));
-void gui_mch_free_font __ARGS((GuiFont font));
-guicolor_T gui_mch_get_color __ARGS((char_u *name));
-void gui_mch_set_colors __ARGS((guicolor_T fg, guicolor_T bg));
-void gui_mch_set_fg_color __ARGS((guicolor_T color));
-void gui_mch_set_bg_color __ARGS((guicolor_T color));
-void gui_mch_draw_string __ARGS((int row, int col, char_u *s, int len, int flags));
-int gui_mch_haskey __ARGS((char_u *name));
-void gui_mch_beep __ARGS((void));
-void gui_mch_flash __ARGS((int msec));
-void gui_mch_invert_rectangle __ARGS((int r, int c, int nr, int nc));
-void gui_mch_iconify __ARGS((void));
-void gui_mch_set_foreground __ARGS((void));
-void gui_mch_settitle __ARGS((char_u *title, char_u *icon));
-void gui_mch_stop_blink __ARGS((void));
-void gui_mch_start_blink __ARGS((void));
-void gui_mch_draw_hollow_cursor __ARGS((guicolor_T color));
-void gui_mch_draw_part_cursor __ARGS((int w, int h, guicolor_T color));
-void gui_mch_update __ARGS((void));
-int gui_mch_wait_for_chars __ARGS((int wtime));
-void gui_mch_flush __ARGS((void));
-void gui_mch_clear_block __ARGS((int row1, int col1, int row2, int col2));
-void gui_mch_clear_all __ARGS((void));
-void gui_mch_delete_lines __ARGS((int row, int num_lines));
-void gui_mch_insert_lines __ARGS((int row, int num_lines));
-void gui_mch_enable_menu __ARGS((int flag));
-void gui_mch_set_menu_pos __ARGS((int x, int y, int w, int h));
-void gui_mch_destroy_menu __ARGS((vimmenu_T *menu));
-void gui_mch_menu_grey __ARGS((vimmenu_T *menu, int grey));
-void gui_mch_menu_hidden __ARGS((vimmenu_T *menu, int hidden));
-void gui_mch_draw_menubar __ARGS((void));
-int clip_mch_own_selection __ARGS((VimClipboard *cbd));
-void mch_setmouse __ARGS((int on));
-int gui_mch_get_mouse_x __ARGS((void));
-int gui_mch_get_mouse_y __ARGS((void));
-void gui_mch_setmouse __ARGS((int x, int y));
-void gui_mch_show_popupmenu __ARGS((vimmenu_T *menu));
-void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
-void clip_mch_request_selection __ARGS((VimClipboard *cbd));
-void clip_mch_set_selection __ARGS((VimClipboard *cbd));
-long_u gui_mch_get_rgb __ARGS((guicolor_T pixel));
-/* vim: set ft=c : */
diff --git a/src/proto/gui_beos.pro b/src/proto/gui_beos.pro
deleted file mode 100644
index af52885f..00000000
--- a/src/proto/gui_beos.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-/* gui_beos.cc - hand crafted */
-int vim_lock_screen __ARGS((void));
-void vim_unlock_screen __ARGS((void));
-void gui_mch_prepare __ARGS((int *argc, char **argv));
-int gui_mch_init __ARGS((void));
-void gui_mch_new_colors __ARGS((void));
-int gui_mch_open __ARGS((void));
-void gui_mch_exit __ARGS((int vim_exitcode));
-GuiFont gui_mch_get_font __ARGS((char_u *name, int giveErrorIfMissing));
-void gui_mch_set_bg_color __ARGS((guicolor_T color));
-void gui_mch_set_font __ARGS((GuiFont font));
-void gui_mch_flush __ARGS((void));
-long_u gui_mch_get_rgb __ARGS((guicolor_T pixel));
-void gui_mch_set_winpos __ARGS((int x, int y));
diff --git a/src/proto/os_beos.pro b/src/proto/os_beos.pro
deleted file mode 100644
index c5371012..00000000
--- a/src/proto/os_beos.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-/* os_beos.c */
-void beos_cleanup_read_thread __ARGS((void));
-int beos_select __ARGS((int nbits, struct fd_set *rbits, struct fd_set *wbits, struct fd_set *ebits, struct timeval *timeout));
-/* vim: set ft=c : */