# HG changeset patch # User Sadrul Habib Chowdhury # Date 1185728930 0 # Node ID c3d0b51d6c60f431add4e276295ea3405745d616 # Parent 1ad1a4e8dfeafa2a89b8d3686597766b5af2393d New flag to show text top-aligned in a textview. diff -r 1ad1a4e8dfea -r c3d0b51d6c60 finch/libgnt/gnttextview.c --- 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) { diff -r 1ad1a4e8dfea -r c3d0b51d6c60 finch/libgnt/gnttextview.h --- 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