diff finch/libgnt/gnttextview.c @ 18719:c3d0b51d6c60

New flag to show text top-aligned in a textview.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 29 Jul 2007 17:08:50 +0000
parents fd01bac27b79
children 85b155a574a3
line wrap: on
line diff
--- a/finch/libgnt/gnttextview.c	Sun Jul 29 16:45:29 2007 +0000
+++ b/finch/libgnt/gnttextview.c	Sun Jul 29 17:08:50 2007 +0000
@@ -68,17 +68,31 @@
 	int i = 0;
 	GList *lines;
 	int rows, scrcol;
+	int comp = 0;          /* Used for top-aligned text */
 	gboolean has_scroll = !(view->flags & GNT_TEXT_VIEW_NO_SCROLL);
 
 	wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL));
 	werase(widget->window);
 
+	if ((view->flags & GNT_TEXT_VIEW_TOP_ALIGN) &&
+			g_list_length(view->list) < widget->priv.height) {
+		GList *now = view->list;
+		comp = widget->priv.height - g_list_length(view->list);
+		view->list = g_list_nth_prev(view->list, comp);
+		if (!view->list) {
+			view->list = g_list_first(now);
+			comp = widget->priv.height - g_list_length(view->list);
+		} else {
+			comp = 0;
+		}
+	}
+
 	for (i = 0, lines = view->list; i < widget->priv.height && lines; i++, lines = lines->next)
 	{
 		GList *iter;
 		GntTextLine *line = lines->data;
 
-		wmove(widget->window, widget->priv.height - 1 - i, 0);
+		wmove(widget->window, widget->priv.height - 1 - i - comp, 0);
 
 		for (iter = line->segments; iter; iter = iter->next)
 		{