mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: move f_screenpos() to move.c
This commit is contained in:
parent
738c204523
commit
4448fa88ec
@ -7057,32 +7057,6 @@ static void f_screencol(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
rettv->vval.v_number = ui_current_col() + 1;
|
rettv->vval.v_number = ui_current_col() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "screenpos({winid}, {lnum}, {col})" function
|
|
||||||
static void f_screenpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|
||||||
{
|
|
||||||
tv_dict_alloc_ret(rettv);
|
|
||||||
dict_T *dict = rettv->vval.v_dict;
|
|
||||||
|
|
||||||
win_T *wp = find_win_by_nr_or_id(&argvars[0]);
|
|
||||||
if (wp == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pos_T pos = {
|
|
||||||
.lnum = (linenr_T)tv_get_number(&argvars[1]),
|
|
||||||
.col = (colnr_T)tv_get_number(&argvars[2]) - 1,
|
|
||||||
.coladd = 0
|
|
||||||
};
|
|
||||||
int row = 0;
|
|
||||||
int scol = 0, ccol = 0, ecol = 0;
|
|
||||||
textpos2screenpos(wp, &pos, &row, &scol, &ccol, &ecol, false);
|
|
||||||
|
|
||||||
tv_dict_add_nr(dict, S_LEN("row"), row);
|
|
||||||
tv_dict_add_nr(dict, S_LEN("col"), scol);
|
|
||||||
tv_dict_add_nr(dict, S_LEN("curscol"), ccol);
|
|
||||||
tv_dict_add_nr(dict, S_LEN("endcol"), ecol);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// "screenrow()" function
|
/// "screenrow()" function
|
||||||
static void f_screenrow(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
static void f_screenrow(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "nvim/diff.h"
|
#include "nvim/diff.h"
|
||||||
#include "nvim/drawscreen.h"
|
#include "nvim/drawscreen.h"
|
||||||
#include "nvim/edit.h"
|
#include "nvim/edit.h"
|
||||||
|
#include "nvim/eval.h"
|
||||||
#include "nvim/fold.h"
|
#include "nvim/fold.h"
|
||||||
#include "nvim/getchar.h"
|
#include "nvim/getchar.h"
|
||||||
#include "nvim/grid.h"
|
#include "nvim/grid.h"
|
||||||
@ -977,6 +978,32 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
|||||||
*ecolp = ecol + coloff;
|
*ecolp = ecol + coloff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// "screenpos({winid}, {lnum}, {col})" function
|
||||||
|
void f_screenpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||||
|
{
|
||||||
|
tv_dict_alloc_ret(rettv);
|
||||||
|
dict_T *dict = rettv->vval.v_dict;
|
||||||
|
|
||||||
|
win_T *wp = find_win_by_nr_or_id(&argvars[0]);
|
||||||
|
if (wp == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos_T pos = {
|
||||||
|
.lnum = (linenr_T)tv_get_number(&argvars[1]),
|
||||||
|
.col = (colnr_T)tv_get_number(&argvars[2]) - 1,
|
||||||
|
.coladd = 0
|
||||||
|
};
|
||||||
|
int row = 0;
|
||||||
|
int scol = 0, ccol = 0, ecol = 0;
|
||||||
|
textpos2screenpos(wp, &pos, &row, &scol, &ccol, &ecol, false);
|
||||||
|
|
||||||
|
tv_dict_add_nr(dict, S_LEN("row"), row);
|
||||||
|
tv_dict_add_nr(dict, S_LEN("col"), scol);
|
||||||
|
tv_dict_add_nr(dict, S_LEN("curscol"), ccol);
|
||||||
|
tv_dict_add_nr(dict, S_LEN("endcol"), ecol);
|
||||||
|
}
|
||||||
|
|
||||||
/// Scroll the current window down by "line_count" logical lines. "CTRL-Y"
|
/// Scroll the current window down by "line_count" logical lines. "CTRL-Y"
|
||||||
///
|
///
|
||||||
/// @param line_count number of lines to scroll
|
/// @param line_count number of lines to scroll
|
||||||
|
Loading…
Reference in New Issue
Block a user