all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: 22873@debbugs.gnu.org,17684@debbugs.gnu.org
Cc: mbork@mbork.pl, rms@gnu.org, johnw@gnu.org, akioburns@icloud.com
Subject: bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column).
Date: Wed, 04 Mar 2020 01:03:10 -0800	[thread overview]
Message-ID: <m2o8tcjxv5.wl%esq@lawlist.com> (raw)
In-Reply-To: <m2oaayavh1.wl%esq@lawlist.com>

[-- Attachment #1: Type: text/plain, Size: 9393 bytes --]

VERSION:  022.007 [03/03/2020]


CHANGELOG:

- nsterm.m:  Bug fix in `mc_ns_draw_window_cursor' relating to a situation where
  the `cursor_glyph` is NULL and the face_id is invalid.  In such a situation,
  we now use the DEFAULT_FACE_ID.

- Pursuant to the written request of Drew Adams on 01-27-2020 to change the name
  of the "crosshairs.el" Lisp file to something else, said file has been changed
  to the file name of "+-mode.el".

- Miscellaneous tidying-up of code.


VIDEOS:

w32:  https://youtu.be/r3BdJVlsAnQ

ns:  https://youtu.be/bc1h8jtbXmw

x11:  https://youtu.be/aCIFhD2Xz5s


SCREENSHOTS:

https://www.lawlist.com/images/22873_17684_light_dark_backgrounds.png


SETUP:

Step 1:  git clone -b master git://git.sv.gnu.org/emacs.git

Step 2:  In the new emacs folder, go back to an Emacs version from 07/14/2019:

git reset --hard ac57c5093829ee09084c562bbbc1c412179be13d

Step 3:  From within the new emacs folder created in Step 1, apply the patch:

git apply /path/to/the/patch.diff

Step 4:  ./autogen.sh

Step 5:  ./configure ... [your custom options]

Step 6:  make

Step 7:  make install


USAGE:

- For a minimal working example of built-in fake cursors, type:  M-x mc-test

  ;;; TURN ON FAKE CURSORS (buffer position, cursor-type, cursor color):

  (setq mc-conf '((1 "hbar" "magenta")
                  (2 "bar" "purple")
                  (3 "box" "#00FF00")
                  (4 "hollow" "#0000FF")
                  (5 ("hbar" 3) [1.0 0.0 1.0])
                  (6 ("bar" 3) [0.0 1.0 1.0])
                  (7 "framed" "OrangeRed")))

  ;;; TURN OFF FAKE CURSORS:

  (setq mc-conf nil)

- To try out both the crosshairs feature and the visible fill column indicator
  feature, type:  M-x +-mode

- To try out just the visible fill column indicator feature, type:  M-x fc-mode

- To try out built-in fake cursors with Magnar Sveen's multiple-cursors package,
  that package must be installed.  If the multiple-cursors package is already
  installed, then just (require '+-mode) and `+-mode.el` will redefine a
  few of the multiple-cursors functions and set up a few keyboard shortcuts.
  If the multiple-cursors package by Magnar Sveen is not already installed, then
  here are two easy ways to install that package:

  Type:  M-x mc-install

  OR, evaluate the following snippet:

  (progn
    (require 'package)
    (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
    (package-initialize)
    (package-refresh-contents)
    (package-install 'multiple-cursors)
    (mc/built-in-cursors))


NOTES:

- Our journey begins at the outset of `update_window' when
  `mc_update_window_dryrun' performs a `!draw_p` simulation to create a new
  cache of fake cursors that are stored in the `w->mc_matrix`.  The cache of
  fake cursors from the previous redisplay is copied to a temporary `mc_matrix`
  under the name of `old_matrix`.  `mc_update_text_area' (used for `!draw_p` /
  `draw_p` situations) calls `mc_draw_glyphs' (writes glyphs to the glass)
  followed by `mc_draw_row' (writes fake cursors to the glass immediately
  thereafter).  At the tail end of `mc_update_window_dryrun',
  `mc_update_window_erase' compares the new `w->mc_matrix` with the `old_matrix`
  to determine which fake cursors are the same -- setting the `same_p` boolean
  struct member accordingly for each applicable fake cursor within the
  `w->mc_matrix`.  All fake cursors in the `old_matrix` that are `!same_p` get
  erased at this juncture.  [Fn 1.]  After the dryrun is complete,
  `update_window' does the real thing -- `draw_p`.  As to the `from_where`
  situations of SKIPPED, POST_CHANGED, UNCHANGED, and SET_CURSOR_TWO,
  `mc_helper' compares the incoming tentative fake cursor with the
  `w->mc_matrix` to see if it has previously been marked as `same_p` -- if it is
  `!same_p`, then the fake cursor is drawn and we `return`.  Fake cursors that
  have a `cursor_type` of MC_LEFT_FRINGE_BITMAP or MC_RIGHT_FRINGE_BITMAP are
  always reset even if they are `same_p`.  As to the `from_where` situations of
  SCRIBE_ONE, SCRIBE_TWO, SCRIBE_THREE, and NOWHERE, `mc_helper' always causes
  fake cursors to be drawn (because new glyphs were written to the glass, or the
  area to the right of the display line was cleared) and we `return`.

. Fn. 1:  Even though writing new glyphs to the glass (SCRIBE_ONE, SCRIBE_TWO,
  and SCRIBE_THREE) would erase fake cursors within those boundaries, it is
  still necessary to erase `!same_p` fake cursors prior thereto.  This is
  because `scrolling_window' occurs before new glyphs are written and
  `rif->scroll_run_hook' may copy one or more rows to other areas of the glass.
  It is not worth the effort to programmatically track both the _copied_ fake
  cursors and the _original_ fake cursors from the previous redisplay cycle,
  whose glyphs may remain where they are in the current redisplay cycle because
  they satisfy the `GLYPH_EQUAL_P' test.

