Replace BufWidth & BufHeight with BufView

BufView returns not only the buffer's width and height but also its
x,y position. It may be useful e.g. for checking if a mouse click was
on the actual buffer or ourside it, e.g. on the gutter.
This commit is contained in:
Dmitry Maluka
2021-04-08 23:32:00 +02:00
parent ab6ce444a7
commit aaac60a78d
4 changed files with 35 additions and 26 deletions

View File

@@ -94,16 +94,18 @@ func (w *BufWindow) IsActive() bool {
return w.active
}
// BufWidth returns the width of the actual buffer displayed in the window,
// which is usually less than the window width due to the gutter, ruler or scrollbar
func (w *BufWindow) BufWidth() int {
return w.bufWidth
}
// BufHeight returns the height of the actual buffer displayed in the window,
// which is usually less than the window height due to the statusline
func (w *BufWindow) BufHeight() int {
return w.bufHeight
// BufView returns the width, height and x,y location of the actual buffer.
// It is not exactly the same as the whole window which also contains gutter,
// ruler, scrollbar and statusline.
func (w *BufWindow) BufView() View {
return View{
X: w.gutterOffset,
Y: 0,
Width: w.bufWidth,
Height: w.bufHeight,
StartLine: w.StartLine,
StartCol: w.StartCol,
}
}
func (w *BufWindow) updateDisplayInfo() {