comparison src/edit.c @ 835:8bebcabccc2c v7.0e01

updated for version 7.0e01
author vimboss
date Mon, 17 Apr 2006 22:14:47 +0000
parents dc8197342755
children 5a7843c57316
comparison
equal deleted inserted replaced
834:5117153003bd 835:8bebcabccc2c
2483 { 2483 {
2484 /* Need to build the popup menu list. */ 2484 /* Need to build the popup menu list. */
2485 compl_match_arraysize = 0; 2485 compl_match_arraysize = 0;
2486 compl = compl_first_match; 2486 compl = compl_first_match;
2487 if (compl_leader != NULL) 2487 if (compl_leader != NULL)
2488 lead_len = STRLEN(compl_leader); 2488 lead_len = (int)STRLEN(compl_leader);
2489 do 2489 do
2490 { 2490 {
2491 if ((compl->cp_flags & ORIGINAL_TEXT) == 0 2491 if ((compl->cp_flags & ORIGINAL_TEXT) == 0
2492 && (compl_leader == NULL 2492 && (compl_leader == NULL
2493 || ins_compl_equal(compl, compl_leader, lead_len))) 2493 || ins_compl_equal(compl, compl_leader, lead_len)))
2641 /* When invoked to match whole lines for CTRL-X CTRL-L adjust the pattern 2641 /* When invoked to match whole lines for CTRL-X CTRL-L adjust the pattern
2642 * to only match at the start of a line. Otherwise just match the 2642 * to only match at the start of a line. Otherwise just match the
2643 * pattern. */ 2643 * pattern. */
2644 if (ctrl_x_mode == CTRL_X_WHOLE_LINE) 2644 if (ctrl_x_mode == CTRL_X_WHOLE_LINE)
2645 { 2645 {
2646 i = STRLEN(pat) + 8; 2646 i = (int)STRLEN(pat) + 8;
2647 ptr = alloc(i); 2647 ptr = alloc(i);
2648 if (ptr == NULL) 2648 if (ptr == NULL)
2649 return; 2649 return;
2650 vim_snprintf((char *)ptr, i, "^\\s*\\zs%s", pat); 2650 vim_snprintf((char *)ptr, i, "^\\s*\\zs%s", pat);
2651 regmatch.regprog = vim_regcomp(ptr, p_magic ? RE_MAGIC : 0); 2651 regmatch.regprog = vim_regcomp(ptr, p_magic ? RE_MAGIC : 0);
2965 line = ml_get_curline(); 2965 line = ml_get_curline();
2966 p = line + curwin->w_cursor.col; 2966 p = line + curwin->w_cursor.col;
2967 mb_ptr_back(line, p); 2967 mb_ptr_back(line, p);
2968 2968
2969 vim_free(compl_leader); 2969 vim_free(compl_leader);
2970 compl_leader = vim_strnsave(line + compl_col, (p - line) - compl_col); 2970 compl_leader = vim_strnsave(line + compl_col, (int)(p - line) - compl_col);
2971 if (compl_leader != NULL) 2971 if (compl_leader != NULL)
2972 { 2972 {
2973 ins_compl_del_pum(); 2973 ins_compl_del_pum();
2974 ins_compl_delete(); 2974 ins_compl_delete();
2975 ins_bytes(compl_leader + curwin->w_cursor.col - compl_col); 2975 ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
3986 && (compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0) 3986 && (compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0)
3987 { 3987 {
3988 /* Set "compl_shown_match" to the actually shown match, it may differ 3988 /* Set "compl_shown_match" to the actually shown match, it may differ
3989 * when "compl_leader" is used to omit some of the matches. */ 3989 * when "compl_leader" is used to omit some of the matches. */
3990 while (!ins_compl_equal(compl_shown_match, 3990 while (!ins_compl_equal(compl_shown_match,
3991 compl_leader, STRLEN(compl_leader)) 3991 compl_leader, (int)STRLEN(compl_leader))
3992 && compl_shown_match->cp_next != NULL 3992 && compl_shown_match->cp_next != NULL
3993 && compl_shown_match->cp_next != compl_first_match) 3993 && compl_shown_match->cp_next != compl_first_match)
3994 compl_shown_match = compl_shown_match->cp_next; 3994 compl_shown_match = compl_shown_match->cp_next;
3995 } 3995 }
3996 3996
4036 found_end = FALSE; 4036 found_end = FALSE;
4037 } 4037 }
4038 if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0 4038 if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0
4039 && compl_leader != NULL 4039 && compl_leader != NULL
4040 && !ins_compl_equal(compl_shown_match, 4040 && !ins_compl_equal(compl_shown_match,
4041 compl_leader, STRLEN(compl_leader))) 4041 compl_leader, (int)STRLEN(compl_leader)))
4042 ++todo; 4042 ++todo;
4043 else 4043 else
4044 /* Remember a matching item. */ 4044 /* Remember a matching item. */
4045 found_compl = compl_shown_match; 4045 found_compl = compl_shown_match;
4046 4046
4444 } 4444 }
4445 } 4445 }
4446 } 4446 }
4447 else if (ctrl_x_mode == CTRL_X_WHOLE_LINE) 4447 else if (ctrl_x_mode == CTRL_X_WHOLE_LINE)
4448 { 4448 {
4449 compl_col = skipwhite(line) - line; 4449 compl_col = (colnr_T)(skipwhite(line) - line);
4450 compl_length = (int)curs_col - (int)compl_col; 4450 compl_length = (int)curs_col - (int)compl_col;
4451 if (compl_length < 0) /* cursor in indent: empty pattern */ 4451 if (compl_length < 0) /* cursor in indent: empty pattern */
4452 compl_length = 0; 4452 compl_length = 0;
4453 if (p_ic) 4453 if (p_ic)
4454 compl_pattern = str_foldcase(line + compl_col, compl_length, 4454 compl_pattern = str_foldcase(line + compl_col, compl_length,
5666 * need to add a space when 'w' is in 'formatoptions' to keep a paragraph 5666 * need to add a space when 'w' is in 'formatoptions' to keep a paragraph
5667 * formatted. */ 5667 * formatted. */
5668 if (!wasatend && has_format_option(FO_WHITE_PAR)) 5668 if (!wasatend && has_format_option(FO_WHITE_PAR))
5669 { 5669 {
5670 new = ml_get_curline(); 5670 new = ml_get_curline();
5671 len = STRLEN(new); 5671 len = (colnr_T)STRLEN(new);
5672 if (curwin->w_cursor.col == len) 5672 if (curwin->w_cursor.col == len)
5673 { 5673 {
5674 pnew = vim_strnsave(new, len + 2); 5674 pnew = vim_strnsave(new, len + 2);
5675 pnew[len] = ' '; 5675 pnew[len] = ' ';
5676 pnew[len + 1] = NUL; 5676 pnew[len + 1] = NUL;
5982 #ifdef FEAT_VISUAL 5982 #ifdef FEAT_VISUAL
5983 /* <C-S-Right> may have started Visual mode, adjust the position for 5983 /* <C-S-Right> may have started Visual mode, adjust the position for
5984 * deleted characters. */ 5984 * deleted characters. */
5985 if (VIsual_active && VIsual.lnum == curwin->w_cursor.lnum) 5985 if (VIsual_active && VIsual.lnum == curwin->w_cursor.lnum)
5986 { 5986 {
5987 cc = STRLEN(ml_get_curline()); 5987 cc = (int)STRLEN(ml_get_curline());
5988 if (VIsual.col > (colnr_T)cc) 5988 if (VIsual.col > (colnr_T)cc)
5989 { 5989 {
5990 VIsual.col = cc; 5990 VIsual.col = cc;
5991 # ifdef FEAT_VIRTUALEDIT 5991 # ifdef FEAT_VIRTUALEDIT
5992 VIsual.coladd = 0; 5992 VIsual.coladd = 0;
6716 if (has_mbyte) 6716 if (has_mbyte)
6717 { 6717 {
6718 del_char(FALSE); 6718 del_char(FALSE);
6719 # ifdef FEAT_VREPLACE 6719 # ifdef FEAT_VREPLACE
6720 if (State & VREPLACE_FLAG) 6720 if (State & VREPLACE_FLAG)
6721 orig_len = STRLEN(ml_get_cursor()); 6721 orig_len = (int)STRLEN(ml_get_cursor());
6722 # endif 6722 # endif
6723 replace_push(cc); 6723 replace_push(cc);
6724 } 6724 }
6725 else 6725 else
6726 #endif 6726 #endif
6727 { 6727 {
6728 pchar_cursor(cc); 6728 pchar_cursor(cc);
6729 #ifdef FEAT_VREPLACE 6729 #ifdef FEAT_VREPLACE
6730 if (State & VREPLACE_FLAG) 6730 if (State & VREPLACE_FLAG)
6731 orig_len = STRLEN(ml_get_cursor()) - 1; 6731 orig_len = (int)STRLEN(ml_get_cursor()) - 1;
6732 #endif 6732 #endif
6733 } 6733 }
6734 replace_pop_ins(); 6734 replace_pop_ins();
6735 6735
6736 #ifdef FEAT_VREPLACE 6736 #ifdef FEAT_VREPLACE
6737 if (State & VREPLACE_FLAG) 6737 if (State & VREPLACE_FLAG)
6738 { 6738 {
6739 /* Get the number of screen cells used by the inserted characters */ 6739 /* Get the number of screen cells used by the inserted characters */
6740 p = ml_get_cursor(); 6740 p = ml_get_cursor();
6741 ins_len = STRLEN(p) - orig_len; 6741 ins_len = (int)STRLEN(p) - orig_len;
6742 vcol = start_vcol; 6742 vcol = start_vcol;
6743 for (i = 0; i < ins_len; ++i) 6743 for (i = 0; i < ins_len; ++i)
6744 { 6744 {
6745 vcol += chartabsize(p + i, vcol); 6745 vcol += chartabsize(p + i, vcol);
6746 #ifdef FEAT_MBYTE 6746 #ifdef FEAT_MBYTE
7906 { 7906 {
7907 char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, 7907 char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum,
7908 TRUE); 7908 TRUE);
7909 int len; 7909 int len;
7910 7910
7911 len = STRLEN(ptr); 7911 len = (int)STRLEN(ptr);
7912 if (len > 0 && ptr[len - 1] == ' ') 7912 if (len > 0 && ptr[len - 1] == ' ')
7913 ptr[len - 1] = NUL; 7913 ptr[len - 1] = NUL;
7914 } 7914 }
7915 7915
7916 (void)do_join(FALSE); 7916 (void)do_join(FALSE);