aboutsummaryrefslogtreecommitdiffstats
path: root/po/ms.pom
blob: 16e81b46253d940d316bb5355ab4b5085760c559 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Workstation"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Graphical Environment"
msgstr "Grafikal"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Server"
msgstr "Pelayan"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Office Workstation"
msgstr "Pejabat"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid ""
"Office programs: wordprocessors (kword, abiword), spreadsheets (kspread, "
"gnumeric), pdf viewers, etc"
msgstr "Pejabat"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Game station"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Amusement programs: arcade, boards, strategy, etc"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Multimedia station"
msgstr "Multimedia"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Sound and video playing/editing programs"
msgstr "Bunyi dan"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Internet station"
msgstr "Internet"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid ""
"Set of tools to read and send mail and news (mutt, tin..) and to browse the "
"Web"
msgstr "dan dan dan"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Network Computer (client)"
msgstr "Rangkaian"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Clients for different protocols including ssh"
msgstr "protokol"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Tools to ease the configuration of your computer"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Scientific Workstation"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Scientific applications such as gnuplot"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Console Tools"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Editors, shells, file tools, terminals"
msgstr "Penyunting fail"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "KDE Workstation"
msgstr "KDE"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid ""
"The K Desktop Environment, the basic graphical environment with a collection "
"of accompanying tools"
msgstr "Desktop Persekitaran asas"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Gnome Workstation"
msgstr "Gnome"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid ""
"A graphical environment with user-friendly set of applications and desktop "
"tools"
msgstr "A pengguna dan"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Other Graphical Desktops"
msgstr "Lain-lain Grafikal"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Icewm, Window Maker, Enlightenment, Fvwm, etc"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "C and C++ development libraries, programs and include files"
msgstr "C dan C dan"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Documentation"
msgstr "Dokumentasi"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Books and Howto's on Linux and Free Software"
msgstr "dan on dan Bebas"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "LSB"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Linux Standard Base. Third party applications support"
msgstr "Asas"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Web/FTP"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Apache, Pro-ftpd"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Postfix mail server"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Database"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "PostgreSQL or MySQL database server"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "Firewall/Router"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Internet gateway"
msgstr "Internet"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "DNS/NIS "
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Domain Name and Network Information Server"
msgstr "Domain Nama dan Rangkaian Maklumat"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Network Computer server"
msgstr "Rangkaian"

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
msgid "NFS server, SMB server, Proxy server, ssh server"
msgstr ""

# DO NOT BOTHER TO MODIFY HERE, BUT IN DRAKX PO
#: ../../share/compssUsers:999
#, fuzzy
msgid "Set of tools to read and send mail and news and to browse the Web"
msgstr "dan dan dan"

a> 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
/* This goofed-up box whacked into shape by Elliot Lee <sopwith@cuc.edu>
   (from the original listbox by Erik Troan <ewt@redhat.com>)
   and contributed to newt for use under the LGPL license.
   Copyright (C) 1996, 1997 Elliot Lee */

#include <slang.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include "newt.h"
#include "newt_pr.h"


/* Linked list of items in the listbox */
struct items {
    char * text;
    const void *data;
    unsigned char isSelected;
    struct items *next;
};

/* Holds all the relevant information for this listbox */
struct listbox {
    newtComponent sb;   /* Scrollbar on right side of listbox */
    int curWidth;	/* size of text w/o scrollbar or border*/
    int curHeight;	/* size of text w/o border */
    int sbAdjust;
    int bdxAdjust, bdyAdjust;
    int numItems, numSelected;
    int userHasSetWidth;
    int currItem, startShowItem; /* startShowItem is the first item displayed
				   on the screen */
    int isActive; /* If we handle key events all the time, it seems
		     to do things even when they are supposed to be for
		     another button/whatever */
    struct items *boxItems;
    int grow;
    int flags; /* flags for this listbox, right now just
		  NEWT_FLAG_RETURNEXIT */
};

static void listboxDraw(newtComponent co);
static void listboxDestroy(newtComponent co);
static struct eventResult listboxEvent(newtComponent co, struct event ev);
static void newtListboxRealSetCurrent(newtComponent co);
static void listboxPlace(newtComponent co, int newLeft, int newTop);
static inline void updateWidth(newtComponent co, struct listbox * li,
				int maxField);
static void listboxMapped(newtComponent co, int isMapped);

static struct componentOps listboxOps = {
    listboxDraw,
    listboxEvent,
    listboxDestroy,
    listboxPlace,
    listboxMapped,
};

static void listboxMapped(newtComponent co, int isMapped) {
    struct listbox * li = co->data;

    co->isMapped = isMapped;
    if (li->sb)
	li->sb->ops->mapped(li->sb, isMapped);
}

