mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.0026: still some /* */ comments
Problem: Still some /* */ comments. Solution: Convert to // comments.
This commit is contained in:
parent
fe72d08400
commit
85a2002adb
918
src/message.c
918
src/message.c
File diff suppressed because it is too large
Load Diff
@ -14,12 +14,12 @@
|
|||||||
#undef NDEBUG
|
#undef NDEBUG
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/* Must include main.c because it contains much more than just main() */
|
// Must include main.c because it contains much more than just main()
|
||||||
#define NO_VIM_MAIN
|
#define NO_VIM_MAIN
|
||||||
#include "main.c"
|
#include "main.c"
|
||||||
|
|
||||||
/* This file has to be included because some of the tested functions are
|
// This file has to be included because some of the tested functions are
|
||||||
* static. */
|
// static.
|
||||||
#include "message.c"
|
#include "message.c"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -31,7 +31,7 @@ test_trunc_string(void)
|
|||||||
char_u *buf; /*allocated every time to find uninit errors */
|
char_u *buf; /*allocated every time to find uninit errors */
|
||||||
char_u *s;
|
char_u *s;
|
||||||
|
|
||||||
/* in place */
|
// in place
|
||||||
buf = alloc(40);
|
buf = alloc(40);
|
||||||
STRCPY(buf, "text");
|
STRCPY(buf, "text");
|
||||||
trunc_string(buf, buf, 20, 40);
|
trunc_string(buf, buf, 20, 40);
|
||||||
@ -56,7 +56,7 @@ test_trunc_string(void)
|
|||||||
assert(STRCMP(buf, "a text t...nott fits") == 0);
|
assert(STRCMP(buf, "a text t...nott fits") == 0);
|
||||||
vim_free(buf);
|
vim_free(buf);
|
||||||
|
|
||||||
/* copy from string to buf */
|
// copy from string to buf
|
||||||
buf = alloc(40);
|
buf = alloc(40);
|
||||||
s = vim_strsave((char_u *)"text");
|
s = vim_strsave((char_u *)"text");
|
||||||
trunc_string(s, buf, 20, 40);
|
trunc_string(s, buf, 20, 40);
|
||||||
|
367
src/misc1.c
367
src/misc1.c
@ -18,8 +18,8 @@
|
|||||||
# include <lm.h>
|
# include <lm.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define URL_SLASH 1 /* path_is_url() has found "://" */
|
#define URL_SLASH 1 // path_is_url() has found "://"
|
||||||
#define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */
|
#define URL_BACKSLASH 2 // path_is_url() has found ":\\"
|
||||||
|
|
||||||
// All user names (for ~user completion as done by shell).
|
// All user names (for ~user completion as done by shell).
|
||||||
static garray_T ga_users;
|
static garray_T ga_users;
|
||||||
@ -45,15 +45,15 @@ get_leader_len(
|
|||||||
int result;
|
int result;
|
||||||
int got_com = FALSE;
|
int got_com = FALSE;
|
||||||
int found_one;
|
int found_one;
|
||||||
char_u part_buf[COM_MAX_LEN]; /* buffer for one option part */
|
char_u part_buf[COM_MAX_LEN]; // buffer for one option part
|
||||||
char_u *string; /* pointer to comment string */
|
char_u *string; // pointer to comment string
|
||||||
char_u *list;
|
char_u *list;
|
||||||
int middle_match_len = 0;
|
int middle_match_len = 0;
|
||||||
char_u *prev_list;
|
char_u *prev_list;
|
||||||
char_u *saved_flags = NULL;
|
char_u *saved_flags = NULL;
|
||||||
|
|
||||||
result = i = 0;
|
result = i = 0;
|
||||||
while (VIM_ISWHITE(line[i])) /* leading white space is ignored */
|
while (VIM_ISWHITE(line[i])) // leading white space is ignored
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -67,60 +67,60 @@ get_leader_len(
|
|||||||
found_one = FALSE;
|
found_one = FALSE;
|
||||||
for (list = curbuf->b_p_com; *list; )
|
for (list = curbuf->b_p_com; *list; )
|
||||||
{
|
{
|
||||||
/* Get one option part into part_buf[]. Advance "list" to next
|
// Get one option part into part_buf[]. Advance "list" to next
|
||||||
* one. Put "string" at start of string. */
|
// one. Put "string" at start of string.
|
||||||
if (!got_com && flags != NULL)
|
if (!got_com && flags != NULL)
|
||||||
*flags = list; /* remember where flags started */
|
*flags = list; // remember where flags started
|
||||||
prev_list = list;
|
prev_list = list;
|
||||||
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
|
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
|
||||||
string = vim_strchr(part_buf, ':');
|
string = vim_strchr(part_buf, ':');
|
||||||
if (string == NULL) /* missing ':', ignore this part */
|
if (string == NULL) // missing ':', ignore this part
|
||||||
continue;
|
continue;
|
||||||
*string++ = NUL; /* isolate flags from string */
|
*string++ = NUL; // isolate flags from string
|
||||||
|
|
||||||
/* If we found a middle match previously, use that match when this
|
// If we found a middle match previously, use that match when this
|
||||||
* is not a middle or end. */
|
// is not a middle or end.
|
||||||
if (middle_match_len != 0
|
if (middle_match_len != 0
|
||||||
&& vim_strchr(part_buf, COM_MIDDLE) == NULL
|
&& vim_strchr(part_buf, COM_MIDDLE) == NULL
|
||||||
&& vim_strchr(part_buf, COM_END) == NULL)
|
&& vim_strchr(part_buf, COM_END) == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* When we already found a nested comment, only accept further
|
// When we already found a nested comment, only accept further
|
||||||
* nested comments. */
|
// nested comments.
|
||||||
if (got_com && vim_strchr(part_buf, COM_NEST) == NULL)
|
if (got_com && vim_strchr(part_buf, COM_NEST) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* When 'O' flag present and using "O" command skip this one. */
|
// When 'O' flag present and using "O" command skip this one.
|
||||||
if (backward && vim_strchr(part_buf, COM_NOBACK) != NULL)
|
if (backward && vim_strchr(part_buf, COM_NOBACK) != NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Line contents and string must match.
|
// Line contents and string must match.
|
||||||
* When string starts with white space, must have some white space
|
// When string starts with white space, must have some white space
|
||||||
* (but the amount does not need to match, there might be a mix of
|
// (but the amount does not need to match, there might be a mix of
|
||||||
* TABs and spaces). */
|
// TABs and spaces).
|
||||||
if (VIM_ISWHITE(string[0]))
|
if (VIM_ISWHITE(string[0]))
|
||||||
{
|
{
|
||||||
if (i == 0 || !VIM_ISWHITE(line[i - 1]))
|
if (i == 0 || !VIM_ISWHITE(line[i - 1]))
|
||||||
continue; /* missing white space */
|
continue; // missing white space
|
||||||
while (VIM_ISWHITE(string[0]))
|
while (VIM_ISWHITE(string[0]))
|
||||||
++string;
|
++string;
|
||||||
}
|
}
|
||||||
for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j)
|
for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j)
|
||||||
;
|
;
|
||||||
if (string[j] != NUL)
|
if (string[j] != NUL)
|
||||||
continue; /* string doesn't match */
|
continue; // string doesn't match
|
||||||
|
|
||||||
/* When 'b' flag used, there must be white space or an
|
// When 'b' flag used, there must be white space or an
|
||||||
* end-of-line after the string in the line. */
|
// end-of-line after the string in the line.
|
||||||
if (vim_strchr(part_buf, COM_BLANK) != NULL
|
if (vim_strchr(part_buf, COM_BLANK) != NULL
|
||||||
&& !VIM_ISWHITE(line[i + j]) && line[i + j] != NUL)
|
&& !VIM_ISWHITE(line[i + j]) && line[i + j] != NUL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* We have found a match, stop searching unless this is a middle
|
// We have found a match, stop searching unless this is a middle
|
||||||
* comment. The middle comment can be a substring of the end
|
// comment. The middle comment can be a substring of the end
|
||||||
* comment in which case it's better to return the length of the
|
// comment in which case it's better to return the length of the
|
||||||
* end comment and its flags. Thus we keep searching with middle
|
// end comment and its flags. Thus we keep searching with middle
|
||||||
* and end matches and use an end match if it matches better. */
|
// and end matches and use an end match if it matches better.
|
||||||
if (vim_strchr(part_buf, COM_MIDDLE) != NULL)
|
if (vim_strchr(part_buf, COM_MIDDLE) != NULL)
|
||||||
{
|
{
|
||||||
if (middle_match_len == 0)
|
if (middle_match_len == 0)
|
||||||
@ -131,8 +131,8 @@ get_leader_len(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (middle_match_len != 0 && j > middle_match_len)
|
if (middle_match_len != 0 && j > middle_match_len)
|
||||||
/* Use this match instead of the middle match, since it's a
|
// Use this match instead of the middle match, since it's a
|
||||||
* longer thus better match. */
|
// longer thus better match.
|
||||||
middle_match_len = 0;
|
middle_match_len = 0;
|
||||||
|
|
||||||
if (middle_match_len == 0)
|
if (middle_match_len == 0)
|
||||||
@ -143,28 +143,28 @@ get_leader_len(
|
|||||||
|
|
||||||
if (middle_match_len != 0)
|
if (middle_match_len != 0)
|
||||||
{
|
{
|
||||||
/* Use the previously found middle match after failing to find a
|
// Use the previously found middle match after failing to find a
|
||||||
* match with an end. */
|
// match with an end.
|
||||||
if (!got_com && flags != NULL)
|
if (!got_com && flags != NULL)
|
||||||
*flags = saved_flags;
|
*flags = saved_flags;
|
||||||
i += middle_match_len;
|
i += middle_match_len;
|
||||||
found_one = TRUE;
|
found_one = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No match found, stop scanning. */
|
// No match found, stop scanning.
|
||||||
if (!found_one)
|
if (!found_one)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
result = i;
|
result = i;
|
||||||
|
|
||||||
/* Include any trailing white space. */
|
// Include any trailing white space.
|
||||||
while (VIM_ISWHITE(line[i]))
|
while (VIM_ISWHITE(line[i]))
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
if (include_space)
|
if (include_space)
|
||||||
result = i;
|
result = i;
|
||||||
|
|
||||||
/* If this comment doesn't nest, stop here. */
|
// If this comment doesn't nest, stop here.
|
||||||
got_com = TRUE;
|
got_com = TRUE;
|
||||||
if (vim_strchr(part_buf, COM_NEST) == NULL)
|
if (vim_strchr(part_buf, COM_NEST) == NULL)
|
||||||
break;
|
break;
|
||||||
@ -190,7 +190,7 @@ get_last_leader_offset(char_u *line, char_u **flags)
|
|||||||
char_u *com_flags;
|
char_u *com_flags;
|
||||||
char_u *list;
|
char_u *list;
|
||||||
int found_one;
|
int found_one;
|
||||||
char_u part_buf[COM_MAX_LEN]; /* buffer for one option part */
|
char_u part_buf[COM_MAX_LEN]; // buffer for one option part
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Repeat to match several nested comment strings.
|
* Repeat to match several nested comment strings.
|
||||||
@ -212,10 +212,10 @@ get_last_leader_offset(char_u *line, char_u **flags)
|
|||||||
*/
|
*/
|
||||||
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
|
(void)copy_option_part(&list, part_buf, COM_MAX_LEN, ",");
|
||||||
string = vim_strchr(part_buf, ':');
|
string = vim_strchr(part_buf, ':');
|
||||||
if (string == NULL) /* If everything is fine, this cannot actually
|
if (string == NULL) // If everything is fine, this cannot actually
|
||||||
* happen. */
|
// happen.
|
||||||
continue;
|
continue;
|
||||||
*string++ = NUL; /* Isolate flags from string. */
|
*string++ = NUL; // Isolate flags from string.
|
||||||
com_leader = string;
|
com_leader = string;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -271,7 +271,7 @@ get_last_leader_offset(char_u *line, char_u **flags)
|
|||||||
|
|
||||||
if (found_one)
|
if (found_one)
|
||||||
{
|
{
|
||||||
char_u part_buf2[COM_MAX_LEN]; /* buffer for one option part */
|
char_u part_buf2[COM_MAX_LEN]; // buffer for one option part
|
||||||
int len1, len2, off;
|
int len1, len2, off;
|
||||||
|
|
||||||
result = i;
|
result = i;
|
||||||
@ -283,11 +283,10 @@ get_last_leader_offset(char_u *line, char_u **flags)
|
|||||||
|
|
||||||
lower_check_bound = i;
|
lower_check_bound = i;
|
||||||
|
|
||||||
/* Let's verify whether the comment leader found is a substring
|
// Let's verify whether the comment leader found is a substring
|
||||||
* of other comment leaders. If it is, let's adjust the
|
// of other comment leaders. If it is, let's adjust the
|
||||||
* lower_check_bound so that we make sure that we have determined
|
// lower_check_bound so that we make sure that we have determined
|
||||||
* the comment leader correctly.
|
// the comment leader correctly.
|
||||||
*/
|
|
||||||
|
|
||||||
while (VIM_ISWHITE(*com_leader))
|
while (VIM_ISWHITE(*com_leader))
|
||||||
++com_leader;
|
++com_leader;
|
||||||
@ -308,8 +307,8 @@ get_last_leader_offset(char_u *line, char_u **flags)
|
|||||||
if (len2 == 0)
|
if (len2 == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Now we have to verify whether string ends with a substring
|
// Now we have to verify whether string ends with a substring
|
||||||
* beginning the com_leader. */
|
// beginning the com_leader.
|
||||||
for (off = (len2 > i ? i : len2); off > 0 && off + len1 > len2;)
|
for (off = (len2 > i ? i : len2); off > 0 && off + len1 > len2;)
|
||||||
{
|
{
|
||||||
--off;
|
--off;
|
||||||
@ -338,11 +337,11 @@ plines(linenr_T lnum)
|
|||||||
plines_win(
|
plines_win(
|
||||||
win_T *wp,
|
win_T *wp,
|
||||||
linenr_T lnum,
|
linenr_T lnum,
|
||||||
int winheight) /* when TRUE limit to window height */
|
int winheight) // when TRUE limit to window height
|
||||||
{
|
{
|
||||||
#if defined(FEAT_DIFF) || defined(PROTO)
|
#if defined(FEAT_DIFF) || defined(PROTO)
|
||||||
/* Check for filler lines above this buffer line. When folded the result
|
// Check for filler lines above this buffer line. When folded the result
|
||||||
* is one line anyway. */
|
// is one line anyway.
|
||||||
return plines_win_nofill(wp, lnum, winheight) + diff_check_fill(wp, lnum);
|
return plines_win_nofill(wp, lnum, winheight) + diff_check_fill(wp, lnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +355,7 @@ plines_nofill(linenr_T lnum)
|
|||||||
plines_win_nofill(
|
plines_win_nofill(
|
||||||
win_T *wp,
|
win_T *wp,
|
||||||
linenr_T lnum,
|
linenr_T lnum,
|
||||||
int winheight) /* when TRUE limit to window height */
|
int winheight) // when TRUE limit to window height
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
int lines;
|
int lines;
|
||||||
@ -368,8 +367,8 @@ plines_win_nofill(
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
/* A folded lines is handled just like an empty line. */
|
// A folded lines is handled just like an empty line.
|
||||||
/* NOTE: Caller must handle lines that are MAYBE folded. */
|
// NOTE: Caller must handle lines that are MAYBE folded.
|
||||||
if (lineFolded(wp, lnum) == TRUE)
|
if (lineFolded(wp, lnum) == TRUE)
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
@ -392,7 +391,7 @@ plines_win_nofold(win_T *wp, linenr_T lnum)
|
|||||||
int width;
|
int width;
|
||||||
|
|
||||||
s = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
s = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
||||||
if (*s == NUL) /* empty line */
|
if (*s == NUL) // empty line
|
||||||
return 1;
|
return 1;
|
||||||
col = win_linetabsize(wp, s, (colnr_T)MAXCOL);
|
col = win_linetabsize(wp, s, (colnr_T)MAXCOL);
|
||||||
|
|
||||||
@ -430,8 +429,8 @@ plines_win_col(win_T *wp, linenr_T lnum, long column)
|
|||||||
char_u *line;
|
char_u *line;
|
||||||
|
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
/* Check for filler lines above this buffer line. When folded the result
|
// Check for filler lines above this buffer line. When folded the result
|
||||||
* is one line anyway. */
|
// is one line anyway.
|
||||||
lines = diff_check_fill(wp, lnum);
|
lines = diff_check_fill(wp, lnum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -483,12 +482,12 @@ plines_m_win(win_T *wp, linenr_T first, linenr_T last)
|
|||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
/* Check if there are any really folded lines, but also included lines
|
// Check if there are any really folded lines, but also included lines
|
||||||
* that are maybe folded. */
|
// that are maybe folded.
|
||||||
x = foldedCount(wp, first, NULL);
|
x = foldedCount(wp, first, NULL);
|
||||||
if (x > 0)
|
if (x > 0)
|
||||||
{
|
{
|
||||||
++count; /* count 1 for "+-- folded" line */
|
++count; // count 1 for "+-- folded" line
|
||||||
first += x;
|
first += x;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -511,7 +510,7 @@ gchar_pos(pos_T *pos)
|
|||||||
{
|
{
|
||||||
char_u *ptr;
|
char_u *ptr;
|
||||||
|
|
||||||
/* When searching columns is sometimes put at the end of a line. */
|
// When searching columns is sometimes put at the end of a line.
|
||||||
if (pos->col == MAXCOL)
|
if (pos->col == MAXCOL)
|
||||||
return NUL;
|
return NUL;
|
||||||
ptr = ml_get_pos(pos);
|
ptr = ml_get_pos(pos);
|
||||||
@ -585,7 +584,7 @@ ask_yesno(char_u *str, int direct)
|
|||||||
int r = ' ';
|
int r = ' ';
|
||||||
int save_State = State;
|
int save_State = State;
|
||||||
|
|
||||||
if (exiting) /* put terminal in raw mode for this question */
|
if (exiting) // put terminal in raw mode for this question
|
||||||
settmode(TMODE_RAW);
|
settmode(TMODE_RAW);
|
||||||
++no_wait_return;
|
++no_wait_return;
|
||||||
#ifdef USE_ON_FLY_SCROLL
|
#ifdef USE_ON_FLY_SCROLL
|
||||||
@ -598,7 +597,7 @@ ask_yesno(char_u *str, int direct)
|
|||||||
|
|
||||||
while (r != 'y' && r != 'n')
|
while (r != 'y' && r != 'n')
|
||||||
{
|
{
|
||||||
/* same highlighting as for wait_return */
|
// same highlighting as for wait_return
|
||||||
smsg_attr(HL_ATTR(HLF_R), "%s (y/n)?", str);
|
smsg_attr(HL_ATTR(HLF_R), "%s (y/n)?", str);
|
||||||
if (direct)
|
if (direct)
|
||||||
r = get_keystroke();
|
r = get_keystroke();
|
||||||
@ -606,7 +605,7 @@ ask_yesno(char_u *str, int direct)
|
|||||||
r = plain_vgetc();
|
r = plain_vgetc();
|
||||||
if (r == Ctrl_C || r == ESC)
|
if (r == Ctrl_C || r == ESC)
|
||||||
r = 'n';
|
r = 'n';
|
||||||
msg_putchar(r); /* show what you typed */
|
msg_putchar(r); // show what you typed
|
||||||
out_flush();
|
out_flush();
|
||||||
}
|
}
|
||||||
--no_wait_return;
|
--no_wait_return;
|
||||||
@ -632,7 +631,7 @@ f_mode(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
if (time_for_testing == 93784)
|
if (time_for_testing == 93784)
|
||||||
{
|
{
|
||||||
/* Testing the two-character code. */
|
// Testing the two-character code.
|
||||||
buf[0] = 'x';
|
buf[0] = 'x';
|
||||||
buf[1] = '!';
|
buf[1] = '!';
|
||||||
}
|
}
|
||||||
@ -702,8 +701,8 @@ f_mode(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear out the minor mode when the argument is not a non-zero number or
|
// Clear out the minor mode when the argument is not a non-zero number or
|
||||||
* non-empty string. */
|
// non-empty string.
|
||||||
if (!non_zero_arg(&argvars[0]))
|
if (!non_zero_arg(&argvars[0]))
|
||||||
buf[1] = NUL;
|
buf[1] = NUL;
|
||||||
|
|
||||||
@ -777,15 +776,15 @@ get_keystroke(void)
|
|||||||
int save_mapped_ctrl_c = mapped_ctrl_c;
|
int save_mapped_ctrl_c = mapped_ctrl_c;
|
||||||
int waited = 0;
|
int waited = 0;
|
||||||
|
|
||||||
mapped_ctrl_c = FALSE; /* mappings are not used here */
|
mapped_ctrl_c = FALSE; // mappings are not used here
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
cursor_on();
|
cursor_on();
|
||||||
out_flush();
|
out_flush();
|
||||||
|
|
||||||
/* Leave some room for check_termcode() to insert a key code into (max
|
// Leave some room for check_termcode() to insert a key code into (max
|
||||||
* 5 chars plus NUL). And fix_input_buffer() can triple the number of
|
// 5 chars plus NUL). And fix_input_buffer() can triple the number of
|
||||||
* bytes. */
|
// bytes.
|
||||||
maxlen = (buflen - 6 - len) / 3;
|
maxlen = (buflen - 6 - len) / 3;
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
buf = alloc(buflen);
|
buf = alloc(buflen);
|
||||||
@ -793,8 +792,8 @@ get_keystroke(void)
|
|||||||
{
|
{
|
||||||
char_u *t_buf = buf;
|
char_u *t_buf = buf;
|
||||||
|
|
||||||
/* Need some more space. This might happen when receiving a long
|
// Need some more space. This might happen when receiving a long
|
||||||
* escape sequence. */
|
// escape sequence.
|
||||||
buflen += 100;
|
buflen += 100;
|
||||||
buf = vim_realloc(buf, buflen);
|
buf = vim_realloc(buf, buflen);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
@ -804,43 +803,43 @@ get_keystroke(void)
|
|||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
{
|
{
|
||||||
do_outofmem_msg((long_u)buflen);
|
do_outofmem_msg((long_u)buflen);
|
||||||
return ESC; /* panic! */
|
return ESC; // panic!
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First time: blocking wait. Second time: wait up to 100ms for a
|
// First time: blocking wait. Second time: wait up to 100ms for a
|
||||||
* terminal code to complete. */
|
// terminal code to complete.
|
||||||
n = ui_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0);
|
n = ui_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
/* Replace zero and CSI by a special key code. */
|
// Replace zero and CSI by a special key code.
|
||||||
n = fix_input_buffer(buf + len, n);
|
n = fix_input_buffer(buf + len, n);
|
||||||
len += n;
|
len += n;
|
||||||
waited = 0;
|
waited = 0;
|
||||||
}
|
}
|
||||||
else if (len > 0)
|
else if (len > 0)
|
||||||
++waited; /* keep track of the waiting time */
|
++waited; // keep track of the waiting time
|
||||||
|
|
||||||
/* Incomplete termcode and not timed out yet: get more characters */
|
// Incomplete termcode and not timed out yet: get more characters
|
||||||
if ((n = check_termcode(1, buf, buflen, &len)) < 0
|
if ((n = check_termcode(1, buf, buflen, &len)) < 0
|
||||||
&& (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
|
&& (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (n == KEYLEN_REMOVED) /* key code removed */
|
if (n == KEYLEN_REMOVED) // key code removed
|
||||||
{
|
{
|
||||||
if (must_redraw != 0 && !need_wait_return && (State & CMDLINE) == 0)
|
if (must_redraw != 0 && !need_wait_return && (State & CMDLINE) == 0)
|
||||||
{
|
{
|
||||||
/* Redrawing was postponed, do it now. */
|
// Redrawing was postponed, do it now.
|
||||||
update_screen(0);
|
update_screen(0);
|
||||||
setcursor(); /* put cursor back where it belongs */
|
setcursor(); // put cursor back where it belongs
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (n > 0) /* found a termcode: adjust length */
|
if (n > 0) // found a termcode: adjust length
|
||||||
len = n;
|
len = n;
|
||||||
if (len == 0) /* nothing typed yet */
|
if (len == 0) // nothing typed yet
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Handle modifier and/or special key code. */
|
// Handle modifier and/or special key code.
|
||||||
n = buf[0];
|
n = buf[0];
|
||||||
if (n == K_SPECIAL)
|
if (n == K_SPECIAL)
|
||||||
{
|
{
|
||||||
@ -866,7 +865,7 @@ get_keystroke(void)
|
|||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
{
|
{
|
||||||
if (MB_BYTE2LEN(n) > len)
|
if (MB_BYTE2LEN(n) > len)
|
||||||
continue; /* more bytes to get */
|
continue; // more bytes to get
|
||||||
buf[len >= buflen ? buflen - 1 : len] = NUL;
|
buf[len >= buflen ? buflen - 1 : len] = NUL;
|
||||||
n = (*mb_ptr2char)(buf);
|
n = (*mb_ptr2char)(buf);
|
||||||
}
|
}
|
||||||
@ -888,7 +887,7 @@ get_keystroke(void)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_number(
|
get_number(
|
||||||
int colon, /* allow colon to abort */
|
int colon, // allow colon to abort
|
||||||
int *mouse_used)
|
int *mouse_used)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -898,16 +897,16 @@ get_number(
|
|||||||
if (mouse_used != NULL)
|
if (mouse_used != NULL)
|
||||||
*mouse_used = FALSE;
|
*mouse_used = FALSE;
|
||||||
|
|
||||||
/* When not printing messages, the user won't know what to type, return a
|
// When not printing messages, the user won't know what to type, return a
|
||||||
* zero (as if CR was hit). */
|
// zero (as if CR was hit).
|
||||||
if (msg_silent != 0)
|
if (msg_silent != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#ifdef USE_ON_FLY_SCROLL
|
#ifdef USE_ON_FLY_SCROLL
|
||||||
dont_scroll = TRUE; /* disallow scrolling here */
|
dont_scroll = TRUE; // disallow scrolling here
|
||||||
#endif
|
#endif
|
||||||
++no_mapping;
|
++no_mapping;
|
||||||
++allow_keys; /* no mapping here, but recognize keys */
|
++allow_keys; // no mapping here, but recognize keys
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
windgoto(msg_row, msg_col);
|
windgoto(msg_row, msg_col);
|
||||||
@ -938,7 +937,7 @@ get_number(
|
|||||||
stuffcharReadbuff(':');
|
stuffcharReadbuff(':');
|
||||||
if (!exmode_active)
|
if (!exmode_active)
|
||||||
cmdline_row = msg_row;
|
cmdline_row = msg_row;
|
||||||
skip_redraw = TRUE; /* skip redraw once */
|
skip_redraw = TRUE; // skip redraw once
|
||||||
do_redraw = FALSE;
|
do_redraw = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -962,7 +961,7 @@ prompt_for_number(int *mouse_used)
|
|||||||
int save_cmdline_row;
|
int save_cmdline_row;
|
||||||
int save_State;
|
int save_State;
|
||||||
|
|
||||||
/* When using ":silent" assume that <CR> was entered. */
|
// When using ":silent" assume that <CR> was entered.
|
||||||
if (mouse_used != NULL)
|
if (mouse_used != NULL)
|
||||||
msg_puts(_("Type number and <Enter> or click with mouse (empty cancels): "));
|
msg_puts(_("Type number and <Enter> or click with mouse (empty cancels): "));
|
||||||
else
|
else
|
||||||
@ -1002,13 +1001,13 @@ msgmore(long n)
|
|||||||
{
|
{
|
||||||
long pn;
|
long pn;
|
||||||
|
|
||||||
if (global_busy /* no messages now, wait until global is finished */
|
if (global_busy // no messages now, wait until global is finished
|
||||||
|| !messaging()) /* 'lazyredraw' set, don't do messages now */
|
|| !messaging()) // 'lazyredraw' set, don't do messages now
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* We don't want to overwrite another important message, but do overwrite
|
// We don't want to overwrite another important message, but do overwrite
|
||||||
* a previous "more lines" or "fewer lines" message, so that "5dd" and
|
// a previous "more lines" or "fewer lines" message, so that "5dd" and
|
||||||
* then "put" reports the last action. */
|
// then "put" reports the last action.
|
||||||
if (keep_msg != NULL && !keep_msg_more)
|
if (keep_msg != NULL && !keep_msg_more)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1054,7 +1053,7 @@ beep_flush(void)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
vim_beep(
|
vim_beep(
|
||||||
unsigned val) /* one of the BO_ values, e.g., BO_OPER */
|
unsigned val) // one of the BO_ values, e.g., BO_OPER
|
||||||
{
|
{
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
called_vim_beep = TRUE;
|
called_vim_beep = TRUE;
|
||||||
@ -1068,8 +1067,8 @@ vim_beep(
|
|||||||
static int did_init = FALSE;
|
static int did_init = FALSE;
|
||||||
static elapsed_T start_tv;
|
static elapsed_T start_tv;
|
||||||
|
|
||||||
/* Only beep once per half a second, otherwise a sequence of beeps
|
// Only beep once per half a second, otherwise a sequence of beeps
|
||||||
* would freeze Vim. */
|
// would freeze Vim.
|
||||||
if (!did_init || ELAPSED_FUNC(start_tv) > 500)
|
if (!did_init || ELAPSED_FUNC(start_tv) > 500)
|
||||||
{
|
{
|
||||||
did_init = TRUE;
|
did_init = TRUE;
|
||||||
@ -1077,15 +1076,15 @@ vim_beep(
|
|||||||
#endif
|
#endif
|
||||||
if (p_vb
|
if (p_vb
|
||||||
#ifdef FEAT_GUI
|
#ifdef FEAT_GUI
|
||||||
/* While the GUI is starting up the termcap is set for
|
// While the GUI is starting up the termcap is set for
|
||||||
* the GUI but the output still goes to a terminal. */
|
// the GUI but the output still goes to a terminal.
|
||||||
&& !(gui.in_use && gui.starting)
|
&& !(gui.in_use && gui.starting)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
out_str_cf(T_VB);
|
out_str_cf(T_VB);
|
||||||
#ifdef FEAT_VTP
|
#ifdef FEAT_VTP
|
||||||
/* No restore color information, refresh the screen. */
|
// No restore color information, refresh the screen.
|
||||||
if (has_vtp_working() != 0
|
if (has_vtp_working() != 0
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
# ifdef FEAT_TERMGUICOLORS
|
||||||
&& (p_tgc || (!p_tgc && t_colors >= 256))
|
&& (p_tgc || (!p_tgc && t_colors >= 256))
|
||||||
@ -1105,9 +1104,9 @@ vim_beep(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When 'debug' contains "beep" produce a message. If we are sourcing
|
// When 'debug' contains "beep" produce a message. If we are sourcing
|
||||||
* a script or executing a function give the user a hint where the beep
|
// a script or executing a function give the user a hint where the beep
|
||||||
* comes from. */
|
// comes from.
|
||||||
if (vim_strchr(p_debug, 'e') != NULL)
|
if (vim_strchr(p_debug, 'e') != NULL)
|
||||||
{
|
{
|
||||||
msg_source(HL_ATTR(HLF_W));
|
msg_source(HL_ATTR(HLF_W));
|
||||||
@ -1132,7 +1131,7 @@ init_homedir(void)
|
|||||||
{
|
{
|
||||||
char_u *var;
|
char_u *var;
|
||||||
|
|
||||||
/* In case we are called a second time (when 'encoding' changes). */
|
// In case we are called a second time (when 'encoding' changes).
|
||||||
VIM_CLEAR(homedir);
|
VIM_CLEAR(homedir);
|
||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
@ -1192,7 +1191,7 @@ init_homedir(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (var != NULL && *var == NUL) /* empty is same as not set */
|
if (var != NULL && *var == NUL) // empty is same as not set
|
||||||
var = NULL;
|
var = NULL;
|
||||||
|
|
||||||
if (enc_utf8 && var != NULL)
|
if (enc_utf8 && var != NULL)
|
||||||
@ -1200,8 +1199,8 @@ init_homedir(void)
|
|||||||
int len;
|
int len;
|
||||||
char_u *pp = NULL;
|
char_u *pp = NULL;
|
||||||
|
|
||||||
/* Convert from active codepage to UTF-8. Other conversions are
|
// Convert from active codepage to UTF-8. Other conversions are
|
||||||
* not done, because they would fail for non-ASCII characters. */
|
// not done, because they would fail for non-ASCII characters.
|
||||||
acp_to_enc(var, (int)STRLEN(var), &pp, &len);
|
acp_to_enc(var, (int)STRLEN(var), &pp, &len);
|
||||||
if (pp != NULL)
|
if (pp != NULL)
|
||||||
{
|
{
|
||||||
@ -1286,40 +1285,40 @@ expand_env_save_opt(char_u *src, int one)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
expand_env(
|
expand_env(
|
||||||
char_u *src, /* input string e.g. "$HOME/vim.hlp" */
|
char_u *src, // input string e.g. "$HOME/vim.hlp"
|
||||||
char_u *dst, /* where to put the result */
|
char_u *dst, // where to put the result
|
||||||
int dstlen) /* maximum length of the result */
|
int dstlen) // maximum length of the result
|
||||||
{
|
{
|
||||||
expand_env_esc(src, dst, dstlen, FALSE, FALSE, NULL);
|
expand_env_esc(src, dst, dstlen, FALSE, FALSE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
expand_env_esc(
|
expand_env_esc(
|
||||||
char_u *srcp, /* input string e.g. "$HOME/vim.hlp" */
|
char_u *srcp, // input string e.g. "$HOME/vim.hlp"
|
||||||
char_u *dst, /* where to put the result */
|
char_u *dst, // where to put the result
|
||||||
int dstlen, /* maximum length of the result */
|
int dstlen, // maximum length of the result
|
||||||
int esc, /* escape spaces in expanded variables */
|
int esc, // escape spaces in expanded variables
|
||||||
int one, /* "srcp" is one file name */
|
int one, // "srcp" is one file name
|
||||||
char_u *startstr) /* start again after this (can be NULL) */
|
char_u *startstr) // start again after this (can be NULL)
|
||||||
{
|
{
|
||||||
char_u *src;
|
char_u *src;
|
||||||
char_u *tail;
|
char_u *tail;
|
||||||
int c;
|
int c;
|
||||||
char_u *var;
|
char_u *var;
|
||||||
int copy_char;
|
int copy_char;
|
||||||
int mustfree; /* var was allocated, need to free it later */
|
int mustfree; // var was allocated, need to free it later
|
||||||
int at_start = TRUE; /* at start of a name */
|
int at_start = TRUE; // at start of a name
|
||||||
int startstr_len = 0;
|
int startstr_len = 0;
|
||||||
|
|
||||||
if (startstr != NULL)
|
if (startstr != NULL)
|
||||||
startstr_len = (int)STRLEN(startstr);
|
startstr_len = (int)STRLEN(startstr);
|
||||||
|
|
||||||
src = skipwhite(srcp);
|
src = skipwhite(srcp);
|
||||||
--dstlen; /* leave one char space for "\," */
|
--dstlen; // leave one char space for "\,"
|
||||||
while (*src && dstlen > 0)
|
while (*src && dstlen > 0)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
/* Skip over `=expr`. */
|
// Skip over `=expr`.
|
||||||
if (src[0] == '`' && src[1] == '=')
|
if (src[0] == '`' && src[1] == '=')
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -1355,17 +1354,17 @@ expand_env_esc(
|
|||||||
* The variable name is copied into dst temporarily, because it may
|
* The variable name is copied into dst temporarily, because it may
|
||||||
* be a string in read-only memory and a NUL needs to be appended.
|
* be a string in read-only memory and a NUL needs to be appended.
|
||||||
*/
|
*/
|
||||||
if (*src != '~') /* environment var */
|
if (*src != '~') // environment var
|
||||||
{
|
{
|
||||||
tail = src + 1;
|
tail = src + 1;
|
||||||
var = dst;
|
var = dst;
|
||||||
c = dstlen - 1;
|
c = dstlen - 1;
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
/* Unix has ${var-name} type environment vars */
|
// Unix has ${var-name} type environment vars
|
||||||
if (*tail == '{' && !vim_isIDc('{'))
|
if (*tail == '{' && !vim_isIDc('{'))
|
||||||
{
|
{
|
||||||
tail++; /* ignore '{' */
|
tail++; // ignore '{'
|
||||||
while (c-- > 0 && *tail && *tail != '}')
|
while (c-- > 0 && *tail && *tail != '}')
|
||||||
*var++ = *tail++;
|
*var++ = *tail++;
|
||||||
}
|
}
|
||||||
@ -1402,7 +1401,7 @@ expand_env_esc(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* home directory */
|
// home directory
|
||||||
else if ( src[1] == NUL
|
else if ( src[1] == NUL
|
||||||
|| vim_ispathsep(src[1])
|
|| vim_ispathsep(src[1])
|
||||||
|| vim_strchr((char_u *)" ,\t\n", src[1]) != NULL)
|
|| vim_strchr((char_u *)" ,\t\n", src[1]) != NULL)
|
||||||
@ -1410,7 +1409,7 @@ expand_env_esc(
|
|||||||
var = homedir;
|
var = homedir;
|
||||||
tail = src + 1;
|
tail = src + 1;
|
||||||
}
|
}
|
||||||
else /* user directory */
|
else // user directory
|
||||||
{
|
{
|
||||||
#if defined(UNIX) || (defined(VMS) && defined(USER_HOME))
|
#if defined(UNIX) || (defined(VMS) && defined(USER_HOME))
|
||||||
/*
|
/*
|
||||||
@ -1434,8 +1433,8 @@ expand_env_esc(
|
|||||||
*/
|
*/
|
||||||
# if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
|
# if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
|
||||||
{
|
{
|
||||||
/* Note: memory allocated by getpwnam() is never freed.
|
// Note: memory allocated by getpwnam() is never freed.
|
||||||
* Calling endpwent() apparently doesn't help. */
|
// Calling endpwent() apparently doesn't help.
|
||||||
struct passwd *pw = (*dst == NUL)
|
struct passwd *pw = (*dst == NUL)
|
||||||
? NULL : getpwnam((char *)dst + 1);
|
? NULL : getpwnam((char *)dst + 1);
|
||||||
|
|
||||||
@ -1453,7 +1452,7 @@ expand_env_esc(
|
|||||||
mustfree = TRUE;
|
mustfree = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
# else /* !UNIX, thus VMS */
|
# else // !UNIX, thus VMS
|
||||||
/*
|
/*
|
||||||
* USER_HOME is a comma-separated list of
|
* USER_HOME is a comma-separated list of
|
||||||
* directories to search for the user account in.
|
* directories to search for the user account in.
|
||||||
@ -1483,17 +1482,17 @@ expand_env_esc(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif /* UNIX */
|
# endif // UNIX
|
||||||
#else
|
#else
|
||||||
/* cannot expand user's home directory, so don't try */
|
// cannot expand user's home directory, so don't try
|
||||||
var = NULL;
|
var = NULL;
|
||||||
tail = (char_u *)""; /* for gcc */
|
tail = (char_u *)""; // for gcc
|
||||||
#endif /* UNIX || VMS */
|
#endif // UNIX || VMS
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
/* If 'shellslash' is set change backslashes to forward slashes.
|
// If 'shellslash' is set change backslashes to forward slashes.
|
||||||
* Can't use slash_adjust(), p_ssl may be set temporarily. */
|
// Can't use slash_adjust(), p_ssl may be set temporarily.
|
||||||
if (p_ssl && var != NULL && vim_strchr(var, '\\') != NULL)
|
if (p_ssl && var != NULL && vim_strchr(var, '\\') != NULL)
|
||||||
{
|
{
|
||||||
char_u *p = vim_strsave(var);
|
char_u *p = vim_strsave(var);
|
||||||
@ -1509,8 +1508,8 @@ expand_env_esc(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If "var" contains white space, escape it with a backslash.
|
// If "var" contains white space, escape it with a backslash.
|
||||||
* Required for ":e ~/tt" when $HOME includes a space. */
|
// Required for ":e ~/tt" when $HOME includes a space.
|
||||||
if (esc && var != NULL && vim_strpbrk(var, (char_u *)" \t") != NULL)
|
if (esc && var != NULL && vim_strpbrk(var, (char_u *)" \t") != NULL)
|
||||||
{
|
{
|
||||||
char_u *p = vim_strsave_escaped(var, (char_u *)" \t");
|
char_u *p = vim_strsave_escaped(var, (char_u *)" \t");
|
||||||
@ -1530,8 +1529,8 @@ expand_env_esc(
|
|||||||
STRCPY(dst, var);
|
STRCPY(dst, var);
|
||||||
dstlen -= (int)STRLEN(var);
|
dstlen -= (int)STRLEN(var);
|
||||||
c = (int)STRLEN(var);
|
c = (int)STRLEN(var);
|
||||||
/* if var[] ends in a path separator and tail[] starts
|
// if var[] ends in a path separator and tail[] starts
|
||||||
* with it, skip a character */
|
// with it, skip a character
|
||||||
if (*var != NUL && after_pathsep(dst, dst + c)
|
if (*var != NUL && after_pathsep(dst, dst + c)
|
||||||
#if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA)
|
#if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA)
|
||||||
&& dst[-1] != ':'
|
&& dst[-1] != ':'
|
||||||
@ -1546,7 +1545,7 @@ expand_env_esc(
|
|||||||
vim_free(var);
|
vim_free(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_char) /* copy at least one char */
|
if (copy_char) // copy at least one char
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Recognize the start of a new name, for '~'.
|
* Recognize the start of a new name, for '~'.
|
||||||
@ -1729,16 +1728,16 @@ vim_getenv(char_u *name, int *mustfree)
|
|||||||
#endif
|
#endif
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
/* remove the file name */
|
// remove the file name
|
||||||
pend = gettail(p);
|
pend = gettail(p);
|
||||||
|
|
||||||
/* remove "doc/" from 'helpfile', if present */
|
// remove "doc/" from 'helpfile', if present
|
||||||
if (p == p_hf)
|
if (p == p_hf)
|
||||||
pend = remove_tail(p, pend, (char_u *)"doc");
|
pend = remove_tail(p, pend, (char_u *)"doc");
|
||||||
|
|
||||||
#ifdef USE_EXE_NAME
|
#ifdef USE_EXE_NAME
|
||||||
# ifdef MACOS_X
|
# ifdef MACOS_X
|
||||||
/* remove "MacOS" from exe_name and add "Resources/vim" */
|
// remove "MacOS" from exe_name and add "Resources/vim"
|
||||||
if (p == exe_name)
|
if (p == exe_name)
|
||||||
{
|
{
|
||||||
char_u *pend1;
|
char_u *pend1;
|
||||||
@ -1758,26 +1757,26 @@ vim_getenv(char_u *name, int *mustfree)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
/* remove "src/" from exe_name, if present */
|
// remove "src/" from exe_name, if present
|
||||||
if (p == exe_name)
|
if (p == exe_name)
|
||||||
pend = remove_tail(p, pend, (char_u *)"src");
|
pend = remove_tail(p, pend, (char_u *)"src");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* for $VIM, remove "runtime/" or "vim54/", if present */
|
// for $VIM, remove "runtime/" or "vim54/", if present
|
||||||
if (!vimruntime)
|
if (!vimruntime)
|
||||||
{
|
{
|
||||||
pend = remove_tail(p, pend, (char_u *)RUNTIME_DIRNAME);
|
pend = remove_tail(p, pend, (char_u *)RUNTIME_DIRNAME);
|
||||||
pend = remove_tail(p, pend, (char_u *)VIM_VERSION_NODOT);
|
pend = remove_tail(p, pend, (char_u *)VIM_VERSION_NODOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove trailing path separator */
|
// remove trailing path separator
|
||||||
if (pend > p && after_pathsep(p, pend))
|
if (pend > p && after_pathsep(p, pend))
|
||||||
--pend;
|
--pend;
|
||||||
|
|
||||||
#ifdef MACOS_X
|
#ifdef MACOS_X
|
||||||
if (p == exe_name || p == p_hf)
|
if (p == exe_name || p == p_hf)
|
||||||
#endif
|
#endif
|
||||||
/* check that the result is a directory name */
|
// check that the result is a directory name
|
||||||
p = vim_strnsave(p, (int)(pend - p));
|
p = vim_strnsave(p, (int)(pend - p));
|
||||||
|
|
||||||
if (p != NULL && !mch_isdir(p))
|
if (p != NULL && !mch_isdir(p))
|
||||||
@ -1785,7 +1784,7 @@ vim_getenv(char_u *name, int *mustfree)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef USE_EXE_NAME
|
#ifdef USE_EXE_NAME
|
||||||
/* may add "/vim54" or "/runtime" if it exists */
|
// may add "/vim54" or "/runtime" if it exists
|
||||||
if (vimruntime && (pend = vim_version_dir(p)) != NULL)
|
if (vimruntime && (pend = vim_version_dir(p)) != NULL)
|
||||||
{
|
{
|
||||||
vim_free(p);
|
vim_free(p);
|
||||||
@ -1798,11 +1797,11 @@ vim_getenv(char_u *name, int *mustfree)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PATHDEF
|
#ifdef HAVE_PATHDEF
|
||||||
/* When there is a pathdef.c file we can use default_vim_dir and
|
// When there is a pathdef.c file we can use default_vim_dir and
|
||||||
* default_vimruntime_dir */
|
// default_vimruntime_dir
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
/* Only use default_vimruntime_dir when it is not empty */
|
// Only use default_vimruntime_dir when it is not empty
|
||||||
if (vimruntime && *default_vimruntime_dir != NUL)
|
if (vimruntime && *default_vimruntime_dir != NUL)
|
||||||
{
|
{
|
||||||
p = default_vimruntime_dir;
|
p = default_vimruntime_dir;
|
||||||
@ -1909,7 +1908,7 @@ get_env_name(
|
|||||||
return NULL;
|
return NULL;
|
||||||
# else
|
# else
|
||||||
# ifndef __WIN32__
|
# ifndef __WIN32__
|
||||||
/* Borland C++ 5.2 has this in a header file. */
|
// Borland C++ 5.2 has this in a header file.
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
# endif
|
# endif
|
||||||
# define ENVNAMELEN 100
|
# define ENVNAMELEN 100
|
||||||
@ -2053,9 +2052,9 @@ match_user(char_u *name)
|
|||||||
for (i = 0; i < ga_users.ga_len; i++)
|
for (i = 0; i < ga_users.ga_len; i++)
|
||||||
{
|
{
|
||||||
if (STRCMP(((char_u **)ga_users.ga_data)[i], name) == 0)
|
if (STRCMP(((char_u **)ga_users.ga_data)[i], name) == 0)
|
||||||
return 2; /* full match */
|
return 2; // full match
|
||||||
if (STRNCMP(((char_u **)ga_users.ga_data)[i], name, n) == 0)
|
if (STRNCMP(((char_u **)ga_users.ga_data)[i], name, n) == 0)
|
||||||
result = 1; /* partial match */
|
result = 1; // partial match
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2083,9 +2082,9 @@ concat_str(char_u *str1, char_u *str2)
|
|||||||
prepare_to_exit(void)
|
prepare_to_exit(void)
|
||||||
{
|
{
|
||||||
#if defined(SIGHUP) && defined(SIG_IGN)
|
#if defined(SIGHUP) && defined(SIG_IGN)
|
||||||
/* Ignore SIGHUP, because a dropped connection causes a read error, which
|
// Ignore SIGHUP, because a dropped connection causes a read error, which
|
||||||
* makes Vim exit and then handling SIGHUP causes various reentrance
|
// makes Vim exit and then handling SIGHUP causes various reentrance
|
||||||
* problems. */
|
// problems.
|
||||||
signal(SIGHUP, SIG_IGN);
|
signal(SIGHUP, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2093,7 +2092,7 @@ prepare_to_exit(void)
|
|||||||
if (gui.in_use)
|
if (gui.in_use)
|
||||||
{
|
{
|
||||||
gui.dying = TRUE;
|
gui.dying = TRUE;
|
||||||
out_trash(); /* trash any pending output */
|
out_trash(); // trash any pending output
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@ -2123,29 +2122,29 @@ preserve_exit(void)
|
|||||||
|
|
||||||
prepare_to_exit();
|
prepare_to_exit();
|
||||||
|
|
||||||
/* Setting this will prevent free() calls. That avoids calling free()
|
// Setting this will prevent free() calls. That avoids calling free()
|
||||||
* recursively when free() was invoked with a bad pointer. */
|
// recursively when free() was invoked with a bad pointer.
|
||||||
really_exiting = TRUE;
|
really_exiting = TRUE;
|
||||||
|
|
||||||
out_str(IObuff);
|
out_str(IObuff);
|
||||||
screen_start(); /* don't know where cursor is now */
|
screen_start(); // don't know where cursor is now
|
||||||
out_flush();
|
out_flush();
|
||||||
|
|
||||||
ml_close_notmod(); /* close all not-modified buffers */
|
ml_close_notmod(); // close all not-modified buffers
|
||||||
|
|
||||||
FOR_ALL_BUFFERS(buf)
|
FOR_ALL_BUFFERS(buf)
|
||||||
{
|
{
|
||||||
if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL)
|
if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL)
|
||||||
{
|
{
|
||||||
OUT_STR("Vim: preserving files...\n");
|
OUT_STR("Vim: preserving files...\n");
|
||||||
screen_start(); /* don't know where cursor is now */
|
screen_start(); // don't know where cursor is now
|
||||||
out_flush();
|
out_flush();
|
||||||
ml_sync_all(FALSE, FALSE); /* preserve all swap files */
|
ml_sync_all(FALSE, FALSE); // preserve all swap files
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ml_close_all(FALSE); /* close all memfiles, without deleting */
|
ml_close_all(FALSE); // close all memfiles, without deleting
|
||||||
|
|
||||||
OUT_STR("Vim: Finished.\n");
|
OUT_STR("Vim: Finished.\n");
|
||||||
|
|
||||||
@ -2208,8 +2207,8 @@ fast_breakcheck(void)
|
|||||||
char_u *
|
char_u *
|
||||||
get_cmd_output(
|
get_cmd_output(
|
||||||
char_u *cmd,
|
char_u *cmd,
|
||||||
char_u *infile, /* optional input file name */
|
char_u *infile, // optional input file name
|
||||||
int flags, /* can be SHELL_SILENT */
|
int flags, // can be SHELL_SILENT
|
||||||
int *ret_len)
|
int *ret_len)
|
||||||
{
|
{
|
||||||
char_u *tempname;
|
char_u *tempname;
|
||||||
@ -2222,14 +2221,14 @@ get_cmd_output(
|
|||||||
if (check_restricted() || check_secure())
|
if (check_restricted() || check_secure())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* get a name for the temp file */
|
// get a name for the temp file
|
||||||
if ((tempname = vim_tempname('o', FALSE)) == NULL)
|
if ((tempname = vim_tempname('o', FALSE)) == NULL)
|
||||||
{
|
{
|
||||||
emsg(_(e_notmp));
|
emsg(_(e_notmp));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the redirection stuff */
|
// Add the redirection stuff
|
||||||
command = make_filter_cmd(cmd, infile, tempname);
|
command = make_filter_cmd(cmd, infile, tempname);
|
||||||
if (command == NULL)
|
if (command == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
@ -2248,7 +2247,7 @@ get_cmd_output(
|
|||||||
* read the names from the file into memory
|
* read the names from the file into memory
|
||||||
*/
|
*/
|
||||||
# ifdef VMS
|
# ifdef VMS
|
||||||
/* created temporary file is not always readable as binary */
|
// created temporary file is not always readable as binary
|
||||||
fd = mch_fopen((char *)tempname, "r");
|
fd = mch_fopen((char *)tempname, "r");
|
||||||
# else
|
# else
|
||||||
fd = mch_fopen((char *)tempname, READBIN);
|
fd = mch_fopen((char *)tempname, READBIN);
|
||||||
@ -2261,7 +2260,7 @@ get_cmd_output(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fseek(fd, 0L, SEEK_END);
|
fseek(fd, 0L, SEEK_END);
|
||||||
len = ftell(fd); /* get size of temp file */
|
len = ftell(fd); // get size of temp file
|
||||||
fseek(fd, 0L, SEEK_SET);
|
fseek(fd, 0L, SEEK_SET);
|
||||||
|
|
||||||
buffer = alloc(len + 1);
|
buffer = alloc(len + 1);
|
||||||
@ -2272,7 +2271,7 @@ get_cmd_output(
|
|||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
len = i; /* VMS doesn't give us what we asked for... */
|
len = i; // VMS doesn't give us what we asked for...
|
||||||
#endif
|
#endif
|
||||||
if (i != len)
|
if (i != len)
|
||||||
{
|
{
|
||||||
@ -2281,12 +2280,12 @@ get_cmd_output(
|
|||||||
}
|
}
|
||||||
else if (ret_len == NULL)
|
else if (ret_len == NULL)
|
||||||
{
|
{
|
||||||
/* Change NUL into SOH, otherwise the string is truncated. */
|
// Change NUL into SOH, otherwise the string is truncated.
|
||||||
for (i = 0; i < len; ++i)
|
for (i = 0; i < len; ++i)
|
||||||
if (buffer[i] == NUL)
|
if (buffer[i] == NUL)
|
||||||
buffer[i] = 1;
|
buffer[i] = 1;
|
||||||
|
|
||||||
buffer[len] = NUL; /* make sure the buffer is terminated */
|
buffer[len] = NUL; // make sure the buffer is terminated
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*ret_len = len;
|
*ret_len = len;
|
||||||
@ -2377,7 +2376,7 @@ get_cmd_output_as_rettv(
|
|||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
goto errret; /* type error; errmsg already given */
|
goto errret; // type error; errmsg already given
|
||||||
}
|
}
|
||||||
len = STRLEN(p);
|
len = STRLEN(p);
|
||||||
if (len > 0 && fwrite(p, len, 1, fd) != 1)
|
if (len > 0 && fwrite(p, len, 1, fd) != 1)
|
||||||
@ -2392,8 +2391,8 @@ get_cmd_output_as_rettv(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Omit SHELL_COOKED when invoked with ":silent". Avoids that the shell
|
// Omit SHELL_COOKED when invoked with ":silent". Avoids that the shell
|
||||||
* echoes typeahead, that messes up the display. */
|
// echoes typeahead, that messes up the display.
|
||||||
if (!msg_silent)
|
if (!msg_silent)
|
||||||
flags += SHELL_COOKED;
|
flags += SHELL_COOKED;
|
||||||
|
|
||||||
@ -2448,7 +2447,7 @@ get_cmd_output_as_rettv(
|
|||||||
{
|
{
|
||||||
res = get_cmd_output(tv_get_string(&argvars[0]), infile, flags, NULL);
|
res = get_cmd_output(tv_get_string(&argvars[0]), infile, flags, NULL);
|
||||||
#ifdef USE_CRNL
|
#ifdef USE_CRNL
|
||||||
/* translate <CR><NL> into <NL> */
|
// translate <CR><NL> into <NL>
|
||||||
if (res != NULL)
|
if (res != NULL)
|
||||||
{
|
{
|
||||||
char_u *s, *d;
|
char_u *s, *d;
|
||||||
@ -2531,14 +2530,14 @@ get_isolated_shell_name(void)
|
|||||||
p = skiptowhite(p_sh);
|
p = skiptowhite(p_sh);
|
||||||
if (*p == NUL)
|
if (*p == NUL)
|
||||||
{
|
{
|
||||||
/* No white space, use the tail. */
|
// No white space, use the tail.
|
||||||
p = vim_strsave(gettail(p_sh));
|
p = vim_strsave(gettail(p_sh));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char_u *p1, *p2;
|
char_u *p1, *p2;
|
||||||
|
|
||||||
/* Find the last path separator before the space. */
|
// Find the last path separator before the space.
|
||||||
p1 = p_sh;
|
p1 = p_sh;
|
||||||
for (p2 = p_sh; p2 < p; MB_PTR_ADV(p2))
|
for (p2 = p_sh; p2 < p; MB_PTR_ADV(p2))
|
||||||
if (vim_ispathsep(*p2))
|
if (vim_ispathsep(*p2))
|
||||||
@ -2593,10 +2592,10 @@ add_time(char_u *buf, size_t buflen, time_t tt)
|
|||||||
{
|
{
|
||||||
curtime = vim_localtime(&tt, &tmval);
|
curtime = vim_localtime(&tt, &tmval);
|
||||||
if (vim_time() - tt < (60L * 60L * 12L))
|
if (vim_time() - tt < (60L * 60L * 12L))
|
||||||
/* within 12 hours */
|
// within 12 hours
|
||||||
(void)strftime((char *)buf, buflen, "%H:%M:%S", curtime);
|
(void)strftime((char *)buf, buflen, "%H:%M:%S", curtime);
|
||||||
else
|
else
|
||||||
/* longer ago */
|
// longer ago
|
||||||
(void)strftime((char *)buf, buflen, "%Y/%m/%d %H:%M:%S", curtime);
|
(void)strftime((char *)buf, buflen, "%Y/%m/%d %H:%M:%S", curtime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
545
src/misc2.c
545
src/misc2.c
File diff suppressed because it is too large
Load Diff
328
src/move.c
328
src/move.c
@ -25,11 +25,11 @@ static void curs_rows(win_T *wp);
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
linenr_T lnum; /* line number */
|
linenr_T lnum; // line number
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
int fill; /* filler lines */
|
int fill; // filler lines
|
||||||
#endif
|
#endif
|
||||||
int height; /* height of added line */
|
int height; // height of added line
|
||||||
} lineoff_T;
|
} lineoff_T;
|
||||||
|
|
||||||
static void topline_back(lineoff_T *lp);
|
static void topline_back(lineoff_T *lp);
|
||||||
@ -108,7 +108,7 @@ comp_botline(win_T *wp)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wp->w_botline is the line that is just below the window */
|
// wp->w_botline is the line that is just below the window
|
||||||
wp->w_botline = lnum;
|
wp->w_botline = lnum;
|
||||||
wp->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
|
wp->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
|
||||||
|
|
||||||
@ -192,8 +192,8 @@ update_topline(void)
|
|||||||
long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
|
long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
|
||||||
int save_so = *so_ptr;
|
int save_so = *so_ptr;
|
||||||
|
|
||||||
/* If there is no valid screen and when the window height is zero just use
|
// If there is no valid screen and when the window height is zero just use
|
||||||
* the cursor line. */
|
// the cursor line.
|
||||||
if (!screen_valid(TRUE) || curwin->w_height == 0)
|
if (!screen_valid(TRUE) || curwin->w_height == 0)
|
||||||
{
|
{
|
||||||
curwin->w_topline = curwin->w_cursor.lnum;
|
curwin->w_topline = curwin->w_cursor.lnum;
|
||||||
@ -207,7 +207,7 @@ update_topline(void)
|
|||||||
if (curwin->w_valid & VALID_TOPLINE)
|
if (curwin->w_valid & VALID_TOPLINE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* When dragging with the mouse, don't scroll that quickly */
|
// When dragging with the mouse, don't scroll that quickly
|
||||||
if (mouse_dragging > 0)
|
if (mouse_dragging > 0)
|
||||||
*so_ptr = mouse_dragging - 1;
|
*so_ptr = mouse_dragging - 1;
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ update_topline(void)
|
|||||||
/*
|
/*
|
||||||
* If the buffer is empty, always set topline to 1.
|
* If the buffer is empty, always set topline to 1.
|
||||||
*/
|
*/
|
||||||
if (BUFEMPTY()) /* special case - file is empty */
|
if (BUFEMPTY()) // special case - file is empty
|
||||||
{
|
{
|
||||||
if (curwin->w_topline != 1)
|
if (curwin->w_topline != 1)
|
||||||
redraw_later(NOT_VALID);
|
redraw_later(NOT_VALID);
|
||||||
@ -237,16 +237,16 @@ update_topline(void)
|
|||||||
{
|
{
|
||||||
if (curwin->w_topline > 1)
|
if (curwin->w_topline > 1)
|
||||||
{
|
{
|
||||||
/* If the cursor is above topline, scrolling is always needed.
|
// If the cursor is above topline, scrolling is always needed.
|
||||||
* If the cursor is far below topline and there is no folding,
|
// If the cursor is far below topline and there is no folding,
|
||||||
* scrolling down is never needed. */
|
// scrolling down is never needed.
|
||||||
if (curwin->w_cursor.lnum < curwin->w_topline)
|
if (curwin->w_cursor.lnum < curwin->w_topline)
|
||||||
check_topline = TRUE;
|
check_topline = TRUE;
|
||||||
else if (check_top_offset())
|
else if (check_top_offset())
|
||||||
check_topline = TRUE;
|
check_topline = TRUE;
|
||||||
}
|
}
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
/* Check if there are more filler lines than allowed. */
|
// Check if there are more filler lines than allowed.
|
||||||
if (!check_topline && curwin->w_topfill > diff_check_fill(curwin,
|
if (!check_topline && curwin->w_topfill > diff_check_fill(curwin,
|
||||||
curwin->w_topline))
|
curwin->w_topline))
|
||||||
check_topline = TRUE;
|
check_topline = TRUE;
|
||||||
@ -261,15 +261,15 @@ update_topline(void)
|
|||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (hasAnyFolding(curwin))
|
if (hasAnyFolding(curwin))
|
||||||
{
|
{
|
||||||
/* Count the number of logical lines between the cursor and
|
// Count the number of logical lines between the cursor and
|
||||||
* topline + scrolloff (approximation of how much will be
|
// topline + scrolloff (approximation of how much will be
|
||||||
* scrolled). */
|
// scrolled).
|
||||||
n = 0;
|
n = 0;
|
||||||
for (lnum = curwin->w_cursor.lnum;
|
for (lnum = curwin->w_cursor.lnum;
|
||||||
lnum < curwin->w_topline + *so_ptr; ++lnum)
|
lnum < curwin->w_topline + *so_ptr; ++lnum)
|
||||||
{
|
{
|
||||||
++n;
|
++n;
|
||||||
/* stop at end of file or when we know we are far off */
|
// stop at end of file or when we know we are far off
|
||||||
if (lnum >= curbuf->b_ml.ml_line_count || n >= halfheight)
|
if (lnum >= curbuf->b_ml.ml_line_count || n >= halfheight)
|
||||||
break;
|
break;
|
||||||
(void)hasFolding(lnum, NULL, &lnum);
|
(void)hasFolding(lnum, NULL, &lnum);
|
||||||
@ -279,9 +279,9 @@ update_topline(void)
|
|||||||
#endif
|
#endif
|
||||||
n = curwin->w_topline + *so_ptr - curwin->w_cursor.lnum;
|
n = curwin->w_topline + *so_ptr - curwin->w_cursor.lnum;
|
||||||
|
|
||||||
/* If we weren't very close to begin with, we scroll to put the
|
// If we weren't very close to begin with, we scroll to put the
|
||||||
* cursor in the middle of the window. Otherwise put the cursor
|
// cursor in the middle of the window. Otherwise put the cursor
|
||||||
* near the top of the window. */
|
// near the top of the window.
|
||||||
if (n >= halfheight)
|
if (n >= halfheight)
|
||||||
scroll_cursor_halfway(FALSE);
|
scroll_cursor_halfway(FALSE);
|
||||||
else
|
else
|
||||||
@ -294,7 +294,7 @@ update_topline(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
/* Make sure topline is the first line of a fold. */
|
// Make sure topline is the first line of a fold.
|
||||||
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
||||||
#endif
|
#endif
|
||||||
check_botline = TRUE;
|
check_botline = TRUE;
|
||||||
@ -327,13 +327,13 @@ update_topline(void)
|
|||||||
{
|
{
|
||||||
lineoff_T loff;
|
lineoff_T loff;
|
||||||
|
|
||||||
/* Cursor is (a few lines) above botline, check if there are
|
// Cursor is (a few lines) above botline, check if there are
|
||||||
* 'scrolloff' window lines below the cursor. If not, need to
|
// 'scrolloff' window lines below the cursor. If not, need to
|
||||||
* scroll. */
|
// scroll.
|
||||||
n = curwin->w_empty_rows;
|
n = curwin->w_empty_rows;
|
||||||
loff.lnum = curwin->w_cursor.lnum;
|
loff.lnum = curwin->w_cursor.lnum;
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
/* In a fold go to its last line. */
|
// In a fold go to its last line.
|
||||||
(void)hasFolding(loff.lnum, NULL, &loff.lnum);
|
(void)hasFolding(loff.lnum, NULL, &loff.lnum);
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
@ -353,11 +353,11 @@ update_topline(void)
|
|||||||
botline_forw(&loff);
|
botline_forw(&loff);
|
||||||
}
|
}
|
||||||
if (n >= *so_ptr)
|
if (n >= *so_ptr)
|
||||||
/* sufficient context, no need to scroll */
|
// sufficient context, no need to scroll
|
||||||
check_botline = FALSE;
|
check_botline = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* sufficient context, no need to scroll */
|
// sufficient context, no need to scroll
|
||||||
check_botline = FALSE;
|
check_botline = FALSE;
|
||||||
}
|
}
|
||||||
if (check_botline)
|
if (check_botline)
|
||||||
@ -365,15 +365,15 @@ update_topline(void)
|
|||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (hasAnyFolding(curwin))
|
if (hasAnyFolding(curwin))
|
||||||
{
|
{
|
||||||
/* Count the number of logical lines between the cursor and
|
// Count the number of logical lines between the cursor and
|
||||||
* botline - scrolloff (approximation of how much will be
|
// botline - scrolloff (approximation of how much will be
|
||||||
* scrolled). */
|
// scrolled).
|
||||||
line_count = 0;
|
line_count = 0;
|
||||||
for (lnum = curwin->w_cursor.lnum;
|
for (lnum = curwin->w_cursor.lnum;
|
||||||
lnum >= curwin->w_botline - *so_ptr; --lnum)
|
lnum >= curwin->w_botline - *so_ptr; --lnum)
|
||||||
{
|
{
|
||||||
++line_count;
|
++line_count;
|
||||||
/* stop at end of file or when we know we are far off */
|
// stop at end of file or when we know we are far off
|
||||||
if (lnum <= 0 || line_count > curwin->w_height + 1)
|
if (lnum <= 0 || line_count > curwin->w_height + 1)
|
||||||
break;
|
break;
|
||||||
(void)hasFolding(lnum, &lnum, NULL);
|
(void)hasFolding(lnum, &lnum, NULL);
|
||||||
@ -409,7 +409,7 @@ update_topline(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
redraw_later(VALID);
|
redraw_later(VALID);
|
||||||
/* May need to set w_skipcol when cursor in w_topline. */
|
// May need to set w_skipcol when cursor in w_topline.
|
||||||
if (curwin->w_cursor.lnum == curwin->w_topline)
|
if (curwin->w_cursor.lnum == curwin->w_topline)
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
}
|
}
|
||||||
@ -450,15 +450,15 @@ check_top_offset(void)
|
|||||||
loff.lnum = curwin->w_cursor.lnum;
|
loff.lnum = curwin->w_cursor.lnum;
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
loff.fill = 0;
|
loff.fill = 0;
|
||||||
n = curwin->w_topfill; /* always have this context */
|
n = curwin->w_topfill; // always have this context
|
||||||
#else
|
#else
|
||||||
n = 0;
|
n = 0;
|
||||||
#endif
|
#endif
|
||||||
/* Count the visible screen lines above the cursor line. */
|
// Count the visible screen lines above the cursor line.
|
||||||
while (n < so)
|
while (n < so)
|
||||||
{
|
{
|
||||||
topline_back(&loff);
|
topline_back(&loff);
|
||||||
/* Stop when included a line above the window. */
|
// Stop when included a line above the window.
|
||||||
if (loff.lnum < curwin->w_topline
|
if (loff.lnum < curwin->w_topline
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
|| (loff.lnum == curwin->w_topline && loff.fill > 0)
|
|| (loff.lnum == curwin->w_topline && loff.fill > 0)
|
||||||
@ -535,10 +535,10 @@ changed_window_setting_win(win_T *wp)
|
|||||||
set_topline(win_T *wp, linenr_T lnum)
|
set_topline(win_T *wp, linenr_T lnum)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
/* go to first of folded lines */
|
// go to first of folded lines
|
||||||
(void)hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL);
|
(void)hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL);
|
||||||
#endif
|
#endif
|
||||||
/* Approximate the value of w_botline */
|
// Approximate the value of w_botline
|
||||||
wp->w_botline += lnum - wp->w_topline;
|
wp->w_botline += lnum - wp->w_topline;
|
||||||
wp->w_topline = lnum;
|
wp->w_topline = lnum;
|
||||||
wp->w_topline_was_set = TRUE;
|
wp->w_topline_was_set = TRUE;
|
||||||
@ -546,7 +546,7 @@ set_topline(win_T *wp, linenr_T lnum)
|
|||||||
wp->w_topfill = 0;
|
wp->w_topfill = 0;
|
||||||
#endif
|
#endif
|
||||||
wp->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_TOPLINE);
|
wp->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_TOPLINE);
|
||||||
/* Don't set VALID_TOPLINE here, 'scrolloff' needs to be checked. */
|
// Don't set VALID_TOPLINE here, 'scrolloff' needs to be checked.
|
||||||
redraw_later(VALID);
|
redraw_later(VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +675,7 @@ curs_rows(win_T *wp)
|
|||||||
long fold_count;
|
long fold_count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check if wp->w_lines[].wl_size is invalid */
|
// Check if wp->w_lines[].wl_size is invalid
|
||||||
all_invalid = (!redrawing()
|
all_invalid = (!redrawing()
|
||||||
|| wp->w_lines_valid == 0
|
|| wp->w_lines_valid == 0
|
||||||
|| wp->w_lines[0].wl_lnum > wp->w_topline);
|
|| wp->w_lines[0].wl_lnum > wp->w_topline);
|
||||||
@ -687,12 +687,12 @@ curs_rows(win_T *wp)
|
|||||||
if (!all_invalid && i < wp->w_lines_valid)
|
if (!all_invalid && i < wp->w_lines_valid)
|
||||||
{
|
{
|
||||||
if (wp->w_lines[i].wl_lnum < lnum || !wp->w_lines[i].wl_valid)
|
if (wp->w_lines[i].wl_lnum < lnum || !wp->w_lines[i].wl_valid)
|
||||||
continue; /* skip changed or deleted lines */
|
continue; // skip changed or deleted lines
|
||||||
if (wp->w_lines[i].wl_lnum == lnum)
|
if (wp->w_lines[i].wl_lnum == lnum)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
/* Check for newly inserted lines below this row, in which
|
// Check for newly inserted lines below this row, in which
|
||||||
* case we need to check for folded lines. */
|
// case we need to check for folded lines.
|
||||||
if (!wp->w_buffer->b_mod_set
|
if (!wp->w_buffer->b_mod_set
|
||||||
|| wp->w_lines[i].wl_lastlnum < wp->w_cursor.lnum
|
|| wp->w_lines[i].wl_lastlnum < wp->w_cursor.lnum
|
||||||
|| wp->w_buffer->b_mod_top
|
|| wp->w_buffer->b_mod_top
|
||||||
@ -701,7 +701,7 @@ curs_rows(win_T *wp)
|
|||||||
valid = TRUE;
|
valid = TRUE;
|
||||||
}
|
}
|
||||||
else if (wp->w_lines[i].wl_lnum > lnum)
|
else if (wp->w_lines[i].wl_lnum > lnum)
|
||||||
--i; /* hold at inserted lines */
|
--i; // hold at inserted lines
|
||||||
}
|
}
|
||||||
if (valid
|
if (valid
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
@ -711,7 +711,7 @@ curs_rows(win_T *wp)
|
|||||||
{
|
{
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
lnum = wp->w_lines[i].wl_lastlnum + 1;
|
lnum = wp->w_lines[i].wl_lastlnum + 1;
|
||||||
/* Cursor inside folded lines, don't count this row */
|
// Cursor inside folded lines, don't count this row
|
||||||
if (lnum > wp->w_cursor.lnum)
|
if (lnum > wp->w_cursor.lnum)
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
@ -765,7 +765,7 @@ curs_rows(win_T *wp)
|
|||||||
}
|
}
|
||||||
else if (i > wp->w_lines_valid)
|
else if (i > wp->w_lines_valid)
|
||||||
{
|
{
|
||||||
/* a line that is too long to fit on the last screen line */
|
// a line that is too long to fit on the last screen line
|
||||||
wp->w_cline_height = 0;
|
wp->w_cline_height = 0;
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum,
|
wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum,
|
||||||
@ -854,11 +854,11 @@ validate_cursor_col(void)
|
|||||||
col += off;
|
col += off;
|
||||||
width = curwin->w_width - off + curwin_col_off2();
|
width = curwin->w_width - off + curwin_col_off2();
|
||||||
|
|
||||||
/* long line wrapping, adjust curwin->w_wrow */
|
// long line wrapping, adjust curwin->w_wrow
|
||||||
if (curwin->w_p_wrap
|
if (curwin->w_p_wrap
|
||||||
&& col >= (colnr_T)curwin->w_width
|
&& col >= (colnr_T)curwin->w_width
|
||||||
&& width > 0)
|
&& width > 0)
|
||||||
/* use same formula as what is used in curs_columns() */
|
// use same formula as what is used in curs_columns()
|
||||||
col -= ((col - curwin->w_width) / width + 1) * width;
|
col -= ((col - curwin->w_width) / width + 1) * width;
|
||||||
if (col > (int)curwin->w_leftcol)
|
if (col > (int)curwin->w_leftcol)
|
||||||
col -= curwin->w_leftcol;
|
col -= curwin->w_leftcol;
|
||||||
@ -922,10 +922,10 @@ curwin_col_off2(void)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
curs_columns(
|
curs_columns(
|
||||||
int may_scroll) /* when TRUE, may scroll horizontally */
|
int may_scroll) // when TRUE, may scroll horizontally
|
||||||
{
|
{
|
||||||
int diff;
|
int diff;
|
||||||
int extra; /* offset for first screen line */
|
int extra; // offset for first screen line
|
||||||
int off_left, off_right;
|
int off_left, off_right;
|
||||||
int n;
|
int n;
|
||||||
int p_lines;
|
int p_lines;
|
||||||
@ -954,14 +954,14 @@ curs_columns(
|
|||||||
*/
|
*/
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (curwin->w_cline_folded)
|
if (curwin->w_cline_folded)
|
||||||
/* In a folded line the cursor is always in the first column */
|
// In a folded line the cursor is always in the first column
|
||||||
startcol = curwin->w_virtcol = endcol = curwin->w_leftcol;
|
startcol = curwin->w_virtcol = endcol = curwin->w_leftcol;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
getvvcol(curwin, &curwin->w_cursor,
|
getvvcol(curwin, &curwin->w_cursor,
|
||||||
&startcol, &(curwin->w_virtcol), &endcol);
|
&startcol, &(curwin->w_virtcol), &endcol);
|
||||||
|
|
||||||
/* remove '$' from change command when cursor moves onto it */
|
// remove '$' from change command when cursor moves onto it
|
||||||
if (startcol > dollar_vcol)
|
if (startcol > dollar_vcol)
|
||||||
dollar_vcol = -1;
|
dollar_vcol = -1;
|
||||||
|
|
||||||
@ -977,7 +977,7 @@ curs_columns(
|
|||||||
textwidth = curwin->w_width - extra;
|
textwidth = curwin->w_width - extra;
|
||||||
if (textwidth <= 0)
|
if (textwidth <= 0)
|
||||||
{
|
{
|
||||||
/* No room for text, put cursor in last char of window. */
|
// No room for text, put cursor in last char of window.
|
||||||
curwin->w_wcol = curwin->w_width - 1;
|
curwin->w_wcol = curwin->w_width - 1;
|
||||||
curwin->w_wrow = curwin->w_height - 1;
|
curwin->w_wrow = curwin->w_height - 1;
|
||||||
}
|
}
|
||||||
@ -985,22 +985,22 @@ curs_columns(
|
|||||||
{
|
{
|
||||||
width = textwidth + curwin_col_off2();
|
width = textwidth + curwin_col_off2();
|
||||||
|
|
||||||
/* long line wrapping, adjust curwin->w_wrow */
|
// long line wrapping, adjust curwin->w_wrow
|
||||||
if (curwin->w_wcol >= curwin->w_width)
|
if (curwin->w_wcol >= curwin->w_width)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_LINEBREAK
|
#ifdef FEAT_LINEBREAK
|
||||||
char_u *sbr;
|
char_u *sbr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* this same formula is used in validate_cursor_col() */
|
// this same formula is used in validate_cursor_col()
|
||||||
n = (curwin->w_wcol - curwin->w_width) / width + 1;
|
n = (curwin->w_wcol - curwin->w_width) / width + 1;
|
||||||
curwin->w_wcol -= n * width;
|
curwin->w_wcol -= n * width;
|
||||||
curwin->w_wrow += n;
|
curwin->w_wrow += n;
|
||||||
|
|
||||||
#ifdef FEAT_LINEBREAK
|
#ifdef FEAT_LINEBREAK
|
||||||
/* When cursor wraps to first char of next line in Insert
|
// When cursor wraps to first char of next line in Insert
|
||||||
* mode, the 'showbreak' string isn't shown, backup to first
|
// mode, the 'showbreak' string isn't shown, backup to first
|
||||||
* column */
|
// column
|
||||||
sbr = get_showbreak_value(curwin);
|
sbr = get_showbreak_value(curwin);
|
||||||
if (*sbr && *ml_get_cursor() == NUL
|
if (*sbr && *ml_get_cursor() == NUL
|
||||||
&& curwin->w_wcol == (int)vim_strsize(sbr))
|
&& curwin->w_wcol == (int)vim_strsize(sbr))
|
||||||
@ -1009,9 +1009,9 @@ curs_columns(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No line wrapping: compute curwin->w_leftcol if scrolling is on and line
|
// No line wrapping: compute curwin->w_leftcol if scrolling is on and line
|
||||||
* is not folded.
|
// is not folded.
|
||||||
* If scrolling is off, curwin->w_leftcol is assumed to be 0 */
|
// If scrolling is off, curwin->w_leftcol is assumed to be 0
|
||||||
else if (may_scroll
|
else if (may_scroll
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
&& !curwin->w_cline_folded
|
&& !curwin->w_cline_folded
|
||||||
@ -1034,8 +1034,8 @@ curs_columns(
|
|||||||
else
|
else
|
||||||
diff = off_right;
|
diff = off_right;
|
||||||
|
|
||||||
/* When far off or not enough room on either side, put cursor in
|
// When far off or not enough room on either side, put cursor in
|
||||||
* middle of window. */
|
// middle of window.
|
||||||
if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left)
|
if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left)
|
||||||
new_leftcol = curwin->w_wcol - extra - textwidth / 2;
|
new_leftcol = curwin->w_wcol - extra - textwidth / 2;
|
||||||
else
|
else
|
||||||
@ -1052,7 +1052,7 @@ curs_columns(
|
|||||||
if (new_leftcol != (int)curwin->w_leftcol)
|
if (new_leftcol != (int)curwin->w_leftcol)
|
||||||
{
|
{
|
||||||
curwin->w_leftcol = new_leftcol;
|
curwin->w_leftcol = new_leftcol;
|
||||||
/* screen has to be redrawn with new curwin->w_leftcol */
|
// screen has to be redrawn with new curwin->w_leftcol
|
||||||
redraw_later(NOT_VALID);
|
redraw_later(NOT_VALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1064,8 +1064,8 @@ curs_columns(
|
|||||||
curwin->w_wcol = 0;
|
curwin->w_wcol = 0;
|
||||||
|
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
/* Skip over filler lines. At the top use w_topfill, there
|
// Skip over filler lines. At the top use w_topfill, there
|
||||||
* may be some filler lines above the window. */
|
// may be some filler lines above the window.
|
||||||
if (curwin->w_cursor.lnum == curwin->w_topline)
|
if (curwin->w_cursor.lnum == curwin->w_topline)
|
||||||
curwin->w_wrow += curwin->w_topfill;
|
curwin->w_wrow += curwin->w_topfill;
|
||||||
else
|
else
|
||||||
@ -1092,17 +1092,17 @@ curs_columns(
|
|||||||
&& width > 0
|
&& width > 0
|
||||||
&& curwin->w_width != 0)
|
&& curwin->w_width != 0)
|
||||||
{
|
{
|
||||||
/* Cursor past end of screen. Happens with a single line that does
|
// Cursor past end of screen. Happens with a single line that does
|
||||||
* not fit on screen. Find a skipcol to show the text around the
|
// not fit on screen. Find a skipcol to show the text around the
|
||||||
* cursor. Avoid scrolling all the time. compute value of "extra":
|
// cursor. Avoid scrolling all the time. compute value of "extra":
|
||||||
* 1: Less than 'scrolloff' lines above
|
// 1: Less than 'scrolloff' lines above
|
||||||
* 2: Less than 'scrolloff' lines below
|
// 2: Less than 'scrolloff' lines below
|
||||||
* 3: both of them */
|
// 3: both of them
|
||||||
extra = 0;
|
extra = 0;
|
||||||
if (curwin->w_skipcol + so * width > curwin->w_virtcol)
|
if (curwin->w_skipcol + so * width > curwin->w_virtcol)
|
||||||
extra = 1;
|
extra = 1;
|
||||||
/* Compute last display line of the buffer line that we want at the
|
// Compute last display line of the buffer line that we want at the
|
||||||
* bottom of the window. */
|
// bottom of the window.
|
||||||
if (p_lines == 0)
|
if (p_lines == 0)
|
||||||
p_lines = plines_win(curwin, curwin->w_cursor.lnum, FALSE);
|
p_lines = plines_win(curwin, curwin->w_cursor.lnum, FALSE);
|
||||||
--p_lines;
|
--p_lines;
|
||||||
@ -1115,20 +1115,20 @@ curs_columns(
|
|||||||
|
|
||||||
if (extra == 3 || p_lines < so * 2)
|
if (extra == 3 || p_lines < so * 2)
|
||||||
{
|
{
|
||||||
/* not enough room for 'scrolloff', put cursor in the middle */
|
// not enough room for 'scrolloff', put cursor in the middle
|
||||||
n = curwin->w_virtcol / width;
|
n = curwin->w_virtcol / width;
|
||||||
if (n > curwin->w_height / 2)
|
if (n > curwin->w_height / 2)
|
||||||
n -= curwin->w_height / 2;
|
n -= curwin->w_height / 2;
|
||||||
else
|
else
|
||||||
n = 0;
|
n = 0;
|
||||||
/* don't skip more than necessary */
|
// don't skip more than necessary
|
||||||
if (n > p_lines - curwin->w_height + 1)
|
if (n > p_lines - curwin->w_height + 1)
|
||||||
n = p_lines - curwin->w_height + 1;
|
n = p_lines - curwin->w_height + 1;
|
||||||
curwin->w_skipcol = n * width;
|
curwin->w_skipcol = n * width;
|
||||||
}
|
}
|
||||||
else if (extra == 1)
|
else if (extra == 1)
|
||||||
{
|
{
|
||||||
/* less then 'scrolloff' lines above, decrease skipcol */
|
// less then 'scrolloff' lines above, decrease skipcol
|
||||||
extra = (curwin->w_skipcol + so * width - curwin->w_virtcol
|
extra = (curwin->w_skipcol + so * width - curwin->w_virtcol
|
||||||
+ width - 1) / width;
|
+ width - 1) / width;
|
||||||
if (extra > 0)
|
if (extra > 0)
|
||||||
@ -1140,7 +1140,7 @@ curs_columns(
|
|||||||
}
|
}
|
||||||
else if (extra == 2)
|
else if (extra == 2)
|
||||||
{
|
{
|
||||||
/* less then 'scrolloff' lines below, increase skipcol */
|
// less then 'scrolloff' lines below, increase skipcol
|
||||||
endcol = (n - curwin->w_height + 1) * width;
|
endcol = (n - curwin->w_height + 1) * width;
|
||||||
while (endcol > curwin->w_virtcol)
|
while (endcol > curwin->w_virtcol)
|
||||||
endcol -= width;
|
endcol -= width;
|
||||||
@ -1151,7 +1151,7 @@ curs_columns(
|
|||||||
curwin->w_wrow -= curwin->w_skipcol / width;
|
curwin->w_wrow -= curwin->w_skipcol / width;
|
||||||
if (curwin->w_wrow >= curwin->w_height)
|
if (curwin->w_wrow >= curwin->w_height)
|
||||||
{
|
{
|
||||||
/* small window, make sure cursor is in it */
|
// small window, make sure cursor is in it
|
||||||
extra = curwin->w_wrow - curwin->w_height + 1;
|
extra = curwin->w_wrow - curwin->w_height + 1;
|
||||||
curwin->w_skipcol += extra * width;
|
curwin->w_skipcol += extra * width;
|
||||||
curwin->w_wrow -= extra;
|
curwin->w_wrow -= extra;
|
||||||
@ -1169,7 +1169,7 @@ curs_columns(
|
|||||||
redraw_later(NOT_VALID);
|
redraw_later(NOT_VALID);
|
||||||
|
|
||||||
#ifdef FEAT_SYN_HL
|
#ifdef FEAT_SYN_HL
|
||||||
/* Redraw when w_virtcol changes and 'cursorcolumn' is set */
|
// Redraw when w_virtcol changes and 'cursorcolumn' is set
|
||||||
if (curwin->w_p_cuc && (curwin->w_valid & VALID_VIRTCOL) == 0
|
if (curwin->w_p_cuc && (curwin->w_valid & VALID_VIRTCOL) == 0
|
||||||
&& !pum_visible())
|
&& !pum_visible())
|
||||||
redraw_later(SOME_VALID);
|
redraw_later(SOME_VALID);
|
||||||
@ -1279,19 +1279,19 @@ f_screenpos(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
void
|
void
|
||||||
scrolldown(
|
scrolldown(
|
||||||
long line_count,
|
long line_count,
|
||||||
int byfold UNUSED) /* TRUE: count a closed fold as one line */
|
int byfold UNUSED) // TRUE: count a closed fold as one line
|
||||||
{
|
{
|
||||||
long done = 0; /* total # of physical lines done */
|
long done = 0; // total # of physical lines done
|
||||||
int wrow;
|
int wrow;
|
||||||
int moved = FALSE;
|
int moved = FALSE;
|
||||||
|
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
linenr_T first;
|
linenr_T first;
|
||||||
|
|
||||||
/* Make sure w_topline is at the first of a sequence of folded lines. */
|
// Make sure w_topline is at the first of a sequence of folded lines.
|
||||||
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
||||||
#endif
|
#endif
|
||||||
validate_cursor(); /* w_wrow needs to be valid */
|
validate_cursor(); // w_wrow needs to be valid
|
||||||
while (line_count-- > 0)
|
while (line_count-- > 0)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
@ -1311,7 +1311,7 @@ scrolldown(
|
|||||||
curwin->w_topfill = 0;
|
curwin->w_topfill = 0;
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
/* A sequence of folded lines only counts for one logical line */
|
// A sequence of folded lines only counts for one logical line
|
||||||
if (hasFolding(curwin->w_topline, &first, NULL))
|
if (hasFolding(curwin->w_topline, &first, NULL))
|
||||||
{
|
{
|
||||||
++done;
|
++done;
|
||||||
@ -1324,11 +1324,11 @@ scrolldown(
|
|||||||
#endif
|
#endif
|
||||||
done += PLINES_NOFILL(curwin->w_topline);
|
done += PLINES_NOFILL(curwin->w_topline);
|
||||||
}
|
}
|
||||||
--curwin->w_botline; /* approximate w_botline */
|
--curwin->w_botline; // approximate w_botline
|
||||||
invalidate_botline();
|
invalidate_botline();
|
||||||
}
|
}
|
||||||
curwin->w_wrow += done; /* keep w_wrow updated */
|
curwin->w_wrow += done; // keep w_wrow updated
|
||||||
curwin->w_cline_row += done; /* keep w_cline_row updated */
|
curwin->w_cline_row += done; // keep w_cline_row updated
|
||||||
|
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
if (curwin->w_cursor.lnum == curwin->w_topline)
|
if (curwin->w_cursor.lnum == curwin->w_topline)
|
||||||
@ -1369,7 +1369,7 @@ scrolldown(
|
|||||||
if (moved)
|
if (moved)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
/* Move cursor to first line of closed fold. */
|
// Move cursor to first line of closed fold.
|
||||||
foldAdjustCursor();
|
foldAdjustCursor();
|
||||||
#endif
|
#endif
|
||||||
coladvance(curwin->w_curswant);
|
coladvance(curwin->w_curswant);
|
||||||
@ -1382,7 +1382,7 @@ scrolldown(
|
|||||||
void
|
void
|
||||||
scrollup(
|
scrollup(
|
||||||
long line_count,
|
long line_count,
|
||||||
int byfold UNUSED) /* TRUE: count a closed fold as one line */
|
int byfold UNUSED) // TRUE: count a closed fold as one line
|
||||||
{
|
{
|
||||||
#if defined(FEAT_FOLDING) || defined(FEAT_DIFF)
|
#if defined(FEAT_FOLDING) || defined(FEAT_DIFF)
|
||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
@ -1399,7 +1399,7 @@ scrollup(
|
|||||||
# endif
|
# endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* count each sequence of folded lines as one logical line */
|
// count each sequence of folded lines as one logical line
|
||||||
lnum = curwin->w_topline;
|
lnum = curwin->w_topline;
|
||||||
while (line_count--)
|
while (line_count--)
|
||||||
{
|
{
|
||||||
@ -1421,7 +1421,7 @@ scrollup(
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* approximate w_botline */
|
// approximate w_botline
|
||||||
curwin->w_botline += lnum - curwin->w_topline;
|
curwin->w_botline += lnum - curwin->w_topline;
|
||||||
curwin->w_topline = lnum;
|
curwin->w_topline = lnum;
|
||||||
}
|
}
|
||||||
@ -1429,7 +1429,7 @@ scrollup(
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
curwin->w_topline += line_count;
|
curwin->w_topline += line_count;
|
||||||
curwin->w_botline += line_count; /* approximate w_botline */
|
curwin->w_botline += line_count; // approximate w_botline
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curwin->w_topline > curbuf->b_ml.ml_line_count)
|
if (curwin->w_topline > curbuf->b_ml.ml_line_count)
|
||||||
@ -1443,7 +1443,7 @@ scrollup(
|
|||||||
|
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (hasAnyFolding(curwin))
|
if (hasAnyFolding(curwin))
|
||||||
/* Make sure w_topline is at the first of a sequence of folded lines. */
|
// Make sure w_topline is at the first of a sequence of folded lines.
|
||||||
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1464,7 +1464,7 @@ scrollup(
|
|||||||
void
|
void
|
||||||
check_topfill(
|
check_topfill(
|
||||||
win_T *wp,
|
win_T *wp,
|
||||||
int down) /* when TRUE scroll down when not enough space */
|
int down) // when TRUE scroll down when not enough space
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -1529,7 +1529,7 @@ scrolldown_clamp(void)
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
validate_cursor(); /* w_wrow needs to be valid */
|
validate_cursor(); // w_wrow needs to be valid
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the row number of the last row of the cursor line
|
* Compute the row number of the last row of the cursor line
|
||||||
@ -1571,7 +1571,7 @@ scrolldown_clamp(void)
|
|||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
||||||
#endif
|
#endif
|
||||||
--curwin->w_botline; /* approximate w_botline */
|
--curwin->w_botline; // approximate w_botline
|
||||||
curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE);
|
curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1592,7 +1592,7 @@ scrollup_clamp(void)
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
validate_cursor(); /* w_wrow needs to be valid */
|
validate_cursor(); // w_wrow needs to be valid
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute the row number of the first row of the cursor line
|
* Compute the row number of the first row of the cursor line
|
||||||
@ -1623,7 +1623,7 @@ scrollup_clamp(void)
|
|||||||
#endif
|
#endif
|
||||||
++curwin->w_topline;
|
++curwin->w_topline;
|
||||||
}
|
}
|
||||||
++curwin->w_botline; /* approximate w_botline */
|
++curwin->w_botline; // approximate w_botline
|
||||||
curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE);
|
curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1640,7 +1640,7 @@ topline_back(lineoff_T *lp)
|
|||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
if (lp->fill < diff_check_fill(curwin, lp->lnum))
|
if (lp->fill < diff_check_fill(curwin, lp->lnum))
|
||||||
{
|
{
|
||||||
/* Add a filler line. */
|
// Add a filler line.
|
||||||
++lp->fill;
|
++lp->fill;
|
||||||
lp->height = 1;
|
lp->height = 1;
|
||||||
}
|
}
|
||||||
@ -1656,7 +1656,7 @@ topline_back(lineoff_T *lp)
|
|||||||
else
|
else
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (hasFolding(lp->lnum, &lp->lnum, NULL))
|
if (hasFolding(lp->lnum, &lp->lnum, NULL))
|
||||||
/* Add a closed fold */
|
// Add a closed fold
|
||||||
lp->height = 1;
|
lp->height = 1;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@ -1676,7 +1676,7 @@ botline_forw(lineoff_T *lp)
|
|||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
if (lp->fill < diff_check_fill(curwin, lp->lnum + 1))
|
if (lp->fill < diff_check_fill(curwin, lp->lnum + 1))
|
||||||
{
|
{
|
||||||
/* Add a filler line. */
|
// Add a filler line.
|
||||||
++lp->fill;
|
++lp->fill;
|
||||||
lp->height = 1;
|
lp->height = 1;
|
||||||
}
|
}
|
||||||
@ -1692,7 +1692,7 @@ botline_forw(lineoff_T *lp)
|
|||||||
else
|
else
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (hasFolding(lp->lnum, NULL, &lp->lnum))
|
if (hasFolding(lp->lnum, NULL, &lp->lnum))
|
||||||
/* Add a closed fold */
|
// Add a closed fold
|
||||||
lp->height = 1;
|
lp->height = 1;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@ -1744,8 +1744,8 @@ scroll_cursor_top(int min_scroll, int always)
|
|||||||
int extra = 0;
|
int extra = 0;
|
||||||
int used;
|
int used;
|
||||||
int i;
|
int i;
|
||||||
linenr_T top; /* just above displayed lines */
|
linenr_T top; // just above displayed lines
|
||||||
linenr_T bot; /* just below displayed lines */
|
linenr_T bot; // just below displayed lines
|
||||||
linenr_T old_topline = curwin->w_topline;
|
linenr_T old_topline = curwin->w_topline;
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
linenr_T old_topfill = curwin->w_topfill;
|
linenr_T old_topfill = curwin->w_topfill;
|
||||||
@ -1764,7 +1764,7 @@ scroll_cursor_top(int min_scroll, int always)
|
|||||||
* - at least 'scrolloff' lines above and below the cursor
|
* - at least 'scrolloff' lines above and below the cursor
|
||||||
*/
|
*/
|
||||||
validate_cheight();
|
validate_cheight();
|
||||||
used = curwin->w_cline_height; /* includes filler lines above */
|
used = curwin->w_cline_height; // includes filler lines above
|
||||||
if (curwin->w_cursor.lnum < curwin->w_topline)
|
if (curwin->w_cursor.lnum < curwin->w_topline)
|
||||||
scrolled = used;
|
scrolled = used;
|
||||||
|
|
||||||
@ -1783,9 +1783,9 @@ scroll_cursor_top(int min_scroll, int always)
|
|||||||
new_topline = top + 1;
|
new_topline = top + 1;
|
||||||
|
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
/* "used" already contains the number of filler lines above, don't add it
|
// "used" already contains the number of filler lines above, don't add it
|
||||||
* again.
|
// again.
|
||||||
* Hide filler lines above cursor line by adding them to "extra". */
|
// Hide filler lines above cursor line by adding them to "extra".
|
||||||
extra += diff_check_fill(curwin, curwin->w_cursor.lnum);
|
extra += diff_check_fill(curwin, curwin->w_cursor.lnum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1797,7 +1797,7 @@ scroll_cursor_top(int min_scroll, int always)
|
|||||||
{
|
{
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (hasFolding(top, &top, NULL))
|
if (hasFolding(top, &top, NULL))
|
||||||
/* count one logical line for a sequence of folded lines */
|
// count one logical line for a sequence of folded lines
|
||||||
i = 1;
|
i = 1;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@ -1807,7 +1807,7 @@ scroll_cursor_top(int min_scroll, int always)
|
|||||||
{
|
{
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (hasFolding(bot, NULL, &bot))
|
if (hasFolding(bot, NULL, &bot))
|
||||||
/* count one logical line for a sequence of folded lines */
|
// count one logical line for a sequence of folded lines
|
||||||
++used;
|
++used;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@ -1880,7 +1880,7 @@ set_empty_rows(win_T *wp, int used)
|
|||||||
wp->w_filler_rows = 0;
|
wp->w_filler_rows = 0;
|
||||||
#endif
|
#endif
|
||||||
if (used == 0)
|
if (used == 0)
|
||||||
wp->w_empty_rows = 0; /* single line that doesn't fit */
|
wp->w_empty_rows = 0; // single line that doesn't fit
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wp->w_empty_rows = wp->w_height - used;
|
wp->w_empty_rows = wp->w_height - used;
|
||||||
@ -1924,7 +1924,7 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
linenr_T old_botline = curwin->w_botline;
|
linenr_T old_botline = curwin->w_botline;
|
||||||
linenr_T old_valid = curwin->w_valid;
|
linenr_T old_valid = curwin->w_valid;
|
||||||
int old_empty_rows = curwin->w_empty_rows;
|
int old_empty_rows = curwin->w_empty_rows;
|
||||||
linenr_T cln; /* Cursor Line Number */
|
linenr_T cln; // Cursor Line Number
|
||||||
long so = get_scrolloff_value();
|
long so = get_scrolloff_value();
|
||||||
|
|
||||||
cln = curwin->w_cursor.lnum;
|
cln = curwin->w_cursor.lnum;
|
||||||
@ -1960,7 +1960,7 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
else
|
else
|
||||||
validate_botline();
|
validate_botline();
|
||||||
|
|
||||||
/* The lines of the cursor line itself are always used. */
|
// The lines of the cursor line itself are always used.
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
used = plines_nofill(cln);
|
used = plines_nofill(cln);
|
||||||
#else
|
#else
|
||||||
@ -1968,9 +1968,9 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
used = curwin->w_cline_height;
|
used = curwin->w_cline_height;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If the cursor is below botline, we will at least scroll by the height
|
// If the cursor is below botline, we will at least scroll by the height
|
||||||
* of the cursor line. Correct for empty lines, which are really part of
|
// of the cursor line. Correct for empty lines, which are really part of
|
||||||
* botline. */
|
// botline.
|
||||||
if (cln >= curwin->w_botline)
|
if (cln >= curwin->w_botline)
|
||||||
{
|
{
|
||||||
scrolled = used;
|
scrolled = used;
|
||||||
@ -2001,8 +2001,8 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
|
|
||||||
while (loff.lnum > 1)
|
while (loff.lnum > 1)
|
||||||
{
|
{
|
||||||
/* Stop when scrolled nothing or at least "min_scroll", found "extra"
|
// Stop when scrolled nothing or at least "min_scroll", found "extra"
|
||||||
* context for 'scrolloff' and counted all lines below the window. */
|
// context for 'scrolloff' and counted all lines below the window.
|
||||||
if ((((scrolled <= 0 || scrolled >= min_scroll)
|
if ((((scrolled <= 0 || scrolled >= min_scroll)
|
||||||
&& extra >= (mouse_dragging > 0 ? mouse_dragging - 1 : so))
|
&& extra >= (mouse_dragging > 0 ? mouse_dragging - 1 : so))
|
||||||
|| boff.lnum + 1 > curbuf->b_ml.ml_line_count)
|
|| boff.lnum + 1 > curbuf->b_ml.ml_line_count)
|
||||||
@ -2014,7 +2014,7 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
)
|
)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Add one line above */
|
// Add one line above
|
||||||
topline_back(&loff);
|
topline_back(&loff);
|
||||||
if (loff.height == MAXCOL)
|
if (loff.height == MAXCOL)
|
||||||
used = MAXCOL;
|
used = MAXCOL;
|
||||||
@ -2029,7 +2029,7 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* Count screen lines that are below the window. */
|
// Count screen lines that are below the window.
|
||||||
scrolled += loff.height;
|
scrolled += loff.height;
|
||||||
if (loff.lnum == curwin->w_botline
|
if (loff.lnum == curwin->w_botline
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
@ -2041,7 +2041,7 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
|
|
||||||
if (boff.lnum < curbuf->b_ml.ml_line_count)
|
if (boff.lnum < curbuf->b_ml.ml_line_count)
|
||||||
{
|
{
|
||||||
/* Add one line below */
|
// Add one line below
|
||||||
botline_forw(&boff);
|
botline_forw(&boff);
|
||||||
used += boff.height;
|
used += boff.height;
|
||||||
if (used > curwin->w_height)
|
if (used > curwin->w_height)
|
||||||
@ -2057,7 +2057,7 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* Count screen lines that are below the window. */
|
// Count screen lines that are below the window.
|
||||||
scrolled += boff.height;
|
scrolled += boff.height;
|
||||||
if (boff.lnum == curwin->w_botline
|
if (boff.lnum == curwin->w_botline
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
@ -2070,13 +2070,13 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* curwin->w_empty_rows is larger, no need to scroll */
|
// curwin->w_empty_rows is larger, no need to scroll
|
||||||
if (scrolled <= 0)
|
if (scrolled <= 0)
|
||||||
line_count = 0;
|
line_count = 0;
|
||||||
/* more than a screenfull, don't scroll but redraw */
|
// more than a screenfull, don't scroll but redraw
|
||||||
else if (used > curwin->w_height)
|
else if (used > curwin->w_height)
|
||||||
line_count = used;
|
line_count = used;
|
||||||
/* scroll minimal number of lines */
|
// scroll minimal number of lines
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
line_count = 0;
|
line_count = 0;
|
||||||
@ -2090,7 +2090,7 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
i += boff.height;
|
i += boff.height;
|
||||||
++line_count;
|
++line_count;
|
||||||
}
|
}
|
||||||
if (i < scrolled) /* below curwin->w_botline, don't scroll */
|
if (i < scrolled) // below curwin->w_botline, don't scroll
|
||||||
line_count = 9999;
|
line_count = 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2151,7 +2151,7 @@ scroll_cursor_halfway(int atend)
|
|||||||
topline = loff.lnum;
|
topline = loff.lnum;
|
||||||
while (topline > 1)
|
while (topline > 1)
|
||||||
{
|
{
|
||||||
if (below <= above) /* add a line below the cursor first */
|
if (below <= above) // add a line below the cursor first
|
||||||
{
|
{
|
||||||
if (boff.lnum < curbuf->b_ml.ml_line_count)
|
if (boff.lnum < curbuf->b_ml.ml_line_count)
|
||||||
{
|
{
|
||||||
@ -2163,13 +2163,13 @@ scroll_cursor_halfway(int atend)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++below; /* count a "~" line */
|
++below; // count a "~" line
|
||||||
if (atend)
|
if (atend)
|
||||||
++used;
|
++used;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (below > above) /* add a line above the cursor */
|
if (below > above) // add a line above the cursor
|
||||||
{
|
{
|
||||||
topline_back(&loff);
|
topline_back(&loff);
|
||||||
if (loff.height == MAXCOL)
|
if (loff.height == MAXCOL)
|
||||||
@ -2208,12 +2208,12 @@ scroll_cursor_halfway(int atend)
|
|||||||
void
|
void
|
||||||
cursor_correct(void)
|
cursor_correct(void)
|
||||||
{
|
{
|
||||||
int above = 0; /* screen lines above topline */
|
int above = 0; // screen lines above topline
|
||||||
linenr_T topline;
|
linenr_T topline;
|
||||||
int below = 0; /* screen lines below botline */
|
int below = 0; // screen lines below botline
|
||||||
linenr_T botline;
|
linenr_T botline;
|
||||||
int above_wanted, below_wanted;
|
int above_wanted, below_wanted;
|
||||||
linenr_T cln; /* Cursor Line Number */
|
linenr_T cln; // Cursor Line Number
|
||||||
int max_off;
|
int max_off;
|
||||||
long so = get_scrolloff_value();
|
long so = get_scrolloff_value();
|
||||||
|
|
||||||
@ -2267,7 +2267,7 @@ cursor_correct(void)
|
|||||||
topline = curwin->w_topline;
|
topline = curwin->w_topline;
|
||||||
botline = curwin->w_botline - 1;
|
botline = curwin->w_botline - 1;
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
/* count filler lines as context */
|
// count filler lines as context
|
||||||
above = curwin->w_topfill;
|
above = curwin->w_topfill;
|
||||||
below = curwin->w_filler_rows;
|
below = curwin->w_filler_rows;
|
||||||
#endif
|
#endif
|
||||||
@ -2292,7 +2292,7 @@ cursor_correct(void)
|
|||||||
#endif
|
#endif
|
||||||
above += PLINES_NOFILL(topline);
|
above += PLINES_NOFILL(topline);
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
/* Count filler lines below this line as context. */
|
// Count filler lines below this line as context.
|
||||||
if (topline < botline)
|
if (topline < botline)
|
||||||
above += diff_check_fill(curwin, topline + 1);
|
above += diff_check_fill(curwin, topline + 1);
|
||||||
#endif
|
#endif
|
||||||
@ -2337,7 +2337,7 @@ onepage(int dir, long count)
|
|||||||
linenr_T old_topline = curwin->w_topline;
|
linenr_T old_topline = curwin->w_topline;
|
||||||
long so = get_scrolloff_value();
|
long so = get_scrolloff_value();
|
||||||
|
|
||||||
if (curbuf->b_ml.ml_line_count == 1) /* nothing to do */
|
if (curbuf->b_ml.ml_line_count == 1) // nothing to do
|
||||||
{
|
{
|
||||||
beep_flush();
|
beep_flush();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -2374,7 +2374,7 @@ onepage(int dir, long count)
|
|||||||
{
|
{
|
||||||
if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1)
|
if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1)
|
||||||
{
|
{
|
||||||
/* Vi compatible scrolling */
|
// Vi compatible scrolling
|
||||||
if (p_window <= 2)
|
if (p_window <= 2)
|
||||||
++curwin->w_topline;
|
++curwin->w_topline;
|
||||||
else
|
else
|
||||||
@ -2385,7 +2385,7 @@ onepage(int dir, long count)
|
|||||||
}
|
}
|
||||||
else if (curwin->w_botline > curbuf->b_ml.ml_line_count)
|
else if (curwin->w_botline > curbuf->b_ml.ml_line_count)
|
||||||
{
|
{
|
||||||
/* at end of file */
|
// at end of file
|
||||||
curwin->w_topline = curbuf->b_ml.ml_line_count;
|
curwin->w_topline = curbuf->b_ml.ml_line_count;
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
curwin->w_topfill = 0;
|
curwin->w_topfill = 0;
|
||||||
@ -2394,8 +2394,8 @@ onepage(int dir, long count)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* For the overlap, start with the line just below the window
|
// For the overlap, start with the line just below the window
|
||||||
* and go upwards. */
|
// and go upwards.
|
||||||
loff.lnum = curwin->w_botline;
|
loff.lnum = curwin->w_botline;
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
loff.fill = diff_check_fill(curwin, loff.lnum)
|
loff.fill = diff_check_fill(curwin, loff.lnum)
|
||||||
@ -2412,19 +2412,19 @@ onepage(int dir, long count)
|
|||||||
VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
|
VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* dir == BACKWARDS */
|
else // dir == BACKWARDS
|
||||||
{
|
{
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
if (curwin->w_topline == 1)
|
if (curwin->w_topline == 1)
|
||||||
{
|
{
|
||||||
/* Include max number of filler lines */
|
// Include max number of filler lines
|
||||||
max_topfill();
|
max_topfill();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1)
|
if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1)
|
||||||
{
|
{
|
||||||
/* Vi compatible scrolling (sort of) */
|
// Vi compatible scrolling (sort of)
|
||||||
if (p_window <= 2)
|
if (p_window <= 2)
|
||||||
--curwin->w_topline;
|
--curwin->w_topline;
|
||||||
else
|
else
|
||||||
@ -2437,9 +2437,9 @@ onepage(int dir, long count)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the line at the top of the window that is going to be the
|
// Find the line at the top of the window that is going to be the
|
||||||
* line at the bottom of the window. Make sure this results in
|
// line at the bottom of the window. Make sure this results in
|
||||||
* the same line as before doing CTRL-F. */
|
// the same line as before doing CTRL-F.
|
||||||
loff.lnum = curwin->w_topline - 1;
|
loff.lnum = curwin->w_topline - 1;
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
loff.fill = diff_check_fill(curwin, loff.lnum + 1)
|
loff.fill = diff_check_fill(curwin, loff.lnum + 1)
|
||||||
@ -2460,8 +2460,8 @@ onepage(int dir, long count)
|
|||||||
}
|
}
|
||||||
curwin->w_cursor.lnum = loff.lnum;
|
curwin->w_cursor.lnum = loff.lnum;
|
||||||
|
|
||||||
/* Find the line just above the new topline to get the right line
|
// Find the line just above the new topline to get the right line
|
||||||
* at the bottom of the window. */
|
// at the bottom of the window.
|
||||||
n = 0;
|
n = 0;
|
||||||
while (n <= curwin->w_height && loff.lnum >= 1)
|
while (n <= curwin->w_height && loff.lnum >= 1)
|
||||||
{
|
{
|
||||||
@ -2471,7 +2471,7 @@ onepage(int dir, long count)
|
|||||||
else
|
else
|
||||||
n += loff.height;
|
n += loff.height;
|
||||||
}
|
}
|
||||||
if (loff.lnum < 1) /* at begin of file */
|
if (loff.lnum < 1) // at begin of file
|
||||||
{
|
{
|
||||||
curwin->w_topline = 1;
|
curwin->w_topline = 1;
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
@ -2481,7 +2481,7 @@ onepage(int dir, long count)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Go two lines forward again. */
|
// Go two lines forward again.
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
topline_botline(&loff);
|
topline_botline(&loff);
|
||||||
#endif
|
#endif
|
||||||
@ -2491,12 +2491,12 @@ onepage(int dir, long count)
|
|||||||
botline_topline(&loff);
|
botline_topline(&loff);
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
/* We're at the wrong end of a fold now. */
|
// We're at the wrong end of a fold now.
|
||||||
(void)hasFolding(loff.lnum, &loff.lnum, NULL);
|
(void)hasFolding(loff.lnum, &loff.lnum, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Always scroll at least one line. Avoid getting stuck on
|
// Always scroll at least one line. Avoid getting stuck on
|
||||||
* very long lines. */
|
// very long lines.
|
||||||
if (loff.lnum >= curwin->w_topline
|
if (loff.lnum >= curwin->w_topline
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
&& (loff.lnum > curwin->w_topline
|
&& (loff.lnum > curwin->w_topline
|
||||||
@ -2505,8 +2505,8 @@ onepage(int dir, long count)
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
/* First try using the maximum number of filler lines. If
|
// First try using the maximum number of filler lines. If
|
||||||
* that's not enough, backup one line. */
|
// that's not enough, backup one line.
|
||||||
loff.fill = curwin->w_topfill;
|
loff.fill = curwin->w_topfill;
|
||||||
if (curwin->w_topfill < diff_check_fill(curwin,
|
if (curwin->w_topfill < diff_check_fill(curwin,
|
||||||
curwin->w_topline))
|
curwin->w_topline))
|
||||||
@ -2601,7 +2601,7 @@ get_scroll_overlap(lineoff_T *lp, int dir)
|
|||||||
#endif
|
#endif
|
||||||
h1 = lp->height;
|
h1 = lp->height;
|
||||||
if (h1 > min_height)
|
if (h1 > min_height)
|
||||||
return; /* no overlap */
|
return; // no overlap
|
||||||
|
|
||||||
loff0 = *lp;
|
loff0 = *lp;
|
||||||
if (dir > 0)
|
if (dir > 0)
|
||||||
@ -2611,7 +2611,7 @@ get_scroll_overlap(lineoff_T *lp, int dir)
|
|||||||
h2 = lp->height;
|
h2 = lp->height;
|
||||||
if (h2 == MAXCOL || h2 + h1 > min_height)
|
if (h2 == MAXCOL || h2 + h1 > min_height)
|
||||||
{
|
{
|
||||||
*lp = loff0; /* no overlap */
|
*lp = loff0; // no overlap
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2623,7 +2623,7 @@ get_scroll_overlap(lineoff_T *lp, int dir)
|
|||||||
h3 = lp->height;
|
h3 = lp->height;
|
||||||
if (h3 == MAXCOL || h3 + h2 > min_height)
|
if (h3 == MAXCOL || h3 + h2 > min_height)
|
||||||
{
|
{
|
||||||
*lp = loff0; /* no overlap */
|
*lp = loff0; // no overlap
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2634,9 +2634,9 @@ get_scroll_overlap(lineoff_T *lp, int dir)
|
|||||||
topline_back(lp);
|
topline_back(lp);
|
||||||
h4 = lp->height;
|
h4 = lp->height;
|
||||||
if (h4 == MAXCOL || h4 + h3 + h2 > min_height || h3 + h2 + h1 > min_height)
|
if (h4 == MAXCOL || h4 + h3 + h2 > min_height || h3 + h2 + h1 > min_height)
|
||||||
*lp = loff1; /* 1 line overlap */
|
*lp = loff1; // 1 line overlap
|
||||||
else
|
else
|
||||||
*lp = loff2; /* 2 lines overlap */
|
*lp = loff2; // 2 lines overlap
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2814,7 +2814,7 @@ halfpage(int flag, linenr_T Prenum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ifdef FEAT_FOLDING
|
# ifdef FEAT_FOLDING
|
||||||
/* Move cursor to first line of closed fold. */
|
// Move cursor to first line of closed fold.
|
||||||
foldAdjustCursor();
|
foldAdjustCursor();
|
||||||
# endif
|
# endif
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
@ -2846,7 +2846,7 @@ do_check_cursorbind(void)
|
|||||||
FOR_ALL_WINDOWS(curwin)
|
FOR_ALL_WINDOWS(curwin)
|
||||||
{
|
{
|
||||||
curbuf = curwin->w_buffer;
|
curbuf = curwin->w_buffer;
|
||||||
/* skip original window and windows with 'noscrollbind' */
|
// skip original window and windows with 'noscrollbind'
|
||||||
if (curwin != old_curwin && curwin->w_p_crb)
|
if (curwin != old_curwin && curwin->w_p_crb)
|
||||||
{
|
{
|
||||||
# ifdef FEAT_DIFF
|
# ifdef FEAT_DIFF
|
||||||
@ -2861,8 +2861,8 @@ do_check_cursorbind(void)
|
|||||||
curwin->w_curswant = curswant;
|
curwin->w_curswant = curswant;
|
||||||
curwin->w_set_curswant = set_curswant;
|
curwin->w_set_curswant = set_curswant;
|
||||||
|
|
||||||
/* Make sure the cursor is in a valid position. Temporarily set
|
// Make sure the cursor is in a valid position. Temporarily set
|
||||||
* "restart_edit" to allow the cursor to be beyond the EOL. */
|
// "restart_edit" to allow the cursor to be beyond the EOL.
|
||||||
restart_edit_save = restart_edit;
|
restart_edit_save = restart_edit;
|
||||||
restart_edit = TRUE;
|
restart_edit = TRUE;
|
||||||
check_cursor();
|
check_cursor();
|
||||||
@ -2871,12 +2871,12 @@ do_check_cursorbind(void)
|
|||||||
validate_cursor();
|
validate_cursor();
|
||||||
# endif
|
# endif
|
||||||
restart_edit = restart_edit_save;
|
restart_edit = restart_edit_save;
|
||||||
/* Correct cursor for multi-byte character. */
|
// Correct cursor for multi-byte character.
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
mb_adjust_cursor();
|
mb_adjust_cursor();
|
||||||
redraw_later(VALID);
|
redraw_later(VALID);
|
||||||
|
|
||||||
/* Only scroll when 'scrollbind' hasn't done this. */
|
// Only scroll when 'scrollbind' hasn't done this.
|
||||||
if (!curwin->w_p_scb)
|
if (!curwin->w_p_scb)
|
||||||
update_topline();
|
update_topline();
|
||||||
curwin->w_redr_status = TRUE;
|
curwin->w_redr_status = TRUE;
|
||||||
|
@ -742,6 +742,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
26,
|
||||||
/**/
|
/**/
|
||||||
25,
|
25,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user