Karsten Hopp c5bd7e
To: vim_dev@googlegroups.com
Karsten Hopp c5bd7e
Subject: Patch 7.3.781
Karsten Hopp c5bd7e
Fcc: outbox
Karsten Hopp c5bd7e
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp c5bd7e
Mime-Version: 1.0
Karsten Hopp c5bd7e
Content-Type: text/plain; charset=UTF-8
Karsten Hopp c5bd7e
Content-Transfer-Encoding: 8bit
Karsten Hopp c5bd7e
------------
Karsten Hopp c5bd7e
Karsten Hopp c5bd7e
Patch 7.3.781
Karsten Hopp c5bd7e
Problem:    Drawing with 'guifontwide' can be slow.
Karsten Hopp c5bd7e
Solution:   Draw multiple characters at a time. (Taro Muraoka)
Karsten Hopp c5bd7e
Files:	    src/gui.c
Karsten Hopp c5bd7e
Karsten Hopp c5bd7e
Karsten Hopp c5bd7e
*** ../vim-7.3.780/src/gui.c	2012-11-20 12:03:02.000000000 +0100
Karsten Hopp c5bd7e
--- src/gui.c	2013-01-23 17:28:48.000000000 +0100
Karsten Hopp c5bd7e
***************
Karsten Hopp c5bd7e
*** 2380,2386 ****
Karsten Hopp c5bd7e
  	int	cl;		/* byte length of current char */
Karsten Hopp c5bd7e
  	int	comping;	/* current char is composing */
Karsten Hopp c5bd7e
  	int	scol = col;	/* screen column */
Karsten Hopp c5bd7e
! 	int	dowide;		/* use 'guifontwide' */
Karsten Hopp c5bd7e
  
Karsten Hopp c5bd7e
  	/* Break the string at a composing character, it has to be drawn on
Karsten Hopp c5bd7e
  	 * top of the previous character. */
Karsten Hopp c5bd7e
--- 2380,2388 ----
Karsten Hopp c5bd7e
  	int	cl;		/* byte length of current char */
Karsten Hopp c5bd7e
  	int	comping;	/* current char is composing */
Karsten Hopp c5bd7e
  	int	scol = col;	/* screen column */
Karsten Hopp c5bd7e
! 	int	curr_wide;	/* use 'guifontwide' */
Karsten Hopp c5bd7e
! 	int	prev_wide = FALSE;
Karsten Hopp c5bd7e
! 	int	wide_changed;
Karsten Hopp c5bd7e
  
Karsten Hopp c5bd7e
  	/* Break the string at a composing character, it has to be drawn on
Karsten Hopp c5bd7e
  	 * top of the previous character. */
Karsten Hopp c5bd7e
***************
Karsten Hopp c5bd7e
*** 2395,2403 ****
Karsten Hopp c5bd7e
  		    && fontset == NOFONTSET
Karsten Hopp c5bd7e
  #  endif
Karsten Hopp c5bd7e
  		    && gui.wide_font != NOFONT)
Karsten Hopp c5bd7e
! 		dowide = TRUE;
Karsten Hopp c5bd7e
  	    else
Karsten Hopp c5bd7e
! 		dowide = FALSE;
Karsten Hopp c5bd7e
  	    comping = utf_iscomposing(c);
Karsten Hopp c5bd7e
  	    if (!comping)	/* count cells from non-composing chars */
Karsten Hopp c5bd7e
  		cells += cn;
Karsten Hopp c5bd7e
--- 2397,2405 ----
Karsten Hopp c5bd7e
  		    && fontset == NOFONTSET
Karsten Hopp c5bd7e
  #  endif
Karsten Hopp c5bd7e
  		    && gui.wide_font != NOFONT)
Karsten Hopp c5bd7e
! 		curr_wide = TRUE;
Karsten Hopp c5bd7e
  	    else
Karsten Hopp c5bd7e
! 		curr_wide = FALSE;
Karsten Hopp c5bd7e
  	    comping = utf_iscomposing(c);
Karsten Hopp c5bd7e
  	    if (!comping)	/* count cells from non-composing chars */
Karsten Hopp c5bd7e
  		cells += cn;
Karsten Hopp c5bd7e
***************
Karsten Hopp c5bd7e
*** 2405,2413 ****
Karsten Hopp c5bd7e
  	    if (cl == 0)	/* hit end of string */
