File: lsPosition.h

package info (click to toggle)
asymptote 2.85%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 43,264 kB
  • sloc: cpp: 210,491; ansic: 98,376; python: 14,568; javascript: 6,629; sh: 4,301; perl: 1,566; lisp: 1,505; makefile: 764; yacc: 554; lex: 446; xml: 182; objc: 177
file content (40 lines) | stat: -rw-r--r-- 1,291 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#include "LibLsp/JsonRpc/serializer.h"



#include <string>
#include <vector>

//Position in a text document expressed as zero - based line and zero - based character offset.
//A position is between two characters like an insert cursor in a editor.Special values like
//for example - 1 to denote the end of a line are not supported.
struct lsPosition {
        lsPosition();
        lsPosition(int line, int character);

        bool operator==(const lsPosition& other) const;
        bool operator<(const lsPosition& other) const;

        std::string ToString() const;

        /**
         * Line position in a document (zero-based).
         */
        // Note: these are 0-based.
        unsigned line = 0;
        /**
         * Character offset on a line in a document (zero-based). Assuming that
         * the line is represented as a string, the `character` value represents
         * the gap between the `character` and `character + 1`.
         *
         * If the character value is greater than the line length it defaults back
         * to the line length.
         */
        unsigned character = 0;
        static const lsPosition kZeroPosition;

        MAKE_SWAP_METHOD(lsPosition, line, character)
};
MAKE_REFLECT_STRUCT(lsPosition, line, character);