diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-07-25 16:58:46 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-07-25 16:58:46 +0200 |
commit | 7fd7320014fb34788ef53fe7c78521b5c25e052e (patch) | |
tree | 8249c7e405578cde42c319b9c216bd868809682c /src | |
parent | fa0ff9aedf9515638e15726141c4a08ca4e05255 (diff) | |
download | vim-git-7fd7320014fb34788ef53fe7c78521b5c25e052e.tar.gz |
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 16 | ||||
-rw-r--r-- | src/if_cscope.c | 24 | ||||
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/option.h | 3 | ||||
-rw-r--r-- | src/proto/quickfix.pro | 2 | ||||
-rw-r--r-- | src/quickfix.c | 73 |
6 files changed, 92 insertions, 29 deletions
diff --git a/src/buffer.c b/src/buffer.c index 22fa13616..0b3742b30 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -60,6 +60,11 @@ static void insert_sign __ARGS((buf_T *buf, signlist_T *prev, signlist_T *next, static void buf_delete_signs __ARGS((buf_T *buf)); #endif +#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +static char *msg_loclist = N_("[Location List]"); +static char *msg_qflist = N_("[Quickfix List]"); +#endif + /* * Open current buffer, that is: open the memfile and read the file into * memory. @@ -3878,6 +3883,13 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hltab, t str = (char_u *)((opt == STL_PREVIEWFLAG_ALT) ? ",PRV" : _("[Preview]")); break; + + case STL_QUICKFIX: + if (bt_quickfix(wp->w_buffer)) + str = (char_u *)(wp->w_llist_ref + ? _(msg_loclist) + : _(msg_qflist)); + break; #endif case STL_MODIFIED: @@ -5124,9 +5136,9 @@ buf_spname(buf) goto win_found; win_found: if (win != NULL && win->w_llist_ref != NULL) - return _("[Location List]"); + return _(msg_loclist); else - return _("[Quickfix List]"); + return _(msg_qflist); } #endif #ifdef FEAT_QUICKFIX diff --git a/src/if_cscope.c b/src/if_cscope.c index 8eaa03769..3ee718321 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -44,7 +44,7 @@ static void cs_file_results __ARGS((FILE *, int *)); static void cs_fill_results __ARGS((char *, int , int *, char ***, char ***, int *)); static int cs_find __ARGS((exarg_T *eap)); -static int cs_find_common __ARGS((char *opt, char *pat, int, int, int)); +static int cs_find_common __ARGS((char *opt, char *pat, int, int, int, char_u *cmdline)); static int cs_help __ARGS((exarg_T *eap)); static void clear_csinfo __ARGS((int i)); static int cs_insert_filelist __ARGS((char *, char *, char *, @@ -294,7 +294,7 @@ do_cstag(eap) if (cs_check_for_connections()) { ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, FALSE, - FALSE); + FALSE, *eap->cmdlinep); if (ret == FALSE) { cs_free_tags(); @@ -322,7 +322,7 @@ do_cstag(eap) if (cs_check_for_connections()) { ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, - FALSE, FALSE); + FALSE, FALSE, *eap->cmdlinep); if (ret == FALSE) cs_free_tags(); } @@ -331,7 +331,7 @@ do_cstag(eap) else if (cs_check_for_connections()) { ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, FALSE, - FALSE); + FALSE, *eap->cmdlinep); if (ret == FALSE) cs_free_tags(); } @@ -1068,6 +1068,7 @@ cs_find(eap) exarg_T *eap; { char *opt, *pat; + int i; if (cs_check_for_connections() == FALSE) { @@ -1088,8 +1089,16 @@ cs_find(eap) return FALSE; } + /* + * Let's replace the NULs written by strtok() with spaces - we need the + * spaces to correctly display the quickfix/location list window's title. + */ + for (i = 0; i < eap_arg_len; ++i) + if (NUL == eap->arg[i]) + eap->arg[i] = ' '; + return cs_find_common(opt, pat, eap->forceit, TRUE, - eap->cmdidx == CMD_lcscope); + eap->cmdidx == CMD_lcscope, *eap->cmdlinep); } /* cs_find */ @@ -1099,12 +1108,13 @@ cs_find(eap) * common code for cscope find, shared by cs_find() and do_cstag() */ static int -cs_find_common(opt, pat, forceit, verbose, use_ll) +cs_find_common(opt, pat, forceit, verbose, use_ll, cmdline) char *opt; char *pat; int forceit; int verbose; int use_ll; + char_u *cmdline; { int i; char *cmd; @@ -1257,7 +1267,7 @@ cs_find_common(opt, pat, forceit, verbose, use_ll) wp = curwin; /* '-' starts a new error list */ if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m", - *qfpos == '-') > 0) + *qfpos == '-', cmdline) > 0) { # ifdef FEAT_WINDOWS if (postponed_split != 0) diff --git a/src/main.c b/src/main.c index 4ccf35628..cadc2efd2 100644 --- a/src/main.c +++ b/src/main.c @@ -670,7 +670,8 @@ main if (params.use_ef != NULL) set_string_option_direct((char_u *)"ef", -1, params.use_ef, OPT_FREE, SID_CARG); - if (qf_init(NULL, p_ef, p_efm, TRUE) < 0) + vim_snprintf((char *)IObuff, IOSIZE, "cfile %s", p_ef); + if (qf_init(NULL, p_ef, p_efm, TRUE, IObuff) < 0) { out_char('\n'); mch_exit(3); diff --git a/src/option.h b/src/option.h index 78560c697..0f697c2e4 100644 --- a/src/option.h +++ b/src/option.h @@ -273,6 +273,7 @@ #define STL_PREVIEWFLAG_ALT 'W' /* - other display */ #define STL_MODIFIED 'm' /* modified flag */ #define STL_MODIFIED_ALT 'M' /* - other display */ +#define STL_QUICKFIX 'q' /* quickfix window description */ #define STL_PERCENTAGE 'p' /* percentage through file */ #define STL_ALTPERCENT 'P' /* percentage as TOP BOT ALL or NN% */ #define STL_ARGLISTSTAT 'a' /* argument list status as (x of y) */ @@ -284,7 +285,7 @@ #define STL_HIGHLIGHT '#' /* highlight name */ #define STL_TABPAGENR 'T' /* tab page label nr */ #define STL_TABCLOSENR 'X' /* tab page close nr */ -#define STL_ALL ((char_u *) "fFtcvVlLknoObBrRhHmYyWwMpPaN{#") +#define STL_ALL ((char_u *) "fFtcvVlLknoObBrRhHmYyWwMqpPaN{#") /* flags used for parsed 'wildmode' */ #define WIM_FULL 1 diff --git a/src/proto/quickfix.pro b/src/proto/quickfix.pro index 408bf6dec..65ef438db 100644 --- a/src/proto/quickfix.pro +++ b/src/proto/quickfix.pro @@ -1,5 +1,5 @@ /* quickfix.c */ -int qf_init __ARGS((win_T *wp, char_u *efile, char_u *errorformat, int newlist)); +int qf_init __ARGS((win_T *wp, char_u *efile, char_u *errorformat, int newlist, char_u *qf_title)); void qf_free_all __ARGS((win_T *wp)); void copy_loclist __ARGS((win_T *from, win_T *to)); void qf_jump __ARGS((qf_info_T *qi, int dir, int errornr, int forceit)); diff --git a/src/quickfix.c b/src/quickfix.c index c2543a124..883de8c72 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -56,6 +56,8 @@ typedef struct qf_list_S int qf_count; /* number of errors (0 means no error list) */ int qf_index; /* current index in the error list */ int qf_nonevalid; /* TRUE if not a single valid entry found */ + char_u *qf_title; /* title derived from the command that created + * the error list */ } qf_list_T; struct qf_info_S @@ -104,8 +106,8 @@ struct efm_S int conthere; /* %> used */ }; -static int qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast)); -static void qf_new_list __ARGS((qf_info_T *qi)); +static int qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast, char_u *qf_title)); +static void qf_new_list __ARGS((qf_info_T *qi, char_u *qf_title)); static void ll_free_all __ARGS((qf_info_T **pqi)); static int qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid)); static qf_info_T *ll_new_list __ARGS((void)); @@ -144,15 +146,16 @@ static qf_info_T *ll_get_or_alloc_list __ARGS((win_T *)); /* * Read the errorfile "efile" into memory, line by line, building the error - * list. + * list. Set the error list's title to qf_title. * Return -1 for error, number of errors for success. */ int -qf_init(wp, efile, errorformat, newlist) +qf_init(wp, efile, errorformat, newlist, qf_title) win_T *wp; char_u *efile; char_u *errorformat; int newlist; /* TRUE: start a new error list */ + char_u *qf_title; { qf_info_T *qi = &ql_info; @@ -167,7 +170,8 @@ qf_init(wp, efile, errorformat, newlist) } return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist, - (linenr_T)0, (linenr_T)0); + (linenr_T)0, (linenr_T)0, + qf_title); } /* @@ -175,11 +179,13 @@ qf_init(wp, efile, errorformat, newlist) * list. * Alternative: when "efile" is null read errors from buffer "buf". * Always use 'errorformat' from "buf" if there is a local value. - * Then lnumfirst and lnumlast specify the range of lines to use. + * Then "lnumfirst" and "lnumlast" specify the range of lines to use. + * Set the title of the list to "qf_title". * Return -1 for error, number of errors for success. */ static int -qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast) +qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast, + qf_title) qf_info_T *qi; char_u *efile; buf_T *buf; @@ -188,6 +194,7 @@ qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast) int newlist; /* TRUE: start a new error list */ linenr_T lnumfirst; /* first line number to use */ linenr_T lnumlast; /* last line number to use */ + char_u *qf_title; { char_u *namebuf; char_u *errmsg; @@ -257,11 +264,11 @@ qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast) if (newlist || qi->qf_curlist == qi->qf_listcount) /* make place for a new list */ - qf_new_list(qi); + qf_new_list(qi, qf_title); else if (qi->qf_lists[qi->qf_curlist].qf_count > 0) /* Adding to existing list, find last entry. */ for (qfprev = qi->qf_lists[qi->qf_curlist].qf_start; - qfprev->qf_next != qfprev; qfprev = qfprev->qf_next) + qfprev->qf_next != qfprev; qfprev = qfprev->qf_next) ; /* @@ -860,8 +867,9 @@ qf_init_end: * Prepare for adding a new quickfix list. */ static void -qf_new_list(qi) +qf_new_list(qi, qf_title) qf_info_T *qi; + char_u *qf_title; { int i; @@ -888,6 +896,16 @@ qf_new_list(qi) qi->qf_curlist = qi->qf_listcount++; qi->qf_lists[qi->qf_curlist].qf_index = 0; qi->qf_lists[qi->qf_curlist].qf_count = 0; + if (qf_title != NULL) + { + char_u *p = alloc(STRLEN(qf_title) + 2); + + qi->qf_lists[qi->qf_curlist].qf_title = p; + if (p != NULL) + sprintf((char *)p, ":%s", (char *)qf_title); + } + else + qi->qf_lists[qi->qf_curlist].qf_title = NULL; } /* @@ -1100,6 +1118,10 @@ copy_loclist(from, to) to_qfl->qf_index = 0; to_qfl->qf_start = NULL; to_qfl->qf_ptr = NULL; + if (from_qfl->qf_title != NULL) + to_qfl->qf_title = vim_strsave(from_qfl->qf_title); + else + to_qfl->qf_title = NULL; if (from_qfl->qf_count) { @@ -2102,6 +2124,7 @@ qf_free(qi, idx) qi->qf_lists[idx].qf_start = qfp; --qi->qf_lists[idx].qf_count; } + vim_free(qi->qf_lists[idx].qf_title); } /* @@ -2366,6 +2389,10 @@ ex_copen(eap) */ qf_fill_buffer(qi); + if (qi->qf_lists[qi->qf_curlist].qf_title != NULL) + set_internal_string_var((char_u *)"w:quickfix_title", + qi->qf_lists[qi->qf_curlist].qf_title); + curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index; curwin->w_cursor.col = 0; check_cursor(); @@ -2790,7 +2817,8 @@ ex_make(eap) res = qf_init(wp, fname, (eap->cmdidx != CMD_make && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, (eap->cmdidx != CMD_grepadd - && eap->cmdidx != CMD_lgrepadd)); + && eap->cmdidx != CMD_lgrepadd), + *eap->cmdlinep); #ifdef FEAT_AUTOCMD if (au_name != NULL) apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, @@ -2977,7 +3005,8 @@ ex_cfile(eap) * quickfix list then a new list is created. */ if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile - && eap->cmdidx != CMD_laddfile)) > 0 + && eap->cmdidx != CMD_laddfile), + *eap->cmdlinep) > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile)) { @@ -3085,7 +3114,7 @@ ex_vimgrep(eap) eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd) || qi->qf_curlist == qi->qf_listcount) /* make place for a new list */ - qf_new_list(qi); + qf_new_list(qi, *eap->cmdlinep); else if (qi->qf_lists[qi->qf_curlist].qf_count > 0) /* Adding to existing list, find last entry. */ for (prevp = qi->qf_lists[qi->qf_curlist].qf_start; @@ -3594,7 +3623,7 @@ set_errorlist(wp, list, action) if (action == ' ' || qi->qf_curlist == qi->qf_listcount) /* make place for a new list */ - qf_new_list(qi); + qf_new_list(qi, NULL); else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0) /* Adding to existing list, find last entry. */ for (prevp = qi->qf_lists[qi->qf_curlist].qf_start; @@ -3725,10 +3754,20 @@ ex_cbuffer(eap) EMSG(_(e_invrange)); else { + char_u *qf_title = *eap->cmdlinep; + + if (buf->b_sfname) + { + vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", + (char *)qf_title, (char *)buf->b_sfname); + qf_title = IObuff; + } + if (qf_init_ext(qi, NULL, buf, NULL, p_efm, (eap->cmdidx != CMD_caddbuffer && eap->cmdidx != CMD_laddbuffer), - eap->line1, eap->line2) > 0 + eap->line1, eap->line2, + qf_title) > 0 && (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer)) qf_jump(qi, 0, 0, eap->forceit); /* display first error */ @@ -3767,7 +3806,7 @@ ex_cexpr(eap) if (qf_init_ext(qi, NULL, NULL, tv, p_efm, (eap->cmdidx != CMD_caddexpr && eap->cmdidx != CMD_laddexpr), - (linenr_T)0, (linenr_T)0) > 0 + (linenr_T)0, (linenr_T)0, *eap->cmdlinep) > 0 && (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr)) qf_jump(qi, 0, 0, eap->forceit); /* display first error */ @@ -3837,7 +3876,7 @@ ex_helpgrep(eap) if (regmatch.regprog != NULL) { /* create a new quickfix list */ - qf_new_list(qi); + qf_new_list(qi, *eap->cmdlinep); /* Go through all directories in 'runtimepath' */ p = p_rtp; |