3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "textcursor.h"
14 #include "paragraph.h"
15 #include "ParagraphList_fwd.h"
22 void TextCursor::setSelection()
24 if (!selection.set()) {
25 selection.start = selection.cursor;
26 selection.end = selection.cursor;
31 // and now the whole selection
32 if (selection.cursor.par() == cursor.par())
33 if (selection.cursor.pos() < cursor.pos()) {
34 selection.end = cursor;
35 selection.start = selection.cursor;
37 selection.end = selection.cursor;
38 selection.start = cursor;
40 else if (selection.cursor.y() < cursor.y() ||
41 (selection.cursor.y() == cursor.y()
42 && selection.cursor.x() < cursor.x())) {
43 selection.end = cursor;
44 selection.start = selection.cursor;
47 selection.end = selection.cursor;
48 selection.start = cursor;
51 // a selection with no contents is not a selection
52 if (selection.start.par() == selection.end.par() &&
53 selection.start.pos() == selection.end.pos())
60 void TextCursor::clearSelection()
63 selection.mark(false);
64 selection.end = cursor;
65 selection.start = cursor;
66 selection.cursor = cursor;