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->caretY())
|
||||||
.arg(e->document()->count())
|
.arg(e->document()->count())
|
||||||
.arg(col)
|
.arg(col)
|
||||||
.arg(e->selText().length());
|
.arg(e->selCount());
|
||||||
} else {
|
} else {
|
||||||
msg = tr("Line: %1/%2 Col: %3")
|
msg = tr("Line: %1/%2 Col: %3")
|
||||||
.arg(e->caretY())
|
.arg(e->caretY())
|
||||||
|
@ -1531,7 +1531,7 @@ void MainWindow::updateStatusbarForLineCol(const Editor* e, bool clear)
|
||||||
.arg(e->document()->count())
|
.arg(e->document()->count())
|
||||||
.arg(e->caretX())
|
.arg(e->caretX())
|
||||||
.arg(e->lineText().length())
|
.arg(e->lineText().length())
|
||||||
.arg(e->selText().length());
|
.arg(e->selCount());
|
||||||
} else {
|
} else {
|
||||||
msg = tr("Line: %1/%2 Char: %3/%4")
|
msg = tr("Line: %1/%2 Char: %3/%4")
|
||||||
.arg(e->caretY())
|
.arg(e->caretY())
|
||||||
|
|
|
@ -4517,6 +4517,27 @@ QString QSynEdit::selText() const
|
||||||
return "";
|
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 QSynEdit::getContent(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) const
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
|
@ -384,6 +384,7 @@ public:
|
||||||
bool empty();
|
bool empty();
|
||||||
|
|
||||||
QString selText() const;
|
QString selText() const;
|
||||||
|
int selCount() const;
|
||||||
|
|
||||||
QStringList getContent(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) const;
|
QStringList getContent(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue