github.com/jmigpin/editor@v1.6.0/util/drawutil/drawer.go (about)

     1  package drawutil
     2  
     3  import (
     4  	"image"
     5  	"image/color"
     6  	"image/draw"
     7  
     8  	"github.com/jmigpin/editor/util/fontutil"
     9  	"github.com/jmigpin/editor/util/iout/iorw"
    10  )
    11  
    12  type Drawer interface {
    13  	Reader() iorw.ReaderAt
    14  	SetReader(iorw.ReaderAt)
    15  	ContentChanged()
    16  
    17  	FontFace() *fontutil.FontFace
    18  	SetFontFace(*fontutil.FontFace)
    19  	LineHeight() int
    20  	SetFg(color.Color)
    21  
    22  	Bounds() image.Rectangle
    23  	SetBounds(image.Rectangle)
    24  
    25  	// rune offset  (set text view position; save/restore view in session file)
    26  	RuneOffset() int
    27  	SetRuneOffset(int)
    28  
    29  	LocalPointOf(index int) image.Point
    30  	LocalIndexOf(image.Point) int
    31  
    32  	Measure() image.Point
    33  	Draw(img draw.Image)
    34  
    35  	// specialized: covers editor row button margin
    36  	FirstLineOffsetX() int
    37  	SetFirstLineOffsetX(x int)
    38  
    39  	// cursor
    40  	SetCursorOffset(int)
    41  
    42  	// scrollable utils
    43  	ScrollOffset() image.Point
    44  	SetScrollOffset(image.Point)
    45  	ScrollSize() image.Point
    46  	ScrollViewSize() image.Point
    47  	ScrollPageSizeY(up bool) int
    48  	ScrollWheelSizeY(up bool) int
    49  
    50  	// visibility utils
    51  	RangeVisible(offset, n int) bool
    52  	RangeVisibleOffset(offset, n int) int
    53  }
    54  
    55  //----------
    56  
    57  type SyntaxHighlightComment struct {
    58  	S, E   string // {start,end} sequence
    59  	IsLine bool   // single line comment (end argument is ignored)
    60  }