Commit 1e71278b authored by Kim F. Storm's avatar Kim F. Storm

* emulation/cua-rect.el (cua--overlay-keymap): New keymap for

highlight overlays; allow using RET when cursor is over a button.
(cua--highlight-rectangle): Use it.
(cua--rectangle-set-corners): Don't move backwards at eol.
(cua--forward-line): Don't move into void after eob.
parent c59ee3b4
...@@ -65,6 +65,10 @@ ...@@ -65,6 +65,10 @@
(defvar cua--rectangle-overlays nil) (defvar cua--rectangle-overlays nil)
(make-variable-buffer-local 'cua--rectangle-overlays) (make-variable-buffer-local 'cua--rectangle-overlays)
(defvar cua--overlay-keymap
(let ((map (make-sparse-keymap)))
(define-key map "\r" 'cua-rotate-rectangle)))
(defvar cua--virtual-edges-debug nil) (defvar cua--virtual-edges-debug nil)
;; Per-buffer CUA mode undo list. ;; Per-buffer CUA mode undo list.
...@@ -274,8 +278,10 @@ Knows about CUA rectangle highlighting in addition to standard undo." ...@@ -274,8 +278,10 @@ Knows about CUA rectangle highlighting in addition to standard undo."
(move-to-column mc) (move-to-column mc)
(set-mark (point)) (set-mark (point))
(goto-char pp) (goto-char pp)
;; Move cursor inside rectangle, except if char at rigth edge is a tab.
(if (and (if (cua--rectangle-right-side) (if (and (if (cua--rectangle-right-side)
(= (move-to-column pc) (- pc tab-width)) (and (= (move-to-column pc) (- pc tab-width))
(not (eolp)))
(> (move-to-column pc) pc)) (> (move-to-column pc) pc))
(not (bolp))) (not (bolp)))
(backward-char 1)) (backward-char 1))
...@@ -285,7 +291,11 @@ Knows about CUA rectangle highlighting in addition to standard undo." ...@@ -285,7 +291,11 @@ Knows about CUA rectangle highlighting in addition to standard undo."
(defun cua--forward-line (n) (defun cua--forward-line (n)
;; Move forward/backward one line. Returns t if movement. ;; Move forward/backward one line. Returns t if movement.
(= (forward-line n) 0)) (let ((pt (point)))
(and (= (forward-line n) 0)
;; Deal with end of buffer
(or (not (eobp))
(goto-char pt)))))
(defun cua--rectangle-resized () (defun cua--rectangle-resized ()
;; Refresh state after resizing rectangle ;; Refresh state after resizing rectangle
...@@ -843,6 +853,7 @@ If command is repeated at same position, delete the rectangle." ...@@ -843,6 +853,7 @@ If command is repeated at same position, delete the rectangle."
(overlay-put overlay 'before-string bs) (overlay-put overlay 'before-string bs)
(overlay-put overlay 'after-string as) (overlay-put overlay 'after-string as)
(overlay-put overlay 'face rface) (overlay-put overlay 'face rface)
(overlay-put overlay 'keymap cua--overlay-keymap)
(setq new (cons overlay new)))))) (setq new (cons overlay new))))))
;; Trim old trailing overlays. ;; Trim old trailing overlays.
(mapcar (function delete-overlay) old) (mapcar (function delete-overlay) old)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment