code format
This commit is contained in:
@@ -1,23 +1,25 @@
|
||||
#include "qcodeedit.h"
|
||||
#include "ui_qcodeedit.h"
|
||||
#include "qcodeedit_completer_p.h"
|
||||
|
||||
#include "ecombobox.h"
|
||||
#include "qad_types.h"
|
||||
#include "iconedlabel.h"
|
||||
#include <QLayout>
|
||||
#include "qad_types.h"
|
||||
#include "qcodeedit_completer_p.h"
|
||||
#include "ui_qcodeedit.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QBoxLayout>
|
||||
#include <QScrollBar>
|
||||
#include <QDesktopServices>
|
||||
#include <QLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QPainter>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QScrollBar>
|
||||
#include <QTextBlock>
|
||||
#include <QTextCursor>
|
||||
#include <QTextDocument>
|
||||
#include <QTextDocumentFragment>
|
||||
#include <QTextOption>
|
||||
#include <QTextCursor>
|
||||
#include <QTextBlock>
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QDesktopServices>
|
||||
#include <QPainter>
|
||||
#include <QPlainTextEdit>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
# include <QWindow>
|
||||
#endif
|
||||
@@ -39,21 +41,20 @@ public:
|
||||
}
|
||||
|
||||
QCodeEdit * ce;
|
||||
|
||||
};
|
||||
|
||||
|
||||
QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent), ui(new Ui::QCodeEdit) {
|
||||
overlay = nullptr;
|
||||
prev_lc = auto_comp_pl = cur_search_ind = pos_press = pos_el_press = -1;
|
||||
timer_parse = 0;
|
||||
timer_parse = 0;
|
||||
_ignore_focus_out = _destructor = _replacing = cursor_state = block_sel_state = false;
|
||||
_first = true;
|
||||
comment_text = "//";
|
||||
_first = true;
|
||||
comment_text = "//";
|
||||
qRegisterMetaType<QTextCursor>();
|
||||
qRegisterMetaType<QCodeEdit::ACEntry>();
|
||||
ui->setupUi(this);
|
||||
overlay = new _QCE_Viewport(ui->textCode->viewport());
|
||||
overlay = new _QCE_Viewport(ui->textCode->viewport());
|
||||
overlay->ce = this;
|
||||
overlay->show();
|
||||
ui->widgetSearch->hide();
|
||||
@@ -86,7 +87,7 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent), ui(new Ui::QCodeEdit) {
|
||||
lbl_help[lhF1]->setIcon(QIcon(":/icons/f1.png"));
|
||||
lbl_help[lhF1]->setText(tr("Press F1 for details"));
|
||||
help_visible = true;
|
||||
completer = new QCodeEditCompleter();
|
||||
completer = new QCodeEditCompleter();
|
||||
|
||||
cursor_width = qMax<int>(qRound(fontHeight(this) / 10.), 1);
|
||||
ui->textCode->setCursorWidth(0);
|
||||
@@ -98,28 +99,34 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent), ui(new Ui::QCodeEdit) {
|
||||
#else
|
||||
ui->textLines->setFixedWidth(ui->textLines->fontMetrics().width(" "));
|
||||
#endif
|
||||
|
||||
QAction * a = new QAction(this); ui->textCode->addAction(a);
|
||||
|
||||
QAction * a = new QAction(this);
|
||||
ui->textCode->addAction(a);
|
||||
a->setShortcut(QKeySequence("Shift+Tab"));
|
||||
a->setShortcutContext(Qt::WidgetShortcut);
|
||||
connect(a, SIGNAL(triggered()), this, SLOT(deindent()));
|
||||
a = new QAction(this); ui->textCode->addAction(a);
|
||||
a = new QAction(this);
|
||||
ui->textCode->addAction(a);
|
||||
a->setShortcut(QKeySequence("Ctrl+D"));
|
||||
a->setShortcutContext(Qt::WidgetShortcut);
|
||||
connect(a, SIGNAL(triggered()), this, SLOT(deleteLine()));
|
||||
a = new QAction(this); ui->textCode->addAction(a);
|
||||
a = new QAction(this);
|
||||
ui->textCode->addAction(a);
|
||||
a->setShortcut(QKeySequence("Ctrl+Return"));
|
||||
a->setShortcutContext(Qt::WidgetShortcut);
|
||||
connect(a, SIGNAL(triggered()), this, SLOT(newLine()));
|
||||
a = new QAction(this); ui->textCode->addAction(a);
|
||||
a = new QAction(this);
|
||||
ui->textCode->addAction(a);
|
||||
a->setShortcut(QKeySequence("Ctrl+Up"));
|
||||
a->setShortcutContext(Qt::WidgetShortcut);
|
||||
connect(a, SIGNAL(triggered()), this, SLOT(scrollUp()));
|
||||
a = new QAction(this); ui->textCode->addAction(a);
|
||||
a = new QAction(this);
|
||||
ui->textCode->addAction(a);
|
||||
a->setShortcut(QKeySequence("Ctrl+Down"));
|
||||
a->setShortcutContext(Qt::WidgetShortcut);
|
||||
connect(a, SIGNAL(triggered()), this, SLOT(scrollDown()));
|
||||
a = new QAction(this); ui->textCode->addAction(a);
|
||||
a = new QAction(this);
|
||||
ui->textCode->addAction(a);
|
||||
a->setShortcut(QKeySequence("Ctrl+Shift+Return"));
|
||||
a->setShortcutContext(Qt::WidgetShortcut);
|
||||
connect(a, SIGNAL(triggered()), this, SLOT(newLineBefore()));
|
||||
@@ -135,7 +142,7 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent), ui(new Ui::QCodeEdit) {
|
||||
connect(a, SIGNAL(triggered(bool)), this, SLOT(search_triggered()));
|
||||
addAction(a);
|
||||
|
||||
connect(completer, SIGNAL(itemDoubleClicked(QTreeWidgetItem * ,int)), this, SLOT(commitCompletition()));
|
||||
connect(completer, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(commitCompletition()));
|
||||
connect(completer, SIGNAL(commit()), this, SLOT(commitCompletition()));
|
||||
connect(completer, SIGNAL(gotoHRef(QCodeEdit::ACEntry)), this, SLOT(gotoHelpHRef(QCodeEdit::ACEntry)));
|
||||
connect(ui->textCode->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->textLines->verticalScrollBar(), SLOT(setValue(int)));
|
||||
@@ -150,7 +157,12 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent), ui(new Ui::QCodeEdit) {
|
||||
connect(ui->comboSearch->lineEdit(), SIGNAL(returnPressed()), this, SLOT(searchNext()));
|
||||
connect(ui->comboReplace->lineEdit(), SIGNAL(returnPressed()), this, SLOT(on_buttonReplaceSearch_clicked()));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
connect(qApp, &QGuiApplication::focusWindowChanged, this, [this](QWindow*w){if (w == nullptr) {hideHelp(); completer->hide();}});
|
||||
connect(qApp, &QGuiApplication::focusWindowChanged, this, [this](QWindow * w) {
|
||||
if (w == nullptr) {
|
||||
hideHelp();
|
||||
completer->hide();
|
||||
}
|
||||
});
|
||||
#endif
|
||||
updateLines();
|
||||
timer_blink = startTimer(QApplication::cursorFlashTime() / 2);
|
||||
@@ -191,8 +203,7 @@ void QCodeEdit::setDocument(QTextDocument * doc) {
|
||||
documentChanged(nullptr);
|
||||
return;
|
||||
}
|
||||
if (!qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()))
|
||||
doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
|
||||
if (!qobject_cast<QPlainTextDocumentLayout *>(doc->documentLayout())) doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
|
||||
ui->textCode->setDocument(doc);
|
||||
cursor_width = qMax<int>(qRound(fontHeight(this) / 10.), 1);
|
||||
ui->textCode->setCursorWidth(0);
|
||||
@@ -303,14 +314,26 @@ void QCodeEdit::registerAutoCompletitionClass(int id, QCodeEdit::ACClassType ac_
|
||||
|
||||
|
||||
int QCodeEdit::skipRange(const QString & s, int pos, QChar oc, QChar cc, QChar sc) {
|
||||
int cnt = 0;
|
||||
int cnt = 0;
|
||||
bool skip = false;
|
||||
for (int i = pos - 1; i >= 0; --i) {
|
||||
QChar c = s[i];
|
||||
if (skip) {skip = false; continue;}
|
||||
if (c == sc) {skip = true; continue;}
|
||||
if (c == cc) {cnt++; continue;}
|
||||
if (c == oc) {cnt--; if (cnt == 0) return i;}
|
||||
if (skip) {
|
||||
skip = false;
|
||||
continue;
|
||||
}
|
||||
if (c == sc) {
|
||||
skip = true;
|
||||
continue;
|
||||
}
|
||||
if (c == cc) {
|
||||
cnt++;
|
||||
continue;
|
||||
}
|
||||
if (c == oc) {
|
||||
cnt--;
|
||||
if (cnt == 0) return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -320,7 +343,7 @@ int QCodeEdit::skipCWord(const QString & s, int pos) {
|
||||
QChar pc(0), c(0);
|
||||
for (int i = pos - 1; i >= 0; --i) {
|
||||
pc = c;
|
||||
c = s[i];
|
||||
c = s[i];
|
||||
if (c.isLetterOrNumber() || (c.toLatin1() == '_')) continue;
|
||||
if (pc.isLetter() || (pc.toLatin1() == '_')) return i + 1;
|
||||
return -1;
|
||||
@@ -339,8 +362,15 @@ bool QCodeEdit::matchWritten(QString s, QString w) {
|
||||
bool ns = false, bl = true;
|
||||
while (sp < s.size()) {
|
||||
if (ns || s[sp].toLatin1() == '_') {
|
||||
if (s[sp].toLatin1() == '_') {sp++; bl = false; continue;}
|
||||
if (s[sp].isLower() && bl) {sp++; continue;}
|
||||
if (s[sp].toLatin1() == '_') {
|
||||
sp++;
|
||||
bl = false;
|
||||
continue;
|
||||
}
|
||||
if (s[sp].isLower() && bl) {
|
||||
sp++;
|
||||
continue;
|
||||
}
|
||||
if (s[sp].toLower() != wc) return false;
|
||||
}
|
||||
if (s[sp].toLower() == wc) break;
|
||||
@@ -384,7 +414,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
if (!isEnabled()) {
|
||||
break;
|
||||
}
|
||||
tc = ui->textCode->cursorForPosition(static_cast<QMouseEvent*>(e)->pos());
|
||||
tc = ui->textCode->cursorForPosition(static_cast<QMouseEvent *>(e)->pos());
|
||||
tc.movePosition(QTextCursor::EndOfLine);
|
||||
pos_el_press = tc.anchor();
|
||||
tc.movePosition(QTextCursor::StartOfLine);
|
||||
@@ -397,7 +427,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
return true;
|
||||
case QEvent::MouseMove:
|
||||
if (!isEnabled()) break;
|
||||
tc = ui->textCode->cursorForPosition(static_cast<QMouseEvent*>(e)->pos());
|
||||
tc = ui->textCode->cursorForPosition(static_cast<QMouseEvent *>(e)->pos());
|
||||
tc.movePosition(QTextCursor::StartOfLine);
|
||||
if (pos_press == tc.anchor()) {
|
||||
if (!tc.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor)) {
|
||||
@@ -425,16 +455,15 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
}
|
||||
}
|
||||
if (o == completer) {
|
||||
//qDebug() << o << e;
|
||||
if (e->type() == QEvent::WindowActivate)
|
||||
_ignore_focus_out = true;
|
||||
//qDebug() << e;
|
||||
// qDebug() << o << e;
|
||||
if (e->type() == QEvent::WindowActivate) _ignore_focus_out = true;
|
||||
// qDebug() << e;
|
||||
return QWidget::eventFilter(o, e);
|
||||
}
|
||||
if (o == ui->comboSearch || o == ui->comboReplace) {
|
||||
//qDebug() << o << e;
|
||||
// qDebug() << o << e;
|
||||
if (e->type() == QEvent::KeyPress) {
|
||||
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape) {
|
||||
if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Escape) {
|
||||
hideHelp();
|
||||
if (completer->isVisible())
|
||||
completer->hide();
|
||||
@@ -442,7 +471,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
hideSearch();
|
||||
}
|
||||
}
|
||||
//qDebug() << e;
|
||||
// qDebug() << e;
|
||||
return QWidget::eventFilter(o, e);
|
||||
}
|
||||
if (ui->textCode) {
|
||||
@@ -452,75 +481,62 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
cancelBlockSelection();
|
||||
completer->hide();
|
||||
hideHelp();
|
||||
auto me = static_cast<QMouseEvent*>(e);
|
||||
auto me = static_cast<QMouseEvent *>(e);
|
||||
if (me->modifiers().testFlag(Qt::ControlModifier) && (me->button() == Qt::LeftButton))
|
||||
if (!hasBlockSelection() && !ui->textCode->textCursor().hasSelection())
|
||||
gotoLink();
|
||||
} break;
|
||||
if (!hasBlockSelection() && !ui->textCode->textCursor().hasSelection()) gotoLink();
|
||||
} break;
|
||||
case QEvent::MouseMove: {
|
||||
if (!completer->isHidden()) break;
|
||||
auto me = static_cast<QMouseEvent*>(e);
|
||||
if (me->buttons() != 0)
|
||||
switchBlockSelection();
|
||||
auto me = static_cast<QMouseEvent *>(e);
|
||||
if (me->buttons() != 0) switchBlockSelection();
|
||||
if (me->modifiers().testFlag(Qt::ControlModifier))
|
||||
if (!hasBlockSelection() && !ui->textCode->textCursor().hasSelection())
|
||||
showLink();
|
||||
} break;
|
||||
case QEvent::Paint:
|
||||
resizeOverlay();
|
||||
break;
|
||||
if (!hasBlockSelection() && !ui->textCode->textCursor().hasSelection()) showLink();
|
||||
} break;
|
||||
case QEvent::Paint: resizeOverlay(); break;
|
||||
case QEvent::DragMove:
|
||||
if (!isEnabled()) break;
|
||||
drag_cursor = ui->textCode->cursorForPosition(
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
static_cast<QDragMoveEvent*>(e)->pos()
|
||||
static_cast<QDragMoveEvent *>(e)->pos()
|
||||
#else
|
||||
static_cast<QDragMoveEvent*>(e)->position().toPoint()
|
||||
static_cast<QDragMoveEvent *>(e)->position().toPoint()
|
||||
#endif
|
||||
);
|
||||
);
|
||||
repaintCursor();
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::DragLeave:
|
||||
case QEvent::Drop:
|
||||
cancelDragCursor();
|
||||
break;
|
||||
case QEvent::Drop: cancelDragCursor(); break;
|
||||
default: break;
|
||||
}
|
||||
return QWidget::eventFilter(o, e);
|
||||
}
|
||||
if (o == ui->textCode) {
|
||||
//qDebug() << e;
|
||||
// qDebug() << e;
|
||||
QMetaObject::invokeMethod(this, "syncScrolls", Qt::QueuedConnection);
|
||||
switch (e->type()) {
|
||||
case QEvent::ToolTip:
|
||||
if (completer->isHidden()) {
|
||||
QTextCursor tc = ui->textCode->cursorForPosition(static_cast<QHelpEvent*>(e)->pos());
|
||||
QTextCursor tc = ui->textCode->cursorForPosition(static_cast<QHelpEvent *>(e)->pos());
|
||||
tc.select(QTextCursor::WordUnderCursor);
|
||||
raiseHelp(tc);
|
||||
}
|
||||
break;
|
||||
case QEvent::KeyPress:
|
||||
//qDebug() << "key" << ke;
|
||||
if (codeKeyEvent(static_cast<QKeyEvent*>(e)))
|
||||
return true;
|
||||
break;
|
||||
case QEvent::KeyRelease:
|
||||
hideLink();
|
||||
// qDebug() << "key" << ke;
|
||||
if (codeKeyEvent(static_cast<QKeyEvent *>(e))) return true;
|
||||
break;
|
||||
case QEvent::KeyRelease: hideLink(); break;
|
||||
case QEvent::FocusOut:
|
||||
if (_ignore_focus_out) {
|
||||
_ignore_focus_out = false;
|
||||
break;
|
||||
}
|
||||
case QEvent::FocusIn:
|
||||
createBlockSelection();
|
||||
break;
|
||||
case QEvent::FocusIn: createBlockSelection(); break;
|
||||
case QEvent::Hide:
|
||||
case QEvent::HideToParent:
|
||||
hideLink();
|
||||
case QEvent::HideToParent: hideLink();
|
||||
case QEvent::MouseButtonPress:
|
||||
//qDebug() << e;
|
||||
// qDebug() << e;
|
||||
completer->hide();
|
||||
hideHelp();
|
||||
default: break;
|
||||
@@ -531,7 +547,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
}
|
||||
|
||||
|
||||
void QCodeEdit::showEvent(QShowEvent * ) {
|
||||
void QCodeEdit::showEvent(QShowEvent *) {
|
||||
if (!_first) return;
|
||||
_first = false;
|
||||
completer->installEventFilter(this);
|
||||
@@ -564,12 +580,11 @@ void QCodeEdit::leaveEvent(QEvent * e) {
|
||||
void QCodeEdit::changeEvent(QEvent * e) {
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
lbl_help[lhF1]->setText(tr("Press F1 for details"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
lbl_help[lhF1]->setText(tr("Press F1 for details"));
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,7 +722,8 @@ bool QCodeEdit::codeKeyEvent(QKeyEvent * ke) {
|
||||
default: break;
|
||||
}
|
||||
if (!ke->text().isEmpty()) {
|
||||
if (hasBlockSelection() && (ke->modifiers() == 0 || ke->modifiers() == Qt::ShiftModifier || ke->modifiers() == Qt::KeypadModifier)) {
|
||||
if (hasBlockSelection() &&
|
||||
(ke->modifiers() == 0 || ke->modifiers() == Qt::ShiftModifier || ke->modifiers() == Qt::KeypadModifier)) {
|
||||
insertBlockSelection(ke->text());
|
||||
return true;
|
||||
}
|
||||
@@ -728,9 +744,9 @@ bool QCodeEdit::codeKeyEvent(QKeyEvent * ke) {
|
||||
void QCodeEdit::toggleComment() {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
tc.beginEditBlock();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
QString st_ = tc.selection().toPlainText();
|
||||
if (st_.endsWith("\n")) {
|
||||
st_.chop(1);
|
||||
@@ -741,7 +757,7 @@ void QCodeEdit::toggleComment() {
|
||||
tc.movePosition(QTextCursor::StartOfLine);
|
||||
ss = tc.position();
|
||||
tc.setPosition(se);
|
||||
tc.movePosition(QTextCursor::EndOfLine );
|
||||
tc.movePosition(QTextCursor::EndOfLine);
|
||||
se = tc.position();
|
||||
tc.setPosition(ss);
|
||||
bool need_comment = false;
|
||||
@@ -754,7 +770,7 @@ void QCodeEdit::toggleComment() {
|
||||
comms[line] = true;
|
||||
} else {
|
||||
need_comment = true;
|
||||
comms[line] = false;
|
||||
comms[line] = false;
|
||||
}
|
||||
} else {
|
||||
comms[line] = false;
|
||||
@@ -816,25 +832,25 @@ void QCodeEdit::highlightBrackets() {
|
||||
QTextEdit::ExtraSelection es;
|
||||
stc.setPosition(stc.position());
|
||||
QTextCursor::MoveOperation mop[2] = {QTextCursor::Left, QTextCursor::Right};
|
||||
QString mbr[2] = {")]}>", "([{<"};
|
||||
QString mbr[2] = {")]}>", "([{<"};
|
||||
for (int d = 0; d < 2; ++d) {
|
||||
tc = stc;
|
||||
tc.movePosition(mop[d], QTextCursor::KeepAnchor);
|
||||
if (!tc.selectedText().isEmpty()) {
|
||||
char ch = tc.selectedText()[0].toLatin1();
|
||||
if (mbr[d].contains(ch)) {
|
||||
es = es_bracket;
|
||||
es = es_bracket;
|
||||
es.cursor = tc;
|
||||
es_brackets << es;
|
||||
QTextCursor ftc = tc;
|
||||
int bcnt = 1;
|
||||
char fch = antiBracket(ch);
|
||||
int bcnt = 1;
|
||||
char fch = antiBracket(ch);
|
||||
while (bcnt > 0) {
|
||||
ftc.setPosition(ftc.position());
|
||||
if (!ftc.movePosition(mop[d], QTextCursor::KeepAnchor)) break;
|
||||
//qDebug() << tc.selectedText();
|
||||
// qDebug() << tc.selectedText();
|
||||
if (ftc.selectedText().isEmpty()) break;
|
||||
if (ftc.selectedText()[0].toLatin1() == ch) ++bcnt;
|
||||
if (ftc.selectedText()[0].toLatin1() == ch) ++bcnt;
|
||||
if (ftc.selectedText()[0].toLatin1() == fch) --bcnt;
|
||||
}
|
||||
if (bcnt == 0) {
|
||||
@@ -853,9 +869,8 @@ void QCodeEdit::highlightBrackets() {
|
||||
|
||||
|
||||
void QCodeEdit::applyExtraSelection() {
|
||||
ui->textCode->setExtraSelections(QList<QTextEdit::ExtraSelection>() << es_line << es_selected
|
||||
<< es_custom << es_brackets << es_search_list << es_cursor
|
||||
<< es_link << es_blockselection);
|
||||
ui->textCode->setExtraSelections(QList<QTextEdit::ExtraSelection>() << es_line << es_selected << es_custom << es_brackets
|
||||
<< es_search_list << es_cursor << es_link << es_blockselection);
|
||||
}
|
||||
|
||||
|
||||
@@ -911,20 +926,20 @@ QRect QCodeEdit::blockSelectionRect() {
|
||||
QPoint ps(block_start_cursor.positionInBlock(), block_start_cursor.blockNumber());
|
||||
QPoint pe(tc.positionInBlock(), tc.blockNumber());
|
||||
return (ui->textCode->cursorRect(tc) | ui->textCode->cursorRect(block_start_cursor))
|
||||
.translated(ui->textCode->horizontalScrollBar()->value(), 0);
|
||||
.translated(ui->textCode->horizontalScrollBar()->value(), 0);
|
||||
}
|
||||
|
||||
|
||||
QVector<QTextCursor> QCodeEdit::blockSelectionCursors(QRect bsr) {
|
||||
QVector<QTextCursor> ret;
|
||||
//qDebug() << bsr;
|
||||
// qDebug() << bsr;
|
||||
int sline = ui->textCode->cursorForPosition(bsr.topLeft()).blockNumber();
|
||||
int eline = ui->textCode->cursorForPosition(bsr.bottomRight()).blockNumber();
|
||||
for (int l = sline; l <= eline; ++l) {
|
||||
QTextCursor stc(ui->textCode->document()->findBlockByNumber(l)), etc;
|
||||
QRect stc_rect = ui->textCode->cursorRect(stc);
|
||||
stc = ui->textCode->cursorForPosition(stc_rect.center() + QPoint(bsr.left() , 0));
|
||||
etc = ui->textCode->cursorForPosition(stc_rect.center() + QPoint(bsr.right(), 0));
|
||||
stc = ui->textCode->cursorForPosition(stc_rect.center() + QPoint(bsr.left(), 0));
|
||||
etc = ui->textCode->cursorForPosition(stc_rect.center() + QPoint(bsr.right(), 0));
|
||||
stc.setPosition(etc.position(), QTextCursor::KeepAnchor);
|
||||
ret << stc;
|
||||
}
|
||||
@@ -941,8 +956,8 @@ void QCodeEdit::drawCursor() {
|
||||
if (!isEnabled() || !ui->textCode->hasFocus()) return;
|
||||
QPainter p(overlay);
|
||||
QTextCursor tc = textCursor();
|
||||
//qDebug() << block_start_cursor.position() << tc.position();
|
||||
QRect line = cursorRect();
|
||||
// qDebug() << block_start_cursor.position() << tc.position();
|
||||
QRect line = cursorRect();
|
||||
if (cursor_state && ui->textCode->hasFocus()) {
|
||||
line.adjust(0, 1, 0, -1);
|
||||
p.setCompositionMode(QPainter::CompositionMode_Difference);
|
||||
@@ -964,7 +979,7 @@ bool QCodeEdit::hasBlockSelection() const {
|
||||
|
||||
void QCodeEdit::startBlockSelection() {
|
||||
if (!hasBlockSelection()) {
|
||||
QTextCursor tc = textCursor();
|
||||
QTextCursor tc = textCursor();
|
||||
block_start_cursor = tc;
|
||||
block_start_cursor.setPosition(tc.selectionStart());
|
||||
}
|
||||
@@ -985,16 +1000,16 @@ void QCodeEdit::switchBlockSelection(QKeyEvent * ke) {
|
||||
}
|
||||
if (alt) {
|
||||
startBlockSelection();
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
QTextCursor::MoveOperation op = QTextCursor::NoMove;
|
||||
if (!ke) {
|
||||
return;
|
||||
}
|
||||
switch (ke->key()) {
|
||||
case Qt::Key_Left : op = QTextCursor::Left ; break;
|
||||
case Qt::Key_Left: op = QTextCursor::Left; break;
|
||||
case Qt::Key_Right: op = QTextCursor::Right; break;
|
||||
case Qt::Key_Up : op = QTextCursor::Up ; break;
|
||||
case Qt::Key_Down : op = QTextCursor::Down ; break;
|
||||
case Qt::Key_Up: op = QTextCursor::Up; break;
|
||||
case Qt::Key_Down: op = QTextCursor::Down; break;
|
||||
default: break;
|
||||
}
|
||||
if (op != QTextCursor::NoMove) {
|
||||
@@ -1013,7 +1028,7 @@ bool QCodeEdit::removeBlockSelection(bool is_del) {
|
||||
return false;
|
||||
}
|
||||
QRect bsr = blockSelectionRect();
|
||||
bool del = false;
|
||||
bool del = false;
|
||||
bool back = false;
|
||||
if (bsr.width() <= 1) {
|
||||
if (is_del) {
|
||||
@@ -1023,19 +1038,19 @@ bool QCodeEdit::removeBlockSelection(bool is_del) {
|
||||
}
|
||||
}
|
||||
QVector<QTextCursor> clist = blockSelectionCursors(bsr);
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
tc.beginEditBlock();
|
||||
int bspx = ui->textCode->cursorRect(block_start_cursor).center().x();
|
||||
int bspx = ui->textCode->cursorRect(block_start_cursor).center().x();
|
||||
int nullw = ui->textCode->fontMetrics().
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
horizontalAdvance
|
||||
horizontalAdvance
|
||||
#else
|
||||
width
|
||||
width
|
||||
#endif
|
||||
(" ");
|
||||
(" ");
|
||||
int min_dist = nullw / 2;
|
||||
int new_pos = -1;
|
||||
for (QTextCursor & c : clist) {
|
||||
int new_pos = -1;
|
||||
for (QTextCursor & c: clist) {
|
||||
if (del || back) {
|
||||
if (qAbs(bspx - ui->textCode->cursorRect(c).center().x()) > min_dist) {
|
||||
continue;
|
||||
@@ -1045,7 +1060,7 @@ bool QCodeEdit::removeBlockSelection(bool is_del) {
|
||||
if (line != c.blockNumber()) {
|
||||
continue;
|
||||
}
|
||||
//qDebug() << qAbs(bspx - ui->textCode->cursorRect(c).center().x()) << min_dist;
|
||||
// qDebug() << qAbs(bspx - ui->textCode->cursorRect(c).center().x()) << min_dist;
|
||||
}
|
||||
c.removeSelectedText();
|
||||
if (c.blockNumber() == tc.blockNumber()) {
|
||||
@@ -1064,24 +1079,24 @@ void QCodeEdit::insertBlockSelection(QString text) {
|
||||
return;
|
||||
}
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
QRect bsr = blockSelectionRect();
|
||||
//qDebug() << "___" << bsr;
|
||||
int scrl = ui->textCode->horizontalScrollBar()->value();
|
||||
QRect bsr = blockSelectionRect();
|
||||
// qDebug() << "___" << bsr;
|
||||
int scrl = ui->textCode->horizontalScrollBar()->value();
|
||||
if (bsr.width() > 1) {
|
||||
removeBlockSelection(false);
|
||||
bsr = blockSelectionRect();
|
||||
//qDebug() << "del" << bsr;
|
||||
// qDebug() << "del" << bsr;
|
||||
}
|
||||
tc.beginEditBlock();
|
||||
int nullw = ui->textCode->fontMetrics().
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
horizontalAdvance
|
||||
horizontalAdvance
|
||||
#else
|
||||
width
|
||||
width
|
||||
#endif
|
||||
(" ");
|
||||
(" ");
|
||||
QVector<QTextCursor> clist = blockSelectionCursors(bsr);
|
||||
for (QTextCursor & c : clist) {
|
||||
for (QTextCursor & c: clist) {
|
||||
c.removeSelectedText();
|
||||
int spcnt = (bsr.left() - ui->textCode->cursorRect(c).center().x() - scrl) / nullw;
|
||||
if (spcnt > 0) {
|
||||
@@ -1102,7 +1117,7 @@ void QCodeEdit::createBlockSelection() {
|
||||
es.format.setForeground(palette().brush(QPalette::HighlightedText));
|
||||
es.format.setBackground(palette().brush(QPalette::Highlight));
|
||||
QVector<QTextCursor> clist = blockSelectionCursors(blockSelectionRect());
|
||||
for (QTextCursor & c : clist) {
|
||||
for (QTextCursor & c: clist) {
|
||||
es.cursor = c;
|
||||
es_blockselection << es;
|
||||
}
|
||||
@@ -1145,7 +1160,7 @@ void QCodeEdit::searchAll() {
|
||||
|
||||
void QCodeEdit::search_triggered() {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
QString st = tc.selectedText();
|
||||
QString st = tc.selectedText();
|
||||
if (st.isEmpty()) {
|
||||
tc.select(QTextCursor::WordUnderCursor);
|
||||
st = tc.selectedText();
|
||||
@@ -1159,7 +1174,8 @@ void QCodeEdit::search_triggered() {
|
||||
|
||||
void QCodeEdit::syncScrolls() {
|
||||
ui->textLines->verticalScrollBar()->setValue(ui->textCode->verticalScrollBar()->value());
|
||||
ui->textLines->setHorizontalScrollBarPolicy(ui->textCode->horizontalScrollBar()->isVisible() ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
|
||||
ui->textLines->setHorizontalScrollBarPolicy(ui->textCode->horizontalScrollBar()->isVisible() ? Qt::ScrollBarAlwaysOn
|
||||
: Qt::ScrollBarAlwaysOff);
|
||||
}
|
||||
|
||||
|
||||
@@ -1196,9 +1212,9 @@ void QCodeEdit::deleteLine() {
|
||||
void QCodeEdit::copyLineUp() {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
tc.beginEditBlock();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
QString st_ = tc.selection().toPlainText();
|
||||
if (st_.endsWith("\n")) {
|
||||
st_.chop(1);
|
||||
@@ -1237,9 +1253,9 @@ void QCodeEdit::copyLineUp() {
|
||||
void QCodeEdit::copyLineDown() {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
tc.beginEditBlock();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
QString st_ = tc.selection().toPlainText();
|
||||
if (st_.endsWith("\n")) {
|
||||
st_.chop(1);
|
||||
@@ -1281,10 +1297,10 @@ void QCodeEdit::copyLineDown() {
|
||||
|
||||
void QCodeEdit::moveLineUp() {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
QString st_ = tc.selection().toPlainText();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
QString st_ = tc.selection().toPlainText();
|
||||
if (st_.endsWith("\n")) {
|
||||
st_.chop(1);
|
||||
se--;
|
||||
@@ -1333,10 +1349,10 @@ void QCodeEdit::moveLineUp() {
|
||||
|
||||
void QCodeEdit::moveLineDown() {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
QString st_ = tc.selection().toPlainText();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
QString st_ = tc.selection().toPlainText();
|
||||
if (st_.endsWith("\n")) {
|
||||
st_.chop(1);
|
||||
se--;
|
||||
@@ -1387,9 +1403,9 @@ void QCodeEdit::moveLineDown() {
|
||||
void QCodeEdit::indent() {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
tc.beginEditBlock();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
QString st_ = tc.selection().toPlainText();
|
||||
if (st_.endsWith("\n")) {
|
||||
st_.chop(1);
|
||||
@@ -1421,9 +1437,9 @@ void QCodeEdit::indent() {
|
||||
void QCodeEdit::deindent() {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
tc.beginEditBlock();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
int ss = tc.selectionStart();
|
||||
int ss_ = ss;
|
||||
int se = tc.selectionEnd();
|
||||
QString st_ = tc.selection().toPlainText();
|
||||
if (st_.endsWith("\n")) {
|
||||
st_.chop(1);
|
||||
@@ -1461,8 +1477,7 @@ void QCodeEdit::deindent() {
|
||||
}
|
||||
se_ -= rs;
|
||||
tc.movePosition(QTextCursor::StartOfLine);
|
||||
if (!tc.movePosition(QTextCursor::Down))
|
||||
break;
|
||||
if (!tc.movePosition(QTextCursor::Down)) break;
|
||||
}
|
||||
tc.setPosition(ss_);
|
||||
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
||||
@@ -1472,7 +1487,7 @@ void QCodeEdit::deindent() {
|
||||
|
||||
|
||||
void QCodeEdit::autoIndent() {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
QTextCursor stc = tc;
|
||||
tc.movePosition(QTextCursor::StartOfLine);
|
||||
if (!tc.movePosition(QTextCursor::Up)) {
|
||||
@@ -1517,7 +1532,7 @@ void QCodeEdit::showLink() {
|
||||
es_link.cursor = tc;
|
||||
overlay->setCursor(tc.isNull() ? Qt::IBeamCursor : Qt::PointingHandCursor);
|
||||
applyExtraSelection();
|
||||
//qDebug() << "showLink" << tc.selectedText() << link_entry.type << link_entry.name;
|
||||
// qDebug() << "showLink" << tc.selectedText() << link_entry.type << link_entry.name;
|
||||
}
|
||||
|
||||
|
||||
@@ -1526,7 +1541,7 @@ void QCodeEdit::hideLink() {
|
||||
overlay->setCursor(Qt::IBeamCursor);
|
||||
link_entry = ACEntry();
|
||||
applyExtraSelection();
|
||||
//qDebug() << "hideLink";
|
||||
// qDebug() << "hideLink";
|
||||
}
|
||||
|
||||
|
||||
@@ -1619,7 +1634,7 @@ QString QCodeEdit::selectArg(QString s, int arg) {
|
||||
s.chop(1);
|
||||
}
|
||||
QStringList al = s.split(",");
|
||||
QString ret = ss + "(";
|
||||
QString ret = ss + "(";
|
||||
for (int i = 0; i < al.size(); ++i) {
|
||||
if (i > 0) {
|
||||
ret += ", ";
|
||||
@@ -1638,7 +1653,7 @@ QString QCodeEdit::selectArg(QString s, int arg) {
|
||||
|
||||
|
||||
QCodeEdit::ACEntry QCodeEdit::findEntryOnCursor(QTextCursor tc, int arg, ACClass * acc, QPair<QStringList, QString> * scope) {
|
||||
bool ok = false;
|
||||
bool ok = false;
|
||||
QPair<QStringList, QString> sc = getScope(tc, &ok);
|
||||
if (scope) {
|
||||
*scope = sc;
|
||||
@@ -1652,10 +1667,10 @@ QCodeEdit::ACEntry QCodeEdit::findEntryOnCursor(QTextCursor tc, int arg, ACClass
|
||||
}
|
||||
ok = false;
|
||||
ACList acl(autoCompletitionList(sc.first, sc.second));
|
||||
for (const ACSection & i : acl) {
|
||||
for (const ACEntry & s : i.second) {
|
||||
for (const ACSection & i: acl) {
|
||||
for (const ACEntry & s: i.second) {
|
||||
QString ts = s.name;
|
||||
//qDebug() << ts << st;
|
||||
// qDebug() << ts << st;
|
||||
if (ts != st) {
|
||||
if (ts.startsWith(st)) {
|
||||
ts.remove(0, st.size());
|
||||
@@ -1669,7 +1684,7 @@ QCodeEdit::ACEntry QCodeEdit::findEntryOnCursor(QTextCursor tc, int arg, ACClass
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//qDebug() << s.second << st;
|
||||
// qDebug() << s.second << st;
|
||||
if (acc) {
|
||||
*acc = ac_classes.value(i.first);
|
||||
}
|
||||
@@ -1696,10 +1711,10 @@ void QCodeEdit::raiseHelp(QTextCursor tc, int arg) {
|
||||
}
|
||||
lbl_help[lhHint]->setText(hint);
|
||||
lbl_help[lhHint]->setHidden(hint.isEmpty());
|
||||
//qDebug() << "help found" << tc.selectionStart() << tc.selectionEnd();
|
||||
// qDebug() << "help found" << tc.selectionStart() << tc.selectionEnd();
|
||||
es_cursor.cursor = tc;
|
||||
applyExtraSelection();
|
||||
//tc.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
|
||||
// tc.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
|
||||
lbl_help[lhMain]->setFont(font());
|
||||
lbl_help[lhF1]->setVisible(!e.help_href.isEmpty() && help_visible);
|
||||
qApp->processEvents();
|
||||
@@ -1715,14 +1730,14 @@ void QCodeEdit::raiseHelp(QTextCursor tc, int arg) {
|
||||
QPoint whp;
|
||||
whp.setX(whr.left() - whr.width() - (widget_help->width() - whr.width()) / 2);
|
||||
whp.setY(whr.top() - widget_help->height() - (fontHeight(this) / 3));
|
||||
//qDebug() << whr << whp << widget_help->width() << ", " << st;
|
||||
// qDebug() << whr << whp << widget_help->width() << ", " << st;
|
||||
widget_help->move(ui->textCode->viewport()->mapToGlobal(whp));
|
||||
widget_help->show();
|
||||
widget_help->raise();
|
||||
help_entry = e;
|
||||
help_entry = e;
|
||||
cursor_scope = scope.first;
|
||||
cursor_scope << scope.second;
|
||||
//qDebug() << "tooltip" << st;
|
||||
// qDebug() << "tooltip" << st;
|
||||
}
|
||||
|
||||
|
||||
@@ -1774,7 +1789,7 @@ QTextCursor QCodeEdit::functionStart(QTextCursor tc, int * arg) {
|
||||
}
|
||||
QTextCursor ret(ui->textCode->document());
|
||||
ret.setPosition(i);
|
||||
//qDebug() << "found" << i << a;
|
||||
// qDebug() << "found" << i << a;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1801,7 +1816,7 @@ QCodeEdit::ACList QCodeEdit::wordsCompletitionList(const QString & written) cons
|
||||
acwl.removeDuplicates();
|
||||
ACSection acl;
|
||||
acl.first = -1;
|
||||
for (const QString & s : acwl) {
|
||||
for (const QString & s: acwl) {
|
||||
acl.second << ACEntry("", s);
|
||||
}
|
||||
ret << acl;
|
||||
@@ -1831,14 +1846,14 @@ QPair<QStringList, QString> QCodeEdit::getScope(QTextCursor tc, bool * ok) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
QString doc = ui->textCode->toPlainText();
|
||||
QString doc = ui->textCode->toPlainText();
|
||||
auto_comp_pl = line;
|
||||
completer->clear();
|
||||
int spos = tc.position(), cpos = spos;
|
||||
tc.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
|
||||
QStringList scope;
|
||||
QString written = tc.selectedText().trimmed();
|
||||
//qDebug() << "\n*** invokeAutoCompletition ***";
|
||||
// qDebug() << "\n*** invokeAutoCompletition ***";
|
||||
if (written != "_" && !written.leftJustified(1)[0].isLetterOrNumber()) {
|
||||
written.clear();
|
||||
} else {
|
||||
@@ -1849,13 +1864,13 @@ QPair<QStringList, QString> QCodeEdit::getScope(QTextCursor tc, bool * ok) {
|
||||
}
|
||||
while (cpos >= 0) {
|
||||
cpos--;
|
||||
//qDebug() << "char =" << doc.mid(cpos, 1);
|
||||
// qDebug() << "char =" << doc.mid(cpos, 1);
|
||||
if (doc.mid(cpos, 1) != ".") break;
|
||||
QChar c = doc.mid(cpos - 1, 1).leftJustified(1)[0];
|
||||
QChar c = doc.mid(cpos - 1, 1).leftJustified(1)[0];
|
||||
int ppos = cpos;
|
||||
if (c == '\"' || c == ')' || c == ']') {
|
||||
cpos = skipRange(doc, cpos, pairChar(c), c, '\\');
|
||||
//qDebug() << "range" << cpos;
|
||||
// qDebug() << "range" << cpos;
|
||||
if (cpos < 0) break;
|
||||
}
|
||||
int npos = skipCWord(doc, cpos);
|
||||
@@ -1863,7 +1878,7 @@ QPair<QStringList, QString> QCodeEdit::getScope(QTextCursor tc, bool * ok) {
|
||||
scope.push_front(doc.mid(npos, ppos - npos));
|
||||
cpos = npos;
|
||||
}
|
||||
ret.first = scope;
|
||||
ret.first = scope;
|
||||
ret.second = written;
|
||||
if (ok) *ok = true;
|
||||
return ret;
|
||||
@@ -1871,17 +1886,17 @@ QPair<QStringList, QString> QCodeEdit::getScope(QTextCursor tc, bool * ok) {
|
||||
|
||||
|
||||
void QCodeEdit::invokeAutoCompletition(bool force) {
|
||||
int arg = -1;
|
||||
int arg = -1;
|
||||
QTextCursor htc = functionStart(ui->textCode->textCursor(), &arg);
|
||||
if (!htc.isNull()) {
|
||||
//qDebug() << "raise";
|
||||
// qDebug() << "raise";
|
||||
raiseHelp(htc, arg);
|
||||
}
|
||||
bool ok;
|
||||
QPair<QStringList, QString> scope = getScope(ui->textCode->textCursor(), &ok);
|
||||
if (!ok) return;
|
||||
ACList acl(autoCompletitionList(scope.first, scope.second));
|
||||
//qDebug() << written << scope << acl.size();
|
||||
// qDebug() << written << scope << acl.size();
|
||||
if (scope.first.isEmpty() && scope.second.isEmpty() && !force) {
|
||||
completer->hide();
|
||||
hideHelp();
|
||||
@@ -1892,7 +1907,7 @@ void QCodeEdit::invokeAutoCompletition(bool force) {
|
||||
}
|
||||
QFont bf(font());
|
||||
bf.setBold(true);
|
||||
foreach (const ACSection & ac, acl) {
|
||||
foreach(const ACSection & ac, acl) {
|
||||
if (ac.second.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -1970,7 +1985,7 @@ void QCodeEdit::commitCompletition() {
|
||||
|
||||
void QCodeEdit::textEdit_cursorPositionChanged() {
|
||||
es_line.cursor = ui->textCode->textCursor();
|
||||
//qDebug() << "cursorPositionChanged" << es_line.cursor.position();
|
||||
// qDebug() << "cursorPositionChanged" << es_line.cursor.position();
|
||||
es_line.cursor.select(QTextCursor::LineUnderCursor);
|
||||
es_line.cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
||||
highlightBrackets();
|
||||
@@ -1978,7 +1993,7 @@ void QCodeEdit::textEdit_cursorPositionChanged() {
|
||||
if (timer_blink) {
|
||||
killTimer(timer_blink);
|
||||
}
|
||||
timer_blink = startTimer(QApplication::cursorFlashTime() / 2);
|
||||
timer_blink = startTimer(QApplication::cursorFlashTime() / 2);
|
||||
cursor_state = true;
|
||||
createBlockSelection();
|
||||
}
|
||||
@@ -1996,8 +2011,8 @@ void QCodeEdit::textEdit_textChanged() {
|
||||
void QCodeEdit::textEdit_selectionChanged() {
|
||||
if (hasBlockSelection()) {
|
||||
QTextCursor tc = ui->textCode->textCursor();
|
||||
//qDebug() << block_start_cursor.selectionStart() << tc.selectionEnd();
|
||||
bool bs = ui->textCode->blockSignals(true);
|
||||
// qDebug() << block_start_cursor.selectionStart() << tc.selectionEnd();
|
||||
bool bs = ui->textCode->blockSignals(true);
|
||||
tc.clearSelection();
|
||||
ui->textCode->setTextCursor(tc);
|
||||
ui->textCode->blockSignals(bs);
|
||||
@@ -2032,8 +2047,8 @@ void QCodeEdit::textEdit_redoAvailable(bool available) {
|
||||
|
||||
|
||||
void QCodeEdit::setShowSpaces(bool yes) {
|
||||
spaces_ = yes;
|
||||
QTextOption to = ui->textCode->document()->defaultTextOption();
|
||||
spaces_ = yes;
|
||||
QTextOption to = ui->textCode->document()->defaultTextOption();
|
||||
QTextOption::Flags tof = to.flags();
|
||||
if (yes) {
|
||||
tof |= QTextOption::ShowTabsAndSpaces;
|
||||
@@ -2122,8 +2137,6 @@ void QCodeEdit::on_buttonReplaceAll_clicked() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QString QCodeEdit::ACEntry::declaration() const {
|
||||
if (declaration_pos < 0 || declaration_file.isEmpty()) {
|
||||
return QString();
|
||||
|
||||
Reference in New Issue
Block a user