cdk

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2021 License: Apache-2.0 Imports: 37 Imported by: 1

README

Made with Go Go version number Go Reference GoReportCard Build status codecov

CDK - Curses Development Kit

This package provides the GDK equivalent for CTK. This is not intended to be a parity of GDK in any way, rather this package simply fulfills the terminal drawing and basic event systems required by CTK.

Unless you're using CTK, you should really be using TCell instead.

Notice

This project should not be used for any purpose other than intellectual curiosity. This project, in its current iteration, is strictly a Proof-of-Concept and nothing more. The lessons learned so far are being incorporated into a clean rewrite of the entire thing.

This status is reflected in the tagged versioning of this trunk branch, v0.0.x, ie: entirely experimental and unfinished in any sense of the word "done".

Installing
go get -u github.com/kckrinke/go-cdk
Building

A makefile has been included to assist in the development workflow.

> make help
usage: make {help|test|clean|demos}

  test: perform all available tests
  clean: cleans package  and built files
  demos: builds the boxes, mouse and unicode demos

Example Usage

While CDK is not intended for direct usage, there are some simple demonstration applications provided.

CDK Demo

A formal CDK application demonstrating the typical boilerplate setup.

Running the tests

CDK provides tests for color, event, runes and styles using the simulation screen. To run the tests, use the make-file for convenience:

> go test -v
testing cdk
  ... (per-test output, trimmed for brevity) ...
ok      github.com/kckrinke/go-cdk  0.171s

Versioning

The current API is unstable and subject to change dramatically. The following is a brief summary of the planned iterations.

  • v0.0.x - Proof of concept, experimental
  • v0.1.x - Rewrite of CDK package, without any (Screen) terminal interface
  • v0.2.x - Write a new Screen interface, following GDK semantics
  • v1.0.0 - First official release, directly related to v1.0.0 of CTK

License

This project is licensed under the Apache 2.0 license - see the LICENSE.md file for details.

Authors and Contributors

  • Kevin C. Krinke - CDK author - kckrinke

Acknowledgments

  • Thanks to TCell for providing a solid and robust platform to build upon.
TCell Authors and Contributors
  • Garrett D'Amore - Original author - gdamore
  • Zachary Yedidia - Contributor - zyedidia
  • Junegunn Choi - Contributor - junegunn
  • Staysail Systems, Inc. - Support Provider - website

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

View Source
const (
	ColorBlack = ColorValid + iota
	ColorMaroon
	ColorGreen
	ColorOlive
	ColorNavy
	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
	ColorNavajoWhite
	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.

View Source
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.

View Source
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)
)
View Source
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"
)
View Source
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
)
View Source
const (
	KeyBackspace  = KeyBS
	KeyTab        = KeyTAB
	KeyEsc        = KeyESC
	KeyEscape     = KeyESC
	KeyEnter      = KeyCR
	KeyBackspace2 = KeyDEL
)

These keys are aliases for other names.

View Source
const (
	LevelError string = "error"
	LevelWarn  string = "warn"
	LevelInfo  string = "info"
	LevelDebug string = "debug"
	LevelTrace string = "trace"
)
View Source
const (
	FormatPretty string = "pretty"
	FormatText   string = "text"
	FormatJson   string = "json"
)
View Source
const (
	OutputStderr string = "stderr"
	OutputStdout string = "stdout"
	OutputFile   string = "file"
)
View Source
const (
	TypeMetaData      CTypeTag = "cdk-metadata"
	SignalSetProperty Signal   = "set-property"
)
View Source
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.

View Source
const (
	TypeSignaling       CTypeTag = "cdk-signaling"
	SignalSignalingInit Signal   = "signaling-init"
)
View Source
const (
	TypeWindow       CTypeTag = "cdk-window"
	SignalDraw       Signal   = "draw"
	SignalSetTitle   Signal   = "set-title"
	SignalSetDisplay Signal   = "set-display"
)
View Source
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.

View Source
const (
	DefaultLogTimestampFormat = "2006-01-02T15:04:05.000"
)
View Source
const OffscreenDisplayTtyPath = "<offscreen>"

Variables

View Source
var (
	EventQueueSize    = 10
	EventKeyQueueSize = 10
	EventKeyTiming    = time.Millisecond * 50
	SignalQueueSize   = 10
)
View Source
var (
	DisplayCallQueueCapacity = 16
	DisplayStartupDelay      = time.Millisecond * 128
)
View Source
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")
)
View Source
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,
	}
)
View Source
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,
	}
)
View Source
var Build = Config{
	LogFile:   true,
	LogLevel:  true,
	LogLevels: true,
}
View Source
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.

View Source
var ColorValues = map[Color]int32{}/* 379 elements not displayed */

ColorValues maps color constants to their RGB values.

View Source
var (
	DefaultGoProfilePath = os.TempDir() + string(os.PathSeparator) + "cdk.pprof"
)
View Source
var (
	DefaultLogPath = os.TempDir() + string(os.PathSeparator) + "cdk.log"
)
View Source
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.

View Source
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",
	}
)

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.

View Source
var (
	TapSpace = "    "
)
View Source
var (
	TypesManager = NewTypeRegistry()
)

Functions

func AddTimeout

func AddTimeout(d time.Duration, fn TimerCallbackFn) (id int)

func CancelTimeout

func CancelTimeout(id int) bool

func DebugDF

func DebugDF(depth int, format string, argv ...interface{})

func DebugF

func DebugF(format string, argv ...interface{})

func DescribeButton

func DescribeButton(button ButtonMask) string