Karsten Hopp c5bd7e
  		len = i + cl;	/* len must be wrong "cannot happen" */
Karsten Hopp c5bd7e
  
Karsten Hopp c5bd7e
! 	    /* print the string so far if it's the last character or there is
Karsten Hopp c5bd7e
  	     * a composing character. */
Karsten Hopp c5bd7e
! 	    if (i + cl >= len || (comping && i > start) || dowide
Karsten Hopp c5bd7e
  #  if defined(FEAT_GUI_X11)
Karsten Hopp c5bd7e
  		    || (cn > 1
Karsten Hopp c5bd7e
  #   ifdef FEAT_XFONTSET
Karsten Hopp c5bd7e
--- 2407,2417 ----
Karsten Hopp c5bd7e
  	    if (cl == 0)	/* hit end of string */
Karsten Hopp c5bd7e
  		len = i + cl;	/* len must be wrong "cannot happen" */
Karsten Hopp c5bd7e
  
Karsten Hopp c5bd7e
! 	    wide_changed = curr_wide != prev_wide;
Karsten Hopp c5bd7e
! 
Karsten Hopp c5bd7e
! 	    /* Print the string so far if it's the last character or there is
Karsten Hopp c5bd7e
  	     * a composing character. */
Karsten Hopp c5bd7e
! 	    if (i + cl >= len || (comping && i > start) || wide_changed
Karsten Hopp c5bd7e
  #  if defined(FEAT_GUI_X11)
Karsten Hopp c5bd7e
  		    || (cn > 1
Karsten Hopp c5bd7e
  #   ifdef FEAT_XFONTSET
Karsten Hopp c5bd7e
***************
Karsten Hopp c5bd7e
*** 2419,2443 ****
Karsten Hopp c5bd7e
  #  endif
Karsten Hopp c5bd7e
  	       )
Karsten Hopp c5bd7e
  	    {
Karsten Hopp c5bd7e
! 		if (comping || dowide)
Karsten Hopp c5bd7e
  		    thislen = i - start;
Karsten Hopp c5bd7e
  		else
Karsten Hopp c5bd7e
  		    thislen = i - start + cl;
Karsten Hopp c5bd7e
  		if (thislen > 0)
Karsten Hopp c5bd7e
  		{
Karsten Hopp c5bd7e
  		    gui_mch_draw_string(gui.row, scol, s + start, thislen,
Karsten Hopp c5bd7e
  								  draw_flags);
Karsten Hopp c5bd7e
  		    start += thislen;
Karsten Hopp c5bd7e
  		}
Karsten Hopp c5bd7e
  		scol += cells;
Karsten Hopp c5bd7e
  		cells = 0;
Karsten Hopp c5bd7e
! 		if (dowide)
Karsten Hopp c5bd7e
  		{
Karsten Hopp c5bd7e
! 		    gui_mch_set_font(gui.wide_font);
Karsten Hopp c5bd7e
! 		    gui_mch_draw_string(gui.row, scol - cn,
Karsten Hopp c5bd7e
! 						   s + start, cl, draw_flags);
Karsten Hopp c5bd7e
! 		    gui_mch_set_font(font);
Karsten Hopp c5bd7e
! 		    start += cl;
Karsten Hopp c5bd7e
  		}
Karsten Hopp c5bd7e
  
Karsten Hopp c5bd7e
  #  if defined(FEAT_GUI_X11)
Karsten Hopp c5bd7e
--- 2423,2450 ----
Karsten Hopp c5bd7e
  #  endif
Karsten Hopp c5bd7e
  	       )
Karsten Hopp c5bd7e
  	    {
Karsten Hopp c5bd7e
! 		if (comping || wide_changed)
Karsten Hopp c5bd7e
  		    thislen = i - start;
Karsten Hopp c5bd7e
  		else
Karsten Hopp c5bd7e
  		    thislen = i - start + cl;
Karsten Hopp c5bd7e
  		if (thislen > 0)
Karsten Hopp c5bd7e
  		{
Karsten Hopp c5bd7e
+ 		    if (prev_wide)
Karsten Hopp c5bd7e
+ 			gui_mch_set_font(gui.wide_font);
Karsten Hopp c5bd7e
  		    gui_mch_draw_string(gui.row, scol, s + start, thislen,
Karsten Hopp c5bd7e
  								  draw_flags);
Karsten Hopp c5bd7e
+ 		    if (prev_wide)
Karsten Hopp c5bd7e
+ 			gui_mch_set_font(font);
Karsten Hopp c5bd7e
  		    start += thislen;
Karsten Hopp c5bd7e
  		}
Karsten Hopp c5bd7e
  		scol += cells;
Karsten Hopp c5bd7e
  		cells = 0;
Karsten Hopp c5bd7e
! 		/* Adjust to not draw a character which width is changed
Karsten Hopp c5bd7e
! 		 * against with last one. */
Karsten Hopp c5bd7e
! 		if (wide_changed && !comping)
Karsten Hopp c5bd7e
  		{
Karsten Hopp c5bd7e
! 		    scol -= cn;
Karsten Hopp c5bd7e
! 		    cl = 0;
Karsten Hopp c5bd7e
  		}
Karsten Hopp c5bd7e
  
Karsten Hopp c5bd7e
  #  if defined(FEAT_GUI_X11)
Karsten Hopp c5bd7e
***************
Karsten Hopp c5bd7e
*** 2447,2453 ****
Karsten Hopp c5bd7e
  #   ifdef FEAT_XFONTSET
Karsten Hopp c5bd7e
  			&& fontset == NOFONTSET
Karsten Hopp c5bd7e
  #   endif
Karsten Hopp c5bd7e
! 			&& !dowide)
Karsten Hopp c5bd7e
  		    gui_mch_draw_string(gui.row, scol - 1, (char_u *)" ",
Karsten Hopp c5bd7e
  							       1, draw_flags);
Karsten Hopp c5bd7e
  #  endif
Karsten Hopp c5bd7e
--- 2454,2460 ----
Karsten Hopp c5bd7e
  #   ifdef FEAT_XFONTSET
Karsten Hopp c5bd7e
  			&& fontset == NOFONTSET
Karsten Hopp c5bd7e
  #   endif
Karsten Hopp c5bd7e
! 			&& !wide_changed)
Karsten Hopp c5bd7e
  		    gui_mch_draw_string(gui.row, scol - 1, (char_u *)" ",
Karsten Hopp c5bd7e
  							       1, draw_flags);
Karsten Hopp c5bd7e
  #  endif
Karsten Hopp c5bd7e
***************
Karsten Hopp c5bd7e
*** 2465,2470 ****
Karsten Hopp c5bd7e
--- 2472,2478 ----
Karsten Hopp c5bd7e
  #  endif
Karsten Hopp c5bd7e
  		start = i + cl;
Karsten Hopp c5bd7e
  	    }
Karsten Hopp c5bd7e
+ 	    prev_wide = curr_wide;
Karsten Hopp c5bd7e
  	}
