mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
move deleted_lines, deleted_lines_mark, changed_lines_buf
This commit is contained in:
parent
83d35e62f2
commit
b353d8599b
@ -356,10 +356,9 @@ void appended_lines_mark(linenr_T lnum, long count)
|
||||
* Must be called AFTER the change and after mark_adjust().
|
||||
* Takes care of marking the buffer to be redrawn and sets the changed flag.
|
||||
*/
|
||||
void
|
||||
deleted_lines(linenr_T lnum, long count)
|
||||
void deleted_lines(linenr_T lnum, long count)
|
||||
{
|
||||
changed_lines(lnum, 0, lnum + count, -count);
|
||||
changed_lines(lnum, 0, lnum + count, -count, true);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -367,47 +366,40 @@ deleted_lines(linenr_T lnum, long count)
|
||||
* Make sure the cursor is on a valid line before calling, a GUI callback may
|
||||
* be triggered to display the cursor.
|
||||
*/
|
||||
void
|
||||
deleted_lines_mark(linenr_T lnum, long count)
|
||||
void deleted_lines_mark(linenr_T lnum, long count)
|
||||
{
|
||||
mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM, -count);
|
||||
changed_lines(lnum, 0, lnum + count, -count);
|
||||
mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM, -count, false);
|
||||
changed_lines(lnum, 0, lnum + count, -count, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Marks the area to be redrawn after a change.
|
||||
*/
|
||||
static void
|
||||
changed_lines_buf(
|
||||
buf_T *buf,
|
||||
linenr_T lnum, // first line with change
|
||||
linenr_T lnume, // line below last changed line
|
||||
long xtra) // number of extra lines (negative when deleting)
|
||||
/// Marks the area to be redrawn after a change.
|
||||
///
|
||||
/// @param buf the buffer where lines were changed
|
||||
/// @param lnum first line with change
|
||||
/// @param lnume line below last changed line
|
||||
/// @param xtra number of extra lines (negative when deleting)
|
||||
void changed_lines_buf(buf_T *buf, linenr_T lnum, linenr_T lnume, long xtra)
|
||||
{
|
||||
if (buf->b_mod_set)
|
||||
{
|
||||
// find the maximum area that must be redisplayed
|
||||
if (lnum < buf->b_mod_top)
|
||||
buf->b_mod_top = lnum;
|
||||
if (lnum < buf->b_mod_bot)
|
||||
{
|
||||
// adjust old bot position for xtra lines
|
||||
buf->b_mod_bot += xtra;
|
||||
if (buf->b_mod_bot < lnum)
|
||||
buf->b_mod_bot = lnum;
|
||||
}
|
||||
if (lnume + xtra > buf->b_mod_bot)
|
||||
buf->b_mod_bot = lnume + xtra;
|
||||
buf->b_mod_xlines += xtra;
|
||||
}
|
||||
else
|
||||
{
|
||||
// set the area that must be redisplayed
|
||||
buf->b_mod_set = TRUE;
|
||||
buf->b_mod_top = lnum;
|
||||
buf->b_mod_bot = lnume + xtra;
|
||||
buf->b_mod_xlines = xtra;
|
||||
if (buf->b_mod_set) {
|
||||
// find the maximum area that must be redisplayed
|
||||
if (lnum < buf->b_mod_top)
|
||||
buf->b_mod_top = lnum;
|
||||
if (lnum < buf->b_mod_bot) {
|
||||
// adjust old bot position for xtra lines
|
||||
buf->b_mod_bot += xtra;
|
||||
if (buf->b_mod_bot < lnum)
|
||||
buf->b_mod_bot = lnum;
|
||||
}
|
||||
if (lnume + xtra > buf->b_mod_bot)
|
||||
buf->b_mod_bot = lnume + xtra;
|
||||
buf->b_mod_xlines += xtra;
|
||||
} else {
|
||||
// set the area that must be redisplayed
|
||||
buf->b_mod_set = true;
|
||||
buf->b_mod_top = lnum;
|
||||
buf->b_mod_bot = lnume + xtra;
|
||||
buf->b_mod_xlines = xtra;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1785,27 +1785,6 @@ int gchar_pos(pos_T *pos)
|
||||
return utf_ptr2char(ml_get_pos(pos));
|
||||
}
|
||||
|
||||
/*
|
||||
* Deleted "count" lines at line "lnum" in the current buffer.
|
||||
* Must be called AFTER the change and after mark_adjust().
|
||||
* Takes care of marking the buffer to be redrawn and sets the changed flag.
|
||||
*/
|
||||
void deleted_lines(linenr_T lnum, long count)
|
||||
{
|
||||
changed_lines(lnum, 0, lnum + count, -count, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Like deleted_lines(), but adjust marks first.
|
||||
* Make sure the cursor is on a valid line before calling, a GUI callback may
|
||||
* be triggered to display the cursor.
|
||||
*/
|
||||
void deleted_lines_mark(linenr_T lnum, long count)
|
||||
{
|
||||
mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM, -count, false);
|
||||
changed_lines(lnum, 0, lnum + count, -count, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Changed lines for the current buffer.
|
||||
* Must be called AFTER the change and after mark_adjust().
|
||||
@ -1859,36 +1838,6 @@ changed_lines(
|
||||
}
|
||||
}
|
||||
|
||||
/// Mark line range in buffer as changed.
|
||||
///
|
||||
/// @param buf the buffer where lines were changed
|
||||
/// @param lnum first line with change
|
||||
/// @param lnume line below last changed line
|
||||
/// @param xtra number of extra lines (negative when deleting)
|
||||
void changed_lines_buf(buf_T *buf, linenr_T lnum, linenr_T lnume, long xtra)
|
||||
{
|
||||
if (buf->b_mod_set) {
|
||||
/* find the maximum area that must be redisplayed */
|
||||
if (lnum < buf->b_mod_top)
|
||||
buf->b_mod_top = lnum;
|
||||
if (lnum < buf->b_mod_bot) {
|
||||
/* adjust old bot position for xtra lines */
|
||||
buf->b_mod_bot += xtra;
|
||||
if (buf->b_mod_bot < lnum)
|
||||
buf->b_mod_bot = lnum;
|
||||
}
|
||||
if (lnume + xtra > buf->b_mod_bot)
|
||||
buf->b_mod_bot = lnume + xtra;
|
||||
buf->b_mod_xlines += xtra;
|
||||
} else {
|
||||
/* set the area that must be redisplayed */
|
||||
buf->b_mod_set = true;
|
||||
buf->b_mod_top = lnum;
|
||||
buf->b_mod_bot = lnume + xtra;
|
||||
buf->b_mod_xlines = xtra;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* unchanged() is called when the changed flag must be reset for buffer 'buf'
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user