- enhancement: scroll while dragging text in the editor
This commit is contained in:
parent
2fffe33bb7
commit
03ae21ebf6
1
NEWS.md
1
NEWS.md
|
@ -2,6 +2,7 @@ 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
|
||||||
- fix: can't correctly display stl containers in watch
|
- fix: can't correctly display stl containers in watch
|
||||||
- fix: the last line in the debug console is not correctly displayed
|
- fix: the last line in the debug console is not correctly displayed
|
||||||
|
- enhancement: scroll while dragging text in the editor
|
||||||
|
|
||||||
Version 0.10.0 For Dev-C++ 7 Beta
|
Version 0.10.0 For Dev-C++ 7 Beta
|
||||||
- enhancement: use gdb/mi interface to communicate with gdb debug session
|
- enhancement: use gdb/mi interface to communicate with gdb debug session
|
||||||
|
|
|
@ -34,6 +34,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mOrigLines = mLines;
|
mOrigLines = mLines;
|
||||||
//fPlugins := TList.Create;
|
//fPlugins := TList.Create;
|
||||||
mMouseMoved = false;
|
mMouseMoved = false;
|
||||||
|
mDragging = false;
|
||||||
mUndoing = false;
|
mUndoing = false;
|
||||||
mLines->connect(mLines.get(), &SynEditStringList::changed, this, &SynEdit::onLinesChanged);
|
mLines->connect(mLines.get(), &SynEditStringList::changed, this, &SynEdit::onLinesChanged);
|
||||||
mLines->connect(mLines.get(), &SynEditStringList::changing, this, &SynEdit::onLinesChanging);
|
mLines->connect(mLines.get(), &SynEditStringList::changing, this, &SynEdit::onLinesChanging);
|
||||||
|
@ -2483,14 +2484,16 @@ void SynEdit::computeCaret(int X, int Y)
|
||||||
void SynEdit::computeScroll(int X, int Y)
|
void SynEdit::computeScroll(int X, int Y)
|
||||||
{
|
{
|
||||||
QRect iScrollBounds; // relative to the client area
|
QRect iScrollBounds; // relative to the client area
|
||||||
// don't scroll if dragging text from other control
|
int dispX,dispY = 2;
|
||||||
// if (not MouseCapture) and (not Dragging) then begin
|
if (mDragging) {
|
||||||
// fScrollTimer.Enabled := False;
|
dispX = mCharWidth / 2 -1;
|
||||||
// Exit;
|
dispY = mTextHeight/ 2 -1;
|
||||||
// end;
|
}
|
||||||
|
|
||||||
iScrollBounds = QRect(mGutterWidth+this->frameWidth(), this->frameWidth(), mCharsInWindow * mCharWidth,
|
iScrollBounds = QRect(mGutterWidth+frameWidth()+dispX,
|
||||||
mLinesInWindow * mTextHeight);
|
frameWidth()+dispY,
|
||||||
|
mCharsInWindow * mCharWidth-2*dispX,
|
||||||
|
mLinesInWindow * mTextHeight-2*dispY);
|
||||||
|
|
||||||
if (X < iScrollBounds.left())
|
if (X < iScrollBounds.left())
|
||||||
mScrollDeltaX = (X - iScrollBounds.left()) / mCharWidth - 1;
|
mScrollDeltaX = (X - iScrollBounds.left()) / mCharWidth - 1;
|
||||||
|
@ -5948,7 +5951,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
|
||||||
// setBlockBegin(TmpBegin);
|
// setBlockBegin(TmpBegin);
|
||||||
// setBlockEnd(TmpEnd);
|
// setBlockEnd(TmpEnd);
|
||||||
|
|
||||||
setMouseTracking(true);
|
//setMouseTracking(true);
|
||||||
//if mousedown occurred in selected block begin drag operation
|
//if mousedown occurred in selected block begin drag operation
|
||||||
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
|
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
|
||||||
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
|
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
|
||||||
|
@ -5988,7 +5991,7 @@ void SynEdit::mouseReleaseEvent(QMouseEvent *event)
|
||||||
mScrollTimer->stop();
|
mScrollTimer->stop();
|
||||||
// if ((button = ) and (Shift = [ssRight]) and Assigned(PopupMenu) then
|
// if ((button = ) and (Shift = [ssRight]) and Assigned(PopupMenu) then
|
||||||
// exit;
|
// exit;
|
||||||
setMouseTracking(false);
|
//setMouseTracking(false);
|
||||||
|
|
||||||
if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) &&
|
if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) &&
|
||||||
!mStateFlags.testFlag(SynStateFlag::sfDblClicked)) {
|
!mStateFlags.testFlag(SynStateFlag::sfDblClicked)) {
|
||||||
|
@ -6129,6 +6132,7 @@ QVariant SynEdit::inputMethodQuery(Qt::InputMethodQuery property) const
|
||||||
void SynEdit::dragEnterEvent(QDragEnterEvent *event)
|
void SynEdit::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
if (event->mimeData()->hasFormat("text/plain")) {
|
if (event->mimeData()->hasFormat("text/plain")) {
|
||||||
|
mDragging = true;
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
mDragCaretSave = caretXY();
|
mDragCaretSave = caretXY();
|
||||||
mDragSelBeginSave = blockBegin();
|
mDragSelBeginSave = blockBegin();
|
||||||
|
@ -6158,6 +6162,7 @@ void SynEdit::dropEvent(QDropEvent *event)
|
||||||
setCaretXY(coord);
|
setCaretXY(coord);
|
||||||
setSelText(event->mimeData()->text());
|
setSelText(event->mimeData()->text());
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
mDragging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::dragMoveEvent(QDragMoveEvent *event)
|
void SynEdit::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
@ -6167,9 +6172,21 @@ void SynEdit::dragMoveEvent(QDragMoveEvent *event)
|
||||||
} else {
|
} else {
|
||||||
event->setDropAction(Qt::MoveAction);
|
event->setDropAction(Qt::MoveAction);
|
||||||
}
|
}
|
||||||
|
// should we begin scrolling?
|
||||||
|
computeScroll(event->pos().x(),
|
||||||
|
event->pos().y());
|
||||||
|
// DisplayCoord P = pixelsToNearestRowColumn(X, Y);
|
||||||
|
// P.Row = minMax(P.Row, 1, displayLineCount());
|
||||||
|
// if (mScrollDeltaX != 0)
|
||||||
|
// P.Column = displayX();
|
||||||
|
// if (mScrollDeltaY != 0)
|
||||||
|
// P.Row = displayY();
|
||||||
|
// internalSetCaretXY(displayToBufferPos(P));
|
||||||
|
// setBlockEnd(caretXY());
|
||||||
|
|
||||||
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
|
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
|
||||||
event->pos().y()));
|
event->pos().y()));
|
||||||
setCaretXY(coord);
|
internalSetCaretXY(coord);
|
||||||
setBlockBegin(mDragSelBeginSave);
|
setBlockBegin(mDragSelBeginSave);
|
||||||
setBlockEnd(mDragSelEndSave);
|
setBlockEnd(mDragSelEndSave);
|
||||||
showCaret();
|
showCaret();
|
||||||
|
@ -6181,6 +6198,8 @@ void SynEdit::dragLeaveEvent(QDragLeaveEvent *)
|
||||||
setBlockBegin(mDragSelBeginSave);
|
setBlockBegin(mDragSelBeginSave);
|
||||||
setBlockEnd(mDragSelEndSave);
|
setBlockEnd(mDragSelEndSave);
|
||||||
showCaret();
|
showCaret();
|
||||||
|
mScrollTimer->stop();
|
||||||
|
mDragging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEdit::maxScrollHeight() const
|
int SynEdit::maxScrollHeight() const
|
||||||
|
@ -6591,8 +6610,11 @@ void SynEdit::onScrollTimeout()
|
||||||
internalSetCaretXY(vCaret);
|
internalSetCaretXY(vCaret);
|
||||||
|
|
||||||
// if MouseCapture is True we're changing selection. otherwise we're dragging
|
// if MouseCapture is True we're changing selection. otherwise we're dragging
|
||||||
// if (mouseCapture())
|
if (mDragging) {
|
||||||
setBlockEnd(caretXY());
|
setBlockBegin(mDragSelBeginSave);
|
||||||
|
setBlockEnd(mDragSelEndSave);
|
||||||
|
} else
|
||||||
|
setBlockEnd(caretXY());
|
||||||
}
|
}
|
||||||
computeScroll(iMousePos.x(), iMousePos.y());
|
computeScroll(iMousePos.x(), iMousePos.y());
|
||||||
}
|
}
|
||||||
|
|
|
@ -701,6 +701,7 @@ private:
|
||||||
BufferCoord mDragCaretSave;
|
BufferCoord mDragCaretSave;
|
||||||
BufferCoord mDragSelBeginSave;
|
BufferCoord mDragSelBeginSave;
|
||||||
BufferCoord mDragSelEndSave;
|
BufferCoord mDragSelEndSave;
|
||||||
|
bool mDragging;
|
||||||
|
|
||||||
friend class SynEditTextPainter;
|
friend class SynEditTextPainter;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ QConsole::QConsole(QWidget *parent):
|
||||||
mBlinkStatus = 0;
|
mBlinkStatus = 0;
|
||||||
//enable input method
|
//enable input method
|
||||||
setAttribute(Qt::WA_InputMethodEnabled);
|
setAttribute(Qt::WA_InputMethodEnabled);
|
||||||
setMouseTracking(false);
|
// setMouseTracking(false);
|
||||||
recalcCharExtent();
|
recalcCharExtent();
|
||||||
mScrollTimer = new QTimer(this);
|
mScrollTimer = new QTimer(this);
|
||||||
mScrollTimer->setInterval(100);
|
mScrollTimer->setInterval(100);
|
||||||
|
@ -504,7 +504,7 @@ void QConsole::mousePressEvent(QMouseEvent *event)
|
||||||
//fKbdHandler.ExecuteMouseDown(Self, Button, Shift, X, Y);
|
//fKbdHandler.ExecuteMouseDown(Self, Button, Shift, X, Y);
|
||||||
|
|
||||||
if (button == Qt::LeftButton) {
|
if (button == Qt::LeftButton) {
|
||||||
setMouseTracking(true);
|
// setMouseTracking(true);
|
||||||
RowColumn mousePosRC = pixelsToNearestRowColumn(X,Y);
|
RowColumn mousePosRC = pixelsToNearestRowColumn(X,Y);
|
||||||
LineChar mousePos = mContents.rowColumnToLineChar(mousePosRC);
|
LineChar mousePos = mContents.rowColumnToLineChar(mousePosRC);
|
||||||
//I couldn't track down why, but sometimes (and definitely not all the time)
|
//I couldn't track down why, but sometimes (and definitely not all the time)
|
||||||
|
@ -522,7 +522,7 @@ void QConsole::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QAbstractScrollArea::mouseReleaseEvent(event);
|
QAbstractScrollArea::mouseReleaseEvent(event);
|
||||||
mScrollTimer->stop();
|
mScrollTimer->stop();
|
||||||
setMouseTracking(false);
|
// setMouseTracking(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue