Compare commits
8 Commits
master
...
more-ellip
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fa11e0774e | ||
![]() |
de03f1a98f | ||
![]() |
5e433c8035 | ||
![]() |
0fae71ad0c | ||
![]() |
01c665e6e9 | ||
![]() |
0ae0a5b804 | ||
![]() |
6b2f4a72ae | ||
![]() |
c700e32c17 |
|
@ -30,6 +30,10 @@ Adds an undoer procedure to the editor's undo stack. If an undo is
|
|||
redoing) changes to an editor, and when this undoer is the first item
|
||||
on the undo (or redo) stack.
|
||||
|
||||
Editor instances are created with no undo stack, so no undo operations
|
||||
will be recorded unless @method[editor<%> set-max-undo-history] is
|
||||
used to change the size of the undo stack.
|
||||
|
||||
The system automatically installs undo records to undo built-in editor
|
||||
operations, such as inserts, deletes, and font changes. Install an
|
||||
undoer only when it is necessary to maintain state or handle
|
||||
|
|
|
@ -61,9 +61,9 @@ A brief example illustrates how editors work. To start, an editor
|
|||
]
|
||||
|
||||
At this point, the editor is fully functional: the user can type text
|
||||
into the editor, but no cut-and-paste operations are available. We
|
||||
can support all of the standard operations on an editor via the
|
||||
menu bar:
|
||||
into the editor, but no cut-and-paste or undo operations are
|
||||
available. We can support all of the standard operations on an editor
|
||||
via the menu bar:
|
||||
|
||||
@racketblock[
|
||||
(define mb (new menu-bar% [parent f]))
|
||||
|
@ -71,16 +71,20 @@ At this point, the editor is fully functional: the user can type text
|
|||
(define m-font (new menu% [label "Font"] [parent mb]))
|
||||
(append-editor-operation-menu-items m-edit #f)
|
||||
(append-editor-font-menu-items m-font)
|
||||
(send t #,(:: editor<%> set-max-undo-history) 100)
|
||||
]
|
||||
|
||||
Now, the standard cut and paste operations work, and the user can even
|
||||
set font styles. The user can also insert an embedded editor by
|
||||
selecting @onscreen{Insert Text} from the @onscreen{Edit} menu; after
|
||||
selecting the menu item, a box appears in the editor with the caret
|
||||
inside. Typing with the caret in the box stretches the box as text is
|
||||
added, and font operations apply wherever the caret is active. Text
|
||||
on the outside of the box is rearranged as the box changes
|
||||
sizes. Note that the box itself can be copied and pasted.
|
||||
Now, the standard cut-and-paste operations work and so does undo, and
|
||||
the user can even set font styles. The editor is created with no undo
|
||||
history stack, @method[editor<%> set-max-undo-history] is used to set
|
||||
a non-zero stack, so undo operations can be recorded. The user can
|
||||
also insert an embedded editor by selecting @onscreen{Insert Text}
|
||||
from the @onscreen{Edit} menu; after selecting the menu item, a box
|
||||
appears in the editor with the caret inside. Typing with the caret in
|
||||
the box stretches the box as text is added, and font operations apply
|
||||
wherever the caret is active. Text on the outside of the box is
|
||||
rearranged as the box changes sizes. Note that the box itself can be
|
||||
copied and pasted.
|
||||
|
||||
The content of an editor is made up of @defterm{@tech{snips}}. An
|
||||
embedded editor is a single snip from the embedding editor's
|
||||
|
|
|
@ -378,6 +378,8 @@
|
|||
(preferences:set-default 'framework:fixup-open-parens #f boolean?)
|
||||
(preferences:set-default 'framework:paren-match #t boolean?)
|
||||
(let ([defaults-ht (make-hasheq)])
|
||||
(for-each (λ (x) (hash-set! defaults-ht x '...))
|
||||
'(... … ...+ …+ ::...))
|
||||
(for-each (λ (x) (hash-set! defaults-ht x 'for/fold))
|
||||
'(for/fold for/fold: for*/fold for*/fold:))
|
||||
(for-each (λ (x) (hash-set! defaults-ht x 'define))
|
||||
|
@ -458,8 +460,9 @@
|
|||
(preferences:set-default
|
||||
'framework:tabify
|
||||
(list defaults-ht #rx"^begin" #rx"^def" #rx"^(for\\*?(/|$)|with-)" #f)
|
||||
(list/c (hash/c symbol? (or/c 'for/fold 'define 'begin 'lambda) #:flat? #t)
|
||||
(or/c #f regexp?) (or/c #f regexp?) (or/c #f regexp?) (or/c #f regexp?)))
|
||||
(cons/c (hash/c symbol? (or/c 'for/fold 'define 'begin 'lambda '...) #:flat? #t)
|
||||
(or/c (list/c (or/c #f regexp?) (or/c #f regexp?) (or/c #f regexp?) (or/c #f regexp?))
|
||||
(list/c (or/c #f regexp?) (or/c #f regexp?) (or/c #f regexp?) (or/c #f regexp?) (or/c #f regexp?)))))
|
||||
|
||||
(define old-style-pred? (listof (list/c symbol? symbol?)))
|
||||
(define new-style-pred?
|
||||
|
|
|
@ -752,13 +752,22 @@
|
|||
(and snd-end
|
||||
(let ([snd-start (get-backward-sexp snd-end)])
|
||||
(and snd-start
|
||||
(equal? (get-text snd-start snd-end)
|
||||
"...")
|
||||
(text-is-ellipsis? (get-text snd-start snd-end))
|
||||
(let ([thrd-start (get-forward-sexp snd-end)])
|
||||
(and (or (not thrd-start)
|
||||
(not (= (position-paragraph thrd-start)
|
||||
(position-paragraph snd-start)))))))))))))
|
||||
|
||||
(define/private (text-is-ellipsis? text)
|
||||
(define pref (preferences:get 'framework:tabify))
|
||||
(define ht (car pref))
|
||||
(define ...-reg (and (> (length pref) 5) (list-ref pref 5)))
|
||||
(hash-ref
|
||||
ht
|
||||
(with-handlers ((exn:fail:read? (λ (x) #f)))
|
||||
(read (open-input-string text)))
|
||||
(λ () (and ...-reg (regexp-match ...-reg text)))))
|
||||
|
||||
(define/private (first-sexp-is-keyword? contains)
|
||||
(let ([fst-end (get-forward-sexp contains)])
|
||||
(and fst-end
|
||||
|
@ -2173,8 +2182,9 @@
|
|||
(values (pick-out 'begin all-keywords null)
|
||||
(pick-out 'define all-keywords null)
|
||||
(pick-out 'lambda all-keywords null)
|
||||
(pick-out 'for/fold all-keywords null))))
|
||||
(define-values (begin-keywords define-keywords lambda-keywords for/fold-keywords)
|
||||
(pick-out 'for/fold all-keywords null)
|
||||
(pick-out '... all-keywords null))))
|
||||
(define-values (begin-keywords define-keywords lambda-keywords for/fold-keywords ellipses-keywords)
|
||||
(get-keywords (car (preferences:get 'framework:tabify))))
|
||||
(define ((add-button-callback keyword-type keyword-symbol list-box) button command)
|
||||
(define new-one
|
||||
|
@ -2276,8 +2286,13 @@
|
|||
'for/fold
|
||||
for/fold-keywords
|
||||
(λ (x) (update-pref 4 x))))
|
||||
(define-values (ellipses-list-box ellipses-regexp-text)
|
||||
(make-column "Ellipses"
|
||||
'...
|
||||
ellipses-keywords
|
||||
(λ (x) (update-pref 5 x))))
|
||||
(define (update-list-boxes hash-table)
|
||||
(define-values (begin-keywords define-keywords lambda-keywords for/fold-keywords)
|
||||
(define-values (begin-keywords define-keywords lambda-keywords for/fold-keywords ellipses-keywords)
|
||||
(get-keywords hash-table))
|
||||
(define (reset list-box keywords)
|
||||
(send list-box clear)
|
||||
|
@ -2286,6 +2301,7 @@
|
|||
(reset define-list-box define-keywords)
|
||||
(reset lambda-list-box lambda-keywords)
|
||||
(reset for/fold-list-box for/fold-keywords)
|
||||
(reset ellipses-list-box ellipses-keywords)
|
||||
#t)
|
||||
(define update-gui
|
||||
(λ (pref)
|
||||
|
@ -2293,7 +2309,10 @@
|
|||
(send begin-regexp-text set-value (or (object-name (list-ref pref 1)) ""))
|
||||
(send define-regexp-text set-value (or (object-name (list-ref pref 2)) ""))
|
||||
(send lambda-regexp-text set-value (or (object-name (list-ref pref 3)) ""))
|
||||
(send for/fold-regexp-text set-value (or (object-name (list-ref pref 4)) ""))))
|
||||
(send for/fold-regexp-text set-value (or (object-name (list-ref pref 4)) ""))
|
||||
(send ellipses-regexp-text set-value (or (and (> (length pref) 5)
|
||||
(object-name (list-ref pref 5)))
|
||||
""))))
|
||||
(preferences:add-callback 'framework:tabify (λ (p v) (update-gui v)))
|
||||
(update-gui (preferences:get 'framework:tabify))
|
||||
main-panel)
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
(let ([w (box 0)]
|
||||
[h (box 0)])
|
||||
(get-backing-size w h)
|
||||
(let ([bm (get-backing-bitmap (lambda (w h) (make-backing-bitmap w h)) (unbox w) (unbox h))])
|
||||
(let ([bm (get-backing-bitmap (lambda (w h) (make-backing-bitmap (max 1 w) (max 1 h))) (unbox w) (unbox h))])
|
||||
(internal-set-bitmap bm #t))
|
||||
(let ([cr (super get-cr)])
|
||||
(set! retained-cr cr)
|
||||
|
|
|
@ -237,6 +237,8 @@
|
|||
|
||||
(define/override (set-child-size child-gtk x y w h)
|
||||
(gtk_fixed_move panel-gtk child-gtk (->screen x) (->screen y))
|
||||
;; gtk3: we expect a panel in a frame to be always visible, so
|
||||
;; this size erquest should work
|
||||
(gtk_widget_set_size_request child-gtk (->screen w) (->screen h)))
|
||||
|
||||
(define/public (on-close) #t)
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
(define-gtk gtk_event_box_set_visible_window (_fun _GtkWidget _gboolean -> _void))
|
||||
|
||||
(define-gtk gtk_fixed_move (_fun _GtkWidget _GtkWidget _int _int -> _void))
|
||||
(define-gtk gtk_widget_get_visible (_fun _GtkWidget -> _gboolean))
|
||||
|
||||
(define-gtk gtk_container_set_border_width (_fun _GtkWidget _int -> _void))
|
||||
|
||||
|
@ -137,7 +138,15 @@
|
|||
(super-new)
|
||||
(define/override (set-child-size child-gtk x y w h)
|
||||
(gtk_fixed_move (get-container-gtk) child-gtk (->screen x) (->screen y))
|
||||
(gtk_widget_set_size_request child-gtk (->screen w) (->screen h)))))
|
||||
(define re-hide?
|
||||
(and gtk3?
|
||||
(not (gtk_widget_get_visible child-gtk))
|
||||
(begin
|
||||
(gtk_widget_show child-gtk)
|
||||
#t)))
|
||||
(gtk_widget_set_size_request child-gtk (->screen w) (->screen h))
|
||||
(when re-hide?
|
||||
(gtk_widget_hide child-gtk)))))
|
||||
|
||||
(define panel%
|
||||
(class (panel-container-mixin (panel-mixin window%))
|
||||
|
|
|
@ -614,7 +614,7 @@
|
|||
(set! client-delta-h (->normal
|
||||
(- (GtkRequisition-height req)
|
||||
(GtkRequisition-height creq)))))
|
||||
(when gtk3? (gtk_widget_show gtk))))
|
||||
(when gtk3? (gtk_widget_hide gtk))))
|
||||
|
||||
(define/public (set-auto-size [dw 0] [dh 0])
|
||||
(let ([req (make-GtkRequisition 0 0)])
|
||||
|
@ -633,7 +633,7 @@
|
|||
(define/public (direct-show on?)
|
||||
;; atomic mode
|
||||
(if on?
|
||||
(gtk_widget_show gtk)
|
||||
(gtk_widget_show gtk)
|
||||
(gtk_widget_hide gtk))
|
||||
(set! shown? (and on? #t))
|
||||
(register-child-in-parent on?)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user