66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
#include "sciedit.h"
|
|
|
|
SciEdit::SciEdit(QWidget * parent)
|
|
: ScintillaEdit(parent)
|
|
{
|
|
connect(this, &ScintillaEditBase::updateUi, this, [this](){
|
|
int curPos = currentPos();
|
|
emit cursorPosChanged(lineFromPosition(curPos) + 1, column(curPos));
|
|
});
|
|
}
|
|
|
|
void SciEdit::setStyleFont(const QFont &font, int style)
|
|
{
|
|
styleSetFont(style, font.family().toUtf8().constData());
|
|
styleSetSizeFractional(0, long(font.pointSizeF() * SC_FONT_SIZE_MULTIPLIER));
|
|
}
|
|
|
|
void SciEdit::setFolding(FoldType foldType, int margin)
|
|
{
|
|
if (foldType == NoFoldType) {
|
|
setMarginWidthN(margin, 0L);
|
|
return;
|
|
}
|
|
|
|
int mask = modEventMask();
|
|
setModEventMask(mask | SC_MOD_CHANGEFOLD);
|
|
setFoldFlags(SC_FOLDFLAG_LINEAFTER_CONTRACTED);
|
|
setMarginTypeN(margin, SC_MARGIN_SYMBOL);
|
|
setMarginMaskN(margin, SC_MASK_FOLDERS);
|
|
setMarginSensitiveN(margin, 1);
|
|
|
|
setMarkerDefine(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS);
|
|
setMarkerDefine(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS);
|
|
setMarkerDefine(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE);
|
|
setMarkerDefine(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER);
|
|
setMarkerDefine(SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED);
|
|
setMarkerDefine(SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED);
|
|
setMarkerDefine(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER);
|
|
|
|
setMarginWidthN(margin, 14);
|
|
return;
|
|
}
|
|
|
|
void SciEdit::setLexer(Scintilla::ILexer5 *lexer)
|
|
{
|
|
setILexer((sptr_t)lexer);
|
|
|
|
qDebug() << lexer->GetName() << "lexer-------------";
|
|
}
|
|
|
|
void SciEdit::sendColor(unsigned int iMessage, uptr_t wParam, const QColor &color) const
|
|
{
|
|
sptr_t lParam = (color.blue() << 16) | (color.green() << 8) | color.red();
|
|
send(iMessage, wParam, lParam);
|
|
}
|
|
|
|
void SciEdit::setMarkerDefine(int markerNumber, int markerSymbol)
|
|
{
|
|
markerDefine(markerNumber, markerSymbol);
|
|
// necessary?
|
|
if (markerSymbol != SC_MARK_EMPTY) {
|
|
sendColor(SCI_MARKERSETFORE, markerNumber, QColor(Qt::white));
|
|
sendColor(SCI_MARKERSETBACK, markerNumber, QColor(128, 128, 128));
|
|
}
|
|
}
|