On Fri, Jul 5, 2019 at 2:32 PM Jordan Johnson <j...@fellowhuman.com> wrote:
>
> Thanks for the reply, Robby.
>
> On Jul 2, 2019, at 19:11, Robby Findler <ro...@cs.northwestern.edu> wrote:
> One note not related to what you ask: lines in editor<%> parlance are 
> soft-breaking; the methods about paragraphs are the ones you want.
> For which specific purpose?
>
> The method that c:e is bound to by default (end-of-line, IIRC — I’m on my 
> phone) is a line method, not paragraph, right? I am (wrongly?) confident that 
> it is the one I need to wrap for my new binding. When I tested it out in DrR 
> with an editor that had some wrapped lines, c:e behaved as I’d expected: it 
> jumps the cursor to the end of the row of characters the cursor is on, which 
> is right before the actual newline iff the line isn’t wrapped. (However, I’ve 
> only tried this with wrapping turned on.) Am I understanding correctly?

Oh, maybe you do want end of lines, in that case. Sorry for the noise.

Robby


> Does c:e have different behavior in editing Scribble or other less-schemey 
> texts? I’ve been assuming it is totally language-agnostic.
>
> Thanks again,
> J
>
> Robby
>
>
> On Tue, Jul 2, 2019 at 11:41 AM Jordan Johnson <j...@fellowhuman.com> wrote:
>>
>> Dear Racket folks,
>>
>> I’m trying to implement a keybinding to get me more familiar with the editor 
>> toolkit. I’m working on modifying the Ctrl+E keybinding so it behaves more 
>> like the Ctrl+A keybinding (which, once at the beginning of the line, 
>> toggles between the true beginning of the line and the beginning of 
>> non-whitespace text on the line). The behavior I want is (I think) outlined 
>> pretty well in the code below, but to be clear: if the cursor is already at 
>> the line end, I want Ctrl+E to make the cursor jump to (right after) the end 
>> of the last s-exp that ends to the left of the cursor on the present line if 
>> there is such a s-exp. (The cursor can stay put if there is no such s-exp.)
>>
>> Here’s what I have so far:
>>
>> ;;;
>> #lang s-exp framework/keybinding-lang
>>
>> (require drracket/tool-lib)
>>
>> (define (at-EOL? ed) ; text% -> Boolean, #true iff cursor is right before 
>> newline
>>   (define sp (send ed get-start-position))
>>   (= sp
>>      (send ed get-end-position)
>>      (send ed line-end-position (send ed find-line sp))))
>>
>> (define (go-to-eol ed evt)
>>   (send (send ed get-keymap) call-function "end-of-line" ed evt #t))
>>
>> (define (go-to-end-of-code-on-line ed) ;; text% -> void?
>>   ;; jump to the end of the code that is on the current line
>>   (void)) ;; TODO
>>
>> (keybinding "c:e" (λ (ed evt)
>>                     (if (at-EOL? ed)
>>                         (go-to-end-of-code-on-line ed)
>>                         (go-to-eol ed evt))))
>> ;;;
>>
>> Two questions for those of you who know the editor toolkit well:
>>
>> Given what’s in the tool-lib, what’d be the best way to approach writing 
>> go-to-end-of-code-on-line? (I was thinking: save cursor position & line no; 
>> move left/backward by one s-exp; then move right/forward by one s-exp; then 
>> check if still on the same line, and if not restore the cursor position from 
>> before the moves.)
>> Does it look like I’m on the right track, otherwise?
>>
>>
>> Thanks,
>> Jordan
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/641F6290-D258-4D8D-B774-CAF5D9327204%40fellowhuman.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAL3TdOO-1u_25gOUGjhQXdWii4jkyub9F1PfWH6wZ0kG%2BEtp%3Dw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAL3TdONMyecdQz0xx%3Dg2m2QD6Bgyh%2BMr2p0hGFYUV%3DzFbbR6DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to