On Wed, Sep 05, 2012 at 03:46:00PM +0200, Bram Moolenaar wrote: >> Thanks for pointing me to this patch. It fixes a few tab related >> issues I just noticed (and tried to fix - you saved me some time, >> thanks). > > Which patch is that, who sent it?
It's Dominique Pellé's patch: http://comments.gmane.org/gmane.editors.vim.devel/33830 > This doesn't look like a nice solution. We could add something in Vim > to report the screen position of the cursor. Perhaps with a function. > The test could use that to check where the cursor really is. You're right it isn't. A function would be much better. I don't know the Vim internals very well, so I just used what was already available. I tried to add the functions (patch attached - as I'm new to Vim internals, please tell me if that's the correct way to do it), but there is one major problem. screen_cur_col and screen_cur_row report the current cursor position - which is of course the command line where the current command is entered (also in tests), e.g. 0, 38. That means we have to save the current cursor position before jumping to the command line when the users enters a command, but I don't know what's the correct place for this task. Please help me with that. Regards, Simon -- + privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9
From 1df0761b0fa1392edbd376e3e6be3c502b20ceee Mon Sep 17 00:00:00 2001 Message-Id: <1df0761b0fa1392edbd376e3e6be3c502b20ceee.1346863957.git.si...@ruderich.org> From: Simon Ruderich <[email protected]> Date: Wed, 5 Sep 2012 18:52:20 +0200 Subject: [PATCH] Add screencol() and screenrow() functions. --- src/eval.c | 26 ++++++++++++++++++++++++++ src/screen.c | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-) diff --git a/src/eval.c b/src/eval.c index 98b2a33..c9864fb 100644 --- a/src/eval.c +++ b/src/eval.c @@ -668,6 +668,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_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)); static void f_searchdecl __ARGS((typval_T *argvars, typval_T *rettv)); static void f_searchpair __ARGS((typval_T *argvars, typval_T *rettv)); @@ -8032,6 +8034,8 @@ static struct fst #ifdef FEAT_FLOAT {"round", 1, 1, f_round}, #endif + {"screencol", 0, 0, f_screencol}, + {"screenrow", 0, 0, f_screenrow}, {"search", 1, 4, f_search}, {"searchdecl", 1, 3, f_searchdecl}, {"searchpair", 3, 7, f_searchpair}, @@ -15717,6 +15721,28 @@ f_round(argvars, rettv) #endif /* + * "screencol()" function + */ + static void +f_screencol(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + rettv->vval.v_number = screen_screencol(); +} + +/* + * "screenrow()" function + */ + static void +f_screenrow(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + rettv->vval.v_number = screen_screenrow(); +} + +/* * "search()" function */ static void diff --git a/src/screen.c b/src/screen.c index 5dccbd7..6892203 100644 --- a/src/screen.c +++ b/src/screen.c @@ -10263,3 +10263,22 @@ number_width(wp) return n; } #endif + +/* + * Return the current cursor column. This is the actual position on the + * screen. + */ + int +screen_screencol() +{ + return screen_cur_col; +} + +/* + * Return the current cursor row. This is the actual position on the screen. + */ + int +screen_screenrow() +{ + return screen_cur_row; +} -- 1.7.7.3
pgpq9mBUxtdv9.pgp
Description: PGP signature
