fixes #264: In the debugger console, Auto-wrapped lines can't be correctly selected.

This commit is contained in:
Roy Qu 2024-03-13 20:10:31 +08:00
parent a946450014
commit 46b0c4d894
3 changed files with 21 additions and 14 deletions

View File

@ -47,6 +47,9 @@ Red Panda C++ Version 2.27
- fix: Failed to evaluate expressions while debugging, if the expression has spaces in it.
- fix: When debugging, can't watch expressions that has spaces in it.
- fix: Shortcuts in non-editor panels conficts with the editor.
- enhancement: Font list in the options / editor / font panel( by CyanoHao ).
- enhancement: Text are vertically center aligned in lines( by CyanoHao ).
- fix: In the debugger console, Auto-wrapped lines can't be correctly selected.
Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors.

View File

@ -481,9 +481,7 @@ void QConsole::contentsLastRowsChanged(int rowCount)
void QConsole::scrollTimerHandler()
{
QPoint iMousePos;
iMousePos = QCursor::pos();
QPoint iMousePos = QCursor::pos();
iMousePos = mapFromGlobal(iMousePos);
RowColumn mousePosRC = pixelsToNearestRowColumn(iMousePos.x(),iMousePos.y());
@ -543,14 +541,15 @@ void QConsole::mouseMoveEvent(QMouseEvent *event)
{
QAbstractScrollArea::mouseMoveEvent(event);
Qt::MouseButtons buttons = event->buttons();
int X=event->pos().x();
int Y=event->pos().y();
int x=event->pos().x();
int y=event->pos().y();
if ((buttons == Qt::LeftButton)) {
// should we begin scrolling?
computeScrollY(Y);
RowColumn mousePosRC = pixelsToNearestRowColumn(X, Y);
computeScrollY(y);
RowColumn mousePosRC = pixelsToNearestRowColumn(x, y);
LineChar mousePos = mContents.rowColumnToLineChar(mousePosRC);
//qDebug()<<x<<y<<mousePosRC.row<<mousePosRC.column<<mousePos.line<<mousePos.ch;
if (mScrollDeltaY == 0) {
int oldStartRow = mContents.lineCharToRowColumn(selectionBegin()).row+1;
int oldEndRow = mContents.lineCharToRowColumn(selectionEnd()).row+1;
@ -886,13 +885,13 @@ bool QConsole::hasSelection()
|| (mSelectionBegin.ch != mSelectionEnd.ch);
}
int QConsole::computeScrollY(int Y)
int QConsole::computeScrollY(int y)
{
QRect iScrollBounds = viewport()->rect();
if (Y < iScrollBounds.top())
mScrollDeltaY = (Y - iScrollBounds.top()) / mRowHeight - 1;
else if (Y >= iScrollBounds.bottom())
mScrollDeltaY = (Y - iScrollBounds.bottom()) / mRowHeight + 1;
if (y < iScrollBounds.top())
mScrollDeltaY = (y - iScrollBounds.top()) / mRowHeight - 1;
else if (y >= iScrollBounds.bottom())
mScrollDeltaY = (y - iScrollBounds.bottom()) / mRowHeight + 1;
else
mScrollDeltaY = 0;
@ -1159,13 +1158,18 @@ LineChar ConsoleLines::rowColumnToLineChar(int row, int column)
int r=row - rows;
QString fragment = line->fragments[r];
int columnsBefore = 0;
int charsBefore = 0;
for (int j=0;j<r;j++) {
charsBefore += line->fragments[j].length();
}
for (int j=0;j<fragment.size();j++) {
QChar ch = fragment[j];
int charColumns= mConsole->charColumns(ch, columnsBefore);
if (column>=columnsBefore && column<columnsBefore+charColumns) {
result.ch = j;
result.ch = charsBefore + j;
break;
}
columnsBefore += charColumns;
}
result.line = i;
break;

View File

@ -199,7 +199,7 @@ private:
bool caretInSelection();
QString removeSelection();
bool hasSelection();
int computeScrollY(int Y);
int computeScrollY(int y);
RowColumn pixelsToNearestRowColumn(int x,int y);
QString lineBreak();