gabesoft / evil-mc

Multiple cursors implementation for evil-mode
MIT License
388 stars 36 forks source link

Insert state changes line height #60

Open duianto opened 7 years ago

duianto commented 7 years ago

Description

In windows the line height changes when one enters and exits insert state. It happens on any line with a multi cursor.

Windows 10

evil-mc-windows-emacs-normal-vs-insert-line-height evil-mc-windows-spacemacs-normal-vs-insert-line-height

Ubuntu 16.10

It works as expected in Ubuntu.

evil-mc-ubuntu-emacs-normal-vs-insert-line-height evil-mc-ubuntu-spacemacs-normal-vs-insert-line-height

System Info

The first animation for each OS shows: Emacs with the evil-mc package installed. The second animation shows: Spacemacs 0.200.9 (develop branch).

System 1:

Emacs 25.1.1 Windows 10

System 2 (Windows 10, Virtual box host OS):

Emacs 26.0.50 Ubuntu 16.10

gabesoft commented 7 years ago

This is a known issue on Windows and Mac. To turn off that behavior and have the fake cursors have the default cursor face set this variable evil-mc-enable-bar-cursor to nil.

duianto commented 7 years ago

Thanks, setting the evil-mc-enable-bar-cursor variable to nil stops the line height from changing.

XPM images as additional cursors

If there aren't any downsides to using XPM images as the additional cursors. Then I might have found a solution to the Windows cursor issue.

This question: http://stackoverflow.com/questions/23744237/emacs-how-to-create-a-vertical-strike-through-effect shows two examples of how to draw XPM images in Emacs. I modified the last example, so that it shows a 1px wide and 16px tall, vertical line (16px is the same height as the cursor).

(let* ((img `(image :type xpm :mask nil :ascent center :data
                    "/* XPM */
      static char * img_xpm[] = {
      \"1 16 1 1\",
      \"* c green\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\",
      \"*\"};"))
       (img-str (propertize " " 'display img))
       (vertical-line-overlay (make-overlay (point) (1+ (point)))))
  (overlay-put vertical-line-overlay 'before-string img-str)
  (internal-show-cursor nil nil)
  (sit-for 2)
  (internal-show-cursor nil t)
  (delete-overlay vertical-line-overlay))

Here's a comparison of the normal and insert state cursors, to the XPM image (with the cursor hidden).

xpm-vertical-line

Where it works

The XPM image looks the same in both Ubuntu and Windows.

Terminals issue:

XPM images probably won't work with text only terminals.

Possible solution:

(display-graphic-p) returns t when a gui version of Emacs is used.

mask descriptor

Maybe :mask nil can be removed from the line: (let* ((img `(image :type xpm :mask nil :ascent center :data Because it seems to work the same, both with or without it.

This page describes the :mask image descriptor: http://www.gnu.org/software/emacs/manual/html_node/elisp/Image-Descriptors.html

gabesoft commented 7 years ago

Thanks, that definitely looks interesting. I'll look into using XPM images when I have some time.