static void listboxPlace(newtComponent co, int newLeft, int newTop) {
    struct listbox * li = co->data;

    co->top = newTop;
    co->left = newLeft;

    if (li->sb)
	li->sb->ops->place(li->sb, co->left + co->width - li->bdxAdjust - 1,
			   co->top);
}

newtComponent newtListbox(int left, int top, int height, int flags) {
    newtComponent co, sb;
    struct listbox * li;

    if (!(co = malloc(sizeof(*co))))
	return NULL;

    if (!(li = malloc(sizeof(struct listbox)))) {
	free(co);
	return NULL;
    }

    li->boxItems = NULL;
    li->numItems = 0;
    li->currItem = 0;
    li->numSelected = 0;
    li->isActive = 0;
    li->userHasSetWidth = 0;
    li->startShowItem = 0;
    li->sbAdjust = 0;
    li->bdxAdjust = 0;
    li->bdyAdjust = 0;
    li->flags = flags & (NEWT_FLAG_RETURNEXIT | NEWT_FLAG_BORDER |
			 NEWT_FLAG_MULTIPLE);

    if (li->flags & NEWT_FLAG_BORDER) {
	li->bdxAdjust = 2;
	li->bdyAdjust = 1;
    }

    co->height = height;
    li->curHeight = co->height - (2 * li->bdyAdjust);

    if (height) {
	li->grow = 0;
	if (flags & NEWT_FLAG_SCROLL) {
	    sb = newtVerticalScrollbar(left, top + li->bdyAdjust,
					li->curHeight,
					COLORSET_LISTBOX, COLORSET_ACTLISTBOX);
	    li->sbAdjust = 3;
	} else {
	    sb = NULL;
	}
    } else {
	li->grow = 1;
	sb = NULL;
    }

    li->sb = sb;
    co->data = li;
    co->isMapped = 0;
    co->left = left;
    co->top = top;
    co->ops = &listboxOps;
    co->takesFocus = 1;
    co->callback = NULL;

    updateWidth(co, li, 5);

    return co;
}

static inline void updateWidth(newtComponent co, struct listbox * li,
				int maxField) {
    li->curWidth = maxField;
    co->width = li->curWidth + li->sbAdjust + 2 * li->bdxAdjust;

    if (li->sb)
	li->sb->left = co->left + co->width - li->bdxAdjust - 1;
}

void newtListboxSetCurrentByKey(newtComponent co, void * key) {
    struct listbox * li = co->data;
    struct items * item;
    int i;

    item = li->boxItems, i = 0;
    while (item && item->data != key)
	item = item->next, i++;

    if (item)
	newtListboxSetCurrent(co, i);
}

void newtListboxSetCurrent(newtComponent co, int num)
{
    struct listbox * li = co->data;

    if (num >= li->numItems)
	li->currItem = li->numItems - 1;
    else if (num < 0)
	li->currItem = 0;
    else
	li->currItem = num;

    if (li->currItem < li->startShowItem)
	li->startShowItem = li->currItem;
    else if (li->currItem - li->startShowItem > li->curHeight - 1)
	li->startShowItem = li->currItem - li->curHeight + 1;
    if (li->startShowItem + li->curHeight > li->numItems)
	li->startShowItem = li->numItems - li->curHeight;
    if(li->startShowItem < 0)
	li->startShowItem = 0;

    newtListboxRealSetCurrent(co);
}

static void newtListboxRealSetCurrent(newtComponent co)
{
    struct listbox * li = co->data;

    if(li->sb)
	newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
    listboxDraw(co);
    if(co->callback) co->callback(co, co->callbackData);
}

void newtListboxSetWidth(newtComponent co, int width) {
    struct listbox * li = co->data;

    co->width = width;
    li->curWidth = co->width - li->sbAdjust - 2 * li->bdxAdjust;
    li->userHasSetWidth = 1;
    if (li->sb) li->sb->left = co->width + co->left - 1;
    listboxDraw(co);
}

void * newtListboxGetCurrent(newtComponent co) {
    struct listbox * li = co->data;
    int i;
    struct items *item;

    for(i = 0, item = li->boxItems; item != NULL && i < li->currItem;
	i++, item = item->next);

    if (item)
	return (void *)item->data;
    else
	return NULL;
}

void newtListboxSelectItem(newtComponent co, const void * key,
	enum newtFlagsSense sense)
{
    struct listbox * li = co->data;
    int i;
    struct items * item;

    item = li->boxItems, i = 0;
    while (item && item->data != key)
	item = item->next, i++;

    if (!item) return;

    if (item->isSelected)
	li->numSelected--;

