jcs
/wifi_da
/amendments
/24
window: Properly truncate long SSIDs when joined
Reported by Tavis Hord
jcs made amendment 24 about 1 year ago
--- window.c Tue Oct 24 23:07:34 2023
+++ window.c Thu Oct 26 09:23:30 2023
@@ -98,7 +98,7 @@ update_window(bool force)
Str255 menuText;
GrafPtr savePort;
Point p;
- short i, icon;
+ short i, icon, x, w;
RgnHandle tmpRgn;
Rect r, destRect;
BitMap bm, cur_bits;
@@ -122,11 +122,26 @@ update_window(bool force)
LineTo(ssid_menu_rect.right, ssid_menu_rect.bottom);
MoveTo(ssid_menu_rect.right, ssid_menu_rect.top + 1);
LineTo(ssid_menu_rect.right, ssid_menu_rect.bottom);
- MoveTo(ssid_menu_rect.left + 15, 16);
+
TextFont(systemFont);
TextSize(0);
GetItem(ssid_menu, 1, &menuText);
- DrawString(menuText);
+ x = 15;
+ MoveTo(ssid_menu_rect.left + x, 16);
+
+ for (i = 1; i <= menuText[0]; i++) {
+ w = CharWidth(menuText[i]);
+ if (i < menuText[0] &&
+ x + w >= (ssid_menu_rect.right - ssid_menu_rect.left - 14)) {
+ /* truncate */
+ GetPen(&p);
+ MoveTo(p.h - 1, p.v);
+ DrawChar('…');
+ break;
+ }
+ DrawChar(menuText[i]);
+ x += w;
+ }
HLock(signal_icons);