To: vim_dev@googlegroups.com Subject: Patch 7.4.1997 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1997 Problem: Cannot easily scroll the quickfix window. Solution: Add ":cbottom". Files: src/ex_cmds.h, src/quickfix.c, src/proto/quickfix.pro, src/ex_docmd.c, src/testdir/test_quickfix.vim, runtime/doc/quickfix.txt *** ../vim-7.4.1996/src/ex_cmds.h 2016-06-12 21:20:50.941837428 +0200 --- src/ex_cmds.h 2016-07-07 18:19:22.888573565 +0200 *************** *** 259,264 **** --- 259,267 ---- EX(CMD_cbuffer, "cbuffer", ex_cbuffer, BANG|RANGE|NOTADR|WORD1|TRLBAR, ADDR_LINES), + EX(CMD_cbottom, "cbottom", ex_cbottom, + TRLBAR, + ADDR_LINES), EX(CMD_cc, "cc", ex_cc, RANGE|NOTADR|COUNT|TRLBAR|BANG, ADDR_LINES), *** ../vim-7.4.1996/src/quickfix.c 2016-07-02 15:41:41.586523202 +0200 --- src/quickfix.c 2016-07-07 18:47:44.182954704 +0200 *************** *** 2808,2813 **** --- 2808,2848 ---- } /* + * Move the cursor in the quickfix window to "lnum". + */ + static void + qf_win_goto(win_T *win, linenr_T lnum) + { + win_T *old_curwin = curwin; + + curwin = win; + curbuf = win->w_buffer; + curwin->w_cursor.lnum = lnum; + curwin->w_cursor.col = 0; + #ifdef FEAT_VIRTUALEDIT + curwin->w_cursor.coladd = 0; + #endif + curwin->w_curswant = 0; + update_topline(); /* scroll to show the line */ + redraw_later(VALID); + curwin->w_redr_status = TRUE; /* update ruler */ + curwin = old_curwin; + curbuf = curwin->w_buffer; + } + + /* + * :cbottom command. + */ + void + ex_cbottom(exarg_T *eap UNUSED) + { + win_T *win = qf_find_win(&ql_info); + + if (win != NULL && win->w_cursor.lnum != win->w_buffer->b_ml.ml_line_count) + qf_win_goto(win, win->w_buffer->b_ml.ml_line_count); + } + + /* * Return the number of the current entry (line number in the quickfix * window). */ *************** *** 2844,2870 **** && qf_index <= win->w_buffer->b_ml.ml_line_count && old_qf_index != qf_index) { - win_T *old_curwin = curwin; - - curwin = win; - curbuf = win->w_buffer; if (qf_index > old_qf_index) { ! curwin->w_redraw_top = old_qf_index; ! curwin->w_redraw_bot = qf_index; } else { ! curwin->w_redraw_top = qf_index; ! curwin->w_redraw_bot = old_qf_index; } ! curwin->w_cursor.lnum = qf_index; ! curwin->w_cursor.col = 0; ! update_topline(); /* scroll to show the line */ ! redraw_later(VALID); ! curwin->w_redr_status = TRUE; /* update ruler */ ! curwin = old_curwin; ! curbuf = curwin->w_buffer; } return win != NULL; } --- 2879,2895 ---- && qf_index <= win->w_buffer->b_ml.ml_line_count && old_qf_index != qf_index) { if (qf_index > old_qf_index) { ! win->w_redraw_top = old_qf_index; ! win->w_redraw_bot = qf_index; } else { ! win->w_redraw_top = qf_index; ! win->w_redraw_bot = old_qf_index; } ! qf_win_goto(win, qf_index); } return win != NULL; } *** ../vim-7.4.1996/src/proto/quickfix.pro 2016-01-19 13:21:55.845334290 +0100 --- src/proto/quickfix.pro 2016-07-07 18:45:33.744948691 +0200 *************** *** 9,14 **** --- 9,15 ---- void ex_cwindow(exarg_T *eap); void ex_cclose(exarg_T *eap); void ex_copen(exarg_T *eap); + void ex_cbottom(exarg_T *eap); linenr_T qf_current_entry(win_T *wp); int bt_quickfix(buf_T *buf); int bt_nofile(buf_T *buf); *** ../vim-7.4.1996/src/ex_docmd.c 2016-06-12 21:20:50.941837428 +0200 --- src/ex_docmd.c 2016-07-07 18:23:05.425238053 +0200 *************** *** 129,134 **** --- 129,135 ---- # define ex_cclose ex_ni # define ex_copen ex_ni # define ex_cwindow ex_ni + # define ex_cbottom ex_ni #endif #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) # define ex_cexpr ex_ni *** ../vim-7.4.1996/src/testdir/test_quickfix.vim 2016-07-02 21:22:46.848282547 +0200 --- src/testdir/test_quickfix.vim 2016-07-07 18:56:27.686962935 +0200 *************** *** 1414,1416 **** --- 1414,1429 ---- call delete('Xone', 'rf') call delete('Xtwo', 'rf') endfunc + + function Test_cbottom() + call setqflist([{'filename': 'foo', 'lnum': 42}]) + copen + let wid = win_getid() + call assert_equal(1, line('.')) + wincmd w + call setqflist([{'filename': 'var', 'lnum': 24}], 'a') + cbottom + call win_gotoid(wid) + call assert_equal(2, line('.')) + cclose + endfunc *** ../vim-7.4.1996/runtime/doc/quickfix.txt 2016-07-01 14:48:02.654783860 +0200 --- runtime/doc/quickfix.txt 2016-07-07 18:39:14.638727812 +0200 *************** *** 427,432 **** --- 437,448 ---- :lw[indow] [height] Same as ":cwindow", except use the window showing the location list for the current window. + :cbo[ttom] Put the cursor in the last line of the quickfix window + and scroll to make it visible. This is useful for + when errors are added by an asynchronous callback. + Only call it once in a while if there are many + updates to avoid a lot of redrawing. + Normally the quickfix window is at the bottom of the screen. If there are vertical splits, it's at the bottom of the rightmost column of windows. To make it always occupy the full width: > *** ../vim-7.4.1996/src/version.c 2016-07-07 17:32:48.290238465 +0200 --- src/version.c 2016-07-07 18:57:09.990317860 +0200 *************** *** 760,761 **** --- 760,763 ---- { /* Add new patch number below this line */ + /**/ + 1997, /**/ -- hundred-and-one symptoms of being an internet addict: 221. Your wife melts your keyboard in the oven. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///