Showing 1 changed files with 32 additions and 10 deletions
+32 -10
Nasal/menu.nas
... ...
@@ -176,27 +176,49 @@ var pageClass = {
176 176
             # - plus other 10 from the window border and the text
177 177
             # - font size tends to be 10x24
178 178
             # - let 8+8 around the separator
179
-            var textWidth = 200;
179
+            var textWidth = 0;
180 180
             var lines = 0;
181
+            var _textWidth = 0;
181 182
             forindex (var o; objects) {
182
-                if (contains(objects[o], 'text')) {
183
+                if (find('end-of-line', objects[o].type) > -1) {
183 184
                     if (scroll != nil and contains(scroll, 'lines')) {
184
-                        if (contains(objects[o], 'scrollgroup'))
185
+                        if (contains(objects[o], 'scrollgroup')) {
185 186
                             if (objects[o].scrollgroup < scroll.lines)
186 187
                                 lines += 1;
188
+                            _textWidth += size(objects[o].text) * 10;
189
+                            if (_textWidth > textWidth) textWidth = _textWidth;
190
+                            _textWidth = 0;
191
+                        }
192
+                        else {
193
+                            lines += 1;
194
+                            _textWidth += size(objects[o].text) * 10;
195
+                            if (_textWidth > textWidth) textWidth = _textWidth;
196
+                            _textWidth = 0;
197
+                        }
187 198
                     }
188
-                    else
199
+                    else {
189 200
                         lines += 1;
190
-                    var l = size(objects[o].text) * 10;
191
-                    if (l > textWidth)
192
-                        textWidth = l;
201
+                        _textWidth += size(objects[o].text) * 10;
202
+                        if (_textWidth > textWidth) textWidth = _textWidth;
203
+                        _textWidth = 0;
204
+                    }
193 205
                 }
206
+                elsif (objects[o].type == 'title') {
207
+                    lines += 1;
208
+                    _textWidth = size(objects[o].text) * 10;
209
+                    if (_textWidth > textWidth) textWidth = _textWidth;
210
+                    _textWidth = 0;
211
+                }
212
+                elsif (objects[o].type != 'separator') {
213
+                    _textWidth += size(objects[o].text) * 10;
214
+                }
215
+
194 216
                 if (contains(objects[o], 'type') and objects[o].type == 'separator')
195 217
                     geometry.sep += 1;
196 218
             }
197
-            if (!contains(geometry, 'l')) geometry.l  = lines;
198
-            if (!contains(geometry, 'x')) geometry.x  = 1014 - textWidth;
199
-            if (!contains(geometry, 'y')) geometry.y  = 758 - (lines * 24) - 72; # 72 = offset from bottom to let softkeys display and margin
219
+            if (!contains(geometry, 'l')) geometry.l = lines;
220
+            if (!contains(geometry, 'x')) geometry.x = 1014 - textWidth;
221
+            if (!contains(geometry, 'y')) geometry.y = 758 - (lines * 24) - 72; # 72 = offset from bottom to let softkeys display and margin
200 222
             if (!contains(geometry, 'w')) geometry.w = textWidth;
201 223
         }
202 224
         if (!contains(geometry, 'h') and !contains(geometry, 'l')) {