func DidFakeExit

func DidFakeExit() bool

func DoWithFakeIO

func DoWithFakeIO(fn func() error) (string, bool, error)

func Error

func Error(err error)

func ErrorDF

func ErrorDF(depth int, format string, argv ...interface{})

func ErrorF

func ErrorF(format string, argv ...interface{})

func Exit

func Exit(code int)

func FakeExiting

func FakeExiting()

func Fatal

func Fatal(err error)

func FatalDF

func FatalDF(depth int, format string, argv ...interface{})

func FatalF

func FatalF(format string, argv ...interface{})

func GetCharset

func GetCharset() string

func GetEncoding

func GetEncoding(charset string) encoding.Encoding

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 GetLastFakeIO() (string, int, error)

func InfoDF

func InfoDF(depth int, format string, argv ...interface{})

func InfoF

func InfoF(format string, argv ...interface{})

func ListEncodings

func ListEncodings() []string

func LookupKeyName added in v0.0.5

func LookupKeyName(key Key) string

func MakeTag added in v0.0.4

func MakeTag(argv ...interface{}) (tag string)

func Panic added in v0.0.5

func Panic(err error)

func PanicDF added in v0.0.5

func PanicDF(depth int, format string, argv ...interface{})

func PanicF added in v0.0.5

func PanicF(format string, argv ...interface{})

func QuarkToString added in v0.0.5

func QuarkToString(id QuarkID) string

Gets the string associated with the given GQuark.

Parameters:

quark    a GQuark.

Returns:

the string associated with the GQuark

func RegisterEncoding

func RegisterEncoding(charset string, enc encoding.Encoding)

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 TraceDF

func TraceDF(depth int, format string, argv ...interface{})

func TraceF

func TraceF(format string, argv ...interface{})

func UnregisterEncoding

func UnregisterEncoding(charset string)

func WarnDF

func WarnDF(depth int, format string, argv ...interface{})

func WarnF

func WarnF(format string, argv ...interface{})

func WithApp

func WithApp(initFn DisplayInitFn, action AppFn) func()

func WithDisplayManager

func WithDisplayManager(action DisplayManagerFn) func()

Types

type App

type App interface {
	GetContext() *cli.Context
	Tag() string
	Title() string
	Name() string
	Usage() string
	DisplayManager() DisplayManager
	CLI() *cli.App
	Version() string
	InitUI() error
	AddFlag(f cli.Flag)
	AddCommand(c *cli.Command)
	Run(args []string) error
	MainActionFn(c *cli.Context) error
}

type AppFn

type AppFn func(app App)

type ArrowRuneSet added in v0.0.4

type ArrowRuneSet struct {
	Up    rune
	Left  rune
	Down  rune
	Right rune
}

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 (m AttrMask) Blink(v bool) AttrMask

return the attributes with (true) or without (false) blink

func (AttrMask) Bold

func (m AttrMask) Bold(v bool) AttrMask

return the attributes with (true) or without (false) bold

func (AttrMask) Dim

func (m AttrMask) Dim(v bool) AttrMask

return the attributes with (true) or without (false) dim

func (m AttrMask) IsBlink() bool

check if the attributes include blink

func (AttrMask) IsBold

func (m AttrMask) IsBold() bool

check if the attributes include bold

func (AttrMask) IsDim

func (m AttrMask) IsDim() bool

check if the attributes include dim

func (AttrMask) IsNormal

func (m AttrMask) IsNormal() bool

check if the attributes are normal

func (AttrMask) IsReverse

func (m AttrMask) IsReverse() bool

check if the attributes include reverse

func (AttrMask) IsUnderline

func (m AttrMask) IsUnderline() bool

check if the attributes include underline

func (AttrMask) Normal

func (m AttrMask) Normal() AttrMask

return a normal attribute mask

func (AttrMask) Reverse

func (m AttrMask) Reverse(v bool) AttrMask

return the attributes with (true) or without (false) reverse

func (AttrMask) Underline

func (m AttrMask) Underline(v bool) AttrMask

return the attributes with (true) or without (false) underline

type Border added in v0.0.5

type Border struct {
	DrawLeft    bool
	DrawRight   bool
	DrawTop     bool
	DrawBottom  bool
	TopLeft     rune
	Top         rune
	TopRight    rune
	Left        rune
	Right       rune
	BottomLeft  rune
	Bottom      rune
	BottomRight rune
}

func NewBorder added in v0.0.5

func NewBorder() *Border

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) AddFlag

func (app *CApp) AddFlag(flag cli.Flag)

func (*CApp) AddFlags added in v0.0.5

func (app *CApp) AddFlags(flags []cli.Flag)

func (*CApp) CLI

func (app *CApp) CLI() *cli.App

func (*CApp) Destroy

func (app *CApp) Destroy()

func (*CApp) DisplayManager

func (app *CApp) DisplayManager() DisplayManager

func (*CApp) GetContext

func (app *CApp) GetContext() *cli.Context

func (*CApp) InitUI

func (app *CApp) InitUI() error

func (*CApp) MainActionFn

func (app *CApp) MainActionFn(c *cli.Context) error

func (*CApp) Name

func (app *CApp) Name() string

func (*CApp) Run

func (app *CApp) Run(args []string) error

func (*CApp) Tag

func (app *CApp) Tag() string

func (*CApp) Title

func (app *CApp) Title() string

func (*CApp) Usage

func (app *CApp) Usage() string

func (*CApp) Version

func (app *CApp) Version() string

type CCanvas

