Mercurial > vim
comparison src/ex_getln.c @ 17970:684a15da9929 v8.1.1981
patch 8.1.1981: the evalfunc.c file is too big
Commit: https://github.com/vim/vim/commit/08c308aeb5e7dfa18fa61f261b0bff79517a4883
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 4 17:48:15 2019 +0200
patch 8.1.1981: the evalfunc.c file is too big
Problem: The evalfunc.c file is too big.
Solution: Move undo functions to undo.c. Move cmdline functions to
ex_getln.c. Move some container functions to list.c.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 04 Sep 2019 18:00:03 +0200 |
parents | 4d63d47d87ef |
children | 5a0d5f8e1778 |
comparison
equal
deleted
inserted
replaced
17969:bfc33cda9075 | 17970:684a15da9929 |
---|---|
3866 /* | 3866 /* |
3867 * Get the current command line in allocated memory. | 3867 * Get the current command line in allocated memory. |
3868 * Only works when the command line is being edited. | 3868 * Only works when the command line is being edited. |
3869 * Returns NULL when something is wrong. | 3869 * Returns NULL when something is wrong. |
3870 */ | 3870 */ |
3871 char_u * | 3871 static char_u * |
3872 get_cmdline_str(void) | 3872 get_cmdline_str(void) |
3873 { | 3873 { |
3874 cmdline_info_T *p; | 3874 cmdline_info_T *p; |
3875 | 3875 |
3876 if (cmdline_star > 0) | 3876 if (cmdline_star > 0) |
3880 return NULL; | 3880 return NULL; |
3881 return vim_strnsave(p->cmdbuff, p->cmdlen); | 3881 return vim_strnsave(p->cmdbuff, p->cmdlen); |
3882 } | 3882 } |
3883 | 3883 |
3884 /* | 3884 /* |
3885 * Get the current command line position, counted in bytes. | 3885 * "getcmdline()" function |
3886 * Zero is the first position. | 3886 */ |
3887 * Only works when the command line is being edited. | 3887 void |
3888 * Returns -1 when something is wrong. | 3888 f_getcmdline(typval_T *argvars UNUSED, typval_T *rettv) |
3889 */ | 3889 { |
3890 int | 3890 rettv->v_type = VAR_STRING; |
3891 get_cmdline_pos(void) | 3891 rettv->vval.v_string = get_cmdline_str(); |
3892 } | |
3893 | |
3894 /* | |
3895 * "getcmdpos()" function | |
3896 */ | |
3897 void | |
3898 f_getcmdpos(typval_T *argvars UNUSED, typval_T *rettv) | |
3892 { | 3899 { |
3893 cmdline_info_T *p = get_ccline_ptr(); | 3900 cmdline_info_T *p = get_ccline_ptr(); |
3894 | 3901 |
3895 if (p == NULL) | 3902 rettv->vval.v_number = 0; |
3896 return -1; | 3903 if (p != NULL) |
3897 return p->cmdpos; | 3904 rettv->vval.v_number = p->cmdpos + 1; |
3898 } | 3905 } |
3899 | 3906 |
3900 /* | 3907 /* |
3901 * Set the command line byte position to "pos". Zero is the first position. | 3908 * Set the command line byte position to "pos". Zero is the first position. |
3902 * Only works when the command line is being edited. | 3909 * Only works when the command line is being edited. |
3903 * Returns 1 when failed, 0 when OK. | 3910 * Returns 1 when failed, 0 when OK. |
3904 */ | 3911 */ |
3905 int | 3912 static int |
3906 set_cmdline_pos( | 3913 set_cmdline_pos( |
3907 int pos) | 3914 int pos) |
3908 { | 3915 { |
3909 cmdline_info_T *p = get_ccline_ptr(); | 3916 cmdline_info_T *p = get_ccline_ptr(); |
3910 | 3917 |
3917 new_cmdpos = 0; | 3924 new_cmdpos = 0; |
3918 else | 3925 else |
3919 new_cmdpos = pos; | 3926 new_cmdpos = pos; |
3920 return 0; | 3927 return 0; |
3921 } | 3928 } |
3929 | |
3930 /* | |
3931 * "setcmdpos()" function | |
3932 */ | |
3933 void | |
3934 f_setcmdpos(typval_T *argvars, typval_T *rettv) | |
3935 { | |
3936 int pos = (int)tv_get_number(&argvars[0]) - 1; | |
3937 | |
3938 if (pos >= 0) | |
3939 rettv->vval.v_number = set_cmdline_pos(pos); | |
3940 } | |
3941 | |
3942 /* | |
3943 * "getcmdtype()" function | |
3944 */ | |
3945 void | |
3946 f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv) | |
3947 { | |
3948 rettv->v_type = VAR_STRING; | |
3949 rettv->vval.v_string = alloc(2); | |
3950 if (rettv->vval.v_string != NULL) | |
3951 { | |
3952 rettv->vval.v_string[0] = get_cmdline_type(); | |
3953 rettv->vval.v_string[1] = NUL; | |
3954 } | |
3955 } | |
3956 | |
3922 #endif | 3957 #endif |
3923 | 3958 |
3924 #if defined(FEAT_EVAL) || defined(FEAT_CMDWIN) || defined(PROTO) | 3959 #if defined(FEAT_EVAL) || defined(FEAT_CMDWIN) || defined(PROTO) |
3925 /* | 3960 /* |
3926 * Get the current command-line type. | 3961 * Get the current command-line type. |