- The rest of our journey takes place wherever `draw_glyphs' would ordinarily be
  called, excluding `update_text_area'.  If features 17684/22873 are active,
  `mc_redraw_row' calls `mc_draw_glyphs' (writes glyphs to the glass) and fake
  cursors are written to the glass immediately thereafter (if the coordinates
  coincide with prerecorded data in the `w->mc_matrix`).  The functions
  containing the aforementioned calls are:
  . `gui_insert_glyphs'
  . `gui_fix_overlapping_area'
  . `draw_row_with_mouse_face'
  . `expose_area'
  . `expose_line'
  . `redraw_overlapped_rows' [which has been incorporated into `update_window']

- As to `mc_scrolling_window', it would appear that there is no tangible
  benefit to rotating the current/prospective cache of fake cursors to compare
  the data before removing the fake cursors.  When scrolling the display, only
  _some_ lines are copied to new locations.  Areas that are not overwritten may
  have fake cursors and those may not necessarily be removed if desired/current
  matrix glyphs are equal.  The test for `GLYPH_EQUAL_P' does not take into
  consideration the existence of a fake cursor, and the glyph (with a fake
  cursor) may not be updated as a result thereof.  As to lines that are not
  copied, portions may be updated and fake cursors would be removed thereby.
  `mc_rotate_matrix' and `mc_reverse_vpos' were removed with patch v. 022.002.