type CCanvas struct {
	// contains filtered or unexported fields
}

concrete implementation of the Canvas interface

func NewCanvas

func NewCanvas(origin Point2I, size Rectangle, style Style) *CCanvas

create a new canvas object with the given origin point, size and theme

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 (c *CCanvas) BoxWithTheme(pos Point2I, size Rectangle, border, fill bool, theme Theme)

func (*CCanvas) Composite

func (c *CCanvas) Composite(v Canvas) error

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

func (c *CCanvas) DebugBox(color Color, format string, argv ...interface{})

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

func (c *CCanvas) DrawHorizontalLine(pos Point2I, length int, style Style)

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

func (c *CCanvas) DrawVerticalLine(pos Point2I, length int, style Style)

convenience method to draw a vertical line

func (*CCanvas) Equals

func (c *CCanvas) Equals(onlyDirty bool, v Canvas) bool

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) Fill

func (c *CCanvas) Fill(theme Theme)

fill the entire canvas according to the given theme

func (*CCanvas) FillBorder

func (c *CCanvas) FillBorder(dim, border bool, theme Theme)

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

func (c *CCanvas) GetContent(x, y int) (textCell TextCell)

get the text cell at the given coordinates

func (*CCanvas) GetOrigin

func (c *CCanvas) GetOrigin() Point2I

get the origin point of the canvas

func (*CCanvas) GetSize

func (c *CCanvas) GetSize() Rectangle

get the rectangle size of the canvas

func (*CCanvas) GetStyle added in v0.0.4

func (c *CCanvas) GetStyle() (style Style)

func (*CCanvas) Height

func (c *CCanvas) Height() (height int)

convenience method to get just the height of the canvas

func (*CCanvas) Render

func (c *CCanvas) Render(display Display) error

render this canvas upon the given display

func (*CCanvas) Resize

func (c *CCanvas) Resize(size Rectangle, style Style)

change the size of the canvas, not recommended to do this in practice

func (*CCanvas) SetContent

func (c *CCanvas) SetContent(x, y int, char string, s Style) error

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

func (c *CCanvas) SetOrigin(origin Point2I)

set the origin (top-left corner) position of the canvas, used when compositing one canvas with another

func (*CCanvas) SetRune

func (c *CCanvas) SetRune(x, y int, r rune, s Style) error

set the rune and the style of the cell at the given coordinates

func (CCanvas) String

func (c CCanvas) String() string

return a string describing the canvas metadata, useful for debugging

func (*CCanvas) Width

func (c *CCanvas) Width() (width int)

convenience method to get just the width of the canvas

type CCanvasBuffer

type CCanvasBuffer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func (b *CCanvasBuffer) SetContent(x int, y int, r rune, style Style) error

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 CColormap added in v0.0.5

type CColormap struct {
}

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 CList added in v0.0.5

type CList interface {
}

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 (o *CMetaData) GetBoolProperty(name Property) (value bool, err error)

func (*CMetaData) GetColorProperty added in v0.0.5

func (o *CMetaData) GetColorProperty(name Property) (value Color, err error)

func (*CMetaData) GetFloat64Property added in v0.0.5

func (o *CMetaData) GetFloat64Property(name Property) (value float64, err error)

func (*CMetaData) GetFloatProperty added in v0.0.5

func (o *CMetaData) GetFloatProperty(name Property) (value float64, err error)

func (*CMetaData) GetIntProperty added in v0.0.5

func (o *CMetaData) GetIntProperty(name Property) (value int, err error)

func (*CMetaData) GetPointProperty added in v0.0.5

func (o *CMetaData) GetPointProperty(name Property) (value Point2I, err error)

func (*CMetaData) GetProperty added in v0.0.5

func (o *CMetaData) GetProperty(name Property) *CProperty

func (*CMetaData) GetRectangleProperty added in v0.0.5

func (o *CMetaData) GetRectangleProperty(name Property) (value Rectangle, err error)

func (*CMetaData) GetRegionProperty added in v0.0.5

func (o *CMetaData) GetRegionProperty(name Property) (value Region, err error)

func (*CMetaData) GetStringProperty added in v0.0.5

func (o *CMetaData) GetStringProperty(name Property) (value string, err error)

func (*CMetaData) GetStructProperty added in v0.0.5

func (o *CMetaData) GetStructProperty(name Property) (value interface{}, err error)

func (*CMetaData) GetStyleProperty added in v0.0.5

func (o *CMetaData) GetStyleProperty(name Property) (value Style, err error)

func (*CMetaData) GetThemeProperty added in v0.0.5

func (o *CMetaData) GetThemeProperty(name Property) (value Theme, err error)

func (*CMetaData) Init added in v0.0.5

func (o *CMetaData) Init() (already bool)

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 (o *CMetaData) IsBuildableProperty(name Property) bool

func (*CMetaData) IsProperty added in v0.0.5

func (o *CMetaData) IsProperty(name Property) bool

func (*CMetaData) ListBuildableProperties added in v0.0.5

func (o *CMetaData) ListBuildableProperties() (properties []Property)

func (*CMetaData) ListProperties added in v0.0.5

func (o *CMetaData) ListProperties() (properties []Property)

func (*CMetaData) OverloadProperty added in v0.0.5

func (o *CMetaData) OverloadProperty(name Property, kind PropertyType, write bool, buildable bool, def interface{}) error

func (*CMetaData) SetBoolProperty added in v0.0.5

func (o *CMetaData) SetBoolProperty(name Property, value bool) error

func (*CMetaData) SetColorProperty added in v0.0.5

