]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.1164 v7.3.1164
authorBram Moolenaar <Bram@vim.org>
Tue, 11 Jun 2013 16:40:13 +0000 (18:40 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 11 Jun 2013 16:40:13 +0000 (18:40 +0200)
Problem:    Can't test what is actually displayed on screen.
Solution:   Add the screenchar() and screenattr() functions.

runtime/doc/eval.txt
src/eval.c
src/version.c

index f7cc93b7231a646c9cd14a84b128e2cc3485a9cf..09eb22dbd5457b21e9202570c5adea20d17b22a5 100644 (file)
@@ -1906,6 +1906,8 @@ repeat( {expr}, {count})  String  repeat {expr} {count} times
 resolve( {filename})           String  get filename a shortcut points to
 reverse( {list})               List    reverse {list} in-place
 round( {expr})                 Float   round off {expr}
+screenattr( {row}, {col})      Number  attribute at screen position
+screenchar( {row}, {col})      Number  character at screen position
 screencol()                    Number  current cursor column
 screenrow()                    Number  current cursor row
 search( {pattern} [, {flags} [, {stopline} [, {timeout}]]])
@@ -4890,6 +4892,21 @@ round({expr})                                                    *round()*
 <                      -5.0
                {only available when compiled with the |+float| feature}
 
+screenattr(row, col)                                           *screenattr()*
+               Like screenchar(), but return the attribute.  This is a rather
+               arbitrary number that can only be used to compare to the
+               attribute at other positions.
+
+screenchar(row, col)                                           *screenchar()*
+               The result is a Number, which is the character at position
+               [row, col] on the screen.  This works for every possible
+               screen position, also status lines, window separators and the
+               command line.  The top left position is row one, column one
+               The character excludes composing characters.  For double-byte
+               encodings it may only be the first byte.
+               This is mainly to be used for testing.
+               Returns -1 when row or col is out of range.
+
 screencol()                                                    *screencol()*
                The result is a Number, which is the current screen column of
                the cursor. The leftmost column has number 1.
index 38893c795db43398b223e867e1e4fcb84e1287f6..81c3ca278a6ee657894e0ca16cb6fc5a8605ba36 100644 (file)
@@ -654,6 +654,8 @@ static void f_reverse __ARGS((typval_T *argvars, typval_T *rettv));
 #ifdef FEAT_FLOAT
 static void f_round __ARGS((typval_T *argvars, typval_T *rettv));
 #endif
+static void f_screenattr __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_screenchar __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_screencol __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_screenrow __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_search __ARGS((typval_T *argvars, typval_T *rettv));
@@ -8037,6 +8039,8 @@ static struct fst
 #ifdef FEAT_FLOAT
     {"round",          1, 1, f_round},
 #endif
+    {"screenattr",     2, 2, f_screenattr},
+    {"screenchar",     2, 2, f_screenchar},
     {"screencol",      0, 0, f_screencol},
     {"screenrow",      0, 0, f_screenrow},
     {"search",         1, 4, f_search},
@@ -15803,6 +15807,59 @@ f_round(argvars, rettv)
 }
 #endif
 
+/*
+ * "screenattr()" function
+ */
+    static void
+f_screenattr(argvars, rettv)
+    typval_T   *argvars UNUSED;
+    typval_T   *rettv;
+{
+    int                row;
+    int                col;
+    int                c;
+
+    row = get_tv_number_chk(&argvars[0], NULL) - 1;
+    col = get_tv_number_chk(&argvars[1], NULL) - 1;
+    if (row < 0 || row >= screen_Rows
+           || col < 0 || col >= screen_Columns)
+       c = -1;
+    else
+       c = ScreenAttrs[LineOffset[row] + col];
+    rettv->vval.v_number = c;
+}
+
+/*
+ * "screenchar()" function
+ */
+    static void
+f_screenchar(argvars, rettv)
+    typval_T   *argvars UNUSED;
+    typval_T   *rettv;
+{
+    int                row;
+    int                col;
+    int                off;
+    int                c;
+
+    row = get_tv_number_chk(&argvars[0], NULL) - 1;
+    col = get_tv_number_chk(&argvars[1], NULL) - 1;
+    if (row < 0 || row >= screen_Rows
+           || col < 0 || col >= screen_Columns)
+       c = -1;
+    else
+    {
+       off = LineOffset[row] + col;
+#ifdef FEAT_MBYTE
+       if (enc_utf8 && ScreenLinesUC[off] != 0)
+           c = ScreenLinesUC[off];
+       else
+#endif
+           c = ScreenLines[off];
+    }
+    rettv->vval.v_number = c;
+}
+
 /*
  * "screencol()" function
  *
index 6be6a6cffed21cef6cde4cb0ca871ab8c9e8d2d4..0122a8092ab81e98604abab9063c5bdd4f2595a9 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1164,
 /**/
     1163,
 /**/