- fix: when editor font is too small, fold signs on the gutter are not correctly displayed

- fix: expand fold signs on the gutter are not correct
This commit is contained in:
Roy Qu 2022-03-20 20:56:21 +08:00
parent 8a911314e1
commit 947374b907
3 changed files with 11 additions and 60 deletions

View File

@ -9,6 +9,8 @@ Red Panda C++ Version 1.0.1
- change: ctrl+click symbol will goto definition, instead of got declaration - change: ctrl+click symbol will goto definition, instead of got declaration
- fix: when size of undo items is greater than the limit, old items should be poped in group - fix: when size of undo items is greater than the limit, old items should be poped in group
- enhancement: max undo size in option dialog's editor->misc tab - enhancement: max undo size in option dialog's editor->misc tab
- fix: when editor font is too small, fold signs on the gutter are not correctly displayed
- fix: expand fold signs on the gutter are not correct
Red Panda C++ Version 1.0.0 Red Panda C++ Version 1.0.0
- fix: calculation for code snippets's tab stop positions is not correct - fix: calculation for code snippets's tab stop positions is not correct

View File

@ -267,7 +267,9 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value)
int oldCaretY = mCaretY; int oldCaretY = mCaretY;
mCaretY = value.Line; mCaretY = value.Line;
invalidateLine(mCaretY); invalidateLine(mCaretY);
invalidateGutterLine(mCaretY);
invalidateLine(oldCaretY); invalidateLine(oldCaretY);
invalidateGutterLine(oldCaretY);
mStatusChanges.setFlag(SynStatusChange::scCaretY); mStatusChanges.setFlag(SynStatusChange::scCaretY);
} }
// Call UpdateLastCaretX before DecPaintLock because the event handler it // Call UpdateLastCaretX before DecPaintLock because the event handler it

View File

@ -154,18 +154,18 @@ void SynEditTextPainter::paintGutter(const QRect& clip)
// Draw the folding lines and squares // Draw the folding lines and squares
if (edit->mUseCodeFolding) { if (edit->mUseCodeFolding) {
for (cRow = aFirstRow; cRow<=aLastRow; cRow++) { for (cRow = aLastRow; cRow>=aFirstRow; cRow--) {
vLine = edit->rowToLine(cRow); vLine = edit->rowToLine(cRow);
if ((vLine > edit->mLines->count()) && (edit->mLines->count() != 0)) if ((vLine > edit->mLines->count()) && (edit->mLines->count() != 0))
break; continue;
// Form a rectangle for the square the user can click on // Form a rectangle for the square the user can click on
//rcFold.Left := Gutter.RealGutterWidth(CharWidth) - Gutter.RightOffset;
rcFold.setLeft(edit->mGutterWidth - edit->mGutter.rightOffset()); rcFold.setLeft(edit->mGutterWidth - edit->mGutter.rightOffset());
rcFold.setRight(rcFold.left() + edit->mGutter.rightOffset() - 4);
rcFold.setTop((cRow - edit->mTopLine) * edit->mTextHeight); rcFold.setTop((cRow - edit->mTopLine) * edit->mTextHeight);
rcFold.setRight(rcFold.left() + edit->mGutter.rightOffset() - 4);
rcFold.setBottom(rcFold.top() + edit->mTextHeight); rcFold.setBottom(rcFold.top() + edit->mTextHeight);
painter->setPen(edit->mCodeFolding.folderBarLinesColor); painter->setPen(edit->mCodeFolding.folderBarLinesColor);
@ -213,69 +213,16 @@ void SynEditTextPainter::paintGutter(const QRect& clip)
if (FoldRange->collapsed) { if (FoldRange->collapsed) {
x = rcFold.left() + (rcFold.width() / 2); x = rcFold.left() + (rcFold.width() / 2);
painter->drawLine(x, rcFold.top() + 2, painter->drawLine(x, rcFold.top() + 2,
x, rcFold.bottom() + 2); x, rcFold.bottom() - 2);
} }
} }
} }
} }
// // the gutter separator if visible
// if (edit->mGutter.borderStyle <> gbsNone) and (AClip.Right >= fGutterWidth - 2) then
// with Canvas do begin
// Pen.Color := fGutter.BorderColor;
// Pen.Width := 1;
// with AClip do begin
// if fGutter.BorderStyle = gbsMiddle then begin
// MoveTo(fGutterWidth - 2, Top);
// LineTo(fGutterWidth - 2, Bottom);
// Pen.Color := fGutter.Color;
// end;
// MoveTo(fGutterWidth - 1, Top);
// LineTo(fGutterWidth - 1, Bottom);
// end;
// end;
// // now the gutter marks
// if BookMarkOptions.GlyphsVisible and (Marks.Count > 0) and (aLastRow >= aFirstRow) then begin
// aGutterOffs := AllocMem((aLastRow - aFirstRow + 1) * SizeOf(integer));
// vFirstLine := RowToLine(aFirstRow);
// vLastLine := RowToLine(aLastRow);
// try
// // Instead of making a two pass loop we look while drawing the bookmarks
// // whether there is any other mark to be drawn
// bHasOtherMarks := FALSE;
// for cMark := 0 to Marks.Count - 1 do
// with Marks[cMark] do
// if Visible and (Line >= vFirstLine) and (Line <= vLastLine) then begin
// if IsBookmark <> BookMarkOptions.DrawBookmarksFirst then
// bHasOtherMarks := TRUE
// else begin
// vMarkRow := LineToRow(Line);
// if vMarkRow >= aFirstRow then
// DrawMark(Marks[cMark], aGutterOffs[vMarkRow - aFirstRow], vMarkRow);
// end
// end;
// if bHasOtherMarks then
// for cMark := 0 to Marks.Count - 1 do
// with Marks[cMark] do begin
// if Visible and (IsBookmark <> BookMarkOptions.DrawBookmarksFirst)
// and (Line >= vFirstLine) and (Line <= vLastLine) then begin
// vMarkRow := LineToRow(Line);
// if vMarkRow >= aFirstRow then
// DrawMark(Marks[cMark], aGutterOffs[vMarkRow - aFirstRow], vMarkRow);
// end;
// end;
// if Assigned(OnGutterPaint) then
// for cRow := aFirstRow to aLastRow do begin
// OnGutterPaint(Self, cRow, aGutterOffs[cRow - aFirstRow],
// (vGutterRow - TopLine) * LineHeight);
// end;
// finally
// FreeMem(aGutterOffs);
// end;
// end;
for (cRow = aFirstRow; cRow <=aLastRow; cRow++) { for (cRow = aFirstRow; cRow <=aLastRow; cRow++) {
vLine = edit->rowToLine(cRow); vLine = edit->rowToLine(cRow);
if ((vLine > edit->mLines->count()) && (edit->mLines->count() != 0))
break;
edit->onGutterPaint(*painter,vLine, 0, (cRow - edit->mTopLine) * edit->mTextHeight); edit->onGutterPaint(*painter,vLine, 0, (cRow - edit->mTopLine) * edit->mTextHeight);
} }
} }