]> git.lyx.org Git - lyx.git/blob - src/support/types.h
replace ParagraphList::iterator by lyx::paroffset_type to prevent cursor
[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         /// a type for positions used in paragraphs
24         // needs to be signed for a while to hold the special value -1 that is
25         // used there...
26         typedef ptrdiff_t  pos_type;
27
28         /// a type for paragraph offsets 
29         typedef ptrdiff_t  paroffset_type;
30
31         /// a type for the nesting depth of a paragraph
32         typedef size_t     depth_type;
33
34 // set this to '0' if you want to have really safe types
35 #if 1
36
37         /// a type for sizes
38         typedef size_t     size_type;
39
40         /// a type used for numbering text classes
41         typedef size_t     textclass_type;
42
43 #else
44
45         // These structs wrap simple things to make them distinguishible
46         // to the compiler.
47         // It's a shame that different typedefs are not "really" different
48
49         struct size_type {
50                 ///
51                 typedef size_t  base_type;
52                 ///
53                 size_type(base_type t) { data_ = t; }
54                 ///
55                 operator base_type() const { return data_; }
56                 ///
57                 private:
58                 base_type data_;
59         };
60
61         struct textclass_type {
62                 ///
63                 typedef size_t   base_type;
64                 ///
65                 textclass_type(base_type t) { data_ = t; }
66                 ///
67                 operator base_type() const { return data_; }
68                 ///
69                 private:
70                 base_type data_;
71         };
72
73
74 #endif
75
76         ///
77         enum word_location {
78                 // the word around the cursor, only if the cursor is
79                 //not at a boundary
80                 WHOLE_WORD_STRICT,
81                 // the word around the cursor
82                 WHOLE_WORD,
83                 /// the word begining from the cursor position
84                 PARTIAL_WORD,
85                 /// the word around the cursor or before the cursor
86                 PREVIOUS_WORD,
87                 /// the next word (not yet used)
88                 NEXT_WORD
89         };
90
91 }
92
93 #endif // LYX_TYPES_H