Skip to content

Commit afa22e5

Browse files
Selector: Ellipsify long paths in "Copying to RAMCard..." dialog
Fixes #867.
1 parent 4984ef8 commit afa22e5

16 files changed

+103
-83
lines changed

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Project Page: https://github.com/a2stuff/a2d
4949
### Selector
5050

5151
* Prevent crash after alert is shown from File > Run a Program... ([#832](https://github.com/a2stuff/a2d/issues/832))
52+
* Ellipsify long paths in "Copying to RAMCard..." dialog. ([#867](https://github.com/a2stuff/a2d/issues/867))
5253

5354
### Disk Copy
5455

res/notes/testplan.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,7 @@ Prerequisite: In DeskTop, Apple Menu > Control Panels > Options, check Show Shor
12361236
* Configure a shortcut for a program with many associated files to copy to RAMCard "at first use". Invoke the shortcut. Verify that the files are copied to the RAMCard, and that the program starts correctly. Return to Shortcuts by quitting the program. Eject the disk containing the program. Invoke the shortcut. Verify that the program starts correctly.
12371237
* Configure a shortcut for a folder (or another target type that can't be run outside of DeskTop, e.g. an image or desk accessory) to copy to RAMCard "at first use". Invoke the shortcut. When the "Unable to run the program." alert is shown, verify that the list of shortcuts renders correctly. Click OK. Verify that the list of shortcuts renders correctly.
12381238
* Configure a shortcut for a program with many associated files to copy to RAMCard "at first use". Invoke the shortcut. While the program's files are being copied to RAMCard, press Escape to cancel. Verify that not all of the files were copied to the RAMCard. Invoke the shortcut again. Verify that the files are copied to the RAMCard and that the program starts correctly.
1239+
* Configure a shortcut for a program with a long path to copy to RAMCard "at first use". Invoke the shortcut. Verify that long paths do not render over the dialog's frame.
12391240

12401241
* Configure a shortcut for the BINSCII system utility. Launch Shortcuts. Invoke the BINSCII system file. Verify that the display is not truncated.
12411242

src/desktop/main.s

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -13847,75 +13847,7 @@ cursor_ibeam_flag: ; high bit set if I-beam, clear if pointer
1384713847
FALL_THROUGH_TO DrawDialogPath
1384813848
.endproc ; DrawDialogPathBuf0
1384913849

13850-
;;; Draw a path (long string) in the progress dialog by without intruding
13851-
;;; into the border. If the string is too long, it is shrunk from the
13852-
;;; center with "..." inserted.
13853-
;;; Inputs: A,X = string address
13854-
;;; Trashes $06...$0C
13855-
.proc DrawDialogPath
13856-
ptr := $6
13857-
stax ptr
13858-
13859-
loop: jsr measure
13860-
bcc draw ; already short enough
13861-
13862-
jsr ellipsify
13863-
jmp loop
13864-
13865-
;; Draw
13866-
draw: MGTK_CALL MGTK::DrawText, txt
13867-
rts
13868-
13869-
;; Measure
13870-
measure:
13871-
txt := $8
13872-
len := $A
13873-
result := $B
13874-
13875-
ldy #0
13876-
lda (ptr),y
13877-
sta len
13878-
ldxy ptr
13879-
inxy
13880-
stxy txt
13881-
MGTK_CALL MGTK::TextWidth, txt
13882-
cmp16 result, #kProgressDialogPathWidth
13883-
rts
13884-
13885-
ellipsify:
13886-
ldy #0
13887-
lda (ptr),y ; length
13888-
sta length
13889-
pha
13890-
sec ; shrink length by one
13891-
sbc #1
13892-
sta (ptr),y
13893-
pla
13894-
lsr ; /= 2
13895-
13896-
pha ; A = length/2
13897-
13898-
tay
13899-
: iny ; shift chars from midpoint to
13900-
lda (ptr),y ; end of string down by one
13901-
dey
13902-
sta (ptr),y
13903-
iny
13904-
length := *+1
13905-
cpy #SELF_MODIFIED_BYTE
13906-
bne :-
13907-
13908-
pla ; A = length/2
13909-
13910-
tay ; overwrite midpoint with
13911-
lda #'.' ; "..."
13912-
sta (ptr),y
13913-
iny
13914-
sta (ptr),y
13915-
iny
13916-
sta (ptr),y
13917-
rts
13918-
.endproc ; DrawDialogPath
13850+
.include "../lib/drawdialogpath.s"
1391913851

1392013852
;;; ============================================================
1392113853
;;; Save/Restore window state at shutdown/launch

src/lib/drawdialogpath.s

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
;;; Draw a path (long string) in the progress dialog by without intruding
2+
;;; into the border. If the string is too long, it is shrunk from the
3+
;;; center with "..." inserted.
4+
;;; Inputs: A,X = string address
5+
;;; Trashes $06...$0C
6+
7+
;;; `kProgressDialogPathWidth` must be defined
8+
9+
.proc DrawDialogPath
10+
ptr := $6
11+
stax ptr
12+
13+
loop: jsr measure
14+
bcc draw ; already short enough
15+
16+
jsr ellipsify
17+
jmp loop
18+
19+
;; Draw
20+
draw: MGTK_CALL MGTK::DrawText, txt
21+
rts
22+
23+
;; Measure
24+
measure:
25+
txt := $8
26+
len := $A
27+
result := $B
28+
29+
ldy #0
30+
lda (ptr),y
31+
sta len
32+
ldxy ptr
33+
inxy
34+
stxy txt
35+
MGTK_CALL MGTK::TextWidth, txt
36+
cmp16 result, #kProgressDialogPathWidth
37+
rts
38+
39+
ellipsify:
40+
ldy #0
41+
lda (ptr),y ; length
42+
sta length
43+
pha
44+
sec ; shrink length by one
45+
sbc #1
46+
sta (ptr),y
47+
pla
48+
lsr ; /= 2
49+
50+
pha ; A = length/2
51+
52+
tay
53+
: iny ; shift chars from midpoint to
54+
lda (ptr),y ; end of string down by one
55+
dey
56+
sta (ptr),y
57+
iny
58+
length := *+1
59+
cpy #SELF_MODIFIED_BYTE
60+
bne :-
61+
62+
pla ; A = length/2
63+
64+
tay ; overwrite midpoint with
65+
lda #'.' ; "..."
66+
sta (ptr),y
67+
iny
68+
sta (ptr),y
69+
iny
70+
sta (ptr),y
71+
rts
72+
.endproc ; DrawDialogPath
73+

src/selector/ovl_file_copy.s

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ pathname_dst:
104104
pathname_src:
105105
.res ::kPathBufferSize, 0
106106

107+
;;; Copy of `pathname_src` modified for display
108+
display_path:
109+
.res ::kPathBufferSize, 0
110+
107111
;;; Paths for overall operation
108112
dst_path: .res 64, 0
109113
src_path: .res 64, 0
@@ -925,8 +929,13 @@ nextwinfo: .addr 0
925929

926930
DEFINE_LABEL download, res_string_label_download, 116, 16
927931

928-
DEFINE_POINT pos_copying, 20, 32
929-
DEFINE_POINT pos_remaining, 20, 45
932+
kProgressDialogDefaultX = 20
933+
kProgressDialogPathLeft = 100
934+
kProgressDialogPathWidth = winfo::kWidth - kProgressDialogPathLeft - kProgressDialogDefaultX
935+
936+
DEFINE_POINT pos_copying, kProgressDialogDefaultX, 32
937+
DEFINE_POINT pos_path, kProgressDialogPathLeft, 32
938+
DEFINE_POINT pos_remaining, kProgressDialogDefaultX, 45
930939

931940
str_copying:
932941
PASCAL_STRING res_string_label_copying
@@ -1013,7 +1022,9 @@ ep2: dec file_count
10131022
MGTK_CALL MGTK::PaintRect, rect_clear_count
10141023
MGTK_CALL MGTK::MoveTo, pos_copying
10151024
param_call DrawString, str_copying
1016-
param_call DrawString, pathname_src
1025+
MGTK_CALL MGTK::MoveTo, pos_path
1026+
COPY_STRING pathname_src, display_path
1027+
param_call DrawDialogPath, display_path
10171028
MGTK_CALL MGTK::MoveTo, pos_remaining
10181029
param_call DrawString, str_files_remaining
10191030
param_call DrawString, str_from_int
@@ -1102,6 +1113,8 @@ ret: rts
11021113

11031114
;;; ============================================================
11041115

1116+
.include "../lib/drawdialogpath.s"
1117+
11051118
ReadSetting := app::ReadSetting
11061119
.include "../lib/inttostring.s"
11071120
.include "../lib/drawstring.s"

src/selector/res/selector.res.bg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
.define res_string_button_desktop "raboten plot"
1818
.define res_char_button_desktop_shortcut 'D'
1919
.define res_string_label_download "kopirane w RAMCARD..."
20-
.define res_string_label_copying "kopirane: "
20+
.define res_string_label_copying "kopirane:"
2121
.define res_string_errmsg_not_enough_room "nqma dostaty~no mqsto w RAM kartata za kopirane na prilovenieto."
2222
.define res_string_errmsg_copy_incomplete "wyznikna gre{ka po wreme na izteglqneto. kopiraneto ne e zawyr{eno."
2323
.define res_string_label_files_to_copy "fajlowe za kopirane: "

src/selector/res/selector.res.da

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
.define res_string_button_desktop "Skrivebord"
1818
.define res_char_button_desktop_shortcut 'S'
1919
.define res_string_label_download "Kopierer til RAMCard..."
20-
.define res_string_label_copying "Kopiering: "
20+
.define res_string_label_copying "Kopiering:"
2121
.define res_string_errmsg_not_enough_room "Ikke nok plads i RAMCard til at kopiere applikationen."
2222
.define res_string_errmsg_copy_incomplete "Der opstod en fejl under download. Kopien blev ikke f{rdiggjort."
2323
.define res_string_label_files_to_copy "Filer der skal kopieres: "

src/selector/res/selector.res.de

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
.define res_string_button_desktop "Schreibtisch"
1818
.define res_char_button_desktop_shortcut 'S'
1919
.define res_string_label_download "Kopiere auf RAMCard..."
20-
.define res_string_label_copying "Kopiere: "
20+
.define res_string_label_copying "Kopiere:"
2121
.define res_string_errmsg_not_enough_room "Nicht genug Speicher auf RAMCard um Programm zu kopieren."
2222
.define res_string_errmsg_copy_incomplete "Ein Fehler trat w{hrend des Ladens auf. Kopieren nicht vollst{ndig."
2323
.define res_string_label_files_to_copy "Zu kopierende Dateien: "

src/selector/res/selector.res.en

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
.define res_string_button_desktop "DeskTop"
1818
.define res_char_button_desktop_shortcut 'D'
1919
.define res_string_label_download "Copying to RAMCard..."
20-
.define res_string_label_copying "Copying: "
20+
.define res_string_label_copying "Copying:"
2121
.define res_string_errmsg_not_enough_room "Not enough room in the RAMCard to copy the application."
2222
.define res_string_errmsg_copy_incomplete "An error occurred during the download. The copy was not completed."
2323
.define res_string_label_files_to_copy "Files to copy: "

src/selector/res/selector.res.es

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
.define res_string_button_desktop "Escritorio"
1818
.define res_char_button_desktop_shortcut 'E'
1919
.define res_string_label_download "Copiando a RAMDisk..."
20-
.define res_string_label_copying "Copiando: "
20+
.define res_string_label_copying "Copiando:"
2121
.define res_string_errmsg_not_enough_room "No hay sitio suficiente en la RAMDisk para copiar la aplicaci\x13n."
2222
.define res_string_errmsg_copy_incomplete "Ha ocurrido un error durante la descarga. La copia no se ha completado."
2323
.define res_string_label_files_to_copy "Archivos para copiar: "

0 commit comments

Comments
 (0)