selection and cocoa clipboard fixes
This commit is contained in:
parent
b69b97c113
commit
f51345b512
|
@ -5,7 +5,8 @@
|
||||||
"utils.rkt"
|
"utils.rkt"
|
||||||
"types.rkt"
|
"types.rkt"
|
||||||
"../common/bstr.rkt"
|
"../common/bstr.rkt"
|
||||||
"../../syntax.rkt")
|
"../../syntax.rkt"
|
||||||
|
"../../lock.rkt")
|
||||||
|
|
||||||
(provide clipboard-driver%
|
(provide clipboard-driver%
|
||||||
has-x-selection?)
|
has-x-selection?)
|
||||||
|
@ -49,20 +50,22 @@
|
||||||
#f)))))
|
#f)))))
|
||||||
|
|
||||||
(define/public (set-client c types)
|
(define/public (set-client c types)
|
||||||
(let ([pb (tell NSPasteboard generalPasteboard)]
|
(atomically
|
||||||
[a (tell NSArray arrayWithObjects:
|
(with-autorelease
|
||||||
#:type (_list i _NSString) (map map-type types)
|
(let ([pb (tell NSPasteboard generalPasteboard)]
|
||||||
count: #:type _NSUInteger (length types))])
|
[a (tell NSArray arrayWithObjects:
|
||||||
(set! counter (tell #:type _NSInteger pb clearContents))
|
#:type (_list i _NSString) (map map-type types)
|
||||||
(set! client c)
|
count: #:type _NSUInteger (length types))])
|
||||||
(for ([type (in-list types)])
|
(set! counter (tell #:type _NSInteger pb clearContents))
|
||||||
(let* ([bstr (send c get-data type)]
|
(set! client c)
|
||||||
[data (tell NSData
|
(for ([type (in-list types)])
|
||||||
dataWithBytes: #:type _bytes bstr
|
(let* ([bstr (send c get-data type)]
|
||||||
length: #:type _NSUInteger (bytes-length bstr))])
|
[data (tell NSData
|
||||||
(tellv (tell NSPasteboard generalPasteboard)
|
dataWithBytes: #:type _bytes bstr
|
||||||
setData: data
|
length: #:type _NSUInteger (bytes-length bstr))])
|
||||||
forType: #:type _NSString (map-type type))))))
|
(tellv (tell NSPasteboard generalPasteboard)
|
||||||
|
setData: data
|
||||||
|
forType: #:type _NSString (map-type type))))))))
|
||||||
|
|
||||||
(define/public (get-data-for-type type)
|
(define/public (get-data-for-type type)
|
||||||
(log-error "didn't expect clipboard data request"))
|
(log-error "didn't expect clipboard data request"))
|
||||||
|
@ -73,9 +76,11 @@
|
||||||
(bytes->string/utf-8 bstr #\?))))
|
(bytes->string/utf-8 bstr #\?))))
|
||||||
|
|
||||||
(define/public (get-data type)
|
(define/public (get-data type)
|
||||||
(let* ([pb (tell NSPasteboard generalPasteboard)]
|
(atomically
|
||||||
[data (tell pb dataForType: #:type _NSString (map-type type))])
|
(with-autorelease
|
||||||
(and data
|
(let* ([pb (tell NSPasteboard generalPasteboard)]
|
||||||
(let ([len (tell #:type _NSUInteger data length)]
|
[data (tell pb dataForType: #:type _NSString (map-type type))])
|
||||||
[bstr (tell #:type _pointer data bytes)])
|
(and data
|
||||||
(scheme_make_sized_byte_string bstr len 1))))))
|
(let ([len (tell #:type _NSUInteger data length)]
|
||||||
|
[bstr (tell #:type _pointer data bytes)])
|
||||||
|
(scheme_make_sized_byte_string bstr len 1))))))))
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
(and (pair? v)
|
(and (pair? v)
|
||||||
(exact-nonnegative-integer? (car v))
|
(exact-nonnegative-integer? (car v))
|
||||||
(exact-nonnegative-integer? (cdr v))
|
(exact-nonnegative-integer? (cdr v))
|
||||||
((car v) . < . (cdr v)))))
|
((car v) . <= . (cdr v)))))
|
||||||
|
|
||||||
(define selected-text-color (get-highlight-text-color))
|
(define selected-text-color (get-highlight-text-color))
|
||||||
|
|
||||||
|
|
|
@ -5188,10 +5188,10 @@
|
||||||
(if (eq? snip s-caret-snip)
|
(if (eq? snip s-caret-snip)
|
||||||
show-caret
|
show-caret
|
||||||
(if (and maybe-hilite?
|
(if (and maybe-hilite?
|
||||||
(endpos . > . p)
|
(-endpos . > . p)
|
||||||
(startpos . < . (+ p (snip->count snip))))
|
(-startpos . < . (+ p (snip->count snip))))
|
||||||
(cons (max 0 (- startpos p))
|
(cons (max 0 (- -startpos p))
|
||||||
(min (snip->count snip) (- endpos p)))
|
(min (snip->count snip) (- -endpos p)))
|
||||||
'no-caret))))))
|
'no-caret))))))
|
||||||
|
|
||||||
;; the rules for hiliting are surprisingly complicated:
|
;; the rules for hiliting are surprisingly complicated:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user