annotate src/termlib.c @ 8631:e5f2e0f8af10 v7.4.1605

commit https://github.com/vim/vim/commit/3905e291fe4375ca5c59efa9ffcb01a39c7be3a9 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 19 18:44:08 2016 +0100 patch 7.4.1605 Problem: Catching exception that won't be thrown. Solution: Remove try/catch.
author Christian Brabandt <cb@256bit.org>
date Sat, 19 Mar 2016 18:45:05 +0100
parents c66e1f50c142
children 4aead6a9b7a9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * The following software is (C) 1984 Peter da Silva, the Mad Australian, in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * the public domain. It may be re-distributed for any purpose with the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * inclusion of this notice.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 /* Modified by Bram Moolenaar for use with VIM - Vi Improved. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 /* A few bugs removed by Olaf 'Rhialto' Seibert. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
1214
a91a2e0c4108 updated for version 7.1b
vimboss
parents: 7
diff changeset
11 /* TERMLIB: Terminal independent database. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "termlib.pro"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 1621
diff changeset
16 #if !defined(AMIGA) && !defined(VMS) && !defined(MACOS)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 # include <sgtty.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 2823
diff changeset
20 static int getent(char *, char *, FILE *, int);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 2823
diff changeset
21 static int nextent(char *, FILE *, int);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 2823
diff changeset
22 static int _match(char *, char *);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 2823
diff changeset
23 static char *_addfmt(char *, char *, int);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 2823
diff changeset
24 static char *_find(char *, char *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 * Global variables for termlib
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 char *tent; /* Pointer to terminal entry, set by tgetent */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 char PC = 0; /* Pad character, default NULL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 char *UP = 0, *BC = 0; /* Pointers to UP and BC strings from database */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 short ospeed; /* Baud rate (1-16, 1=300, 16=19200), as in stty */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 * Module: tgetent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 * Purpose: Get termcap entry for <term> into buffer at <tbuf>.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 * Calling conventions: char tbuf[TBUFSZ+], term=canonical name for terminal.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 * Returned values: 1 = success, -1 = can't open file,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 * 0 = can't find terminal.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 * Notes:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 * - Should probably supply static buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 * - Uses environment variables "TERM" and "TERMCAP". If TERM = term (that is,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 * if the argument matches the environment) then it looks at TERMCAP.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 * - If TERMCAP begins with a slash, then it assumes this is the file to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 * search rather than /etc/termcap.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 * - If TERMCAP does not begin with a slash, and it matches TERM, then this is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 * used as the entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 * - This could be simplified considerably for non-UNIX systems.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 #ifndef TERMCAPFILE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 # ifdef AMIGA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 # define TERMCAPFILE "s:termcap"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 # ifdef VMS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 # define TERMCAPFILE "VIMRUNTIME:termcap"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 # define TERMCAPFILE "/etc/termcap"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
69 tgetent(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
70 char *tbuf, /* Buffer to hold termcap entry, TBUFSZ bytes max */
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
71 char *term) /* Name of terminal */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 char tcbuf[32]; /* Temp buffer to handle */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 char *tcptr = tcbuf; /* extended entries */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 char *tcap = TERMCAPFILE; /* Default termcap file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 char *tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 FILE *termcap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 int retval = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 if ((tmp = (char *)mch_getenv((char_u *)"TERMCAP")) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 if (*tmp == '/') /* TERMCAP = name of termcap file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 tcap = tmp ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 #if defined(AMIGA)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 /* Convert /usr/share/lib/termcap to usr:share/lib/termcap */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 tcap++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 tmp = strchr(tcap, '/');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 if (tmp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 *tmp = ':';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 else /* TERMCAP = termcap entry itself */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 int tlen = strlen(term);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 while (*tmp && *tmp != ':') /* Check if TERM matches */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 char *nexttmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 while (*tmp == '|')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 tmp++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 nexttmp = _find(tmp, ":|"); /* Rhialto */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 if (tmp+tlen == nexttmp && _match(tmp, term) == tlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 strcpy(tbuf, tmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 tent = tbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 tmp = nexttmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 if (!(termcap = mch_fopen(tcap, "r")))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 strcpy(tbuf, tcap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 while (getent(tbuf + len, term, termcap, TBUFSZ - len))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 tcptr = tcbuf; /* Rhialto */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 if ((term = tgetstr("tc", &tcptr))) /* extended entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 rewind(termcap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 len = strlen(tbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 retval = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 tent = tbuf; /* reset it back to the beginning */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 fclose(termcap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 static int
8340
c66e1f50c142 commit https://github.com/vim/vim/commit/2f6271b1e7cff985cac66f6850116bcf3fcccd58
Christian Brabandt <cb@256bit.org>
parents: 7835
diff changeset
143 getent(char *tbuf, char *term, FILE *termcap, int buflen)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 char *tptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 int tlen = strlen(term);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 while (nextent(tbuf, termcap, buflen)) /* For each possible entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 tptr = tbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 while (*tptr && *tptr != ':') /* : terminates name field */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 char *nexttptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154
1214
a91a2e0c4108 updated for version 7.1b
vimboss
parents: 7
diff changeset
155 while (*tptr == '|') /* | separates names */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 tptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 nexttptr = _find(tptr, ":|"); /* Rhialto */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 if (tptr + tlen == nexttptr &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 _match(tptr, term) == tlen) /* FOUND! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 tent = tbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 else /* Look for next name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 tptr = nexttptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
171 /*
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
172 * Read 1 entry from TERMCAP file.
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
173 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
175 nextent(char *tbuf, FILE *termcap, int buflen)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 char *lbuf = tbuf; /* lbuf=line buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 /* read lines straight into buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 while (lbuf < tbuf+buflen && /* There's room and */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 fgets(lbuf, (int)(tbuf+buflen-lbuf), termcap)) /* another line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 int llen = strlen(lbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 if (*lbuf == '#') /* eat comments */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 if (lbuf[-1] == ':' && /* and whitespace */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 lbuf[0] == '\t' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 lbuf[1] == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 {
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1341
diff changeset
191 STRMOVE(lbuf, lbuf + 2);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 llen -= 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 if (lbuf[llen-2] == '\\') /* and continuations */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 lbuf += llen-2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 lbuf[llen-1]=0; /* no continuation, return */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 return 0; /* ran into end of file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 * Module: tgetflag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 * Purpose: returns flag true or false as to the existence of a given entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 * used with 'bs', 'am', etc...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 * Calling conventions: id is the 2 character capability id.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 * Returned values: 1 for success, 0 for failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
218 tgetflag(char *id)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 char buf[256], *ptr = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 return tgetstr(id, &ptr) ? 1 : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 * Module: tgetnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 * Purpose: get numeric value such as 'li' or 'co' from termcap.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 * Calling conventions: id = 2 character id.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 * Returned values: -1 for failure, else numerical value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
236 tgetnum(char *id)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 char *ptr, buf[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 ptr = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 if (tgetstr(id, &ptr))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 return atoi(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 * Module: tgetstr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 * Purpose: get terminal capability string from database.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 * Calling conventions: id is the two character capability id.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 * (*buf) points into a hold buffer for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 * id. the capability is copied into the buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 * and (*buf) is advanced to point to the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 * free byte in the buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 * Returned values: 0 = no such entry, otherwise returns original
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 * (*buf) (now a pointer to the string).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 * Notes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 * It also decodes certain escape sequences in the buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 * they should be obvious from the code:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 * \E = escape.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 * \n, \r, \t, \f, \b match the 'c' escapes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 * ^x matches control-x (^@...^_).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 * \nnn matches nnn octal.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 * \x, where x is anything else, matches x. I differ
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 * from the standard library here, in that I allow ^: to match
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 * :.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 char *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
275 tgetstr(char *id, char **buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 int len = strlen(id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 char *tmp=tent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 char *hold;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 do {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 tmp = _find(tmp, ":"); /* For each field */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 while (*tmp == ':') /* skip empty fields */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 tmp++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 if (!*tmp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 if (_match(id, tmp) == len) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 tmp += len; /* find '=' '@' or '#' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 if (*tmp == '@') /* :xx@: entry for tc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 return 0; /* deleted entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 hold= *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 while (*++tmp && *tmp != ':') { /* not at end of field */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 switch(*tmp) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 case '\\': /* Expand escapes here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 switch(*++tmp) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 case 0: /* ignore backslashes */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 tmp--; /* at end of entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 break; /* shouldn't happen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 case 'e':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 case 'E': /* ESC */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 *(*buf)++ = ESC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 case 'n': /* \n */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 *(*buf)++ = '\n';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 case 'r': /* \r */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 *(*buf)++ = '\r';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 case 't': /* \t */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 *(*buf)++ = '\t';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 case 'b': /* \b */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 *(*buf)++ = '\b';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 case 'f': /* \f */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 *(*buf)++ = '\f';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 case '0': /* \nnn */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 case '1':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 case '2':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 case '3':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 case '4':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 case '5':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 case '6':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 case '7':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 case '8':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 case '9':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 **buf = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 /* get up to three digits */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 for (i = 0; i < 3 && VIM_ISDIGIT(*tmp); ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 **buf = **buf * 8 + *tmp++ - '0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 (*buf)++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 tmp--;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 default: /* \x, for all other x */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 *(*buf)++= *tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 case '^': /* control characters */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 ++tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 *(*buf)++ = Ctrl_chr(*tmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 *(*buf)++ = *tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 *(*buf)++ = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 return hold;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 } while (*tmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 * Module: tgoto
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 * Purpose: decode cm cursor motion string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 * Calling conventions: cm is cursor motion string. line, col, are the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 * desired destination.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 * Returned values: a string pointing to the decoded string, or "OOPS" if it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 * cannot be decoded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 * Notes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 * The accepted escapes are:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 * %d as in printf, 0 origin.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 * %2, %3 like %02d, %03d in printf.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 * %. like %c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 * %+x adds <x> to value, then %.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 * %>xy if value>x, adds y. No output.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 * %i increments line& col, no output.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 * %r reverses order of line&col. No output.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 * %% prints as a single %.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 * %n exclusive or row & col with 0140.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 * %B BCD, no output.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 * %D reverse coding (x-2*(x%16)), no output.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 char *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
384 tgoto(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
385 char *cm, /* cm string, from termcap */
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
386 int col, /* column, x position */
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
387 int line) /* line, y position */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 char gx, gy, /* x, y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 *ptr, /* pointer in 'cm' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 reverse = 0, /* reverse flag */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 *bufp, /* pointer in returned string */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 addup = 0, /* add upline */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 addbak = 0, /* add backup */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 static char buffer[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 if (!cm)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 return "OOPS"; /* Kludge, but standard */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 bufp = buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 ptr = cm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 while (*ptr) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 if ((c = *ptr++) != '%') { /* normal char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 *bufp++ = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 } else { /* % escape */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 switch(c = *ptr++) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 case 'd': /* decimal */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 bufp = _addfmt(bufp, "%d", line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 line = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 case '2': /* 2 digit decimal */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 bufp = _addfmt(bufp, "%02d", line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 line = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 case '3': /* 3 digit decimal */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 bufp = _addfmt(bufp, "%03d", line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 line = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 case '>': /* %>xy: if >x, add y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 gx = *ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 gy = *ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 if (col>gx) col += gy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 if (line>gx) line += gy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 case '+': /* %+c: add c */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 line += *ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 case '.': /* print x/y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 if (line == '\t' || /* these are */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 line == '\n' || /* chars that */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 line == '\004' || /* UNIX hates */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 line == '\0') {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 line++; /* so go to next pos */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 if (reverse == (line == col))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 addup=1; /* and mark UP */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 addbak=1; /* or BC */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 *bufp++=line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 line = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 case 'r': /* r: reverse */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 gx = line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 line = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 col = gx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 reverse = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 case 'i': /* increment (1-origin screen) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 col++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 line++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 case '%': /* %%=% literally */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 *bufp++='%';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 case 'n': /* magic DM2500 code */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 line ^= 0140;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 col ^= 0140;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 case 'B': /* bcd encoding */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 line = line/10<<4+line%10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 col = col/10<<4+col%10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 case 'D': /* magic Delta Data code */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 line = line-2*(line&15);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 col = col-2*(col&15);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 default: /* Unknown escape */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 return "OOPS";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 if (addup) /* add upline */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 if (UP) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 ptr=UP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 while (VIM_ISDIGIT(*ptr) || *ptr == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 if (*ptr == '*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 while (*ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 *bufp++ = *ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 if (addbak) /* add backspace */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 if (BC) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 ptr=BC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 while (VIM_ISDIGIT(*ptr) || *ptr == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 if (*ptr == '*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 while (*ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 *bufp++ = *ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 *bufp++='\b';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 *bufp = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 return(buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 * Module: tputs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 * Purpose: decode padding information
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 * Calling conventions: cp = string to be padded, affcnt = # of items affected
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 * (lines, characters, whatever), outc = routine to output 1 character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 * Returned values: none
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 * Notes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 * cp has padding information ahead of it, in the form
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 * nnnTEXT or nnn*TEXT. nnn is the number of milliseconds to delay,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 * and may be a decimal (nnn.mmm). If the asterisk is given, then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 * the delay is multiplied by afcnt. The delay is produced by outputting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 * a number of nulls (or other padding char) after printing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 * TEXT.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 long _bauds[16]={
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 0, 50, 75, 110,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 134, 150, 200, 300,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 600, 1200, 1800, 2400,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 4800, 9600, 19200, 19200 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
530 tputs(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
531 char *cp, /* string to print */
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
532 int affcnt, /* Number of lines affected */
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
533 void (*outc)(unsigned int)) /* routine to output 1 character */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 long frac, /* 10^(#digits after decimal point) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 counter, /* digits */
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 2823
diff changeset
537 atol(const char *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 if (VIM_ISDIGIT(*cp)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 counter = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 frac = 1000;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 while (VIM_ISDIGIT(*cp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 counter = counter * 10L + (long)(*cp++ - '0');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 if (*cp == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 while (VIM_ISDIGIT(*++cp)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 counter = counter * 10L + (long)(*cp++ - '0');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 frac = frac * 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 if (*cp!='*') { /* multiply by affected lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 if (affcnt>1) affcnt = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 cp++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 /* Calculate number of characters for padding counter/frac ms delay */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 if (ospeed)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 counter = (counter * _bauds[ospeed] * (long)affcnt) / frac;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 while (*cp) /* output string */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 (*outc)(*cp++);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 if (ospeed)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 while (counter--) /* followed by pad characters */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 (*outc)(PC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 while (*cp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 (*outc)(*cp++);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 * Module: tutil.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 * Purpose: Utility routines for TERMLIB functions.
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
575 * Returns length of text common to s1 and s2.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 static int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
578 _match(char *s1, char *s2)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 int i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 while (s1[i] && s1[i] == s2[i])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 i++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 return i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 * finds next c in s that's a member of set, returns pointer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 static char *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
592 _find(char *s, char *set)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 for(; *s; s++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 char *ptr = set;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 while (*ptr && *s != *ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 ptr++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 if (*ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 return s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 return s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 * add val to buf according to format fmt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 static char *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
612 _addfmt(char *buf, char *fmt, int val)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 sprintf(buf, fmt, val);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 while (*buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 buf++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 }