Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add vi-swapcase-and-forward-char command for vi-mode #1630

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extensions/vi-mode/binds.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
(define-key *normal-keymap* "g U" 'vi-upcase)
(define-key *normal-keymap* "g u" 'vi-downcase)
(define-key *normal-keymap* "g ~" 'vi-swapcase)
(define-key *normal-keymap* "~" 'vi-swapcase-and-forward-char)
(define-key *normal-keymap* "u" 'vi-undo)
(define-key *normal-keymap* "C-r" 'vi-redo)
(define-key *motion-keymap* 'delete-previous-char 'vi-backward-char)
Expand Down
7 changes: 7 additions & 0 deletions extensions/vi-mode/commands.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
:vi-upcase
:vi-downcase
:vi-swapcase
:vi-swapcase-and-forward-char
:vi-undo
:vi-redo
:vi-record-macro
Expand Down Expand Up @@ -639,6 +640,12 @@ Move the cursor to the first non-blank character of the line."
(apply-visual-range #'swapcase-region)
(swapcase-region start end))))

(define-command vi-swapcase-and-forward-char () ()
(let* ((start (copy-point (current-point)))
(end (character-offset (current-point) 1)))
(vi-swapcase start end (current-state)))
(vi-forward-char))

(define-command vi-undo (&optional (n 1)) (:universal)
(undo n))

Expand Down
13 changes: 13 additions & 0 deletions src/mouse.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@
(funcall callback window point)
t))

(defun sync-mark-start-point-for-vi-mode (start-point)
(when (typep (lem:current-global-mode) 'lem-vi-mode:vi-mode)
;; Ensure current main state is visual-char.
(unless (lem-vi-mode/visual:visual-char-p)
(lem-vi-mode/commands::vi-visual-char))
;; Override the *start-point* in vi-visual mode.
(setf lem-vi-mode/visual::*start-point* start-point)
))

(defmethod handle-mouse-hover (buffer mouse-event &key window x y)
(case (mouse-event-button mouse-event)
((nil)
Expand All @@ -224,6 +233,8 @@
(handle-mouse-unhover-buffer window point))))
(:button-1
(when (window-last-mouse-button-down-point window)
(sync-mark-start-point-for-vi-mode (window-last-mouse-button-down-point window))

(move-current-point-to-x-y-position window x y)
(set-current-mark (window-last-mouse-button-down-point window))))))

Expand Down Expand Up @@ -310,6 +321,8 @@
(multiple-value-bind (start end)
(get-select-expression-points (current-point))
(when start
(sync-mark-start-point-for-vi-mode start)

(set-current-mark start)
(move-point (current-point) end))))

Expand Down
Loading