]> git.lyx.org Git - lyx.git/blob - src/textcursor.C
Overhaul the branches code.
[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         return selection.cursor < cursor ? selection.cursor : cursor;
21 }
22
23
24 LyXCursor const & TextCursor::selEnd() const
25 {
26         if (!selection.set())
27                 return cursor;
28         return selection.cursor < cursor ? cursor : selection.cursor;
29 }
30
31
32 LyXCursor & TextCursor::selStart()
33 {
34         TextCursor const & t = *this;
35         return const_cast<LyXCursor &>(t.selStart());
36 }
37
38
39 LyXCursor & TextCursor::selEnd()
40 {
41         TextCursor const & t = *this;
42         return const_cast<LyXCursor &>(t.selEnd());
43 }
44
45
46 void TextCursor::setSelection()
47 {
48         selection.set(true);
49         // a selection with no contents is not a selection
50         if (cursor.par() == selection.cursor.par() &&
51             cursor.pos() == selection.cursor.pos())
52         {
53                 selection.set(false);
54         }
55 }
56
57
58 void TextCursor::clearSelection()
59 {
60         selection.set(false);
61         selection.mark(false);
62         selection.cursor = cursor;
63 }
64