From 1ccd28e65e8731ea433b8b7be5f548b713254868 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 14 Mar 2024 09:58:57 +0800 Subject: [PATCH] enhancement: display column info if force fixed font width is turned on --- RedPandaIDE/mainwindow.cpp | 40 ++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index a0d62887..92840a50 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1498,19 +1498,35 @@ void MainWindow::updateStatusbarForLineCol(const Editor* e, bool clear) { if (!clear && e!=nullptr) { QString msg; - if (e->selAvail()) { - msg = tr("Line: %1/%2 Char: %3/%4 Sel:%5") - .arg(e->caretY()) - .arg(e->document()->count()) - .arg(e->caretX()) - .arg(e->lineText().length()) - .arg(e->selText().length()); + if (pSettings->editor().forceFixedFontWidth()){ + int col = e->charToGlyphLeft(e->caretY(),e->caretX())/e->charWidth()+1; + if (e->selAvail()) { + msg = tr("Line: %1/%2 Col: %3 Sel:%5") + .arg(e->caretY()) + .arg(e->document()->count()) + .arg(col) + .arg(e->selText().length()); + } else { + msg = tr("Line: %1/%2 Col: %3") + .arg(e->caretY()) + .arg(e->document()->count()) + .arg(col); + } } else { - msg = tr("Line: %1/%2 Char: %3/%4") - .arg(e->caretY()) - .arg(e->document()->count()) - .arg(e->caretX()) - .arg(e->lineText().length()); + if (e->selAvail()) { + msg = tr("Line: %1/%2 Char: %3/%4 Sel:%5") + .arg(e->caretY()) + .arg(e->document()->count()) + .arg(e->caretX()) + .arg(e->lineText().length()) + .arg(e->selText().length()); + } else { + msg = tr("Line: %1/%2 Char: %3/%4") + .arg(e->caretY()) + .arg(e->document()->count()) + .arg(e->caretX()) + .arg(e->lineText().length()); + } } mFileInfoStatus->setText(msg); } else {