Karsten Hopp c5bd7e
  	/* The stuff below assumes "len" is the length in screen columns. */
Karsten Hopp c5bd7e
  	len = scol - col;
Karsten Hopp c5bd7e
*** ../vim-7.3.780/src/version.c	2013-01-23 17:15:25.000000000 +0100
Karsten Hopp c5bd7e
--- src/version.c	2013-01-23 17:28:17.000000000 +0100
Karsten Hopp c5bd7e
***************
Karsten Hopp c5bd7e
*** 727,728 ****
Karsten Hopp c5bd7e
--- 727,730 ----
Karsten Hopp c5bd7e
  {   /* Add new patch number below this line */
Karsten Hopp c5bd7e
+ /**/
Karsten Hopp c5bd7e
+     781,
Karsten Hopp c5bd7e
  /**/
Karsten Hopp c5bd7e
Karsten Hopp c5bd7e
-- 
Karsten Hopp c5bd7e
GUARD #1:  Where'd you get the coconut?
Karsten Hopp c5bd7e
ARTHUR:    We found them.
Karsten Hopp c5bd7e
GUARD #1:  Found them?  In Mercea?  The coconut's tropical!
Karsten Hopp c5bd7e
ARTHUR:    What do you mean?
Karsten Hopp c5bd7e
GUARD #1:  Well, this is a temperate zone.
Karsten Hopp c5bd7e
                                  The Quest for the Holy Grail (Monty Python)
Karsten Hopp c5bd7e
Karsten Hopp c5bd7e
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp c5bd7e
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp c5bd7e
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp c5bd7e
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///