func (o *CMetaData) SetColorProperty(name Property, value Color) error

func (*CMetaData) SetFloatProperty added in v0.0.5

func (o *CMetaData) SetFloatProperty(name Property, value float64) error

func (*CMetaData) SetIntProperty added in v0.0.5

func (o *CMetaData) SetIntProperty(name Property, value int) error

func (*CMetaData) SetPointProperty added in v0.0.5

func (o *CMetaData) SetPointProperty(name Property, value Point2I) error

func (*CMetaData) SetProperties added in v0.0.5

func (o *CMetaData) SetProperties(properties map[Property]string) (err error)

func (*CMetaData) SetProperty added in v0.0.5

func (o *CMetaData) SetProperty(name Property, value interface{}) error

func (*CMetaData) SetPropertyFromString added in v0.0.5

func (o *CMetaData) SetPropertyFromString(name Property, value string) error

func (*CMetaData) SetRectangleProperty added in v0.0.5

func (o *CMetaData) SetRectangleProperty(name Property, value Rectangle) error

func (*CMetaData) SetRegionProperty added in v0.0.5

func (o *CMetaData) SetRegionProperty(name Property, value Region) error

func (*CMetaData) SetStringProperty added in v0.0.5

func (o *CMetaData) SetStringProperty(name Property, value string) error

func (*CMetaData) SetStructProperty added in v0.0.5

func (o *CMetaData) SetStructProperty(name Property, value interface{}) error

func (*CMetaData) SetStyleProperty added in v0.0.5

func (o *CMetaData) SetStyleProperty(name Property, value Style) error

func (*CMetaData) SetThemeProperty added in v0.0.5

func (o *CMetaData) SetThemeProperty(name Property, value Theme) error

type CObject

type CObject struct {
	CMetaData
}

func (*CObject) Destroy

func (o *CObject) Destroy()

func (*CObject) GetName added in v0.0.5

func (o *CObject) GetName() (name string)

func (*CObject) GetTheme

func (o *CObject) GetTheme() (theme Theme)

func (*CObject) GetThemeRequest added in v0.0.4

func (o *CObject) GetThemeRequest() (theme Theme)

func (*CObject) Init

func (o *CObject) Init() (already bool)

func (*CObject) InitWithProperties added in v0.0.5

func (o *CObject) InitWithProperties(properties map[Property]string) (already bool, err error)

func (*CObject) SetName added in v0.0.5

func (o *CObject) SetName(name string)

func (*CObject) SetTheme

func (o *CObject) SetTheme(theme Theme)

func (*CObject) SetThemeRequest added in v0.0.4

func (o *CObject) SetThemeRequest(theme Theme)

type COffscreenDisplay

type COffscreenDisplay struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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 (o *COffscreenDisplay) GetContent(x, y int) (mc rune, comb []rune, style Style, width int)

func (*COffscreenDisplay) GetContents

func (o *COffscreenDisplay) GetContents() ([]OffscreenCell, int, int)

func (*COffscreenDisplay) GetCursor

func (o *COffscreenDisplay) GetCursor() (int, int, bool)

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) Resize

func (o *COffscreenDisplay) Resize(int, int, int, int)

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 CPixmap added in v0.0.5

type CPixmap struct {
}

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) Buildable added in v0.0.5

func (p *CProperty) Buildable() bool

func (*CProperty) Clone added in v0.0.5

func (p *CProperty) Clone() *CProperty

func (*CProperty) Default added in v0.0.5

func (p *CProperty) Default() (def interface{})

func (*CProperty) Name added in v0.0.5

func (p *CProperty) Name() Property

func (*CProperty) ReadOnly added in v0.0.5

func (p *CProperty) ReadOnly() bool

func (*CProperty) Set added in v0.0.5

func (p *CProperty) Set(value interface{}) error

func (*CProperty) SetFromString added in v0.0.5

func (p *CProperty) SetFromString(value string) error

func (*CProperty) Type added in v0.0.5

func (p *CProperty) Type() PropertyType

func (*CProperty) Value added in v0.0.5

func (p *CProperty) Value() (value interface{})

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().

func (CQuark) ID added in v0.0.5

func (q CQuark) ID() QuarkID

func (CQuark) String added in v0.0.5

func (q CQuark) String() string

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) Raw

func (m *CTango) Raw() string

func (*CTango) TextBuffer

func (m *CTango) TextBuffer(mnemonic bool) TextBuffer

type CTextBuffer

type CTextBuffer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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 CTextCell

type CTextCell struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*CTextCell) Dirty

func (t *CTextCell) Dirty() bool

func (*CTextCell) Equals added in v0.0.5

func (t *CTextCell) Equals(mc rune, style Style, width int) bool

func (*CTextCell) IsNil added in v0.0.4

func (t *CTextCell) IsNil() bool

func (*CTextCell) IsSpace

func (t *CTextCell) IsSpace() bool

func (*CTextCell) Set

func (t *CTextCell) Set(r rune)

func (*CTextCell) SetByte

func (t *CTextCell) SetByte(b []byte)

func (*CTextCell) SetStyle

func (t *CTextCell) SetStyle(style Style)

func (*CTextCell) String

func (t *CTextCell) String() string

func (*CTextCell) Style

func (t *CTextCell) Style() Style

func (*CTextCell) Value

func (t *CTextCell) Value() rune

func (*CTextCell) Width

func (t *CTextCell) Width() int

type CTextChar

type CTextChar struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*CTextChar) IsSpace

