1
0
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:
Timo Sirainen 2001-08-12 18:25:43 +00:00 committed by cras
parent 53c13065d2
commit 08b9062028
2 changed files with 44 additions and 31 deletions

View File

@ -870,10 +870,36 @@ static int view_get_lines_height(TEXT_BUFFER_VIEW_REC *view,
return height < view->height ? height : view->height; 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, static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
int linecount) int linecount)
{ {
int realcount, scroll; int realcount;
view_bookmarks_check(view, line); 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); 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 /* first line in the buffer - this is the most commonly
removed line.. */ removed line.. */
if (view->bottom_startline == line) { if (view->bottom_startline == line) {
@ -900,39 +926,24 @@ static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
/* removing the first line in screen */ /* removing the first line in screen */
realcount = view_scroll(view, &view->startline, realcount = view_scroll(view, &view->startline,
&view->subline, &view->subline,
linecount, TRUE); linecount, FALSE);
view->ypos -= realcount; view->ypos -= realcount;
view->empty_linecount += linecount-realcount; view->empty_linecount += linecount-realcount;
} }
} else if (textbuffer_line_exists_after(view->bottom_startline, } else {
line)) { if (textbuffer_line_exists_after(view->bottom_startline,
realcount = view_scroll(view, &view->bottom_startline, line)) {
&view->bottom_subline, realcount = view_scroll(view, &view->bottom_startline,
-linecount, FALSE); &view->bottom_subline,
if (view->bottom) { -linecount, FALSE);
/* we're at the bottom, remove the same amount as view->empty_linecount += linecount-realcount;
from bottom_startline */ }
view_scroll(view, &view->startline,
&view->subline, -linecount, TRUE); if (textbuffer_line_exists_after(view->startline,
view->ypos -= linecount-realcount; line)) {
} else { view_remove_line_update_startline(view, line,
if (view->startline == line) { linecount);
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;
} }
view->bottom = view_is_bottom(view); view->bottom = view_is_bottom(view);

View File

@ -308,6 +308,8 @@ void textbuffer_remove(TEXT_BUFFER_REC *buffer, LINE_REC *line)
line->next : line->prev; line->next : line->prev;
} }
line->prev = line->next = NULL;
buffer->lines_count--; buffer->lines_count--;
textbuffer_line_unref(buffer, line); textbuffer_line_unref(buffer, line);
} }