Neovim Home
src
nvim
mark.h
Go to the documentation of this file.
1
#ifndef NVIM_MARK_H
2
#define NVIM_MARK_H
3
4
#include "
nvim/ascii.h
"
5
#include "
nvim/buffer_defs.h
"
6
#include "
nvim/ex_cmds_defs.h
"
// for exarg_T
7
#include "
nvim/extmark_defs.h
"
8
#include "
nvim/func_attr.h
"
9
#include "
nvim/macros.h
"
10
#include "
nvim/mark_defs.h
"
11
#include "
nvim/memory.h
"
12
#include "
nvim/os/time.h
"
13
#include "
nvim/pos.h
"
14
16
#define SET_FMARK(fmarkp_, mark_, fnum_) \
17
do { \
18
fmark_T *const fmarkp__ = fmarkp_; \
19
fmarkp__->mark = mark_; \
20
fmarkp__->fnum = fnum_; \
21
fmarkp__->timestamp = os_time(); \
22
fmarkp__->additional_data = NULL; \
23
} while (0)
24
26
#define RESET_FMARK(fmarkp_, mark_, fnum_) \
27
do { \
28
fmark_T *const fmarkp___ = fmarkp_; \
29
free_fmark(*fmarkp___); \
30
SET_FMARK(fmarkp___, mark_, fnum_); \
31
} while (0)
32
34
#define CLEAR_FMARK(fmarkp_) \
35
RESET_FMARK(fmarkp_, ((pos_T) { 0, 0, 0 }), 0)
36
38
#define SET_XFMARK(xfmarkp_, mark_, fnum_, fname_) \
39
do { \
40
xfmark_T *const xfmarkp__ = xfmarkp_; \
41
xfmarkp__->fname = fname_; \
42
SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_); \
43
} while (0)
44
46
#define RESET_XFMARK(xfmarkp_, mark_, fnum_, fname_) \
47
do { \
48
xfmark_T *const xfmarkp__ = xfmarkp_; \
49
free_xfmark(*xfmarkp__); \
50
xfmarkp__->fname = fname_; \
51
SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_); \
52
} while (0)
53
55
static
inline
int
mark_global_index(
const
char
name
)
56
FUNC_ATTR_CONST
57
{
58
return
(
ASCII_ISUPPER
(
name
)
59
? (
name
-
'A'
)
60
: (ascii_isdigit(
name
)
61
? (
NMARKS
+ (
name
-
'0'
))
62
: -1));
63
}
64
66
static
inline
int
mark_local_index(
const
char
name
)
67
FUNC_ATTR_CONST
68
{
69
return
(
ASCII_ISLOWER
(
name
)
70
? (
name
-
'a'
)
71
: (
name
==
'"'
72
?
NMARKS
73
: (
name
==
'^'
74
?
NMARKS
+ 1
75
: (
name
==
'.'
76
?
NMARKS
+ 2
77
: -1))));
78
}
79
80
static
inline
bool
lt(
pos_T
,
pos_T
)
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE
;
81
static
inline
bool
equalpos(
pos_T
,
pos_T
)
82
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE
;
83
static
inline
bool
ltoreq(
pos_T
,
pos_T
)
84
REAL_FATTR_CONST
REAL_FATTR_ALWAYS_INLINE
;
85
static
inline
void
clearpos(
pos_T
*)
86
REAL_FATTR_ALWAYS_INLINE
;
87
89
static
inline
bool
lt(
pos_T
a,
pos_T
b)
90
{
91
if
(a.
lnum
!= b.
lnum
) {
92
return
a.
lnum
< b.
lnum
;
93
}
else
if
(a.
col
!= b.
col
) {
94
return
a.
col
< b.
col
;
95
}
else
{
96
return
a.
coladd
< b.
coladd
;
97
}
98
}
99
101
static
inline
bool
equalpos(
pos_T
a,
pos_T
b)
102
{
103
return
(a.
lnum
== b.
lnum
) && (a.
col
== b.
col
) && (a.
coladd
== b.
coladd
);
104
}
105
107
static
inline
bool
ltoreq(
pos_T
a,
pos_T
b)
108
{
109
return
lt(a, b) || equalpos(a, b);
110
}
111
113
static
inline
void
clearpos(
pos_T
*a)
114
{
115
a->
lnum
= 0;
116
a->
col
= 0;
117
a->
coladd
= 0;
118
}
119
120
#ifdef INCLUDE_GENERATED_DECLARATIONS
121
# include "mark.h.generated.h"
122
#endif
123
#endif // NVIM_MARK_H
FUNC_ATTR_CONST
#define FUNC_ATTR_CONST
Definition:
func_attr.h:243
time.h
ASCII_ISLOWER
#define ASCII_ISLOWER(c)
Definition:
macros.h:51
macros.h
pos_T::lnum
linenr_T lnum
line number
Definition:
pos.h:30
pos_T::col
colnr_T col
column number
Definition:
pos.h:31
mark_defs.h
pos_T
position in file or buffer
Definition:
pos.h:29
REAL_FATTR_CONST
#define REAL_FATTR_CONST
Definition:
func_attr.h:167
pos_T::coladd
colnr_T coladd
Definition:
pos.h:32
ASCII_ISUPPER
#define ASCII_ISUPPER(c)
Definition:
macros.h:52
extmark_defs.h
name
char_u * name
Definition:
userfunc.c:817
ex_cmds_defs.h
buffer_defs.h
func_attr.h
REAL_FATTR_ALWAYS_INLINE
static int REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE
Definition:
typval_encode.c.h:265
ascii.h
NMARKS
#define NMARKS
Maximum possible number of letter marks.
Definition:
mark_defs.h:17
memory.h
pos.h