aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mark_defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/mark_defs.h')
-rw-r--r--src/nvim/mark_defs.h49
1 files changed, 43 insertions, 6 deletions
diff --git a/src/nvim/mark_defs.h b/src/nvim/mark_defs.h
index 67532d030f..98bdb6ee04 100644
--- a/src/nvim/mark_defs.h
+++ b/src/nvim/mark_defs.h
@@ -2,7 +2,6 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/os/time_defs.h"
-#include "nvim/pos_defs.h"
// marks: positions in a file
// (a normal mark is a lnum/col pair, the same as a file position)
@@ -59,7 +58,7 @@ typedef enum {
#define TAGSTACKSIZE 20
/// Represents view in which the mark was created
-typedef struct fmarkv {
+typedef struct {
linenr_T topline_offset; ///< Amount of lines from the mark lnum to the top of the window.
///< Use MAXLNUM to indicate that the mark does not have a view.
} fmarkv_T;
@@ -67,7 +66,7 @@ typedef struct fmarkv {
#define INIT_FMARKV { MAXLNUM }
/// Structure defining single local mark
-typedef struct filemark {
+typedef struct {
pos_T mark; ///< Cursor position.
int fnum; ///< File number.
Timestamp timestamp; ///< Time when this mark was last set.
@@ -78,12 +77,50 @@ typedef struct filemark {
#define INIT_FMARK { { 0, 0, 0 }, 0, 0, INIT_FMARKV, NULL }
/// Structure defining extended mark (mark with file name attached)
-typedef struct xfilemark {
+typedef struct {
fmark_T fmark; ///< Actual mark.
char *fname; ///< File name, used when fnum == 0.
} xfmark_T;
#define INIT_XFMARK { INIT_FMARK, NULL }
-/// Global marks (marks with file number or name)
-EXTERN xfmark_T namedfm[NGLOBALMARKS] INIT( = { 0 });
+/// Set fmark using given value
+static inline bool lt(pos_T a, pos_T b)
+ REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
+/// Return true if position a is before (less than) position b.
+static inline bool lt(pos_T a, pos_T b)
+{
+ if (a.lnum != b.lnum) {
+ return a.lnum < b.lnum;
+ } else if (a.col != b.col) {
+ return a.col < b.col;
+ } else {
+ return a.coladd < b.coladd;
+ }
+}
+
+static inline bool equalpos(pos_T a, pos_T b)
+ REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
+/// Return true if position a and b are equal.
+static inline bool equalpos(pos_T a, pos_T b)
+{
+ return (a.lnum == b.lnum) && (a.col == b.col) && (a.coladd == b.coladd);
+}
+
+static inline bool ltoreq(pos_T a, pos_T b)
+ REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
+/// Return true if position a is less than or equal to b.
+static inline bool ltoreq(pos_T a, pos_T b)
+{
+ return lt(a, b) || equalpos(a, b);
+}
+
+static inline void clearpos(pos_T *a)
+ REAL_FATTR_ALWAYS_INLINE;
+/// Clear the pos_T structure pointed to by a.
+static inline void clearpos(pos_T *a)
+{
+ a->lnum = 0;
+ a->col = 0;
+ a->coladd = 0;
+}