Mercurial > vim
comparison src/window.c @ 6432:84190359b979 v7.4.546
updated for version 7.4.546
Problem: Repeated use of vim_snprintf() with a number.
Solution: Move these vim_snprintf() calls into a function.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 13 Dec 2014 03:58:09 +0100 |
parents | 5a76e36f07b1 |
children | cba15023c403 |
comparison
equal
deleted
inserted
replaced
6431:5c9e04efc9b6 | 6432:84190359b979 |
---|---|
9 | 9 |
10 #include "vim.h" | 10 #include "vim.h" |
11 | 11 |
12 static int path_is_url __ARGS((char_u *p)); | 12 static int path_is_url __ARGS((char_u *p)); |
13 #if defined(FEAT_WINDOWS) || defined(PROTO) | 13 #if defined(FEAT_WINDOWS) || defined(PROTO) |
14 static void cmd_with_count __ARGS((char *cmd, char_u *bufp, size_t bufsize, long Prenum)); | |
14 static void win_init __ARGS((win_T *newp, win_T *oldp, int flags)); | 15 static void win_init __ARGS((win_T *newp, win_T *oldp, int flags)); |
15 static void win_init_some __ARGS((win_T *newp, win_T *oldp)); | 16 static void win_init_some __ARGS((win_T *newp, win_T *oldp)); |
16 static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col)); | 17 static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col)); |
17 static void frame_setheight __ARGS((frame_T *curfrp, int height)); | 18 static void frame_setheight __ARGS((frame_T *curfrp, int height)); |
18 #ifdef FEAT_VERTSPLIT | 19 #ifdef FEAT_VERTSPLIT |
165 /* split current window and edit alternate file */ | 166 /* split current window and edit alternate file */ |
166 case Ctrl_HAT: | 167 case Ctrl_HAT: |
167 case '^': | 168 case '^': |
168 CHECK_CMDWIN | 169 CHECK_CMDWIN |
169 reset_VIsual_and_resel(); /* stop Visual mode */ | 170 reset_VIsual_and_resel(); /* stop Visual mode */ |
170 STRCPY(cbuf, "split #"); | 171 cmd_with_count("split #", cbuf, sizeof(cbuf), Prenum); |
171 if (Prenum) | |
172 vim_snprintf((char *)cbuf + 7, sizeof(cbuf) - 7, | |
173 "%ld", Prenum); | |
174 do_cmdline_cmd(cbuf); | 172 do_cmdline_cmd(cbuf); |
175 break; | 173 break; |
176 | 174 |
177 /* open new window */ | 175 /* open new window */ |
178 case Ctrl_N: | 176 case Ctrl_N: |
197 | 195 |
198 /* quit current window */ | 196 /* quit current window */ |
199 case Ctrl_Q: | 197 case Ctrl_Q: |
200 case 'q': | 198 case 'q': |
201 reset_VIsual_and_resel(); /* stop Visual mode */ | 199 reset_VIsual_and_resel(); /* stop Visual mode */ |
202 STRCPY(cbuf, "quit"); | 200 cmd_with_count("quit", cbuf, sizeof(cbuf), Prenum); |
203 if (Prenum) | |
204 vim_snprintf((char *)cbuf + 4, sizeof(cbuf) - 5, | |
205 "%ld", Prenum); | |
206 do_cmdline_cmd(cbuf); | 201 do_cmdline_cmd(cbuf); |
207 break; | 202 break; |
208 | 203 |
209 /* close current window */ | 204 /* close current window */ |
210 case Ctrl_C: | 205 case Ctrl_C: |
211 case 'c': | 206 case 'c': |
212 reset_VIsual_and_resel(); /* stop Visual mode */ | 207 reset_VIsual_and_resel(); /* stop Visual mode */ |
213 STRCPY(cbuf, "close"); | 208 cmd_with_count("close", cbuf, sizeof(cbuf), Prenum); |
214 if (Prenum) | |
215 vim_snprintf((char *)cbuf + 5, sizeof(cbuf) - 5, | |
216 "%ld", Prenum); | |
217 do_cmdline_cmd(cbuf); | 209 do_cmdline_cmd(cbuf); |
218 break; | 210 break; |
219 | 211 |
220 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 212 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) |
221 /* close preview window */ | 213 /* close preview window */ |
241 /* close all but current window */ | 233 /* close all but current window */ |
242 case Ctrl_O: | 234 case Ctrl_O: |
243 case 'o': | 235 case 'o': |
244 CHECK_CMDWIN | 236 CHECK_CMDWIN |
245 reset_VIsual_and_resel(); /* stop Visual mode */ | 237 reset_VIsual_and_resel(); /* stop Visual mode */ |
246 STRCPY(cbuf, "only"); | 238 cmd_with_count("only", cbuf, sizeof(cbuf), Prenum); |
247 if (Prenum > 0) | |
248 vim_snprintf((char *)cbuf + 4, sizeof(cbuf) - 4, | |
249 "%ld", Prenum); | |
250 do_cmdline_cmd(cbuf); | 239 do_cmdline_cmd(cbuf); |
251 break; | 240 break; |
252 | 241 |
253 /* cursor to next window with wrap around */ | 242 /* cursor to next window with wrap around */ |
254 case Ctrl_W: | 243 case Ctrl_W: |
631 break; | 620 break; |
632 | 621 |
633 default: beep_flush(); | 622 default: beep_flush(); |
634 break; | 623 break; |
635 } | 624 } |
625 } | |
626 | |
627 static void | |
628 cmd_with_count(cmd, bufp, bufsize, Prenum) | |
629 char *cmd; | |
630 char_u *bufp; | |
631 size_t bufsize; | |
632 long Prenum; | |
633 { | |
634 size_t len = STRLEN(cmd); | |
635 | |
636 STRCPY(bufp, cmd); | |
637 if (Prenum > 0) | |
638 vim_snprintf((char *)bufp + len, bufsize - len, "%ld", Prenum); | |
636 } | 639 } |
637 | 640 |
638 /* | 641 /* |
639 * split the current window, implements CTRL-W s and :split | 642 * split the current window, implements CTRL-W s and :split |
640 * | 643 * |