summaryrefslogtreecommitdiff
path: root/src/fe-text
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-08-12 18:25:43 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-08-12 18:25:43 +0000
commit08b906202805f0cb6358e1ab0c057eaa5d8082dc (patch)
treee165c5f13ec1903a87bf46a55979b890a1f21c05 /src/fe-text
parent53c13065d26c6e116c66e73255297099dc973241 (diff)
downloadirssi-08b906202805f0cb6358e1ab0c057eaa5d8082dc.zip
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
Diffstat (limited to 'src/fe-text')
-rw-r--r--src/fe-text/textbuffer-view.c73
-rw-r--r--src/fe-text/textbuffer.c2
2 files changed, 44 insertions, 31 deletions
diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c
index 37434f55..e27a7826 100644
--- a/src/fe-text/textbuffer-view.c
+++ b/src/fe-text/textbuffer-view.c
@@ -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,39 +926,24 @@ 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,
- 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;
- }
+ } else {
+ if (textbuffer_line_exists_after(view->bottom_startline,
+ line)) {
+ realcount = view_scroll(view, &view->bottom_startline,
+ &view->bottom_subline,
+ -linecount, FALSE);
+ view->empty_linecount += linecount-realcount;
+ }
+
+ if (textbuffer_line_exists_after(view->startline,
+ line)) {
+ view_remove_line_update_startline(view, line,
+ linecount);
}
- view->empty_linecount += linecount-realcount;
}
view->bottom = view_is_bottom(view);
diff --git a/src/fe-text/textbuffer.c b/src/fe-text/textbuffer.c
index adf3334d..8b0c9469 100644
--- a/src/fe-text/textbuffer.c
+++ b/src/fe-text/textbuffer.c
@@ -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);
}