diff options
| author | Jakub Kadlcik <frostyx@email.cz> | 2023-02-10 16:15:12 +0100 |
|---|---|---|
| committer | jixiuf <jixiuf@qq.com> | 2023-04-17 12:24:16 +0800 |
| commit | 94e2b0b2b4a750e7907dacd5b4c0584900846dd1 (patch) | |
| tree | 93b5d67f8669a3ba52f168903fc38107d821be9a | |
| parent | bb213bb97800d35a93d0fc1138d9e0ec2c0807a8 (diff) | |
Don't allow moving cursor below the last prompt via mouse
Without this patch, I am able to click somewhere below the last
prompt line and move the cursor there. I don't think this was an
intended feature, it feels more like a weird quirk.
We don't have any function telling us the point or line number of the
last prompt, and it doesn't seem to be easy to implement, so I
needed to workaround this.
| -rw-r--r-- | vterm.el | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -642,6 +642,7 @@ Exceptions are defined by `vterm-keymap-exceptions'." (define-key map [remap xterm-paste] #'vterm-xterm-paste) (define-key map [remap yank-pop] #'vterm-yank-pop) (define-key map [remap mouse-yank-primary] #'vterm-yank-primary) + (define-key map [mouse-1] #'vterm-mouse-set-point) (define-key map (kbd "C-SPC") #'vterm--self-insert) (define-key map (kbd "S-SPC") #'vterm-send-space) (define-key map (kbd "C-_") #'vterm--self-insert) @@ -1112,6 +1113,18 @@ Argument ARG is passed to `yank'" (cl-letf (((symbol-function 'insert-for-yank) #'vterm-insert)) (yank-pop arg)))) +(defun vterm-mouse-set-point (event &optional promote-to-region) + "Move point to the position clicked on with the mouse. +But when clicking to the unused area below the last prompt, +move the cursor to the prompt area." + (interactive "e\np") + (let ((pt (mouse-set-point event promote-to-region))) + (if (= (count-words pt (point-max)) 0) + (vterm-reset-cursor-point) + pt)) + ;; Otherwise it selects text for every other click + (keyboard-quit)) + (defun vterm-send-string (string &optional paste-p) "Send the string STRING to vterm. Optional argument PASTE-P paste-p." |
