From c3786dbc3b6315e325b3a74f6fc2d019614c6ac0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 1 May 2022 00:32:55 +0100 Subject: [PATCH] script: Allow multiselect of large numbers Signed-off-by: Ian Jackson --- templates/script.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/templates/script.ts b/templates/script.ts index be5b606f..e95f994d 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -489,7 +489,7 @@ function some_keydown(e: KeyboardEvent) { if (special_count == null) special_count = 0; special_count *= 10; special_count += special_count_key; - special_count %= 100; + special_count %= 100000; special_count_reupdate(); return; } @@ -550,15 +550,18 @@ function special_count_reupdate() { let xy; if (special_count != 0) { let path = 'stroke-linecap="square" d="M -10 -10 10 10 M 10 -10 -10 10"'; + let text_len = special_count.toString().length; + let text_x = text_len <= 3 ? 0 : -15; + let text_size = text_len <= 3 ? 50 : 45 * (4/text_len); xy = '15 50'; svg = ` + viewBox="-15 0 120 65" width="120" height="65"> - ${special_count} + ${special_count} `; } else { let path = 'stroke-linecap="square" d="M -10 -10 0 0 10 -10 M 0 0 0 -20"'; @@ -1116,6 +1119,11 @@ function mouse_find_clicked(e: MouseEvent, if (clicked) clicked.multigrab = special_count; return clicked; } else { + if (special_count > 99) { + add_log_message( + `Refusing to try to select ${special_count} pieces (max is 99)`); + return null; + } let clickpos = mouseevent_pos(e); return mouse_find_predicate( special_count, count_allow_for_deselect, note_already, -- 2.30.2