Re: [CM] Navigation in nrepl
Wow! Thanks! I'll merge those changes into my version later today. ___ Cmdist mailing list Cmdist@ccrma.stanford.edu https://cm-mail.stanford.edu/mailman/listinfo/cmdist
Re: [CM] Navigation in nrepl
attached patch Sorry, that was an older version; revised is attached.diff --git a/nrepl.scm b/nrepl.scm index aaf7515..eae5f11 100644 --- a/nrepl.scm +++ b/nrepl.scm @@ -972,8 +972,11 @@ (mouse-col #f) (mouse-row #f) (repl-done #f) - (selection #f) - (control-key (ash 1 33))); notcurses getc returns 32 bits + (selection "") + (previously-selected #f) + (just-selected #f) + (control-key (ash 1 33)) + (meta-key (ash 1 34))); notcurses getc returns 32 bits (set! (top-level-let 'ncp-let) (curlet)) (set! display-debug-info local-debug-info) @@ -1154,67 +1157,123 @@ ((= i 256)) (set! (keymap i) normal-char)) - (set! (keymap (char->integer #\escape)) - (lambda (c) - ;; these are the Meta key handlers - (let ((k (notcurses_getc nc (c-pointer 0) (c-pointer 0) ni))) - - (case (integer->char k) - ((#\C #\c) - (do ((len (- (eols row) col)) - (cur-line (ncplane_contents ncp row col 1 (- (eols row) col))) - (i 0 (+ i 1))) - ((or (= i len) - (char-alphabetic? (cur-line i))) - (when (< i len) - (set! (cur-line i) (char-upcase (cur-line i))) - (nc-display row col cur-line) - (notcurses_refresh nc) - (do ((k (+ i 1) (+ k 1))) - ((or (>= k len) - (not (or (char-alphabetic? (cur-line k)) - (char-numeric? (cur-line k) - (set! col (min (eols row) (+ col k) - - ((#\L #\l) - (do ((len (- (eols row) col)) - (cur-line (ncplane_contents ncp row col 1 (- (eols row) col))) - (i 0 (+ i 1))) - ((or (= i len) - (char-alphabetic? (cur-line i))) - (when (< i len) - (do ((k i (+ k 1))) - ((or (= k len) - (not (char-alphabetic? (cur-line k - (nc-display row col cur-line) - (notcurses_refresh nc) - (set! col (+ col k))) - (set! (cur-line k) (char-downcase (cur-line k - - ((#\U #\u) - (do ((len (- (eols row) col)) - (cur-line (ncplane_contents ncp row col 1 (- (eols row) col))) - (i 0 (+ i 1))) - ((or (= i len) - (char-alphabetic? (cur-line i))) - (when (< i len) - (do ((k i (+ k 1))) - ((or (= k len) - (not (char-alphabetic? (cur-line k - (nc-display row col cur-line) - (notcurses_refresh nc) - (set! col (+ col k))) - (set! (cur-line k) (char-upcase (cur-line k - - ((#\<) - (set-row 0) - (set-col (bols 0))) - - ((#\>) - (set-row ncp-max-row) - (set-col (bols ncp-max-row))) - - ; end Meta keys + (define (prepend-to-selection new-text) +(unless (zero? (length new-text)) + (set! selection (if previously-selected (append new-text selection) +new-text)) + (set! just-selected #t))) + (define (append-to-selection new-text) +(unless (zero? (length new-text)) + (set! selection (if previously-selected (append selection new-text) +new-
[CM] Navigation in nrepl
Nrepl is really great, but I've found myself missing wordwise navigation and deletion. So, the attached patch to nrepl.scm implements C-w, M-d, C-u, M-b, M-f a la readline (except with more relaxed word separators as befits lisp). It also changes meta-key recognition to recognise 'alt' as a meta key. Cheers, -E 975,976c975,979 < (selection #f) < (control-key (ash 1 33))); notcurses getc returns 32 bits --- > (selection "") > (previously-selected #f) > (just-selected #f) > (control-key (ash 1 33)) > (meta-key (ash 1 34))); notcurses getc returns 32 > bits 1157,1217c1160,1276 < (set! (keymap (char->integer #\escape)) < (lambda (c) < ;; these are the Meta key handlers < (let ((k (notcurses_getc nc (c-pointer 0) (c-pointer 0) ni))) < < (case (integer->char k) < ((#\C #\c) < (do ((len (- (eols row) col)) < (cur-line (ncplane_contents ncp row col 1 (- (eols row) col))) < (i 0 (+ i 1))) < ((or (= i len) < (char-alphabetic? (cur-line i))) < (when (< i len) < (set! (cur-line i) (char-upcase (cur-line i))) < (nc-display row col cur-line) < (notcurses_refresh nc) < (do ((k (+ i 1) (+ k 1))) < ((or (>= k len) < (not (or (char-alphabetic? (cur-line k)) < (char-numeric? (cur-line k) < (set! col (min (eols row) (+ col k) < < ((#\L #\l) < (do ((len (- (eols row) col)) < (cur-line (ncplane_contents ncp row col 1 (- (eols row) col))) < (i 0 (+ i 1))) < ((or (= i len) < (char-alphabetic? (cur-line i))) < (when (< i len) < (do ((k i (+ k 1))) < ((or (= k len) < (not (char-alphabetic? (cur-line k < (nc-display row col cur-line) < (notcurses_refresh nc) < (set! col (+ col k))) < (set! (cur-line k) (char-downcase (cur-line k < < ((#\U #\u) < (do ((len (- (eols row) col)) < (cur-line (ncplane_contents ncp row col 1 (- (eols row) col))) < (i 0 (+ i 1))) < ((or (= i len) < (char-alphabetic? (cur-line i))) < (when (< i len) < (do ((k i (+ k 1))) < ((or (= k len) < (not (char-alphabetic? (cur-line k < (nc-display row col cur-line) < (notcurses_refresh nc) < (set! col (+ col k))) < (set! (cur-line k) (char-upcase (cur-line k < < ((#\<) < (set-row 0) < (set-col (bols 0))) < < ((#\>) < (set-row ncp-max-row) < (set-col (bols ncp-max-row))) < < ; end Meta keys --- > (define (prepend-to-selection new-text) > (unless (zero? (length new-text)) > (set! selection (if previously-selected (append > new-text selection) > new-text)) > (set! just-selected #t))) > (define (append-to-selection new-text) > (unless (zero? (length new-text)) > (set! selection (if previously-selected (append > selection new-text) > new-text)) > (set! just-selected #t))) > (define (char-alphanumeric? c) > (or (char-alph