    switch(sense) {
	case NEWT_FLAGS_RESET:
		item->isSelected = 0; break;
	case NEWT_FLAGS_SET:
		item->isSelected = 1; break;
	case NEWT_FLAGS_TOGGLE:
		item->isSelected = !item->isSelected;
    }

    if (item->isSelected)
	li->numSelected++;

    listboxDraw(co);
}

void newtListboxClearSelection(newtComponent co)
{
    struct items *item;
    struct listbox * li = co->data;

    for(item = li->boxItems; item != NULL;
	item = item->next)
	item->isSelected = 0;
    li->numSelected = 0;
    listboxDraw(co);
}

/* Free the returned array after use, but NOT the values in the array */
void ** newtListboxGetSelection(newtComponent co, int *numitems)
{
    struct listbox * li;
    int i;
    void **retval;
    struct items *item;

    if(!co || !numitems) return NULL;

    li = co->data;
    if(!li || !li->numSelected) return NULL;

    retval = malloc(li->numSelected * sizeof(void *));
    for(i = 0, item = li->boxItems; item != NULL;
	item = item->next)
	if(item->isSelected)
	    retval[i++] = (void *)item->data;
    *numitems = li->numSelected;
    return retval;
}

void newtListboxSetEntry(newtComponent co, int num, const char * text) {
    struct listbox * li = co->data;
    int i;
    struct items *item;

    for(i = 0, item = li->boxItems; item != NULL && i < num;
	i++, item = item->next);

    if(!item)
	return;
    else {
	free(item->text);
	item->text = strdup(text);
    }
    if (li->userHasSetWidth == 0 && strlen(text) > (size_t)li->curWidth) {
	updateWidth(co, li, strlen(text));
    }

    if (num >= li->startShowItem && num <= li->startShowItem + co->height)
	listboxDraw(co);
}

void newtListboxSetData(newtComponent co, int num, void * data) {
    struct listbox * li = co->data;
    int i;
    struct items *item;

    for(i = 0, item = li->boxItems; item != NULL && i < num;
	i++, item = item->next);

    item->data = data;
}

int newtListboxAppendEntry(newtComponent co, const char * text,
	                const void * data) {
    struct listbox * li = co->data;
    struct items *item;

    if(li->boxItems) {
	for (item = li->boxItems; item->next != NULL; item = item->next);

	item = item->next = malloc(sizeof(struct items));
    } else {
	item = li->boxItems = malloc(sizeof(struct items));
    }

    if (!li->userHasSetWidth && text && (strlen(text) > (size_t)li->curWidth))
	updateWidth(co, li, strlen(text));

    item->text = strdup(text); item->data = data; item->next = NULL;
    item->isSelected = 0;

    if (li->grow)
	co->height++, li->curHeight++;
    li->numItems++;

    return 0;
}

int newtListboxInsertEntry(newtComponent co, const char * text,
	                   const void * data, void * key) {
    struct listbox * li = co->data;
    struct items *item, *t;

    if (li->boxItems) {
	if (key) {
	    item = li->boxItems;
	    while (item && item->data != key) item = item->next;

	    if (!item) return 1;

	    t = item->next;
	    item = item->next = malloc(sizeof(struct items));
	    item->next = t;
	} else {
	    t = li->boxItems;
	    item = li->boxItems = malloc(sizeof(struct items));
	    item->next = t;
	}
    } else if (key) {
	return 1;
    } else {
	item = li->boxItems = malloc(sizeof(struct items));
	item->next = NULL;
    }

    if (!li->userHasSetWidth && text && (strlen(text) > (size_t)li->curWidth))
	updateWidth(co, li, strlen(text));

    item->text = strdup(text?text:"(null)"); item->data = data;
    item->isSelected = 0;

    if (li->sb)
	li->sb->left = co->left + co->width - li->bdxAdjust - 1;
    li->numItems++;

    listboxDraw(co);

    return 0;
}

int newtListboxDeleteEntry(newtComponent co, void * key) {
    struct listbox * li = co->data;
    int widest = 0, t;
    struct items *item, *item2 = NULL;
    int num;

    if (li->boxItems == NULL || li->numItems <= 0)
	return 0;

    num = 0;

    item2 = NULL, item = li->boxItems;
    while (item && item->data != key) {
	item2 = item;
	item = item->next;
	num++;
    }

    if (!item)
	return -1;

    if (item2)
	item2->next = item->next;
    else
	li->boxItems = item->next;

    free(item->text);
    free(item);
    li->numItems--;

    if (!li->userHasSetWidth) {
	widest = 0;
	for (item = li->boxItems; item != NULL; item = item->next)
	    if ((t = strlen(item->text)) > widest) widest = t;
    }

    if (li->currItem >= num)
	li->currItem--;

    if (!li->userHasSetWidth) {
	updateWidth(co, li, widest);
    }

    listboxDraw(co);

    return 0;
}

void newtListboxClear(newtComponent co)
{
    struct listbox * li;
    struct items *anitem, *nextitem;
    if(co == NULL || (li = co->data) == NULL)
	return;
    for(anitem = li->boxItems; anitem != NULL; anitem = nextitem) {
	nextitem = anitem->next;
	free(anitem->text);
	free(anitem);
    }
    li->numItems = li->numSelected = li->currItem = li->startShowItem = 0;
    li->boxItems = NULL;
    if (!li->userHasSetWidth)
	updateWidth(co, li, 5);
}

/* If you don't want to get back the text, pass in NULL for the ptr-ptr. Same
   goes for the data. */
void newtListboxGetEntry(newtComponent co, int num, char **text, void **data) {
    struct listbox * li = co->data;
    int i;
    struct items *item;

    if (!li->boxItems || num >= li->numItems) {
	if(text)
	    *text = NULL;
	if(data)
	    *data = NULL;
	return;
    }

    i = 0;
    item = li->boxItems;
    while (item && i < num) {
	i++, item = item->next;
    }

    if (item) {
	if (text)
	    *text = item->text;
	if (data)
	    *data = (void *)item->data;
    }
}

static void listboxDraw(newtComponent co)
{
    struct listbox * li = co->data;
    struct items *item;
    int i, j;

    if (!co->isMapped) return ;

    if(li->flags & NEWT_FLAG_BORDER) {
      if(li->isActive)
	  SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
      else
          SLsmg_set_color(NEWT_COLORSET_LISTBOX);

      newtDrawBox(co->left, co->top, co->width, co->height, 0);
    }

    if(li->sb)
	li->sb->ops->draw(li->sb);

    SLsmg_set_color(NEWT_COLORSET_LISTBOX);

    for(i = 0, item = li->boxItems; item != NULL && i < li->startShowItem;
	i++, item = item->next);

    j = i;

    for (i = 0; item != NULL && i < li->curHeight; i++, item = item->next) {
	if (!item->text) continue;

	newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust);
	if(j + i == li->currItem) {
	    if(item->isSelected)
		SLsmg_set_color(NEWT_COLORSET_ACTSELLISTBOX);
	    else
		SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
	} else if(item->isSelected)
	    SLsmg_set_color(NEWT_COLORSET_SELLISTBOX);
	else
	    SLsmg_set_color(NEWT_COLORSET_LISTBOX);

	SLsmg_write_nstring(item->text, li->curWidth);

    }
    newtGotorc(co->top + (li->currItem - li->startShowItem), co->left);
}

static struct eventResult listboxEvent(newtComponent co, struct event ev) {
    struct eventResult er;
    struct listbox * li = co->data;
    struct items *item;
    int i;
    
    er.result = ER_IGNORED;

    if(ev.when == EV_EARLY || ev.when == EV_LATE) {
	return er;
    }

    switch(ev.event) {
      case EV_KEYPRESS:
	if (!li->isActive) break;

	switch(ev.u.key) {
	  case ' ':
	    if(!(li->flags & NEWT_FLAG_MULTIPLE)) break;
	    newtListboxSelectItem(co, li->boxItems[li->currItem].data,
				  NEWT_FLAGS_TOGGLE);
	    er.result = ER_SWALLOWED;
	    /* We don't break here, because it is cool to be able to
	       hold space to select a bunch of items in a list at once */

	  case NEWT_KEY_DOWN:
	    if(li->numItems <= 0) break;
	    if(li->currItem < li->numItems - 1) {
		li->currItem++;
		if(li->currItem > (li->startShowItem + li->curHeight - 1)) {
		    li->startShowItem = li->currItem - li->curHeight + 1;
		    if(li->startShowItem + li->curHeight > li->numItems)
			li->startShowItem = li->numItems - li->curHeight;
		}
		if(li->sb)
		    newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
		listboxDraw(co);
	    }
	    if(co->callback) co->callback(co, co->callbackData);
	    er.result = ER_SWALLOWED;
	    break;

	  case NEWT_KEY_ENTER:
	    if(li->numItems <= 0) break;
	    if(li->flags & NEWT_FLAG_RETURNEXIT)
		er.result = ER_EXITFORM;
	    break;

	  case NEWT_KEY_UP:
	    if(li->numItems <= 0) break;
	    if(li->currItem > 0) {
		li->currItem--;
		if(li->currItem < li->startShowItem)
		    li->startShowItem = li->currItem;
		if(li->sb)
		    newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
		listboxDraw(co);
	    }