fixes #264: In the debugger console, Auto-wrapped lines can't be correctly selected.
This commit is contained in:
parent
a946450014
commit
46b0c4d894
3
NEWS.md
3
NEWS.md
|
@ -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: 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: When debugging, can't watch expressions that has spaces in it.
|
||||||
- fix: Shortcuts in non-editor panels conficts with the editor.
|
- 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
|
Red Panda C++ Version 2.26
|
||||||
- enhancement: Code suggestion for embedded std::vectors.
|
- enhancement: Code suggestion for embedded std::vectors.
|
||||||
|
|
|
@ -481,9 +481,7 @@ void QConsole::contentsLastRowsChanged(int rowCount)
|
||||||
void QConsole::scrollTimerHandler()
|
void QConsole::scrollTimerHandler()
|
||||||
|
|
||||||
{
|
{
|
||||||
QPoint iMousePos;
|
QPoint iMousePos = QCursor::pos();
|
||||||
|
|
||||||
iMousePos = QCursor::pos();
|
|
||||||
iMousePos = mapFromGlobal(iMousePos);
|
iMousePos = mapFromGlobal(iMousePos);
|
||||||
RowColumn mousePosRC = pixelsToNearestRowColumn(iMousePos.x(),iMousePos.y());
|
RowColumn mousePosRC = pixelsToNearestRowColumn(iMousePos.x(),iMousePos.y());
|
||||||
|
|
||||||
|
@ -543,14 +541,15 @@ void QConsole::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QAbstractScrollArea::mouseMoveEvent(event);
|
QAbstractScrollArea::mouseMoveEvent(event);
|
||||||
Qt::MouseButtons buttons = event->buttons();
|
Qt::MouseButtons buttons = event->buttons();
|
||||||
int X=event->pos().x();
|
int x=event->pos().x();
|
||||||
int Y=event->pos().y();
|
int y=event->pos().y();
|
||||||
|
|
||||||
if ((buttons == Qt::LeftButton)) {
|
if ((buttons == Qt::LeftButton)) {
|
||||||
// should we begin scrolling?
|
// should we begin scrolling?
|
||||||
computeScrollY(Y);
|
computeScrollY(y);
|
||||||
RowColumn mousePosRC = pixelsToNearestRowColumn(X, Y);
|
RowColumn mousePosRC = pixelsToNearestRowColumn(x, y);
|
||||||
LineChar mousePos = mContents.rowColumnToLineChar(mousePosRC);
|
LineChar mousePos = mContents.rowColumnToLineChar(mousePosRC);
|
||||||
|
//qDebug()<<x<<y<<mousePosRC.row<<mousePosRC.column<<mousePos.line<<mousePos.ch;
|
||||||
if (mScrollDeltaY == 0) {
|
if (mScrollDeltaY == 0) {
|
||||||
int oldStartRow = mContents.lineCharToRowColumn(selectionBegin()).row+1;
|
int oldStartRow = mContents.lineCharToRowColumn(selectionBegin()).row+1;
|
||||||
int oldEndRow = mContents.lineCharToRowColumn(selectionEnd()).row+1;
|
int oldEndRow = mContents.lineCharToRowColumn(selectionEnd()).row+1;
|
||||||
|
@ -886,13 +885,13 @@ bool QConsole::hasSelection()
|
||||||
|| (mSelectionBegin.ch != mSelectionEnd.ch);
|
|| (mSelectionBegin.ch != mSelectionEnd.ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
int QConsole::computeScrollY(int Y)
|
int QConsole::computeScrollY(int y)
|
||||||
{
|
{
|
||||||
QRect iScrollBounds = viewport()->rect();
|
QRect iScrollBounds = viewport()->rect();
|
||||||
if (Y < iScrollBounds.top())
|
if (y < iScrollBounds.top())
|
||||||
mScrollDeltaY = (Y - iScrollBounds.top()) / mRowHeight - 1;
|
mScrollDeltaY = (y - iScrollBounds.top()) / mRowHeight - 1;
|
||||||
else if (Y >= iScrollBounds.bottom())
|
else if (y >= iScrollBounds.bottom())
|
||||||
mScrollDeltaY = (Y - iScrollBounds.bottom()) / mRowHeight + 1;
|
mScrollDeltaY = (y - iScrollBounds.bottom()) / mRowHeight + 1;
|
||||||
else
|
else
|
||||||
mScrollDeltaY = 0;
|
mScrollDeltaY = 0;
|
||||||
|
|
||||||
|
@ -1159,13 +1158,18 @@ LineChar ConsoleLines::rowColumnToLineChar(int row, int column)
|
||||||
int r=row - rows;
|
int r=row - rows;
|
||||||
QString fragment = line->fragments[r];
|
QString fragment = line->fragments[r];
|
||||||
int columnsBefore = 0;
|
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++) {
|
for (int j=0;j<fragment.size();j++) {
|
||||||
QChar ch = fragment[j];
|
QChar ch = fragment[j];
|
||||||
int charColumns= mConsole->charColumns(ch, columnsBefore);
|
int charColumns= mConsole->charColumns(ch, columnsBefore);
|
||||||
if (column>=columnsBefore && column<columnsBefore+charColumns) {
|
if (column>=columnsBefore && column<columnsBefore+charColumns) {
|
||||||
result.ch = j;
|
result.ch = charsBefore + j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
columnsBefore += charColumns;
|
||||||
}
|
}
|
||||||
result.line = i;
|
result.line = i;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -199,7 +199,7 @@ private:
|
||||||
bool caretInSelection();
|
bool caretInSelection();
|
||||||
QString removeSelection();
|
QString removeSelection();
|
||||||
bool hasSelection();
|
bool hasSelection();
|
||||||
int computeScrollY(int Y);
|
int computeScrollY(int y);
|
||||||
RowColumn pixelsToNearestRowColumn(int x,int y);
|
RowColumn pixelsToNearestRowColumn(int x,int y);
|
||||||
QString lineBreak();
|
QString lineBreak();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue