Mercurial > vim
comparison src/quickfix.c @ 859:99305c4c42d4
updated for version 7.0g02
author | vimboss |
---|---|
date | Wed, 03 May 2006 21:26:49 +0000 |
parents | b933657f7c9d |
children | 4ec4c53046b5 |
comparison
equal
deleted
inserted
replaced
858:ca82de29ac19 | 859:99305c4c42d4 |
---|---|
116 static char_u *qf_guess_filepath __ARGS((char_u *)); | 116 static char_u *qf_guess_filepath __ARGS((char_u *)); |
117 static void qf_fmt_text __ARGS((char_u *text, char_u *buf, int bufsize)); | 117 static void qf_fmt_text __ARGS((char_u *text, char_u *buf, int bufsize)); |
118 static void qf_clean_dir_stack __ARGS((struct dir_stack_T **)); | 118 static void qf_clean_dir_stack __ARGS((struct dir_stack_T **)); |
119 #ifdef FEAT_WINDOWS | 119 #ifdef FEAT_WINDOWS |
120 static int qf_win_pos_update __ARGS((qf_info_T *qi, int old_qf_index)); | 120 static int qf_win_pos_update __ARGS((qf_info_T *qi, int old_qf_index)); |
121 static int is_qf_win __ARGS((win_T *win, qf_info_T *qi)); | |
121 static win_T *qf_find_win __ARGS((qf_info_T *qi)); | 122 static win_T *qf_find_win __ARGS((qf_info_T *qi)); |
122 static buf_T *qf_find_buf __ARGS((qf_info_T *qi)); | 123 static buf_T *qf_find_buf __ARGS((qf_info_T *qi)); |
123 static void qf_update_buffer __ARGS((qf_info_T *qi)); | 124 static void qf_update_buffer __ARGS((qf_info_T *qi)); |
124 static void qf_fill_buffer __ARGS((qf_info_T *qi)); | 125 static void qf_fill_buffer __ARGS((qf_info_T *qi)); |
125 #endif | 126 #endif |
2197 { | 2198 { |
2198 qf_info_T *qi = &ql_info; | 2199 qf_info_T *qi = &ql_info; |
2199 int height; | 2200 int height; |
2200 win_T *win; | 2201 win_T *win; |
2201 tabpage_T *prevtab = curtab; | 2202 tabpage_T *prevtab = curtab; |
2203 buf_T *qf_buf; | |
2202 | 2204 |
2203 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) | 2205 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) |
2204 { | 2206 { |
2205 qi = GET_LOC_LIST(curwin); | 2207 qi = GET_LOC_LIST(curwin); |
2206 if (qi == NULL) | 2208 if (qi == NULL) |
2229 | 2231 |
2230 if (win != NULL && cmdmod.tab == 0) | 2232 if (win != NULL && cmdmod.tab == 0) |
2231 win_goto(win); | 2233 win_goto(win); |
2232 else | 2234 else |
2233 { | 2235 { |
2236 qf_buf = qf_find_buf(qi); | |
2237 | |
2234 /* The current window becomes the previous window afterwards. */ | 2238 /* The current window becomes the previous window afterwards. */ |
2235 win = curwin; | 2239 win = curwin; |
2236 | 2240 |
2237 if (eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow) | 2241 if (eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow) |
2238 /* Create the new window at the very bottom. */ | 2242 /* Create the new window at the very bottom. */ |
2254 */ | 2258 */ |
2255 curwin->w_llist_ref = win->w_llist; | 2259 curwin->w_llist_ref = win->w_llist; |
2256 win->w_llist->qf_refcount++; | 2260 win->w_llist->qf_refcount++; |
2257 } | 2261 } |
2258 | 2262 |
2259 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE); | 2263 if (qf_buf != NULL) |
2260 /* switch off 'swapfile' */ | 2264 /* Use the existing quickfix buffer */ |
2261 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); | 2265 (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, |
2262 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix", | 2266 ECMD_HIDE + ECMD_OLDBUF); |
2267 else | |
2268 { | |
2269 /* Create a new quickfix buffer */ | |
2270 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE); | |
2271 /* switch off 'swapfile' */ | |
2272 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); | |
2273 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix", | |
2263 OPT_LOCAL); | 2274 OPT_LOCAL); |
2264 set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL); | 2275 set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL); |
2265 set_option_value((char_u *)"diff", 0L, (char_u *)"", OPT_LOCAL); | 2276 set_option_value((char_u *)"diff", 0L, (char_u *)"", OPT_LOCAL); |
2277 } | |
2266 | 2278 |
2267 /* Only set the height when still in the same tab page and there is no | 2279 /* Only set the height when still in the same tab page and there is no |
2268 * window to the side. */ | 2280 * window to the side. */ |
2269 if (curtab == prevtab | 2281 if (curtab == prevtab |
2270 #ifdef FEAT_VERTSPLIT | 2282 #ifdef FEAT_VERTSPLIT |
2350 } | 2362 } |
2351 return win != NULL; | 2363 return win != NULL; |
2352 } | 2364 } |
2353 | 2365 |
2354 /* | 2366 /* |
2367 * Check whether the given window is displaying the specified quickfix/location | |
2368 * list buffer | |
2369 */ | |
2370 static int | |
2371 is_qf_win(win, qi) | |
2372 win_T *win; | |
2373 qf_info_T *qi; | |
2374 { | |
2375 /* | |
2376 * A window displaying the quickfix buffer will have the w_llist_ref field | |
2377 * set to NULL. | |
2378 * A window displaying a location list buffer will have the w_llist_ref | |
2379 * pointing to the location list. | |
2380 */ | |
2381 if (bt_quickfix(win->w_buffer)) | |
2382 if ((qi == &ql_info && win->w_llist_ref == NULL) | |
2383 || (qi != &ql_info && win->w_llist_ref == qi)) | |
2384 return TRUE; | |
2385 | |
2386 return FALSE; | |
2387 } | |
2388 | |
2389 /* | |
2355 * Find a window displaying the quickfix/location list 'qi' | 2390 * Find a window displaying the quickfix/location list 'qi' |
2391 * Searches in only the windows opened in the current tab. | |
2356 */ | 2392 */ |
2357 static win_T * | 2393 static win_T * |
2358 qf_find_win(qi) | 2394 qf_find_win(qi) |
2359 qf_info_T *qi; | 2395 qf_info_T *qi; |
2360 { | 2396 { |
2361 win_T *win; | 2397 win_T *win; |
2362 | 2398 |
2363 /* | |
2364 * When searching for the quickfix buffer, find a window | |
2365 * with w_llist_ref set to NULL. | |
2366 * When searching for the location list buffer, find a window | |
2367 * with w_llist_ref pointing to the supplied location list. | |
2368 */ | |
2369 FOR_ALL_WINDOWS(win) | 2399 FOR_ALL_WINDOWS(win) |
2370 if (bt_quickfix(win->w_buffer)) | 2400 if (is_qf_win(win, qi)) |
2371 if ((qi == &ql_info && win->w_llist_ref == NULL) | 2401 break; |
2372 || (qi != &ql_info && win->w_llist_ref == qi)) | |
2373 break; | |
2374 | 2402 |
2375 return win; | 2403 return win; |
2376 } | 2404 } |
2377 | 2405 |
2378 /* | 2406 /* |
2379 * Find quickfix buffer. | 2407 * Find a quickfix buffer. |
2408 * Searches in windows opened in all the tabs. | |
2380 */ | 2409 */ |
2381 static buf_T * | 2410 static buf_T * |
2382 qf_find_buf(qi) | 2411 qf_find_buf(qi) |
2383 qf_info_T *qi; | 2412 qf_info_T *qi; |
2384 { | 2413 { |
2414 tabpage_T *tp; | |
2385 win_T *win; | 2415 win_T *win; |
2386 | 2416 |
2387 win = qf_find_win(qi); | 2417 FOR_ALL_TAB_WINDOWS(tp, win) |
2388 | 2418 if (is_qf_win(win, qi)) |
2389 return (win != NULL) ? win->w_buffer: NULL; | 2419 return win->w_buffer; |
2420 | |
2421 return NULL; | |
2390 } | 2422 } |
2391 | 2423 |
2392 /* | 2424 /* |
2393 * Find the quickfix buffer. If it exists, update the contents. | 2425 * Find the quickfix buffer. If it exists, update the contents. |
2394 */ | 2426 */ |