changeset 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 1ad1a4e8dfea
children a69ab280147b
files finch/libgnt/gnttextview.c finch/libgnt/gnttextview.h
diffstat 2 files changed, 18 insertions(+), 2 deletions(-) [+]
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)
 		{
--- a/finch/libgnt/gnttextview.h	Sun Jul 29 16:45:29 2007 +0000
+++ b/finch/libgnt/gnttextview.h	Sun Jul 29 17:08:50 2007 +0000
@@ -47,9 +47,11 @@
 typedef struct _GntTextViewPriv		GntTextViewPriv;
 typedef struct _GntTextViewClass		GntTextViewClass;
 
-typedef enum _GntTextViewFlag {
+typedef enum
+{
 	GNT_TEXT_VIEW_NO_SCROLL     = 1 << 0,
 	GNT_TEXT_VIEW_WRAP_CHAR     = 1 << 1,
+	GNT_TEXT_VIEW_TOP_ALIGN     = 1 << 2,
 } GntTextViewFlag;
 
 struct _GntTextView