- NS:  As of 09/28/2018 (7946445962372c4255180af45cb7c857f1b0b5fa), the NS port
  no longer does anything useful during `update_window' except mark dirty
  rectangles.  All drawing is now done when the MacOS calls `drawRect', which in
  turn calls `expose_frame'.  This was done to add support for MacOS Mojave ....


TODO:

- When an idle-timer fires and point is at the end of a horizontally scrolled
  line in a narrow window, the temporary horizontal scroll is canceled.  Create
  a minimal working example and file a bug report.

  (progn
    (defun test ()
    (interactive)
      (let ((ov (make-overlay (point) (1+ (point)) nil t t)))
        (overlay-put ov 'face '(:foreground "red"))))
    (global-set-key [f5] 'test)
    (split-window-horizontally)
    (switch-to-buffer (get-buffer-create "foo"))
    (setq bidi-display-reordering nil)
    (setq-local auto-hscroll-mode 'current-line)
    (dotimes (i 80)
      (insert (char-to-string (+ 65 i)))))

- `ns_draw_window_cursor' calls `ns_clip_to_rect', which does _not_ take
  `row->clip` into consideration when drawing cursors with `NSRectFill'.  When
  it comes time to draw glyphs on top of the box/hollow family of cursors,
  `row->clip` is taken into consideration by `get_glyph_string_clip'.  Fake
  cursors can be drawn even though the glyphs cannot, resulting in hollow/box
  family of cursors without text.  The issue can be reproduced with M-x mc-test.
  [A temporary workaround is to disable `row->clip` while drawing the glyphs.]
  https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00009.html

- Deal with left/right overwritten glyphs in the w32 and X ports of Emacs.

- The current test for `auto_hscroll_mode_p' only looks for `current_line` and
  all five related tests are based upon that assumption, which may not be true.

- Multiple Cursors:  If point is in the middle of a composite character, then
  select a fully composed character so that the fake cursor is visible.

- Implement functionality similar to the Lisp multiple-cursors by Magnar Sveen.

- Follow up with the Emacs team re bug#32177; i.e., (Current line number shifts
  one column to the left.)

- Follow up with the Emacs team re bug#32060; i.e., Horizontal Scrolling
  (Current Line):  Wrong line gets h-scrolled.

- Determine if bug #28936 needs to be fixed and help the Emacs team re same.

- Is there any additional meaningful optimization that can be added to the
  three calls of `mc_pre_scroll_clean'?

- There is a bug affecting an older version of Emacs for the NS port that causes
  partial line flickering when the same characters are grouped together (;;;;;;)
  and MC_GLYPHLESS cursors are above or below -- having the same background color
  as the frame; e.g., black on black (used to erase a glyphless cursor).  The
  partial flickering is only noticeable with rapid fire; e.g., holding down the
  right/left arrow key.  When changing the color of the glyphless cursor, the
  issue is not present.  [@lawlist has verified that the X and HPOS coordinates
  are accurate.]


