Skip to content

Commit 9e3da92

Browse files
committed
Improved viewportMargin rendering
1 parent 7e8c8b9 commit 9e3da92

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

Diff for: editor/window.go

+31-20
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,6 @@ func (w *Window) grabScreen() *gui.QPixmap {
236236
fullRect.Y()+(w.viewportMargins[0]*font.lineHeight),
237237
fullRect.Width()-w.viewportMargins[2]*int(font.cellwidth)-w.viewportMargins[3]*int(font.cellwidth),
238238
fullRect.Height()-(w.viewportMargins[0]*font.lineHeight)-(w.viewportMargins[1]*font.lineHeight),
239-
// fullRect.X(),
240-
// fullRect.Y(),
241-
// fullRect.Width(),
242-
// fullRect.Height(),
243239
)
244240
return w.Grab(rect)
245241
}
@@ -293,9 +289,6 @@ func (w *Window) paint(event *gui.QPaintEvent) {
293289
rows++
294290
}
295291

296-
// Draw scroll snapshot
297-
w.drawScrollSnapshot(p)
298-
299292
var verScrollPixels int
300293
if w.lastScrollphase != core.Qt__NoScrollPhase {
301294
verScrollPixels = w.scrollPixels2
@@ -304,24 +297,42 @@ func (w *Window) paint(event *gui.QPaintEvent) {
304297
verScrollPixels += w.scrollPixels[1]
305298
}
306299

300+
// -------------
307301
// Draw contents
302+
// -------------
303+
308304
if w.isFloatWin && !w.isMsgGrid {
309305
w.drawUndrawnAreas(p)
310306
}
311-
// for y := row + rows; y >= row; y-- {
312-
// w.drawBackground(p, y, col, cols)
313-
// w.drawForeground(p, y, col, cols)
314-
// }
315-
if verScrollPixels <= 0 {
316-
for y := row + rows; y >= row; y-- {
317-
w.drawBackground(p, y, col, cols)
318-
w.drawForeground(p, y, col, cols)
307+
// Draw content within viewportMargin in the y-axis direction
308+
for y := row + rows; y >= row; y-- {
309+
if y < w.viewportMargins[0] {
310+
continue
319311
}
320-
} else {
321-
for y := row; y <= row+rows; y++ {
322-
w.drawBackground(p, y, col, cols)
323-
w.drawForeground(p, y, col, cols)
312+
if y > w.rows-w.viewportMargins[1] {
313+
continue
314+
}
315+
w.drawBackground(p, y, col, cols)
316+
w.drawForeground(p, y, col, cols)
317+
}
318+
319+
// Draw scroll snapshot
320+
w.drawScrollSnapshot(p)
321+
322+
// Draw content outside the viewportMargin in the y-axis direction
323+
for y := row + rows; y >= row; y-- {
324+
if y <= w.viewportMargins[0] {
325+
continue
326+
}
327+
w.drawBackground(p, y, col, cols)
328+
w.drawForeground(p, y, col, cols)
329+
}
330+
for y := row + rows; y >= row; y-- {
331+
if y >= w.rows-w.viewportMargins[1] {
332+
continue
324333
}
334+
w.drawBackground(p, y, col, cols)
335+
w.drawForeground(p, y, col, cols)
325336
}
326337

327338
// TODO: We should use msgSepChar to separate message window area
@@ -3516,7 +3527,7 @@ func (w *Window) focusGrid() {
35163527
}
35173528

35183529
// convertWindowsToUnixPath converts a Windows path to a Unix path as wslpath does.
3519-
func convertWindowsToUnixPath(winPath string) string {
3530+
func convertWindowsToUnixPath(winPath string) string {
35203531
unixPath := strings.ReplaceAll(winPath, `\`, `/`)
35213532
if len(unixPath) <= 2 {
35223533
return unixPath

0 commit comments

Comments
 (0)