- fix: don't show tips in the editor, when selecting by mouse

This commit is contained in:
Roy Qu 2022-04-07 17:30:06 +08:00
parent f93a57c82d
commit 7e284b98f2
4 changed files with 24 additions and 55 deletions

View File

@ -7,6 +7,7 @@ Red Panda C++ Version 1.0.3
- enhancement: support Devcie Pixel Ratio ( for linux ) - enhancement: support Devcie Pixel Ratio ( for linux )
- fix: crash when editing txt file and input symbol at the beginning of a line - fix: crash when editing txt file and input symbol at the beginning of a line
- fix: ctrl+shift+end doesn't select - fix: ctrl+shift+end doesn't select
- fix: don't show tips in the editor, when selecting by mouse
Red Panda C++ Version 1.0.2 Red Panda C++ Version 1.0.2
- enhancement: press tab in column mode won't exit column mode - enhancement: press tab in column mode won't exit column mode

View File

@ -995,6 +995,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
bool Editor::event(QEvent *event) bool Editor::event(QEvent *event)
{ {
if ((event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove) if ((event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove)
&& qApp->mouseButtons() == Qt::NoButton
&& pSettings->editor().enableTooltips() && pSettings->editor().enableTooltips()
&& !pMainWindow->completionPopup()->isVisible() && !pMainWindow->completionPopup()->isVisible()
&& !pMainWindow->functionTip()->isVisible() && !pMainWindow->functionTip()->isVisible()

View File

@ -6120,15 +6120,12 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
bool bWasSel = false; bool bWasSel = false;
bool bStartDrag = false; bool bStartDrag = false;
mMouseMoved = false; mMouseMoved = false;
// BufferCoord TmpBegin = mBlockBegin;
// BufferCoord TmpEnd = mBlockEnd;
Qt::MouseButton button = event->button(); Qt::MouseButton button = event->button();
int X=event->pos().x(); int X=event->pos().x();
int Y=event->pos().y(); int Y=event->pos().y();
QAbstractScrollArea::mousePressEvent(event); QAbstractScrollArea::mousePressEvent(event);
//fKbdHandler.ExecuteMouseDown(Self, Button, Shift, X, Y);
if (button == Qt::RightButton) { if (button == Qt::RightButton) {
if (mOptions.testFlag(eoRightMouseMovesCursor) && if (mOptions.testFlag(eoRightMouseMovesCursor) &&
@ -6147,14 +6144,6 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
mMouseDownPos = event->pos(); mMouseDownPos = event->pos();
} }
computeCaret(); computeCaret();
//I couldn't track down why, but sometimes (and definitely not all the time)
//the block positioning is lost. This makes sure that the block is
//maintained in case they started a drag operation on the block
// setBlockBegin(TmpBegin);
// setBlockEnd(TmpEnd);
//setMouseTracking(true);
//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)
&& (mSelectionMode == SynSelectionMode::smNormal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { && (mSelectionMode == SynSelectionMode::smNormal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) {
@ -6191,10 +6180,6 @@ void SynEdit::mouseReleaseEvent(QMouseEvent *event)
processGutterClick(event); processGutterClick(event);
} }
//mScrollTimer->stop();
// if ((button = ) and (Shift = [ssRight]) and Assigned(PopupMenu) then
// exit;
//setMouseTracking(false);
if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) && if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) &&
!mStateFlags.testFlag(SynStateFlag::sfDblClicked)) { !mStateFlags.testFlag(SynStateFlag::sfDblClicked)) {
@ -6212,8 +6197,6 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
QAbstractScrollArea::mouseMoveEvent(event); QAbstractScrollArea::mouseMoveEvent(event);
mMouseMoved = true; mMouseMoved = true;
Qt::MouseButtons buttons = event->buttons(); Qt::MouseButtons buttons = event->buttons();
// int X=event->pos().x();
// int Y=event->pos().y();
if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) { if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) {
if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) { if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) {
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
@ -6224,8 +6207,6 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
drag->setMimeData(mimeData); drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction | Qt::MoveAction); drag->exec(Qt::CopyAction | Qt::MoveAction);
//drag->setPixmap(iconPixmap);
//BeginDrag(false);
} }
} else if ((buttons == Qt::LeftButton)) { } else if ((buttons == Qt::LeftButton)) {
if (mOptions.testFlag(eoAltSetsColumnMode) && if (mOptions.testFlag(eoAltSetsColumnMode) &&
@ -6235,16 +6216,6 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
else else
setActiveSelectionMode(selectionMode()); setActiveSelectionMode(selectionMode());
} }
// should we begin scrolling?
//computeScroll(X, Y,false);
// 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());
} else if (buttons == Qt::NoButton) { } else if (buttons == Qt::NoButton) {
updateMouseCursor(); updateMouseCursor();
} }
@ -6255,10 +6226,8 @@ void SynEdit::mouseDoubleClickEvent(QMouseEvent *event)
QAbstractScrollArea::mouseDoubleClickEvent(event); QAbstractScrollArea::mouseDoubleClickEvent(event);
QPoint ptMouse = event->pos(); QPoint ptMouse = event->pos();
if (ptMouse.x() >= mGutterWidth + 2) { if (ptMouse.x() >= mGutterWidth + 2) {
if (!mOptions.testFlag(eoNoSelection))
setWordBlock(caretXY()); setWordBlock(caretXY());
mStateFlags.setFlag(SynStateFlag::sfDblClicked); mStateFlags.setFlag(SynStateFlag::sfDblClicked);
//MouseCapture := FALSE;
} }
} }
@ -6641,29 +6610,27 @@ BufferCoord SynEdit::blockEnd() const
void SynEdit::setBlockEnd(BufferCoord Value) void SynEdit::setBlockEnd(BufferCoord Value)
{ {
//setActiveSelectionMode(mSelectionMode); //setActiveSelectionMode(mSelectionMode);
if (!mOptions.testFlag(eoNoSelection)) { Value.Line = minMax(Value.Line, 1, mLines->count());
Value.Line = minMax(Value.Line, 1, mLines->count()); Value.Char = minMax(Value.Char, 1, mLines->lengthOfLongestLine()+1);
Value.Char = minMax(Value.Char, 1, mLines->lengthOfLongestLine()+1); if (mActiveSelectionMode == SynSelectionMode::smNormal) {
if (mActiveSelectionMode == SynSelectionMode::smNormal) { if (Value.Line >= 1 && Value.Line <= mLines->count())
if (Value.Line >= 1 && Value.Line <= mLines->count()) Value.Char = std::min(Value.Char, mLines->getString(Value.Line - 1).length() + 1);
Value.Char = std::min(Value.Char, mLines->getString(Value.Line - 1).length() + 1); else
else Value.Char = 1;
Value.Char = 1; }
} if (Value.Char != mBlockEnd.Char || Value.Line != mBlockEnd.Line) {
if (Value.Char != mBlockEnd.Char || Value.Line != mBlockEnd.Line) { if (mActiveSelectionMode == SynSelectionMode::smColumn && Value.Char != mBlockEnd.Char) {
if (mActiveSelectionMode == SynSelectionMode::smColumn && Value.Char != mBlockEnd.Char) { invalidateLines(
invalidateLines( std::min(mBlockBegin.Line, std::min(mBlockEnd.Line, Value.Line)),
std::min(mBlockBegin.Line, std::min(mBlockEnd.Line, Value.Line)), std::max(mBlockBegin.Line, std::max(mBlockEnd.Line, Value.Line)));
std::max(mBlockBegin.Line, std::max(mBlockEnd.Line, Value.Line))); mBlockEnd = Value;
mBlockEnd = Value; } else {
} else { int nLine = mBlockEnd.Line;
int nLine = mBlockEnd.Line; mBlockEnd = Value;
mBlockEnd = Value; if (mActiveSelectionMode != SynSelectionMode::smColumn || mBlockBegin.Char != mBlockEnd.Char)
if (mActiveSelectionMode != SynSelectionMode::smColumn || mBlockBegin.Char != mBlockEnd.Char) invalidateLines(nLine, mBlockEnd.Line);
invalidateLines(nLine, mBlockEnd.Line);
}
setStatusChanged(SynStatusChange::scSelection);
} }
setStatusChanged(SynStatusChange::scSelection);
} }
} }

