Merge pull request #253 from jtamagnan/fake-bar-cursor

When cursor-type is bar, mc/cursors appear as bars
This commit is contained in:
Jules Tamangan 2016-06-16 17:04:58 -04:00 committed by GitHub
commit 8413969a97

View File

@ -35,6 +35,11 @@
"The face used for fake cursors" "The face used for fake cursors"
:group 'multiple-cursors) :group 'multiple-cursors)
(defface mc/cursor-bar-face
`((t (:height 1 :background ,(face-attribute 'cursor :background))))
"The face used for fake cursors if the cursor-type is bar"
:group 'multiple-cursors)
(defface mc/region-face (defface mc/region-face
'((t :inherit region)) '((t :inherit region))
"The face used for fake regions" "The face used for fake regions"
@ -98,16 +103,26 @@
(set-marker ,p nil) (set-marker ,p nil)
(set-marker ,s nil)))) (set-marker ,s nil))))
(defun mc/cursor-is-bar ()
"returns true if the cursor is a bar"
(cond ((equalp cursor-type 'bar) t)
((when (listp cursor-type) (equalp (car cursor-type) 'bar)) t)
(t nil)))
(defun mc/make-cursor-overlay-at-eol (pos) (defun mc/make-cursor-overlay-at-eol (pos)
"Create overlay to look like cursor at end of line." "Create overlay to look like cursor at end of line."
(let ((overlay (make-overlay pos pos nil nil nil))) (let ((overlay (make-overlay pos pos nil nil nil)))
(overlay-put overlay 'after-string (propertize " " 'face 'mc/cursor-face)) (if (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)) overlay))
(defun mc/make-cursor-overlay-inline (pos) (defun mc/make-cursor-overlay-inline (pos)
"Create overlay to look like cursor inside text." "Create overlay to look like cursor inside text."
(let ((overlay (make-overlay pos (1+ pos) nil nil nil))) (let ((overlay (make-overlay pos (1+ pos) nil nil nil)))
(overlay-put overlay 'face 'mc/cursor-face) (if (mc/cursor-is-bar)
(overlay-put overlay 'before-string (propertize "|" 'face 'mc/cursor-bar-face))
(overlay-put overlay 'face 'mc/cursor-face))
overlay)) overlay))
(defun mc/make-cursor-overlay-at-point () (defun mc/make-cursor-overlay-at-point ()