func (c *CTextChar) IsSpace() bool

func (*CTextChar) Set

func (c *CTextChar) Set(r rune)

func (*CTextChar) SetByte

func (c *CTextChar) SetByte(b []byte)

func (*CTextChar) String

func (c *CTextChar) String() string

func (*CTextChar) Value

func (c *CTextChar) Value() rune

func (*CTextChar) Width

func (c *CTextChar) Width() int

type CType

type CType struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*CType) Add

func (t *CType) Add(item interface{})

func (*CType) Aliases added in v0.0.5

func (t *CType) Aliases() (aliases []string)

func (*CType) Buildable added in v0.0.5

func (t *CType) Buildable() (hasConstructor bool)

func (*CType) Items

func (t *CType) Items() []interface{}

func (*CType) New added in v0.0.5

func (t *CType) New() interface{}

func (*CType) Remove

func (t *CType) Remove(item TypeItem) error

type CTypeItem

type CTypeItem struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*CTypeItem) DestroyObject

func (o *CTypeItem) DestroyObject() (err error)

func (*CTypeItem) GetName

func (o *CTypeItem) GetName() string

func (*CTypeItem) GetTypeTag

func (o *CTypeItem) GetTypeTag() TypeTag

func (*CTypeItem) Init

func (o *CTypeItem) Init() (already bool)

func (*CTypeItem) InitTypeItem

func (o *CTypeItem) InitTypeItem(tag TypeTag, thing interface{}) (already bool)

func (*CTypeItem) IsValid

func (o *CTypeItem) IsValid() bool

func (*CTypeItem) LogDebug

func (o *CTypeItem) LogDebug(format string, argv ...interface{})

func (*CTypeItem) LogErr

func (o *CTypeItem) LogErr(err error)

func (*CTypeItem) LogError

func (o *CTypeItem) LogError(format string, argv ...interface{})

func (*CTypeItem) LogInfo

func (o *CTypeItem) LogInfo(format string, argv ...interface{})

func (*CTypeItem) LogTag

func (o *CTypeItem) LogTag() string

func (*CTypeItem) LogTrace

func (o *CTypeItem) LogTrace(format string, argv ...interface{})

func (*CTypeItem) LogWarn

func (o *CTypeItem) LogWarn(format string, argv ...interface{})

func (*CTypeItem) ObjectID

func (o *CTypeItem) ObjectID() int

func (*CTypeItem) ObjectName

func (o *CTypeItem) ObjectName() string

func (*CTypeItem) Self added in v0.0.5

func (o *CTypeItem) Self() (this interface{})

func (*CTypeItem) SetName

func (o *CTypeItem) SetName(name string)

func (*CTypeItem) String

func (o *CTypeItem) String() string

type CTypeItemList

type CTypeItemList []TypeItem

func (CTypeItemList) Index

func (t CTypeItemList) Index(item TypeItem) int

type CTypeRegistry

type CTypeRegistry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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) GetType

func (r *CTypeRegistry) GetType(tag TypeTag) (t Type, ok bool)

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 NewTypeTag

func NewTypeTag(tag string) CTypeTag

constructs a new Concrete TypeTag instance

func (CTypeTag) ClassName added in v0.0.5

func (tag CTypeTag) ClassName() string

returns the CamelCase, or "Class Name", version of this type tag

func (CTypeTag) Equals added in v0.0.5

func (tag CTypeTag) Equals(tt TypeTag) bool

returns true if the given type tag is the same as this type tag

func (CTypeTag) GladeString added in v0.0.5

func (tag CTypeTag) GladeString() string

returns a string representation of this type tag, translated for Gtk class naming conventions (ie: GtkCamelCase)

func (CTypeTag) Less added in v0.0.5

func (tag CTypeTag) Less(tt TypeTag) bool

returns true if this type tag is numerically less than the given type tag, used in sorting routines

func (CTypeTag) String

func (tag CTypeTag) String() string

Stringer interface implementation

func (CTypeTag) Tag

func (tag CTypeTag) Tag() CTypeTag

returns the underlying CTypeTag instance

func (CTypeTag) Valid added in v0.0.5

func (tag CTypeTag) Valid() bool

type CVisual added in v0.0.5

type CVisual struct {
}

type CWindow

type CWindow struct {
	CObject
	// contains filtered or unexported fields
}

Basic window type

func (*CWindow) Draw

func (w *CWindow) Draw(canvas Canvas) EventFlag

func (*CWindow) GetDisplayManager

func (w *CWindow) GetDisplayManager() DisplayManager

func (*CWindow) GetTitle

func (w *CWindow) GetTitle() string

func (*CWindow) Init

func (w *CWindow) Init() bool

func (*CWindow) ProcessEvent

func (w *CWindow) ProcessEvent(evt Event) EventFlag

func (*CWindow) SetDisplayManager

func (w *CWindow) SetDisplayManager(d DisplayManager)

func (*CWindow) SetTitle

func (w *CWindow) SetTitle(title string)

type CWordCell

type CWordCell struct {
	// contains filtered or unexported fields
}

func (*CWordCell) AppendRune

func (w *CWordCell) AppendRune(r rune, style Style)

func (*CWordCell) Characters

func (w *CWordCell) Characters() []TextCell

func (*CWordCell) CompactLen

func (w *CWordCell) CompactLen() (count int)

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

func (w *CWordCell) GetCharacter(index int) (char TextCell)

func (*CWordCell) HasSpace

func (w *CWordCell) HasSpace() bool

func (*CWordCell) IsNil added in v0.0.4

