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

Add option to disable bar-style fake cursors #367

Merged
merged 1 commit into from
Dec 15, 2020
Merged
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
16 changes: 14 additions & 2 deletions multiple-cursors-core.el
Original file line number Diff line number Diff line change
@@ -40,6 +40,18 @@
"The face used for fake cursors if the cursor-type is bar"
:group 'multiple-cursors)

(defcustom mc/match-cursor-style t
"If non-nil, attempt to match the cursor style that the user
has selected. Namely, use vertical bars the user has configured
Emacs to use that cursor.

If nil, just use standard rectangle cursors for all fake cursors.

In some modes/themes, the bar fake cursors are either not
rendered or shift text."
:type '(boolean)
:group 'multiple-cursors)

(defface mc/region-face
'((t :inherit region))
"The face used for fake regions"
@@ -125,15 +137,15 @@
(defun mc/make-cursor-overlay-at-eol (pos)
"Create overlay to look like cursor at end of line."
(let ((overlay (make-overlay pos pos nil nil nil)))
(if (mc/cursor-is-bar)
(if (and mc/match-cursor-style (mc/cursor-is-bar))
(overlay-put overlay 'before-string (propertize "|" 'face 'mc/cursor-bar-face))
(overlay-put overlay 'after-string (propertize " " 'face 'mc/cursor-face)))
overlay))

(defun mc/make-cursor-overlay-inline (pos)
"Create overlay to look like cursor inside text."
(let ((overlay (make-overlay pos (1+ pos) nil nil nil)))
(if (mc/cursor-is-bar)
(if (and mc/match-cursor-style (mc/cursor-is-bar))
(overlay-put overlay 'before-string (propertize "|" 'face 'mc/cursor-bar-face))
(overlay-put overlay 'face 'mc/cursor-face))
overlay))