View File

@ -103,7 +103,7 @@ enum SynEditorOption {
eoShowRainbowColor = 0x00080000, eoShowRainbowColor = 0x00080000,
eoTrimTrailingSpaces =0x00100000, //Spaces at the end of lines will be trimmed and not saved eoTrimTrailingSpaces =0x00100000, //Spaces at the end of lines will be trimmed and not saved
eoSelectWordByDblClick=0x00200000, eoSelectWordByDblClick=0x00200000,
eoNoSelection = 0x00400000, //Disables selecting text // eoNoSelection = 0x00400000, //Disables selecting text
//eoAutoSizeMaxScrollWidth = 0x00000008, //Automatically resizes the MaxScrollWidth property when inserting text //eoAutoSizeMaxScrollWidth = 0x00000008, //Automatically resizes the MaxScrollWidth property when inserting text
//eoDisableScrollArrows = 0x00000010 , //Disables the scroll bar arrow buttons when you can't scroll in that direction any more //eoDisableScrollArrows = 0x00000010 , //Disables the scroll bar arrow buttons when you can't scroll in that direction any more
// eoScrollHintFollows = 0x00020000, //The scroll hint follows the mouse when scrolling vertically // eoScrollHintFollows = 0x00020000, //The scroll hint follows the mouse when scrolling vertically