Skip to content

Commit

Permalink
Types for window digit
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed May 23, 2024
1 parent a10cc9e commit fe3d679
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
34 changes: 16 additions & 18 deletions evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -4563,28 +4563,28 @@ of the parent of the splitted window are rebalanced."
(evil-define-command evil-window-left (count)
"Move the cursor to new COUNT-th window left of the current one."
:repeat nil
(interactive "p")
(interactive "<w>")
(dotimes (_ count)
(windmove-left)))

(evil-define-command evil-window-right (count)
"Move the cursor to new COUNT-th window right of the current one."
:repeat nil
(interactive "p")
(interactive "<w>")
(dotimes (_ count)
(windmove-right)))

(evil-define-command evil-window-up (count)
"Move the cursor to new COUNT-th window above the current one."
:repeat nil
(interactive "p")
(interactive "<w>")
(dotimes (_ (or count 1))
(windmove-up)))

(evil-define-command evil-window-down (count)
"Move the cursor to new COUNT-th window below the current one."
:repeat nil
(interactive "p")
(interactive "<w>")
(dotimes (_ (or count 1))
(windmove-down)))

Expand Down Expand Up @@ -4627,7 +4627,7 @@ is different from the current one."
With COUNT go to the count-th window in the order starting from
top-left."
:repeat nil
(interactive "<c>")
(interactive "<wc>")
(if (not count)
(other-window +1)
(evil-window-top-left)
Expand All @@ -4638,7 +4638,7 @@ top-left."
With COUNT go to the count-th window in the order starting from
top-left."
:repeat nil
(interactive "<c>")
(interactive "<wc>")
(if (not count)
(other-window -1)
(evil-window-top-left)
Expand Down Expand Up @@ -4681,39 +4681,37 @@ and open a new buffer name or edit a certain FILE."
(evil-define-command evil-window-increase-height (count)
"Increase current window height by COUNT."
:repeat nil
(interactive "p")
(enlarge-window (* count (if (< 0 evil--window-digit) evil--window-digit 1))))
(interactive "<w>")
(enlarge-window count))

(evil-define-command evil-window-decrease-height (count)
"Decrease current window height by COUNT."
:repeat nil
(interactive "p")
(enlarge-window (- (* count (if (< 0 evil--window-digit) evil--window-digit 1)))))
(interactive "<w>")
(enlarge-window (- count)))

(evil-define-command evil-window-increase-width (count)
"Increase current window width by COUNT."
:repeat nil
(interactive "p")
(enlarge-window (* count (if (< 0 evil--window-digit) evil--window-digit 1)) t))
(interactive "<w>")
(enlarge-window count t))

(evil-define-command evil-window-decrease-width (count)
"Decrease current window width by COUNT."
:repeat nil
(interactive "p")
;; TODO better names
(let ((count (* count (if (< 0 evil--window-digit) evil--window-digit 1))))
(enlarge-window (- count) t)))
(interactive "<w>")
(enlarge-window (- count) t))

(evil-define-command evil-window-set-height (count)
"Set the height of the current window to COUNT."
:repeat nil
(interactive "<c>")
(interactive "<wc>")
(evil-resize-window (or count (frame-height)) nil))

(evil-define-command evil-window-set-width (count)
"Set the width of the current window to COUNT."
:repeat nil
(interactive "<c>")
(interactive "<wc>")
(evil-resize-window (or count (frame-width)) t))

(evil-define-command evil-ex-resize (arg)
Expand Down
17 changes: 17 additions & 0 deletions evil-types.el
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ the last column is excluded."

;;; Custom interactive codes

(evil-define-interactive-code "<w>"
"Prefix argument converted to number, possibly multiplied by evil--window-digit."
(let ((prefix-num (prefix-numeric-value current-prefix-arg)))
(if (< 0 evil--window-digit)
(list (* evil--window-digit prefix-num))
(list prefix-num))))

(evil-define-interactive-code "<c>"
"Count."
(list (when current-prefix-arg
Expand All @@ -294,6 +301,16 @@ directly."
(prefix-numeric-value
current-prefix-arg))))

(evil-define-interactive-code "<wc>"
"Prefix argument converted to number, or nil possibly multiplied by
evil--window-digit."
(list
(when current-prefix-arg
(let ((prefix-num (prefix-numeric-value current-prefix-arg)))
(if (< 0 evil--window-digit)
(* evil--window-digit prefix-num)
prefix-num)))))

(evil-define-interactive-code "<C>"
"Character read through `evil-read-key'."
(list
Expand Down

0 comments on commit fe3d679

Please sign in to comment.