* work save
This commit is contained in:
parent
3076d01cb2
commit
bd95fccfa8
|
@ -66,7 +66,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mGutter.setRightOffset(21);
|
mGutter.setRightOffset(21);
|
||||||
mGutter.connect(&mGutter, &SynGutter::changed, this, &SynEdit::gutterChanged);
|
mGutter.connect(&mGutter, &SynGutter::changed, this, &SynEdit::gutterChanged);
|
||||||
mGutterWidth = mGutter.width();
|
mGutterWidth = mGutter.width();
|
||||||
mTextOffset = mGutterWidth + 2;
|
|
||||||
//ControlStyle := ControlStyle + [csOpaque, csSetCaption, csNeedsBorderPaint];
|
//ControlStyle := ControlStyle + [csOpaque, csSetCaption, csNeedsBorderPaint];
|
||||||
//Height := 150;
|
//Height := 150;
|
||||||
//Width := 200;
|
//Width := 200;
|
||||||
|
@ -114,7 +113,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mBlockBegin.Line = 1;
|
mBlockBegin.Line = 1;
|
||||||
mBlockEnd = mBlockBegin;
|
mBlockEnd = mBlockBegin;
|
||||||
mOptions = eoAutoIndent | eoDragDropEditing | eoEnhanceEndKey |
|
mOptions = eoAutoIndent | eoDragDropEditing | eoEnhanceEndKey |
|
||||||
eoScrollPastEol | eoShowScrollHint | eoSmartTabs | eoTabsToSpaces |
|
eoShowScrollHint | eoSmartTabs | eoTabsToSpaces |
|
||||||
eoSmartTabDelete| eoGroupUndo;
|
eoSmartTabDelete| eoGroupUndo;
|
||||||
qDebug()<<"init SynEdit: 9";
|
qDebug()<<"init SynEdit: 9";
|
||||||
|
|
||||||
|
@ -135,6 +134,11 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
qDebug()<<"init SynEdit: done";
|
qDebug()<<"init SynEdit: done";
|
||||||
|
|
||||||
showCaret();
|
showCaret();
|
||||||
|
|
||||||
|
connect(horizontalScrollBar(),&QScrollBar::valueChanged,
|
||||||
|
this, &SynEdit::doScrolled);
|
||||||
|
connect(verticalScrollBar(),&QScrollBar::valueChanged,
|
||||||
|
this, &SynEdit::doScrolled);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEdit::displayLineCount()
|
int SynEdit::displayLineCount()
|
||||||
|
@ -147,7 +151,6 @@ int SynEdit::displayLineCount()
|
||||||
|
|
||||||
DisplayCoord SynEdit::displayXY()
|
DisplayCoord SynEdit::displayXY()
|
||||||
{
|
{
|
||||||
qDebug()<<"displayXY"<<caretXY().Char<<caretXY().Line;
|
|
||||||
return bufferToDisplayPos(caretXY());
|
return bufferToDisplayPos(caretXY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,8 +216,7 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPos, BufferCoord value)
|
||||||
if (!mOptions.testFlag(SynEditorOption::eoScrollPastEol))
|
if (!mOptions.testFlag(SynEditorOption::eoScrollPastEol))
|
||||||
nMaxX = mLines->getString(value.Line-1).length();
|
nMaxX = mLines->getString(value.Line-1).length();
|
||||||
}
|
}
|
||||||
if ((value.Char > nMaxX) && (! (mOptions.testFlag(SynEditorOption::eoScrollPastEol)) ||
|
if ((value.Char > nMaxX) && (! (mOptions.testFlag(SynEditorOption::eoScrollPastEol)) ) )
|
||||||
!(mOptions.testFlag(SynEditorOption::eoAutoSizeMaxScrollWidth))) )
|
|
||||||
value.Char = nMaxX;
|
value.Char = nMaxX;
|
||||||
if (value.Char < 1)
|
if (value.Char < 1)
|
||||||
value.Char = 1;
|
value.Char = 1;
|
||||||
|
@ -361,7 +363,7 @@ DisplayCoord SynEdit::pixelsToRowColumn(int aX, int aY)
|
||||||
QPoint SynEdit::RowColumnToPixels(const DisplayCoord &coord)
|
QPoint SynEdit::RowColumnToPixels(const DisplayCoord &coord)
|
||||||
{
|
{
|
||||||
QPoint result;
|
QPoint result;
|
||||||
result.setX((coord.Column - 1) * mCharWidth + mTextOffset);
|
result.setX((coord.Column - 1) * mCharWidth + textOffset());
|
||||||
result.setY((coord.Row - mTopLine) * mTextHeight);
|
result.setY((coord.Row - mTopLine) * mTextHeight);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -374,7 +376,6 @@ QPoint SynEdit::RowColumnToPixels(const DisplayCoord &coord)
|
||||||
*/
|
*/
|
||||||
DisplayCoord SynEdit::bufferToDisplayPos(const BufferCoord &p)
|
DisplayCoord SynEdit::bufferToDisplayPos(const BufferCoord &p)
|
||||||
{
|
{
|
||||||
qDebug()<<"bufferTodisplayPos"<<p.Char<<p.Line;
|
|
||||||
DisplayCoord result {p.Char,p.Line};
|
DisplayCoord result {p.Char,p.Line};
|
||||||
// Account for tabs and charColumns
|
// Account for tabs and charColumns
|
||||||
result.Column = charToColumn(p.Line,p.Char);
|
result.Column = charToColumn(p.Line,p.Char);
|
||||||
|
@ -481,7 +482,6 @@ int SynEdit::rowToLine(int aRow)
|
||||||
|
|
||||||
int SynEdit::lineToRow(int aLine)
|
int SynEdit::lineToRow(int aLine)
|
||||||
{
|
{
|
||||||
qDebug()<<"line to row"<<aLine;
|
|
||||||
return bufferToDisplayPos({1, aLine}).Row;
|
return bufferToDisplayPos({1, aLine}).Row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,12 +902,12 @@ void SynEdit::ensureCursorPosVisibleEx(bool ForceToMiddle)
|
||||||
|
|
||||||
void SynEdit::scrollWindow(int dx, int dy)
|
void SynEdit::scrollWindow(int dx, int dy)
|
||||||
{
|
{
|
||||||
int nx = horizontalScrollBar()->value()+dx;
|
// int nx = horizontalScrollBar()->value()+dx;
|
||||||
int ny = verticalScrollBar()->value()+dy;
|
// int ny = verticalScrollBar()->value()+dy;
|
||||||
nx = std::min(std::max(horizontalScrollBar()->minimum(),nx),horizontalScrollBar()->maximum());
|
// nx = std::min(std::max(horizontalScrollBar()->minimum(),nx),horizontalScrollBar()->maximum());
|
||||||
ny = std::min(std::max(verticalScrollBar()->minimum(),ny),verticalScrollBar()->maximum());
|
// ny = std::min(std::max(verticalScrollBar()->minimum(),ny),verticalScrollBar()->maximum());
|
||||||
horizontalScrollBar()->setValue(nx);
|
// horizontalScrollBar()->setValue(nx);
|
||||||
verticalScrollBar()->setValue(ny);
|
// verticalScrollBar()->setValue(ny);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,6 +962,7 @@ void SynEdit::updateScrollbars()
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOn);
|
setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOn);
|
||||||
}
|
}
|
||||||
if (mScrollBars == SynScrollStyle::ssBoth || mScrollBars == SynScrollStyle::ssHorizontal) {
|
if (mScrollBars == SynScrollStyle::ssBoth || mScrollBars == SynScrollStyle::ssHorizontal) {
|
||||||
|
nMaxScroll = std::max(mLines->lengthOfLongestLine(), 1);
|
||||||
if (mOptions.testFlag(eoScrollPastEol))
|
if (mOptions.testFlag(eoScrollPastEol))
|
||||||
nMaxScroll = mMaxScrollWidth;
|
nMaxScroll = mMaxScrollWidth;
|
||||||
else
|
else
|
||||||
|
@ -1505,6 +1506,11 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SynEdit::textOffset()
|
||||||
|
{
|
||||||
|
return mGutterWidth + 2 - (mLeftChar-1)*mCharWidth;
|
||||||
|
}
|
||||||
|
|
||||||
void SynEdit::sizeOrFontChanged(bool bFont)
|
void SynEdit::sizeOrFontChanged(bool bFont)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1534,6 +1540,13 @@ void SynEdit::doChange()
|
||||||
emit Changed();
|
emit Changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SynEdit::doScrolled(int)
|
||||||
|
{
|
||||||
|
mLeftChar = horizontalScrollBar()->value();
|
||||||
|
mTopLine = verticalScrollBar()->value();
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
PSynEditStringList SynEdit::lines() const
|
PSynEditStringList SynEdit::lines() const
|
||||||
{
|
{
|
||||||
return mLines;
|
return mLines;
|
||||||
|
@ -1581,6 +1594,9 @@ void SynEdit::paintEvent(QPaintEvent *event)
|
||||||
if (mPainting)
|
if (mPainting)
|
||||||
return;
|
return;
|
||||||
mPainting = true;
|
mPainting = true;
|
||||||
|
auto action = finally([&,this] {
|
||||||
|
mPainting = false;
|
||||||
|
});
|
||||||
|
|
||||||
// Now paint everything while the caret is hidden.
|
// Now paint everything while the caret is hidden.
|
||||||
QPainter painter(viewport());
|
QPainter painter(viewport());
|
||||||
|
@ -1596,18 +1612,9 @@ void SynEdit::paintEvent(QPaintEvent *event)
|
||||||
QRect rcCaret(caretPos.x(),caretPos.y(),caretWidth,
|
QRect rcCaret(caretPos.x(),caretPos.y(),caretWidth,
|
||||||
mTextHeight);
|
mTextHeight);
|
||||||
|
|
||||||
qDebug()<<"Painting";
|
|
||||||
qDebug()<<"Caret rect:"<<rcCaret;
|
|
||||||
qDebug()<<"Clip rect:"<<rcClip;
|
|
||||||
|
|
||||||
auto action = finally([&,this] {
|
|
||||||
mPainting = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (rcCaret == rcClip) {
|
if (rcCaret == rcClip) {
|
||||||
// only update caret
|
// only update caret
|
||||||
// calculate the needed invalid area for caret
|
// calculate the needed invalid area for caret
|
||||||
//painter.drawImage(rcCaret,*mContentImage);
|
|
||||||
painter.drawImage(rcCaret,*mContentImage,rcCaret);
|
painter.drawImage(rcCaret,*mContentImage,rcCaret);
|
||||||
} else {
|
} else {
|
||||||
QRect rcDraw;
|
QRect rcDraw;
|
||||||
|
@ -1623,12 +1630,12 @@ void SynEdit::paintEvent(QPaintEvent *event)
|
||||||
nL1 = MinMax(mTopLine + rcClip.top() / mTextHeight, mTopLine, displayLineCount());
|
nL1 = MinMax(mTopLine + rcClip.top() / mTextHeight, mTopLine, displayLineCount());
|
||||||
nL2 = MinMax(mTopLine + (rcClip.bottom() + mTextHeight - 1) / mTextHeight, 1, displayLineCount());
|
nL2 = MinMax(mTopLine + (rcClip.bottom() + mTextHeight - 1) / mTextHeight, 1, displayLineCount());
|
||||||
|
|
||||||
|
qDebug()<<"Paint:"<<nL1<<nL2<<nC1<<nC2;
|
||||||
|
|
||||||
QPainter cachePainter(mContentImage.get());
|
QPainter cachePainter(mContentImage.get());
|
||||||
cachePainter.setFont(font());
|
cachePainter.setFont(font());
|
||||||
SynEditTextPainter textPainter(this, &cachePainter,
|
SynEditTextPainter textPainter(this, &cachePainter,
|
||||||
nL1,nL2,nC1,nC2);
|
nL1,nL2,nC1,nC2);
|
||||||
// SynEditTextPainter textPainter(this, &painter,
|
|
||||||
// nL1,nL2,nC1,nC2);
|
|
||||||
// First paint paint the text area if it was (partly) invalidated.
|
// First paint paint the text area if it was (partly) invalidated.
|
||||||
if (rcClip.right() > mGutterWidth ) {
|
if (rcClip.right() > mGutterWidth ) {
|
||||||
rcDraw = rcClip;
|
rcDraw = rcClip;
|
||||||
|
@ -1652,12 +1659,11 @@ void SynEdit::paintEvent(QPaintEvent *event)
|
||||||
paintCaret(painter, rcCaret);
|
paintCaret(painter, rcCaret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::resizeEvent(QResizeEvent *event)
|
void SynEdit::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
//resize the cache image
|
//resize the cache image
|
||||||
std::shared_ptr<QImage> image = std::make_shared<QImage>(clientWidth(),clientHeight(),
|
std::shared_ptr<QImage> image = std::make_shared<QImage>(clientWidth(),clientHeight(),
|
||||||
QImage::Format_ARGB32);
|
QImage::Format_ARGB32);
|
||||||
|
|
||||||
QRect newRect = image->rect().intersected(mContentImage->rect());
|
QRect newRect = image->rect().intersected(mContentImage->rect());
|
||||||
|
|
||||||
QPainter painter(image.get());
|
QPainter painter(image.get());
|
||||||
|
@ -1671,9 +1677,7 @@ void SynEdit::resizeEvent(QResizeEvent *event)
|
||||||
|
|
||||||
void SynEdit::timerEvent(QTimerEvent *event)
|
void SynEdit::timerEvent(QTimerEvent *event)
|
||||||
{
|
{
|
||||||
qDebug()<<"timer"<<event->timerId();
|
|
||||||
if (event->timerId() == m_blinkTimerId) {
|
if (event->timerId() == m_blinkTimerId) {
|
||||||
qDebug()<<"blink"<<m_blinkStatus;
|
|
||||||
m_blinkStatus = 1- m_blinkStatus;
|
m_blinkStatus = 1- m_blinkStatus;
|
||||||
DisplayCoord coord = displayXY();
|
DisplayCoord coord = displayXY();
|
||||||
QPoint caretPos = RowColumnToPixels(coord);
|
QPoint caretPos = RowColumnToPixels(coord);
|
||||||
|
@ -1697,6 +1701,16 @@ bool SynEdit::event(QEvent *event)
|
||||||
QAbstractScrollArea::event(event);
|
QAbstractScrollArea::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SynEdit::focusInEvent(QFocusEvent *)
|
||||||
|
{
|
||||||
|
showCaret();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SynEdit::focusOutEvent(QFocusEvent *)
|
||||||
|
{
|
||||||
|
hideCaret();
|
||||||
|
}
|
||||||
|
|
||||||
int SynEdit::maxScrollWidth() const
|
int SynEdit::maxScrollWidth() const
|
||||||
{
|
{
|
||||||
return mMaxScrollWidth;
|
return mMaxScrollWidth;
|
||||||
|
@ -1740,7 +1754,6 @@ void SynEdit::setGutterWidth(int Value)
|
||||||
Value = std::max(Value, 0);
|
Value = std::max(Value, 0);
|
||||||
if (mGutterWidth != Value) {
|
if (mGutterWidth != Value) {
|
||||||
mGutterWidth = Value;
|
mGutterWidth = Value;
|
||||||
mTextOffset = mGutterWidth + 2 - (mLeftChar - 1) * mCharWidth;
|
|
||||||
sizeOrFontChanged(false);
|
sizeOrFontChanged(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1824,11 +1837,6 @@ void SynEdit::linesInserted(int index, int count)
|
||||||
}
|
}
|
||||||
invalidateLines(index + 1, INT_MAX);
|
invalidateLines(index + 1, INT_MAX);
|
||||||
invalidateGutterLines(index + 1, INT_MAX);
|
invalidateGutterLines(index + 1, INT_MAX);
|
||||||
if (mOptions.setFlag(SynEditorOption::eoAutoSizeMaxScrollWidth)) {
|
|
||||||
int L = mLines->lineColumns(index);
|
|
||||||
if (L > mMaxScrollWidth)
|
|
||||||
setMaxScrollWidth(L);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::linesPutted(int index, int)
|
void SynEdit::linesPutted(int index, int)
|
||||||
|
@ -1842,12 +1850,6 @@ void SynEdit::linesPutted(int index, int)
|
||||||
vEndLine = INT_MAX;
|
vEndLine = INT_MAX;
|
||||||
}
|
}
|
||||||
invalidateLines(index + 1, vEndLine);
|
invalidateLines(index + 1, vEndLine);
|
||||||
|
|
||||||
if (mOptions.setFlag(SynEditorOption::eoAutoSizeMaxScrollWidth)) {
|
|
||||||
int L = mLines->lineColumns(index);
|
|
||||||
if (L > mMaxScrollWidth)
|
|
||||||
setMaxScrollWidth(L);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::undoAdded()
|
void SynEdit::undoAdded()
|
||||||
|
@ -1971,38 +1973,15 @@ int SynEdit::leftChar() const
|
||||||
void SynEdit::setLeftChar(int Value)
|
void SynEdit::setLeftChar(int Value)
|
||||||
{
|
{
|
||||||
int MaxVal;
|
int MaxVal;
|
||||||
int iDelta;
|
|
||||||
//QRect iTextArea;
|
//QRect iTextArea;
|
||||||
|
MaxVal = mLines->lengthOfLongestLine();
|
||||||
if (mOptions.testFlag(SynEditorOption::eoScrollPastEol)) {
|
if (mOptions.testFlag(SynEditorOption::eoScrollPastEol)) {
|
||||||
if (mOptions.testFlag(SynEditorOption::eoAutoSizeMaxScrollWidth))
|
Value = std::min(Value,MaxVal);
|
||||||
MaxVal = INT_MAX - mCharsInWindow;
|
|
||||||
else
|
|
||||||
MaxVal = mMaxScrollWidth - mCharsInWindow + 1;
|
|
||||||
} else {
|
} else {
|
||||||
MaxVal = mLines->lengthOfLongestLine();
|
Value = std::min(Value,MaxVal-mCharsInWindow+1);
|
||||||
if (MaxVal > mCharsInWindow)
|
|
||||||
MaxVal = MaxVal - mCharsInWindow + 1;
|
|
||||||
else
|
|
||||||
MaxVal = 1;
|
|
||||||
}
|
}
|
||||||
Value = MinMax(Value, 1, MaxVal);
|
|
||||||
if (Value != mLeftChar) {
|
if (Value != mLeftChar) {
|
||||||
iDelta = mLeftChar - Value;
|
horizontalScrollBar()->setValue(Value);
|
||||||
mLeftChar = Value;
|
|
||||||
mTextOffset = mGutterWidth + 2 - (mLeftChar - 1) * mCharWidth;
|
|
||||||
if (std::abs(iDelta) < mCharsInWindow) {
|
|
||||||
// iTextArea = clientRect();
|
|
||||||
// iTextArea.setLeft(iTextArea.left() + mGutterWidth + 2);
|
|
||||||
scrollWindow(iDelta * mCharWidth, 0);
|
|
||||||
} else {
|
|
||||||
invalidateLines(-1, -1);
|
|
||||||
}
|
|
||||||
if ( (mOptions & (SynEditorOption::eoAutoSizeMaxScrollWidth | SynEditorOption::eoScrollPastEol))
|
|
||||||
&&
|
|
||||||
(mMaxScrollWidth < mLeftChar + mCharsInWindow)) {
|
|
||||||
setMaxScrollWidth(mLeftChar + mCharsInWindow);
|
|
||||||
} else
|
|
||||||
updateScrollbars();
|
|
||||||
setStatusChanged(SynStatusChange::scLeftChar);
|
setStatusChanged(SynStatusChange::scLeftChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2026,16 +2005,8 @@ void SynEdit::setTopLine(int Value)
|
||||||
Value = std::min(Value, displayLineCount() - mLinesInWindow + 1);
|
Value = std::min(Value, displayLineCount() - mLinesInWindow + 1);
|
||||||
Value = std::max(Value, 1);
|
Value = std::max(Value, 1);
|
||||||
if (Value != mTopLine) {
|
if (Value != mTopLine) {
|
||||||
int Delta = mTopLine - Value;
|
//updateScrollbars();
|
||||||
mTopLine = Value;
|
verticalScrollBar()->setValue(Value);
|
||||||
if (mPainterLock == 0) {
|
|
||||||
if (std::abs(Delta) < mLinesInWindow) {
|
|
||||||
scrollWindow(0, mTextHeight * Delta);
|
|
||||||
} else {
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateScrollbars();
|
|
||||||
setStatusChanged(SynStatusChange::scTopLine);
|
setStatusChanged(SynStatusChange::scTopLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ enum SynEditorOption {
|
||||||
eoAltSetsColumnMode = 0x00000001, //Holding down the Alt Key will put the selection mode into columnar format
|
eoAltSetsColumnMode = 0x00000001, //Holding down the Alt Key will put the selection mode into columnar format
|
||||||
eoAutoIndent = 0x00000002, //Will indent the caret on new lines with the same amount of leading white space as the preceding line
|
eoAutoIndent = 0x00000002, //Will indent the caret on new lines with the same amount of leading white space as the preceding line
|
||||||
eoAddIndent = 0x00000004, //Will add one tab width of indent when typing { and :, and remove the same amount when typing }
|
eoAddIndent = 0x00000004, //Will add one tab width of indent when typing { and :, and remove the same amount when typing }
|
||||||
eoAutoSizeMaxScrollWidth = 0x00000008, //Automatically resizes the MaxScrollWidth property when inserting text
|
//eoAutoSizeMaxScrollWidth = 0x00000008, //Automatically resizes the MaxScrollWidth property when inserting text
|
||||||
//eoDisableScrollArrows = 0x00000010 , //Disables the scroll bar arrow buttons when you can't scroll in that direction any more
|
//eoDisableScrollArrows = 0x00000010 , //Disables the scroll bar arrow buttons when you can't scroll in that direction any more
|
||||||
eoDragDropEditing = 0x00000020, //Allows you to select a block of text and drag it within the document to another location
|
eoDragDropEditing = 0x00000020, //Allows you to select a block of text and drag it within the document to another location
|
||||||
eoDropFiles = 0x00000040, //Allows the editor accept OLE file drops
|
eoDropFiles = 0x00000040, //Allows the editor accept OLE file drops
|
||||||
|
@ -260,9 +260,6 @@ protected:
|
||||||
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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearAreaList(SynEditingAreaList areaList);
|
void clearAreaList(SynEditingAreaList areaList);
|
||||||
void computeCaret(int X, int Y);
|
void computeCaret(int X, int Y);
|
||||||
|
@ -316,6 +313,7 @@ private:
|
||||||
PSynEditFoldRange checkFoldRange(SynEditFoldRanges* FoldRangeToCheck,int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine);
|
PSynEditFoldRange checkFoldRange(SynEditFoldRanges* FoldRangeToCheck,int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine);
|
||||||
PSynEditFoldRange foldEndAtLine(int Line);
|
PSynEditFoldRange foldEndAtLine(int Line);
|
||||||
void paintCaret(QPainter& painter, const QRect rcClip);
|
void paintCaret(QPainter& painter, const QRect rcClip);
|
||||||
|
int textOffset();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void bookMarkOptionsChanged();
|
void bookMarkOptionsChanged();
|
||||||
|
@ -331,6 +329,7 @@ private slots:
|
||||||
void undoAdded();
|
void undoAdded();
|
||||||
void sizeOrFontChanged(bool bFont);
|
void sizeOrFontChanged(bool bFont);
|
||||||
void doChange();
|
void doChange();
|
||||||
|
void doScrolled(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QImage> mContentImage;
|
std::shared_ptr<QImage> mContentImage;
|
||||||
|
@ -369,7 +368,6 @@ private:
|
||||||
SynScrollHintFormat mScrollHintFormat;
|
SynScrollHintFormat mScrollHintFormat;
|
||||||
SynScrollStyle mScrollBars;
|
SynScrollStyle mScrollBars;
|
||||||
int mTextHeight;
|
int mTextHeight;
|
||||||
int mTextOffset;
|
|
||||||
int mTopLine;
|
int mTopLine;
|
||||||
PSynHighlighter mHighlighter;
|
PSynHighlighter mHighlighter;
|
||||||
QColor mSelectedForeground;
|
QColor mSelectedForeground;
|
||||||
|
@ -458,6 +456,11 @@ void timerEvent(QTimerEvent *event) override;
|
||||||
// QObject interface
|
// QObject interface
|
||||||
public:
|
public:
|
||||||
bool event(QEvent *event) override;
|
bool event(QEvent *event) override;
|
||||||
|
|
||||||
|
// QWidget interface
|
||||||
|
protected:
|
||||||
|
void focusInEvent(QFocusEvent *event) override;
|
||||||
|
void focusOutEvent(QFocusEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SYNEDIT_H
|
#endif // SYNEDIT_H
|
||||||
|
|
|
@ -25,7 +25,7 @@ void SynEditTextPainter::paintTextLines(const QRect& clip)
|
||||||
QString SynTabGlyphString = SynTabGlyph;
|
QString SynTabGlyphString = SynTabGlyph;
|
||||||
bDoRightEdge = false;
|
bDoRightEdge = false;
|
||||||
if (edit->mRightEdge > 0) { // column value
|
if (edit->mRightEdge > 0) { // column value
|
||||||
nRightEdge = edit->mTextOffset + edit->mRightEdge * edit->mCharWidth; // pixel value
|
nRightEdge = edit->textOffset()+ edit->mRightEdge * edit->mCharWidth; // pixel value
|
||||||
if (nRightEdge >= AClip.left() &&nRightEdge <= AClip.right()) {
|
if (nRightEdge >= AClip.left() &&nRightEdge <= AClip.right()) {
|
||||||
bDoRightEdge = true;
|
bDoRightEdge = true;
|
||||||
QPen pen(edit->mRightEdgeColor,1);
|
QPen pen(edit->mRightEdgeColor,1);
|
||||||
|
@ -344,7 +344,7 @@ void SynEditTextPainter::setDrawingColors(bool Selected)
|
||||||
|
|
||||||
int SynEditTextPainter::ColumnToXValue(int Col)
|
int SynEditTextPainter::ColumnToXValue(int Col)
|
||||||
{
|
{
|
||||||
return edit->mTextOffset + (Col - 1) * edit->mCharWidth;
|
return edit->textOffset() + (Col - 1) * edit->mCharWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int ColumnsBefore, int First, int Last, bool)
|
void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int ColumnsBefore, int First, int Last, bool)
|
||||||
|
@ -358,7 +358,7 @@ void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int Col
|
||||||
Last -= ColumnsBefore;
|
Last -= ColumnsBefore;
|
||||||
if (First > TokenCols) {
|
if (First > TokenCols) {
|
||||||
} else {
|
} else {
|
||||||
qDebug()<<"token clip rect:"<<rcToken << Token;
|
qDebug()<<"token clip rect:"<<rcToken << Token << First << Last;
|
||||||
// painter->setClipRect(rcToken);
|
// painter->setClipRect(rcToken);
|
||||||
int tokenColLen=0;
|
int tokenColLen=0;
|
||||||
startPaint = false;
|
startPaint = false;
|
||||||
|
@ -381,10 +381,12 @@ void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int Col
|
||||||
startPaint = true;
|
startPaint = true;
|
||||||
}
|
}
|
||||||
//painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent()*edit->dpiFactor() , Token[i]);
|
//painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent()*edit->dpiFactor() , Token[i]);
|
||||||
painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent() , Token[i]);
|
if (startPaint) {
|
||||||
|
painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent() , Token[i]);
|
||||||
|
nX += charCols * edit->mCharWidth;
|
||||||
|
}
|
||||||
|
|
||||||
tokenColLen += charCols;
|
tokenColLen += charCols;
|
||||||
nX += charCols * edit->mCharWidth;
|
|
||||||
if (tokenColLen > Last)
|
if (tokenColLen > Last)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -664,7 +666,7 @@ void SynEditTextPainter::PaintFoldAttributes()
|
||||||
// Step horizontal coord
|
// Step horizontal coord
|
||||||
TabSteps = edit->mTabWidth;
|
TabSteps = edit->mTabWidth;
|
||||||
while (TabSteps < LineIndent) {
|
while (TabSteps < LineIndent) {
|
||||||
X = TabSteps * edit->mCharWidth + edit->mTextOffset - 2;
|
X = TabSteps * edit->mCharWidth + edit->textOffset() - 2;
|
||||||
TabSteps+=edit->mTabWidth;
|
TabSteps+=edit->mTabWidth;
|
||||||
|
|
||||||
// Move to top of vertical line
|
// Move to top of vertical line
|
||||||
|
|
Loading…
Reference in New Issue