- fix: dragging text from lines in the front to lines back will cause error
- fix: dragging text onto itself should do nothing
This commit is contained in:
parent
ed3f320c50
commit
db61432d36
2
NEWS.md
2
NEWS.md
|
@ -1,6 +1,8 @@
|
||||||
Version 0.10.2 For Dev-C++ 7 Beta
|
Version 0.10.2 For Dev-C++ 7 Beta
|
||||||
- fix: select by mouse can't correctly set mouse's column position
|
- fix: select by mouse can't correctly set mouse's column position
|
||||||
- fix: dragging out of the editor and back will cause error
|
- fix: dragging out of the editor and back will cause error
|
||||||
|
- fix: dragging text from lines in the front to lines back will cause error
|
||||||
|
- fix: dragging text onto itself should do nothing
|
||||||
|
|
||||||
Version 0.10.1 For Dev-C++ 7 Beta
|
Version 0.10.1 For Dev-C++ 7 Beta
|
||||||
- fix: can't correctly expand watch expression that has spaces in it
|
- fix: can't correctly expand watch expression that has spaces in it
|
||||||
|
|
|
@ -6203,23 +6203,58 @@ void SynEdit::dragEnterEvent(QDragEnterEvent *event)
|
||||||
void SynEdit::dropEvent(QDropEvent *event)
|
void SynEdit::dropEvent(QDropEvent *event)
|
||||||
{
|
{
|
||||||
//mScrollTimer->stop();
|
//mScrollTimer->stop();
|
||||||
mUndoList->BeginBlock();
|
|
||||||
auto action = finally([this] {
|
|
||||||
mUndoList->EndBlock();
|
|
||||||
});
|
|
||||||
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
|
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
|
||||||
event->pos().y()));
|
event->pos().y()));
|
||||||
int topLine = mTopLine;
|
|
||||||
int leftChar = mLeftChar;
|
|
||||||
if (event->proposedAction() == Qt::DropAction::MoveAction) {
|
|
||||||
setBlockBegin(mDragSelBeginSave);
|
|
||||||
setBlockEnd(mDragSelEndSave);
|
|
||||||
setSelText("");
|
|
||||||
}
|
|
||||||
setTopLine(topLine);
|
|
||||||
setLeftChar(leftChar);
|
|
||||||
setCaretXY(coord);
|
setCaretXY(coord);
|
||||||
setSelText(event->mimeData()->text());
|
if (coord>=mDragSelBeginSave && coord<=mDragSelEndSave) {
|
||||||
|
//do nothing if drag onto itself
|
||||||
|
} else if (event->proposedAction() == Qt::DropAction::CopyAction) {
|
||||||
|
//just copy it
|
||||||
|
setSelText(event->mimeData()->text());
|
||||||
|
} else if (event->proposedAction() == Qt::DropAction::MoveAction) {
|
||||||
|
int topLine = mTopLine;
|
||||||
|
int leftChar = mLeftChar;
|
||||||
|
mUndoList->BeginBlock();
|
||||||
|
if (coord < mDragSelBeginSave ) {
|
||||||
|
//delete old
|
||||||
|
setBlockBegin(mDragSelBeginSave);
|
||||||
|
setBlockEnd(mDragSelEndSave);
|
||||||
|
setSelText("");
|
||||||
|
//paste to new position
|
||||||
|
setTopLine(topLine);
|
||||||
|
setLeftChar(leftChar);
|
||||||
|
setCaretXY(coord);
|
||||||
|
setSelText(event->mimeData()->text());
|
||||||
|
} else {
|
||||||
|
//paste to new position
|
||||||
|
setTopLine(topLine);
|
||||||
|
setLeftChar(leftChar);
|
||||||
|
setCaretXY(coord);
|
||||||
|
setSelText(event->mimeData()->text());
|
||||||
|
//delete old
|
||||||
|
setBlockBegin(mDragSelBeginSave);
|
||||||
|
setBlockEnd(mDragSelEndSave);
|
||||||
|
setSelText("");
|
||||||
|
//set caret to right pos
|
||||||
|
if (mDragSelBeginSave.Line == mDragSelEndSave.Line) {
|
||||||
|
if (coord.Line == mDragSelEndSave.Line) {
|
||||||
|
coord.Char -= mDragSelEndSave.Char-mDragSelBeginSave.Char;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (coord.Line == mDragSelEndSave.Line) {
|
||||||
|
coord.Char -= mDragSelEndSave.Char-1;
|
||||||
|
} else {
|
||||||
|
coord.Line -= mDragSelEndSave.Line-mDragSelBeginSave.Line;
|
||||||
|
topLine -= mDragSelEndSave.Line-mDragSelBeginSave.Line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTopLine(topLine);
|
||||||
|
setLeftChar(leftChar);
|
||||||
|
setCaretXY(coord);
|
||||||
|
}
|
||||||
|
mUndoList->EndBlock();
|
||||||
|
}
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,3 +239,32 @@ bool BufferCoord::operator==(const BufferCoord &coord)
|
||||||
{
|
{
|
||||||
return coord.Char == Char && coord.Line == Line;
|
return coord.Char == Char && coord.Line == Line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BufferCoord::operator>=(const BufferCoord &coord)
|
||||||
|
{
|
||||||
|
return (Line > coord.Line)
|
||||||
|
|| (Line == coord.Line && Char >= coord.Char);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BufferCoord::operator>(const BufferCoord &coord)
|
||||||
|
{
|
||||||
|
return (Line > coord.Line)
|
||||||
|
|| (Line == coord.Line && Char > coord.Char);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BufferCoord::operator<(const BufferCoord &coord)
|
||||||
|
{
|
||||||
|
return (Line < coord.Line)
|
||||||
|
|| (Line == coord.Line && Char < coord.Char);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BufferCoord::operator<=(const BufferCoord &coord)
|
||||||
|
{
|
||||||
|
return (Line < coord.Line)
|
||||||
|
|| (Line == coord.Line && Char <= coord.Char);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BufferCoord::operator!=(const BufferCoord &coord)
|
||||||
|
{
|
||||||
|
return coord.Char != Char || coord.Line != Line;
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,11 @@ struct BufferCoord {
|
||||||
int Char;
|
int Char;
|
||||||
int Line;
|
int Line;
|
||||||
bool operator==(const BufferCoord& coord);
|
bool operator==(const BufferCoord& coord);
|
||||||
|
bool operator>=(const BufferCoord& coord);
|
||||||
|
bool operator>(const BufferCoord& coord);
|
||||||
|
bool operator<(const BufferCoord& coord);
|
||||||
|
bool operator<=(const BufferCoord& coord);
|
||||||
|
bool operator!=(const BufferCoord& coord);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SynEdit;
|
class SynEdit;
|
||||||
|
|
Loading…
Reference in New Issue