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