comparison console/libgnt/gnttree.c @ 13851:41753203a94d

[gaim-migrate @ 16310] The colors should now look 'better' in terminals that don't apparently allow changing colors. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 22 Jun 2006 22:38:03 +0000
parents 0e1e59770cb0
children bbf0470cb348
comparison
equal deleted inserted replaced
13850:0e1e59770cb0 13851:41753203a94d
45 GntWidget *widget = GNT_WIDGET(tree); 45 GntWidget *widget = GNT_WIDGET(tree);
46 GList *iter; 46 GList *iter;
47 47
48 wbkgd(tree->scroll, COLOR_PAIR(GNT_COLOR_NORMAL)); 48 wbkgd(tree->scroll, COLOR_PAIR(GNT_COLOR_NORMAL));
49 49
50 /* XXX: Add the rows */
51 for (start = tree->top, iter = g_list_nth(tree->list, tree->top); 50 for (start = tree->top, iter = g_list_nth(tree->list, tree->top);
52 iter && start < tree->bottom; start++, iter = iter->next) 51 iter && start < tree->bottom; start++, iter = iter->next)
53 { 52 {
54 char str[2096]; /* XXX: This should be safe for any terminal */ 53 char str[2096]; /* XXX: This should be safe for any terminal */
55 GntTreeRow *row = g_hash_table_lookup(tree->hash, iter->data); 54 GntTreeRow *row = g_hash_table_lookup(tree->hash, iter->data);
56 55
57 snprintf(str, widget->priv.width - 2, "%s\n", row->text); 56 if (snprintf(str, widget->priv.width, "%s\n", row->text) >= widget->priv.width)
57 {
58 /* XXX: ellipsize */
59 str[widget->priv.width - 1] = 0;
60 }
58 61
59 if (start == tree->current) 62 if (start == tree->current)
60 { 63 {
61 wbkgdset(tree->scroll, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); 64 wbkgdset(tree->scroll, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT));
62 mvwprintw(tree->scroll, start, 0, str); 65 mvwprintw(tree->scroll, start, 0, str);
81 { 84 {
82 GntTree *tree = GNT_TREE(widget); 85 GntTree *tree = GNT_TREE(widget);
83 86
84 /* For the Tree (or anything that scrolls), we will create a 'hidden' window 87 /* For the Tree (or anything that scrolls), we will create a 'hidden' window
85 * of 'large enough' size. We never wrefresh that hidden-window, instead we 88 * of 'large enough' size. We never wrefresh that hidden-window, instead we
86 * just 'scroll' it, and wrefresh the subwindow */ 89 * just copy stuff from it into the visible window */
87 90
88 if (tree->scroll == NULL) 91 if (tree->scroll == NULL)
89 { 92 {
90 tree->scroll = newwin(SCROLL_HEIGHT, widget->priv.width, widget->priv.y, widget->priv.x); 93 tree->scroll = newwin(SCROLL_HEIGHT, widget->priv.width, widget->priv.y, widget->priv.x);
91 scrollok(tree->scroll, TRUE); 94 scrollok(tree->scroll, TRUE);