Skip to content

Commit ba2d751

Browse files
committed
add racket:current-tabify-reverse
Add reverse-mode tabbing for languages, like Rhombus, that support iterating through tabbing alteratives. Map "s:tab" to iterate through alternatives in reverse mode.
1 parent 2d322fc commit ba2d751

5 files changed

Lines changed: 24 additions & 6 deletions

File tree

gui-doc/scribblings/framework/racket.scrbl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,18 @@
7474
@defmethod*[(((tabify (start-pos exact-integer?
7575
(send this get-start-position)))
7676
void?))]{
77-
Tabs the line containing by @racket[start-pos]
77+
Tabs the line containing by @racket[start-pos]. See also @racket[racket:current-tabify-reverse].
7878
}
7979

8080
@defmethod*[(((tabify-selection (start exact-integer? (send this get-start-position))
8181
(end exact-integer? (send this get-end-position)))
8282
void?))]{
8383
Sets the tabbing for the lines containing positions @racket[start]
84-
through @racket[end].
84+
through @racket[end]. See also @racket[racket:current-tabify-reverse].
8585
}
8686

8787
@defmethod*[(((tabify-all) void?))]{
88-
Tabs all lines.
88+
Tabs all lines. See also @racket[racket:current-tabify-reverse].
8989

9090
Indentation results depend on the graphical context associated with the object;
9191
if there is not one, the indentation is based on the assumption that a fixed-width

gui-lib/framework/main.rkt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,18 @@ are currently open in tabs.
16391639
(listof (list/c symbol? symbol?))
16401640
@{The default parentheses that are matched when using @racket[racket:text-mode-mixin].
16411641

1642-
@history[#:added "1.60"]})
1642+
@history[#:added "1.60"]})
1643+
1644+
(parameter-doc
1645+
racket:current-tabify-reverse
1646+
(parameter/c boolean?)
1647+
reverse?
1648+
@{A parameter that indicates whether tabbing should cycle through options (if any) in reverse mode.
1649+
This parameter is meant to be set before calling @method[racket:text<%> tabify],
1650+
@method[racket:text<%> tabify-selection], or @method[racket:text<%> tabify-all],
1651+
although default implementations of those methods do not use the parameter.
1652+
1653+
@history[#:added "1.77"]})
16431654

16441655
(proc-doc/names
16451656
racket:add-preferences-panel

gui-lib/framework/private/racket.rkt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
("[" . "]")
4949
("{" . "}")))
5050

51+
(define current-tabify-reverse (make-parameter #f))
52+
5153
(define text-balanced?
5254
(lambda (text [start 0] [in-end #f])
5355
(let* ([end (or in-end (send text last-position))]
@@ -1714,6 +1716,9 @@
17141716
(λ (x) (send x select-up-sexp)))
17151717
(add-edit-function "tabify-at-caret"
17161718
(λ (x) (send x tabify-selection)))
1719+
(add-edit-function "reverse-tabify-at-caret"
1720+
(λ (x) (parameterize ([current-tabify-reverse #t])
1721+
(send x tabify-selection))))
17171722
(add-edit-function "do-return"
17181723
(λ (x) (send x insert-return)))
17191724
(add-edit-function "comment-out"
@@ -1827,6 +1832,7 @@
18271832
(send keymap map-function key func))
18281833

18291834
(map "TAB" "tabify-at-caret")
1835+
(map "s:TAB" "reverse-tabify-at-caret")
18301836

18311837
(map "return" "do-return")
18321838
(map "s:return" "do-return")

gui-lib/framework/private/sig.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@
418418

419419
text-balanced?
420420

421-
default-paren-matches))
421+
default-paren-matches
422+
current-tabify-reverse))
422423

423424
(define-signature main-class^ ())
424425
(define-signature main^ extends main-class^ ())

gui-lib/info.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
(define pkg-authors '(mflatt robby))
3636

37-
(define version "1.76")
37+
(define version "1.77")
3838

3939
(define license
4040
'(Apache-2.0 OR MIT))

0 commit comments

Comments
 (0)