* move cursor horizontally ok
This commit is contained in:
parent
7f0ab217e8
commit
d4abd99a6c
File diff suppressed because it is too large
Load Diff
|
@ -142,10 +142,15 @@ public:
|
||||||
explicit SynEdit(QWidget *parent = nullptr);
|
explicit SynEdit(QWidget *parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief how many rows are there in the editor
|
* Returns how many rows are there in the editor
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int displayLineCount();
|
int displayLineCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief displayX
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
DisplayCoord displayXY();
|
DisplayCoord displayXY();
|
||||||
int displayX();
|
int displayX();
|
||||||
int displayY();
|
int displayY();
|
||||||
|
@ -192,6 +197,7 @@ public:
|
||||||
void showCaret();
|
void showCaret();
|
||||||
void hideCaret();
|
void hideCaret();
|
||||||
|
|
||||||
|
// setter && getters
|
||||||
int topLine() const;
|
int topLine() const;
|
||||||
void setTopLine(int value);
|
void setTopLine(int value);
|
||||||
|
|
||||||
|
@ -224,6 +230,15 @@ public:
|
||||||
|
|
||||||
int tabWidth() const;
|
int tabWidth() const;
|
||||||
|
|
||||||
|
PSynHighlighter highlighter() const;
|
||||||
|
void setHighlighter(const PSynHighlighter &highlighter);
|
||||||
|
|
||||||
|
bool useCodeFolding() const;
|
||||||
|
void setUseCodeFolding(bool value);
|
||||||
|
|
||||||
|
QString lineText();
|
||||||
|
void setLineText(const QString s);
|
||||||
|
|
||||||
PSynEditStringList lines() const;
|
PSynEditStringList lines() const;
|
||||||
bool empty();
|
bool empty();
|
||||||
|
|
||||||
|
@ -252,6 +267,8 @@ signals:
|
||||||
void fontChanged();
|
void fontChanged();
|
||||||
void tabSizeChanged();
|
void tabSizeChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool onGetSpecialLineColors(int Line,
|
virtual bool onGetSpecialLineColors(int Line,
|
||||||
QColor& foreground, QColor& backgroundColor) ;
|
QColor& foreground, QColor& backgroundColor) ;
|
||||||
|
@ -259,6 +276,9 @@ protected:
|
||||||
virtual void onGutterGetText(int aLine, QString& aText);
|
virtual void onGutterGetText(int aLine, QString& aText);
|
||||||
virtual void onGutterPaint(QPainter& painter, int aLine, int X, int Y);
|
virtual void onGutterPaint(QPainter& painter, int aLine, int X, int Y);
|
||||||
virtual void onPaint(QPainter& painter);
|
virtual void onPaint(QPainter& painter);
|
||||||
|
virtual void onProcessCommand(SynEditorCommand Command, QChar AChar, void * pData);
|
||||||
|
virtual void onCommandProcessed(SynEditorCommand Command, QChar AChar, void * pData);
|
||||||
|
virtual void ExecuteCommand(SynEditorCommand Command, QChar AChar, void * pData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearAreaList(SynEditingAreaList areaList);
|
void clearAreaList(SynEditingAreaList areaList);
|
||||||
|
@ -315,6 +335,18 @@ private:
|
||||||
PSynEditFoldRange foldEndAtLine(int Line);
|
PSynEditFoldRange foldEndAtLine(int Line);
|
||||||
void paintCaret(QPainter& painter, const QRect rcClip);
|
void paintCaret(QPainter& painter, const QRect rcClip);
|
||||||
int textOffset();
|
int textOffset();
|
||||||
|
SynEditorCommand TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers);
|
||||||
|
void CommandProcessor(SynEditorCommand Command, QChar AChar, void * pData);
|
||||||
|
/**
|
||||||
|
* Move the caret to right DX columns
|
||||||
|
* @param DX
|
||||||
|
* @param SelectionCommand
|
||||||
|
*/
|
||||||
|
void MoveCaretHorz(int DX, bool isSelection);
|
||||||
|
void MoveCaretAndSelection(const BufferCoord& ptBefore, const BufferCoord& ptAfter,
|
||||||
|
bool isSelection);
|
||||||
|
void MoveCaretToLineStart(bool isSelection);
|
||||||
|
void MoveCaretToLineEnd(bool isSelection);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void bookMarkOptionsChanged();
|
void bookMarkOptionsChanged();
|
||||||
|
@ -440,34 +472,19 @@ private:
|
||||||
int m_blinkStatus;
|
int m_blinkStatus;
|
||||||
|
|
||||||
|
|
||||||
// QWidget interface
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *event) override;
|
|
||||||
|
|
||||||
friend class SynEditTextPainter;
|
friend class SynEditTextPainter;
|
||||||
|
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
protected:
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
// QObject interface
|
|
||||||
protected:
|
|
||||||
void timerEvent(QTimerEvent *event) override;
|
void timerEvent(QTimerEvent *event) override;
|
||||||
|
|
||||||
// QObject interface
|
|
||||||
public:
|
|
||||||
bool event(QEvent *event) override;
|
bool event(QEvent *event) override;
|
||||||
|
|
||||||
// QWidget interface
|
|
||||||
PSynHighlighter highlighter() const;
|
|
||||||
void setHighlighter(const PSynHighlighter &highlighter);
|
|
||||||
|
|
||||||
bool useCodeFolding() const;
|
|
||||||
void setUseCodeFolding(bool value);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void focusInEvent(QFocusEvent *event) override;
|
void focusInEvent(QFocusEvent *event) override;
|
||||||
void focusOutEvent(QFocusEvent *event) override;
|
void focusOutEvent(QFocusEvent *event) override;
|
||||||
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SYNEDIT_H
|
#endif // SYNEDIT_H
|
||||||
|
|
|
@ -50,9 +50,7 @@ void SynEditTextPainter::paintTextLines(const QRect& clip)
|
||||||
rcToken.setRight(edit->mGutterWidth + 2);
|
rcToken.setRight(edit->mGutterWidth + 2);
|
||||||
// Paint whole left edge of the text with same color.
|
// Paint whole left edge of the text with same color.
|
||||||
// (value of WhiteAttribute can vary in e.g. MultiSyn)
|
// (value of WhiteAttribute can vary in e.g. MultiSyn)
|
||||||
painter->setPen(colEditorBG());
|
painter->fillRect(rcToken,colEditorBG());
|
||||||
painter->setBrush(colEditorBG());
|
|
||||||
painter->drawRect(rcToken);
|
|
||||||
// Adjust the invalid area to not include this area.
|
// Adjust the invalid area to not include this area.
|
||||||
AClip.setLeft(rcToken.right());
|
AClip.setLeft(rcToken.right());
|
||||||
}
|
}
|
||||||
|
@ -60,9 +58,7 @@ void SynEditTextPainter::paintTextLines(const QRect& clip)
|
||||||
rcToken = AClip;
|
rcToken = AClip;
|
||||||
rcToken.setTop((aLastRow - edit->mTopLine + 1) * edit->mTextHeight);
|
rcToken.setTop((aLastRow - edit->mTopLine + 1) * edit->mTextHeight);
|
||||||
if (rcToken.top() < rcToken.bottom()) {
|
if (rcToken.top() < rcToken.bottom()) {
|
||||||
painter->setPen(colEditorBG());
|
painter->fillRect(rcToken,colEditorBG());
|
||||||
painter->setBrush(colEditorBG());
|
|
||||||
painter->drawRect(rcToken);
|
|
||||||
// Draw the right edge if necessary.
|
// Draw the right edge if necessary.
|
||||||
if (bDoRightEdge) {
|
if (bDoRightEdge) {
|
||||||
QPen pen(edit->mRightEdgeColor,1);
|
QPen pen(edit->mRightEdgeColor,1);
|
||||||
|
@ -95,12 +91,9 @@ void SynEditTextPainter::paintGutter(const QRect& clip)
|
||||||
// the background first. Do it line by line with TextRect instead
|
// the background first. Do it line by line with TextRect instead
|
||||||
// and fill only the area after the last visible line.
|
// and fill only the area after the last visible line.
|
||||||
//painter->setClipRect(AClip);
|
//painter->setClipRect(AClip);
|
||||||
painter->setBrush(edit->mGutter.color());
|
painter->fillRect(AClip,edit->mGutter.color());
|
||||||
painter->setPen(edit->mGutter.color());
|
|
||||||
rcLine=AClip;
|
rcLine=AClip;
|
||||||
|
|
||||||
painter->drawRect(AClip);
|
|
||||||
|
|
||||||
if (edit->mGutter.showLineNumbers()) {
|
if (edit->mGutter.showLineNumbers()) {
|
||||||
// prepare the rect initially
|
// prepare the rect initially
|
||||||
rcLine = AClip;
|
rcLine = AClip;
|
||||||
|
@ -355,11 +348,7 @@ void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int Col
|
||||||
nX = ColumnToXValue(First);
|
nX = ColumnToXValue(First);
|
||||||
First -= ColumnsBefore;
|
First -= ColumnsBefore;
|
||||||
Last -= ColumnsBefore;
|
Last -= ColumnsBefore;
|
||||||
QPen oldPen = painter->pen();
|
painter->fillRect(rcToken,painter->brush());
|
||||||
QPen newPen(painter->brush().color());
|
|
||||||
painter->setPen(newPen);
|
|
||||||
painter->drawRect(rcToken);
|
|
||||||
painter->setPen(oldPen);
|
|
||||||
if (First > TokenCols) {
|
if (First > TokenCols) {
|
||||||
} else {
|
} else {
|
||||||
int tokenColLen=0;
|
int tokenColLen=0;
|
||||||
|
@ -520,30 +509,26 @@ void SynEditTextPainter::PaintHighlightToken(bool bFillToEOL)
|
||||||
rcToken.setRight(nX1);
|
rcToken.setRight(nX1);
|
||||||
// if (TokenAccu.Len != 0 && TokenAccu.Style != SynFontStyle::fsNone)
|
// if (TokenAccu.Len != 0 && TokenAccu.Style != SynFontStyle::fsNone)
|
||||||
// AdjustEndRect();
|
// AdjustEndRect();
|
||||||
painter->setPen(Qt::NoPen);
|
painter->fillRect(rcToken,painter->brush());
|
||||||
painter->drawRect(rcToken);
|
|
||||||
rcToken.setLeft(nX1);
|
rcToken.setLeft(nX1);
|
||||||
}
|
}
|
||||||
if (rcToken.left() < nX2) {
|
if (rcToken.left() < nX2) {
|
||||||
setDrawingColors(true);
|
setDrawingColors(true);
|
||||||
rcToken.setRight(nX2);
|
rcToken.setRight(nX2);
|
||||||
painter->setPen(Qt::NoPen);
|
painter->fillRect(rcToken,painter->brush());
|
||||||
painter->drawRect(rcToken);
|
|
||||||
rcToken.setLeft(nX2);
|
rcToken.setLeft(nX2);
|
||||||
}
|
}
|
||||||
if (rcToken.left() < rcLine.right()) {
|
if (rcToken.left() < rcLine.right()) {
|
||||||
setDrawingColors(false);
|
setDrawingColors(false);
|
||||||
rcToken.setRight(rcLine.right());
|
rcToken.setRight(rcLine.right());
|
||||||
painter->setPen(Qt::NoPen);
|
painter->fillRect(rcToken,painter->brush());
|
||||||
painter->drawRect(rcToken);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setDrawingColors(bLineSelected);
|
setDrawingColors(bLineSelected);
|
||||||
rcToken.setRight(rcLine.right());
|
rcToken.setRight(rcLine.right());
|
||||||
// if (TokenAccu.Len != 0 && TokenAccu.Style != SynFontStyle::fsNone)
|
// if (TokenAccu.Len != 0 && TokenAccu.Style != SynFontStyle::fsNone)
|
||||||
// AdjustEndRect();
|
// AdjustEndRect();
|
||||||
painter->setPen(painter->brush().color());
|
painter->fillRect(rcToken,painter->brush());
|
||||||
painter->drawRect(rcToken);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue