From cebf1b174cad17b70915ef94d0270fa396b6c997 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 2 Jul 2025 08:39:21 -0600 Subject: [PATCH] framework: add `tabify-selection/reverse-choices` to `racket:text<%>` Add reverse-order tabbing for languages, like Rhombus, that support iterating through tabbing alteratives. Map "s:tab" to iterate through alternatives in reverse mode. Merge before racket/drracket#753 --- gui-doc/scribblings/framework/racket.scrbl | 11 +++++++++++ gui-lib/framework/private/racket.rkt | 8 ++++++++ gui-lib/info.rkt | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gui-doc/scribblings/framework/racket.scrbl b/gui-doc/scribblings/framework/racket.scrbl index c9f287c47..dd2b60cf6 100644 --- a/gui-doc/scribblings/framework/racket.scrbl +++ b/gui-doc/scribblings/framework/racket.scrbl @@ -84,6 +84,17 @@ through @racket[end]. } + @defmethod*[(((tabify-selection/reverse-choices (start exact-integer? (send this get-start-position)) + (end exact-integer? (send this get-end-position))) + void?))]{ + Sets the tabbing for the lines containing positions @racket[start] + through @racket[end], but if there are multiple valid tabbings to cycle through, + this method should cycle through the choices in reverse order. The default + implementation calls @method[racket:text<%> tabify-selection]. + + @history[#:added "1.77"] + } + @defmethod*[(((tabify-all) void?))]{ Tabs all lines. diff --git a/gui-lib/framework/private/racket.rkt b/gui-lib/framework/private/racket.rkt index 0118daf9d..fb6f1ca32 100644 --- a/gui-lib/framework/private/racket.rkt +++ b/gui-lib/framework/private/racket.rkt @@ -373,6 +373,7 @@ tabify-on-return? tabify tabify-selection + tabify-selection/reverse-choices tabify-all insert-return @@ -675,6 +676,10 @@ (when (< first-para end-para) (end-busy-cursor))))))) + (define/public (tabify-selection/reverse-choices [start-pos (get-start-position)] + [end-pos (get-end-position)]) + (tabify-selection start-pos end-pos)) + (define/public (tabify-all) (tabify-selection 0 (last-position))) (define/public (insert-return) (begin-edit-sequence #t #f) @@ -1714,6 +1719,8 @@ (λ (x) (send x select-up-sexp))) (add-edit-function "tabify-at-caret" (λ (x) (send x tabify-selection))) + (add-edit-function "tabify-at-caret/reverse-choices" + (λ (x) (send x tabify-selection/reverse-choices))) (add-edit-function "do-return" (λ (x) (send x insert-return))) (add-edit-function "comment-out" @@ -1827,6 +1834,7 @@ (send keymap map-function key func)) (map "TAB" "tabify-at-caret") + (map "s:TAB" "tabify-at-caret/reverse-choices") (map "return" "do-return") (map "s:return" "do-return") diff --git a/gui-lib/info.rkt b/gui-lib/info.rkt index 2daa5497b..db042dff4 100644 --- a/gui-lib/info.rkt +++ b/gui-lib/info.rkt @@ -34,7 +34,7 @@ (define pkg-authors '(mflatt robby)) -(define version "1.76") +(define version "1.77") (define license '(Apache-2.0 OR MIT))