mirror of
https://github.com/irssi/irssi.git
synced 2024-10-27 05:20:20 -04:00
textbuffer_view_remove_line() fixes (with a small kludge..)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1741 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
53c13065d2
commit
08b9062028
@ -870,10 +870,36 @@ static int view_get_lines_height(TEXT_BUFFER_VIEW_REC *view,
|
||||
return height < view->height ? height : view->height;
|
||||
}
|
||||
|
||||
static void view_remove_line_update_startline(TEXT_BUFFER_VIEW_REC *view,
|
||||
LINE_REC *line, int linecount)
|
||||
{
|
||||
int scroll;
|
||||
|
||||
if (view->startline == line) {
|
||||
view->startline = view->startline->prev != NULL ?
|
||||
view->startline->prev : view->startline->next;
|
||||
view->subline = 0;
|
||||
} else {
|
||||
scroll = view->height -
|
||||
view_get_lines_height(view, view->startline,
|
||||
view->subline, line);
|
||||
if (scroll > 0) {
|
||||
view_scroll(view, &view->startline,
|
||||
&view->subline, -scroll, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: this is slow and unnecessary, but it's easy and
|
||||
really works :) */
|
||||
textbuffer_view_init_ypos(view);
|
||||
if (textbuffer_line_exists_after(view->startline, line))
|
||||
view->ypos -= linecount;
|
||||
}
|
||||
|
||||
static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
|
||||
int linecount)
|
||||
{
|
||||
int realcount, scroll;
|
||||
int realcount;
|
||||
|
||||
view_bookmarks_check(view, line);
|
||||
|
||||
@ -887,7 +913,7 @@ static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
|
||||
view_get_linecount(view, prevline);
|
||||
}
|
||||
|
||||
if (line == view->buffer->first_line) {
|
||||
if (view->buffer->first_line == line) {
|
||||
/* first line in the buffer - this is the most commonly
|
||||
removed line.. */
|
||||
if (view->bottom_startline == line) {
|
||||
@ -900,41 +926,26 @@ static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
|
||||
/* removing the first line in screen */
|
||||
realcount = view_scroll(view, &view->startline,
|
||||
&view->subline,
|
||||
linecount, TRUE);
|
||||
linecount, FALSE);
|
||||
view->ypos -= realcount;
|
||||
view->empty_linecount += linecount-realcount;
|
||||
}
|
||||
} else if (textbuffer_line_exists_after(view->bottom_startline,
|
||||
} else {
|
||||
if (textbuffer_line_exists_after(view->bottom_startline,
|
||||
line)) {
|
||||
realcount = view_scroll(view, &view->bottom_startline,
|
||||
&view->bottom_subline,
|
||||
-linecount, FALSE);
|
||||
if (view->bottom) {
|
||||
/* we're at the bottom, remove the same amount as
|
||||
from bottom_startline */
|
||||
view_scroll(view, &view->startline,
|
||||
&view->subline, -linecount, TRUE);
|
||||
view->ypos -= linecount-realcount;
|
||||
} else {
|
||||
if (view->startline == line) {
|
||||
view->startline =
|
||||
view->startline->next != NULL ?
|
||||
view->startline->next :
|
||||
view->startline->prev;
|
||||
view->subline = 0;
|
||||
}
|
||||
scroll = view->height -
|
||||
view_get_lines_height(view, view->startline,
|
||||
view->subline, line);
|
||||
if (scroll > 0) {
|
||||
view_scroll(view, &view->startline,
|
||||
&view->subline, -scroll, TRUE);
|
||||
view->ypos -= scroll;
|
||||
}
|
||||
}
|
||||
view->empty_linecount += linecount-realcount;
|
||||
}
|
||||
|
||||
if (textbuffer_line_exists_after(view->startline,
|
||||
line)) {
|
||||
view_remove_line_update_startline(view, line,
|
||||
linecount);
|
||||
}
|
||||
}
|
||||
|
||||
view->bottom = view_is_bottom(view);
|
||||
if (view->window != NULL)
|
||||
screen_refresh(view->window);
|
||||
|
@ -308,6 +308,8 @@ void textbuffer_remove(TEXT_BUFFER_REC *buffer, LINE_REC *line)
|
||||
line->next : line->prev;
|
||||
}
|
||||
|
||||
line->prev = line->next = NULL;
|
||||
|
||||
buffer->lines_count--;
|
||||
textbuffer_line_unref(buffer, line);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user