mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 22:07:09 +09:00
Softwrap implementation enhanced to fix various issues with scrolling, centering, relocating etc. The main idea is simple: work not with simple line numbers but with (Line, Row) pairs, where Line is a line number in the buffer and Row is a visual line (a row) number within this line. The logic remains mostly the same, but simple arithmetic operations on line numbers are replaced with corresponding operations on (Line, Row) pairs. Fixes #632, #1657
37 lines
758 B
Go
37 lines
758 B
Go
package display
|
|
|
|
import (
|
|
"github.com/zyedidia/micro/v2/internal/buffer"
|
|
)
|
|
|
|
type View struct {
|
|
X, Y int // X,Y location of the view
|
|
Width, Height int // Width and height of the view
|
|
|
|
// Start line of the view (for vertical scroll)
|
|
StartLine SLoc
|
|
|
|
// Start column of the view (for horizontal scroll)
|
|
// note that since the starting column of every line is different if the view
|
|
// is scrolled, StartCol is a visual index (will be the same for every line)
|
|
StartCol int
|
|
}
|
|
|
|
type Window interface {
|
|
Display()
|
|
Clear()
|
|
Relocate() bool
|
|
GetView() *View
|
|
SetView(v *View)
|
|
LocFromVisual(vloc buffer.Loc) buffer.Loc
|
|
Resize(w, h int)
|
|
SetActive(b bool)
|
|
IsActive() bool
|
|
}
|
|
|
|
type BWindow interface {
|
|
Window
|
|
SoftWrap
|
|
SetBuffer(b *buffer.Buffer)
|
|
}
|