Mercurial > vim
comparison src/ex_getln.c @ 531:da9142bd190a v7.0149
updated for version 7.0149
author | vimboss |
---|---|
date | Tue, 20 Sep 2005 23:22:24 +0000 |
parents | b47114409935 |
children | 7052f11a3dc9 |
comparison
equal
deleted
inserted
replaced
530:339999b511a0 | 531:da9142bd190a |
---|---|
29 int cmdindent; /* number of spaces before cmdline */ | 29 int cmdindent; /* number of spaces before cmdline */ |
30 char_u *cmdprompt; /* message in front of cmdline */ | 30 char_u *cmdprompt; /* message in front of cmdline */ |
31 int cmdattr; /* attributes for prompt */ | 31 int cmdattr; /* attributes for prompt */ |
32 int overstrike; /* Typing mode on the command line. Shared by | 32 int overstrike; /* Typing mode on the command line. Shared by |
33 getcmdline() and put_on_cmdline(). */ | 33 getcmdline() and put_on_cmdline(). */ |
34 int xp_context; /* type of expansion */ | |
35 # ifdef FEAT_EVAL | |
36 char_u *xp_arg; /* user-defined expansion arg */ | |
37 int input_fn; /* Invoked for input() function */ | |
38 # endif | |
34 }; | 39 }; |
35 | 40 |
36 static struct cmdline_info ccline; /* current cmdline_info */ | 41 static struct cmdline_info ccline; /* current cmdline_info */ |
37 | 42 |
38 static int cmd_showtail; /* Only show path tail in lists ? */ | 43 static int cmd_showtail; /* Only show path tail in lists ? */ |
252 set_cmdspos(); | 257 set_cmdspos(); |
253 } | 258 } |
254 xpc.xp_context = EXPAND_NOTHING; | 259 xpc.xp_context = EXPAND_NOTHING; |
255 xpc.xp_backslash = XP_BS_NONE; | 260 xpc.xp_backslash = XP_BS_NONE; |
256 | 261 |
262 #if defined(FEAT_EVAL) | |
263 if (ccline.input_fn) | |
264 { | |
265 xpc.xp_context = ccline.xp_context; | |
266 xpc.xp_pattern = ccline.cmdbuff; | |
267 xpc.xp_arg = ccline.xp_arg; | |
268 } | |
269 #endif | |
270 | |
257 /* | 271 /* |
258 * Avoid scrolling when called by a recursive do_cmdline(), e.g. when | 272 * Avoid scrolling when called by a recursive do_cmdline(), e.g. when |
259 * doing ":@0" when register 0 doesn't contain a CR. | 273 * doing ":@0" when register 0 doesn't contain a CR. |
260 */ | 274 */ |
261 msg_scroll = FALSE; | 275 msg_scroll = FALSE; |
412 wim_index = 0; | 426 wim_index = 0; |
413 #ifdef FEAT_WILDMENU | 427 #ifdef FEAT_WILDMENU |
414 if (p_wmnu && wild_menu_showing != 0) | 428 if (p_wmnu && wild_menu_showing != 0) |
415 { | 429 { |
416 int skt = KeyTyped; | 430 int skt = KeyTyped; |
431 int old_RedrawingDisabled; | |
432 | |
433 if (ccline.input_fn) | |
434 { | |
435 old_RedrawingDisabled = RedrawingDisabled; | |
436 RedrawingDisabled = 0; | |
437 } | |
417 | 438 |
418 if (wild_menu_showing == WM_SCROLLED) | 439 if (wild_menu_showing == WM_SCROLLED) |
419 { | 440 { |
420 /* Entered command line, move it up */ | 441 /* Entered command line, move it up */ |
421 cmdline_row--; | 442 cmdline_row--; |
440 # else | 461 # else |
441 lastwin->w_redr_status = TRUE; | 462 lastwin->w_redr_status = TRUE; |
442 # endif | 463 # endif |
443 redraw_statuslines(); | 464 redraw_statuslines(); |
444 } | 465 } |
466 if (ccline.input_fn) | |
467 RedrawingDisabled = old_RedrawingDisabled; | |
445 KeyTyped = skt; | 468 KeyTyped = skt; |
446 wild_menu_showing = 0; | 469 wild_menu_showing = 0; |
447 } | 470 } |
448 #endif | 471 #endif |
449 } | 472 } |
1789 * This is prepared to be called recursively from getcmdline() (e.g. by | 1812 * This is prepared to be called recursively from getcmdline() (e.g. by |
1790 * f_input() when evaluating an expression from CTRL-R =). | 1813 * f_input() when evaluating an expression from CTRL-R =). |
1791 * Returns the command line in allocated memory, or NULL. | 1814 * Returns the command line in allocated memory, or NULL. |
1792 */ | 1815 */ |
1793 char_u * | 1816 char_u * |
1794 getcmdline_prompt(firstc, prompt, attr) | 1817 getcmdline_prompt(firstc, prompt, attr, xp_context, xp_arg) |
1795 int firstc; | 1818 int firstc; |
1796 char_u *prompt; /* command line prompt */ | 1819 char_u *prompt; /* command line prompt */ |
1797 int attr; /* attributes for prompt */ | 1820 int attr; /* attributes for prompt */ |
1821 int xp_context; /* type of expansion */ | |
1822 char_u *xp_arg; /* user-defined expansion argument */ | |
1798 { | 1823 { |
1799 char_u *s; | 1824 char_u *s; |
1800 struct cmdline_info save_ccline; | 1825 struct cmdline_info save_ccline; |
1801 int msg_col_save = msg_col; | 1826 int msg_col_save = msg_col; |
1802 | 1827 |
1803 save_cmdline(&save_ccline); | 1828 save_cmdline(&save_ccline); |
1804 ccline.cmdprompt = prompt; | 1829 ccline.cmdprompt = prompt; |
1805 ccline.cmdattr = attr; | 1830 ccline.cmdattr = attr; |
1831 # ifdef FEAT_EVAL | |
1832 ccline.xp_context = xp_context; | |
1833 ccline.xp_arg = xp_arg; | |
1834 ccline.input_fn = (firstc == '@'); | |
1835 # endif | |
1806 s = getcmdline(firstc, 1L, 0); | 1836 s = getcmdline(firstc, 1L, 0); |
1807 restore_cmdline(&save_ccline); | 1837 restore_cmdline(&save_ccline); |
1808 /* Restore msg_col, the prompt from input() may have changed it. */ | 1838 /* Restore msg_col, the prompt from input() may have changed it. */ |
1809 msg_col = msg_col_save; | 1839 msg_col = msg_col_save; |
1810 | 1840 |
1828 * indent. | 1858 * indent. |
1829 */ | 1859 */ |
1830 static void | 1860 static void |
1831 set_cmdspos() | 1861 set_cmdspos() |
1832 { | 1862 { |
1833 if (ccline.cmdfirstc) | 1863 if (ccline.cmdfirstc != NUL) |
1834 ccline.cmdspos = 1 + ccline.cmdindent; | 1864 ccline.cmdspos = 1 + ccline.cmdindent; |
1835 else | 1865 else |
1836 ccline.cmdspos = 0 + ccline.cmdindent; | 1866 ccline.cmdspos = 0 + ccline.cmdindent; |
1837 } | 1867 } |
1838 | 1868 |
2220 int old_col; | 2250 int old_col; |
2221 colnr_T col; | 2251 colnr_T col; |
2222 | 2252 |
2223 old_row = msg_row; | 2253 old_row = msg_row; |
2224 old_col = msg_col; | 2254 old_col = msg_col; |
2225 cmdspos = ((ccline.cmdfirstc) ? 1 : 0) + ccline.cmdindent; | 2255 cmdspos = ((ccline.cmdfirstc != NUL) ? 1 : 0) + ccline.cmdindent; |
2226 | 2256 |
2227 # ifdef FEAT_MBYTE | 2257 # ifdef FEAT_MBYTE |
2228 if (has_mbyte) | 2258 if (has_mbyte) |
2229 { | 2259 { |
2230 for (col = 0; col < preedit_start_col | 2260 for (col = 0; col < preedit_start_col |
2811 { | 2841 { |
2812 int i; | 2842 int i; |
2813 | 2843 |
2814 if (cmd_silent) | 2844 if (cmd_silent) |
2815 return; | 2845 return; |
2816 if (ccline.cmdfirstc) | 2846 if (ccline.cmdfirstc != NUL) |
2817 msg_putchar(ccline.cmdfirstc); | 2847 msg_putchar(ccline.cmdfirstc); |
2818 if (ccline.cmdprompt != NULL) | 2848 if (ccline.cmdprompt != NULL) |
2819 { | 2849 { |
2820 msg_puts_attr(ccline.cmdprompt, ccline.cmdattr); | 2850 msg_puts_attr(ccline.cmdprompt, ccline.cmdattr); |
2821 ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; | 2851 ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; |
2822 /* do the reverse of set_cmdspos() */ | 2852 /* do the reverse of set_cmdspos() */ |
2823 if (ccline.cmdfirstc) | 2853 if (ccline.cmdfirstc != NUL) |
2824 --ccline.cmdindent; | 2854 --ccline.cmdindent; |
2825 } | 2855 } |
2826 else | 2856 else |
2827 for (i = ccline.cmdindent; i > 0; --i) | 2857 for (i = ccline.cmdindent; i > 0; --i) |
2828 msg_putchar(' '); | 2858 msg_putchar(' '); |
3841 { | 3871 { |
3842 /* only expansion for ':', '>' and '=' command-lines */ | 3872 /* only expansion for ':', '>' and '=' command-lines */ |
3843 if (ccline.cmdfirstc != ':' | 3873 if (ccline.cmdfirstc != ':' |
3844 #ifdef FEAT_EVAL | 3874 #ifdef FEAT_EVAL |
3845 && ccline.cmdfirstc != '>' && ccline.cmdfirstc != '=' | 3875 && ccline.cmdfirstc != '>' && ccline.cmdfirstc != '=' |
3876 && !ccline.input_fn | |
3846 #endif | 3877 #endif |
3847 ) | 3878 ) |
3848 { | 3879 { |
3849 xp->xp_context = EXPAND_NOTHING; | 3880 xp->xp_context = EXPAND_NOTHING; |
3850 return; | 3881 return; |
3873 | 3904 |
3874 #ifdef FEAT_EVAL | 3905 #ifdef FEAT_EVAL |
3875 if (ccline.cmdfirstc == '=') | 3906 if (ccline.cmdfirstc == '=') |
3876 /* pass CMD_SIZE because there is no real command */ | 3907 /* pass CMD_SIZE because there is no real command */ |
3877 set_context_for_expression(xp, str, CMD_SIZE); | 3908 set_context_for_expression(xp, str, CMD_SIZE); |
3909 else if (ccline.input_fn) | |
3910 { | |
3911 xp->xp_context = ccline.xp_context; | |
3912 xp->xp_pattern = ccline.cmdbuff; | |
3913 xp->xp_arg = ccline.xp_arg; | |
3914 } | |
3878 else | 3915 else |
3879 #endif | 3916 #endif |
3880 while (nextcomm != NULL) | 3917 while (nextcomm != NULL) |
3881 nextcomm = set_one_cmd_context(xp, nextcomm); | 3918 nextcomm = set_one_cmd_context(xp, nextcomm); |
3882 | 3919 |
4833 if (pos < 0) | 4870 if (pos < 0) |
4834 new_cmdpos = 0; | 4871 new_cmdpos = 0; |
4835 else | 4872 else |
4836 new_cmdpos = pos; | 4873 new_cmdpos = pos; |
4837 return 0; | 4874 return 0; |
4875 } | |
4876 | |
4877 /* | |
4878 * Get the current command-line type. | |
4879 * Returns ':' or '/' or '?' or '@' or '>' | |
4880 * Only works when the command line is being edited. | |
4881 * Returns NUL when something is wrong. | |
4882 */ | |
4883 int | |
4884 get_cmdline_type() | |
4885 { | |
4886 struct cmdline_info *p = get_ccline_ptr(); | |
4887 | |
4888 if (p == NULL) | |
4889 return NUL; | |
4890 return p->cmdfirstc; | |
4838 } | 4891 } |
4839 | 4892 |
4840 /* | 4893 /* |
4841 * Calculate history index from a number: | 4894 * Calculate history index from a number: |
4842 * num > 0: seen as identifying number of a history entry | 4895 * num > 0: seen as identifying number of a history entry |