Gentoo Archives: gentoo-commits

From: "Harald van Dijk (truedfx)" <truedfx@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-portage/ufed/files: ufed-0.40-termsize-2.patch
Date: Thu, 18 Jun 2009 17:16:21
Message-Id: E1MHLDo-00063v-1V@stork.gentoo.org
1 truedfx 09/06/18 17:16:20
2
3 Added: ufed-0.40-termsize-2.patch
4 Log:
5 Support flags with too many descriptions to fit on one screen (#273309 by ulm)
6 (Portage version: 2.2_rc33/cvs/Linux i686)
7
8 Revision Changes Path
9 1.1 app-portage/ufed/files/ufed-0.40-termsize-2.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-portage/ufed/files/ufed-0.40-termsize-2.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-portage/ufed/files/ufed-0.40-termsize-2.patch?rev=1.1&content-type=text/plain
13
14 Index: ufed-0.40-termsize-2.patch
15 ===================================================================
16
17 Allow termsizes as small as allowing only one line in the list.
18 Bug #273309 by ulm
19
20 --- ufed-0.40/ufed-curses.c
21 +++ ufed-0.40/ufed-curses.c
22 @@ -21,7 +21,7 @@
23 static const struct key *keys;
24
25 static struct item *items, *currentitem;
26 -int topy, minheight, minwidth;
27 +int topy, minwidth;
28
29 static void checktermsize(void);
30
31 @@ -53,7 +53,7 @@
32 }
33
34 static void checktermsize(void) {
35 - while(wHeight(List) < minheight
36 + while(wHeight(List) < 1
37 || wWidth(List) < minwidth) {
38 #ifdef KEY_RESIZE
39 clear();
40 @@ -227,32 +227,13 @@
41 }
42
43 void scrollcurrent(void) {
44 - int oldtopy = topy;
45 if(currentitem->top < topy)
46 - topy = currentitem->top;
47 + topy = max(currentitem->top, currentitem->top+currentitem->height-wHeight(List));
48 else if(currentitem->top+currentitem->height > topy+wHeight(List))
49 - topy = currentitem->top+currentitem->height-wHeight(List);
50 + topy = min(currentitem->top+currentitem->height-wHeight(List), currentitem->top);
51 else
52 return;
53 - if(abs(topy-oldtopy)>wHeight(List)) {
54 - drawitems();
55 + drawitems();
56 - } else {
57 - struct item *item = currentitem;
58 - scrollok(win(List), TRUE);
59 - wscrl(win(List), topy-oldtopy);
60 - scrollok(win(List), FALSE);
61 - if(topy<oldtopy)
62 - while((item=item->next)!=items
63 - && item->top < oldtopy
64 - && item->top < topy + wHeight(List))
65 - (*drawitem)(item, FALSE);
66 - else
67 - while((item=item->prev)->next!=items
68 - && item->top > oldtopy
69 - && item->top + item->height-1 >= topy)
70 - (*drawitem)(item, FALSE);
71 - mvwhline(win(List), wHeight(List), 0, ' ', wWidth(List));
72 - }
73 drawscrollbar();
74 }
75
76 @@ -282,8 +263,8 @@
77 window[w].win = newwin(wHeight(w), wWidth(w), wTop(w), wLeft(w));
78 } }
79 /* this won't work for the help viewer, but it doesn't use yesno() */
80 - currentitem = items;
81 topy = 0;
82 + scrollcurrent();
83 draw();
84 wattrset(win(Input), COLOR_PAIR(4) | A_BOLD | A_REVERSE);
85 mvwhline(win(Input), 0, 0, ' ', wWidth(Input));
86 @@ -463,7 +444,11 @@
87
88 switch(c) {
89 case KEY_UP:
90 - if(currentitem!=items) {
91 + if(currentitem->top<topy) {
92 + (*drawitem)(currentitem, FALSE);
93 + topy--;
94 + (*drawitem)(currentitem, TRUE);
95 + } else if(currentitem!=items || topy>currentitem->top) {
96 (*drawitem)(currentitem, FALSE);
97 currentitem = currentitem->prev;
98 scrollcurrent();
99 @@ -472,7 +457,11 @@
100 break;
101
102 case KEY_DOWN:
103 - if(currentitem->next!=items) {
104 + if(currentitem->top+currentitem->height>topy+wHeight(List)) {
105 + (*drawitem)(currentitem, FALSE);
106 + topy++;
107 + (*drawitem)(currentitem, TRUE);
108 + } else if(currentitem->next!=items) {
109 (*drawitem)(currentitem, FALSE);
110 currentitem = currentitem->next;
111 scrollcurrent();
112 @@ -484,9 +473,9 @@
113 if(currentitem!=items) {
114 struct item *olditem = currentitem;
115 (*drawitem)(currentitem, FALSE);
116 + do currentitem = currentitem->prev;
117 while(currentitem!=items
118 - && olditem->top - currentitem->prev->top <= wHeight(List))
119 + && olditem->top - currentitem->prev->top <= wHeight(List));
120 - currentitem = currentitem->prev;
121 scrollcurrent();
122 (*drawitem)(currentitem, TRUE);
123 }
124 @@ -496,10 +485,10 @@
125 if(currentitem->next!=items) {
126 struct item *olditem = currentitem;
127 (*drawitem)(currentitem, FALSE);
128 + do currentitem = currentitem->next;
129 while(currentitem->next!=items
130 && (currentitem->next->top + currentitem->next->height)
131 - - (olditem->top + olditem->height) <= wHeight(List))
132 + - (olditem->top + olditem->height) <= wHeight(List));
133 - currentitem = currentitem->next;
134 scrollcurrent();
135 (*drawitem)(currentitem, TRUE);
136 }
137 @@ -531,11 +520,11 @@
138 delwin(window[w].win);
139 window[w].win = newwin(wHeight(w), wWidth(w), wTop(w), wLeft(w));
140 } }
141 - if(result==-1)
142 + if(result==-1) {
143 - currentitem = items;
144 + topy = 0;
145 + scrollcurrent();
146 - else
147 + } else
148 items = currentitem;
149 - topy = 0;
150 draw();
151 break;
152 #endif
153 --- ufed-0.40/ufed-curses-checklist.c
154 +++ ufed-0.40/ufed-curses-checklist.c
155 @@ -109,8 +109,6 @@
156 flag->state = &line[state.start];
157
158 flag->item.height = ndescr;
159 - if(ndescr > minheight)
160 - minheight = ndescr;
161 { int i; for(i=0; i<ndescr; i++) {
162 flag->descr[i] = getline(input);
163 } }
164 @@ -174,11 +172,12 @@
165 wattrset(win(List), COLOR_PAIR(3));
166 else
167 wattrset(win(List), COLOR_PAIR(3) | A_BOLD | A_REVERSE);
168 - if(y < 0) {
169 + if(y >= 0 || -y >= flag->item.height) {
170 + d = &flag->descr[0];
171 + } else {
172 wmove(win(List), 0, 0);
173 d = &flag->descr[-y];
174 y = 0;
175 - goto descriptiononly;
176 }
177 wmove(win(List), y, 0);
178 sprintf(buf, " %c%c%c %-*s %-5.5s ",
179 @@ -187,7 +186,6 @@
180 flag->on == ' ' ? ')' : ']',
181 minwidth-12, flag->name,
182 flag->state);
183 - d = &flag->descr[0];
184 if(d != &flag->descr[flag->item.height]) {
185 for(;;) {
186 sprintf(buf+minwidth, "%-*.*s",
187 @@ -198,7 +196,6 @@
188 waddstr(win(List), buf);
189 d++;
190 y++;
191 - descriptiononly:
192 if(d!=&flag->descr[flag->item.height] && y<wHeight(List)) {
193 char *p;
194 for(p=buf; p!=buf+minwidth; p++)
195 @@ -214,7 +211,7 @@
196 y++;
197 }
198 if(highlight)
199 - wmove(win(List), flag->item.top - topy, 2);
200 + wmove(win(List), max(flag->item.top - topy, 0), 2);
201 wnoutrefresh(win(List));
202 }
203
204 --- ufed-0.40/ufed-curses.h
205 +++ ufed-0.40/ufed-curses.h
206 @@ -45,6 +45,8 @@
207 static inline int wLeft (enum win w) { return (window[w].left >= 0 ? 0 : COLS ) + window[w].left ; }
208 static inline int wHeight(enum win w) { return (window[w].height > 0 ? 0 : LINES) + window[w].height; }
209 static inline int wWidth (enum win w) { return (window[w].width > 0 ? 0 : COLS ) + window[w].width ; }
210 +static inline int min(int a, int b) { return a < b ? a : b; }
211 +static inline int max(int a, int b) { return a > b ? a : b; }
212
213 -extern int minheight, minwidth;
214 +extern int minwidth;
215 extern int topy;