comparison 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
comparison
equal deleted inserted replaced
18718:1ad1a4e8dfea 18719:c3d0b51d6c60
66 { 66 {
67 GntTextView *view = GNT_TEXT_VIEW(widget); 67 GntTextView *view = GNT_TEXT_VIEW(widget);
68 int i = 0; 68 int i = 0;
69 GList *lines; 69 GList *lines;
70 int rows, scrcol; 70 int rows, scrcol;
71 int comp = 0; /* Used for top-aligned text */
71 gboolean has_scroll = !(view->flags & GNT_TEXT_VIEW_NO_SCROLL); 72 gboolean has_scroll = !(view->flags & GNT_TEXT_VIEW_NO_SCROLL);
72 73
73 wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL)); 74 wbkgd(widget->window, COLOR_PAIR(GNT_COLOR_NORMAL));
74 werase(widget->window); 75 werase(widget->window);
76
77 if ((view->flags & GNT_TEXT_VIEW_TOP_ALIGN) &&
78 g_list_length(view->list) < widget->priv.height) {
79 GList *now = view->list;
80 comp = widget->priv.height - g_list_length(view->list);
81 view->list = g_list_nth_prev(view->list, comp);
82 if (!view->list) {
83 view->list = g_list_first(now);
84 comp = widget->priv.height - g_list_length(view->list);
85 } else {
86 comp = 0;
87 }
88 }
75 89
76 for (i = 0, lines = view->list; i < widget->priv.height && lines; i++, lines = lines->next) 90 for (i = 0, lines = view->list; i < widget->priv.height && lines; i++, lines = lines->next)
77 { 91 {
78 GList *iter; 92 GList *iter;
79 GntTextLine *line = lines->data; 93 GntTextLine *line = lines->data;
80 94
81 wmove(widget->window, widget->priv.height - 1 - i, 0); 95 wmove(widget->window, widget->priv.height - 1 - i - comp, 0);
82 96
83 for (iter = line->segments; iter; iter = iter->next) 97 for (iter = line->segments; iter; iter = iter->next)
84 { 98 {
85 GntTextSegment *seg = iter->data; 99 GntTextSegment *seg = iter->data;
86 char *end = view->string->str + seg->end; 100 char *end = view->string->str + seg->end;