func (w *CWordCell) IsNil() bool

func (*CWordCell) IsSpace

func (w *CWordCell) IsSpace() bool

func (*CWordCell) Len

func (w *CWordCell) Len() (count int)

the total number of characters in this word

func (*CWordCell) Set

func (w *CWordCell) Set(word string, style Style)

func (*CWordCell) String

func (w *CWordCell) String() (s string)

returns the debuggable value of the word

func (*CWordCell) Value

func (w *CWordCell) Value() (word string)

returns the literal string value of the word

type CWordLine

type CWordLine struct {
	// contains filtered or unexported fields
}

func (*CWordLine) AppendWord

func (w *CWordLine) AppendWord(word string, style Style)

func (*CWordLine) AppendWordCell

func (w *CWordLine) AppendWordCell(word WordCell)

func (*CWordLine) AppendWordRune

func (w *CWordLine) AppendWordRune(wordIndex int, char rune, style Style) error

func (*CWordLine) CharacterCount

func (w *CWordLine) CharacterCount() (count int)

func (*CWordLine) GetCharacter

func (w *CWordLine) GetCharacter(index int) TextCell

func (*CWordLine) GetWord

func (w *CWordLine) GetWord(index int) WordCell

func (*CWordLine) HasSpace

func (w *CWordLine) HasSpace() bool

func (*CWordLine) Len

func (w *CWordLine) Len() (wordSpaceCount int)

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 (w *CWordLine) RemoveWord(index int)

func (*CWordLine) SetCharacter added in v0.0.4

func (w *CWordLine) SetCharacter(index int, r rune)

func (*CWordLine) SetLine

func (w *CWordLine) SetLine(line string, style Style)

func (*CWordLine) String

func (w *CWordLine) String() (s string)

func (*CWordLine) Value

func (w *CWordLine) Value() (s string)

func (*CWordLine) WordCount

func (w *CWordLine) WordCount() (wordCount int)

func (*CWordLine) Words

func (w *CWordLine) Words() []WordCell

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 CWordPage added in v0.0.4

type CWordPage []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

type CanvasForEachFn = func(x, y int, cell TextCell) EventFlag

func signature used when iterating over each cell

type CellBuffer

type CellBuffer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func (cb *CellBuffer) GetContent(x, y int) (mainc rune, combc []rune, style Style, width int)

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

func (cb *CellBuffer) SetContent(x int, y int, mainc rune, combc []rune, style Style)

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

func FindColor(c Color, palette []Color) Color

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

func GetColor(name string) Color

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

func NewHexColor(v int32) Color

NewHexColor returns a color using the given 24-bit RGB value.

func NewRGBColor

func NewRGBColor(r, g, b int32) Color

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

func PaletteColor(index int) Color

PaletteColor creates a color based on the palette index.

func ParseColor added in v0.0.5

func ParseColor(name string) (c Color, ok bool)

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

func (c Color) Hex() int32

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) IsRGB

func (c Color) IsRGB() bool

IsRGB is true if the color is an RGB specific value.

func (Color) RGB

func (c Color) RGB() (int32, int32, int32)

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

func (c Color) String() string

Stringer interface implementation so the Color can be used in normal fmt operations without required the developer to jump any hoops.

func (Color) TrueColor

func (c Color) TrueColor() Color

TrueColor returns the true color (RGB) version of the provided color. This is useful for ensuring color accuracy when using named colors. This will override terminal theme colors.

func (Color) Valid

func (c Color) Valid() bool

Valid indicates the color is a valid value (has been set).

type Colormap added in v0.0.5

type Colormap interface {
}

type Config

type Config struct {
	Profiling          bool
	LogFile            bool
	LogFormat          bool
	LogFullPaths       bool
	LogLevel           bool
	LogLevels          bool
	LogTimestamps      bool
	LogTimestampFormat bool
	LogOutput          bool
}

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

func NewConsoleDisplay() (Display, error)

NewConsoleDisplay returns a console based display. This platform doesn't have support for any, so it returns nil and a suitable error.

func NewDisplay

func NewDisplay() (Display, error)

NewDisplay returns a default Display suitable for the user's terminal environment.

func NewTerminfoDisplay

func NewTerminfoDisplay() (Display, error)

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 EnumFromString interface {
	FromString(value string) (enum interface{}, err error)
}

type Event

type Event interface {
	// When reports the time when the event was generated.
	When() time.Time
}

Event is a generic interface used for passing around Events. Concrete types follow.

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) Error

func (ev *EventError) Error() string

Error implements the error.

func (*EventError) When

func (ev *EventError) When() time.Time

When returns the time when the event was created.

type EventFlag

type EventFlag int

CEvent handling event flag type

const (
	EVENT_PASS EventFlag = iota // Allow other handlers to process
	EVENT_STOP                  // Prevent further event handling
)

CEvent handling event flags

type EventHandler

type EventHandler interface {
	HandleEvent(Event) bool
}

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

func NewEventKey(k Key, ch rune, mod ModMask) *EventKey

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

func (ev *EventKey) Key() 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

func (ev *EventKey) Modifiers() ModMask

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

func (ev *EventKey) Name() string

Name returns a printable value or the key stroke. This can be used when printing the event, for example.

func (*EventKey) Rune

func (ev *EventKey) Rune() rune

Rune returns the rune corresponding to the key press, if it makes sense. The result is only defined if the value of Key() is KeyRune.

func (*EventKey) When

func (ev *EventKey) When() time.Time

When returns the time when this Event was created, which should closely match the time when the key was pressed.

