comparison src/ex_getln.c @ 772:aaaca5077255

updated for version 7.0226
author vimboss
date Thu, 16 Mar 2006 21:41:35 +0000
parents afac7b58ed46
children d20041a02ee5
comparison
equal deleted inserted replaced
771:c0f1b710ce07 772:aaaca5077255
1375 case Ctrl_A: /* all matches */ 1375 case Ctrl_A: /* all matches */
1376 if (nextwild(&xpc, WILD_ALL, 0) == FAIL) 1376 if (nextwild(&xpc, WILD_ALL, 0) == FAIL)
1377 break; 1377 break;
1378 goto cmdline_changed; 1378 goto cmdline_changed;
1379 1379
1380 case Ctrl_L: /* longest common part */ 1380 case Ctrl_L:
1381 #ifdef FEAT_SEARCH_EXTRA
1382 if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
1383 {
1384 /* Add a character from under the cursor for 'incsearch' */
1385 if (did_incsearch
1386 && !equalpos(curwin->w_cursor, old_cursor))
1387 {
1388 c = gchar_cursor();
1389 if (c != NUL)
1390 break;
1391 }
1392 goto cmdline_not_changed;
1393 }
1394 #endif
1395
1396 /* completion: longest common part */
1381 if (nextwild(&xpc, WILD_LONGEST, 0) == FAIL) 1397 if (nextwild(&xpc, WILD_LONGEST, 0) == FAIL)
1382 break; 1398 break;
1383 goto cmdline_changed; 1399 goto cmdline_changed;
1384 1400
1385 case Ctrl_N: /* next match */ 1401 case Ctrl_N: /* next match */
1663 /* 1679 /*
1664 * 'incsearch' highlighting. 1680 * 'incsearch' highlighting.
1665 */ 1681 */
1666 if (p_is && !cmd_silent && (firstc == '/' || firstc == '?')) 1682 if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
1667 { 1683 {
1684 pos_T end_pos;
1685
1668 /* if there is a character waiting, search and redraw later */ 1686 /* if there is a character waiting, search and redraw later */
1669 if (char_avail()) 1687 if (char_avail())
1670 { 1688 {
1671 incsearch_postponed = TRUE; 1689 incsearch_postponed = TRUE;
1672 continue; 1690 continue;
1694 } 1712 }
1695 else if (char_avail()) 1713 else if (char_avail())
1696 /* cancelled searching because a char was typed */ 1714 /* cancelled searching because a char was typed */
1697 incsearch_postponed = TRUE; 1715 incsearch_postponed = TRUE;
1698 } 1716 }
1699 if (i) 1717 if (i != 0)
1700 highlight_match = TRUE; /* highlight position */ 1718 highlight_match = TRUE; /* highlight position */
1701 else 1719 else
1702 highlight_match = FALSE; /* remove highlight */ 1720 highlight_match = FALSE; /* remove highlight */
1703 1721
1704 /* first restore the old curwin values, so the screen is 1722 /* first restore the old curwin values, so the screen is
1715 if (i != 0) 1733 if (i != 0)
1716 { 1734 {
1717 pos_T save_pos = curwin->w_cursor; 1735 pos_T save_pos = curwin->w_cursor;
1718 1736
1719 /* 1737 /*
1720 * First move cursor to end of match, then to start. This 1738 * First move cursor to end of match, then to the start. This
1721 * moves the whole match onto the screen when 'nowrap' is set. 1739 * moves the whole match onto the screen when 'nowrap' is set.
1722 */ 1740 */
1723 curwin->w_cursor.lnum += search_match_lines; 1741 curwin->w_cursor.lnum += search_match_lines;
1724 curwin->w_cursor.col = search_match_endcol; 1742 curwin->w_cursor.col = search_match_endcol;
1725 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) 1743 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
1726 { 1744 {
1727 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; 1745 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
1728 coladvance((colnr_T)MAXCOL); 1746 coladvance((colnr_T)MAXCOL);
1729 } 1747 }
1730 validate_cursor(); 1748 validate_cursor();
1749 end_pos = curwin->w_cursor;
1731 curwin->w_cursor = save_pos; 1750 curwin->w_cursor = save_pos;
1732 } 1751 }
1752
1733 validate_cursor(); 1753 validate_cursor();
1734 1754
1735 save_cmdline(&save_ccline); 1755 save_cmdline(&save_ccline);
1736 update_screen(SOME_VALID); 1756 update_screen(SOME_VALID);
1737 restore_cmdline(&save_ccline); 1757 restore_cmdline(&save_ccline);
1758
1759 /* Leave it at the end to make CTRL-R CTRL-W work. */
1760 if (i != 0)
1761 curwin->w_cursor = end_pos;
1738 1762
1739 msg_starthere(); 1763 msg_starthere();
1740 redrawcmdline(); 1764 redrawcmdline();
1741 did_incsearch = TRUE; 1765 did_incsearch = TRUE;
1742 } 1766 }
2811 int regname; 2835 int regname;
2812 int literally; /* Insert text literally instead of "as typed" */ 2836 int literally; /* Insert text literally instead of "as typed" */
2813 { 2837 {
2814 long i; 2838 long i;
2815 char_u *arg; 2839 char_u *arg;
2840 char_u *p;
2816 int allocated; 2841 int allocated;
2817 struct cmdline_info save_ccline; 2842 struct cmdline_info save_ccline;
2818 2843
2819 /* check for valid regname; also accept special characters for CTRL-R in 2844 /* check for valid regname; also accept special characters for CTRL-R in
2820 * the command line */ 2845 * the command line */
2843 if (i) 2868 if (i)
2844 { 2869 {
2845 /* Got the value of a special register in "arg". */ 2870 /* Got the value of a special register in "arg". */
2846 if (arg == NULL) 2871 if (arg == NULL)
2847 return FAIL; 2872 return FAIL;
2848 cmdline_paste_str(arg, literally); 2873
2874 /* When 'incsearch' is set and CTRL-R CTRL-W used: skip the duplicate
2875 * part of the word. */
2876 p = arg;
2877 if (p_is && regname == Ctrl_W)
2878 {
2879 char_u *w;
2880 int len;
2881
2882 /* Locate start of last word in the cmd buffer. */
2883 for (w = ccline.cmdbuff + ccline.cmdlen; w > ccline.cmdbuff; )
2884 {
2885 #ifdef FEAT_MBYTE
2886 if (has_mbyte)
2887 {
2888 len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1;
2889 if (!vim_iswordc(mb_ptr2char(w - len)))
2890 break;
2891 w -= len;
2892 }
2893 else
2894 #endif
2895 {
2896 if (!vim_iswordc(w[-1]))
2897 break;
2898 --w;
2899 }
2900 }
2901 len = (ccline.cmdbuff + ccline.cmdlen) - w;
2902 if (p_ic ? STRNICMP(w, arg, len) == 0 : STRNCMP(w, arg, len) == 0)
2903 p += len;
2904 }
2905
2906 cmdline_paste_str(p, literally);
2849 if (allocated) 2907 if (allocated)
2850 vim_free(arg); 2908 vim_free(arg);
2851 return OK; 2909 return OK;
2852 } 2910 }
2853 2911