Patch 7.4.2003

69 views
Skip to first unread message

Bram Moolenaar

unread,
Jul 8, 2016, 3:42:18 PM7/8/16
to vim...@googlegroups.com

Patch 7.4.2003
Problem: Still cursor flickering when a callback updates the screen. (David
Samvelyan)
Solution: Put the cursor in the right position after updating the screen.
Files: src/screen.c


*** ../vim-7.4.2002/src/screen.c 2016-07-07 16:42:57.318788362 +0200
--- src/screen.c 2016-07-08 21:17:43.316001662 +0200
***************
*** 422,428 ****
; /* do nothing */
else if (State & CMDLINE)
redrawcmdline();
! else if ((State & NORMAL) || (State & INSERT))
{
update_screen(0);
setcursor();
--- 422,428 ----
; /* do nothing */
else if (State & CMDLINE)
redrawcmdline();
! else if (State & (NORMAL | INSERT))
{
update_screen(0);
setcursor();
***************
*** 486,493 ****
}

/*
- * update_screen()
- *
* Based on the current value of curwin->w_topline, transfer a screenfull
* of stuff from Filemem to ScreenLines[], and update curwin->w_botline.
*/
--- 486,491 ----
***************
*** 499,504 ****
--- 497,506 ----
#if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
int did_one;
#endif
+ #ifdef FEAT_GUI
+ int gui_cursor_col;
+ int gui_cursor_row;
+ #endif

/* Don't do anything if the screen structures are (not yet) valid. */
if (!screen_valid(TRUE))
***************
*** 696,702 ****
--- 698,708 ----
* scrolling may make it difficult to redraw the text under
* it. */
if (gui.in_use)
+ {
+ gui_cursor_col = gui.cursor_col;
+ gui_cursor_row = gui.cursor_row;
gui_undraw_cursor();
+ }
#endif
}
#endif
***************
*** 752,758 ****
--- 758,770 ----
{
out_flush(); /* required before updating the cursor */
if (did_one)
+ {
+ /* Put the GUI position where the cursor was, gui_update_cursor()
+ * uses that. */
+ gui.col = gui_cursor_col;
+ gui.row = gui_cursor_row;
gui_update_cursor(FALSE, FALSE);
+ }
gui_update_scrollbars(FALSE);
}
#endif
*** ../vim-7.4.2002/src/version.c 2016-07-08 20:11:02.406985104 +0200
--- src/version.c 2016-07-08 21:19:56.370022944 +0200
***************
*** 760,761 ****
--- 760,763 ----
{ /* Add new patch number below this line */
+ /**/
+ 2003,
/**/

--
hundred-and-one symptoms of being an internet addict:
241. You try to look for Net Search even when you're in File Manager.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bram Moolenaar

unread,
Jul 8, 2016, 4:20:16 PM7/8/16
to Bram Moolenaar, vim...@googlegroups.com

I wrote:

> Patch 7.4.2003
> Problem: Still cursor flickering when a callback updates the screen. (David
> Samvelyan)
> Solution: Put the cursor in the right position after updating the screen.
> Files: src/screen.c

Looks like this fix triggers another cursor positioning problem.
When doing "rx" it first gets displayed in the right place, then drawn
two characters to the left. Not sure where that comes from yet...

--
hundred-and-one symptoms of being an internet addict:
242. You turn down a better-paying job because it doesn't come with
a free e-mail account.

mattn

unread,
Oct 2, 2016, 8:37:49 AM10/2/16
to vim_dev, Br...@moolenaar.net
On Saturday, July 9, 2016 at 5:20:16 AM UTC+9, Bram Moolenaar wrote:
> I wrote:
>
> > Patch 7.4.2003
> > Problem: Still cursor flickering when a callback updates the screen. (David
> > Samvelyan)
> > Solution: Put the cursor in the right position after updating the screen.
> > Files: src/screen.c
>
> Looks like this fix triggers another cursor positioning problem.
> When doing "rx" it first gets displayed in the right place, then drawn
> two characters to the left. Not sure where that comes from yet...

As your worries, this change doesn't work with multi-byte characters correctly. When the cursor goes down bottom of screen, and the cursor overwrap with trailing-byte of multi-byte, screen break drawing.

[][][]_ []
--------------- bottom line
X[][][][]

"_" is cursor.

https://cloud.githubusercontent.com/assets/518808/19011184/a29ebeee-87c9-11e6-9d5e-032e9423b7ae.png

gui.col should be fixed if the cursor is overwrapped on the trailing-byte of multibyte.

diff --git a/src/screen.c b/src/screen.c
index 4604ec7..5ebca09 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -765,6 +765,9 @@ update_screen(int type)
* uses that. */
gui.col = gui_cursor_col;
gui.row = gui_cursor_row;
+# ifdef FEAT_MBYTE
+ gui.col = mb_fix_col(gui.col, gui.row);
+# endif
gui_update_cursor(FALSE, FALSE);
screen_cur_col = gui.col;
screen_cur_row = gui.row;

Bram Moolenaar

unread,
Oct 2, 2016, 5:09:59 PM10/2/16
to mattn, vim_dev

Yasuhiro Matsumoto wrote:

> On Saturday, July 9, 2016 at 5:20:16 AM UTC+9, Bram Moolenaar wrote:
> > I wrote:
> >
> > > Patch 7.4.2003
> > > Problem: Still cursor flickering when a callback updates the screen. (David
> > > Samvelyan)
> > > Solution: Put the cursor in the right position after updating the screen.
> > > Files: src/screen.c
> >
> > Looks like this fix triggers another cursor positioning problem.
> > When doing "rx" it first gets displayed in the right place, then drawn
> > two characters to the left. Not sure where that comes from yet...
>
> As your worries, this change doesn't work with multi-byte characters correctly. When the cursor goes down bottom of screen, and the cursor overwrap with trailing-byte of multi-byte, screen break drawing.
>
> [][][]_ []
> --------------- bottom line
> X[][][][]
>
> "_" is cursor.
>
> https://cloud.githubusercontent.com/assets/518808/19011184/a29ebeee-87c9-11e6-9d5e-032e9423b7ae.png
>
> gui.col should be fixed if the cursor is overwrapped on the
> trailing-byte of multibyte.

Thanks. I suppose it's not so easy to write a test for this.

--
ARTHUR: I command you as King of the Britons to stand aside!
BLACK KNIGHT: I move for no man.
The Quest for the Holy Grail (Monty Python)
Reply all
Reply to author
Forward
0 new messages