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"
23 void TextCursor::setSelection()
25 if (!selection.set()) {
26 selection.start = selection.cursor;
27 selection.end = selection.cursor;
32 // and now the whole selection
33 if (selection.cursor.par() == cursor.par())
34 if (selection.cursor.pos() < cursor.pos()) {
35 selection.end = cursor;
36 selection.start = selection.cursor;
38 selection.end = selection.cursor;
39 selection.start = cursor;
41 else if (selection.cursor.par() < cursor.par() ||
42 (selection.cursor.par() == cursor.par()
43 && selection.cursor.pos() < cursor.pos())) {
44 selection.end = cursor;
45 selection.start = selection.cursor;
48 selection.end = selection.cursor;
49 selection.start = cursor;
52 // a selection with no contents is not a selection
53 if (selection.start.par() == selection.end.par() &&
54 selection.start.pos() == selection.end.pos())
61 void TextCursor::clearSelection()
64 selection.mark(false);
65 selection.end = cursor;
66 selection.start = cursor;
67 selection.cursor = cursor;