[-- Attachment #2: 2020_03_03__22_21_51_685.diff --]
[-- Type: application/diff, Size: 640805 bytes --]

  parent reply	other threads:[~2020-03-04  9:03 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-01 18:44 bug#22873: 25.1.50; Feature Request -- Multiple Cursors (built-in support) Keith David Bershatsky
2016-03-03  6:30 ` Can we support multiple Cursors? John Wiegley
2016-03-03  6:54   ` Marcin Borkowski
2016-03-03 11:20     ` bug#22873: " Richard Stallman
2016-03-03 15:05       ` Marcin Borkowski
2016-03-04  9:19         ` Richard Stallman
2016-03-04  9:19         ` Richard Stallman
2016-03-04 14:59           ` Stefan Monnier
2016-03-04 22:18             ` Magnar Sveen
2016-03-05  2:16               ` Stefan Monnier
2016-03-05 13:00                 ` Richard Stallman
2016-03-06  4:47                 ` John Wiegley
2016-03-06 20:30                 ` Clément Pit--Claudel
2016-03-08  4:53                   ` Stefan Monnier
2016-03-06 20:33               ` Clément Pit--Claudel
2016-03-08  4:55                 ` Stefan Monnier
2016-03-05 12:58             ` Richard Stallman
2016-03-03 15:05       ` Marcin Borkowski
2016-03-03 11:20     ` Richard Stallman
2016-03-03  6:54   ` Marcin Borkowski
2016-03-03  6:30 ` John Wiegley
2016-03-04 23:16 ` Keith David Bershatsky
2016-03-05  6:59   ` Marcin Borkowski
2016-03-09  6:50   ` Keith David Bershatsky
2016-03-09  6:27 ` Keith David Bershatsky
2016-03-09  6:45   ` Keith David Bershatsky
2016-03-09 16:03   ` Eli Zaretskii
2016-03-09 18:30 ` Keith David Bershatsky
2016-03-11  7:18 ` Keith David Bershatsky
2016-03-14 18:35 ` Keith David Bershatsky
2016-03-14 18:49   ` Eli Zaretskii
2016-03-14 22:38 ` Keith David Bershatsky
2016-03-16  8:00 ` Keith David Bershatsky
2016-03-18  4:00 ` Keith David Bershatsky
2016-03-26 23:58   ` John Wiegley
2016-03-29  3:45 ` Keith David Bershatsky
2016-03-29 14:58   ` Eli Zaretskii
2016-03-29 17:26 ` Keith David Bershatsky
2017-06-25 22:09 ` Keith David Bershatsky
2017-07-30 17:39 ` Keith David Bershatsky
2017-08-11  0:00 ` bug#22873: Can we support multiple cursors? Keith David Bershatsky
2017-08-13 18:19 ` Keith David Bershatsky
2017-08-13 18:36   ` Eli Zaretskii
2017-08-14  3:20 ` Keith David Bershatsky
2017-08-14 15:01   ` Eli Zaretskii
2017-08-14 20:35 ` Keith David Bershatsky
2017-12-27 17:13 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
2017-12-27 23:55   ` John Wiegley
2017-12-28  1:20 ` bug#22873: #22873 (multiple fake cursors) Keith David Bershatsky
2017-12-28  1:26 ` Keith David Bershatsky
2018-07-17 19:09 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
2018-08-29  6:39 ` Keith David Bershatsky
2019-05-03  0:48 ` Keith David Bershatsky
2019-05-06 18:39 ` Keith David Bershatsky
2019-05-28  8:31 ` Keith David Bershatsky
2019-06-02  7:29 ` Keith David Bershatsky
2019-07-16 19:28 ` Keith David Bershatsky
2019-07-23  6:01 ` Keith David Bershatsky
2019-08-23  5:19 ` Keith David Bershatsky
2019-10-17 21:08 ` bug#22873: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
2020-03-04  9:03 ` Keith David Bershatsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-06-03 20:36 bug#17684: 24.4.50; Feature Request -- Vertical Lines to the Left of and Through Characters Keith David Bershatsky
2018-07-09  5:28 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
2018-11-11  3:36 ` Keith David Bershatsky
2018-11-11 16:51 ` Keith David Bershatsky
2018-11-21  4:53 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
2018-12-14  7:11 ` Keith David Bershatsky
2019-04-09  4:03 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs) Keith David Bershatsky
2019-04-21  5:15 ` Keith David Bershatsky
2019-04-29  1:21 ` Keith David Bershatsky
2019-06-08 23:44 ` Keith David Bershatsky
2019-06-16  8:07 ` Keith David Bershatsky
2019-06-24  2:25 ` Keith David Bershatsky
2019-06-30  5:42 ` Keith David Bershatsky
2019-07-31 19:39 ` Keith David Bershatsky
2019-10-18  1:12 ` bug#17684: #22873 (multiple fake cursors); and, #17684 (crosshairs / fill-column) Keith David Bershatsky
2019-11-18  6:58 ` Keith David Bershatsky
2020-01-27  7:39 ` Keith David Bershatsky
2020-05-02 20:50 ` Keith David Bershatsky
2020-10-01  3:00   ` bug#17684: bug#22873: " Lars Ingebrigtsen
2020-10-01  3:54     ` Keith David Bershatsky
2020-10-01 16:21       ` Lars Ingebrigtsen
2020-10-01 17:00         ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2o8tcjxv5.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=17684@debbugs.gnu.org \
    --cc=22873@debbugs.gnu.org \
    --cc=akioburns@icloud.com \
    --cc=johnw@gnu.org \
    --cc=mbork@mbork.pl \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.