type EventMask added in v0.0.5

type EventMask uint64
const (
	EVENT_MASK_NONE EventMask = iota
	EVENT_MASK_KEY
	EVENT_MASK_MOUSE
	EVENT_MASK_PASTE
	EVENT_MASK_QUEUE
	EVENt_MASK_RESIZE
)

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

func NewEventTime(t time.Time) *EventTime

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

func (e *EventTime) SetEventTime(t time.Time)

SetEventTime sets the time of occurrence for the event.

func (*EventTime) When

func (e *EventTime) When() time.Time

When returns the time stamp when the event occurred.

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

func LookupKeyRune(r rune) Key

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.

const (
	ModShift ModMask = 1 << iota
	ModCtrl
	ModAlt
	ModMeta
	ModNone ModMask = 0
)

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.

func (ModMask) Has

func (m ModMask) Has(mask ModMask) bool

func (ModMask) String added in v0.0.5

func (m ModMask) String() string

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 Pixmap added in v0.0.5

type Pixmap interface {
}

type Point2I

type Point2I struct {
	X, Y int
}

Point2I is a 2-aspect vector represented by x and y coordinates.

func MakePoint2I

func MakePoint2I(x, y int) Point2I

Construct a new Point2I structure (non-pointer)

func NewPoint2I

func NewPoint2I(x, y int) *Point2I

Construct a new instance of a Point2I structure

func ParsePoint2I added in v0.0.5

func ParsePoint2I(value string) (point Point2I, ok bool)

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) Add added in v0.0.5

func (p *Point2I) Add(x, y int)

add the given x and y values to this Point2I

func (*Point2I) AddPoint

func (p *Point2I) AddPoint(point Point2I)

add the given Point2I to this Point2I

func (*Point2I) ClampToRegion added in v0.0.5

func (p *Point2I) ClampToRegion(region Region) (clamped bool)

restrict this Point2I instance to be within the boundaries defined by the given region

func (Point2I) Clone added in v0.0.5

func (p Point2I) Clone() (clone Point2I)

returns a new Point2I structure with the same values as this structure

func (Point2I) Equals

func (p Point2I) Equals(x, y int) bool

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

func (p Point2I) EqualsTo(o Point2I) bool

returns true if both the given Point2I and this Point2I are equivalent and false otherwise

func (Point2I) NewClone added in v0.0.5

func (p Point2I) NewClone() (clone *Point2I)

returns a new Point2I instance with the same values as this structure

func (*Point2I) Set added in v0.0.5

func (p *Point2I) Set(x, y int)

set this Point2I instance to the given x and y values

func (*Point2I) SetPoint

func (p *Point2I) SetPoint(point Point2I)

set this Point2I instance to be equivalent to the given Point2I

func (Point2I) String

func (p Point2I) String() string

returns a formal string representation of the Point2I structure, ie: "{x:0,y:0}"

func (*Point2I) Sub added in v0.0.5

func (p *Point2I) Sub(x, y int)

subtract the given x and y values from this Point2I instance

func (*Point2I) SubPoint

func (p *Point2I) SubPoint(point Point2I)

subtract the given Point2I's values from this Point2I instance

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"

func (Property) String added in v0.0.5

func (p Property) String() string

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

func QuarkFromString(text string) (qid QuarkID)

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

func QuarkTryString(text string) QuarkID

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 Range added in v0.0.4

type Range struct {
	Start, End int
}

func MakeRange added in v0.0.4

func MakeRange(start, end int) Range

func NewRange added in v0.0.4

func NewRange(start, end int) *Range

func (Range) String added in v0.0.4

func (r Range) String() string

type Rectangle

type Rectangle struct {
	W, H int
}

Rectangle is a 2-aspect vector represented by width and height values

func MakeRectangle

func MakeRectangle(w, h int) Rectangle

Construct a new Point2I structure (non-pointer)

func NewRectangle

func NewRectangle(w, h int) *Rectangle

Construct a new instance of a Point2I structure

func ParseRectangle added in v0.0.5

func ParseRectangle(value string) (point Rectangle, ok bool)

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) Add added in v0.0.5

func (r *Rectangle) Add(w, h int)

add the given w and h values to this Point2I

func (*Rectangle) AddRectangle added in v0.0.5

func (r *Rectangle) AddRectangle(size Rectangle)

add the given Point2I to this Point2I

func (*Rectangle) Clamp

func (r *Rectangle) Clamp(minWidth, minHeight, maxWidth, maxHeight int)

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 (r *Rectangle) ClampToRegion(region Region) (clamped bool)

func (Rectangle) Clone added in v0.0.5

func (r Rectangle) Clone() (clone Rectangle)

returns a new Point2I structure with the same values as this structure

func (Rectangle) Equals

func (r Rectangle) Equals(w, h int) bool

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

func (r Rectangle) EqualsTo(o Rectangle) bool

returns true if both the given Point2I and this Point2I are equivalent and false otherwise

func (*Rectangle) Floor

func (r *Rectangle) Floor(minWidth, minHeight int)

constrain the width and height values to be at least the given values or greater

func (Rectangle) NewClone added in v0.0.5

func (r Rectangle) NewClone() (clone *Rectangle)

returns a new Point2I instance with the same values as this structure

func (*Rectangle) Set added in v0.0.5

func (r *Rectangle) Set(w, h int)

set this Point2I instance to the given x and y values

func (*Rectangle) SetRectangle added in v0.0.5

func (r *Rectangle) SetRectangle(size Rectangle)

