mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
dcd8fb0428
invalidation if the paragraphlist is changed. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7883 a592a061-630c-0410-9148-cb99ea01b6c8
69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
/**
|
|
* \file textcursor.C
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author André Pönitz
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "textcursor.h"
|
|
#include "paragraph.h"
|
|
#include "ParagraphList_fwd.h"
|
|
|
|
#include <string>
|
|
|
|
using std::string;
|
|
|
|
|
|
void TextCursor::setSelection()
|
|
{
|
|
if (!selection.set()) {
|
|
selection.start = selection.cursor;
|
|
selection.end = selection.cursor;
|
|
}
|
|
|
|
selection.set(true);
|
|
|
|
// and now the whole selection
|
|
if (selection.cursor.par() == cursor.par())
|
|
if (selection.cursor.pos() < cursor.pos()) {
|
|
selection.end = cursor;
|
|
selection.start = selection.cursor;
|
|
} else {
|
|
selection.end = selection.cursor;
|
|
selection.start = cursor;
|
|
}
|
|
else if (selection.cursor.y() < cursor.y() ||
|
|
(selection.cursor.y() == cursor.y()
|
|
&& selection.cursor.x() < cursor.x())) {
|
|
selection.end = cursor;
|
|
selection.start = selection.cursor;
|
|
}
|
|
else {
|
|
selection.end = selection.cursor;
|
|
selection.start = cursor;
|
|
}
|
|
|
|
// a selection with no contents is not a selection
|
|
if (selection.start.par() == selection.end.par() &&
|
|
selection.start.pos() == selection.end.pos())
|
|
{
|
|
selection.set(false);
|
|
}
|
|
}
|
|
|
|
|
|
void TextCursor::clearSelection()
|
|
{
|
|
selection.set(false);
|
|
selection.mark(false);
|
|
selection.end = cursor;
|
|
selection.start = cursor;
|
|
selection.cursor = cursor;
|
|
}
|
|
|