Documentation
¶
Overview ¶
CDK - Curses Development Kit
The Curses Development Kit is the low-level compliment to the higher-level Curses Tool Kit.
Introduction ¶
CDK is based primarily upon the TCell codebase, however, it is a hard-fork with many API-breaking changes. Some of the more salient changes are as follows:
- `Screen` is now a `Display`
- `Theme` is a collection of purpose-intended `Style`s
- Developers are not intended to use the `Display` directly
- a `Canvas` type is used to composite the rendering process
- a `Window` type is used to render to a `Display` and handle events
- `EventFlag`s are used to manage the propagation of events
- robust canvas rendering enables reliable wrapping, justification and alignment of textual content
- `Tango` markup format to augment the text rendering with applied style attributes (with similar features as Pango for GDK/GTK)
CDK Demo Walkthrough ¶
All CDK applications require some form of `Window` implementation in order to function. One can use the build-in `cdk.CWindow` type to construct a basic `Window` object and tie into it's signals in order to render to the canvas and handle events. For this example however, a more formal approach is taken.
type CdkDemoWindow struct { cdk.CWindow }
Starting out with a very slim definition of our custom `Window`, all that's necessary is the embed the concrete `cdk.CWindow` type and proceed with overriding various methods.
func (w *CdkDemoWindow) Init() (already bool) { if w.CWindow.Init() { return true } return false }
The `Init` method is not necessary to overload, however, this is a good spot to do any UI initializations or the like. For this demo, the boilerplate minimum is given as an example to start from.
func (w *CdkDemoWindow) Draw(canvas cdk.Canvas) cdk.EventFlag { ... things ... }
The next method implemented is the `Draw` method. This method receives a pre-configured Canvas object, set to the available size of the `Display`. Within this method, the application needs to process as little "work" as possible and focus primarily on just rendering the content upon the canvas. Let's walk through each line of the `Draw` method.
w.LogInfo("Draw: %s", canvas)
This line uses the built-in logging facilities to log an "info" message that the `Draw` method was invoked and let's us know some sort of human-readable description of the canvas (resembles JSON text but isn't really JSON). The advantage to using these built-in logging facilities is that the log entry itself will be prefixed with some extra metadata identifying the particular object instance with a bit of text in the format of "typeName-ID" where typeName is the object's CDK-type and the ID is an integer (marking the unique instance).
theme := w.GetDisplayManager().DefaultTheme()
Within CDK, there is a concept of `Theme`, which really is just a collection of useful purpose-driven `Style`s. One can set the default theme for the running CDK system, however the stock state is either a monochrome base theme or a colorized variant. Some of the rendering functions require `Style`s or `Theme`s passed as arguments and so we're getting that here for later use.
size := canvas.Size()
Simply getting a `Rectangle` primitive with it's `W`idth and `H`eight values set according to the size of the canvas' internal buffer.
`Rectangle` is a CDK primitive which has just two fields: `W` and `H`. Most places where spacial bounds are necessary, these primitives are used (such as the concept of a box `size` for painting upon a canvas).
canvas.Box(cdk.Point2I{}, size, true, true, theme)
This is the first actual draw command. In this case, the `Box` method is configured to draw a box on the screen, starting at a position of 0,0 (top left corner), taking up the full volume of the canvas, with a border (first boolean `true` argument), ensuring to fill the entire area with the filler rune and style within a given theme, which is the last argument to the `Box` method. On a color-supporting terminal, this will paint a navy-blue box over the entire terminal screen.
content := "..." content += "..." content += "..."
These few lines of code are merely concatenating a string of `Tango` markup that includes use of `<b></b>`, `<u></u>`, `<i></i>`, and `<span></span>` tags. All colors have fallback versions and are typically safe even for monochrome terminal sessions.
textPoint := cdk.MakePoint2I(size.W/2/2, size.H/2-1)
This sets up a variable holding a `Point2I` instance configured for 1/4 of the width into the screen (from the left) and halfway minus one of the height into the screen (from the top).
`Point2I` is a CDK primitive which has just two fields: `X` and `Y`. Most places where coordinates are necessary, these primitives are used (such as the concept of an `origin` point for painting upon a canvas).
textSize := cdk.MakeRectangle(size.W/2, size.H/2)
This sets up a variable holding a `Rectangle` configured to be half the size of the canvas itself.
canvas.DrawText(textPoint, textSize, cdk.JUSTIFY_CENTER, false, cdk.WRAP_WORD, cdk.DefaultColorTheme.Normal, true, content)
This last command within the `Draw` method paints the textual-content prepared earlier onto the canvas provided, center-justified, wrapping on word boundaries, using the default `Normal` theme, specifying that the content is in fact to be parsed as `Tango` markup and finally the content itself.
The result of this drawing process should be a navy-blue screen, with a border, and three lines of text centered neatly. The three lines of text should be marked up with bold, italics, underlines and colorization. The last line of text should be telling the current time and date at the time of rendering.
func (w *CdkDemoWindow) ProcessEvent(evt cdk.Event) cdk.EventFlag { w.LogInfo("ProcessEvent: %v", evt) return cdk.EVENT_STOP }
The `ProcessEvent` method is the main event handler. Whenever a new event is received by a CDK `Display`, it is passed on to the active `Window` and in this demonstration, all that's happening is a log entry is being made which mentions the event received.
When implementing your own `ProcessEvent` method, if the `Display` should repaint the screen for example, one would make two calls to methods on the `DisplayManager`:
w.GetDisplayManager().RequestDraw() w.GetDisplayManager().RequestShow()
CDK is a multi-threaded framework and the various `Request*()` methods on the `DisplayManager` are used to funnel requests along the right channels in order to first render the canvas (via `Draw` calls on the active `Window`) and then follow that up with the running `Display` painting itself from the canvas modified in the `Draw` process.
The other complete list of request methods is as follows:
RequestDraw() // window draw rendering RequestShow() // display rendering (modified cells only) RequestSync() // full display synchronization (all cells updated) RequestQuit() // graceful shutdown of a CDK `Display`
This concludes the `CdkDemoWindow` type implementation. Now on to using it!
The Main Func ¶
The `main()` function within the `_demos/cdk-demo.go` sources is deceptively simple to implement.
app := cdk.NewApp( "cdk-demo", "An example of a formal CDK Application", "0.0.1", "demo", "CDK Demo", "/dev/tty", func(d cdk.DisplayManager) error { cdk.DebugF("cdk-demo initFn hit") d.CaptureCtrlC() w := &CdkDemoWindow{} w.Init() d.SetActiveWindow(w) cdk.AddTimeout(time.Second, func() cdk.EventFlag { d.RequestDraw() d.RequestShow() return cdk.EVENT_PASS // keep looping every second }) return nil }, }
The bulk of the code is constructing a new CDK `App` instance. This object is a wrapper around the `github.com/urfave/cli/v2` CLI package, providing a tidy interface to managing CLI arguments, help documentation and so on. In this example, the `App` is configured with a bunch of metadata for: the program's name "cdk-demo", a simply usage summary, the current version number, an internally-used tag, a title for the main window and the display is to use the `/dev/tty` (default) terminal device.
Beyond the metadata, the final argument is an initialization function. This function receives a fully instantiated and running `Display` instance and it is expected that the application instantiates it's `Window` and sets it as the active window for the given `Display`.
In addition to that is one final call to `AddTimeout`. This call will trigger the given `func() cdk.EventFlag` once, after a second. Because the `func()` implemented here in this demonstration returns the `cdk.EVENT_PASS` flag it will be continually called once per second. For this demonstration, this implementation simply requests a draw and show cycle which will cause the screen to be repainted with the current date and time every second the demo application is running.
if err := app.Run(os.Args); err != nil { panic(err) }
The final bit of code in this CDK demonstration simply passes the arguments provided by the end-user on the command-line in a call to the `App`'s `Run()` method. This will cause the `DisplayManager`, `Display` and other systems to instantiate and begin processing events and render cycles.
Index ¶
- Constants
- Variables
- func AddTimeout(d time.Duration, fn TimerCallbackFn) (id int)
- func CancelTimeout(id int) bool
- func DebugDF(depth int, format string, argv ...interface{})
- func DebugF(format string, argv ...interface{})
- func DescribeButton(button ButtonMask) string
- func DidFakeExit() bool
- func DoWithFakeIO(fn func() error) (string, bool, error)
- func Error(err error)
- func ErrorDF(depth int, format string, argv ...interface{})
- func ErrorF(format string, argv ...interface{})
- func Exit(code int)
- func FakeExiting()
- func Fatal(err error)
- func FatalDF(depth int, format string, argv ...interface{})
- func FatalF(format string, argv ...interface{})
- func GetCharset() string
- func GetEncoding(charset string) encoding.Encoding
- func GetLastFakeIO() (string, int, error)
- func InfoDF(depth int, format string, argv ...interface{})
- func InfoF(format string, argv ...interface{})
- func ListEncodings() []string
- func LookupKeyName(key Key) string
- func MakeTag(argv ...interface{}) (tag string)
- func Panic(err error)
- func PanicDF(depth int, format string, argv ...interface{})
- func PanicF(format string, argv ...interface{})
- func QuarkToString(id QuarkID) string
- func RegisterEncoding(charset string, enc encoding.Encoding)
- func ReloadLogging() error
- func ResetFakeExited()
- func RestoreExiting()
- func SetCurrentTheme(theme Theme)
- func SetEncodingFallback(fb EncodingFallback)
- func StopLogging() error
- func TestingMakesActiveWindow(d DisplayManager) error
- func TestingMakesNoContent(d DisplayManager) error
- func TraceDF(depth int, format string, argv ...interface{})
- func TraceF(format string, argv ...interface{})
- func UnregisterEncoding(charset string)
- func WarnDF(depth int, format string, argv ...interface{})
- func WarnF(format string, argv ...interface{})
- func WithApp(initFn DisplayInitFn, action AppFn) func()
- func WithDisplayManager(action DisplayManagerFn) func()
- type App
- type AppFn
- type ArrowRuneSet
- type AttrMask
- func (m AttrMask) Blink(v bool) AttrMask
- func (m AttrMask) Bold(v bool) AttrMask
- func (m AttrMask) Dim(v bool) AttrMask
- func (m AttrMask) IsBlink() bool
- func (m AttrMask) IsBold() bool
- func (m AttrMask) IsDim() bool
- func (m AttrMask) IsNormal() bool
- func (m AttrMask) IsReverse() bool
- func (m AttrMask) IsUnderline() bool
- func (m AttrMask) Normal() AttrMask
- func (m AttrMask) Reverse(v bool) AttrMask
- func (m AttrMask) Underline(v bool) AttrMask
- type Border
- type BorderRuneSet
- type ButtonMask
- type CApp
- func (app *CApp) AddCommand(command *cli.Command)
- func (app *CApp) AddCommands(commands []*cli.Command)
- func (app *CApp) AddFlag(flag cli.Flag)
- func (app *CApp) AddFlags(flags []cli.Flag)
- func (app *CApp) CLI() *cli.App
- func (app *CApp) Destroy()
- func (app *CApp) DisplayManager() DisplayManager
- func (app *CApp) GetContext() *cli.Context
- func (app *CApp) InitUI() error
- func (app *CApp) MainActionFn(c *cli.Context) error
- func (app *CApp) Name() string
- func (app *CApp) Run(args []string) error
- func (app *CApp) Tag() string
- func (app *CApp) Title() string
- func (app *CApp) Usage() string
- func (app *CApp) Version() string
- type CCanvas
- func (c *CCanvas) Box(pos Point2I, size Rectangle, border, fill, overlay bool, fillRune rune, ...)
- func (c *CCanvas) BoxWithTheme(pos Point2I, size Rectangle, border, fill bool, theme Theme)
- func (c *CCanvas) Composite(v Canvas) error
- func (c *CCanvas) DebugBox(color Color, format string, argv ...interface{})
- func (c *CCanvas) DrawHorizontalLine(pos Point2I, length int, style Style)
- func (c *CCanvas) DrawLine(pos Point2I, length int, orient Orientation, style Style)
- func (c *CCanvas) DrawSingleLineText(position Point2I, maxChars int, ellipsize bool, justify Justification, ...)
- func (c *CCanvas) DrawText(pos Point2I, size Rectangle, justify Justification, singleLineMode bool, ...)
- func (c *CCanvas) DrawVerticalLine(pos Point2I, length int, style Style)
- func (c *CCanvas) Equals(onlyDirty bool, v Canvas) bool
- func (c *CCanvas) Fill(theme Theme)
- func (c *CCanvas) FillBorder(dim, border bool, theme Theme)
- func (c *CCanvas) FillBorderTitle(dim bool, title string, justify Justification, theme Theme)
- func (c *CCanvas) ForEach(fn CanvasForEachFn) EventFlag
- func (c *CCanvas) GetContent(x, y int) (textCell TextCell)
- func (c *CCanvas) GetOrigin() Point2I
- func (c *CCanvas) GetSize() Rectangle
- func (c *CCanvas) GetStyle() (style Style)
- func (c *CCanvas) Height() (height int)
- func (c *CCanvas) Render(display Display) error
- func (c *CCanvas) Resize(size Rectangle, style Style)
- func (c *CCanvas) SetContent(x, y int, char string, s Style) error
- func (c *CCanvas) SetOrigin(origin Point2I)
- func (c *CCanvas) SetRune(x, y int, r rune, s Style) error
- func (c CCanvas) String() string
- func (c *CCanvas) Width() (width int)
- type CCanvasBuffer
- func (b *CCanvasBuffer) Cell(x int, y int) TextCell
- func (b *CCanvasBuffer) GetBgColor(x, y int) (bg Color)
- func (b *CCanvasBuffer) GetContent(x, y int) (textCell TextCell)
- func (b *CCanvasBuffer) GetDim(x, y int) bool
- func (b *CCanvasBuffer) Height() (height int)
- func (b *CCanvasBuffer) LoadData(d [][]TextCell)
- func (b *CCanvasBuffer) Resize(size Rectangle, style Style)
- func (b *CCanvasBuffer) SetContent(x int, y int, r rune, style Style) error
- func (b *CCanvasBuffer) Size() (size Rectangle)
- func (b *CCanvasBuffer) String() string
- func (b *CCanvasBuffer) Style() (style Style)
- func (b *CCanvasBuffer) Width() (width int)
- type CColormap
- type CDisplayManager
- func (d *CDisplayManager) ActiveWindow() Window
- func (d *CDisplayManager) AddQuitHandler(tag string, fn func())
- func (d *CDisplayManager) AddWindow(w Window)
- func (d *CDisplayManager) AddWindowOverlay(pid int, overlay Window, region Region)
- func (d *CDisplayManager) App() *CApp
- func (d *CDisplayManager) AsyncCall(fn DisplayCallbackFn) error
- func (d *CDisplayManager) AwaitCall(fn DisplayCallbackFn) error
- func (d *CDisplayManager) CaptureCtrlC()
- func (d *CDisplayManager) CaptureDisplay(ttyPath string)
- func (d *CDisplayManager) Colors() (numberOfColors int)
- func (d *CDisplayManager) DefaultTheme() Theme
- func (d *CDisplayManager) Destroy()
- func (d *CDisplayManager) Display() Display
- func (d *CDisplayManager) DisplayCaptured() bool
- func (d *CDisplayManager) DrawScreen() EventFlag
- func (d *CDisplayManager) GetEventFocus() (widget interface{})
- func (d *CDisplayManager) GetPriorEvent() (event Event)
- func (d *CDisplayManager) GetTitle() string
- func (d *CDisplayManager) GetTtyPath() string
- func (d *CDisplayManager) GetWindowOverlayRegion(windowId, overlayId int) (region Region)
- func (d *CDisplayManager) GetWindowOverlays(windowId int) (windows []Window)
- func (d *CDisplayManager) GetWindowTopOverlay(windowId int) (window Window)
- func (d *CDisplayManager) GetWindows() (windows []Window)
- func (d *CDisplayManager) Init() (already bool)
- func (d *CDisplayManager) IsMonochrome() bool
- func (d *CDisplayManager) IsRunning() bool
- func (d *CDisplayManager) PostEvent(evt Event) error
- func (d *CDisplayManager) ProcessEvent(evt Event) EventFlag
- func (d *CDisplayManager) ReleaseCtrlC()
- func (d *CDisplayManager) ReleaseDisplay()
- func (d *CDisplayManager) RemoveQuitHandler(tag string)
- func (d *CDisplayManager) RemoveWindow(wid int)
- func (d *CDisplayManager) RemoveWindowOverlay(pid int, oid int)
- func (d *CDisplayManager) RequestDraw()
- func (d *CDisplayManager) RequestQuit()
- func (d *CDisplayManager) RequestShow()
- func (d *CDisplayManager) RequestSync()
- func (d *CDisplayManager) Run() error
- func (d *CDisplayManager) SetActiveWindow(w Window)
- func (d *CDisplayManager) SetEventFocus(widget interface{}) error
- func (d *CDisplayManager) SetTitle(title string)
- func (d *CDisplayManager) SetTtyPath(ttyPath string)
- func (d *CDisplayManager) SetWindowOverlayRegion(windowId, overlayId int, region Region)
- type CList
- type CMetaData
- func (o *CMetaData) GetBoolProperty(name Property) (value bool, err error)
- func (o *CMetaData) GetColorProperty(name Property) (value Color, err error)
- func (o *CMetaData) GetFloat64Property(name Property) (value float64, err error)
- func (o *CMetaData) GetFloatProperty(name Property) (value float64, err error)
- func (o *CMetaData) GetIntProperty(name Property) (value int, err error)
- func (o *CMetaData) GetPointProperty(name Property) (value Point2I, err error)
- func (o *CMetaData) GetProperty(name Property) *CProperty
- func (o *CMetaData) GetRectangleProperty(name Property) (value Rectangle, err error)
- func (o *CMetaData) GetRegionProperty(name Property) (value Region, err error)
- func (o *CMetaData) GetStringProperty(name Property) (value string, err error)
- func (o *CMetaData) GetStructProperty(name Property) (value interface{}, err error)
- func (o *CMetaData) GetStyleProperty(name Property) (value Style, err error)
- func (o *CMetaData) GetThemeProperty(name Property) (value Theme, err error)
- func (o *CMetaData) Init() (already bool)
- func (o *CMetaData) InstallBuildableProperty(name Property, kind PropertyType, write bool, def interface{}) error
- func (o *CMetaData) InstallProperty(name Property, kind PropertyType, write bool, def interface{}) error
- func (o *CMetaData) IsBuildableProperty(name Property) bool
- func (o *CMetaData) IsProperty(name Property) bool
- func (o *CMetaData) ListBuildableProperties() (properties []Property)
- func (o *CMetaData) ListProperties() (properties []Property)
- func (o *CMetaData) OverloadProperty(name Property, kind PropertyType, write bool, buildable bool, def interface{}) error
- func (o *CMetaData) SetBoolProperty(name Property, value bool) error
- func (o *CMetaData) SetColorProperty(name Property, value Color) error
- func (o *CMetaData) SetFloatProperty(name Property, value float64) error
- func (o *CMetaData) SetIntProperty(name Property, value int) error
- func (o *CMetaData) SetPointProperty(name Property, value Point2I) error
- func (o *CMetaData) SetProperties(properties map[Property]string) (err error)
- func (o *CMetaData) SetProperty(name Property, value interface{}) error
- func (o *CMetaData) SetPropertyFromString(name Property, value string) error
- func (o *CMetaData) SetRectangleProperty(name Property, value Rectangle) error
- func (o *CMetaData) SetRegionProperty(name Property, value Region) error
- func (o *CMetaData) SetStringProperty(name Property, value string) error
- func (o *CMetaData) SetStructProperty(name Property, value interface{}) error
- func (o *CMetaData) SetStyleProperty(name Property, value Style) error
- func (o *CMetaData) SetThemeProperty(name Property, value Theme) error
- type CObject
- func (o *CObject) Destroy()
- func (o *CObject) GetName() (name string)
- func (o *CObject) GetTheme() (theme Theme)
- func (o *CObject) GetThemeRequest() (theme Theme)
- func (o *CObject) Init() (already bool)
- func (o *CObject) InitWithProperties(properties map[Property]string) (already bool, err error)
- func (o *CObject) SetName(name string)
- func (o *CObject) SetTheme(theme Theme)
- func (o *CObject) SetThemeRequest(theme Theme)
- type COffscreenDisplay
- func (o *COffscreenDisplay) Beep() error
- func (o *COffscreenDisplay) CanDisplay(r rune, checkFallbacks bool) bool
- func (o *COffscreenDisplay) CharacterSet() string
- func (o *COffscreenDisplay) Clear()
- func (o *COffscreenDisplay) Close()
- func (o *COffscreenDisplay) Colors() int
- func (o *COffscreenDisplay) DisableMouse()
- func (o *COffscreenDisplay) DisablePaste()
- func (o *COffscreenDisplay) EnableMouse(_ ...MouseFlags)
- func (o *COffscreenDisplay) EnablePaste()
- func (o *COffscreenDisplay) Export() *CellBuffer
- func (o *COffscreenDisplay) Fill(r rune, style Style)
- func (o *COffscreenDisplay) GetContent(x, y int) (mc rune, comb []rune, style Style, width int)
- func (o *COffscreenDisplay) GetContents() ([]OffscreenCell, int, int)
- func (o *COffscreenDisplay) GetCursor() (int, int, bool)
- func (o *COffscreenDisplay) HasKey(Key) bool
- func (o *COffscreenDisplay) HasMouse() bool
- func (o *COffscreenDisplay) HideCursor()
- func (o *COffscreenDisplay) Import(cb *CellBuffer)
- func (o *COffscreenDisplay) Init() error
- func (o *COffscreenDisplay) InjectKey(key Key, r rune, mod ModMask)
- func (o *COffscreenDisplay) InjectKeyBytes(b []byte) bool
- func (o *COffscreenDisplay) InjectMouse(x, y int, buttons ButtonMask, mod ModMask)
- func (o *COffscreenDisplay) PollEvent() Event
- func (o *COffscreenDisplay) PostEvent(ev Event) error
- func (o *COffscreenDisplay) PostEventWait(ev Event)
- func (o *COffscreenDisplay) RegisterRuneFallback(r rune, subst string)
- func (o *COffscreenDisplay) Resize(int, int, int, int)
- func (o *COffscreenDisplay) SetCell(x, y int, style Style, ch ...rune)
- func (o *COffscreenDisplay) SetContent(x, y int, mc rune, comb []rune, st Style)
- func (o *COffscreenDisplay) SetSize(w, h int)
- func (o *COffscreenDisplay) SetStyle(style Style)
- func (o *COffscreenDisplay) Show()
- func (o *COffscreenDisplay) ShowCursor(x, y int)
- func (o *COffscreenDisplay) Size() (w, h int)
- func (o *COffscreenDisplay) Sync()
- func (o *COffscreenDisplay) UnregisterRuneFallback(r rune)
- type COffscreenWindow
- func (w *COffscreenWindow) Draw(canvas Canvas) EventFlag
- func (w *COffscreenWindow) GetDisplayManager() DisplayManager
- func (w *COffscreenWindow) GetTitle() string
- func (w *COffscreenWindow) Init() bool
- func (w *COffscreenWindow) ProcessEvent(evt Event) EventFlag
- func (w *COffscreenWindow) SetDisplayManager(d DisplayManager)
- func (w *COffscreenWindow) SetTitle(title string)
- type CPixmap
- type CProperty
- func (p *CProperty) Buildable() bool
- func (p *CProperty) Clone() *CProperty
- func (p *CProperty) Default() (def interface{})
- func (p *CProperty) Name() Property
- func (p *CProperty) ReadOnly() bool
- func (p *CProperty) Set(value interface{}) error
- func (p *CProperty) SetFromString(value string) error
- func (p *CProperty) Type() PropertyType
- func (p *CProperty) Value() (value interface{})
- type CQuark
- type CSignalListener
- type CSignaling
- func (o *CSignaling) Connect(signal Signal, handle string, c SignalListenerFn, data ...interface{})
- func (o *CSignaling) Disconnect(signal Signal, handle string) error
- func (o *CSignaling) Emit(signal Signal, argv ...interface{}) EventFlag
- func (o *CSignaling) Freeze()
- func (o *CSignaling) Handled(signal Signal, handle string) (found bool)
- func (o *CSignaling) Init() (already bool)
- func (o *CSignaling) IsFrozen() bool
- func (o *CSignaling) IsSignalPassed(signal Signal) bool
- func (o *CSignaling) IsSignalStopped(signal Signal) bool
- func (o *CSignaling) PassSignal(signal Signal)
- func (o *CSignaling) ResumeSignal(signal Signal)
- func (o *CSignaling) StopSignal(signal Signal)
- func (o *CSignaling) Thaw()
- type CTango
- type CTextBuffer
- func (b *CTextBuffer) CharacterCount() (cellCount int)
- func (b *CTextBuffer) ClearText(wordWrap WrapMode, ellipsize bool, justify Justification, maxChars int) (plain string)
- func (b *CTextBuffer) Draw(canvas Canvas, singleLine bool, wordWrap WrapMode, ellipsize bool, ...) EventFlag
- func (b *CTextBuffer) Input() (raw string)
- func (b *CTextBuffer) Mnemonic() (enabled bool)
- func (b *CTextBuffer) PlainText(wordWrap WrapMode, ellipsize bool, justify Justification, maxChars int) (plain string)
- func (b *CTextBuffer) PlainTextInfo(wordWrap WrapMode, ellipsize bool, justify Justification, maxChars int) (longestLine, lineCount int)
- func (b *CTextBuffer) Set(input string, style Style)
- func (b *CTextBuffer) SetInput(input WordLine)
- func (b *CTextBuffer) SetMnemonic(enabled bool)
- func (b *CTextBuffer) SetStyle(style Style)
- func (b *CTextBuffer) Style() Style
- func (b *CTextBuffer) WordCount() (wordCount int)
- type CTextCell
- func (t *CTextCell) Dirty() bool
- func (t *CTextCell) Equals(mc rune, style Style, width int) bool
- func (t *CTextCell) IsNil() bool
- func (t *CTextCell) IsSpace() bool
- func (t *CTextCell) Set(r rune)
- func (t *CTextCell) SetByte(b []byte)
- func (t *CTextCell) SetStyle(style Style)
- func (t *CTextCell) String() string
- func (t *CTextCell) Style() Style
- func (t *CTextCell) Value() rune
- func (t *CTextCell) Width() int
- type CTextChar
- type CType
- type CTypeItem
- func (o *CTypeItem) DestroyObject() (err error)
- func (o *CTypeItem) GetName() string
- func (o *CTypeItem) GetTypeTag() TypeTag
- func (o *CTypeItem) Init() (already bool)
- func (o *CTypeItem) InitTypeItem(tag TypeTag, thing interface{}) (already bool)
- func (o *CTypeItem) IsValid() bool
- func (o *CTypeItem) LogDebug(format string, argv ...interface{})
- func (o *CTypeItem) LogErr(err error)
- func (o *CTypeItem) LogError(format string, argv ...interface{})
- func (o *CTypeItem) LogInfo(format string, argv ...interface{})
- func (o *CTypeItem) LogTag() string
- func (o *CTypeItem) LogTrace(format string, argv ...interface{})
- func (o *CTypeItem) LogWarn(format string, argv ...interface{})
- func (o *CTypeItem) ObjectID() int
- func (o *CTypeItem) ObjectName() string
- func (o *CTypeItem) Self() (this interface{})
- func (o *CTypeItem) SetName(name string)
- func (o *CTypeItem) String() string
- type CTypeItemList
- type CTypeRegistry
- func (r *CTypeRegistry) AddType(tag TypeTag, constructor func() interface{}, aliases ...string) error
- func (r *CTypeRegistry) AddTypeAlias(tag TypeTag, aliases ...string)
- func (r *CTypeRegistry) AddTypeItem(tag TypeTag, item interface{}) (id int, err error)
- func (r *CTypeRegistry) GetBuildableInfo() (info map[string]TypeTag)
- func (r *CTypeRegistry) GetNextID() (id int)
- func (r *CTypeRegistry) GetType(tag TypeTag) (t Type, ok bool)
- func (r *CTypeRegistry) GetTypeItemByID(id int) interface{}
- func (r *CTypeRegistry) GetTypeItemByName(name string) interface{}
- func (r *CTypeRegistry) GetTypeItems(tag TypeTag) []interface{}
- func (r *CTypeRegistry) GetTypeTagByAlias(alias string) (tt TypeTag, ok bool)
- func (r *CTypeRegistry) GetTypeTags() (tags []TypeTag)
- func (r *CTypeRegistry) HasID(index int) bool
- func (r *CTypeRegistry) HasType(tag TypeTag) (exists bool)
- func (r *CTypeRegistry) MakeType(tag TypeTag) (thing interface{}, err error)
- func (r *CTypeRegistry) RemoveTypeItem(tag TypeTag, item TypeItem) error
- type CTypeTag
- type CVisual
- type CWindow
- func (w *CWindow) Draw(canvas Canvas) EventFlag
- func (w *CWindow) GetDisplayManager() DisplayManager
- func (w *CWindow) GetTitle() string
- func (w *CWindow) Init() bool
- func (w *CWindow) ProcessEvent(evt Event) EventFlag
- func (w *CWindow) SetDisplayManager(d DisplayManager)
- func (w *CWindow) SetTitle(title string)
- type CWordCell
- func (w *CWordCell) AppendRune(r rune, style Style)
- func (w *CWordCell) Characters() []TextCell
- func (w *CWordCell) CompactLen() (count int)
- func (w *CWordCell) GetCharacter(index int) (char TextCell)
- func (w *CWordCell) HasSpace() bool
- func (w *CWordCell) IsNil() bool
- func (w *CWordCell) IsSpace() bool
- func (w *CWordCell) Len() (count int)
- func (w *CWordCell) Set(word string, style Style)
- func (w *CWordCell) String() (s string)
- func (w *CWordCell) Value() (word string)
- type CWordLine
- func (w *CWordLine) AppendWord(word string, style Style)
- func (w *CWordLine) AppendWordCell(word WordCell)
- func (w *CWordLine) AppendWordRune(wordIndex int, char rune, style Style) error
- func (w *CWordLine) CharacterCount() (count int)
- func (w *CWordLine) GetCharacter(index int) TextCell
- func (w *CWordLine) GetWord(index int) WordCell
- func (w *CWordLine) HasSpace() bool
- func (w *CWordLine) Len() (wordSpaceCount int)
- func (w *CWordLine) Make(mnemonic bool, wrap WrapMode, ellipsize bool, justify Justification, ...) (formatted []WordLine)
- func (w *CWordLine) RemoveWord(index int)
- func (w *CWordLine) SetCharacter(index int, r rune)
- func (w *CWordLine) SetLine(line string, style Style)
- func (w *CWordLine) String() (s string)
- func (w *CWordLine) Value() (s string)
- func (w *CWordLine) WordCount() (wordCount int)
- func (w *CWordLine) Words() []WordCell
- type CWordLineCache
- type CWordPage
- type Canvas
- type CanvasBuffer
- type CanvasForEachFn
- type CellBuffer
- func (cb *CellBuffer) Dirty(x, y int) bool
- func (cb *CellBuffer) Fill(r rune, style Style)
- func (cb *CellBuffer) GetContent(x, y int) (mainc rune, combc []rune, style Style, width int)
- func (cb *CellBuffer) Invalidate()
- func (cb *CellBuffer) Resize(w, h int)
- func (cb *CellBuffer) SetContent(x int, y int, mainc rune, combc []rune, style Style)
- func (cb *CellBuffer) SetDirty(x, y int, dirty bool)
- func (cb *CellBuffer) Size() (w, h int)
- type Color
- type Colormap
- type Config
- type ConnectFlags
- type DestDefaults
- type Display
- type DisplayCallbackFn
- type DisplayInitFn
- type DisplayManager
- type DisplayManagerFn
- type DragResult
- type EncodingFallback
- type EnumFromString
- type Event
- type EventError
- type EventFlag
- type EventHandler
- type EventInterrupt
- type EventKey
- type EventMask
- type EventMouse
- func (ev *EventMouse) Button() ButtonMask
- func (ev *EventMouse) ButtonHas(check ButtonMask) bool
- func (ev *EventMouse) ButtonPressed() ButtonMask
- func (ev *EventMouse) Buttons() ButtonMask
- func (ev *EventMouse) Clone() Event
- func (ev *EventMouse) CloneForPosition(x, y int) Event
- func (ev *EventMouse) IsDragStarted() bool
- func (ev *EventMouse) IsDragStopped() bool
- func (ev *EventMouse) IsDragging() bool
- func (ev *EventMouse) IsMoving() bool
- func (ev *EventMouse) IsPressed() bool
- func (ev *EventMouse) IsReleased() bool
- func (ev *EventMouse) IsWheelImpulse() bool
- func (ev *EventMouse) Modifiers() ModMask
- func (ev *EventMouse) Position() (x, y int)
- func (ev *EventMouse) Report() string
- func (ev *EventMouse) State() MouseState
- func (ev *EventMouse) StateHas(check MouseState) bool
- func (ev *EventMouse) WheelImpulse() ButtonMask
- func (ev *EventMouse) When() time.Time
- type EventPaste
- type EventResize
- type EventTime
- type FlagSorter
- type HorizontalAlignment
- type IButtonMask
- type IMouseState
- type Justification
- type Key
- type MetaData
- type ModMask
- type MouseFlags
- type MouseState
- type Object
- type ObjectFlags
- type OffscreenCell
- type OffscreenDisplay
- type OffscreenWindow
- type Orientation
- type Pixmap
- type Point2I
- func (p *Point2I) Add(x, y int)
- func (p *Point2I) AddPoint(point Point2I)
- func (p *Point2I) ClampToRegion(region Region) (clamped bool)
- func (p Point2I) Clone() (clone Point2I)
- func (p Point2I) Equals(x, y int) bool
- func (p Point2I) EqualsTo(o Point2I) bool
- func (p Point2I) NewClone() (clone *Point2I)
- func (p *Point2I) Set(x, y int)
- func (p *Point2I) SetPoint(point Point2I)
- func (p Point2I) String() string
- func (p *Point2I) Sub(x, y int)
- func (p *Point2I) SubPoint(point Point2I)
- type Property
- type PropertyType
- type QuarkID
- type Range
- type Rectangle
- func (r *Rectangle) Add(w, h int)
- func (r *Rectangle) AddRectangle(size Rectangle)
- func (r *Rectangle) Clamp(minWidth, minHeight, maxWidth, maxHeight int)
- func (r *Rectangle) ClampToRegion(region Region) (clamped bool)
- func (r Rectangle) Clone() (clone Rectangle)
- func (r Rectangle) Equals(w, h int) bool
- func (r Rectangle) EqualsTo(o Rectangle) bool
- func (r *Rectangle) Floor(minWidth, minHeight int)
- func (r Rectangle) NewClone() (clone *Rectangle)
- func (r *Rectangle) Set(w, h int)
- func (r *Rectangle) SetRectangle(size Rectangle)
- func (r Rectangle) String() string
- func (r *Rectangle) Sub(w, h int)
- func (r *Rectangle) SubRectangle(size Rectangle)
- func (r Rectangle) Volume() int
- type Region
- func (r Region) Clone() (clone Region)
- func (r Region) FarPoint() Point2I
- func (r Region) HasPoint(pos Point2I) bool
- func (r Region) NewClone() (clone *Region)
- func (r Region) Origin() Point2I
- func (r *Region) Set(x, y, w, h int)
- func (r *Region) SetRegion(region Region)
- func (r Region) Size() Rectangle
- func (r Region) String() string
- type ResizeMode
- type ScreenStateReq
- type Sensitive
- type Signal
- type SignalFlags
- type SignalListenerData
- type SignalListenerFn
- type SignalMatchType
- type SignalRunType
- type Signaling
- type Style
- func (s Style) Attributes(attrs AttrMask) Style
- func (s Style) Background(c Color) Style
- func (s Style) Blink(on bool) Style
- func (s Style) Bold(on bool) Style
- func (s Style) Decompose() (fg Color, bg Color, attr AttrMask)
- func (s Style) Dim(on bool) Style
- func (s Style) Foreground(c Color) Style
- func (s Style) Italic(on bool) Style
- func (s Style) Normal() Style
- func (s Style) Reverse(on bool) Style
- func (s Style) StrikeThrough(on bool) Style
- func (s Style) String() string
- func (s Style) Underline(on bool) Style
- type Tango
- type TargetFlags
- type TextBuffer
- type TextCell
- type TextChar
- type Theme
- type ThemeAspect
- type TimerCallbackFn
- type Type
- type TypeItem
- type TypeRegistry
- type TypeTag
- type VerticalAlignment
- type Visual
- type Window
- type WindowType
- type WordCell
- type WordLine
- type WordLineCacheFn
- type WordPageCache
- type WrapMode
Constants ¶
const ( ColorBlack = ColorValid + iota ColorMaroon ColorGreen ColorOlive ColorPurple ColorTeal ColorSilver ColorGray ColorRed ColorLime ColorYellow ColorBlue ColorFuchsia ColorAqua ColorWhite Color16 Color17 Color18 Color19 Color20 Color21 Color22 Color23 Color24 Color25 Color26 Color27 Color28 Color29 Color30 Color31 Color32 Color33 Color34 Color35 Color36 Color37 Color38 Color39 Color40 Color41 Color42 Color43 Color44 Color45 Color46 Color47 Color48 Color49 Color50 Color51 Color52 Color53 Color54 Color55 Color56 Color57 Color58 Color59 Color60 Color61 Color62 Color63 Color64 Color65 Color66 Color67 Color68 Color69 Color70 Color71 Color72 Color73 Color74 Color75 Color76 Color77 Color78 Color79 Color80 Color81 Color82 Color83 Color84 Color85 Color86 Color87 Color88 Color89 Color90 Color91 Color92 Color93 Color94 Color95 Color96 Color97 Color98 Color99 Color100 Color101 Color102 Color103 Color104 Color105 Color106 Color107 Color108 Color109 Color110 Color111 Color112 Color113 Color114 Color115 Color116 Color117 Color118 Color119 Color120 Color121 Color122 Color123 Color124 Color125 Color126 Color127 Color128 Color129 Color130 Color131 Color132 Color133 Color134 Color135 Color136 Color137 Color138 Color139 Color140 Color141 Color142 Color143 Color144 Color145 Color146 Color147 Color148 Color149 Color150 Color151 Color152 Color153 Color154 Color155 Color156 Color157 Color158 Color159 Color160 Color161 Color162 Color163 Color164 Color165 Color166 Color167 Color168 Color169 Color170 Color171 Color172 Color173 Color174 Color175 Color176 Color177 Color178 Color179 Color180 Color181 Color182 Color183 Color184 Color185 Color186 Color187 Color188 Color189 Color190 Color191 Color192 Color193 Color194 Color195 Color196 Color197 Color198 Color199 Color200 Color201 Color202 Color203 Color204 Color205 Color206 Color207 Color208 Color209 Color210 Color211 Color212 Color213 Color214 Color215 Color216 Color217 Color218 Color219 Color220 Color221 Color222 Color223 Color224 Color225 Color226 Color227 Color228 Color229 Color230 Color231 Color232 Color233 Color234 Color235 Color236 Color237 Color238 Color239 Color240 Color241 Color242 Color243 Color244 Color245 Color246 Color247 Color248 Color249 Color250 Color251 Color252 Color253 Color254 Color255 ColorAliceBlue ColorAntiqueWhite ColorAquaMarine ColorAzure ColorBeige ColorBisque ColorBlanchedAlmond ColorBlueViolet ColorBrown ColorBurlyWood ColorCadetBlue ColorChartreuse ColorChocolate ColorCoral ColorCornflowerBlue ColorCornsilk ColorCrimson ColorDarkBlue ColorDarkCyan ColorDarkGoldenrod ColorDarkGray ColorDarkGreen ColorDarkKhaki ColorDarkMagenta ColorDarkOliveGreen ColorDarkOrange ColorDarkOrchid ColorDarkRed ColorDarkSalmon ColorDarkSeaGreen ColorDarkSlateBlue ColorDarkSlateGray ColorDarkTurquoise ColorDarkViolet ColorDeepPink ColorDeepSkyBlue ColorDimGray ColorDodgerBlue ColorFireBrick ColorFloralWhite ColorForestGreen ColorGainsboro ColorGhostWhite ColorGold ColorGoldenrod ColorGreenYellow ColorHoneydew ColorHotPink ColorIndianRed ColorIndigo ColorIvory ColorKhaki ColorLavender ColorLavenderBlush ColorLawnGreen ColorLemonChiffon ColorLightBlue ColorLightCoral ColorLightCyan ColorLightGoldenrodYellow ColorLightGray ColorLightGreen ColorLightPink ColorLightSalmon ColorLightSeaGreen ColorLightSkyBlue ColorLightSlateGray ColorLightSteelBlue ColorLightYellow ColorLimeGreen ColorLinen ColorMediumAquamarine ColorMediumBlue ColorMediumOrchid ColorMediumPurple ColorMediumSeaGreen ColorMediumSlateBlue ColorMediumSpringGreen ColorMediumTurquoise ColorMediumVioletRed ColorMidnightBlue ColorMintCream ColorMistyRose ColorMoccasin ColorOldLace ColorOliveDrab ColorOrange ColorOrangeRed ColorOrchid ColorPaleGoldenrod ColorPaleGreen ColorPaleTurquoise ColorPaleVioletRed ColorPapayaWhip ColorPeachPuff ColorPeru ColorPink ColorPlum ColorPowderBlue ColorRebeccaPurple ColorRosyBrown ColorRoyalBlue ColorSaddleBrown ColorSalmon ColorSandyBrown ColorSeaGreen ColorSeashell ColorSienna ColorSkyblue ColorSlateBlue ColorSlateGray ColorSnow ColorSpringGreen ColorSteelBlue ColorTan ColorThistle ColorTomato ColorTurquoise ColorViolet ColorWheat ColorWhiteSmoke ColorYellowGreen )
Note that the order of these options is important -- it follows the definitions used by ECMA and XTerm. Hence any further named colors must begin at a value not less than 256.
const ( ColorGrey = ColorGray ColorDimGrey = ColorDimGray ColorDarkGrey = ColorDarkGray ColorDarkSlateGrey = ColorDarkSlateGray ColorLightGrey = ColorLightGray ColorLightSlateGrey = ColorLightSlateGray ColorSlateGrey = ColorSlateGray )
These are aliases for the color gray, because some of us spell it as grey.
const ( MouseButtonEvents = MouseFlags(1) // Click events only MouseDragEvents = MouseFlags(2) // Click-drag events (includes button events) MouseMotionEvents = MouseFlags(4) // All mouse events (includes click and drag events) )
const ( TypeDisplayManager CTypeTag = "cdk-display-manager" SignalDisplayInit Signal = "display-init" SignalDisplayCaptured Signal = "display-captured" SignalInterrupt Signal = "sigint" SignalEvent Signal = "event" SignalEventError Signal = "event-error" SignalEventKey Signal = "event-key" SignalEventMouse Signal = "event-mouse" SignalEventResize Signal = "event-resize" SignalSetEventFocus Signal = "set-event-focus" )
const ( // EncodingFallbackFail behavior causes GetEncoding to fail // when it cannot find an encoding. EncodingFallbackFail = iota // EncodingFallbackASCII behaviore causes GetEncoding to fall back // to a 7-bit ASCII encoding, if no other encoding can be found. EncodingFallbackASCII // EncodingFallbackUTF8 behavior causes GetEncoding to assume // UTF8 can pass unmodified upon failure. Note that this behavior // is not recommended, unless you are sure your terminal can cope // with real UTF8 sequences. EncodingFallbackUTF8 )
const ( KeyBackspace = KeyBS KeyTab = KeyTAB KeyEsc = KeyESC KeyEscape = KeyESC KeyEnter = KeyCR KeyBackspace2 = KeyDEL )
These keys are aliases for other names.
const ( LevelError string = "error" LevelWarn string = "warn" LevelInfo string = "info" LevelDebug string = "debug" LevelTrace string = "trace" )
const ( FormatPretty string = "pretty" FormatText string = "text" FormatJson string = "json" )
const ( OutputStderr string = "stderr" OutputStdout string = "stdout" OutputFile string = "file" )
const ( TypeMetaData CTypeTag = "cdk-metadata" SignalSetProperty Signal = "set-property" )
const ( RuneSterling = '£' RuneDArrow = '↓' RuneLArrow = '←' RuneRArrow = '→' RuneUArrow = '↑' RuneBullet = '·' RuneBoard = '░' RuneCkBoard = '▒' RuneDegree = '°' RuneDiamond = '◆' RuneGEqual = '≥' RunePi = 'π' RuneHLine = '─' RuneLantern = '§' RunePlus = '┼' RuneLEqual = '≤' RuneLLCorner = '└' RuneLRCorner = '┘' RuneNEqual = '≠' RunePlMinus = '±' RuneS1 = '⎺' RuneS3 = '⎻' RuneS7 = '⎼' RuneS9 = '⎽' RuneBlock = '█' RuneTTee = '┬' RuneRTee = '┤' RuneLTee = '├' RuneBTee = '┴' RuneULCorner = '┌' RuneURCorner = '┐' RuneVLine = '│' // Extra Arrow-Type Things RuneLeftwardsTwoHeadedArrowWithTriangleArrowheads = '⯬' RuneUpwardsTwoHeadedArrowWithTriangleArrowheads = '⯭' RuneRightwardsTwoHeadedArrowWithTriangleArrowheads = '⯮' RuneDownwardsTwoHeadedArrowWithTriangleArrowheads = '⯯' RuneBlackSquareCentred = '⯀' RuneBlackMediumUpPointingTriangleCentred = '⯅' RuneBlackMediumDownPointingTriangleCentred = '⯆' RuneBlackMediumLeftPointingTriangleCentred = '⯇' RuneBlackMediumRightPointingTriangleCentred = '⯈' RuneLeftwardsBlackCircledWhiteArrow = '⮈' RuneUpwardsBlackCircledWhiteArrow = '⮉' RuneRightwardsBlackCircledWhiteArrow = '⮊' RuneDownwardsBlackCircledWhiteArrow = '⮋' // Punctuation, typography RuneEllipsis = '…' )
The names of these constants are chosen to match Terminfo names, modulo case, and changing the prefix from ACS_ to Rune. These are the runes we provide extra special handling for, with ASCII fallbacks for terminals that lack them.
const ( TypeSignaling CTypeTag = "cdk-signaling" SignalSignalingInit Signal = "signaling-init" )
const ( TypeWindow CTypeTag = "cdk-window" SignalDraw Signal = "draw" SignalSetTitle Signal = "set-title" SignalSetDisplay Signal = "set-display" )
const ( // ColorReset is used to indicate that the color should use the // vanilla terminal colors. (Basically go back to the defaults.) ColorReset = ColorSpecial | iota )
Special colors.
const (
DefaultLogTimestampFormat = "2006-01-02T15:04:05.000"
)
const OffscreenDisplayTtyPath = "<offscreen>"
Variables ¶
var ( EventQueueSize = 10 EventKeyQueueSize = 10 EventKeyTiming = time.Millisecond * 50 SignalQueueSize = 10 )
var ( DisplayCallQueueCapacity = 16 DisplayStartupDelay = time.Millisecond * 128 )
var ( // ErrTermNotFound indicates that a suitable terminal entry could // not be found. This can result from either not having TERM set, // or from the TERM failing to support certain minimal functionality, // in particular absolute cursor addressability (the cup capability) // is required. For example, legacy "adm3" lacks this capability, // whereas the slightly newer "adm3a" supports it. This failure // occurs most often with "dumb". ErrTermNotFound = terminfo.ErrTermNotFound // ErrNoDisplay indicates that no suitable display could be found. // This may result from attempting to run on a platform where there // is no support for either termios or console I/O (such as nacl), // or from running in an environment where there is no access to // a suitable console/terminal device. (For example, running on // without a controlling TTY or with no /dev/tty on POSIX platforms.) ErrNoDisplay = errors.New("no suitable display available") // ErrNoCharset indicates that the locale environment the // program is not supported by the program, because no suitable // encoding was found for it. This problem never occurs if // the environment is UTF-8 or UTF-16. ErrNoCharset = errors.New("character set not supported") // ErrEventQFull indicates that the event queue is full, and // cannot accept more events. ErrEventQFull = errors.New("event queue full") )
var ( DefaultFillRune = ' ' DefaultMonoStyle = StyleDefault.Reverse(false).Dim(true) DefaultColorStyle = StyleDefault.Foreground(ColorWhite).Background(ColorNavy) DefaultBorderRune = BorderRuneSet{ TopLeft: RuneULCorner, Top: RuneHLine, TopRight: RuneURCorner, Left: RuneVLine, Right: RuneVLine, BottomLeft: RuneLLCorner, Bottom: RuneHLine, BottomRight: RuneLRCorner, } DefaultArrowRune = ArrowRuneSet{ Up: RuneUArrow, Left: RuneLArrow, Down: RuneDArrow, Right: RuneRArrow, } FancyArrowRune = ArrowRuneSet{ Up: RuneBlackMediumUpPointingTriangleCentred, Left: RuneBlackMediumLeftPointingTriangleCentred, Down: RuneBlackMediumDownPointingTriangleCentred, Right: RuneBlackMediumRightPointingTriangleCentred, } )
var ( DefaultNilTheme = Theme{} DefaultMonoThemeAspect = ThemeAspect{ Normal: DefaultMonoStyle, Focused: DefaultMonoStyle.Dim(false), Active: DefaultMonoStyle.Dim(false).Reverse(true), FillRune: DefaultFillRune, BorderRunes: DefaultBorderRune, ArrowRunes: DefaultArrowRune, Overlay: false, } DefaultColorThemeAspect = ThemeAspect{ Normal: DefaultColorStyle.Dim(true), Focused: DefaultColorStyle.Dim(false), Active: DefaultColorStyle.Dim(false).Reverse(true), FillRune: DefaultFillRune, BorderRunes: DefaultBorderRune, ArrowRunes: DefaultArrowRune, Overlay: false, } DefaultMonoTheme = Theme{ Content: DefaultMonoThemeAspect, Border: DefaultMonoThemeAspect, } DefaultColorTheme = Theme{ Content: DefaultColorThemeAspect, Border: DefaultColorThemeAspect, } )
var Build = Config{ LogFile: true, LogLevel: true, LogLevels: true, }
var ColorNames = map[string]Color{}/* 146 elements not displayed */
ColorNames holds the written names of colors. Useful to present a list of recognized named colors.
var ColorValues = map[Color]int32{}/* 379 elements not displayed */
ColorValues maps color constants to their RGB values.
var (
DefaultGoProfilePath = os.TempDir() + string(os.PathSeparator) + "cdk.pprof"
)
var (
DefaultLogPath = os.TempDir() + string(os.PathSeparator) + "cdk.log"
)
var KeyNames = map[Key]string{}/* 118 elements not displayed */
KeyNames holds the written names of special keys. Useful to echo back a key name, or to look up a key from a string value.
var LogLevels = []string{ LevelError, LevelWarn, LevelInfo, LevelDebug, LevelTrace, }
var (
MOUSE_STATES map[MouseState]string = map[MouseState]string{
MOUSE_NONE: "None",
MOUSE_MOVE: "Move",
BUTTON_PRESS: "Pressed",
BUTTON_RELEASE: "Released",
WHEEL_PULSE: "Impulse",
DRAG_START: "DragStart",
DRAG_MOVE: "DragMove",
DRAG_STOP: "DragStop",
}
)
var RuneFallbacks = map[rune]string{ RuneSterling: "f", RuneDArrow: "v", RuneLArrow: "<", RuneRArrow: ">", RuneUArrow: "^", RuneBullet: "o", RuneBoard: "#", RuneCkBoard: ":", RuneDegree: "\\", RuneDiamond: "+", RuneGEqual: ">", RunePi: "*", RuneHLine: "-", RuneLantern: "#", RunePlus: "+", RuneLEqual: "<", RuneLLCorner: "+", RuneLRCorner: "+", RuneNEqual: "!", RunePlMinus: "#", RuneS1: "~", RuneS3: "-", RuneS7: "-", RuneS9: "_", RuneBlock: "#", RuneTTee: "+", RuneRTee: "+", RuneLTee: "+", RuneBTee: "+", RuneULCorner: "+", RuneURCorner: "+", RuneVLine: "|", RuneLeftwardsTwoHeadedArrowWithTriangleArrowheads: "<", RuneUpwardsTwoHeadedArrowWithTriangleArrowheads: "^", RuneRightwardsTwoHeadedArrowWithTriangleArrowheads: ">", RuneDownwardsTwoHeadedArrowWithTriangleArrowheads: "v", RuneBlackSquareCentred: "#", RuneBlackMediumUpPointingTriangleCentred: "^", RuneBlackMediumDownPointingTriangleCentred: "v", RuneBlackMediumLeftPointingTriangleCentred: "<", RuneBlackMediumRightPointingTriangleCentred: ">", RuneLeftwardsBlackCircledWhiteArrow: "<", RuneUpwardsBlackCircledWhiteArrow: "^", RuneRightwardsBlackCircledWhiteArrow: ">", RuneDownwardsBlackCircledWhiteArrow: "v", RuneEllipsis: "...", }
RuneFallbacks is the default map of fallback strings that will be used to replace a rune when no other more appropriate transformation is available, and the rune cannot be displayed directly.
New entries may be added to this map over time, as it becomes clear that such is desirable. Characters that represent either letters or numbers should not be added to this list unless it is certain that the meaning will still convey unambiguously.
As an example, it would be appropriate to add an ASCII mapping for the full width form of the letter 'A', but it would not be appropriate to do so a glyph representing the country China.
Programs that desire richer fallbacks may register additional ones, or change or even remove these mappings with Display.RegisterRuneFallback Display.UnregisterRuneFallback methods.
Note that Unicode is presumed to be able to display all glyphs. This is a pretty poor assumption, but there is no easy way to figure out which glyphs are supported in a given font. Hence, some care in selecting the characters you support in your application is still appropriate.
var (
TapSpace = " "
)
var (
TypesManager = NewTypeRegistry()
)
Functions ¶
func AddTimeout ¶
func AddTimeout(d time.Duration, fn TimerCallbackFn) (id int)
func CancelTimeout ¶
func DescribeButton ¶
func DescribeButton(button ButtonMask) string
func DidFakeExit ¶
func DidFakeExit() bool
func FakeExiting ¶
func FakeExiting()
func GetCharset ¶
func GetCharset() string
func GetEncoding ¶
GetEncoding is used by Display implementors who want to locate an encoding for the given character set name. Note that this will return nil for either the Unicode (UTF-8) or ASCII encodings, since we don't use encodings for them but instead have our own native methods.
func GetLastFakeIO ¶
func ListEncodings ¶
func ListEncodings() []string
func LookupKeyName ¶ added in v0.0.5
func QuarkToString ¶ added in v0.0.5
Gets the string associated with the given GQuark.
Parameters:
quark a GQuark.
Returns:
the string associated with the GQuark
func RegisterEncoding ¶
RegisterEncoding may be called by the application to register an encoding. The presence of additional encodings will facilitate application usage with terminal environments where the I/O subsystem does not support Unicode.
Windows systems use Unicode natively, and do not need any of the encoding subsystem when using Windows Console screens.
Please see the Go documentation for golang.org/x/text/encoding -- most of the common ones exist already as stock variables. For example, ISO8859-15 can be registered using the following code:
import "golang.org/x/text/encoding/charmap" ... RegisterEncoding("ISO8859-15", charmap.ISO8859_15)
Aliases can be registered as well, for example "8859-15" could be an alias for "ISO8859-15".
For POSIX systems, the cdk package will check the environment variables LC_ALL, LC_CTYPE, and LANG (in that order) to determine the character set. These are expected to have the following pattern:
$language[.$codeset[@$variant]
We extract only the $codeset part, which will usually be something like UTF-8 or ISO8859-15 or KOI8-R. Note that if the locale is either "POSIX" or "C", then we assume US-ASCII (the POSIX 'portable character set' and assume all other characters are somehow invalid.)
Modern POSIX systems and terminal emulators may use UTF-8, and for those systems, this API is also unnecessary. For example, Darwin (MacOS X) and modern Linux running modern xterm generally will out of the box without any of this. Use of UTF-8 is recommended when possible, as it saves quite a lot processing overhead.
Note that some encodings are quite large (for example GB18030 which is a superset of Unicode) and so the application size can be expected ot increase quite a bit as each encoding is added. The East Asian encodings have been seen to add 100-200K per encoding to the application size.
func ReloadLogging ¶
func ReloadLogging() error
func ResetFakeExited ¶
func ResetFakeExited()
func RestoreExiting ¶
func RestoreExiting()
func SetCurrentTheme ¶ added in v0.0.4
func SetCurrentTheme(theme Theme)
func SetEncodingFallback ¶
func SetEncodingFallback(fb EncodingFallback)
SetEncodingFallback changes the behavior of GetEncoding when a suitable encoding is not found. The default is EncodingFallbackFail, which causes GetEncoding to simply return nil.
func StopLogging ¶
func StopLogging() error
func TestingMakesActiveWindow ¶
func TestingMakesActiveWindow(d DisplayManager) error
func TestingMakesNoContent ¶
func TestingMakesNoContent(d DisplayManager) error
func UnregisterEncoding ¶
func UnregisterEncoding(charset string)
func WithApp ¶
func WithApp(initFn DisplayInitFn, action AppFn) func()
func WithDisplayManager ¶
func WithDisplayManager(action DisplayManagerFn) func()
Types ¶
type ArrowRuneSet ¶ added in v0.0.4
func (ArrowRuneSet) String ¶ added in v0.0.4
func (b ArrowRuneSet) String() string
type AttrMask ¶
type AttrMask int
AttrMask represents a mask of text attributes, apart from color. Note that support for attributes may vary widely across terminals.
const ( AttrBold AttrMask = 1 << iota AttrBlink AttrReverse AttrUnderline AttrDim AttrItalic AttrStrikeThrough AttrInvalid // Mark the style or attributes invalid AttrNone AttrMask = 0 // Just normal text. )
Attributes are not colors, but affect the display of text. They can be combined.
func (AttrMask) IsUnderline ¶
check if the attributes include underline
type Border ¶ added in v0.0.5
type BorderRuneSet ¶ added in v0.0.4
type BorderRuneSet struct { TopLeft rune Top rune TopRight rune Left rune Right rune BottomLeft rune Bottom rune BottomRight rune }
func (BorderRuneSet) String ¶ added in v0.0.4
func (b BorderRuneSet) String() string
type ButtonMask ¶
type ButtonMask int16
ButtonMask is a mask of mouse buttons and wheel events. Mouse button presses are normally delivered as both press and release events. Mouse wheel events are normally just single impulse events. Windows supports up to eight separate buttons plus all four wheel directions, but XTerm can only support mouse buttons 1-3 and wheel up/down. Its not unheard of for terminals to support only one or two buttons (think Macs). Old terminals, and true emulations (such as vt100) won't support mice at all, of course.
const ( Button1 ButtonMask = 1 << iota // Usually left mouse button. Button2 // Usually the middle mouse button. Button3 // Usually the right mouse button. Button4 // Often a side button (thumb/next). Button5 // Often a side button (thumb/prev). Button6 Button7 Button8 WheelUp // Wheel motion up/away from user. WheelDown // Wheel motion down/towards user. WheelLeft // Wheel motion to left. WheelRight // Wheel motion to right. LastButtonMask // Highest mask value ButtonNone ButtonMask = 0 // No button or wheel events. ButtonPrimary = Button1 ButtonSecondary = Button2 ButtonMiddle = Button3 )
These are the actual button values. Note that tcell version 1.x reversed buttons two and three on *nix based terminals. We use button 1 as the primary, and button 2 as the secondary, and button 3 (which is often missing) as the middle.
func (ButtonMask) Clear ¶
func (i ButtonMask) Clear(m ButtonMask) ButtonMask
return a button mask with the given flags cleared, does not modify itself
func (ButtonMask) Has ¶
func (i ButtonMask) Has(m ButtonMask) bool
check if the mask has the given flag(s)
func (ButtonMask) Set ¶
func (i ButtonMask) Set(m ButtonMask) ButtonMask
return a button mask with the given flags set, does not modify itself
func (ButtonMask) String ¶
func (i ButtonMask) String() string
func (ButtonMask) Toggle ¶
func (i ButtonMask) Toggle(m ButtonMask) ButtonMask
return a button mask with the give flags reversed, does not modify itself
type CApp ¶
type CApp struct {
// contains filtered or unexported fields
}
func NewApp ¶
func NewApp(name, usage, version, tag, title, ttyPath string, initFn DisplayInitFn) *CApp
func (*CApp) AddCommand ¶
func (app *CApp) AddCommand(command *cli.Command)
func (*CApp) AddCommands ¶ added in v0.0.5
func (app *CApp) AddCommands(commands []*cli.Command)
func (*CApp) DisplayManager ¶
func (app *CApp) DisplayManager() DisplayManager
func (*CApp) GetContext ¶
func (app *CApp) GetContext() *cli.Context
func (*CApp) MainActionFn ¶
type CCanvas ¶
type CCanvas struct {
// contains filtered or unexported fields
}
concrete implementation of the Canvas interface
func (*CCanvas) Box ¶
func (c *CCanvas) Box(pos Point2I, size Rectangle, border, fill, overlay bool, fillRune rune, contentStyle, borderStyle Style, borderRunes BorderRuneSet)
draw a box, at position, of size, with or without a border, with or without being filled in and following the given theme
func (*CCanvas) BoxWithTheme ¶ added in v0.0.4
func (*CCanvas) Composite ¶
apply the given canvas to this canvas, at the given one's origin. returns an error if the underlying buffer write failed or if the given canvas is beyond the bounds of this canvas
func (*CCanvas) DebugBox ¶
draw a box with Sprintf-formatted text along the top-left of the box, useful for debugging more than anything else as the normal draw primitives are far more flexible
func (*CCanvas) DrawHorizontalLine ¶
convenience method to draw a horizontal line
func (*CCanvas) DrawLine ¶
func (c *CCanvas) DrawLine(pos Point2I, length int, orient Orientation, style Style)
draw a line vertically or horizontally with the given style
func (*CCanvas) DrawSingleLineText ¶
func (c *CCanvas) DrawSingleLineText(position Point2I, maxChars int, ellipsize bool, justify Justification, style Style, markup, mnemonic bool, text string)
write a single line of text to the canvas at the given position, of at most maxChars, with the text justified and styled. supports Tango markup content
func (*CCanvas) DrawText ¶
func (c *CCanvas) DrawText(pos Point2I, size Rectangle, justify Justification, singleLineMode bool, wrap WrapMode, ellipsize bool, style Style, markup, mnemonic bool, text string)
Write text to the canvas buffer origin is the top-left coordinate for the text area being rendered alignment is based on origin.X boxed by maxChars or canvas size.W
func (*CCanvas) DrawVerticalLine ¶
convenience method to draw a vertical line
func (*CCanvas) Equals ¶
returns true if the given canvas is painted the same as this one, can compare for only cells that were "set" (dirty) or compare every cell of the two canvases
func (*CCanvas) FillBorder ¶
fill the entire canvas, with or without 'dim' styling, with or without a border
func (*CCanvas) FillBorderTitle ¶
func (c *CCanvas) FillBorderTitle(dim bool, title string, justify Justification, theme Theme)
fill the entire canvas, with or without 'dim' styling, with plain text justified across the top border
func (*CCanvas) ForEach ¶
func (c *CCanvas) ForEach(fn CanvasForEachFn) EventFlag
convenience method to iterate of each cell of the canvas, if the given fn returns EVENT_STOP then the iteration is halted, otherwise EVEN_PASS will allow for the next iteration to proceed
func (*CCanvas) GetContent ¶
get the text cell at the given coordinates
func (*CCanvas) SetContent ¶
from the given string, set the character and style of the cell at the given coordinates. note that only the first UTF-8 byte is used
func (*CCanvas) SetOrigin ¶
set the origin (top-left corner) position of the canvas, used when compositing one canvas with another
type CCanvasBuffer ¶
concrete implementation of the CanvasBuffer interface
func (*CCanvasBuffer) Cell ¶
func (b *CCanvasBuffer) Cell(x int, y int) TextCell
return the text cell at the given coordinates, nil if not found
func (*CCanvasBuffer) GetBgColor ¶
func (b *CCanvasBuffer) GetBgColor(x, y int) (bg Color)
return the background color at the given coordinates
func (*CCanvasBuffer) GetContent ¶
func (b *CCanvasBuffer) GetContent(x, y int) (textCell TextCell)
convenience method, returns the results of calling Cell() with the given coordinates
func (*CCanvasBuffer) GetDim ¶
func (b *CCanvasBuffer) GetDim(x, y int) bool
return true if the given coordinates are styled 'dim', false otherwise
func (*CCanvasBuffer) Height ¶
func (b *CCanvasBuffer) Height() (height int)
return just the height of the buffer
func (*CCanvasBuffer) LoadData ¶
func (b *CCanvasBuffer) LoadData(d [][]TextCell)
given matrix array of text cells, load that data in this canvas space
func (*CCanvasBuffer) Resize ¶
func (b *CCanvasBuffer) Resize(size Rectangle, style Style)
resize the buffer
func (*CCanvasBuffer) SetContent ¶
set the cell content at the given coordinates
func (*CCanvasBuffer) Size ¶
func (b *CCanvasBuffer) Size() (size Rectangle)
return the rectangle size of the buffer
func (*CCanvasBuffer) String ¶
func (b *CCanvasBuffer) String() string
return a string describing the buffer, only useful for debugging purposes
func (*CCanvasBuffer) Style ¶ added in v0.0.4
func (b *CCanvasBuffer) Style() (style Style)
return the rectangle size of the buffer
func (*CCanvasBuffer) Width ¶
func (b *CCanvasBuffer) Width() (width int)
return just the width of the buffer
type CDisplayManager ¶
type CDisplayManager struct { CObject // contains filtered or unexported fields }
Basic display type
func NewDisplayManager ¶
func NewDisplayManager(title string, ttyPath string) *CDisplayManager
func (*CDisplayManager) ActiveWindow ¶
func (d *CDisplayManager) ActiveWindow() Window
func (*CDisplayManager) AddQuitHandler ¶ added in v0.0.5
func (d *CDisplayManager) AddQuitHandler(tag string, fn func())
func (*CDisplayManager) AddWindow ¶
func (d *CDisplayManager) AddWindow(w Window)
func (*CDisplayManager) AddWindowOverlay ¶ added in v0.0.5
func (d *CDisplayManager) AddWindowOverlay(pid int, overlay Window, region Region)
func (*CDisplayManager) App ¶
func (d *CDisplayManager) App() *CApp
func (*CDisplayManager) AsyncCall ¶
func (d *CDisplayManager) AsyncCall(fn DisplayCallbackFn) error
func (*CDisplayManager) AwaitCall ¶
func (d *CDisplayManager) AwaitCall(fn DisplayCallbackFn) error
func (*CDisplayManager) CaptureCtrlC ¶
func (d *CDisplayManager) CaptureCtrlC()
func (*CDisplayManager) CaptureDisplay ¶
func (d *CDisplayManager) CaptureDisplay(ttyPath string)
func (*CDisplayManager) Colors ¶
func (d *CDisplayManager) Colors() (numberOfColors int)
func (*CDisplayManager) DefaultTheme ¶
func (d *CDisplayManager) DefaultTheme() Theme
func (*CDisplayManager) Destroy ¶
func (d *CDisplayManager) Destroy()
func (*CDisplayManager) Display ¶
func (d *CDisplayManager) Display() Display
func (*CDisplayManager) DisplayCaptured ¶
func (d *CDisplayManager) DisplayCaptured() bool
func (*CDisplayManager) DrawScreen ¶
func (d *CDisplayManager) DrawScreen() EventFlag
func (*CDisplayManager) GetEventFocus ¶ added in v0.0.5
func (d *CDisplayManager) GetEventFocus() (widget interface{})
func (*CDisplayManager) GetPriorEvent ¶ added in v0.0.5
func (d *CDisplayManager) GetPriorEvent() (event Event)
func (*CDisplayManager) GetTitle ¶
func (d *CDisplayManager) GetTitle() string
func (*CDisplayManager) GetTtyPath ¶
func (d *CDisplayManager) GetTtyPath() string
func (*CDisplayManager) GetWindowOverlayRegion ¶ added in v0.0.5
func (d *CDisplayManager) GetWindowOverlayRegion(windowId, overlayId int) (region Region)
func (*CDisplayManager) GetWindowOverlays ¶ added in v0.0.5
func (d *CDisplayManager) GetWindowOverlays(windowId int) (windows []Window)
func (*CDisplayManager) GetWindowTopOverlay ¶ added in v0.0.5
func (d *CDisplayManager) GetWindowTopOverlay(windowId int) (window Window)
func (*CDisplayManager) GetWindows ¶
func (d *CDisplayManager) GetWindows() (windows []Window)
func (*CDisplayManager) Init ¶
func (d *CDisplayManager) Init() (already bool)
func (*CDisplayManager) IsMonochrome ¶
func (d *CDisplayManager) IsMonochrome() bool
func (*CDisplayManager) IsRunning ¶
func (d *CDisplayManager) IsRunning() bool
func (*CDisplayManager) PostEvent ¶
func (d *CDisplayManager) PostEvent(evt Event) error
func (*CDisplayManager) ProcessEvent ¶
func (d *CDisplayManager) ProcessEvent(evt Event) EventFlag
func (*CDisplayManager) ReleaseCtrlC ¶
func (d *CDisplayManager) ReleaseCtrlC()
func (*CDisplayManager) ReleaseDisplay ¶
func (d *CDisplayManager) ReleaseDisplay()
func (*CDisplayManager) RemoveQuitHandler ¶ added in v0.0.5
func (d *CDisplayManager) RemoveQuitHandler(tag string)
func (*CDisplayManager) RemoveWindow ¶ added in v0.0.5
func (d *CDisplayManager) RemoveWindow(wid int)
func (*CDisplayManager) RemoveWindowOverlay ¶ added in v0.0.5
func (d *CDisplayManager) RemoveWindowOverlay(pid int, oid int)
func (*CDisplayManager) RequestDraw ¶
func (d *CDisplayManager) RequestDraw()
func (*CDisplayManager) RequestQuit ¶
func (d *CDisplayManager) RequestQuit()
func (*CDisplayManager) RequestShow ¶
func (d *CDisplayManager) RequestShow()
func (*CDisplayManager) RequestSync ¶
func (d *CDisplayManager) RequestSync()
func (*CDisplayManager) Run ¶
func (d *CDisplayManager) Run() error
func (*CDisplayManager) SetActiveWindow ¶
func (d *CDisplayManager) SetActiveWindow(w Window)
func (*CDisplayManager) SetEventFocus ¶ added in v0.0.5
func (d *CDisplayManager) SetEventFocus(widget interface{}) error
func (*CDisplayManager) SetTitle ¶
func (d *CDisplayManager) SetTitle(title string)
func (*CDisplayManager) SetTtyPath ¶
func (d *CDisplayManager) SetTtyPath(ttyPath string)
func (*CDisplayManager) SetWindowOverlayRegion ¶ added in v0.0.5
func (d *CDisplayManager) SetWindowOverlayRegion(windowId, overlayId int, region Region)
type CMetaData ¶ added in v0.0.5
type CMetaData struct { CSignaling // contains filtered or unexported fields }
func (*CMetaData) GetBoolProperty ¶ added in v0.0.5
func (*CMetaData) GetColorProperty ¶ added in v0.0.5
func (*CMetaData) GetFloat64Property ¶ added in v0.0.5
func (*CMetaData) GetFloatProperty ¶ added in v0.0.5
func (*CMetaData) GetIntProperty ¶ added in v0.0.5
func (*CMetaData) GetPointProperty ¶ added in v0.0.5
func (*CMetaData) GetProperty ¶ added in v0.0.5
func (*CMetaData) GetRectangleProperty ¶ added in v0.0.5
func (*CMetaData) GetRegionProperty ¶ added in v0.0.5
func (*CMetaData) GetStringProperty ¶ added in v0.0.5
func (*CMetaData) GetStructProperty ¶ added in v0.0.5
func (*CMetaData) GetStyleProperty ¶ added in v0.0.5
func (*CMetaData) GetThemeProperty ¶ added in v0.0.5
func (*CMetaData) InstallBuildableProperty ¶ added in v0.0.5
func (o *CMetaData) InstallBuildableProperty(name Property, kind PropertyType, write bool, def interface{}) error
func (*CMetaData) InstallProperty ¶ added in v0.0.5
func (o *CMetaData) InstallProperty(name Property, kind PropertyType, write bool, def interface{}) error
func (*CMetaData) IsBuildableProperty ¶ added in v0.0.5
func (*CMetaData) IsProperty ¶ added in v0.0.5
func (*CMetaData) ListBuildableProperties ¶ added in v0.0.5
func (*CMetaData) ListProperties ¶ added in v0.0.5
func (*CMetaData) OverloadProperty ¶ added in v0.0.5
func (*CMetaData) SetBoolProperty ¶ added in v0.0.5
func (*CMetaData) SetColorProperty ¶ added in v0.0.5
func (*CMetaData) SetFloatProperty ¶ added in v0.0.5
func (*CMetaData) SetIntProperty ¶ added in v0.0.5
func (*CMetaData) SetPointProperty ¶ added in v0.0.5
func (*CMetaData) SetProperties ¶ added in v0.0.5
func (*CMetaData) SetProperty ¶ added in v0.0.5
func (*CMetaData) SetPropertyFromString ¶ added in v0.0.5
func (*CMetaData) SetRectangleProperty ¶ added in v0.0.5
func (*CMetaData) SetRegionProperty ¶ added in v0.0.5
func (*CMetaData) SetStringProperty ¶ added in v0.0.5
func (*CMetaData) SetStructProperty ¶ added in v0.0.5
func (*CMetaData) SetStyleProperty ¶ added in v0.0.5
type CObject ¶
type CObject struct {
CMetaData
}
func (*CObject) GetThemeRequest ¶ added in v0.0.4
func (*CObject) InitWithProperties ¶ added in v0.0.5
func (*CObject) SetThemeRequest ¶ added in v0.0.4
type COffscreenDisplay ¶
func (*COffscreenDisplay) Beep ¶
func (o *COffscreenDisplay) Beep() error
func (*COffscreenDisplay) CanDisplay ¶
func (o *COffscreenDisplay) CanDisplay(r rune, checkFallbacks bool) bool
func (*COffscreenDisplay) CharacterSet ¶
func (o *COffscreenDisplay) CharacterSet() string
func (*COffscreenDisplay) Clear ¶
func (o *COffscreenDisplay) Clear()
func (*COffscreenDisplay) Close ¶
func (o *COffscreenDisplay) Close()
func (*COffscreenDisplay) Colors ¶
func (o *COffscreenDisplay) Colors() int
func (*COffscreenDisplay) DisableMouse ¶
func (o *COffscreenDisplay) DisableMouse()
func (*COffscreenDisplay) DisablePaste ¶
func (o *COffscreenDisplay) DisablePaste()
func (*COffscreenDisplay) EnableMouse ¶
func (o *COffscreenDisplay) EnableMouse(_ ...MouseFlags)
func (*COffscreenDisplay) EnablePaste ¶
func (o *COffscreenDisplay) EnablePaste()
func (*COffscreenDisplay) Export ¶
func (o *COffscreenDisplay) Export() *CellBuffer
func (*COffscreenDisplay) Fill ¶
func (o *COffscreenDisplay) Fill(r rune, style Style)
func (*COffscreenDisplay) GetContent ¶
func (*COffscreenDisplay) GetContents ¶
func (o *COffscreenDisplay) GetContents() ([]OffscreenCell, int, int)
func (*COffscreenDisplay) HasKey ¶
func (o *COffscreenDisplay) HasKey(Key) bool
func (*COffscreenDisplay) HasMouse ¶
func (o *COffscreenDisplay) HasMouse() bool
func (*COffscreenDisplay) HideCursor ¶
func (o *COffscreenDisplay) HideCursor()
func (*COffscreenDisplay) Import ¶
func (o *COffscreenDisplay) Import(cb *CellBuffer)
func (*COffscreenDisplay) Init ¶
func (o *COffscreenDisplay) Init() error
func (*COffscreenDisplay) InjectKey ¶
func (o *COffscreenDisplay) InjectKey(key Key, r rune, mod ModMask)
func (*COffscreenDisplay) InjectKeyBytes ¶
func (o *COffscreenDisplay) InjectKeyBytes(b []byte) bool
func (*COffscreenDisplay) InjectMouse ¶
func (o *COffscreenDisplay) InjectMouse(x, y int, buttons ButtonMask, mod ModMask)
func (*COffscreenDisplay) PollEvent ¶
func (o *COffscreenDisplay) PollEvent() Event
func (*COffscreenDisplay) PostEvent ¶
func (o *COffscreenDisplay) PostEvent(ev Event) error
func (*COffscreenDisplay) PostEventWait ¶
func (o *COffscreenDisplay) PostEventWait(ev Event)
func (*COffscreenDisplay) RegisterRuneFallback ¶
func (o *COffscreenDisplay) RegisterRuneFallback(r rune, subst string)
func (*COffscreenDisplay) SetCell ¶
func (o *COffscreenDisplay) SetCell(x, y int, style Style, ch ...rune)
func (*COffscreenDisplay) SetContent ¶
func (o *COffscreenDisplay) SetContent(x, y int, mc rune, comb []rune, st Style)
func (*COffscreenDisplay) SetSize ¶
func (o *COffscreenDisplay) SetSize(w, h int)
func (*COffscreenDisplay) SetStyle ¶
func (o *COffscreenDisplay) SetStyle(style Style)
func (*COffscreenDisplay) Show ¶
func (o *COffscreenDisplay) Show()
func (*COffscreenDisplay) ShowCursor ¶
func (o *COffscreenDisplay) ShowCursor(x, y int)
func (*COffscreenDisplay) Size ¶
func (o *COffscreenDisplay) Size() (w, h int)
func (*COffscreenDisplay) Sync ¶
func (o *COffscreenDisplay) Sync()
func (*COffscreenDisplay) UnregisterRuneFallback ¶
func (o *COffscreenDisplay) UnregisterRuneFallback(r rune)
type COffscreenWindow ¶
type COffscreenWindow struct { CObject // contains filtered or unexported fields }
Basic window type
func (*COffscreenWindow) Draw ¶
func (w *COffscreenWindow) Draw(canvas Canvas) EventFlag
func (*COffscreenWindow) GetDisplayManager ¶
func (w *COffscreenWindow) GetDisplayManager() DisplayManager
func (*COffscreenWindow) GetTitle ¶
func (w *COffscreenWindow) GetTitle() string
func (*COffscreenWindow) Init ¶
func (w *COffscreenWindow) Init() bool
func (*COffscreenWindow) ProcessEvent ¶
func (w *COffscreenWindow) ProcessEvent(evt Event) EventFlag
func (*COffscreenWindow) SetDisplayManager ¶
func (w *COffscreenWindow) SetDisplayManager(d DisplayManager)
func (*COffscreenWindow) SetTitle ¶
func (w *COffscreenWindow) SetTitle(title string)
type CProperty ¶ added in v0.0.5
type CProperty struct {
// contains filtered or unexported fields
}
func NewProperty ¶ added in v0.0.5
func NewProperty(name Property, kind PropertyType, write bool, buildable bool, def interface{}) (property *CProperty)
func (*CProperty) SetFromString ¶ added in v0.0.5
func (*CProperty) Type ¶ added in v0.0.5
func (p *CProperty) Type() PropertyType
type CQuark ¶ added in v0.0.5
type CQuark struct {
// contains filtered or unexported fields
}
Quarks are associations between strings and integer identifiers. Given either the string or the QuarkID identifier it is possible to retrieve the other.
Quarks are used for both datasets and keyed data lists.
To create a new quark from a string, use QuarkFromString().
To find the string corresponding to a given QuarkID, use QuarkID.ToString().
To find the QuarkID corresponding to a given string, use QuarkID.TryString().
type CSignalListener ¶
type CSignalListener struct {
// contains filtered or unexported fields
}
type CSignaling ¶
type CSignaling struct { CTypeItem // contains filtered or unexported fields }
func (*CSignaling) Connect ¶
func (o *CSignaling) Connect(signal Signal, handle string, c SignalListenerFn, data ...interface{})
Connect callback to signal, identified by handle
func (*CSignaling) Disconnect ¶
func (o *CSignaling) Disconnect(signal Signal, handle string) error
Disconnect callback from signal identified by handle
func (*CSignaling) Emit ¶
func (o *CSignaling) Emit(signal Signal, argv ...interface{}) EventFlag
Emit a signal event to all connected listener callbacks
func (*CSignaling) Freeze ¶ added in v0.0.5
func (o *CSignaling) Freeze()
func (*CSignaling) Handled ¶ added in v0.0.5
func (o *CSignaling) Handled(signal Signal, handle string) (found bool)
func (*CSignaling) Init ¶
func (o *CSignaling) Init() (already bool)
func (*CSignaling) IsFrozen ¶ added in v0.0.5
func (o *CSignaling) IsFrozen() bool
func (*CSignaling) IsSignalPassed ¶
func (o *CSignaling) IsSignalPassed(signal Signal) bool
func (*CSignaling) IsSignalStopped ¶
func (o *CSignaling) IsSignalStopped(signal Signal) bool
func (*CSignaling) PassSignal ¶
func (o *CSignaling) PassSignal(signal Signal)
func (*CSignaling) ResumeSignal ¶
func (o *CSignaling) ResumeSignal(signal Signal)
Enable propagation of the given signal
func (*CSignaling) StopSignal ¶
func (o *CSignaling) StopSignal(signal Signal)
Disable propagation of the given signal
func (*CSignaling) Thaw ¶ added in v0.0.5
func (o *CSignaling) Thaw()
type CTango ¶
type CTango struct {
// contains filtered or unexported fields
}
func (*CTango) TextBuffer ¶
func (m *CTango) TextBuffer(mnemonic bool) TextBuffer
type CTextBuffer ¶
func (*CTextBuffer) CharacterCount ¶
func (b *CTextBuffer) CharacterCount() (cellCount int)
func (*CTextBuffer) ClearText ¶ added in v0.0.5
func (b *CTextBuffer) ClearText(wordWrap WrapMode, ellipsize bool, justify Justification, maxChars int) (plain string)
func (*CTextBuffer) Draw ¶
func (b *CTextBuffer) Draw(canvas Canvas, singleLine bool, wordWrap WrapMode, ellipsize bool, justify Justification, vAlign VerticalAlignment) EventFlag
func (*CTextBuffer) Input ¶ added in v0.0.5
func (b *CTextBuffer) Input() (raw string)
func (*CTextBuffer) Mnemonic ¶ added in v0.0.5
func (b *CTextBuffer) Mnemonic() (enabled bool)
func (*CTextBuffer) PlainText ¶ added in v0.0.4
func (b *CTextBuffer) PlainText(wordWrap WrapMode, ellipsize bool, justify Justification, maxChars int) (plain string)
func (*CTextBuffer) PlainTextInfo ¶ added in v0.0.4
func (b *CTextBuffer) PlainTextInfo(wordWrap WrapMode, ellipsize bool, justify Justification, maxChars int) (longestLine, lineCount int)
func (*CTextBuffer) Set ¶
func (b *CTextBuffer) Set(input string, style Style)
func (*CTextBuffer) SetInput ¶
func (b *CTextBuffer) SetInput(input WordLine)
func (*CTextBuffer) SetMnemonic ¶ added in v0.0.5
func (b *CTextBuffer) SetMnemonic(enabled bool)
func (*CTextBuffer) SetStyle ¶ added in v0.0.4
func (b *CTextBuffer) SetStyle(style Style)
func (*CTextBuffer) Style ¶
func (b *CTextBuffer) Style() Style
func (*CTextBuffer) WordCount ¶
func (b *CTextBuffer) WordCount() (wordCount int)
type CTypeItem ¶
func (*CTypeItem) DestroyObject ¶
func (*CTypeItem) GetTypeTag ¶
func (*CTypeItem) InitTypeItem ¶
func (*CTypeItem) ObjectName ¶
type CTypeItemList ¶
type CTypeItemList []TypeItem
func (CTypeItemList) Index ¶
func (t CTypeItemList) Index(item TypeItem) int
type CTypeRegistry ¶
func (*CTypeRegistry) AddType ¶
func (r *CTypeRegistry) AddType(tag TypeTag, constructor func() interface{}, aliases ...string) error
func (*CTypeRegistry) AddTypeAlias ¶ added in v0.0.5
func (r *CTypeRegistry) AddTypeAlias(tag TypeTag, aliases ...string)
func (*CTypeRegistry) AddTypeItem ¶
func (r *CTypeRegistry) AddTypeItem(tag TypeTag, item interface{}) (id int, err error)
func (*CTypeRegistry) GetBuildableInfo ¶ added in v0.0.5
func (r *CTypeRegistry) GetBuildableInfo() (info map[string]TypeTag)
func (*CTypeRegistry) GetNextID ¶ added in v0.0.5
func (r *CTypeRegistry) GetNextID() (id int)
func (*CTypeRegistry) GetTypeItemByID ¶ added in v0.0.5
func (r *CTypeRegistry) GetTypeItemByID(id int) interface{}
func (*CTypeRegistry) GetTypeItemByName ¶ added in v0.0.5
func (r *CTypeRegistry) GetTypeItemByName(name string) interface{}
func (*CTypeRegistry) GetTypeItems ¶
func (r *CTypeRegistry) GetTypeItems(tag TypeTag) []interface{}
func (*CTypeRegistry) GetTypeTagByAlias ¶ added in v0.0.5
func (r *CTypeRegistry) GetTypeTagByAlias(alias string) (tt TypeTag, ok bool)
func (*CTypeRegistry) GetTypeTags ¶ added in v0.0.5
func (r *CTypeRegistry) GetTypeTags() (tags []TypeTag)
func (*CTypeRegistry) HasID ¶ added in v0.0.5
func (r *CTypeRegistry) HasID(index int) bool
func (*CTypeRegistry) HasType ¶
func (r *CTypeRegistry) HasType(tag TypeTag) (exists bool)
func (*CTypeRegistry) MakeType ¶ added in v0.0.5
func (r *CTypeRegistry) MakeType(tag TypeTag) (thing interface{}, err error)
func (*CTypeRegistry) RemoveTypeItem ¶
func (r *CTypeRegistry) RemoveTypeItem(tag TypeTag, item TypeItem) error
type CTypeTag ¶
type CTypeTag string
denotes a concrete type identity
const (
TypeNil CTypeTag = ""
)
const TypeObject CTypeTag = "cdk-object"
const (
TypeOffscreenWindow CTypeTag = "cdk-offscreen-window"
)
func (CTypeTag) ClassName ¶ added in v0.0.5
returns the CamelCase, or "Class Name", version of this type tag
func (CTypeTag) Equals ¶ added in v0.0.5
returns true if the given type tag is the same as this type tag
func (CTypeTag) GladeString ¶ added in v0.0.5
returns a string representation of this type tag, translated for Gtk class naming conventions (ie: GtkCamelCase)
type CWindow ¶
type CWindow struct { CObject // contains filtered or unexported fields }
Basic window type
func (*CWindow) GetDisplayManager ¶
func (w *CWindow) GetDisplayManager() DisplayManager
func (*CWindow) ProcessEvent ¶
func (*CWindow) SetDisplayManager ¶
func (w *CWindow) SetDisplayManager(d DisplayManager)
type CWordCell ¶
type CWordCell struct {
// contains filtered or unexported fields
}
func (*CWordCell) AppendRune ¶
func (*CWordCell) Characters ¶
func (*CWordCell) CompactLen ¶
same as `Len()` with space-words being treated as 1 character wide rather than the literal number of spaces from the input string
func (*CWordCell) GetCharacter ¶
type CWordLine ¶
type CWordLine struct {
// contains filtered or unexported fields
}
func (*CWordLine) AppendWord ¶
func (*CWordLine) AppendWordCell ¶
func (*CWordLine) AppendWordRune ¶
func (*CWordLine) CharacterCount ¶
func (*CWordLine) GetCharacter ¶
func (*CWordLine) Make ¶
func (w *CWordLine) Make(mnemonic bool, wrap WrapMode, ellipsize bool, justify Justification, maxChars int, fillerStyle Style) (formatted []WordLine)
wrap, justify and align the set input, with filler style
func (*CWordLine) RemoveWord ¶
func (*CWordLine) SetCharacter ¶ added in v0.0.4
type CWordLineCache ¶ added in v0.0.4
type CWordLineCache struct {
// contains filtered or unexported fields
}
func NewWordPageCache ¶ added in v0.0.4
func NewWordPageCache() (wpc *CWordLineCache)
func (*CWordLineCache) Clear ¶ added in v0.0.4
func (c *CWordLineCache) Clear()
func (*CWordLineCache) Hit ¶ added in v0.0.4
func (c *CWordLineCache) Hit(tag string, fn WordLineCacheFn) (lines []WordLine)
type Canvas ¶
type Canvas interface { String() string Resize(size Rectangle, style Style) GetContent(x, y int) (textCell TextCell) SetContent(x, y int, char string, s Style) error SetRune(x, y int, r rune, s Style) error SetOrigin(origin Point2I) GetOrigin() Point2I GetSize() Rectangle Width() (width int) Height() (height int) Equals(onlyDirty bool, v Canvas) bool Composite(v Canvas) error Render(display Display) error ForEach(fn CanvasForEachFn) EventFlag DrawText(pos Point2I, size Rectangle, justify Justification, singleLineMode bool, wrap WrapMode, ellipsize bool, style Style, markup, mnemonic bool, text string) DrawSingleLineText(position Point2I, maxChars int, ellipsize bool, justify Justification, style Style, markup, mnemonic bool, text string) DrawLine(pos Point2I, length int, orient Orientation, style Style) DrawHorizontalLine(pos Point2I, length int, style Style) DrawVerticalLine(pos Point2I, length int, style Style) Box(pos Point2I, size Rectangle, border, fill, overlay bool, fillRune rune, contentStyle, borderStyle Style, borderRunes BorderRuneSet) BoxWithTheme(pos Point2I, size Rectangle, border, fill bool, theme Theme) DebugBox(color Color, format string, argv ...interface{}) Fill(theme Theme) FillBorder(dim, border bool, theme Theme) FillBorderTitle(dim bool, title string, justify Justification, theme Theme) }
a Canvas is the primary means of drawing to the terminal display within CDK
type CanvasBuffer ¶
type CanvasBuffer interface { String() string Style() (style Style) Size() (size Rectangle) Width() (width int) Height() (height int) Resize(size Rectangle, style Style) Cell(x int, y int) TextCell GetDim(x, y int) bool GetBgColor(x, y int) (bg Color) GetContent(x, y int) (textCell TextCell) SetContent(x int, y int, r rune, style Style) error LoadData(d [][]TextCell) sync.Locker }
provide an underlying buffer for Canvases
func NewCanvasBuffer ¶
func NewCanvasBuffer(size Rectangle, style Style) CanvasBuffer
construct a new canvas buffer
type CanvasForEachFn ¶
func signature used when iterating over each cell
type CellBuffer ¶
CellBuffer represents a two dimensional array of character cells. This is primarily intended for use by Display implementors; it contains much of the common code they need. To create one, just declare a variable of its type; no explicit initialization is necessary.
CellBuffer should be thread safe, original tcell is not.
func NewCellBuffer ¶
func NewCellBuffer() *CellBuffer
func (*CellBuffer) Dirty ¶
func (cb *CellBuffer) Dirty(x, y int) bool
Dirty checks if a character at the given location needs an to be refreshed on the physical display. This returns true if the cell content is different since the last time it was marked clean.
func (*CellBuffer) Fill ¶
func (cb *CellBuffer) Fill(r rune, style Style)
Fill fills the entire cell buffer array with the specified character and style. Normally choose ' ' to clear the display. This API doesn't support combining characters, or characters with a width larger than one.
func (*CellBuffer) GetContent ¶
GetContent returns the contents of a character cell, including the primary rune, any combining character runes (which will usually be nil), the style, and the display width in cells. (The width can be either 1, normally, or 2 for East Asian full-width characters.)
func (*CellBuffer) Invalidate ¶
func (cb *CellBuffer) Invalidate()
Invalidate marks all characters within the buffer as dirty.
func (*CellBuffer) Resize ¶
func (cb *CellBuffer) Resize(w, h int)
Resize is used to resize the cells array, with different dimensions, while preserving the original contents. The cells will be invalidated so that they can be redrawn.
func (*CellBuffer) SetContent ¶
SetContent sets the contents (primary rune, combining runes, and style) for a cell at a given location.
func (*CellBuffer) SetDirty ¶
func (cb *CellBuffer) SetDirty(x, y int, dirty bool)
SetDirty is normally used to indicate that a cell has been displayed (in which case dirty is false), or to manually force a cell to be marked dirty.
func (*CellBuffer) Size ¶
func (cb *CellBuffer) Size() (w, h int)
Size returns the (width, height) in cells of the buffer.
type Color ¶
type Color uint64
Color represents a color. The low numeric values are the same as used by ECMA-48, and beyond that XTerm. A 24-bit RGB value may be used by adding in the ColorIsRGB flag. For Color names we use the W3C approved color names.
We use a 64-bit integer to allow future expansion if we want to add an 8-bit alpha, while still leaving us some room for extra options.
Note that on various terminals colors may be approximated however, or not supported at all. If no suitable representation for a color is known, the library will simply not set any color, deferring to whatever default attributes the terminal uses.
const ( // ColorDefault is used to leave the Color unchanged from whatever // system or terminal default may exist. It's also the zero value. ColorDefault Color = 0 // ColorIsValid is used to indicate the color value is actually // valid (initialized). This is useful to permit the zero value // to be treated as the default. ColorValid Color = 1 << 32 // ColorIsRGB is used to indicate that the numeric value is not // a known color constant, but rather an RGB value. The lower // order 3 bytes are RGB. ColorIsRGB Color = 1 << 33 // ColorSpecial is a flag used to indicate that the values have // special meaning, and live outside of the color space(s). ColorSpecial Color = 1 << 34 )
func FindColor ¶
FindColor attempts to find a given color, or the best match possible for it, from the palette given. This is an expensive operation, so results should be cached by the caller.
func GetColor ¶
GetColor creates a Color from a color name (W3C name). A hex value may be supplied as a string in the format "#ffffff".
func NewHexColor ¶
NewHexColor returns a color using the given 24-bit RGB value.
func NewRGBColor ¶
NewRGBColor returns a new color with the given red, green, and blue values. Each value must be represented in the range 0-255.
func PaletteColor ¶
PaletteColor creates a color based on the palette index.
func ParseColor ¶ added in v0.0.5
GetColor creates a Color from a color name (W3C name). A hex value may be supplied as a string in the format "#ffffff".
func (Color) Hex ¶
Hex returns the color's hexadecimal RGB 24-bit value with each component consisting of a single byte, ala R << 16 | G << 8 | B. If the color is unknown or unset, -1 is returned.
func (Color) RGB ¶
RGB returns the red, green, and blue components of the color, with each component represented as a value 0-255. In the event that the color cannot be broken up (not set usually), -1 is returned for each value.
func (Color) String ¶
Stringer interface implementation so the Color can be used in normal fmt operations without required the developer to jump any hoops.
type ConnectFlags ¶
type ConnectFlags uint64
Connect flags
const ( CONNECT_AFTER ConnectFlags = 1 << 0 CONNECT_SWAPPED ConnectFlags = 1 << iota )
type DestDefaults ¶
type DestDefaults uint64
Dest defaults
const ( DEST_DEFAULT_MOTION DestDefaults = 1 << 0 DEST_DEFAULT_HIGHLIGHT DestDefaults = 1 << iota DEST_DEFAULT_DROP DEST_DEFAULT_ALL DestDefaults = 0 )
type Display ¶
type Display interface { // Init initializes the display for use. Init() error // Close finalizes the display also releasing resources. Close() // Clear erases the display. The contents of any display buffers // will also be cleared. This has the logical effect of // filling the display with spaces, using the global default style. Clear() // Fill fills the display with the given character and style. Fill(rune, Style) // SetCell is an older API, and will be removed. Please use // SetContent instead; SetCell is implemented in terms of SetContent. SetCell(x int, y int, style Style, ch ...rune) // GetContent returns the contents at the given location. If the // coordinates are out of range, then the values will be 0, nil, // StyleDefault. Note that the contents returned are logical contents // and may not actually be what is displayed, but rather are what will // be displayed if Show() or Sync() is called. The width is the width // in display cells; most often this will be 1, but some East Asian // characters require two cells. GetContent(x, y int) (mainc rune, combc []rune, style Style, width int) // SetContent sets the contents of the given cell location. If // the coordinates are out of range, then the operation is ignored. // // The first rune is the primary non-zero width rune. The array // that follows is a possible list of combining characters to append, // and will usually be nil (no combining characters.) // // The results are not displayd until Show() or Sync() is called. // // Note that wide (East Asian full width) runes occupy two cells, // and attempts to place character at next cell to the right will have // undefined effects. Wide runes that are printed in the // last column will be replaced with a single width space on output. SetContent(x int, y int, mainc rune, combc []rune, style Style) // SetStyle sets the default style to use when clearing the display // or when StyleDefault is specified. If it is also StyleDefault, // then whatever system/terminal default is relevant will be used. SetStyle(style Style) // ShowCursor is used to display the cursor at a given location. // If the coordinates -1, -1 are given or are otherwise outside the // dimensions of the display, the cursor will be hidden. ShowCursor(x int, y int) // HideCursor is used to hide the cursor. Its an alias for // ShowCursor(-1, -1). HideCursor() // Size returns the display size as width, height. This changes in // response to a call to Clear or Flush. Size() (w, h int) // PollEvent waits for events to arrive. Main application loops // must spin on this to prevent the application from stalling. // Furthermore, this will return nil if the Display is finalized. PollEvent() Event // PostEvent tries to post an event into the event stream. This // can fail if the event queue is full. In that case, the event // is dropped, and ErrEventQFull is returned. PostEvent(ev Event) error // EnableMouse enables the mouse. (If your terminal supports it.) // If no flags are specified, then all events are reported, if the // terminal supports them. EnableMouse(...MouseFlags) // DisableMouse disables the mouse. DisableMouse() // EnablePaste enables bracketed paste mode, if supported. EnablePaste() // DisablePaste() disables bracketed paste mode. DisablePaste() // HasMouse returns true if the terminal (apparently) supports a // mouse. Note that the a return value of true doesn't guarantee that // a mouse/pointing device is present; a false return definitely // indicates no mouse support is available. HasMouse() bool // Colors returns the number of colors. All colors are assumed to // use the ANSI color map. If a terminal is monochrome, it will // return 0. Colors() int // Show makes all the content changes made using SetContent() visible // on the display. // // It does so in the most efficient and least visually disruptive // manner possible. Show() // Sync works like Show(), but it updates every visible cell on the // physical display, assuming that it is not synchronized with any // internal model. This may be both expensive and visually jarring, // so it should only be used when believed to actually be necessary. // // Typically this is called as a result of a user-requested redraw // (e.g. to clear up on display corruption caused by some other program), // or during a resize event. Sync() // CharacterSet returns information about the character set. // This isn't the full locale, but it does give us the input/output // character set. Note that this is just for diagnostic purposes, // we normally translate input/output to/from UTF-8, regardless of // what the user's environment is. CharacterSet() string // The display string should be the same width as original rune. // This makes it possible to register two character replacements // for full width East Asian characters, for example. // // It is recommended that replacement strings consist only of // 7-bit ASCII, since other characters may not display everywhere. RegisterRuneFallback(r rune, subst string) // UnregisterRuneFallback unmaps a replacement. It will unmap // the implicit ASCII replacements for alternate characters as well. // When an unmapped char needs to be displayed, but no suitable // glyph is available, '?' is emitted instead. It is not possible // to "disable" the use of alternate characters that are supported // by your terminal except by changing the terminal database. UnregisterRuneFallback(r rune) // CanDisplay returns true if the given rune can be displayed on // this display. Note that this is a best guess effort -- whether // your fonts support the character or not may be questionable. // Mostly this is for folks who work outside of Unicode. // // If checkFallbacks is true, then if any (possibly imperfect) // fallbacks are registered, this will return true. This will // also return true if the terminal can replace the glyph with // one that is visually indistinguishable from the one requested. CanDisplay(r rune, checkFallbacks bool) bool // Resize does nothing, since its generally not possible to // ask a display to resize, but it allows the Display to implement // the View interface. Resize(int, int, int, int) // HasKey returns true if the keyboard is believed to have the // key. In some cases a keyboard may have keys with this name // but no support for them, while in others a key may be reported // as supported but not actually be usable (such as some emulators // that hijack certain keys). Its best not to depend to strictly // on this function, but it can be used for hinting when building // menus, displayed hot-keys, etc. Note that KeyRune (literal // runes) is always true. HasKey(Key) bool // Beep attempts to sound an OS-dependent audible alert and returns an error // when unsuccessful. Beep() error Export() *CellBuffer Import(cb *CellBuffer) }
Display represents the physical (or emulated) display. This can be a terminal window or a physical console. Platforms implement this differently.
func NewConsoleDisplay ¶
NewConsoleDisplay returns a console based display. This platform doesn't have support for any, so it returns nil and a suitable error.
func NewDisplay ¶
NewDisplay returns a default Display suitable for the user's terminal environment.
func NewTerminfoDisplay ¶
NewTerminfoDisplay returns a Display that uses the stock TTY interface and POSIX terminal control, combined with a terminfo description taken from the $TERM environment variable. It returns an error if the terminal is not supported for any reason.
For terminals that do not support dynamic resize events, the $LINES $COLUMNS environment variables can be set to the actual window size, otherwise defaults taken from the terminal database are used.
type DisplayCallbackFn ¶
type DisplayCallbackFn = func(d DisplayManager) error
type DisplayInitFn ¶
type DisplayInitFn = func(d DisplayManager) error
type DisplayManager ¶
type DisplayManager interface { Object Init() (already bool) Destroy() GetTitle() string SetTitle(title string) GetTtyPath() string SetTtyPath(ttyPath string) Display() Display DisplayCaptured() bool CaptureDisplay(ttyPath string) ReleaseDisplay() IsMonochrome() bool Colors() (numberOfColors int) CaptureCtrlC() ReleaseCtrlC() DefaultTheme() Theme ActiveWindow() Window SetActiveWindow(w Window) AddWindow(w Window) RemoveWindow(wid int) AddWindowOverlay(pid int, overlay Window, region Region) RemoveWindowOverlay(pid int, oid int) GetWindows() (windows []Window) GetWindowOverlays(windowId int) (windows []Window) GetWindowTopOverlay(windowId int) (window Window) GetWindowOverlayRegion(windowId, overlayId int) (region Region) SetWindowOverlayRegion(windowId, overlayId int, region Region) App() *CApp SetEventFocus(widget interface{}) error GetEventFocus() (widget interface{}) GetPriorEvent() (event Event) ProcessEvent(evt Event) EventFlag DrawScreen() EventFlag RequestDraw() RequestShow() RequestSync() RequestQuit() AsyncCall(fn DisplayCallbackFn) error AwaitCall(fn DisplayCallbackFn) error PostEvent(evt Event) error AddQuitHandler(tag string, fn func()) RemoveQuitHandler(tag string) Run() error IsRunning() bool }
func GetDisplayManager ¶ added in v0.0.4
func GetDisplayManager() (dm DisplayManager)
type DisplayManagerFn ¶
type DisplayManagerFn func(d DisplayManager)
type DragResult ¶
type DragResult uint64
Drag result
const ( DRAG_RESULT_SUCCESS DragResult = iota DRAG_RESULT_NO_TARGET DRAG_RESULT_USER_CANCELLED DRAG_RESULT_TIMEOUT_EXPIRED DRAG_RESULT_GRAB_BROKEN DRAG_RESULT_ERROR )
type EncodingFallback ¶
type EncodingFallback int
EncodingFallback describes how the system behavees when the locale requires a character set that we do not support. The system always supports UTF-8 and US-ASCII. On Windows consoles, UTF-16LE is also supported automatically. Other character sets must be added using the RegisterEncoding API. (A large group of nearly all of them can be added using the RegisterAll function in the encoding sub package.)
type EnumFromString ¶ added in v0.0.5
type EventError ¶
type EventError struct {
// contains filtered or unexported fields
}
An EventError is an event representing some sort of error, and carries an error payload.
func NewEventError ¶
func NewEventError(err error) *EventError
NewEventError creates an ErrorEvent with the given error payload.
func (*EventError) Clone ¶ added in v0.0.5
func (ev *EventError) Clone() *EventError
func (*EventError) Err ¶ added in v0.0.5
func (ev *EventError) Err() error
func (*EventError) When ¶
func (ev *EventError) When() time.Time
When returns the time when the event was created.
type EventHandler ¶
EventHandler is anything that handles events. If the handler has consumed the event, it should return true. False otherwise.
type EventInterrupt ¶
type EventInterrupt struct {
// contains filtered or unexported fields
}
EventInterrupt is a generic wakeup event. Its can be used to to request a redraw. It can carry an arbitrary payload, as well.
func NewEventInterrupt ¶
func NewEventInterrupt(data interface{}) *EventInterrupt
NewEventInterrupt creates an EventInterrupt with the given payload.
func (*EventInterrupt) Data ¶
func (ev *EventInterrupt) Data() interface{}
Data is used to obtain the opaque event payload.
func (*EventInterrupt) When ¶
func (ev *EventInterrupt) When() time.Time
When returns the time when this event was created.
type EventKey ¶
type EventKey struct {
// contains filtered or unexported fields
}
EventKey represents a key press. Usually this is a key press followed by a key release, but since terminal programs don't have a way to report key release events, we usually get just one event. If a key is held down then the terminal may synthesize repeated key presses at some predefined rate. We have no control over that, nor visibility into it.
In some cases, we can have a modifier key, such as ModAlt, that can be generated with a key press. (This usually is represented by having the high bit set, or in some cases, by sending an ESC prior to the rune.)
If the value of Key() is KeyRune, then the actual key value will be available with the Rune() method. This will be the case for most keys. In most situations, the modifiers will not be set. For example, if the rune is 'A', this will be reported without the ModShift bit set, since really can't tell if the Shift key was pressed (it might have been CAPSLOCK, or a terminal that only can send capitals, or keyboard with separate capital letters from lower case letters).
Generally, terminal applications have far less visibility into keyboard activity than graphical applications. Hence, they should avoid depending overly much on availability of modifiers, or the availability of any specific keys.
func NewEventKey ¶
NewEventKey attempts to create a suitable event. It parses the various ASCII control sequences if KeyRune is passed for Key, but if the caller has more precise information it should set that specifically. Callers that aren't sure about modifier state (most) should just pass ModNone.
func (*EventKey) Key ¶
Key returns a virtual key code. We use this to identify specific key codes, such as KeyEnter, etc. Most control and function keys are reported with unique Key values. Normal alphanumeric and punctuation keys will generally return KeyRune here; the specific key can be further decoded using the Rune() function.
func (*EventKey) Modifiers ¶
Modifiers returns the modifiers that were present with the key press. Note that not all platforms and terminals support this equally well, and some cases we will not not know for sure. Hence, applications should avoid using this in most circumstances.
func (*EventKey) Name ¶
Name returns a printable value or the key stroke. This can be used when printing the event, for example.
type EventMouse ¶
type EventMouse struct {
// contains filtered or unexported fields
}
EventMouse is a mouse event. It is sent on either mouse up or mouse down events. It is also sent on mouse motion events - if the terminal supports it. We make every effort to ensure that mouse release events are delivered. Hence, click drag can be identified by a motion event with the mouse down, without any intervening button release. On some terminals only the initiating press and terminating release event will be delivered.
Mouse wheel events, when reported, may appear on their own as individual impulses; that is, there will normally not be a release event delivered for mouse wheel movements.
Most terminals cannot report the state of more than one button at a time -- and some cannot report motion events unless a button is pressed.
Applications can inspect the time between events to resolve double or triple clicks.
func NewEventMouse ¶
func NewEventMouse(x, y int, btn ButtonMask, mod ModMask) *EventMouse
NewEventMouse is used to create a new mouse event. Applications shouldn't need to use this; its mostly for display implementors.
func (*EventMouse) Button ¶
func (ev *EventMouse) Button() ButtonMask
func (*EventMouse) ButtonHas ¶
func (ev *EventMouse) ButtonHas(check ButtonMask) bool
func (*EventMouse) ButtonPressed ¶
func (ev *EventMouse) ButtonPressed() ButtonMask
func (*EventMouse) Buttons ¶
func (ev *EventMouse) Buttons() ButtonMask
Buttons returns the list of buttons that were pressed or wheel motions.
func (*EventMouse) Clone ¶ added in v0.0.5
func (ev *EventMouse) Clone() Event
func (*EventMouse) CloneForPosition ¶ added in v0.0.5
func (ev *EventMouse) CloneForPosition(x, y int) Event
func (*EventMouse) IsDragStarted ¶
func (ev *EventMouse) IsDragStarted() bool
func (*EventMouse) IsDragStopped ¶
func (ev *EventMouse) IsDragStopped() bool
func (*EventMouse) IsDragging ¶
func (ev *EventMouse) IsDragging() bool
func (*EventMouse) IsMoving ¶
func (ev *EventMouse) IsMoving() bool
func (*EventMouse) IsPressed ¶
func (ev *EventMouse) IsPressed() bool
func (*EventMouse) IsReleased ¶
func (ev *EventMouse) IsReleased() bool
func (*EventMouse) IsWheelImpulse ¶
func (ev *EventMouse) IsWheelImpulse() bool
func (*EventMouse) Modifiers ¶
func (ev *EventMouse) Modifiers() ModMask
Modifiers returns a list of keyboard modifiers that were pressed with the mouse button(s).
func (*EventMouse) Position ¶
func (ev *EventMouse) Position() (x, y int)
Position returns the mouse position in character cells. The origin 0, 0 is at the upper left corner.
func (*EventMouse) Report ¶
func (ev *EventMouse) Report() string
func (*EventMouse) State ¶
func (ev *EventMouse) State() MouseState
func (*EventMouse) StateHas ¶
func (ev *EventMouse) StateHas(check MouseState) bool
func (*EventMouse) WheelImpulse ¶
func (ev *EventMouse) WheelImpulse() ButtonMask
func (*EventMouse) When ¶
func (ev *EventMouse) When() time.Time
When returns the time when this EventMouse was created.
type EventPaste ¶
type EventPaste struct {
// contains filtered or unexported fields
}
EventPaste is used to mark the start and end of a bracketed paste. An event with .MainInit() true will be sent to mark the start. Then a number of keys will be sent to indicate that the content is pasted in. At the end, an event with .MainInit() false will be sent.
func NewEventPaste ¶
func NewEventPaste(start bool) *EventPaste
NewEventPaste returns a new EventPaste.
func (*EventPaste) End ¶
func (ev *EventPaste) End() bool
End returns true if this is the end of a paste.
func (*EventPaste) Start ¶
func (ev *EventPaste) Start() bool
MainInit returns true if this is the start of a paste.
func (*EventPaste) When ¶
func (ev *EventPaste) When() time.Time
When returns the time when this EventMouse was created.
type EventResize ¶
type EventResize struct {
// contains filtered or unexported fields
}
EventResize is sent when the window size changes.
func NewEventResize ¶
func NewEventResize(width, height int) *EventResize
NewEventResize creates an EventResize with the new updated window size, which is given in character cells.
func (*EventResize) Size ¶
func (ev *EventResize) Size() (w, h int)
Size returns the new window size as width, height in character cells.
func (*EventResize) When ¶
func (ev *EventResize) When() time.Time
When returns the time when the Event was created.
type EventTime ¶
type EventTime struct {
// contains filtered or unexported fields
}
EventTime is a simple base event class, suitable for easy reuse. It can be used to deliver actual timer events as well.
func NewEventTime ¶
NewEventTime creates a Time Event for the given time
func (*EventTime) SetEventNow ¶
func (e *EventTime) SetEventNow()
SetEventNow sets the time of occurrence for the event to the current time.
func (*EventTime) SetEventTime ¶
SetEventTime sets the time of occurrence for the event.
type FlagSorter ¶
type FlagSorter []cli.Flag
FlagSorter is a slice of Flag.
func (FlagSorter) Len ¶
func (f FlagSorter) Len() int
func (FlagSorter) Less ¶
func (f FlagSorter) Less(i, j int) bool
func (FlagSorter) Swap ¶
func (f FlagSorter) Swap(i, j int)
type HorizontalAlignment ¶
type HorizontalAlignment uint
const ( ALIGN_LEFT HorizontalAlignment = 0 ALIGN_RIGHT HorizontalAlignment = 1 ALIGN_CENTER HorizontalAlignment = 2 )
type IButtonMask ¶
type IButtonMask interface { Has(m ButtonMask) bool Set(m ButtonMask) ButtonMask Clear(m ButtonMask) ButtonMask Toggle(m ButtonMask) ButtonMask String() string }
type IMouseState ¶
type IMouseState interface { Has(m MouseState) bool Set(m MouseState) MouseState Clear(m MouseState) MouseState Toggle(m MouseState) MouseState String() string }
type Justification ¶
type Justification uint64
Justification
const ( JUSTIFY_LEFT Justification = iota JUSTIFY_RIGHT JUSTIFY_CENTER JUSTIFY_FILL )
type Key ¶
type Key int16
Key is a generic value for representing keys, and especially special keys (function keys, cursor movement keys, etc.) For normal keys, like ASCII letters, we use KeyRune, and then expect the application to inspect the Rune() member of the EventKey.
const ( KeyRune Key = iota + 256 KeyUp KeyDown KeyRight KeyLeft KeyUpLeft KeyUpRight KeyDownLeft KeyDownRight KeyCenter KeyPgUp KeyPgDn KeyHome KeyEnd KeyInsert KeyDelete KeyHelp KeyExit KeyClear KeyCancel KeyPrint KeyPause KeyBacktab KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyF13 KeyF14 KeyF15 KeyF16 KeyF17 KeyF18 KeyF19 KeyF20 KeyF21 KeyF22 KeyF23 KeyF24 KeyF25 KeyF26 KeyF27 KeyF28 KeyF29 KeyF30 KeyF31 KeyF32 KeyF33 KeyF34 KeyF35 KeyF36 KeyF37 KeyF38 KeyF39 KeyF40 KeyF41 KeyF42 KeyF43 KeyF44 KeyF45 KeyF46 KeyF47 KeyF48 KeyF49 KeyF50 KeyF51 KeyF52 KeyF53 KeyF54 KeyF55 KeyF56 KeyF57 KeyF58 KeyF59 KeyF60 KeyF61 KeyF62 KeyF63 KeyF64 )
This is the list of named keys. KeyRune is special however, in that it is a place holder key indicating that a printable character was sent. The actual value of the rune will be transported in the Rune of the associated EventKey.
const ( KeyCtrlSpace Key = iota KeyCtrlA KeyCtrlB KeyCtrlC KeyCtrlD KeyCtrlE KeyCtrlF KeyCtrlG KeyCtrlH KeyCtrlI KeyCtrlJ KeyCtrlK KeyCtrlL KeyCtrlM KeyCtrlN KeyCtrlO KeyCtrlP KeyCtrlQ KeyCtrlR KeyCtrlS KeyCtrlT KeyCtrlU KeyCtrlV KeyCtrlW KeyCtrlX KeyCtrlY KeyCtrlZ KeyCtrlLeftSq // Escape KeyCtrlBackslash KeyCtrlRightSq KeyCtrlCarat KeyCtrlUnderscore )
These are the control keys. Note that they overlap with other keys, perhaps. For example, KeyCtrlH is the same as KeyBackspace.
const ( KeyNUL Key = iota KeySOH KeySTX KeyETX KeyEOT KeyENQ KeyACK KeyBEL KeyBS KeyTAB KeyLF KeyVT KeyFF KeyCR KeySO KeySI KeyDLE KeyDC1 KeyDC2 KeyDC3 KeyDC4 KeyNAK KeySYN KeyETB KeyCAN KeyEM KeySUB KeyESC KeyFS KeyGS KeyRS KeyUS KeyDEL Key = 0x7F )
These are the defined ASCII values for key codes. They generally match with KeyCtrl values.
const ( KeySpacebar Key = KeyRune KeySpace Key = 32 KeyExclamationMark Key = 33 KeyDoubleQuote Key = 34 KeyNumber Key = 35 KeyDollarSign Key = 36 KeyPercent Key = 37 KeyAmpersand Key = 38 KeySingleQuote Key = 39 KeyLeftParenthesis Key = 40 KeyRightParenthesis Key = 41 KeyAsterisk Key = 42 KeyPlus Key = 43 KeyComma Key = 44 KeyMinus Key = 45 KeyPeriod Key = 46 KeySlash Key = 47 KeyZero Key = 48 KeyOne Key = 49 KeyTwo Key = 50 KeyThree Key = 51 KeyFour Key = 52 KeyFive Key = 53 KeySix Key = 54 KeySeven Key = 55 KeyEight Key = 56 KeyNine Key = 57 KeyColon Key = 58 KeySemicolon Key = 59 KeyLessThan Key = 60 KeyEqualitySign Key = 61 KeyGreaterThan Key = 62 KeyQuestionMark Key = 63 KeyAtSign Key = 64 KeyCapitalA Key = 65 KeyCapitalB Key = 66 KeyCapitalC Key = 67 KeyCapitalD Key = 68 KeyCapitalE Key = 69 KeyCapitalF Key = 70 KeyCapitalG Key = 71 KeyCapitalH Key = 72 KeyCapitalI Key = 73 KeyCapitalJ Key = 74 KeyCapitalK Key = 75 KeyCapitalL Key = 76 KeyCapitalM Key = 77 KeyCapitalN Key = 78 KeyCapitalO Key = 79 KeyCapitalP Key = 80 KeyCapitalQ Key = 81 KeyCapitalR Key = 82 KeyCapitalS Key = 83 KeyCapitalT Key = 84 KeyCapitalU Key = 85 KeyCapitalV Key = 86 KeyCapitalW Key = 87 KeyCapitalX Key = 88 KeyCapitalY Key = 89 KeyCapitalZ Key = 90 KeyLeftSquareBracket Key = 91 KeyBackslash Key = 92 KeyRightSquareBracket Key = 93 KeyCaretCircumflex Key = 94 KeyUnderscore Key = 95 KeyGraveAccent Key = 96 KeySmallA Key = 97 KeySmallB Key = 98 KeySmallC Key = 99 KeySmallD Key = 100 KeySmallE Key = 101 KeySmallF Key = 102 KeySmallG Key = 103 KeySmallH Key = 104 KeySmallI Key = 105 KeySmallJ Key = 106 KeySmallK Key = 107 KeySmallL Key = 108 KeySmallM Key = 109 KeySmallN Key = 110 KeySmallO Key = 111 KeySmallP Key = 112 KeySmallQ Key = 113 KeySmallR Key = 114 KeySmallS Key = 115 KeySmallT Key = 116 KeySmallU Key = 117 KeySmallV Key = 118 KeySmallW Key = 119 KeySmallX Key = 120 KeySmallY Key = 121 KeySmallZ Key = 122 KeyLeftCurlyBracket Key = 123 KeyVerticalBar Key = 124 KeyRightCurlyBracket Key = 125 KeyTilde Key = 126 )
ASCII Keys
func LookupKeyRune ¶ added in v0.0.5
type MetaData ¶ added in v0.0.5
type MetaData interface { Signaling Init() (already bool) InstallProperty(name Property, kind PropertyType, write bool, def interface{}) error InstallBuildableProperty(name Property, kind PropertyType, write bool, def interface{}) error OverloadProperty(name Property, kind PropertyType, write bool, buildable bool, def interface{}) error ListProperties() (properties []Property) ListBuildableProperties() (properties []Property) SetProperties(properties map[Property]string) (err error) IsProperty(name Property) bool IsBuildableProperty(name Property) bool GetProperty(name Property) *CProperty SetPropertyFromString(name Property, value string) error SetProperty(name Property, value interface{}) error GetBoolProperty(name Property) (value bool, err error) SetBoolProperty(name Property, value bool) error GetStringProperty(name Property) (value string, err error) SetStringProperty(name Property, value string) error GetIntProperty(name Property) (value int, err error) SetIntProperty(name Property, value int) error GetFloatProperty(name Property) (value float64, err error) SetFloatProperty(name Property, value float64) error GetColorProperty(name Property) (value Color, err error) SetColorProperty(name Property, value Color) error GetStyleProperty(name Property) (value Style, err error) SetStyleProperty(name Property, value Style) error GetThemeProperty(name Property) (value Theme, err error) SetThemeProperty(name Property, value Theme) error GetPointProperty(name Property) (value Point2I, err error) SetPointProperty(name Property, value Point2I) error GetRectangleProperty(name Property) (value Rectangle, err error) SetRectangleProperty(name Property, value Rectangle) error GetRegionProperty(name Property) (value Region, err error) SetRegionProperty(name Property, value Region) error GetStructProperty(name Property) (value interface{}, err error) SetStructProperty(name Property, value interface{}) error }
type ModMask ¶
type ModMask int16
ModMask is a mask of modifier keys. Note that it will not always be possible to report modifier keys.
These are the modifiers keys that can be sent either with a key press, or a mouse event. Note that as of now, due to the confusion associated with Meta, and the lack of support for it on many/most platforms, the current implementations never use it. Instead, they use ModAlt, even for events that could possibly have been distinguished from ModAlt.
type MouseFlags ¶ added in v0.0.4
type MouseFlags int
MouseFlags are options to modify the handling of mouse events. Actual events can be or'd together.
type MouseState ¶
type MouseState uint64
const ( MOUSE_NONE MouseState = 0 MOUSE_MOVE MouseState = 1 << iota BUTTON_PRESS BUTTON_RELEASE WHEEL_PULSE DRAG_START DRAG_MOVE DRAG_STOP )
func (MouseState) Clear ¶
func (i MouseState) Clear(m MouseState) MouseState
func (MouseState) Has ¶
func (i MouseState) Has(m MouseState) bool
func (MouseState) Set ¶
func (i MouseState) Set(m MouseState) MouseState
func (MouseState) String ¶
func (i MouseState) String() string
func (MouseState) Toggle ¶
func (i MouseState) Toggle(m MouseState) MouseState
type Object ¶
type Object interface { MetaData Init() (already bool) InitWithProperties(properties map[Property]string) (already bool, err error) Destroy() GetName() (name string) SetName(name string) GetTheme() (theme Theme) SetTheme(theme Theme) GetThemeRequest() (theme Theme) SetThemeRequest(theme Theme) }
This is the base type for all complex CDK object types. The Object type provides a means of installing properties, getting and setting property values
type ObjectFlags ¶
type ObjectFlags uint64
Object flags
const ( IN_DESTRUCTION ObjectFlags = 1 << 0 FLOATING ObjectFlags = 1 << iota RESERVED_1 RESERVED_2 )
type OffscreenCell ¶
type OffscreenCell struct { // Bytes is the actual character bytes. Normally this is // rune data, but it could be be data in another encoding system. Bytes []byte // Style is the style used to display the data. Style Style // Runes is the list of runes, unadulterated, in UTF-8. Runes []rune }
OffscreenCell represents a simulated display cell. The purpose of this is to track on display content.
type OffscreenDisplay ¶
type OffscreenDisplay interface { // InjectKeyBytes injects a stream of bytes corresponding to // the native encoding (see charset). It turns true if the entire // set of bytes were processed and delivered as KeyEvents, false // if any bytes were not fully understood. Any bytes that are not // fully converted are discarded. InjectKeyBytes(buf []byte) bool // InjectKey injects a key event. The rune is a UTF-8 rune, post // any translation. InjectKey(key Key, r rune, mod ModMask) // InjectMouse injects a mouse event. InjectMouse(x, y int, buttons ButtonMask, mod ModMask) // SetSize resizes the underlying physical display. It also causes // a resize event to be injected during the next Show() or Sync(). // A new physical contents array will be allocated (with data from // the old copied), so any prior value obtained with GetContents // won't be used anymore SetSize(width, height int) // GetContents returns display contents as an array of // cells, along with the physical width & height. Note that the // physical contents will be used until the next time SetSize() // is called. GetContents() (cells []OffscreenCell, width int, height int) // GetCursor returns the cursor details. GetCursor() (x int, y int, visible bool) Display }
OffscreenDisplay represents a display simulation. This is intended to be a superset of normal Screens, but also adds some important interfaces for testing.
func MakeOffscreenDisplay ¶
func MakeOffscreenDisplay(charset string) (OffscreenDisplay, error)
func NewOffscreenDisplay ¶
func NewOffscreenDisplay(charset string) OffscreenDisplay
NewOffscreenDisplay returns a OffscreenDisplay. Note that OffscreenDisplay is also a Display.
type OffscreenWindow ¶
type OffscreenWindow interface { Object GetTitle() string SetTitle(title string) GetDisplayManager() DisplayManager SetDisplayManager(d DisplayManager) Draw(canvas Canvas) EventFlag ProcessEvent(evt Event) EventFlag }
Basic window interface
type Orientation ¶
type Orientation uint64
Orientation
const ( ORIENTATION_NONE Orientation = iota ORIENTATION_HORIZONTAL ORIENTATION_VERTICAL )
func (Orientation) FromString ¶ added in v0.0.5
func (o Orientation) FromString(value string) (enum interface{}, err error)
type Point2I ¶
type Point2I struct {
X, Y int
}
Point2I is a 2-aspect vector represented by x and y coordinates.
func MakePoint2I ¶
Construct a new Point2I structure (non-pointer)
func NewPoint2I ¶
Construct a new instance of a Point2I structure
func ParsePoint2I ¶ added in v0.0.5
Parse a Point2I structure from a string representation. There are two valid formats supported by this parser function:
formal "{x:0,y:0}" plain "0 0"
func (*Point2I) ClampToRegion ¶ added in v0.0.5
restrict this Point2I instance to be within the boundaries defined by the given region
func (Point2I) Clone ¶ added in v0.0.5
returns a new Point2I structure with the same values as this structure
func (Point2I) Equals ¶
returns true if both the given x and y coordinates and this Point2I are equivalent, returns false otherwise
func (Point2I) EqualsTo ¶ added in v0.0.5
returns true if both the given Point2I and this Point2I are equivalent and false otherwise
func (Point2I) NewClone ¶ added in v0.0.5
returns a new Point2I instance with the same values as this structure
func (Point2I) String ¶
returns a formal string representation of the Point2I structure, ie: "{x:0,y:0}"
type Property ¶ added in v0.0.5
type Property string
const PropertyDebug Property = "debug"
request that the object be rendered with additional features useful to debugging custom Widget development
const PropertyName Property = "name"
property wrapper around the CTypeItem name field
const PropertyTheme Property = "theme"
const PropertyThemeRequest Property = "theme-request"
type PropertyType ¶ added in v0.0.5
type PropertyType string
const ( BoolProperty PropertyType = "bool" StringProperty PropertyType = "string" IntProperty PropertyType = "int" FloatProperty PropertyType = "float" ColorProperty PropertyType = "color" StyleProperty PropertyType = "style" ThemeProperty PropertyType = "theme" PointProperty PropertyType = "point" RectangleProperty PropertyType = "rectangle" RegionProperty PropertyType = "region" StructProperty PropertyType = "struct" )
func (PropertyType) String ¶ added in v0.0.5
func (p PropertyType) String() string
type QuarkID ¶ added in v0.0.5
type QuarkID uint64
A QuarkID is a non-zero integer which uniquely identifies a particular string. A QuarkID value of zero is associated to nil.
func QuarkFromString ¶ added in v0.0.5
Gets the QuarkID identifying the given string. If the string does not currently have an associated QuarkID, a new QuarkID is created, using a copy of the string.
This function must not be used before library constructors have finished running.
Parameters string a string.
Returns
the QuarkID identifying the string, or 0 if string is nil
func QuarkTryString ¶ added in v0.0.5
Gets the GQuark associated with the given string, or 0 if string is nil or it has no associated QuarkID.
If you want the GQuark to be created if it doesn't already exist, use QuarkFromString().
This function must not be used before library constructors have finished running.
Parameters
string a string.
Returns
the GQuark associated with the string, or 0 if string is nil or there is no GQuark associated with it
type Rectangle ¶
type Rectangle struct {
W, H int
}
Rectangle is a 2-aspect vector represented by width and height values
func MakeRectangle ¶
Construct a new Point2I structure (non-pointer)
func NewRectangle ¶
Construct a new instance of a Point2I structure
func ParseRectangle ¶ added in v0.0.5
Parse a Point2I structure from a string representation. There are two valid formats supported by this parser function:
formal "{w:0,h:0}" plain "0 0"
func (*Rectangle) AddRectangle ¶ added in v0.0.5
add the given Point2I to this Point2I
func (*Rectangle) Clamp ¶
constrain the width and height values to be within the given ranges of min and max values
func (*Rectangle) ClampToRegion ¶ added in v0.0.5
func (Rectangle) Clone ¶ added in v0.0.5
returns a new Point2I structure with the same values as this structure
func (Rectangle) Equals ¶
returns true if both the given x and y coordinates and this Point2I are equivalent, returns false otherwise
func (Rectangle) EqualsTo ¶ added in v0.0.5
returns true if both the given Point2I and this Point2I are equivalent and false otherwise
func (*Rectangle) Floor ¶
constrain the width and height values to be at least the given values or greater
func (Rectangle) NewClone ¶ added in v0.0.5
returns a new Point2I instance with the same values as this structure
func (*Rectangle) SetRectangle ¶ added in v0.0.5
set this Point2I instance to be equivalent to the given Point2I
func (Rectangle) String ¶
returns a formal string representation of the Point2I structure, ie: "{w:0,h:0}"
func (*Rectangle) Sub ¶ added in v0.0.5
subtract the given x and y values from this Point2I instance
func (*Rectangle) SubRectangle ¶ added in v0.0.5
subtract the given Point2I's values from this Point2I instance
type ResizeMode ¶
type ResizeMode uint64
Resize mode
const ( RESIZE_PARENT ResizeMode = iota RESIZE_QUEUE RESIZE_IMMEDIATE )
type ScreenStateReq ¶
type ScreenStateReq uint64
const ( NullRequest ScreenStateReq = 1 << iota DrawRequest ShowRequest SyncRequest QuitRequest )
type Signal ¶
type Signal string
const SignalDestroy Signal = "destroy"
emitted when the object instance is destroyed
type SignalFlags ¶
type SignalFlags uint64
Signal flags
const ( SIGNAL_RUN_FIRST SignalFlags = 1 << 0 SIGNAL_RUN_LAST SignalFlags = 1 << iota SIGNAL_RUN_CLEANUP SIGNAL_NO_RECURSE SIGNAL_DETAILED SIGNAL_ACTION SIGNAL_NO_HOOKS SIGNAL_MUST_COLLECT SIGNAL_DEPRECATED )
type SignalListenerData ¶
type SignalListenerData []interface{}
type SignalListenerFn ¶
type SignalListenerFn func(data []interface{}, argv ...interface{}) EventFlag
type SignalMatchType ¶
type SignalMatchType uint64
Signal match type
const ( SIGNAL_MATCH_ID SignalMatchType = 1 << 0 SIGNAL_MATCH_DETAIL SignalMatchType = 1 << iota SIGNAL_MATCH_CLOSURE SIGNAL_MATCH_FUNC SIGNAL_MATCH_DATA SIGNAL_MATCH_UNBLOCKED )
type SignalRunType ¶
type SignalRunType uint64
Signal run type
const ( RUN_FIRST SignalRunType = SignalRunType(SIGNAL_RUN_FIRST) RUN_LAST SignalRunType = SignalRunType(SIGNAL_RUN_LAST) RUN_BOTH SignalRunType = SignalRunType(RUN_FIRST | RUN_LAST) RUN_NO_RECURSE SignalRunType = SignalRunType(SIGNAL_NO_RECURSE) RUN_ACTION SignalRunType = SignalRunType(SIGNAL_ACTION) RUN_NO_HOOKS SignalRunType = SignalRunType(SIGNAL_NO_HOOKS) )
type Signaling ¶
type Signaling interface { TypeItem Connect(signal Signal, handle string, c SignalListenerFn, data ...interface{}) Disconnect(signal Signal, handle string) error Emit(signal Signal, argv ...interface{}) EventFlag StopSignal(signal Signal) IsSignalStopped(signal Signal) bool PassSignal(signal Signal) IsSignalPassed(signal Signal) bool ResumeSignal(signal Signal) Freeze() Thaw() IsFrozen() bool }
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
Style represents a complete text style, including both foreground color, background color, and additional attributes such as "bold" or "underline".
Note that not all terminals can display all colors or attributes, and many might have specific incompatibilities between specific attributes and color combinations.
To use Style, just declare a variable of its type.
var StyleDefault Style
StyleDefault represents a default style, based upon the context. It is the zero value.
func ParseStyle ¶ added in v0.0.5
func (Style) Attributes ¶
Attributes returns a new style based on s, with its attributes set as specified.
func (Style) Background ¶
Background returns a new style based on s, with the background color set as requested. ColorDefault can be used to select the global default.
func (Style) Blink ¶
Blink returns a new style based on s, with the blink attribute set as requested.
func (Style) Decompose ¶
Decompose breaks a style up, returning the foreground, background, and other attributes.
func (Style) Foreground ¶
Foreground returns a new style based on s, with the foreground color set as requested. ColorDefault can be used to select the global default.
func (Style) Italic ¶
Italic returns a new style based on s, with the italic attribute set as requested.
func (Style) Reverse ¶
Reverse returns a new style based on s, with the reverse attribute set as requested. (Reverse usually changes the foreground and background colors.)
func (Style) StrikeThrough ¶
StrikeThrough sets strikethrough mode.
type Tango ¶
type Tango interface { Raw() string TextBuffer(mnemonic bool) TextBuffer }
type TargetFlags ¶
type TargetFlags uint64
Target flags
const ( TARGET_SAME_APP TargetFlags = 1 << 0 TARGET_SAME_WIDGET TargetFlags = 1 << iota TARGET_OTHER_APP TARGET_OTHER_WIDGET )
type TextBuffer ¶
type TextBuffer interface { Set(input string, style Style) Input() (raw string) SetInput(input WordLine) Style() Style SetStyle(style Style) Mnemonic() (enabled bool) SetMnemonic(enabled bool) CharacterCount() (cellCount int) WordCount() (wordCount int) ClearText(wordWrap WrapMode, ellipsize bool, justify Justification, maxChars int) (plain string) PlainText(wordWrap WrapMode, ellipsize bool, justify Justification, maxChars int) (plain string) PlainTextInfo(wordWrap WrapMode, ellipsize bool, justify Justification, maxChars int) (longestLine, lineCount int) Draw(canvas Canvas, singleLine bool, wordWrap WrapMode, ellipsize bool, justify Justification, vAlign VerticalAlignment) EventFlag }
func NewEmptyTextBuffer ¶
func NewEmptyTextBuffer(style Style, mnemonic bool) TextBuffer
func NewTextBuffer ¶
func NewTextBuffer(input string, style Style, mnemonic bool) TextBuffer
type TextCell ¶
type TextCell interface { Dirty() bool Set(r rune) SetByte(b []byte) SetStyle(style Style) Equals(mc rune, style Style, width int) bool Width() int Value() rune String() string Style() Style IsNil() bool IsSpace() bool }
func NewRuneCell ¶
func NewTextCell ¶
type TextChar ¶
type TextChar interface { Set(r rune) SetByte(b []byte) Width() int Value() rune String() string IsSpace() bool }
func NewTextChar ¶
type Theme ¶
type Theme struct { Content ThemeAspect Border ThemeAspect }
func GetCurrentTheme ¶ added in v0.0.4
func GetCurrentTheme() (theme Theme)
type ThemeAspect ¶ added in v0.0.4
type ThemeAspect struct { Normal Style Focused Style Active Style FillRune rune BorderRunes BorderRuneSet ArrowRunes ArrowRuneSet Overlay bool // keep existing background }
func (ThemeAspect) String ¶ added in v0.0.4
func (t ThemeAspect) String() string
type TimerCallbackFn ¶
type TimerCallbackFn = func() EventFlag
type Type ¶
type TypeItem ¶
type TypeItem interface { sync.Locker InitTypeItem(tag TypeTag, thing interface{}) (already bool) Init() (already bool) IsValid() bool Self() (this interface{}) String() string GetTypeTag() TypeTag GetName() string SetName(name string) ObjectID() int ObjectName() string DestroyObject() (err error) LogTag() string LogTrace(format string, argv ...interface{}) LogDebug(format string, argv ...interface{}) LogInfo(format string, argv ...interface{}) LogWarn(format string, argv ...interface{}) LogError(format string, argv ...interface{}) LogErr(err error) }
func NewTypeItem ¶
type TypeRegistry ¶
type TypeRegistry interface { GetTypeTags() (tags []TypeTag) GetBuildableInfo() (info map[string]TypeTag) MakeType(tag TypeTag) (thing interface{}, err error) AddType(tag TypeTag, constructor func() interface{}, aliases ...string) error HasType(tag TypeTag) (exists bool) GetType(tag TypeTag) (t Type, ok bool) AddTypeAlias(tag TypeTag, alias ...string) GetTypeTagByAlias(alias string) (tt TypeTag, ok bool) AddTypeItem(tag TypeTag, item interface{}) (id int, err error) HasID(index int) bool GetNextID() (id int) GetTypeItems(tag TypeTag) []interface{} GetTypeItemByID(id int) interface{} GetTypeItemByName(name string) interface{} RemoveTypeItem(tag TypeTag, item TypeItem) error }
func NewTypeRegistry ¶
func NewTypeRegistry() TypeRegistry
type TypeTag ¶
type TypeTag interface { Tag() CTypeTag String() string GladeString() string ClassName() string Equals(tt TypeTag) bool Less(tt TypeTag) bool Valid() bool }
func MakeTypeTag ¶ added in v0.0.5
constructs a new TypeTag instance
type VerticalAlignment ¶
type VerticalAlignment uint
const ( ALIGN_TOP VerticalAlignment = 0 ALIGN_BOTTOM VerticalAlignment = 1 ALIGN_MIDDLE VerticalAlignment = 2 )
type Window ¶
type Window interface { Object GetTitle() string SetTitle(title string) GetDisplayManager() DisplayManager SetDisplayManager(d DisplayManager) Draw(canvas Canvas) EventFlag ProcessEvent(evt Event) EventFlag }
Basic window interface
func NewOffscreenWindow ¶
func NewWindow ¶
func NewWindow(title string, d DisplayManager) Window
type WindowType ¶
type WindowType uint64
Window type
const ( WINDOW_TOPLEVEL WindowType = iota WINDOW_POPUP )
type WordCell ¶
type WordCell interface { Characters() []TextCell Set(word string, style Style) GetCharacter(index int) (char TextCell) AppendRune(r rune, style Style) IsNil() bool IsSpace() bool HasSpace() bool Len() (count int) CompactLen() (count int) Value() (word string) String() (s string) }
func NewEmptyWordCell ¶
func NewEmptyWordCell() WordCell
func NewNilWordCell ¶ added in v0.0.4
func NewWordCell ¶
type WordLine ¶
type WordLine interface { SetLine(line string, style Style) AppendWord(word string, style Style) AppendWordCell(word WordCell) AppendWordRune(wordIndex int, char rune, style Style) error GetWord(index int) WordCell RemoveWord(index int) GetCharacter(index int) TextCell SetCharacter(index int, r rune) Words() []WordCell Len() (wordSpaceCount int) CharacterCount() (count int) WordCount() (wordCount int) HasSpace() bool Value() (s string) String() (s string) Make(mnemonic bool, wrap WrapMode, ellipsize bool, justify Justification, maxChars int, fillerStyle Style) (formatted []WordLine) }
func NewEmptyWordLine ¶
func NewEmptyWordLine() WordLine
func NewWordLine ¶
type WordLineCacheFn ¶ added in v0.0.4
type WordLineCacheFn = func() []WordLine
type WordPageCache ¶ added in v0.0.4
type WordPageCache interface {
Hit(tag string, fn WordLineCacheFn) []WordLine
}
Source Files
¶
- attr.go
- border.go
- buttonmask.go
- canvas.go
- canvas_buffer.go
- cdisplay.go
- cdisplay_unix.go
- cdk.go
- cdk_build_config.go
- cdk_cli_flags.go
- cell.go
- cell_buffer.go
- charset_unix.go
- clist.go
- color.go
- colorfit.go
- colormap.go
- console_display_stub.go
- ctype.go
- ctype_item.go
- ctype_item_list.go
- ctype_registry.go
- ctype_tag.go
- cursor.go
- display.go
- display_manager.go
- doc.go
- encoding.go
- enumtypes.go
- event.go
- event_error.go
- event_interrupt.go
- event_key.go
- event_mask.go
- event_mouse.go
- event_paste.go
- event_queue.go
- event_resize.go
- flag_sorter.go
- logging.go
- metadata.go
- mousestate.go
- object.go
- offscreen_display.go
- offscreen_window.go
- pixmap.go
- point2i.go
- property.go
- property_type.go
- quark.go
- range.go
- rectangle.go
- region.go
- runes.go
- sensitive.go
- signal.go
- signal_listener.go
- signaling.go
- style.go
- tango.go
- terms_default.go
- terms_dynamic.go
- testing.go
- text_buffer.go
- text_cell.go
- text_char.go
- theme.go
- timing.go
- visual.go
- window.go
- word_cell.go
- word_line.go
- word_line_cache.go
- word_line_justify.go
- word_line_wrap.go