]> git.lyx.org Git - lyx.git/blob - src/textcursor.C
some integer type changes for inset unification
[lyx.git] / src / textcursor.C
1 /**
2  * \file textcursor.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "textcursor.h"
14
15
16 LyXCursor const & TextCursor::selStart() const
17 {
18         if (!selection.set())
19                 return cursor_;
20         // can't use std::min as this creates a new object
21         return anchor_ < cursor_ ? anchor_ : cursor_;
22 }
23
24
25 LyXCursor const & TextCursor::selEnd() const
26 {
27         if (!selection.set())
28                 return cursor_;
29         return anchor_ > cursor_ ? anchor_ : cursor_;
30 }
31
32
33 LyXCursor & TextCursor::selStart()
34 {
35         if (!selection.set())
36                 return cursor_;
37         return anchor_ < cursor_ ? anchor_ : cursor_;
38 }
39
40
41 LyXCursor & TextCursor::selEnd()
42 {
43         if (!selection.set())
44                 return cursor_;
45         return anchor_ > cursor_ ? anchor_ : cursor_;
46 }
47
48
49 void TextCursor::setSelection()
50 {
51         selection.set(true);
52         // a selection with no contents is not a selection
53         if (cursor_.par() == anchor_.par() && cursor_.pos() == anchor_.pos())
54                 selection.set(false);
55 }
56
57
58 void TextCursor::clearSelection()
59 {
60         selection.set(false);
61         selection.mark(false);
62         anchor_ = cursor_;
63 }
64