]> git.lyx.org Git - lyx.git/blob - src/textcursor.C
remove Inset::getParagraphs()
[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 #include "paragraph.h"
15 #include "ParagraphList_fwd.h"
16 #include "debug.h"
17
18 #include <string>
19
20 using std::string;
21
22
23 void TextCursor::setSelection()
24 {
25         selection.set(true);
26
27         if (selection.cursor.par() == cursor.par())
28                 if (selection.cursor.pos() < cursor.pos()) {
29                         selection.end = cursor;
30                         selection.start = selection.cursor;
31                 } else {
32                         selection.end = selection.cursor;
33                         selection.start = cursor;
34                 }
35         else if (selection.cursor.par() < cursor.par() ||
36                  (selection.cursor.par() == cursor.par()
37                   && selection.cursor.pos() < cursor.pos())) {
38                 selection.end = cursor;
39                 selection.start = selection.cursor;
40         } else {
41                 selection.end = selection.cursor;
42                 selection.start = cursor;
43         }
44
45         // a selection with no contents is not a selection
46         if (selection.start.par() == selection.end.par() &&
47             selection.start.pos() == selection.end.pos())
48         {
49                 selection.set(false);
50         }
51 }
52
53
54 void TextCursor::clearSelection()
55 {
56         selection.set(false);
57         selection.mark(false);
58         selection.end    = cursor;
59         selection.start  = cursor;
60         selection.cursor = cursor;
61 }
62