Skip to content

Commit

Permalink
GUI: Fix editor line focus with wrapped lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdupak committed Nov 29, 2023
1 parent 3cc293b commit 5342412
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/gui/windows/editor/srceditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ bool SrcEditor::saveFile(QString filename) {
}

void SrcEditor::setCursorToLine(int ln) {
QTextCursor cursor(document()->findBlockByLineNumber(ln - 1));
QTextCursor cursor(document()->findBlockByNumber(ln - 1));
setTextCursor(cursor);
}

void SrcEditor::setCursorTo(int ln, int col) {
QTextCursor cursor(document()->findBlockByLineNumber(ln - 1));
QTextCursor cursor(document()->findBlockByNumber(ln - 1));
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, col - 1);
setTextCursor(cursor);
}
Expand Down Expand Up @@ -267,24 +267,14 @@ void SrcEditor::updateLineNumberArea(const QRect &rect, int dy) {

if (rect.contains(viewport()->rect())) updateMargins(0);
}

void SrcEditor::resizeEvent(QResizeEvent *event) {
QPlainTextEdit::resizeEvent(event);

QRect cr = contentsRect();
line_number_area->setGeometry(
QRect(cr.left(), cr.top(), line_number_area->sizeHint().width(), cr.height()));
}

void SrcEditor::setShowLineNumbers(bool show) {
line_number_area->set(show);
updateMargins(0);
}

void SrcEditor::insertFromMimeData(const QMimeData *source) {
if (source->hasText()) { insertPlainText(source->text()); }
}

bool SrcEditor::canInsertFromMimeData(const QMimeData *source) const {
return source->hasText();
}

0 comments on commit 5342412

Please sign in to comment.