aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Platto <hinidu@gmail.com>2014-05-16 11:59:00 +0300
committerJustin M. Keyes <justinkz@gmail.com>2014-05-28 10:42:06 -0400
commitbaaa4287851ecf478b40054efd7b786501eb70ef (patch)
tree37a5b788a29278e8a4e27b6e9c5c9f787da41a60
parent2a154ef71de506e64fbbc2d8e613b5a696f8cb60 (diff)
downloadrneovim-baaa4287851ecf478b40054efd7b786501eb70ef.tar.gz
rneovim-baaa4287851ecf478b40054efd7b786501eb70ef.tar.bz2
rneovim-baaa4287851ecf478b40054efd7b786501eb70ef.zip
Remove ml_ prefix from cursor.h functions
s/ml_get_curline/get_cursor_line_ptr s/ml_get_cursor/get_cursor_pos_ptr
-rw-r--r--src/nvim/cursor.c10
-rw-r--r--src/nvim/cursor.h4
-rw-r--r--src/nvim/edit.c96
-rw-r--r--src/nvim/eval.c6
-rw-r--r--src/nvim/ex_cmds.c4
-rw-r--r--src/nvim/ex_docmd.c2
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/farsi.c26
-rw-r--r--src/nvim/getchar.c4
-rw-r--r--src/nvim/indent.c14
-rw-r--r--src/nvim/indent_c.c80
-rw-r--r--src/nvim/mbyte.c8
-rw-r--r--src/nvim/misc1.c14
-rw-r--r--src/nvim/move.c2
-rw-r--r--src/nvim/normal.c47
-rw-r--r--src/nvim/ops.c36
-rw-r--r--src/nvim/quickfix.c2
-rw-r--r--src/nvim/screen.c2
-rw-r--r--src/nvim/search.c20
-rw-r--r--src/nvim/spell.c10
-rw-r--r--src/nvim/window.c2
21 files changed, 197 insertions, 194 deletions
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index e90422bf6d..8427f2a0a2 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -70,7 +70,7 @@ int coladvance(colnr_T wcol)
if (wcol == MAXCOL || rc == FAIL)
curwin->w_valid &= ~VALID_VIRTCOL;
- else if (*ml_get_cursor() != TAB) {
+ else if (*get_cursor_pos_ptr() != TAB) {
/* Virtcol is valid when not on a TAB */
curwin->w_valid |= VALID_VIRTCOL;
curwin->w_virtcol = wcol;
@@ -444,8 +444,8 @@ int leftcol_changed(void)
int gchar_cursor(void)
{
if (has_mbyte)
- return (*mb_ptr2char)(ml_get_cursor());
- return (int)*ml_get_cursor();
+ return (*mb_ptr2char)(get_cursor_pos_ptr());
+ return (int)*get_cursor_pos_ptr();
}
/*
@@ -461,7 +461,7 @@ void pchar_cursor(char_u c)
/*
* Return pointer to cursor line.
*/
-char_u *ml_get_curline(void)
+char_u *get_cursor_line_ptr(void)
{
return ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE);
}
@@ -469,7 +469,7 @@ char_u *ml_get_curline(void)
/*
* Return pointer to cursor position.
*/
-char_u *ml_get_cursor(void)
+char_u *get_cursor_pos_ptr(void)
{
return ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE) +
curwin->w_cursor.col;
diff --git a/src/nvim/cursor.h b/src/nvim/cursor.h
index 5cf28ce590..3cceb0261e 100644
--- a/src/nvim/cursor.h
+++ b/src/nvim/cursor.h
@@ -20,8 +20,8 @@ void adjust_cursor_col(void);
int leftcol_changed(void);
int gchar_cursor(void);
void pchar_cursor(char_u c);
-char_u *ml_get_curline(void);
-char_u *ml_get_cursor(void);
+char_u *get_cursor_line_ptr(void);
+char_u *get_cursor_pos_ptr(void);
#endif // NVIM_CURSOR_H
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 5ce73e5dc8..6ea88843ab 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -428,7 +428,7 @@ edit (
if (startln)
Insstart.col = 0;
}
- Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
+ Insstart_textlen = (colnr_T)linetabsize(get_cursor_line_ptr());
Insstart_blank_vcol = MAXCOL;
if (!did_ai)
ai_col = 0;
@@ -521,7 +521,7 @@ edit (
update_curswant();
if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum)
|| curwin->w_curswant > curwin->w_virtcol)
- && *(ptr = ml_get_curline() + curwin->w_cursor.col) != NUL) {
+ && *(ptr = get_cursor_line_ptr() + curwin->w_cursor.col) != NUL) {
if (ptr[1] == NUL)
++curwin->w_cursor.col;
else if (has_mbyte) {
@@ -1501,7 +1501,7 @@ void display_dollar(colnr_T col)
char_u *p;
/* If on the last byte of a multi-byte move to the first byte. */
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
curwin->w_cursor.col -= (*mb_head_off)(p, p + col);
}
curs_columns(FALSE); /* recompute w_wrow and w_wcol */
@@ -1555,7 +1555,7 @@ change_indent (
/* VREPLACE mode needs to know what the line was like before changing */
if (State & VREPLACE_FLAG) {
- orig_line = vim_strsave(ml_get_curline()); /* Deal with NULL below */
+ orig_line = vim_strsave(get_cursor_line_ptr()); /* Deal with NULL below */
orig_col = curwin->w_cursor.col;
}
@@ -1636,7 +1636,7 @@ change_indent (
*/
vcol = last_vcol = 0;
new_cursor_col = -1;
- ptr = ml_get_curline();
+ ptr = get_cursor_line_ptr();
while (vcol <= (int)curwin->w_virtcol) {
last_vcol = vcol;
if (has_mbyte && new_cursor_col >= 0)
@@ -1727,7 +1727,7 @@ change_indent (
return;
/* Save new line */
- new_line = vim_strsave(ml_get_curline());
+ new_line = vim_strsave(get_cursor_line_ptr());
/* We only put back the new line up to the cursor */
new_line[curwin->w_cursor.col] = NUL;
@@ -1798,13 +1798,13 @@ static int del_char_after_col(int limit_col)
* composing character. */
mb_adjust_cursor();
while (curwin->w_cursor.col < (colnr_T)limit_col) {
- int l = utf_ptr2len(ml_get_cursor());
+ int l = utf_ptr2len(get_cursor_pos_ptr());
if (l == 0) /* end of line */
break;
curwin->w_cursor.col += l;
}
- if (*ml_get_cursor() == NUL || curwin->w_cursor.col == ecol)
+ if (*get_cursor_pos_ptr() == NUL || curwin->w_cursor.col == ecol)
return FALSE;
del_bytes((long)((int)ecol - curwin->w_cursor.col), FALSE, TRUE);
} else
@@ -2321,7 +2321,8 @@ void set_completion(colnr_T startcol, list_T *list)
compl_col = startcol;
compl_length = (int)curwin->w_cursor.col - (int)startcol;
/* compl_pattern doesn't need to be set */
- compl_orig_text = vim_strnsave(ml_get_curline() + compl_col, compl_length);
+ compl_orig_text = vim_strnsave(get_cursor_line_ptr() + compl_col,
+ compl_length);
if (ins_compl_add(compl_orig_text, -1, p_ic, NULL, NULL, 0,
ORIGINAL_TEXT, FALSE) != OK) {
return;
@@ -2849,7 +2850,7 @@ static int ins_compl_bs(void)
char_u *line;
char_u *p;
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
p = line + curwin->w_cursor.col;
mb_ptr_back(line, p);
@@ -2971,7 +2972,7 @@ static void ins_compl_addleader(int c)
* break redo. */
if (!compl_opt_refresh_always) {
free(compl_leader);
- compl_leader = vim_strnsave(ml_get_curline() + compl_col,
+ compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col,
(int)(curwin->w_cursor.col - compl_col));
ins_compl_new_leader();
}
@@ -3220,7 +3221,7 @@ static int ins_compl_prep(int c)
if (stop_arrow() == OK)
insertchar(NUL, 0, -1);
if (prev_col > 0
- && ml_get_curline()[curwin->w_cursor.col] != NUL)
+ && get_cursor_line_ptr()[curwin->w_cursor.col] != NUL)
inc_cursor();
}
@@ -4921,7 +4922,8 @@ insert_special (
# define WHITECHAR(cc) (vim_iswhite(cc) && \
(!enc_utf8 || \
- !utf_iscomposing(utf_ptr2char(ml_get_cursor() + 1))))
+ !utf_iscomposing( \
+ utf_ptr2char(get_cursor_pos_ptr() + 1))))
/*
* "flags": INSCHAR_FORMAT - force formatting
@@ -4967,7 +4969,7 @@ insertchar (
|| (!vim_iswhite(c)
&& !((State & REPLACE_FLAG)
&& !(State & VREPLACE_FLAG)
- && *ml_get_cursor() != NUL)
+ && *get_cursor_pos_ptr() != NUL)
&& (curwin->w_cursor.lnum != Insstart.lnum
|| ((!has_format_option(FO_INS_LONG)
|| Insstart_textlen <= (colnr_T)textwidth)
@@ -5002,7 +5004,7 @@ insertchar (
* Need to remove existing (middle) comment leader and insert end
* comment leader. First, check what comment leader we can find.
*/
- i = get_leader_len(line = ml_get_curline(), &p, FALSE, TRUE);
+ i = get_leader_len(line = get_cursor_line_ptr(), &p, FALSE, TRUE);
if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) { /* Just checking */
/* Skip middle-comment string */
while (*p && p[-1] != ':') /* find end of middle flags */
@@ -5198,7 +5200,7 @@ internal_format (
/* Don't break until after the comment leader */
if (do_comments)
- leader_len = get_leader_len(ml_get_curline(), NULL, FALSE, TRUE);
+ leader_len = get_leader_len(get_cursor_line_ptr(), NULL, FALSE, TRUE);
else
leader_len = 0;
@@ -5350,7 +5352,7 @@ internal_format (
* In VREPLACE mode, we will backspace over the text to be
* wrapped, so save a copy now to put on the next line.
*/
- saved_text = vim_strsave(ml_get_cursor());
+ saved_text = vim_strsave(get_cursor_pos_ptr());
curwin->w_cursor.col = orig_col;
if (saved_text == NULL)
break; /* Can't do it, out of memory */
@@ -5428,7 +5430,7 @@ internal_format (
* may have added or removed indent.
*/
curwin->w_cursor.col += startcol;
- len = (colnr_T)STRLEN(ml_get_curline());
+ len = (colnr_T)STRLEN(get_cursor_line_ptr());
if (curwin->w_cursor.col > len)
curwin->w_cursor.col = len;
}
@@ -5476,7 +5478,7 @@ auto_format (
return;
pos = curwin->w_cursor;
- old = ml_get_curline();
+ old = get_cursor_line_ptr();
/* may remove added space */
check_auto_format(FALSE);
@@ -5539,7 +5541,7 @@ auto_format (
* need to add a space when 'w' is in 'formatoptions' to keep a paragraph
* formatted. */
if (!wasatend && has_format_option(FO_WHITE_PAR)) {
- new = ml_get_curline();
+ new = get_cursor_line_ptr();
len = (colnr_T)STRLEN(new);
if (curwin->w_cursor.col == len) {
pnew = vim_strnsave(new, len + 2);
@@ -5702,7 +5704,7 @@ int stop_arrow(void)
ins_need_undo = FALSE;
}
Insstart = curwin->w_cursor; /* new insertion starts here */
- Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
+ Insstart_textlen = (colnr_T)linetabsize(get_cursor_line_ptr());
ai_col = 0;
if (State & VREPLACE_FLAG) {
orig_line_count = curbuf->b_ml.ml_line_count;
@@ -5820,7 +5822,7 @@ stop_insert (
/* <C-S-Right> may have started Visual mode, adjust the position for
* deleted characters. */
if (VIsual_active && VIsual.lnum == curwin->w_cursor.lnum) {
- int len = (int)STRLEN(ml_get_curline());
+ int len = (int)STRLEN(get_cursor_line_ptr());
if (VIsual.col > len) {
VIsual.col = len;
@@ -5917,7 +5919,7 @@ void beginline(int flags)
if (flags & (BL_WHITE | BL_SOL)) {
char_u *ptr;
- for (ptr = ml_get_curline(); vim_iswhite(*ptr)
+ for (ptr = get_cursor_line_ptr(); vim_iswhite(*ptr)
&& !((flags & BL_FIX) && ptr[1] == NUL); ++ptr)
++curwin->w_cursor.col;
}
@@ -5942,7 +5944,7 @@ int oneright(void)
pos_T prevpos = curwin->w_cursor;
/* Adjust for multi-wide char (excluding TAB) */
- ptr = ml_get_cursor();
+ ptr = get_cursor_pos_ptr();
coladvance(getviscol() + ((*ptr != TAB && vim_isprintc(
(*mb_ptr2char)(ptr)
))
@@ -5953,7 +5955,7 @@ int oneright(void)
|| prevpos.coladd != curwin->w_cursor.coladd) ? OK : FAIL;
}
- ptr = ml_get_cursor();
+ ptr = get_cursor_pos_ptr();
if (*ptr == NUL)
return FAIL; /* already at the very end */
@@ -6000,7 +6002,7 @@ int oneleft(void)
char_u *ptr;
/* Adjust for multi-wide char (not a TAB) */
- ptr = ml_get_cursor();
+ ptr = get_cursor_pos_ptr();
if (*ptr != TAB && vim_isprintc(
(*mb_ptr2char)(ptr)
) && ptr2cells(ptr) > 1)
@@ -6226,7 +6228,7 @@ static int echeck_abbr(int c)
if (p_paste || no_abbr || arrow_used)
return FALSE;
- return check_abbr(c, ml_get_curline(), curwin->w_cursor.col,
+ return check_abbr(c, get_cursor_line_ptr(), curwin->w_cursor.col,
curwin->w_cursor.lnum == Insstart.lnum ? Insstart.col : 0);
}
@@ -6417,23 +6419,23 @@ static void replace_do_bs(int limit_col)
/* Get the number of screen cells used by the character we are
* going to delete. */
getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL);
- orig_vcols = chartabsize(ml_get_cursor(), start_vcol);
+ orig_vcols = chartabsize(get_cursor_pos_ptr(), start_vcol);
}
if (has_mbyte) {
(void)del_char_after_col(limit_col);
if (State & VREPLACE_FLAG)
- orig_len = (int)STRLEN(ml_get_cursor());
+ orig_len = (int)STRLEN(get_cursor_pos_ptr());
replace_push(cc);
} else {
pchar_cursor(cc);
if (State & VREPLACE_FLAG)
- orig_len = (int)STRLEN(ml_get_cursor()) - 1;
+ orig_len = (int)STRLEN(get_cursor_pos_ptr()) - 1;
}
replace_pop_ins();
if (State & VREPLACE_FLAG) {
/* Get the number of screen cells used by the inserted characters */
- p = ml_get_cursor();
+ p = get_cursor_pos_ptr();
ins_len = (int)STRLEN(p) - orig_len;
vcol = start_vcol;
for (i = 0; i < ins_len; ++i) {
@@ -6576,7 +6578,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
*/
else if (*look == 'e') {
if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) {
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
if (skipwhite(p) == p + curwin->w_cursor.col - 4 &&
STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0)
return TRUE;
@@ -6590,18 +6592,18 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
*/
else if (*look == ':') {
if (try_match && keytyped == ':') {
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
if (cin_iscase(p, FALSE) || cin_isscopedecl(p) || cin_islabel())
return TRUE;
/* Need to get the line again after cin_islabel(). */
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
if (curwin->w_cursor.col > 2
&& p[curwin->w_cursor.col - 1] == ':'
&& p[curwin->w_cursor.col - 2] == ':') {
p[curwin->w_cursor.col - 1] = ' ';
i = (cin_iscase(p, FALSE) || cin_isscopedecl(p)
|| cin_islabel());
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
p[curwin->w_cursor.col - 1] = ':';
if (i)
return TRUE;
@@ -6653,7 +6655,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
/* Just completed a word, check if it starts with "look".
* search back for the start of a word. */
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
if (has_mbyte) {
char_u *n;
@@ -6676,7 +6678,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
if (keytyped == (int)p[-1] || (icase && keytyped < 256
&& TOLOWER_LOC(keytyped) ==
TOLOWER_LOC((int)p[-1]))) {
- line = ml_get_cursor();
+ line = get_cursor_pos_ptr();
if ((curwin->w_cursor.col == (colnr_T)(p - look)
|| !vim_iswordc(line[-(p - look) - 1]))
&& (icase
@@ -6688,7 +6690,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty)
if (match && try_match_word && !try_match) {
/* "0=word": Check if there are only blanks before the
* word. */
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
if ((int)(skipwhite(line) - line) !=
(int)(curwin->w_cursor.col - (p - look)))
match = FALSE;
@@ -7229,7 +7231,7 @@ static void ins_shift(int c, int lastc)
} else
change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE);
- if (did_ai && *skipwhite(ml_get_curline()) != NUL)
+ if (did_ai && *skipwhite(get_cursor_line_ptr()) != NUL)
did_ai = FALSE;
did_si = FALSE;
can_si = FALSE;
@@ -7452,8 +7454,8 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
&& ((p_sta && in_indent)
|| (get_sts_value() != 0
&& curwin->w_cursor.col > 0
- && (*(ml_get_cursor() - 1) == TAB
- || (*(ml_get_cursor() - 1) == ' '
+ && (*(get_cursor_pos_ptr() - 1) == TAB
+ || (*(get_cursor_pos_ptr() - 1) == ' '
&& (!*inserted_space_p
|| arrow_used)))))) {
int ts;
@@ -7478,7 +7480,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
/* delete characters until we are at or before want_vcol */
while (vcol > want_vcol
- && (cc = *(ml_get_cursor() - 1), vim_iswhite(cc)))
+ && (cc = *(get_cursor_pos_ptr() - 1), vim_iswhite(cc)))
ins_bs_one(&vcol);
/* insert extra spaces until we are at want_vcol */
@@ -7530,7 +7532,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
replace_do_bs(-1);
else {
if (enc_utf8 && p_deco)
- (void)utfc_ptr2char(ml_get_cursor(), cpc);
+ (void)utfc_ptr2char(get_cursor_pos_ptr(), cpc);
(void)del_char(FALSE);
/*
* If there are combining characters and 'delcombine' is set
@@ -7767,7 +7769,7 @@ static void ins_right(void)
oneright();
else {
if (has_mbyte)
- curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
+ curwin->w_cursor.col += (*mb_ptr2len)(get_cursor_pos_ptr());
else
++curwin->w_cursor.col;
}
@@ -7976,10 +7978,10 @@ static int ins_tab(void)
if (State & VREPLACE_FLAG) {
pos = curwin->w_cursor;
cursor = &pos;
- saved_line = vim_strsave(ml_get_curline());
+ saved_line = vim_strsave(get_cursor_line_ptr());
ptr = saved_line + pos.col;
} else {
- ptr = ml_get_cursor();
+ ptr = get_cursor_pos_ptr();
cursor = &curwin->w_cursor;
}
@@ -8120,7 +8122,7 @@ static int ins_eol(int c)
/* NL in reverse insert will always start in the end of
* current line. */
if (revins_on)
- curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor());
+ curwin->w_cursor.col += (colnr_T)STRLEN(get_cursor_pos_ptr());
AppendToRedobuff(NL_STR);
i = open_line(FORWARD,
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index bf82e9373e..95fb6ed732 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -8036,7 +8036,7 @@ static void f_col(typval_T *argvars, typval_T *rettv)
/* col(".") when the cursor is on the NUL at the end of the line
* because of "coladd" can be seen as an extra column. */
if (virtual_active() && fp == &curwin->w_cursor) {
- char_u *p = ml_get_cursor();
+ char_u *p = get_cursor_pos_ptr();
if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p,
curwin->w_virtcol - curwin->w_cursor.coladd)) {
@@ -13832,7 +13832,7 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv)
/* Find the start and length of the badly spelled word. */
len = spell_move_to(curwin, FORWARD, TRUE, TRUE, &attr);
if (len != 0)
- word = ml_get_cursor();
+ word = get_cursor_pos_ptr();
} else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != NUL) {
char_u *str = get_tv_string_chk(&argvars[0]);
int capcol = -1;
@@ -15393,7 +15393,7 @@ var2fpos (
pos.col = 0;
} else {
pos.lnum = curwin->w_cursor.lnum;
- pos.col = (colnr_T)STRLEN(ml_get_curline());
+ pos.col = (colnr_T)STRLEN(get_cursor_line_ptr());
}
return &pos;
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 2fc882113a..de01665286 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -91,7 +91,7 @@ void do_ascii(exarg_T *eap)
int len;
if (enc_utf8)
- c = utfc_ptr2char(ml_get_cursor(), cc);
+ c = utfc_ptr2char(get_cursor_pos_ptr(), cc);
else
c = gchar_cursor();
if (c == NUL) {
@@ -258,7 +258,7 @@ static int linelen(int *has_tab)
int len;
/* find the first non-blank character */
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
first = skipwhite(line);
/* find the character after the last non-blank character */
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index a76f09f3bb..832870cf2d 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -6120,7 +6120,7 @@ static void ex_open(exarg_T *eap)
regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0);
if (regmatch.regprog != NULL) {
regmatch.rm_ic = p_ic;
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
if (vim_regexec(&regmatch, p, (colnr_T)0))
curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p);
else
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 14687be426..57af0c20e4 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -5306,7 +5306,7 @@ static int ex_window(void)
* and don't modify the cmd window. */
ccline.cmdbuff = NULL;
} else
- ccline.cmdbuff = vim_strsave(ml_get_curline());
+ ccline.cmdbuff = vim_strsave(get_cursor_line_ptr());
if (ccline.cmdbuff == NULL)
cmdwin_result = Ctrl_C;
else {
diff --git a/src/nvim/farsi.c b/src/nvim/farsi.c
index edda8f3f23..6e532bbe0a 100644
--- a/src/nvim/farsi.c
+++ b/src/nvim/farsi.c
@@ -170,7 +170,7 @@ static int toF_Xor_X_(int c)
tempc = _HE;
if (p_ri &&
- (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(ml_get_curline()))) {
+ (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(get_cursor_line_ptr()))) {
inc_cursor();
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
tempc = _HE_;
@@ -178,7 +178,7 @@ static int toF_Xor_X_(int c)
dec_cursor();
}
- if (!p_ri && STRLEN(ml_get_curline())) {
+ if (!p_ri && STRLEN(get_cursor_line_ptr())) {
dec_cursor();
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
tempc = _HE_;
@@ -455,7 +455,7 @@ static void put_curr_and_l_to_X(int c)
return;
}
- if ((curwin->w_cursor.col < (colnr_T)STRLEN(ml_get_curline()))) {
+ if ((curwin->w_cursor.col < (colnr_T)STRLEN(get_cursor_line_ptr()))) {
if ((p_ri && curwin->w_cursor.col) || !p_ri) {
if (p_ri) {
dec_cursor();
@@ -699,7 +699,7 @@ static void chg_c_to_X_or_X(void)
tempc = gchar_cursor();
- if (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(ml_get_curline())) {
+ if (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(get_cursor_line_ptr())) {
inc_cursor();
if ((tempc == F_HE) && (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))) {
tempc = _HE_;
@@ -722,7 +722,7 @@ static void chg_l_to_X_orX_(void)
int tempc;
if ((curwin->w_cursor.col != 0)
- && (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) {
+ && (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(get_cursor_line_ptr()))) {
return;
}
@@ -802,7 +802,7 @@ static void chg_l_toXor_X(void)
int tempc;
if ((curwin->w_cursor.col != 0) &&
- (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) {
+ (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(get_cursor_line_ptr()))) {
return;
}
@@ -1564,7 +1564,7 @@ int fkmap(int c)
break;
case 'G':
- if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
+ if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (gchar_cursor() == _LAM) {
chg_c_toX_orX();
} else if (p_ri) {
@@ -1600,7 +1600,7 @@ int fkmap(int c)
return tempc;
case 'h':
- if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
+ if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (p_ri) {
chg_c_to_X_or_X();
}
@@ -1643,7 +1643,7 @@ int fkmap(int c)
case 'i':
- if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
+ if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (!p_ri && !F_is_TyE(tempc)) {
chg_c_to_X_orX_();
}
@@ -1678,7 +1678,7 @@ int fkmap(int c)
case 'J':
- if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
+ if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (p_ri) {
chg_c_to_X_or_X();
}
@@ -1753,7 +1753,7 @@ int fkmap(int c)
break;
case 'u':
- if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
+ if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (!p_ri && !F_is_TyE(tempc)) {
chg_c_to_X_orX_();
}
@@ -1797,7 +1797,7 @@ int fkmap(int c)
break;
case 'y':
- if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
+ if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (!p_ri && !F_is_TyE(tempc)) {
chg_c_to_X_orX_();
}
@@ -1857,7 +1857,7 @@ int fkmap(int c)
}
if ((F_isalpha(tempc) || F_isdigit(tempc))) {
- if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
+ if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) {
if (!p_ri && !F_is_TyE(tempc)) {
chg_c_to_X_orX_();
}
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 9cd12a1d52..d215bb06e7 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -2172,7 +2172,7 @@ static int vgetorpeek(int advance)
* character -- webb
*/
col = vcol = curwin->w_wcol = 0;
- ptr = ml_get_curline();
+ ptr = get_cursor_line_ptr();
while (col < curwin->w_cursor.col) {
if (!vim_iswhite(ptr[col]))
curwin->w_wcol = vcol;
@@ -2200,7 +2200,7 @@ static int vgetorpeek(int advance)
if (has_mbyte && col > 0 && curwin->w_wcol > 0) {
/* Correct when the cursor is on the right halve
* of a double-wide character. */
- ptr = ml_get_curline();
+ ptr = get_cursor_line_ptr();
col -= (*mb_head_off)(ptr, ptr + col);
if ((*mb_ptr2cells)(ptr + col) > 1)
--curwin->w_wcol;
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index fc59bdb50b..fcdc71e636 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -18,7 +18,7 @@ static int lisp_match(char_u *p);
// Count the size (in window cells) of the indent in the current line.
int get_indent(void)
{
- return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts);
+ return get_indent_str(get_cursor_line_ptr(), (int)curbuf->b_p_ts);
}
@@ -88,7 +88,7 @@ int set_indent(int size, int flags)
// characters needed for the indent.
todo = size;
ind_len = 0;
- p = oldline = ml_get_curline();
+ p = oldline = get_cursor_line_ptr();
// Calculate the buffer size for the new indent, and check to see if it
// isn't already set.
@@ -368,14 +368,14 @@ int copy_indent(int size, char_u *src)
if (p == NULL) {
// Allocate memory for the result: the copied indent, new indent
// and the rest of the line.
- line_len = (int)STRLEN(ml_get_curline()) + 1;
+ line_len = (int)STRLEN(get_cursor_line_ptr()) + 1;
line = xmalloc(ind_len + line_len);
p = line;
}
}
// Append the original line
- memmove(p, ml_get_curline(), (size_t)line_len);
+ memmove(p, get_cursor_line_ptr(), (size_t)line_len);
// Replace the line
ml_replace(curwin->w_cursor.lnum, line, false);
@@ -437,7 +437,7 @@ int inindent(int extra)
char_u *ptr;
colnr_T col;
- for (col = 0, ptr = ml_get_curline(); vim_iswhite(*ptr); ++col) {
+ for (col = 0, ptr = get_cursor_line_ptr(); vim_iswhite(*ptr); ++col) {
ptr++;
}
@@ -550,7 +550,7 @@ int get_lisp_indent(void)
continue;
}
- for (that = ml_get_curline(); *that != NUL; ++that) {
+ for (that = get_cursor_line_ptr(); *that != NUL; ++that) {
if (*that == ';') {
while (*(that + 1) != NUL) {
that++;
@@ -597,7 +597,7 @@ int get_lisp_indent(void)
curwin->w_cursor.col = pos->col;
col = pos->col;
- that = ml_get_curline();
+ that = get_cursor_line_ptr();
if (vi_lisp && (get_indent() == 0)) {
amount = 2;
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 8db16efb80..631ef06d01 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -267,7 +267,7 @@ int cin_islabel(void)
{ /* XXX */
char_u *s;
- s = cin_skipcomment(ml_get_curline());
+ s = cin_skipcomment(get_cursor_line_ptr());
/*
* Exclude "default" from labels, since it should be indented
@@ -298,7 +298,7 @@ int cin_islabel(void)
if ((trypos = ind_find_start_comment()) != NULL) /* XXX */
curwin->w_cursor = *trypos;
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
if (cin_ispreproc(line)) /* ignore #defines, #if, etc. */
continue;
if (*(line = cin_skipcomment(line)) == NUL)
@@ -328,7 +328,7 @@ static int cin_isinit(void)
char_u *s;
static char *skip[] = {"static", "public", "protected", "private"};
- s = cin_skipcomment(ml_get_curline());
+ s = cin_skipcomment(get_cursor_line_ptr());
if (cin_starts_with(s, "typedef"))
s = cin_skipcomment(s + 7);
@@ -522,16 +522,16 @@ static int skip_label(linenr_T lnum, char_u **pp)
cursor_save = curwin->w_cursor;
curwin->w_cursor.lnum = lnum;
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
/* XXX */
if (cin_iscase(l, FALSE) || cin_isscopedecl(l) || cin_islabel()) {
amount = get_indent_nolabel(lnum);
- l = after_label(ml_get_curline());
+ l = after_label(get_cursor_line_ptr());
if (l == NULL) /* just in case */
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
} else {
amount = get_indent();
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
}
*pp = l;
@@ -553,7 +553,7 @@ static int cin_first_id_amount(void)
pos_T fp;
colnr_T col;
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
p = skipwhite(line);
len = (int)(skiptowhite(p) - p);
if (len == 6 && STRNCMP(p, "static", 6) == 0) {
@@ -869,7 +869,7 @@ cin_iswhileofdo ( /* XXX */
cursor_save = curwin->w_cursor;
curwin->w_cursor.lnum = lnum;
curwin->w_cursor.col = 0;
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
while (*p && *p != 'w') { /* skip any '}', until the 'w' of the "while" */
++p;
++curwin->w_cursor.col;
@@ -942,7 +942,7 @@ static int cin_iswhileofdo_end(int terminated)
if (terminated != ';') /* there must be a ';' at the end */
return FALSE;
- p = line = ml_get_curline();
+ p = line = get_cursor_line_ptr();
while (*p != NUL) {
p = cin_skipcomment(p);
if (*p == ')') {
@@ -964,7 +964,7 @@ static int cin_iswhileofdo_end(int terminated)
}
/* Searching may have made "line" invalid, get it again. */
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
p = line + i;
}
}
@@ -1000,7 +1000,7 @@ cin_is_cpp_baseclass (
char_u *s;
int class_or_struct, lookfor_ctor_init, cpp_base_class;
linenr_T lnum = curwin->w_cursor.lnum;
- char_u *line = ml_get_curline();
+ char_u *line = get_cursor_line_ptr();
*col = 0;
@@ -1126,10 +1126,10 @@ static int get_baseclass_amount(int col)
if (col == 0) {
amount = get_indent();
- if (find_last_paren(ml_get_curline(), '(', ')')
+ if (find_last_paren(get_cursor_line_ptr(), '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)
amount = get_indent_lnum(trypos->lnum); /* XXX */
- if (!cin_ends_in(ml_get_curline(), (char_u *)",", NULL))
+ if (!cin_ends_in(get_cursor_line_ptr(), (char_u *)",", NULL))
amount += curbuf->b_ind_cpp_baseclass;
} else {
curwin->w_cursor.col = col;
@@ -1866,7 +1866,7 @@ int get_c_indent(void)
/* Ignore a '(' in front of the line that has a match before
* our matching '('. */
curwin->w_cursor.lnum = our_paren_pos.lnum;
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
look_col = (int)(look - line);
curwin->w_cursor.col = look_col + 1;
if ((trypos = findmatchlimit(NULL, ')', 0,
@@ -2042,7 +2042,7 @@ int get_c_indent(void)
* }
*/
if (curbuf->b_ind_js || (curbuf->b_ind_keep_case_label
- && cin_iscase(skipwhite(ml_get_curline()),
+ && cin_iscase(skipwhite(get_cursor_line_ptr()),
FALSE)))
amount = get_indent();
else
@@ -2106,7 +2106,7 @@ int get_c_indent(void)
if (start_brace == BRACE_AT_END) { /* '{' is at end of line */
amount += curbuf->b_ind_open_imag;
- l = skipwhite(ml_get_curline());
+ l = skipwhite(get_cursor_line_ptr());
if (cin_is_cpp_namespace(l))
amount += curbuf->b_ind_cpp_namespace;
} else {
@@ -2178,7 +2178,7 @@ int get_c_indent(void)
break;
}
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
/*
* If we're in a comment now, skip to the start of the
@@ -2287,7 +2287,7 @@ int get_c_indent(void)
< ourscope - FIND_NAMESPACE_LIM)
break;
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
/* If we're in a comment now, skip to the start of
* the comment. */
@@ -2325,7 +2325,7 @@ int get_c_indent(void)
continue;
}
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
/*
* If this is a switch() label, may line up relative to that.
@@ -2406,7 +2406,7 @@ int get_c_indent(void)
*/
if (n) {
amount = n;
- l = after_label(ml_get_curline());
+ l = after_label(get_cursor_line_ptr());
if (l != NULL && cin_is_cinword(l)) {
if (theline[0] == '{')
amount += curbuf->b_ind_open_extra;
@@ -2450,7 +2450,7 @@ int get_c_indent(void)
* Ignore jump labels with nothing after them.
*/
if (!curbuf->b_ind_js && cin_islabel()) {
- l = after_label(ml_get_curline());
+ l = after_label(get_cursor_line_ptr());
if (l == NULL || cin_nocode(l))
continue;
}
@@ -2461,7 +2461,7 @@ int get_c_indent(void)
* (need to get the line again, cin_islabel() may have
* unlocked it)
*/
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)
|| cin_nocode(l))
continue;
@@ -2473,7 +2473,7 @@ int get_c_indent(void)
n = FALSE;
if (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0) {
n = cin_is_cpp_baseclass(&col);
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
}
if (n) {
if (lookfor == LOOKFOR_UNTERM) {
@@ -2545,7 +2545,7 @@ int get_c_indent(void)
* asdf)
*/
curwin->w_cursor = *trypos;
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) {
++curwin->w_cursor.lnum;
curwin->w_cursor.col = 0;
@@ -2657,7 +2657,7 @@ int get_c_indent(void)
* x = 1;
* -> here
*/
- l = skipwhite(ml_get_curline());
+ l = skipwhite(get_cursor_line_ptr());
if (cin_isdo(l)) {
if (whilelevel == 0)
break;
@@ -2676,7 +2676,7 @@ int get_c_indent(void)
* not the one from "if () {". */
if (*l == '}')
curwin->w_cursor.col =
- (colnr_T)(l - ml_get_curline()) + 1;
+ (colnr_T)(l - get_cursor_line_ptr()) + 1;
if ((trypos = find_start_brace()) == NULL
|| find_match(LOOKFOR_IF, trypos->lnum)
@@ -2802,7 +2802,7 @@ int get_c_indent(void)
* may be lined up with the case label.
*/
if (lookfor == LOOKFOR_NOBREAK
- && cin_isbreak(skipwhite(ml_get_curline()))) {
+ && cin_isbreak(skipwhite(get_cursor_line_ptr()))) {
lookfor = LOOKFOR_ANY;
continue;
}
@@ -2811,7 +2811,7 @@ int get_c_indent(void)
* Handle "do {" line.
*/
if (whilelevel > 0) {
- l = cin_skipcomment(ml_get_curline());
+ l = cin_skipcomment(get_cursor_line_ptr());
if (cin_isdo(l)) {
amount = get_indent(); /* XXX */
--whilelevel;
@@ -2867,7 +2867,7 @@ int get_c_indent(void)
* here;
*/
term_again:
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
if (find_last_paren(l, '(', ')')
&& (trypos = find_match_paren(
curbuf->b_ind_maxparen)) != NULL) {
@@ -2878,7 +2878,7 @@ term_again:
* asdf)
*/
curwin->w_cursor = *trypos;
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) {
++curwin->w_cursor.lnum;
curwin->w_cursor.col = 0;
@@ -2935,13 +2935,13 @@ term_again:
* If we're at the end of a block, skip to the start of
* that block.
*/
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
if (find_last_paren(l, '{', '}') /* XXX */
&& (trypos = find_start_brace()) != NULL) {
curwin->w_cursor = *trypos;
/* if not "else {" check for terminated again */
/* but skip block for "} else {" */
- l = cin_skipcomment(ml_get_curline());
+ l = cin_skipcomment(get_cursor_line_ptr());
if (*l == '}' || !cin_iselse(l))
goto term_again;
++curwin->w_cursor.lnum;
@@ -3006,7 +3006,7 @@ term_again:
curwin->w_cursor.lnum--;
curwin->w_cursor.col = 0;
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
/*
* If we're in a comment now, skip to the start of the comment.
@@ -3024,7 +3024,7 @@ term_again:
n = FALSE;
if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{') {
n = cin_is_cpp_baseclass(&col);
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
}
if (n) {
/* XXX */
@@ -3091,7 +3091,7 @@ term_again:
*/
if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) /* XXX */
break;
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
/*
* Finding the closing '}' of a previous function. Put
@@ -3152,7 +3152,7 @@ term_again:
if (cin_ends_in(l, (char_u *)",", NULL)
|| (*l != NUL && l[STRLEN(l) - 1] == '\\'))
break;
- l = ml_get_curline();
+ l = get_cursor_line_ptr();
}
/*
@@ -3226,7 +3226,7 @@ static int find_match(int lookfor, linenr_T ourscope)
curwin->w_cursor.lnum--;
curwin->w_cursor.col = 0;
- look = cin_skipcomment(ml_get_curline());
+ look = cin_skipcomment(get_cursor_line_ptr());
if (cin_iselse(look)
|| cin_isif(look)
|| cin_isdo(look) /* XXX */
@@ -3260,7 +3260,7 @@ static int find_match(int lookfor, linenr_T ourscope)
* then we need to go back to another if, so
* increment elselevel
*/
- look = cin_skipcomment(ml_get_curline());
+ look = cin_skipcomment(get_cursor_line_ptr());
if (cin_iselse(look)) {
mightbeif = cin_skipcomment(look + 4);
if (!cin_isif(mightbeif))
@@ -3278,7 +3278,7 @@ static int find_match(int lookfor, linenr_T ourscope)
}
/* If it's an "if" decrement elselevel */
- look = cin_skipcomment(ml_get_curline());
+ look = cin_skipcomment(get_cursor_line_ptr());
if (cin_isif(look)) {
elselevel--;
/*
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index ecc272fe00..ec1997657b 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -2860,7 +2860,7 @@ void show_utf8()
/* Get the byte length of the char under the cursor, including composing
* characters. */
- line = ml_get_cursor();
+ line = get_cursor_pos_ptr();
len = utfc_ptr2len(line);
if (len == 0) {
MSG("NUL");
@@ -3097,7 +3097,7 @@ void utf_find_illegal()
curwin->w_cursor.coladd = 0;
for (;; ) {
- p = ml_get_cursor();
+ p = get_cursor_pos_ptr();
if (vimconv.vc_type != CONV_NONE) {
free(tofree);
tofree = string_convert(&vimconv, p, NULL);
@@ -3113,12 +3113,12 @@ void utf_find_illegal()
if (*p >= 0x80 && (len == 1
|| utf_char2len(utf_ptr2char(p)) != len)) {
if (vimconv.vc_type == CONV_NONE)
- curwin->w_cursor.col += (colnr_T)(p - ml_get_cursor());
+ curwin->w_cursor.col += (colnr_T)(p - get_cursor_pos_ptr());
else {
int l;
len = (int)(p - tofree);
- for (p = ml_get_cursor(); *p != NUL && len-- > 0; p += l) {
+ for (p = get_cursor_pos_ptr(); *p != NUL && len-- > 0; p += l) {
l = utf_ptr2len(p);
curwin->w_cursor.col += l;
}
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index efe0ccff6a..e63ca008bc 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -120,7 +120,7 @@ open_line (
/*
* make a copy of the current line so we can mess with it
*/
- saved_line = vim_strsave(ml_get_curline());
+ saved_line = vim_strsave(get_cursor_line_ptr());
if (State & VREPLACE_FLAG) {
/*
@@ -286,7 +286,7 @@ open_line (
if ((pos = findmatch(NULL, '(')) != NULL) {
curwin->w_cursor.lnum = pos->lnum;
newindent = get_indent();
- ptr = ml_get_curline();
+ ptr = get_cursor_line_ptr();
}
}
/*
@@ -887,7 +887,7 @@ open_line (
&& curbuf->b_p_lisp
&& curbuf->b_p_ai) {
fixthisline(get_lisp_indent);
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
ai_col = (colnr_T)(skipwhite(p) - p);
}
/*
@@ -901,7 +901,7 @@ open_line (
? KEY_OPEN_FORW
: KEY_OPEN_BACK, ' ', linewhite(curwin->w_cursor.lnum))) {
do_c_expr_indent();
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
ai_col = (colnr_T)(skipwhite(p) - p);
}
if (vreplace_mode != 0)
@@ -914,7 +914,7 @@ open_line (
*/
if (State & VREPLACE_FLAG) {
/* Put new line in p_extra */
- p_extra = vim_strsave(ml_get_curline());
+ p_extra = vim_strsave(get_cursor_line_ptr());
/* Put back original line */
ml_replace(curwin->w_cursor.lnum, next_line, FALSE);
@@ -1595,7 +1595,7 @@ int del_char(int fixpos)
if (has_mbyte) {
/* Make sure the cursor is at the start of a character. */
mb_adjust_cursor();
- if (*ml_get_cursor() == NUL)
+ if (*get_cursor_pos_ptr() == NUL)
return FAIL;
return del_chars(1L, fixpos);
}
@@ -1612,7 +1612,7 @@ int del_chars(long count, int fixpos)
char_u *p;
int l;
- p = ml_get_cursor();
+ p = get_cursor_pos_ptr();
for (i = 0; i < count && *p != NUL; ++i) {
l = (*mb_ptr2len)(p);
bytes += l;
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 5ecdc93f51..f744e1b812 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -798,7 +798,7 @@ curs_columns (
/* When cursor wraps to first char of next line in Insert
* mode, the 'showbreak' string isn't shown, backup to first
* column */
- if (*p_sbr && *ml_get_cursor() == NUL
+ if (*p_sbr && *get_cursor_pos_ptr() == NUL
&& curwin->w_wcol == (int)vim_strsize(p_sbr))
curwin->w_wcol = 0;
}
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 63156d72fb..210fc1227c 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1349,7 +1349,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
oap->start.col = 0;
if (hasFolding(curwin->w_cursor.lnum, NULL,
&curwin->w_cursor.lnum))
- curwin->w_cursor.col = (colnr_T)STRLEN(ml_get_curline());
+ curwin->w_cursor.col = (colnr_T)STRLEN(get_cursor_line_ptr());
}
oap->end = curwin->w_cursor;
curwin->w_cursor = oap->start;
@@ -2519,9 +2519,9 @@ do_mouse (
find_end_of_word(&VIsual);
} else {
find_start_of_word(&VIsual);
- if (*p_sel == 'e' && *ml_get_cursor() != NUL)
+ if (*p_sel == 'e' && *get_cursor_pos_ptr() != NUL)
curwin->w_cursor.col +=
- (*mb_ptr2len)(ml_get_cursor());
+ (*mb_ptr2len)(get_cursor_pos_ptr());
find_end_of_word(&curwin->w_cursor);
}
}
@@ -2983,9 +2983,9 @@ void clear_showcmd(void)
if (cursor_bot) {
s = ml_get_pos(&VIsual);
- e = ml_get_cursor();
+ e = get_cursor_pos_ptr();
} else {
- s = ml_get_cursor();
+ s = get_cursor_pos_ptr();
e = ml_get_pos(&VIsual);
}
while ((*p_sel != 'e') ? s <= e : s < e) {
@@ -3406,7 +3406,8 @@ find_decl (
par_pos = curwin->w_cursor;
} else {
par_pos = curwin->w_cursor;
- while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != NUL)
+ while (curwin->w_cursor.lnum > 1
+ && *skipwhite(get_cursor_line_ptr()) != NUL)
--curwin->w_cursor.lnum;
}
curwin->w_cursor.col = 0;
@@ -3438,7 +3439,7 @@ find_decl (
}
break;
}
- if (get_leader_len(ml_get_curline(), NULL, FALSE, TRUE) > 0) {
+ if (get_leader_len(get_cursor_line_ptr(), NULL, FALSE, TRUE) > 0) {
/* Ignore this line, continue at start of next line. */
++curwin->w_cursor.lnum;
curwin->w_cursor.col = 0;
@@ -3484,7 +3485,7 @@ find_decl (
*/
static int nv_screengo(oparg_T *oap, int dir, long dist)
{
- int linelen = linetabsize(ml_get_curline());
+ int linelen = linetabsize(get_cursor_line_ptr());
int retval = OK;
int atend = FALSE;
int n;
@@ -3545,7 +3546,7 @@ static int nv_screengo(oparg_T *oap, int dir, long dist)
if (!(fdo_flags & FDO_ALL))
(void)hasFolding(curwin->w_cursor.lnum,
&curwin->w_cursor.lnum, NULL);
- linelen = linetabsize(ml_get_curline());
+ linelen = linetabsize(get_cursor_line_ptr());
if (linelen > width1)
curwin->w_curswant += (((linelen - width1 - 1) / width2)
+ 1) * width2;
@@ -3569,7 +3570,7 @@ static int nv_screengo(oparg_T *oap, int dir, long dist)
}
curwin->w_cursor.lnum++;
curwin->w_curswant %= width2;
- linelen = linetabsize(ml_get_curline());
+ linelen = linetabsize(get_cursor_line_ptr());
}
}
}
@@ -4370,7 +4371,7 @@ static void nv_ident(cmdarg_T *cap)
* it was.
*/
setpcmark();
- curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline());
+ curwin->w_cursor.col = (colnr_T) (ptr - get_cursor_line_ptr());
if (!g_cmd && vim_iswordp(ptr))
STRCPY(buf, "\\<");
@@ -4483,7 +4484,7 @@ static void nv_ident(cmdarg_T *cap)
*/
if (cmdchar == '*' || cmdchar == '#') {
if (!g_cmd && (
- has_mbyte ? vim_iswordp(mb_prevptr(ml_get_curline(), ptr)) :
+ has_mbyte ? vim_iswordp(mb_prevptr(get_cursor_line_ptr(), ptr)) :
vim_iswordc(ptr[-1])))
STRCAT(buf, "\\>");
/* put pattern in search history */
@@ -4515,7 +4516,7 @@ get_visual_text (
return FAIL;
}
if (VIsual_mode == 'V') {
- *pp = ml_get_curline();
+ *pp = get_cursor_line_ptr();
*lenp = (int)STRLEN(*pp);
} else {
if (lt(curwin->w_cursor, VIsual)) {
@@ -4645,7 +4646,7 @@ static void nv_right(cmdarg_T *cap)
for (n = cap->count1; n > 0; --n) {
if ((!PAST_LINE && oneright() == FAIL)
- || (PAST_LINE && *ml_get_cursor() == NUL)
+ || (PAST_LINE && *get_cursor_pos_ptr() == NUL)
) {
/*
* <Space> wraps to next line if 'whichwrap' has 's'.
@@ -4691,7 +4692,7 @@ static void nv_right(cmdarg_T *cap)
else {
if (has_mbyte)
curwin->w_cursor.col +=
- (*mb_ptr2len)(ml_get_cursor());
+ (*mb_ptr2len)(get_cursor_pos_ptr());
else
++curwin->w_cursor.col;
}
@@ -4746,7 +4747,7 @@ static void nv_left(cmdarg_T *cap)
if ( (cap->oap->op_type == OP_DELETE
|| cap->oap->op_type == OP_CHANGE)
&& !lineempty(curwin->w_cursor.lnum)) {
- char_u *cp = ml_get_cursor();
+ char_u *cp = get_cursor_pos_ptr();
if (*cp != NUL) {
if (has_mbyte) {
@@ -5470,7 +5471,7 @@ static void nv_replace(cmdarg_T *cap)
}
/* Abort if not enough characters to replace. */
- ptr = ml_get_cursor();
+ ptr = get_cursor_pos_ptr();
if (STRLEN(ptr) < (unsigned)cap->count1
|| (has_mbyte && mb_charlen(ptr) < cap->count1)
) {
@@ -6309,7 +6310,7 @@ static void nv_g_cmd(cmdarg_T *cap)
cap->oap->op_type == OP_NOP) == FAIL)
clearopbeep(cap->oap);
else {
- char_u *ptr = ml_get_curline();
+ char_u *ptr = get_cursor_line_ptr();
/* In Visual mode we may end up after the line. */
if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL)
@@ -6413,7 +6414,7 @@ static void nv_g_cmd(cmdarg_T *cap)
if (curbuf->b_last_insert.lnum != 0) {
curwin->w_cursor = curbuf->b_last_insert;
check_cursor_lnum();
- i = (int)STRLEN(ml_get_curline());
+ i = (int)STRLEN(get_cursor_line_ptr());
if (curwin->w_cursor.col > (colnr_T)i) {
if (virtual_active())
curwin->w_cursor.coladd += curwin->w_cursor.col - i;
@@ -7117,7 +7118,7 @@ static void nv_edit(cmdarg_T *cap)
coladvance((colnr_T)MAXCOL);
State = save_State;
} else
- curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor());
+ curwin->w_cursor.col += (colnr_T)STRLEN(get_cursor_pos_ptr());
break;
case 'I': /* "I"nsert before the first non-blank */
@@ -7132,10 +7133,10 @@ static void nv_edit(cmdarg_T *cap)
* column otherwise, also to append after an unprintable char */
if (virtual_active()
&& (curwin->w_cursor.coladd > 0
- || *ml_get_cursor() == NUL
- || *ml_get_cursor() == TAB))
+ || *get_cursor_pos_ptr() == NUL
+ || *get_cursor_pos_ptr() == TAB))
curwin->w_cursor.coladd++;
- else if (*ml_get_cursor() != NUL)
+ else if (*get_cursor_pos_ptr() != NUL)
inc_cursor();
break;
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 0483d931b5..4c5a9fdf63 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -212,7 +212,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount)
block_col = curwin->w_cursor.col;
for (i = oap->line_count; --i >= 0; ) {
- first_char = *ml_get_curline();
+ first_char = *get_cursor_line_ptr();
if (first_char == NUL) /* empty line */
curwin->w_cursor.col = 0;
else if (oap->block_mode)
@@ -345,7 +345,7 @@ static void shift_block(oparg_T *oap, int amount)
/* total is number of screen columns to be inserted/removed */
total = amount * p_sw;
- oldp = ml_get_curline();
+ oldp = get_cursor_line_ptr();
if (!left) {
/*
@@ -598,7 +598,7 @@ int (*how)(void);
*/
if (i != oap->line_count - 1 || oap->line_count == 1
|| how != get_lisp_indent) {
- l = skipwhite(ml_get_curline());
+ l = skipwhite(get_cursor_line_ptr());
if (*l == NUL) /* empty or blank line */
count = 0;
else
@@ -1563,7 +1563,7 @@ int op_delete(oparg_T *oap)
/* fix up things for virtualedit-delete:
* break the tabs which are going to get in our way
*/
- char_u *curline = ml_get_curline();
+ char_u *curline = get_cursor_line_ptr();
int len = (int)STRLEN(curline);
if (oap->end.coladd != 0
@@ -1744,7 +1744,7 @@ int op_replace(oparg_T *oap, int c)
/* oldlen includes textlen, so don't double count */
n += numc - bd.textlen;
- oldp = ml_get_curline();
+ oldp = get_cursor_line_ptr();
oldlen = STRLEN(oldp);
newp = (char_u *) xmalloc((size_t)(oldlen + 1 + n));
memset(newp, NUL, (size_t)(oldlen + 1 + n));
@@ -2012,7 +2012,7 @@ int swapchar(int op_type, pos_T *pos)
curwin->w_cursor = *pos;
/* don't use del_char(), it also removes composing chars */
- del_bytes(utf_ptr2len(ml_get_cursor()), FALSE, FALSE);
+ del_bytes(utf_ptr2len(get_cursor_pos_ptr()), FALSE, FALSE);
ins_char(nc);
curwin->w_cursor = sp;
} else
@@ -2070,7 +2070,7 @@ void op_insert(oparg_T *oap, long count1)
) {
/* Move the cursor to the character right of the block. */
curwin->w_set_curswant = TRUE;
- while (*ml_get_cursor() != NUL
+ while (*get_cursor_pos_ptr() != NUL
&& (curwin->w_cursor.col < bd.textcol + bd.textlen))
++curwin->w_cursor.col;
if (bd.is_short && !bd.is_MAX) {
@@ -2687,11 +2687,11 @@ do_put (
* between. */
if (u_save_cursor() == FAIL)
goto end;
- ptr = vim_strsave(ml_get_cursor());
+ ptr = vim_strsave(get_cursor_pos_ptr());
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);
free(ptr);
- ptr = vim_strnsave(ml_get_curline(), curwin->w_cursor.col);
+ ptr = vim_strnsave(get_cursor_line_ptr(), curwin->w_cursor.col);
ml_replace(curwin->w_cursor.lnum, ptr, FALSE);
++nr_lines;
dir = FORWARD;
@@ -2776,7 +2776,7 @@ do_put (
if (has_mbyte)
/* move to start of next multi-byte character */
- curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
+ curwin->w_cursor.col += (*mb_ptr2len)(get_cursor_pos_ptr());
else if (c != TAB || ve_flags != VE_ALL)
++curwin->w_cursor.col;
++col;
@@ -2817,7 +2817,7 @@ do_put (
++nr_lines;
}
/* get the old line and advance to the position to insert at */
- oldp = ml_get_curline();
+ oldp = get_cursor_line_ptr();
oldlen = (int)STRLEN(oldp);
for (ptr = oldp; vcol < col && *ptr; ) {
/* Count a tab for what it's worth (if list mode not on) */
@@ -2906,7 +2906,7 @@ do_put (
curwin->w_cursor.col++;
/* in Insert mode we might be after the NUL, correct for that */
- len = (colnr_T)STRLEN(ml_get_curline());
+ len = (colnr_T)STRLEN(get_cursor_line_ptr());
if (curwin->w_cursor.col > len)
curwin->w_cursor.col = len;
} else
@@ -2920,7 +2920,7 @@ do_put (
* char */
if (dir == FORWARD && gchar_cursor() != NUL) {
if (has_mbyte) {
- int bytelen = (*mb_ptr2len)(ml_get_cursor());
+ int bytelen = (*mb_ptr2len)(get_cursor_pos_ptr());
/* put it on the next of the multi-byte character. */
col += bytelen;
@@ -3951,7 +3951,7 @@ format_lines (
mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
(long)-next_leader_len);
} else if (second_indent > 0) { /* the "leader" for FO_Q_SECOND */
- char_u *p = ml_get_curline();
+ char_u *p = get_cursor_line_ptr();
int indent = (int)(skipwhite(p) - p);
if (indent > 0) {
@@ -3967,7 +3967,7 @@ format_lines (
}
first_par_line = FALSE;
/* If the line is getting long, format it next time */
- if (STRLEN(ml_get_curline()) > (size_t)max_len)
+ if (STRLEN(get_cursor_line_ptr()) > (size_t)max_len)
force_format = TRUE;
else
force_format = FALSE;
@@ -4241,7 +4241,7 @@ int do_addsub(int command, linenr_T Prenum1)
dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); /* "Octal" */
doalp = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); /* "alPha" */
- ptr = ml_get_curline();
+ ptr = get_cursor_line_ptr();
RLADDSUBFIX(ptr);
/*
@@ -4290,7 +4290,7 @@ int do_addsub(int command, linenr_T Prenum1)
}
/* get ptr again, because u_save() may have changed it */
- ptr = ml_get_curline();
+ ptr = get_cursor_line_ptr();
RLADDSUBFIX(ptr);
if (doalp && ASCII_ISALPHA(firstdigit)) {
@@ -5119,7 +5119,7 @@ void cursor_pos_info(void)
(int64_t)char_count_cursor, (int64_t)char_count,
(int64_t)byte_count_cursor, (int64_t)byte_count);
} else {
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
validate_virtcol();
col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
(int)curwin->w_virtcol + 1);
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 219a20d8b5..cba6b5f94d 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1639,7 +1639,7 @@ win_found:
* found, reduce the error column value by the length of
* a tab character.
*/
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
screen_col = 0;
for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col) {
if (*line == NUL)
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 02b77ab1d9..e14f7d20d3 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -6780,7 +6780,7 @@ void setcursor(void)
* character, position it on the leftmost column. */
curwin->w_p_rl ? ((int)W_WIDTH(curwin) - curwin->w_wcol - (
(has_mbyte
- && (*mb_ptr2cells)(ml_get_cursor()) == 2
+ && (*mb_ptr2cells)(get_cursor_pos_ptr()) == 2
&& vim_isprintc(gchar_cursor())) ? 2 :
1)) :
curwin->w_wcol));
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 750c789461..fc741955da 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -1339,7 +1339,7 @@ int searchc(cmdarg_T *cap, int t_cmd)
else
cap->oap->inclusive = TRUE;
- p = ml_get_curline();
+ p = get_cursor_line_ptr();
col = curwin->w_cursor.col;
len = (int)STRLEN(p);
@@ -2416,7 +2416,7 @@ fwd_word (
/*
* We'll stop if we land on a blank line
*/
- if (curwin->w_cursor.col == 0 && *ml_get_curline() == NUL)
+ if (curwin->w_cursor.col == 0 && *get_cursor_line_ptr() == NUL)
break;
i = inc_cursor();
@@ -3099,7 +3099,7 @@ static int in_html_tag(int);
*/
static int in_html_tag(int end_tag)
{
- char_u *line = ml_get_curline();
+ char_u *line = get_cursor_line_ptr();
char_u *p;
int c;
int lc = NUL;
@@ -3202,12 +3202,12 @@ current_tagblock (
if (in_html_tag(FALSE)) {
/* cursor on start tag, move to its '>' */
- while (*ml_get_cursor() != '>')
+ while (*get_cursor_pos_ptr() != '>')
if (inc_cursor() < 0)
break;
} else if (in_html_tag(TRUE)) {
/* cursor on end tag, move to just before it */
- while (*ml_get_cursor() != '<')
+ while (*get_cursor_pos_ptr() != '<')
if (dec_cursor() < 0)
break;
dec_cursor();
@@ -3240,7 +3240,7 @@ again:
* Search for matching "</aaa>". First isolate the "aaa".
*/
inc_cursor();
- p = ml_get_cursor();
+ p = get_cursor_pos_ptr();
for (cp = p; *cp != NUL && *cp != '>' && !vim_iswhite(*cp); mb_ptr_adv(cp))
;
len = (int)(cp - p);
@@ -3270,12 +3270,12 @@ again:
if (do_include || r < 1) {
/* Include up to the '>'. */
- while (*ml_get_cursor() != '>')
+ while (*get_cursor_pos_ptr() != '>')
if (inc_cursor() < 0)
break;
} else {
/* Exclude the '<' of the end tag. */
- if (*ml_get_cursor() == '<')
+ if (*get_cursor_pos_ptr() == '<')
dec_cursor();
}
end_pos = curwin->w_cursor;
@@ -3284,7 +3284,7 @@ again:
/* Exclude the start tag. */
curwin->w_cursor = start_pos;
while (inc_cursor() >= 0)
- if (*ml_get_cursor() == '>') {
+ if (*get_cursor_pos_ptr() == '>') {
inc_cursor();
start_pos = curwin->w_cursor;
break;
@@ -3567,7 +3567,7 @@ current_quote (
int quotechar /* Quote character */
)
{
- char_u *line = ml_get_curline();
+ char_u *line = get_cursor_line_ptr();
int col_end;
int col_start = curwin->w_cursor.col;
int inclusive = FALSE;
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 44a42f0aaf..901115e55f 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -8648,7 +8648,7 @@ void spell_suggest(int count)
// No bad word or it starts after the cursor: use the word under the
// cursor.
curwin->w_cursor = prev_cursor;
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
p = line + curwin->w_cursor.col;
// Backup to before start of word.
while (p > line && spell_iswordp_nmw(p, curwin))
@@ -8670,7 +8670,7 @@ void spell_suggest(int count)
need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col);
// Make a copy of current line since autocommands may free the line.
- line = vim_strsave(ml_get_curline());
+ line = vim_strsave(get_cursor_line_ptr());
// Get the list of suggestions. Limit to 'lines' - 2 or the number in
// 'spellsuggest', whatever is smaller.
@@ -8824,7 +8824,7 @@ static int check_need_cap(linenr_T lnum, colnr_T col)
if (curwin->w_s->b_cap_prog == NULL)
return FALSE;
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
endcol = 0;
if ((int)(skipwhite(line) - line) >= (int)col) {
// At start of line, check if previous line is empty or sentence
@@ -8899,7 +8899,7 @@ void ex_spellrepall(exarg_T *eap)
// Only replace when the right word isn't there yet. This happens
// when changing "etc" to "etc.".
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col,
repl_to, STRLEN(repl_to)) != 0) {
p = xmalloc(STRLEN(line) + addlen + 1);
@@ -13548,7 +13548,7 @@ int spell_word_start(int startcol)
return startcol;
// Find a word character before "startcol".
- line = ml_get_curline();
+ line = get_cursor_line_ptr();
for (p = line + startcol; p > line; ) {
mb_ptr_back(line, p);
if (spell_iswordp_nmw(p, curwin))
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 12840e502e..6f97401a80 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -4773,7 +4773,7 @@ char_u *grab_file_name(long count, linenr_T *file_lnum)
*/
char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum)
{
- return file_name_in_line(ml_get_curline(),
+ return file_name_in_line(get_cursor_line_ptr(),
curwin->w_cursor.col, options, count, curbuf->b_ffname,
file_lnum);
}