Karsten Hopp 80d541
To: vim_dev@googlegroups.com
Karsten Hopp 80d541
Subject: Patch 7.3.1164
Karsten Hopp 80d541
Fcc: outbox
Karsten Hopp 80d541
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 80d541
Mime-Version: 1.0
Karsten Hopp 80d541
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 80d541
Content-Transfer-Encoding: 8bit
Karsten Hopp 80d541
------------
Karsten Hopp 80d541
Karsten Hopp 80d541
Patch 7.3.1164
Karsten Hopp 80d541
Problem:    Can't test what is actually displayed on screen.
Karsten Hopp 80d541
Solution:   Add the screenchar() and screenattr() functions.
Karsten Hopp 80d541
Files:      src/eval.c, runtime/doc/eval.txt
Karsten Hopp 80d541
    
Karsten Hopp 80d541
Karsten Hopp 80d541
*** ../vim-7.3.1163/src/eval.c	2013-06-10 20:10:40.000000000 +0200
Karsten Hopp 80d541
--- src/eval.c	2013-06-10 23:15:38.000000000 +0200
Karsten Hopp 80d541
***************
Karsten Hopp 80d541
*** 654,659 ****
Karsten Hopp 80d541
--- 654,661 ----
Karsten Hopp 80d541
  #ifdef FEAT_FLOAT
Karsten Hopp 80d541
  static void f_round __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 80d541
  #endif
Karsten Hopp 80d541
+ static void f_screenattr __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 80d541
+ static void f_screenchar __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 80d541
  static void f_screencol __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 80d541
  static void f_screenrow __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 80d541
  static void f_search __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 80d541
***************
Karsten Hopp 80d541
*** 8037,8042 ****
Karsten Hopp 80d541
--- 8039,8046 ----
Karsten Hopp 80d541
  #ifdef FEAT_FLOAT
Karsten Hopp 80d541
      {"round",		1, 1, f_round},
Karsten Hopp 80d541
  #endif
Karsten Hopp 80d541
+     {"screenattr",	2, 2, f_screenattr},
Karsten Hopp 80d541
+     {"screenchar",	2, 2, f_screenchar},
Karsten Hopp 80d541
      {"screencol",	0, 0, f_screencol},
Karsten Hopp 80d541
      {"screenrow",	0, 0, f_screenrow},
Karsten Hopp 80d541
      {"search",		1, 4, f_search},
Karsten Hopp 80d541
***************
Karsten Hopp 80d541
*** 15804,15809 ****
Karsten Hopp 80d541
--- 15808,15866 ----
Karsten Hopp 80d541
  #endif
Karsten Hopp 80d541
  
Karsten Hopp 80d541
  /*
Karsten Hopp 80d541
+  * "screenattr()" function
Karsten Hopp 80d541
+  */
Karsten Hopp 80d541
+     static void
Karsten Hopp 80d541
+ f_screenattr(argvars, rettv)
Karsten Hopp 80d541
+     typval_T	*argvars UNUSED;
Karsten Hopp 80d541
+     typval_T	*rettv;
Karsten Hopp 80d541
+ {
Karsten Hopp 80d541
+     int		row;
Karsten Hopp 80d541
+     int		col;
Karsten Hopp 80d541
+     int		c;
Karsten Hopp 80d541
+ 
Karsten Hopp 80d541
+     row = get_tv_number_chk(&argvars[0], NULL) - 1;
Karsten Hopp 80d541
+     col = get_tv_number_chk(&argvars[1], NULL) - 1;
Karsten Hopp 80d541
+     if (row < 0 || row >= screen_Rows
Karsten Hopp 80d541
+ 	    || col < 0 || col >= screen_Columns)
Karsten Hopp 80d541
+ 	c = -1;
Karsten Hopp 80d541
+     else
Karsten Hopp 80d541
+ 	c = ScreenAttrs[LineOffset[row] + col];
Karsten Hopp 80d541
+     rettv->vval.v_number = c;
Karsten Hopp 80d541
+ }
Karsten Hopp 80d541
+ 
Karsten Hopp 80d541
+ /*
Karsten Hopp 80d541
+  * "screenchar()" function
Karsten Hopp 80d541
+  */
Karsten Hopp 80d541
+     static void
Karsten Hopp 80d541
+ f_screenchar(argvars, rettv)
Karsten Hopp 80d541
+     typval_T	*argvars UNUSED;
Karsten Hopp 80d541
+     typval_T	*rettv;
Karsten Hopp 80d541
+ {
Karsten Hopp 80d541
+     int		row;
Karsten Hopp 80d541
+     int		col;
Karsten Hopp 80d541
+     int		off;
Karsten Hopp 80d541
+     int		c;
Karsten Hopp 80d541
+ 
Karsten Hopp 80d541
+     row = get_tv_number_chk(&argvars[0], NULL) - 1;
Karsten Hopp 80d541
+     col = get_tv_number_chk(&argvars[1], NULL) - 1;
Karsten Hopp 80d541
+     if (row < 0 || row >= screen_Rows
Karsten Hopp 80d541
+ 	    || col < 0 || col >= screen_Columns)
Karsten Hopp 80d541
+ 	c = -1;
Karsten Hopp 80d541
+     else
Karsten Hopp 80d541
+     {
Karsten Hopp 80d541
+ 	off = LineOffset[row] + col;
Karsten Hopp 80d541
+ #ifdef FEAT_MBYTE
Karsten Hopp 80d541
+ 	if (enc_utf8 && ScreenLinesUC[off] != 0)
Karsten Hopp 80d541
+ 	    c = ScreenLinesUC[off];
Karsten Hopp 80d541
+ 	else
Karsten Hopp 80d541
+ #endif
Karsten Hopp 80d541
+ 	    c = ScreenLines[off];
Karsten Hopp 80d541
+     }
Karsten Hopp 80d541
+     rettv->vval.v_number = c;
Karsten Hopp 80d541
+ }
Karsten Hopp 80d541
+ 
Karsten Hopp 80d541
+ /*
Karsten Hopp 80d541
   * "screencol()" function
Karsten Hopp 80d541
   *
Karsten Hopp 80d541
   * First column is 1 to be consistent with virtcol().
Karsten Hopp 80d541
*** ../vim-7.3.1163/runtime/doc/eval.txt	2013-05-06 04:50:26.000000000 +0200
Karsten Hopp 80d541
--- runtime/doc/eval.txt	2013-06-11 18:39:17.000000000 +0200
Karsten Hopp 80d541
***************
Karsten Hopp 80d541
*** 1895,1900 ****
Karsten Hopp 80d541
--- 1906,1913 ----
Karsten Hopp 80d541
  resolve( {filename})		String	get filename a shortcut points to
Karsten Hopp 80d541
  reverse( {list})		List	reverse {list} in-place
Karsten Hopp 80d541
  round( {expr})			Float	round off {expr}
Karsten Hopp 80d541
+ screenattr( {row}, {col})	Number	attribute at screen position
Karsten Hopp 80d541
+ screenchar( {row}, {col})	Number	character at screen position
Karsten Hopp 80d541
  screencol()			Number	current cursor column
Karsten Hopp 80d541
  screenrow()			Number	current cursor row
Karsten Hopp 80d541
  search( {pattern} [, {flags} [, {stopline} [, {timeout}]]])
Karsten Hopp 80d541
***************
Karsten Hopp 80d541
*** 4863,4868 ****
Karsten Hopp 80d541
--- 4893,4913 ----
Karsten Hopp 80d541
  <			-5.0
Karsten Hopp 80d541
  		{only available when compiled with the |+float| feature}
Karsten Hopp 80d541
  
Karsten Hopp 80d541
+ screenattr(row, col)						*screenattr()*
Karsten Hopp 80d541
+ 		Like screenchar(), but return the attribute.  This is a rather
Karsten Hopp 80d541
+ 		arbitrary number that can only be used to compare to the
Karsten Hopp 80d541
+ 		attribute at other positions.
Karsten Hopp 80d541
+ 
Karsten Hopp 80d541
+ screenchar(row, col)						*screenchar()*
Karsten Hopp 80d541
+ 		The result is a Number, which is the character at position
Karsten Hopp 80d541
+ 		[row, col] on the screen.  This works for every possible
Karsten Hopp 80d541
+ 		screen position, also status lines, window separators and the
Karsten Hopp 80d541
+ 		command line.  The top left position is row one, column one
Karsten Hopp 80d541
+ 		The character excludes composing characters.  For double-byte
Karsten Hopp 80d541
+ 		encodings it may only be the first byte.
Karsten Hopp 80d541
+ 		This is mainly to be used for testing.
Karsten Hopp 80d541
+ 		Returns -1 when row or col is out of range.
Karsten Hopp 80d541
+ 
Karsten Hopp 80d541
  screencol()							*screencol()*
Karsten Hopp 80d541
  		The result is a Number, which is the current screen column of
Karsten Hopp 80d541
  		the cursor. The leftmost column has number 1.
Karsten Hopp 80d541
*** ../vim-7.3.1163/src/version.c	2013-06-10 21:27:18.000000000 +0200
Karsten Hopp 80d541
--- src/version.c	2013-06-11 18:36:46.000000000 +0200
Karsten Hopp 80d541
***************
Karsten Hopp 80d541
*** 730,731 ****
Karsten Hopp 80d541
--- 730,733 ----
Karsten Hopp 80d541
  {   /* Add new patch number below this line */
Karsten Hopp 80d541
+ /**/
Karsten Hopp 80d541
+     1164,
Karsten Hopp 80d541
  /**/
Karsten Hopp 80d541
Karsten Hopp 80d541
-- 
Karsten Hopp 80d541
Fingers not found - Pound head on keyboard to continue.
Karsten Hopp 80d541
Karsten Hopp 80d541
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 80d541
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 80d541
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 80d541
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///