]> git.lyx.org Git - lyx.git/blob - src/support/types.h
Let paragraph::requestSpellcheck() consider contained insets
[lyx.git] / src / support / types.h
1 // -*- C++ -*-
2 /**
3  * \file types.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * Provide a set of typedefs for commonly used things like sizes and
8  * indices wile trying to stay compatible with types used
9  * by the standard containers.
10  *
11  * \author André Pönitz
12  *
13  * Full author contact details are available in file CREDITS.
14  */
15
16 #ifndef LYX_TYPES_H
17 #define LYX_TYPES_H
18
19 #include <cstddef>
20
21 namespace lyx {
22
23         /*!
24          * A type for positions used in paragraphs.
25          * Each position is either occupied by a single character or an inset.
26          * For insets, the placeholder META_INSET is stored in the paragraph
27          * text, and the actual insets are maintained separately.
28          */
29         // FIXME: should be unsigned, but needs to be signed for a while to
30         // hold the special value -1 that is used somewhere
31         // Specifically, TexRow::getDocIteratorsFromEntries uses negative pos
32         // the way Python does: counting from the end. So maybe this should just
33         // be signed.
34         // Note that the signed property is also used in loops counting to zero.
35         typedef ptrdiff_t  pos_type;
36
37         /*!
38          * A type for paragraph offsets.
39          * This is used to address paragraphs in ParagraphList, Text etc.
40          */
41         // FIXME: should be unsigned as well.
42         // however, simply changing it breaks a downward loop somewhere...
43         typedef ptrdiff_t  pit_type;
44
45         /// a type for the nesting depth of a paragraph
46         typedef size_t     depth_type;
47
48         /// type for cell indices in inset
49         typedef size_t     idx_type;
50         /// type for row indices
51         typedef size_t     row_type;
52         /// type for col indices
53         typedef size_t     col_type;
54
55         /// type for cells and math insets
56         typedef void const * uid_type;
57
58 // set this to '0' if you want to have really safe types
59 #if 1
60
61         /// a type for sizes
62         typedef size_t     size_type;
63
64 #else
65
66         // These structs wrap simple things to make them distinguishible
67         // to the compiler.
68         // It's a shame that different typedefs are not "really" different
69
70         struct size_type {
71                 ///
72                 typedef size_t base_type;
73                 ///
74                 size_type(base_type t) { data_ = t; }
75                 ///
76                 operator base_type() const { return data_; }
77                 ///
78         private:
79                 base_type data_;
80         };
81
82 #endif
83
84         ///
85         enum word_location {
86                 /// the word around the cursor, only if the cursor is
87                 /// not at a boundary
88                 WHOLE_WORD_STRICT,
89                 // the word around the cursor
90                 WHOLE_WORD,
91                 /// the word beginning from the cursor position
92                 PARTIAL_WORD,
93                 /// the word around the cursor or before the cursor
94                 PREVIOUS_WORD,
95                 /// the next word (not yet used)
96                 NEXT_WORD
97         };
98
99         ///
100         enum PageSides {
101                 ///
102                 OneSide,
103                 ///
104                 TwoSides
105         };
106
107 } // namespace lyx
108
109 #endif // LYX_TYPES_H