speed out selection count calculation
This commit is contained in:
parent
5e10d0b4db
commit
2cad9262c9
|
@ -1517,7 +1517,7 @@ void MainWindow::updateStatusbarForLineCol(const Editor* e, bool clear)
|
|||
.arg(e->caretY())
|
||||
.arg(e->document()->count())
|
||||
.arg(col)
|
||||
.arg(e->selText().length());
|
||||
.arg(e->selCount());
|
||||
} else {
|
||||
msg = tr("Line: %1/%2 Col: %3")
|
||||
.arg(e->caretY())
|
||||
|
@ -1531,7 +1531,7 @@ void MainWindow::updateStatusbarForLineCol(const Editor* e, bool clear)
|
|||
.arg(e->document()->count())
|
||||
.arg(e->caretX())
|
||||
.arg(e->lineText().length())
|
||||
.arg(e->selText().length());
|
||||
.arg(e->selCount());
|
||||
} else {
|
||||
msg = tr("Line: %1/%2 Char: %3/%4")
|
||||
.arg(e->caretY())
|
||||
|
|
|
@ -4517,6 +4517,27 @@ QString QSynEdit::selText() const
|
|||
return "";
|
||||
}
|
||||
|
||||
int QSynEdit::selCount() const
|
||||
{
|
||||
if (!selAvail())
|
||||
return 0;
|
||||
if (mActiveSelectionMode == SelectionMode::Column)
|
||||
return selText().length();
|
||||
BufferCoord begin=blockBegin();
|
||||
BufferCoord end = blockEnd();
|
||||
if (begin.line == end.line)
|
||||
return (end.ch - begin.ch);
|
||||
int count = mDocument->getLine(begin.line-1).length()+1-begin.ch;
|
||||
int lineEndCount = lineBreak().length();
|
||||
count += lineEndCount;
|
||||
for (int i=begin.line;i<end.line-1;i++) {
|
||||
count += mDocument->getLine(i).length();
|
||||
count += lineEndCount;
|
||||
}
|
||||
count+= end.ch-1;
|
||||
return count;
|
||||
}
|
||||
|
||||
QStringList QSynEdit::getContent(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) const
|
||||
{
|
||||
QStringList result;
|
||||
|
|
|
@ -384,6 +384,7 @@ public:
|
|||
bool empty();
|
||||
|
||||
QString selText() const;
|
||||
int selCount() const;
|
||||
|
||||
QStringList getContent(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue