From dda0f82b4d0a39b3192b5c44a0efb53fd272ad4c Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 22 Nov 2021 19:10:56 +0800 Subject: [PATCH] - fix: columns calculation not correct when paint lines containing chinese characters --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 1 - RedPandaIDE/mainwindow.cpp | 11 ----------- RedPandaIDE/mainwindow.h | 2 -- RedPandaIDE/qsynedit/SynEdit.cpp | 6 +++++- RedPandaIDE/qsynedit/TextPainter.cpp | 2 +- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9604af37..6bbcf14e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ Version 0.9.3 For Dev-C++ 7 Beta - fix: the count in the title of issues view isn't correct + - fix: columns calculation not correct when paint lines containing chinese characters Version 0.9.2 For Dev-C++ 7 Beta - fix: gutter of the disassembly code control in the cpu info dialog is grayed diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 7873cbb1..94d48b1a 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -876,7 +876,6 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to if (token.isEmpty()) return; -// qDebug()<name()<<" - "<identifierAttribute())) { BufferCoord p{aChar,line}; BufferCoord pBeginPos,pEndPos; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 300df729..87fb4e50 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -5695,16 +5695,6 @@ void MainWindow::on_actionProblem_triggered() showHideMessagesTab(ui->tabProblem,state); } - -void MainWindow::on_actionInsert_Line_triggered() -{ - Editor *e=mEditorList->getEditor(); - if (e) { - e->insertLine(); - } -} - - void MainWindow::on_actionDelete_Line_triggered() { Editor *e=mEditorList->getEditor(); @@ -5713,7 +5703,6 @@ void MainWindow::on_actionDelete_Line_triggered() } } - void MainWindow::on_actionDuplicate_Line_triggered() { Editor *e=mEditorList->getEditor(); diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 693299e8..4e0383b4 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -518,8 +518,6 @@ private slots: void on_actionProblem_triggered(); - void on_actionInsert_Line_triggered(); - void on_actionDelete_Line_triggered(); void on_actionDuplicate_Line_triggered(); diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 5194d8f3..3c1793f3 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -250,6 +250,10 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPos, BufferCoord value) invalidateLine(mCaretY); invalidateLine(oldCaretY); } + if (mGutter.activeLineTextColor().isValid()) { + invalidateGutterLine(mCaretY); + invalidateGutterLine(oldCaretY); + } mStatusChanges.setFlag(SynStatusChange::scCaretY); } // Call UpdateLastCaretX before DecPaintLock because the event handler it @@ -829,7 +833,7 @@ int SynEdit::columnToChar(int aLine, int aColumn) const int SynEdit::stringColumns(const QString &line, int colsBefore) const { - int columns = colsBefore; + int columns = std::max(0,colsBefore); int charCols; for (int i=0;imHighlighter->next(); } // Don't assume HL.GetTokenPos is valid after HL.GetEOL == True. - nTokenColumnsBefore += edit->stringColumns(sToken,nTokenColumnsBefore-1); + nTokenColumnsBefore += edit->stringColumns(sToken,nTokenColumnsBefore); if (edit->mHighlighter->eol() && (nTokenColumnsBefore < vLastChar)) { int lineColumns = edit->mLines->lineColumns(vLine-1); // Draw text that couldn't be parsed by the highlighter, if any.