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
|
--- newt-0.52.2/checkboxtree.c.dwchar 2006-08-04 13:41:28.000000000 +0200
+++ newt-0.52.2/checkboxtree.c 2006-08-04 13:41:28.000000000 +0200
@@ -490,8 +490,17 @@
currRow = co->top + i;
}
- SLsmg_write_nstring((*item)->text, co->width - 4 -
- (3 * (*item)->depth));
+ j = 4 + (3 * (*item)->depth);
+ SLsmg_write_nstring(NULL, co->width - j);
+ newtGotorc(co->top + i, co->left + j);
+ if (wstrlen((*item)->text, -1) > co->width - j) {
+ char *tmp;
+ tmp = strdup((*item)->text);
+ trim_string(tmp, co->width - j);
+ SLsmg_write_string(tmp);
+ free(tmp);
+ } else
+ SLsmg_write_string((*item)->text);
item++;
i++;
--- newt-0.52.2/newt_pr.h.dwchar 2005-09-30 16:05:55.000000000 +0200
+++ newt-0.52.2/newt_pr.h 2006-08-04 13:41:28.000000000 +0200
@@ -82,5 +82,6 @@
int _newt_wstrlen(const char *str, int len);
#define wstrlen(str,len) _newt_wstrlen((str),(len))
+void trim_string(char *title, int chrs);
#endif /* H_NEWT_PR */
--- newt-0.52.2/listbox.c.dwchar 2006-08-04 13:41:28.000000000 +0200
+++ newt-0.52.2/listbox.c 2006-08-04 13:41:28.000000000 +0200
@@ -527,7 +527,16 @@
else
SLsmg_set_color(NEWT_COLORSET_LISTBOX);
- SLsmg_write_nstring(item->text, li->curWidth);
+ SLsmg_write_nstring(NULL, li->curWidth);
+ newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust);
+ if (wstrlen(item->text, -1) > li->curWidth) {
+ char *tmp;
+ tmp = strdup(item->text);
+ trim_string(tmp, li->curWidth);
+ SLsmg_write_string(tmp);
+ free(tmp);
+ } else
+ SLsmg_write_string(item->text);
if (li->flags & NEWT_FLAG_MULTIPLE) {
newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust);
--- newt-0.52.2/newt.c.dwchar 2006-08-04 13:41:28.000000000 +0200
+++ newt-0.52.2/newt.c 2006-08-04 13:41:28.000000000 +0200
@@ -184,12 +184,13 @@
void trim_string(char *title, int chrs)
{
char *p = title;
- int ln = chrs;
+ int ln;
int x = 0,y = 0;
wchar_t tmp;
mbstate_t ps;
memset(&ps, 0, sizeof(ps));
+ ln = strlen(title);
while (*p) {
x = mbrtowc(&tmp, p, ln, &ps);
@@ -198,12 +199,13 @@
return;
}
y = wcwidth(tmp);
- if (y > ln) {
+ if (y > chrs) {
*p = '\0';
return;
} else {
p += x;
- ln -= y;
+ ln -= x;
+ chrs -= y;
}
}
}
@@ -638,10 +640,10 @@
currentWindow->height = height;
currentWindow->title = title ? strdup(title) : NULL;
- currentWindow->buffer = malloc(sizeof(SLsmg_Char_Type) * (width + 3) * (height + 3));
+ currentWindow->buffer = malloc(sizeof(SLsmg_Char_Type) * (width + 5) * (height + 3));
row = top - 1;
- col = left - 1;
+ col = left - 2;
/* clip to the current screen bounds - msw */
if (row < 0)
row = 0;
@@ -655,8 +657,8 @@
for (j = 0; j < height + 3; j++, row++) {
SLsmg_gotorc(row, col);
SLsmg_read_raw(currentWindow->buffer + n,
- currentWindow->width + 3);
- n += currentWindow->width + 3;
+ currentWindow->width + 5);
+ n += currentWindow->width + 5;
}
newtTrashScreen();
@@ -732,7 +734,7 @@
row = col = 0;
row = currentWindow->top - 1;
- col = currentWindow->left - 1;
+ col = currentWindow->left - 2;
if (row < 0)
row = 0;
if (col < 0)
@@ -740,8 +742,8 @@
for (j = 0; j < currentWindow->height + 3; j++, row++) {
SLsmg_gotorc(row, col);
SLsmg_write_raw(currentWindow->buffer + n,
- currentWindow->width + 3);
- n += currentWindow->width + 3;
+ currentWindow->width + 5);
+ n += currentWindow->width + 5;
}
free(currentWindow->buffer);
|