package tui import ( "git.tordarus.net/Tordarus/buf2d" "github.com/gdamore/tcell" ) type ViewBuffer = buf2d.Buffer[Rune] type KeyEvent = tcell.EventKey type Style = tcell.Style type Color = tcell.Color var StyleDefault Style = tcell.StyleDefault type Point struct { X, Y int } type Size struct { Width, Height int } type Dimension struct { Point Size } type Orientation uint8 const ( Horizontal Orientation = iota Vertical ) type Side uint8 const ( SideTop Side = iota SideBottom SideLeft SideRight ) // Horizontal returns true if s is either SideLeft or SideRight func (s Side) Horizontal() bool { return s == SideLeft || s == SideRight } // Vertical returns true if s is either SideTop or SideBottom func (s Side) Vertical() bool { return s == SideTop || s == SideBottom } type Anchor uint8 const ( AnchorTopLeft Anchor = iota AnchorTop AnchorTopRight AnchorLeft AnchorCenter AnchorRight AnchorBottomLeft AnchorBottom AnchorBottomRight ) type MouseEvent struct { X, Y int Button MouseButton Modifiers tcell.ModMask } type MouseButton uint8 const ( MouseButtonNone MouseButton = iota MouseButtonLeft MouseButtonMiddle MouseButtonRight MouseButtonNext MouseButtonPrev MouseWheelUp MouseWheelDown MouseWheelLeft MouseWheelRight ) func convertMouseButton(mask tcell.ButtonMask) MouseButton { if mask&tcell.Button1 == tcell.Button1 { return MouseButtonLeft } else if mask&tcell.Button2 == tcell.Button2 { return MouseButtonMiddle } else if mask&tcell.Button3 == tcell.Button3 { return MouseButtonRight } else if mask&tcell.Button4 == tcell.Button4 { return MouseButtonNext } else if mask&tcell.Button5 == tcell.Button5 { return MouseButtonPrev } else if mask&tcell.WheelUp == tcell.WheelUp { return MouseWheelUp } else if mask&tcell.WheelDown == tcell.WheelDown { return MouseWheelDown } else if mask&tcell.WheelLeft == tcell.WheelLeft { return MouseWheelLeft } else if mask&tcell.WheelRight == tcell.WheelRight { return MouseWheelRight } return MouseButtonNone }