set this Point2I instance to be equivalent to the given Point2I

func (Rectangle) String

func (r Rectangle) String() string

returns a formal string representation of the Point2I structure, ie: "{w:0,h:0}"

func (*Rectangle) Sub added in v0.0.5

func (r *Rectangle) Sub(w, h int)

subtract the given x and y values from this Point2I instance

func (*Rectangle) SubRectangle added in v0.0.5

func (r *Rectangle) SubRectangle(size Rectangle)

subtract the given Point2I's values from this Point2I instance

func (Rectangle) Volume

func (r Rectangle) Volume() int

returns the volume of the Rectangle (w * h)

type Region

type Region struct {
	Point2I
	Rectangle
}

func MakeRegion

func MakeRegion(x, y, w, h int) Region

func NewRegion

func NewRegion(x, y, w, h int) *Region

func ParseRegion added in v0.0.5

func ParseRegion(value string) (point Region, ok bool)

func (Region) Clone added in v0.0.5

func (r Region) Clone() (clone Region)

func (Region) FarPoint

func (r Region) FarPoint() Point2I

func (Region) HasPoint

func (r Region) HasPoint(pos Point2I) bool

func (Region) NewClone added in v0.0.5

func (r Region) NewClone() (clone *Region)

func (Region) Origin

func (r Region) Origin() Point2I

func (*Region) Set added in v0.0.5

func (r *Region) Set(x, y, w, h int)

func (*Region) SetRegion

func (r *Region) SetRegion(region Region)

func (Region) Size

func (r Region) Size() Rectangle

func (Region) String

func (r Region) String() string

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 Sensitive added in v0.0.5

type Sensitive interface {
	ProcessEvent(evt Event) EventFlag
}

type Signal

type Signal string
const SignalDestroy Signal = "destroy"

emitted when the object instance is destroyed

func (Signal) String

func (s Signal) String() string

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 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 ParseStyle(value string) (style Style, err error)

func (Style) Attributes

func (s Style) Attributes(attrs AttrMask) Style

Attributes returns a new style based on s, with its attributes set as specified.

func (Style) Background

func (s Style) Background(c Color) Style

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 (s Style) Blink(on bool) Style

Blink returns a new style based on s, with the blink attribute set as requested.

func (Style) Bold

func (s Style) Bold(on bool) Style

Bold returns a new style based on s, with the bold attribute set as requested.

func (Style) Decompose

func (s Style) Decompose() (fg Color, bg Color, attr AttrMask)

Decompose breaks a style up, returning the foreground, background, and other attributes.

func (Style) Dim

func (s Style) Dim(on bool) Style

Dim returns a new style based on s, with the dim attribute set as requested.

func (Style) Foreground

func (s Style) Foreground(c Color) Style

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

func (s Style) Italic(on bool) Style

Italic returns a new style based on s, with the italic attribute set as requested.

func (Style) Normal

func (s Style) Normal() Style

Normal returns the style with all attributes disabled.

func (Style) Reverse

func (s Style) Reverse(on bool) Style

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

func (s Style) StrikeThrough(on bool) Style

StrikeThrough sets strikethrough mode.

func (Style) String

func (s Style) String() string

func (Style) Underline

func (s Style) Underline(on bool) Style

Underline returns a new style based on s, with the underline attribute set as requested.

type Tango

type Tango interface {
	Raw() string
	TextBuffer(mnemonic bool) TextBuffer
}

func NewMarkup

func NewMarkup(text string, style Style) (markup Tango, err error)

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 NewRuneCell(char rune, style Style) TextCell

func NewTextCell

func NewTextCell(char TextChar, style Style) TextCell

type TextChar

type TextChar interface {
	Set(r rune)
	SetByte(b []byte)
	Width() int
	Value() rune
	String() string
	IsSpace() bool
}

func NewTextChar

func NewTextChar(b []byte) TextChar

type Theme

type Theme struct {
	Content ThemeAspect
	Border  ThemeAspect
}

func GetCurrentTheme added in v0.0.4

func GetCurrentTheme() (theme Theme)

func (Theme) String

func (t Theme) String() string

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 Type interface {
	New() interface{}
	Buildable() (hasConstructor bool)
	Items() []interface{}
	Add(item interface{})
	Remove(item TypeItem) error
	Aliases() []string
}

func NewType

func NewType(tag TypeTag, constructor func() interface{}, aliases ...string) 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

func NewTypeItem(tag CTypeTag, name string) TypeItem

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

func MakeTypeTag(tag string) TypeTag

constructs a new TypeTag instance

type VerticalAlignment

type VerticalAlignment uint
const (
	ALIGN_TOP    VerticalAlignment = 0
	ALIGN_BOTTOM VerticalAlignment = 1
	ALIGN_MIDDLE VerticalAlignment = 2
)

type Visual added in v0.0.5

type Visual interface {
}

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 NewOffscreenWindow(title string) Window

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 NewNilWordCell(style Style) WordCell

func NewWordCell

func NewWordCell(word string, style Style) WordCell

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

func NewWordLine(line string, style Style) WordLine

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
}

type WrapMode

type WrapMode uint64

Wrap mode

const (
	WRAP_NONE WrapMode = iota
	WRAP_CHAR
	WRAP_WORD
	WRAP_WORD_CHAR
)

func (WrapMode) FromString added in v0.0.5

func (m WrapMode) FromString(value string) (enum interface{}, err error)

Directories

Path Synopsis
boxes just displays random colored boxes on your terminal screen.
boxes just displays random colored boxes on your terminal screen.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL