Skip to content

Commit 7d3c09f

Browse files
DeskTop: Fix display of long device names in Format/Erase picker
Long names could be longer than the item width in the Format/Erase volume picker, leading to truncation and spilling over the edge of the control. Add in ellipsifying to the routine. Perhaps a better fix would be to increase the size of the dialog, but since it is shared with other DeskTop dialogs that's more work. Maybe in the future.
1 parent 17c35a2 commit 7d3c09f

File tree

7 files changed

+106
-4
lines changed

7 files changed

+106
-4
lines changed

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Project Page: https://github.com/a2stuff/a2d
4747
* Set empty window maprect so that when restored with new file scrollbars are inactive.
4848
* Fix volume icon flicker after Check All Drives for removable disks.
4949
* Select volume icomn after Format/Erase.
50+
* Fix display of long device names in Format/Erase volume picker.
5051

5152
### Selector
5253

src/desktop/APIs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Desk Accessories:
1010
* [LineEdit ToolKit](../toolkits/LETK.md)
1111
* [Button ToolKit](../toolkits/BTK.md)
1212
* [ListBox ToolKit](../toolkits/LBTK.md)
13+
* [Option Picker ToolKit](../toolkits/OPTK.md)
1314
* DeskTop Jump Table - simple JSR calls starting at $4003 MAIN, no arguments
1415
* Aux Entry Points
1516

src/desktop/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ When running, memory use includes:
122122
* [Icon ToolKit](APIs.md)
123123
* [LineEdit ToolKit](../toolkits/LETK.md)
124124
* [Button ToolKit](../toolkits/BTK.md)
125+
* [ListBox ToolKit](../toolkits/LBTK.md)
126+
* [Option Picker ToolKit](../toolkits/OPTK.md)
125127
* Alert dialog resources/code
126128

127129
...and in the Aux language card area (accessible from both aux and

src/desktop/desktop.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
DEFSEG SegmentInvoker, $0290, $0160
3939

4040
;; Dynamically loaded overlays
41-
DEFSEG OverlayFormatErase, $0800, $0F00
41+
DEFSEG OverlayFormatErase, $0800, $1000
4242
DEFSEG OverlayShortcutPick, $5000, $0800
4343
DEFSEG OverlayFileDialog, $6000, $0A00
4444
DEFSEG OverlayFileCopy, $7000, $0100

src/desktop/ovl_format_erase.s

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,40 @@ no: RETURN A=#$80
359359

360360
;;; Input: A = index in `DEVLST`
361361
.proc DrawDeviceNameForIndex
362+
buf := text_buffer2
363+
ptr := $06
364+
365+
;; Look up device name in table
362366
asl a
363367
tay
364-
copy16 device_name_table,y, @addr
365-
MGTK_CALL MGTK::DrawString, SELF_MODIFIED, @addr
368+
copy16 device_name_table,y, ptr
369+
CALL main::CopyPtr1ToBuf, AX=#buf
370+
371+
PARAM_BLOCK string_width_params, $06
372+
str .addr
373+
width .word
374+
END_PARAM_BLOCK
375+
376+
;; Check the length; shrink until it fits
377+
copy16 #buf, string_width_params::str
378+
DO
379+
MGTK_CALL MGTK::StringWidth, string_width_params
380+
cmp16 string_width_params::width, #kVolPickerItemWidth
381+
BREAK_IF LT
382+
;; Shrink by one character, replace last 3 with "..."
383+
dec buf
384+
ldy buf
385+
lda #'.'
386+
ldx #3
387+
DO
388+
sta buf,y
389+
dey
390+
dex
391+
WHILE NOT ZERO
392+
WHILE NOT POS ; always
393+
394+
;; Draw it
395+
MGTK_CALL MGTK::DrawString, buf
366396
rts
367397
.endproc ; DrawDeviceNameForIndex
368398

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
--[[ BEGINCONFIG ========================================
2+
3+
MODELARGS="-aux ext80 -sl2 mouse \
4+
-sl7 scsi \
5+
-sl7:scsi:scsibus:6 harddisk \
6+
-sl7:scsi:scsibus:5 aplcdsc \
7+
-sl7:scsi:scsibus:4 aplcdsc \
8+
-sl7:scsi:scsibus:3 aplcdsc \
9+
-sl7:scsi:scsibus:2 aplcdsc \
10+
-sl7:scsi:scsibus:0 aplcdsc \
11+
-sl6 scsi \
12+
-sl6:scsi:scsibus:6 aplcdsc \
13+
-sl6:scsi:scsibus:5 aplcdsc \
14+
-sl6:scsi:scsibus:4 aplcdsc \
15+
-sl6:scsi:scsibus:3 aplcdsc \
16+
-sl6:scsi:scsibus:2 aplcdsc \
17+
"
18+
DISKARGS="\
19+
-hard1 $HARDIMG \
20+
"
21+
======================================== ENDCONFIG ]]
22+
23+
--[[
24+
* harddisk is: "SEAGATEST225N1" (Seagate ST-225N)
25+
* aplcdsc is: "SONYCD-ROMCDU-80" (Sony CD-ROM CDU-8002)
26+
* cdrom (id 1) is: "SONYCDU-76S1" (Sony CDU-765S)
27+
]]
28+
29+
a2d.ConfigureRepaintTime(5)
30+
31+
-- Callback called with func to invoke menu item; pass false if
32+
-- no volumes selected, true if volumes selected (affects menu item)
33+
function FormatEraseTest(name, func)
34+
test.Variants(
35+
{
36+
name .. " - Format",
37+
name .. " - Erase",
38+
},
39+
function(idx)
40+
a2d.CloseAllWindows()
41+
a2d.ClearSelection()
42+
func(
43+
function(vol_selected)
44+
if vol_selected then
45+
a2d.InvokeMenuItem(a2d.SPECIAL_MENU, a2d.SPECIAL_FORMAT_DISK+idx-1)
46+
else
47+
a2d.InvokeMenuItem(a2d.SPECIAL_MENU, a2d.SPECIAL_FORMAT_DISK-2+idx-1)
48+
end
49+
end)
50+
end)
51+
end
52+
53+
--[[
54+
Show the dialog. Snapshots verifying long device names don't mispaint.
55+
]]
56+
FormatEraseTest(
57+
"Long names",
58+
function(invoke)
59+
invoke(false)
60+
test.Snap("long names on device selection")
61+
for i = 1, 13 do
62+
apple2.DownArrowKey()
63+
end
64+
test.Snap("long names with selection device selection")
65+
a2d.DialogOK()
66+
test.Snap("long names erased after device selection")
67+
a2d.DialogCancel()
68+
end)

tests/desktop/format_erase_many_disks.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--[[ BEGINCONFIG ========================================
22
3-
MODELARGS="-aux ext80 -sl2 mouse '' \
3+
MODELARGS="-aux ext80 -sl2 mouse \
44
-sl7 scsi \
55
-sl7:scsi:scsibus:2 harddisk \
66
-sl7:scsi:scsibus:3 harddisk \

0 commit comments

Comments
 (0)