cdk

package module
v0.5.22 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 52 Imported by: 25

README

Go-Curses

Made with Go Go documentation

CDK - Curses Development Kit

This package provides a very rough 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 of CDK directly.

Notice

This project should not be used for any purpose other than intellectual curiosity. This status is reflected in the tagged versioning of this trunk branch, v0.5.x, ie: still experimental and unfinished, yet getting near the word "done".

Installing

$ go get github.com/go-curses/cdk

Building

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

$ make help
usage: make [target]

qa targets:
  vet         - run go vet command
  test        - perform all available tests
  cover       - perform all available tests with coverage report

cleanup targets:
  clean       - cleans package and built files
  clean-logs  - cleans *.log from the project

go.mod helpers:
  local       - add go.mod local package replacements
  unlocal     - remove go.mod local package replacements

build targets:
  examples    - builds all examples
  build       - build test for main cdk package
  dev         - build helloworld with profiling

run targets:
  run         - run the dev build (sanely handle crashes)
  profile.cpu - run the dev build and profile CPU
  profile.mem - run the dev build and profile memory

Hello World

An example CDK application demonstrating basic usage and a cdk.Window with customized draw handler.

Use the makefile to build the examples.

$ make examples 
# cleaning *.log files
# cleaning *.out files
# cleaning pprof files
# cleaning go caches
# cleaning binaries
# building all examples...
#	building helloworld... done.
$ ./helloworld help
NAME:
   helloworld - An example CDK application

USAGE:
   helloworld [global options] command [command options] [arguments...]

VERSION:
   0.0.1

DESCRIPTION:
   Hello World is an example CDK application

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h, --usage  display command-line usage information (default: false)
   --version            display the version (default: false)

helloworld screenshot

Application Server

This is something not found in GTK at all and is entirely exclusive to terminal environments. The idea is simple. Be able to write a terminal interface for local (/dev/tty) and/or remote connections (ssh).

Running the example

To run the example, everything necessary is already included. Start with running a make examples...

$ make examples
# cleaning *.log files
# cleaning *.out files
# cleaning pprof files
# cleaning go caches
# cleaning binaries
# building all examples...
#	building appserver... done.
#	building helloworld... done.

There should now be an appserver binary in the current directory.

$ ./appserver help
NAME:
   appserver - run an application server

USAGE:
   appserver [global options] command [command options] [arguments...]

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --listen-port value     sets the port for the server to listen on (default: 2200)
   --listen-address value  sets the address for the server to listen on (default: 0.0.0.0)
   --id-rsa value          sets the path to the server id_rsa file (default: ./examples/appserver/id_rsa)
   --htpasswd value        sets the path to the htpasswd file (default: ./examples/appserver/htpasswd)
   --daemon                start a server daemon instead of a server terminal (default: false)
   --help, -h, --usage     display command-line usage information (default: false)

We can see the default settings for the global options to the command. All of these files are included in the repository and so the defaults should "just work".

$ ./appserver

appserver server-side screenshot

A version of the helloworld.go screen should now appear displaying the time, roughly to the current second. However, in the background the default port of 2200 has been opened and is listening for ssh connections. Note that it also has a title at the top: "Server Side".

From a new terminal session, leaving the previous appserver running, login with ssh with the username foo and the password bar, using localhost and on port 2200. Note that a second user bar exists as well with the password foo.

$ ssh -p 2200 foo@localhost

appserver client-side screenshot

This new session should now be presenting a similar screen as the terminal server one, with one main difference, the title is "Client Side". This is not to say that any code is running on the "Client Side"'s shell session, just to say that this is the "connected via ssh" user interface whereas the "Server Side" one is the server user interface.

Looking back at the "Server Side" session, it should now report the new client connection.

appserver server-side-with-client screenshot

Running the tests

There are a handful of sub-packages within the CDK package. The makefile includes a make test option which covers all of these.

$ make test
# vetting cdk ... done
# testing cdk ...
=== RUN   FirstTests

  ... (per-test output, trimmed for brevity) ...

--- PASS: OtherTests (0.01s)
PASS
ok      github.com/go-curses/cdk     0.037s

Alternatively, GoConvey can be used for that delux developer experience.

# Install GoConvey first
$ go get github.com/smartystreets/goconvey
 ...
# startup the service, this will open the default browser
$ goconvey

Versioning

The current API is unstable and subject to change dramatically.

License

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

Acknowledgments

  • Thanks to TCell for providing a great starting point for CDK and thus making CTK a plausible reality.

Documentation

Index

Constants

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 (
	TypeMetaData      CTypeTag = "cdk-metadata"
	SignalSetProperty Signal   = "set-property"
)
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 (
	TypeWindow         CTypeTag = "cdk-window"
	PropertyWindowType Property = "window-type"
	SignalDraw         Signal   = "draw"
	SignalSetTitle     Signal   = "set-title"
	SignalSetDisplay   Signal   = "set-display"
)
View Source
const ApplicationDisplayShutdownHandle = "application-display-shutdown-handler"
View Source
const ApplicationDisplayStartupHandle = "application-display-startup-handler"
View Source
const ApplicationServerDisplayStartupHandle = "application-server-display-startup-handler"
View Source
const (
	DisplayStartupCompleteHandle = "display-screen-startup-complete-handler"
)
View Source
const ObjectSetPropertyHandle = "object-set-property-handle"
View Source
const OffscreenTtyPath = "<offscreen>"

Variables

View Source
var (
	AppCliProfileFlag = &cli.StringFlag{
		Category:    "Go-Curses",
		Name:        "cdk-profile",
		EnvVars:     []string{"GO_CDK_PROFILE"},
		Usage:       "profile one of: none, block, cpu, goroutine, mem, mutex, thread or trace",
		DefaultText: "none",
	}
	AppCliProfilePathFlag = &cli.StringFlag{
		Category:    "Go-Curses",
		Name:        "cdk-profile-path",
		EnvVars:     []string{"GO_CDK_PROFILE_PATH"},
		Usage:       "specify the directory path to store the profile data",
		DefaultText: DefaultGoProfilePath,
	}
	AppCliLogFileFlag = &cli.StringFlag{
		Category:    "Go-Curses",
		Name:        "cdk-log-file",
		EnvVars:     []string{"GO_CDK_LOG_FILE"},
		Usage:       "path to log file",
		DefaultText: log.DefaultLogPath,
	}
	AppCliLogLevelFlag = &cli.StringFlag{
		Category:    "Go-Curses",
		Name:        "cdk-log-level",
		EnvVars:     []string{"GO_CDK_LOG_LEVEL"},
		Value:       "error",
		Usage:       "highest level of verbosity",
		DefaultText: "error",
	}
	AppCliLogFormatFlag = &cli.StringFlag{
		Category:    "Go-Curses",
		Name:        "cdk-log-format",
		EnvVars:     []string{"GO_CDK_LOG_FORMAT"},
		Value:       "pretty",
		Usage:       "json, text or pretty",
		DefaultText: "pretty",
	}
	AppCliLogTimestampsFlag = &cli.BoolFlag{
		Category:    "Go-Curses",
		Name:        "cdk-log-timestamps",
		EnvVars:     []string{"GO_CDK_LOG_TIMESTAMPS"},
		Usage:       "enable timestamps",
		DefaultText: "false",
	}
	AppCliLogTimestampFormatFlag = &cli.StringFlag{
		Category:    "Go-Curses",
		Name:        "cdk-log-timestamp-format",
		EnvVars:     []string{"GO_CDK_LOG_TIMESTAMP_FORMAT"},
		Value:       log.DefaultTimestampFormat,
		Usage:       "timestamp format",
		DefaultText: log.DefaultTimestampFormat,
	}
	AppCliLogFullPathsFlag = &cli.BoolFlag{
		Category:    "Go-Curses",
		Name:        "cdk-log-full-paths",
		EnvVars:     []string{"GO_CDK_LOG_FULL_PATHS"},
		Usage:       "log the full paths of source files",
		DefaultText: "false",
	}
	AppCliLogOutputFlag = &cli.StringFlag{
		Category:    "Go-Curses",
		Name:        "cdk-log-output",
		EnvVars:     []string{"GO_CDK_LOG_OUTPUT"},
		Value:       "file",
		Usage:       "logging output type: stdout, stderr or file",
		DefaultText: "file",
	}
	AppCliLogLevelsFlag = &cli.BoolFlag{
		Category: "Go-Curses",
		Name:     "cdk-log-levels",
		Usage:    "list the levels of logging verbosity",
	}
	AppCliTtyFlag = &cli.StringFlag{
		Category: "Go-Curses",
		Name:     "cdk-tty",
		Usage:    "specify the display tty",
		EnvVars:  []string{"GO_CDK_TTY"},
	}
)
View Source
var (
	IncludeTtyFlag            = "false"
	IncludeProfiling          = "false"
	IncludeLogFile            = "false"
	IncludeLogFormat          = "false"
	IncludeLogFullPaths       = "false"
	IncludeLogLevel           = "false"
	IncludeLogLevels          = "false"
	IncludeLogTimestamps      = "false"
	IncludeLogTimestampFormat = "false"
	IncludeLogOutput          = "false"
)

Setting these globals will enable command line flags and their corresponding features. To set these, use the go build -ldflags:

go build -v -ldflags="-X 'github.com/go-curses/cdk.IncludeTtyFlag=true'"
View Source
var (
	// DisplayCallCapacity limits the number of concurrent calls on main threads
	DisplayCallCapacity    = 128
	DisplayEventCapacity   = 1024
	DisplayMainsCapacity   = 128
	DisplayInboundCapacity = 1024
	// MainIterateDelay is the event iteration loop delay
	MainIterateDelay = time.Millisecond * 25
	// MainDrawInterval is the interval between renders (milliseconds)
	MainDrawInterval    int64 = 50
	MainLoopInterval    int64 = 10
	DisplayLoopCapacity       = 1024
)
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 (
	EventQueueSize    = 1024
	EventKeyQueueSize = 1024
	EventKeyTiming    = time.Millisecond * 50
	SignalQueueSize   = 100
)
View Source
var Build = Config{
	Profiling:          false,
	LogFile:            false,
	LogFormat:          false,
	LogFullPaths:       false,
	LogLevel:           false,
	LogLevels:          false,
	LogTimestamps:      false,
	LogTimestampFormat: false,
	LogOutput:          false,
	DisableLocalCall:   true,
	DisableRemoteCall:  true,
}
View Source
var (
	DefaultGoProfilePath = os.TempDir() + string(os.PathSeparator) + "cdk.pprof"
)
View Source
var (
	DefaultServerAuthHtpasswdPath = "./htpasswd"
)
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",
	}
)
View Source
var (
	TypesManager = NewTypeRegistry()
)

Functions

func AddTimeout

func AddTimeout(delay time.Duration, fn TimerCallbackFn) (id uuid.UUID)

func ArgvApplicationSignalStartup added in v0.4.2

func ArgvApplicationSignalStartup(argv ...interface{}) (app Application, display Display, ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup, ok bool)

func CancelAllTimeouts

func CancelAllTimeouts()

func DecodeCtrlKey added in v0.3.3

func DecodeCtrlKey(in Key) (key Key, mods ModMask, ok bool)

func DescribeButton

func DescribeButton(button ButtonMask) string

func DisplaySignalDisplayStartupArgv added in v0.4.0

func DisplaySignalDisplayStartupArgv(argv ...interface{}) (ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup, ok bool)

func GetApplicationCliFlags added in v0.3.2

func GetApplicationCliFlags() (flags []cli.Flag)

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 Go added in v0.3.2

func Go(fn func())

func GoWithMainContext added in v0.3.2

func GoWithMainContext(user, host string, display *CDisplay, data interface{}, fn func())

func Init

func Init()

func ListEncodings

func ListEncodings() []string

func LookupKeyName

func LookupKeyName(key Key) string

func ParseKeyMods added in v0.3.3

func ParseKeyMods(input string) (key Key, mods ModMask, err error)

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 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 StopTimeout

func StopTimeout(id uuid.UUID)

func TestingMakesActiveWindow

func TestingMakesActiveWindow(d Display) error

func TestingMakesNoContent

func TestingMakesNoContent(_ []interface{}, _ ...interface{}) enums.EventFlag

func UnregisterEncoding

func UnregisterEncoding(charset string)

func WithApp

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

func WithDisplayManager

func WithDisplayManager(action DisplayManagerFn) func()

Types

type AppFn

type AppFn func(app Application)

type Application added in v0.3.2

type Application interface {
	Object

	Init() (already bool)
	SetupDisplay()
	Destroy()
	CLI() *cli.App
	GetContext() *cli.Context
	Tag() string
	Title() string
	Name() string
	Usage() string
	Description() string
	Version() string
	Reconfigure(name, usage, description, version, tag, title, ttyPath string)
	AddFlag(flag cli.Flag)
	RemoveFlag(flag cli.Flag) (removed bool)
	AddFlags(flags []cli.Flag)
	AddCommand(command *cli.Command)
	AddCommands(commands []*cli.Command)
	Display() *CDisplay
	SetDisplay(d *CDisplay) (err error)
	NotifyStartupComplete()
	StartupCompleted() bool
	Run(args []string) (err error)
	MainInit(argv ...interface{}) (ok bool)
	MainRun(runner ApplicationMain)
	MainEventsPending() (pending bool)
	MainIterateEvents()
	MainFinish()
	CliActionFn(ctx *cli.Context) (err error)
}

func ArgvApplicationSignalPrepareStartup added in v0.5.20

func ArgvApplicationSignalPrepareStartup(argv ...interface{}) (app Application, args []string, ok bool)

func LoadApplicationFromPlugin added in v0.3.6

func LoadApplicationFromPlugin(path string) (app Application, err error)

LoadApplicationFromPlugin is a wrapper around LoadApplicationFromPluginWithExport, using a default exported symbol name of `CdkApp`.

func LoadApplicationFromPluginWithExport added in v0.3.6

func LoadApplicationFromPluginWithExport(exported, path string) (app Application, err error)

LoadApplicationFromPluginWithExport opens the shared object file indicated by the path argument, looks for the exported symbol (which needs to be to a valid cdk.Application instance), recasts and returns the result.

type ApplicationInitFn added in v0.4.2

type ApplicationInitFn = func(app Application)

type ApplicationMain added in v0.4.0

type ApplicationMain func(ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup)

type ApplicationPrepareStartupFn added in v0.5.20

type ApplicationPrepareStartupFn = func(app Application, args []string) enums.EventFlag

type ApplicationRunFn added in v0.4.0

type ApplicationRunFn = func(ctx *cli.Context) error

type ApplicationServer added in v0.3.2

type ApplicationServer interface {
	Object

	Init() (already bool)
	GetClients() (clients []uuid.UUID)
	GetClient(id uuid.UUID) (*CApplicationServerClient, error)
	App() (app *CApplication)
	Display() (display *CDisplay)
	SetListenAddress(address string)
	GetListenAddress() (address string)
	SetListenPort(port int)
	GetListenPort() (port int)
	Stop() (err error)
	Daemon() (err error)
	Start() (err error)
	ClearAuthHandlers()
	InstallAuthHandler(handler ServerAuthHandler) (err error)
	UnInstallAuthHandler(handler ServerAuthHandler) (err error)
}

type ApplicationShutdownFn added in v0.4.2

type ApplicationShutdownFn = func() enums.EventFlag

type ApplicationStartupFn added in v0.4.2

type ApplicationStartupFn = func(
	app Application,
	display Display,
	ctx context.Context,
	cancel context.CancelFunc,
	wg *sync.WaitGroup,
) enums.EventFlag

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 CApplication added in v0.3.2

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

func NewApplication added in v0.3.6

func NewApplication(name, usage, description, version, tag, title, ttyPath string) *CApplication

func (*CApplication) AddCommand added in v0.3.2

func (app *CApplication) AddCommand(command *cli.Command)

func (*CApplication) AddCommands added in v0.3.2

func (app *CApplication) AddCommands(commands []*cli.Command)

func (*CApplication) AddFlag added in v0.3.2

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

func (*CApplication) AddFlags added in v0.3.2

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

func (*CApplication) CLI added in v0.3.2

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

func (*CApplication) CliActionFn added in v0.3.2

func (app *CApplication) CliActionFn(ctx *cli.Context) (err error)

func (*CApplication) Description added in v0.3.2

func (app *CApplication) Description() string

func (*CApplication) Destroy added in v0.3.2

func (app *CApplication) Destroy()

func (*CApplication) Display added in v0.3.2

func (app *CApplication) Display() *CDisplay

func (*CApplication) GetContext added in v0.3.2

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

func (*CApplication) Init added in v0.3.6

func (app *CApplication) Init() (already bool)

func (*CApplication) MainEventsPending added in v0.3.2

func (app *CApplication) MainEventsPending() (pending bool)

func (*CApplication) MainFinish added in v0.3.2

func (app *CApplication) MainFinish()

func (*CApplication) MainInit added in v0.3.2

func (app *CApplication) MainInit(argv ...interface{}) (ok bool)

MainInit is used to initialize the Application based on the CLI arguments given at runtime.

`argv` can be one of the following cases:

nil/empty     use only the environment variables, if any are set
*cli.Context  do not parse anything, just use existing context
...string     parse the given strings as if it were os.Args

func (*CApplication) MainIterateEvents added in v0.3.2

func (app *CApplication) MainIterateEvents()

func (*CApplication) MainRun added in v0.3.2

func (app *CApplication) MainRun(runner ApplicationMain)

func (*CApplication) Name added in v0.3.2

func (app *CApplication) Name() string

func (*CApplication) NotifyStartupComplete added in v0.4.0

func (app *CApplication) NotifyStartupComplete()

func (*CApplication) Reconfigure added in v0.4.0

func (app *CApplication) Reconfigure(name, usage, description, version, tag, title, ttyPath string)

func (*CApplication) RemoveFlag added in v0.3.2

func (app *CApplication) RemoveFlag(flag cli.Flag) (removed bool)

func (*CApplication) Run added in v0.3.2

func (app *CApplication) Run(args []string) (err error)

func (*CApplication) SetDisplay added in v0.4.1

func (app *CApplication) SetDisplay(d *CDisplay) (err error)

func (*CApplication) SetupDisplay added in v0.3.2

func (app *CApplication) SetupDisplay()

func (*CApplication) StartupCompleted added in v0.5.9

func (app *CApplication) StartupCompleted() bool

func (*CApplication) Tag added in v0.3.2

func (app *CApplication) Tag() string

func (*CApplication) Title added in v0.3.2

func (app *CApplication) Title() string

func (*CApplication) Usage added in v0.3.2

func (app *CApplication) Usage() string

func (*CApplication) Version added in v0.3.2

func (app *CApplication) Version() string

type CApplicationServer added in v0.3.2

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

func NewApplicationServer added in v0.3.2

func NewApplicationServer(name, usage, description, version, tag, title string, clientInitFn SignalListenerFn, serverInitFn SignalListenerFn, privateKeyPath string) *CApplicationServer

func (*CApplicationServer) App added in v0.3.2

func (s *CApplicationServer) App() (app *CApplication)

func (*CApplicationServer) ClearAuthHandlers added in v0.3.2

func (s *CApplicationServer) ClearAuthHandlers()

func (*CApplicationServer) Daemon added in v0.3.2

func (s *CApplicationServer) Daemon() (err error)

func (*CApplicationServer) Display added in v0.3.2

func (s *CApplicationServer) Display() (display *CDisplay)

func (*CApplicationServer) GetClient added in v0.3.2

func (*CApplicationServer) GetClients added in v0.3.2

func (s *CApplicationServer) GetClients() (clients []uuid.UUID)

func (*CApplicationServer) GetListenAddress added in v0.3.2

func (s *CApplicationServer) GetListenAddress() (address string)

func (*CApplicationServer) GetListenPort added in v0.3.2

func (s *CApplicationServer) GetListenPort() (port int)

func (*CApplicationServer) Init added in v0.3.2

func (s *CApplicationServer) Init() (already bool)

func (*CApplicationServer) InstallAuthHandler added in v0.3.2

func (s *CApplicationServer) InstallAuthHandler(handler ServerAuthHandler) (err error)

func (*CApplicationServer) SetListenAddress added in v0.3.2

func (s *CApplicationServer) SetListenAddress(address string)

func (*CApplicationServer) SetListenPort added in v0.3.2

func (s *CApplicationServer) SetListenPort(port int)

func (*CApplicationServer) Start added in v0.3.2

func (s *CApplicationServer) Start() (err error)

func (*CApplicationServer) Stop added in v0.3.2

func (s *CApplicationServer) Stop() (err error)

func (*CApplicationServer) UnInstallAuthHandler added in v0.3.2

func (s *CApplicationServer) UnInstallAuthHandler(handler ServerAuthHandler) (err error)

type CApplicationServerClient added in v0.3.2

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

func (*CApplicationServerClient) String added in v0.3.2

func (asc *CApplicationServerClient) String() string

type CClipboard added in v0.5.10

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

func (*CClipboard) Copy added in v0.5.10

func (c *CClipboard) Copy(text string)

Copy updates the clipboard's cache of pasted content and passes the copy event to the underlying operating system (if supported) using OSC52 terminal sequences

func (*CClipboard) GetText added in v0.5.10

func (c *CClipboard) GetText() (text string)

GetText retrieves the clipboard's cache of pasted content

func (*CClipboard) Init added in v0.5.10

func (c *CClipboard) Init() (already bool)

func (*CClipboard) Paste added in v0.5.10

func (c *CClipboard) Paste(text string)

Paste updates the clipboard's cache of pasted content and emits a "Paste" event itself

func (*CClipboard) SetText added in v0.5.10

func (c *CClipboard) SetText(text string)

SetText updates the clipboard's cache of pasted content

type CDisplay

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

Basic display type

func GetDefaultDisplay

func GetDefaultDisplay() (display *CDisplay)

GetDefaultDisplay returns the default display for the current app context

func NewDisplay

func NewDisplay(title string, ttyPath string) (d *CDisplay)

func NewDisplayWithHandle

func NewDisplayWithHandle(title string, ttyHandle *os.File) (d *CDisplay)

func (*CDisplay) App

func (d *CDisplay) App() *CApplication

func (*CDisplay) AsyncCall

func (d *CDisplay) AsyncCall(fn DisplayCallbackFn) error

AsyncCall runs the given DisplayCallbackFn on the UI thread, non-blocking

func (*CDisplay) AsyncCallMain added in v0.4.0

func (d *CDisplay) AsyncCallMain(fn DisplayCallbackFn) error

AsyncCallMain will run the given DisplayCallbackFn on the main runner thread, non-blocking

func (*CDisplay) AwaitCall

func (d *CDisplay) AwaitCall(fn DisplayCallbackFn) error

AwaitCall runs the given DisplayCallbackFn on the UI thread, blocking

func (*CDisplay) AwaitCallMain added in v0.4.0

func (d *CDisplay) AwaitCallMain(fn DisplayCallbackFn) error

AwaitCallMain will run the given DisplayCallbackFn on the main runner thread, blocking

func (*CDisplay) Call added in v0.5.0

func (d *CDisplay) Call(fn cexec.Callback) (err error)

func (*CDisplay) CallEnabled added in v0.5.4

func (d *CDisplay) CallEnabled() (enabled bool, err error)

func (*CDisplay) CaptureCtrlC

func (d *CDisplay) CaptureCtrlC()

func (*CDisplay) CaptureDisplay

func (d *CDisplay) CaptureDisplay() (err error)

func (*CDisplay) CapturedCtrlC added in v0.5.10

func (d *CDisplay) CapturedCtrlC() bool

func (*CDisplay) Colors

func (d *CDisplay) Colors() (numberOfColors int)

func (*CDisplay) Command added in v0.5.1

func (d *CDisplay) Command(name string, argv ...string) (err error)

func (*CDisplay) CursorPosition added in v0.4.5

func (d *CDisplay) CursorPosition() (position ptypes.Point2I, moving bool)

func (*CDisplay) Destroy

func (d *CDisplay) Destroy()

func (*CDisplay) DisplayCaptured

func (d *CDisplay) DisplayCaptured() bool

func (*CDisplay) FocusNextWindow added in v0.4.4

func (d *CDisplay) FocusNextWindow()

func (*CDisplay) FocusPreviousWindow added in v0.4.4

func (d *CDisplay) FocusPreviousWindow()

func (*CDisplay) FocusWindow added in v0.4.4

func (d *CDisplay) FocusWindow(w Window)

func (*CDisplay) FocusedWindow added in v0.4.4

func (d *CDisplay) FocusedWindow() Window

func (*CDisplay) GetClipboard added in v0.5.10

func (d *CDisplay) GetClipboard() (clipboard Clipboard)

func (*CDisplay) GetCompressEvents added in v0.3.0

func (d *CDisplay) GetCompressEvents() bool

func (*CDisplay) GetEventFocus

func (d *CDisplay) GetEventFocus() (widget Object)

func (*CDisplay) GetPriorEvent

func (d *CDisplay) GetPriorEvent() (event Event)

func (*CDisplay) GetTitle

func (d *CDisplay) GetTitle() string

func (*CDisplay) GetTtyHandle

func (d *CDisplay) GetTtyHandle() *os.File

func (*CDisplay) GetTtyPath

func (d *CDisplay) GetTtyPath() string

func (*CDisplay) GetWindowAtPoint added in v0.4.4

func (d *CDisplay) GetWindowAtPoint(point ptypes.Point2I) (window Window)

func (*CDisplay) GetWindows

func (d *CDisplay) GetWindows() (windows []Window)

func (*CDisplay) HasBufferedEvents added in v0.3.0

func (d *CDisplay) HasBufferedEvents() (hasEvents bool)

HasBufferedEvents returns TRUE if there are any pending events buffered.

func (*CDisplay) HasPendingEvents added in v0.3.0

func (d *CDisplay) HasPendingEvents() (pending bool)

HasPendingEvents returns TRUE if there are any pending events, or if the Main thread is still running (and waiting for events).

func (*CDisplay) Init

func (d *CDisplay) Init() (already bool)

func (*CDisplay) IsMappedWindow added in v0.4.4

func (d *CDisplay) IsMappedWindow(w Window) (mapped bool)

func (*CDisplay) IsMonochrome

func (d *CDisplay) IsMonochrome() bool

func (*CDisplay) IsRunning

func (d *CDisplay) IsRunning() bool

IsRunning returns TRUE if the main thread is currently running.

func (*CDisplay) IterateBufferedEvents added in v0.3.0

func (d *CDisplay) IterateBufferedEvents() (refreshed bool)

IterateBufferedEvents compresses the pending event buffer by reducing multiple events of the same type to just the last ones received. Each remaining pending event is then processed. If any of the events return EVENT_STOP from their signal listeners, draw and show requests are made to refresh the display contents.

func (*CDisplay) Main added in v0.4.0

func (d *CDisplay) Main(ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup) (err error)

Main is the primary Display thread. It starts the event receiver, event processor and screen worker threads and proceeds to handle AsyncCallMain, AwaitCallMain, screen event transmitter and shutdown mechanics. When RequestQuit is called, the main loop exits, cancels all threads, destroys the display object, recovers from any go panics and finally emits a SignalDisplayShutdown.

func (*CDisplay) MainFinish added in v0.3.0

func (d *CDisplay) MainFinish()

MainFinish cleans up any pending internal processes remaining after Main() has completed processing.

func (*CDisplay) MapWindow added in v0.4.3

func (d *CDisplay) MapWindow(w Window)

func (*CDisplay) MapWindowWithRegion added in v0.4.4

func (d *CDisplay) MapWindowWithRegion(w Window, region ptypes.Region)

func (*CDisplay) PostEvent

func (d *CDisplay) PostEvent(evt Event) error

PostEvent sends the given Event to the Display Screen for processing. This is mainly useful for synthesizing Screen events, though not a recommended practice.

func (*CDisplay) ProcessEvent

func (d *CDisplay) ProcessEvent(evt Event) enums.EventFlag

ProcessEvent handles events sent from the Screen instance and manages passing those events to the active window

func (*CDisplay) ReleaseCtrlC

func (d *CDisplay) ReleaseCtrlC()

func (*CDisplay) ReleaseDisplay

func (d *CDisplay) ReleaseDisplay()

func (*CDisplay) RequestDraw

func (d *CDisplay) RequestDraw()

RequestDraw asks the Display to process a SignalDraw event cycle, this does not actually render the contents to in Screen, just update

func (*CDisplay) RequestQuit

func (d *CDisplay) RequestQuit()

RequestQuit asks the Display to quit nicely

func (*CDisplay) RequestShow

func (d *CDisplay) RequestShow()

RequestShow asks the Display to render pending Screen changes

func (*CDisplay) RequestSync

func (d *CDisplay) RequestSync()

RequestSync asks the Display to render everything in the Screen

func (*CDisplay) Run

func (d *CDisplay) Run() (err error)

Run is the standard means of invoking a Display instance. It calls Startup, handles the main event look and finally calls MainFinish when all is complete.

func (*CDisplay) Screen

func (d *CDisplay) Screen() Screen

func (*CDisplay) SetCompressEvents added in v0.3.0

func (d *CDisplay) SetCompressEvents(compress bool)

func (*CDisplay) SetEventFocus

func (d *CDisplay) SetEventFocus(widget Object) error

func (*CDisplay) SetTheme added in v0.5.10

func (d *CDisplay) SetTheme(theme paint.Theme)

func (*CDisplay) SetTitle

func (d *CDisplay) SetTitle(title string)

func (*CDisplay) SetTtyHandle

func (d *CDisplay) SetTtyHandle(ttyHandle *os.File)

func (*CDisplay) SetTtyPath

func (d *CDisplay) SetTtyPath(ttyPath string)

func (*CDisplay) Startup added in v0.4.0

func (d *CDisplay) Startup() (ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup, err error)

Startup captures the Display, sets the internal running state and allocates the necessary runtime context.WithCancel and sync.WaitGroup for the main runner thread of the Display. Once setup, starts the Main runner with the necessary rigging for thread synchronization and shutdown mechanics.

func (*CDisplay) StartupComplete added in v0.4.0

func (d *CDisplay) StartupComplete()

StartupComplete emits SignalStartupComplete

func (*CDisplay) UnmapWindow added in v0.4.3

func (d *CDisplay) UnmapWindow(w Window)

type CLocalContextData added in v0.5.3

type CLocalContextData struct {
	User    string
	Host    string
	Display *CDisplay
	Data    interface{}
}

func GetLocalContext

func GetLocalContext() (acd *CLocalContextData, err error)

type CMetaData

type CMetaData struct {
	CSignaling
	// contains filtered or unexported fields
}

func (*CMetaData) GetBoolProperty

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

func (*CMetaData) GetColorProperty

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

func (*CMetaData) GetFloat64Property

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

func (*CMetaData) GetFloatProperty

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

func (*CMetaData) GetIntProperty

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

func (*CMetaData) GetPointProperty

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

func (*CMetaData) GetProperty

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

func (*CMetaData) GetRectangleProperty

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

func (*CMetaData) GetRegionProperty

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

func (*CMetaData) GetStringProperty

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

func (*CMetaData) GetStructProperty

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

func (*CMetaData) GetStyleProperty

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

func (*CMetaData) GetThemeProperty

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

func (*CMetaData) GetTimeProperty added in v0.4.5

func (o *CMetaData) GetTimeProperty(name Property) (value time.Duration, err error)

func (*CMetaData) Init

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

func (*CMetaData) InstallBuildableProperty

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

func (*CMetaData) InstallProperty

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

func (*CMetaData) IsBuildableProperty

func (o *CMetaData) IsBuildableProperty(name Property) (buildable bool)

func (*CMetaData) IsProperty

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

func (*CMetaData) ListBuildableProperties

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

func (*CMetaData) ListProperties

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

func (*CMetaData) OverloadProperty

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

func (*CMetaData) SetBoolProperty

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

func (*CMetaData) SetColorProperty

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

func (*CMetaData) SetFloatProperty

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

func (*CMetaData) SetIntProperty

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

func (*CMetaData) SetPointProperty

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

func (*CMetaData) SetProperties

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

func (*CMetaData) SetProperty

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

func (*CMetaData) SetPropertyFromString

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

func (*CMetaData) SetRectangleProperty

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

func (*CMetaData) SetRegionProperty

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

func (*CMetaData) SetStringProperty

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

func (*CMetaData) SetStructProperty

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

func (*CMetaData) SetStyleProperty

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

func (*CMetaData) SetThemeProperty

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

func (*CMetaData) SetTimeProperty added in v0.4.5

func (o *CMetaData) SetTimeProperty(name Property, value time.Duration) error

type CObject

type CObject struct {
	CMetaData
}

func (*CObject) Destroy

func (o *CObject) Destroy()

func (*CObject) GetName

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

func (*CObject) GetTheme

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

func (*CObject) Init

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

func (*CObject) InitWithProperties

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

func (*CObject) SetName

func (o *CObject) SetName(name string)

func (*CObject) SetTheme

func (o *CObject) SetTheme(theme paint.Theme)

type COffScreen

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

func (*COffScreen) Beep

func (o *COffScreen) Beep() error

func (*COffScreen) CanDisplay

func (o *COffScreen) CanDisplay(r rune, checkFallbacks bool) bool

func (*COffScreen) CharacterSet

func (o *COffScreen) CharacterSet() string

func (*COffScreen) Clear

func (o *COffScreen) Clear()

func (*COffScreen) Close

func (o *COffScreen) Close()

func (*COffScreen) Colors

func (o *COffScreen) Colors() int

func (*COffScreen) CopyToClipboard added in v0.5.10

func (o *COffScreen) CopyToClipboard(s string)

func (*COffScreen) DisableMouse

func (o *COffScreen) DisableMouse()

func (*COffScreen) DisablePaste

func (o *COffScreen) DisablePaste()

func (*COffScreen) EnableHostClipboard added in v0.5.10

func (o *COffScreen) EnableHostClipboard(enabled bool)

func (*COffScreen) EnableMouse

func (o *COffScreen) EnableMouse(_ ...MouseFlags)

func (*COffScreen) EnablePaste

func (o *COffScreen) EnablePaste()

func (*COffScreen) EnableTermClipboard added in v0.5.10

func (o *COffScreen) EnableTermClipboard(enabled bool)

func (*COffScreen) Export

func (o *COffScreen) Export() *CellBuffer

func (*COffScreen) Fill

func (o *COffScreen) Fill(r rune, style paint.Style)

func (*COffScreen) GetContent

func (o *COffScreen) GetContent(x, y int) (mc rune, comb []rune, style paint.Style, width int)

func (*COffScreen) GetContents

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

func (*COffScreen) GetCursor

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

func (*COffScreen) GetTermType added in v0.5.19

func (o *COffScreen) GetTermType() (ttyType term.TermType)

func (*COffScreen) GetTtyCloseWithStiRead added in v0.5.4

func (o *COffScreen) GetTtyCloseWithStiRead() (enabled bool)

func (*COffScreen) HasKey

func (o *COffScreen) HasKey(Key) bool

func (*COffScreen) HasMouse

func (o *COffScreen) HasMouse() bool

func (*COffScreen) HideCursor

func (o *COffScreen) HideCursor()

func (*COffScreen) HostClipboardEnabled added in v0.5.10

func (o *COffScreen) HostClipboardEnabled() (enabled bool)

func (*COffScreen) Import

func (o *COffScreen) Import(cb *CellBuffer)

func (*COffScreen) Init

func (o *COffScreen) Init() error

func (*COffScreen) InitWithFileHandle

func (o *COffScreen) InitWithFileHandle(ttyHandle *os.File) (err error)

func (*COffScreen) InitWithFilePath

func (o *COffScreen) InitWithFilePath(ttyFile string) (err error)

func (*COffScreen) InjectKey

func (o *COffScreen) InjectKey(key Key, r rune, mod ModMask)

func (*COffScreen) InjectKeyBytes

func (o *COffScreen) InjectKeyBytes(b []byte) bool

func (*COffScreen) InjectMouse

func (o *COffScreen) InjectMouse(x, y int, buttons ButtonMask, mod ModMask)

func (*COffScreen) PasteFromClipboard added in v0.5.10

func (o *COffScreen) PasteFromClipboard() (s string, ok bool)

func (*COffScreen) PollEvent

func (o *COffScreen) PollEvent() Event

func (*COffScreen) PollEventChan

func (o *COffScreen) PollEventChan() (next chan Event)

func (*COffScreen) PostEvent

func (o *COffScreen) PostEvent(ev Event) error

func (*COffScreen) PostEventWait

func (o *COffScreen) PostEventWait(ev Event)

func (*COffScreen) RegisterConsoleFallback added in v0.5.19

func (o *COffScreen) RegisterConsoleFallback(r rune, subst rune)

func (*COffScreen) RegisterRuneFallback

func (o *COffScreen) RegisterRuneFallback(r rune, subst string)

func (*COffScreen) Resize

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

func (*COffScreen) SetCell

func (o *COffScreen) SetCell(x, y int, style paint.Style, ch ...rune)

func (*COffScreen) SetContent

func (o *COffScreen) SetContent(x, y int, mc rune, comb []rune, st paint.Style)

func (*COffScreen) SetSize

func (o *COffScreen) SetSize(w, h int)

func (*COffScreen) SetStyle

func (o *COffScreen) SetStyle(style paint.Style)

func (*COffScreen) Show

func (o *COffScreen) Show()

func (*COffScreen) ShowCursor

func (o *COffScreen) ShowCursor(x, y int)

func (*COffScreen) Size

func (o *COffScreen) Size() (w, h int)

func (*COffScreen) Sync

func (o *COffScreen) Sync()

func (*COffScreen) TtyCloseWithStiRead added in v0.5.4

func (o *COffScreen) TtyCloseWithStiRead(enabled bool)

func (*COffScreen) TtyKeepFileHandle added in v0.5.1

func (o *COffScreen) TtyKeepFileHandle(keep bool)

func (*COffScreen) TtyKeepingFileHandle added in v0.5.1

func (o *COffScreen) TtyKeepingFileHandle() (keeping bool)

func (*COffScreen) UnregisterConsoleFallback added in v0.5.19

func (o *COffScreen) UnregisterConsoleFallback(orig rune)

func (*COffScreen) UnregisterRuneFallback

func (o *COffScreen) UnregisterRuneFallback(r rune)

type COffscreenWindow

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

Basic window type

func (*COffscreenWindow) Draw

func (w *COffscreenWindow) Draw() enums.EventFlag

func (*COffscreenWindow) GetDisplay

func (w *COffscreenWindow) GetDisplay() Display

func (*COffscreenWindow) GetTitle

func (w *COffscreenWindow) GetTitle() string

func (*COffscreenWindow) GetWindowType added in v0.4.5

func (w *COffscreenWindow) GetWindowType() (value enums.WindowType)

GetWindowType returns the type of the window. See: enums.WindowType.

func (*COffscreenWindow) Init

func (w *COffscreenWindow) Init() bool

func (*COffscreenWindow) ProcessEvent

func (w *COffscreenWindow) ProcessEvent(evt Event) enums.EventFlag

func (*COffscreenWindow) SetDisplay

func (w *COffscreenWindow) SetDisplay(d Display)

func (*COffscreenWindow) SetTitle

func (w *COffscreenWindow) SetTitle(title string)

func (*COffscreenWindow) SetWindowType added in v0.4.5

func (w *COffscreenWindow) SetWindowType(hint enums.WindowType)

SetWindowType updates the type of the window. See: enums.WindowType

type CProperty

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

func NewProperty

func NewProperty(name Property, kind PropertyType, write bool, buildable bool, def interface{}) (property *CProperty)

func (*CProperty) Buildable

func (p *CProperty) Buildable() bool

func (*CProperty) Clone

func (p *CProperty) Clone() *CProperty

func (*CProperty) Default

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

func (*CProperty) Name

func (p *CProperty) Name() Property

func (*CProperty) ReadOnly

func (p *CProperty) ReadOnly() bool

func (*CProperty) Set

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

func (*CProperty) SetFromString

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

func (*CProperty) Type

func (p *CProperty) Type() PropertyType

func (*CProperty) Value

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

type CScreen

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

CScreen represents a screen backed by a terminfo implementation.

func (*CScreen) Beep

func (d *CScreen) Beep() error

Beep emits a beep to the terminal.

func (*CScreen) CanDisplay

func (d *CScreen) CanDisplay(r rune, checkFallbacks bool) bool

func (*CScreen) CharacterSet

func (d *CScreen) CharacterSet() string

func (*CScreen) Clear

func (d *CScreen) Clear()

func (*CScreen) Close

func (d *CScreen) Close()

func (*CScreen) Colors

func (d *CScreen) Colors() int

func (*CScreen) CopyToClipboard added in v0.5.10

func (d *CScreen) CopyToClipboard(s string)

func (*CScreen) DisableMouse

func (d *CScreen) DisableMouse()

func (*CScreen) DisablePaste

func (d *CScreen) DisablePaste()

func (*CScreen) EnableGPM

func (d *CScreen) EnableGPM()

func (*CScreen) EnableHostClipboard added in v0.5.10

func (d *CScreen) EnableHostClipboard(enabled bool)

func (*CScreen) EnableMouse

func (d *CScreen) EnableMouse(flags ...MouseFlags)

func (*CScreen) EnablePaste

func (d *CScreen) EnablePaste()

func (*CScreen) EnableTermClipboard added in v0.5.10

func (d *CScreen) EnableTermClipboard(enabled bool)

func (*CScreen) Export

func (d *CScreen) Export() *CellBuffer

func (*CScreen) Fill

func (d *CScreen) Fill(r rune, style paint.Style)

func (*CScreen) GetContent

func (d *CScreen) GetContent(x, y int) (rune, []rune, paint.Style, int)

func (*CScreen) GetTermType added in v0.5.19

func (d *CScreen) GetTermType() (ttyType cterm.TermType)

func (*CScreen) GetTtyCloseWithStiRead added in v0.5.4

func (d *CScreen) GetTtyCloseWithStiRead() (enabled bool)

func (*CScreen) HasKey

func (d *CScreen) HasKey(k Key) bool

func (*CScreen) HasMouse

func (d *CScreen) HasMouse() bool

func (*CScreen) HideCursor

func (d *CScreen) HideCursor()

func (*CScreen) HostClipboardEnabled added in v0.5.10

func (d *CScreen) HostClipboardEnabled() (enabled bool)

func (*CScreen) Import

func (d *CScreen) Import(cb *CellBuffer)

func (*CScreen) Init

func (d *CScreen) Init() error

func (*CScreen) InitWithFileHandle

func (d *CScreen) InitWithFileHandle(fh *os.File) error

func (*CScreen) InitWithFilePath

func (d *CScreen) InitWithFilePath(fp string) error

func (*CScreen) PasteFromClipboard added in v0.5.10

func (d *CScreen) PasteFromClipboard() (s string, ok bool)

func (*CScreen) PollEvent

func (d *CScreen) PollEvent() Event

func (*CScreen) PollEventChan

func (d *CScreen) PollEventChan() (next chan Event)

func (*CScreen) PostEvent

func (d *CScreen) PostEvent(ev Event) error

func (*CScreen) PostEventWait

func (d *CScreen) PostEventWait(ev Event)

func (*CScreen) RegisterConsoleFallback added in v0.5.19

func (d *CScreen) RegisterConsoleFallback(r rune, subst rune)

func (*CScreen) RegisterRuneFallback

func (d *CScreen) RegisterRuneFallback(orig rune, fallback string)

func (*CScreen) SetCell

func (d *CScreen) SetCell(x, y int, style paint.Style, ch ...rune)

func (*CScreen) SetContent

func (d *CScreen) SetContent(x, y int, mc rune, comb []rune, style paint.Style)

func (*CScreen) SetStyle

func (d *CScreen) SetStyle(style paint.Style)

func (*CScreen) Show

func (d *CScreen) Show()

func (*CScreen) ShowCursor

func (d *CScreen) ShowCursor(x, y int)

func (*CScreen) Size

func (d *CScreen) Size() (w, h int)

func (*CScreen) Sync

func (d *CScreen) Sync()

func (*CScreen) TPuts

func (d *CScreen) TPuts(s string)

func (*CScreen) TtyCloseWithStiRead added in v0.5.4

func (d *CScreen) TtyCloseWithStiRead(enabled bool)

func (*CScreen) TtyKeepFileHandle added in v0.5.1

func (d *CScreen) TtyKeepFileHandle(keep bool)

func (*CScreen) TtyKeepingFileHandle added in v0.5.1

func (d *CScreen) TtyKeepingFileHandle() (keeping bool)

func (*CScreen) UnregisterConsoleFallback added in v0.5.19

func (d *CScreen) UnregisterConsoleFallback(orig rune)

func (*CScreen) UnregisterRuneFallback

func (d *CScreen) UnregisterRuneFallback(orig rune)

type CServerAuthHandler added in v0.3.2

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

CServerAuthHandler is the base type for application server authentication handler implementations. This handler does no authentication and just accepts all connections.

func (*CServerAuthHandler) Attach added in v0.3.2

func (h *CServerAuthHandler) Attach(server ApplicationServer) (err error)

func (*CServerAuthHandler) Detach added in v0.3.2

func (h *CServerAuthHandler) Detach() (err error)

func (*CServerAuthHandler) HasArgument added in v0.3.2

func (h *CServerAuthHandler) HasArgument(arg string) (has bool)

func (*CServerAuthHandler) ID added in v0.3.2

func (h *CServerAuthHandler) ID() (id uuid.UUID)

func (*CServerAuthHandler) Init added in v0.3.2

func (h *CServerAuthHandler) Init() (already bool)

func (*CServerAuthHandler) PasswordCallback added in v0.3.2

func (h *CServerAuthHandler) PasswordCallback(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error)

func (*CServerAuthHandler) RegisterArgument added in v0.3.2

func (h *CServerAuthHandler) RegisterArgument(flag cli.Flag)

func (*CServerAuthHandler) Reload added in v0.3.2

func (h *CServerAuthHandler) Reload(ctx *cli.Context) (err error)

type CServerAuthHtpasswdHandler added in v0.3.2

type CServerAuthHtpasswdHandler struct {
	CServerAuthHandler
	// contains filtered or unexported fields
}

func NewServerAuthHtpasswdHandler added in v0.3.2

func NewServerAuthHtpasswdHandler(defaultHttpasswdFilePath string) (handler *CServerAuthHtpasswdHandler)

func (*CServerAuthHtpasswdHandler) Init added in v0.3.2

func (h *CServerAuthHtpasswdHandler) Init() (already bool)

func (*CServerAuthHtpasswdHandler) PasswordCallback added in v0.3.2

func (s *CServerAuthHtpasswdHandler) PasswordCallback(c ssh.ConnMetadata, pass []byte) (*ssh.Permissions, error)

func (*CServerAuthHtpasswdHandler) Reload added in v0.3.2

func (h *CServerAuthHtpasswdHandler) Reload(ctx *cli.Context) (err error)

type CSignalListener

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

func (*CSignalListener) Data added in v0.4.5

func (*CSignalListener) Func added in v0.4.5

func (*CSignalListener) Name added in v0.4.5

func (l *CSignalListener) Name() string

func (*CSignalListener) Signal added in v0.4.5

func (l *CSignalListener) Signal() Signal

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

Locking: write

func (*CSignaling) Disconnect

func (o *CSignaling) Disconnect(signal Signal, handle string) error

Disconnect callback from signal identified by handle

Locking: write

func (*CSignaling) DisconnectAll added in v0.4.5

func (o *CSignaling) DisconnectAll()

func (*CSignaling) Emit

func (o *CSignaling) Emit(signal Signal, argv ...interface{}) enums.EventFlag

Emit a signal event to all connected listener callbacks

Locking: none

func (*CSignaling) Freeze

func (o *CSignaling) Freeze()

Freeze pauses all signal emissions until a corresponding Thaw is called.

Locking: write

func (*CSignaling) Handled

func (o *CSignaling) Handled(signal Signal, handle string) (found bool)

Handled returns TRUE if there is at least one signal listener with the given handle.

Locking: read

func (*CSignaling) HasListeners added in v0.4.0

func (o *CSignaling) HasListeners(signal Signal) (has bool)

HasListeners returns true if there are one or more listeners connected to the given Signal.

func (*CSignaling) Init

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

func (*CSignaling) IsFrozen

func (o *CSignaling) IsFrozen() (frozen bool)

IsFrozen returns TRUE if Thaw has been called at least once.

Locking: read, signal read

func (*CSignaling) IsSignalPassed

func (o *CSignaling) IsSignalPassed(signals ...Signal) (passed bool)

IsSignalPassed returns TRUE if the given signal is currently passed.

Locking: none

func (*CSignaling) IsSignalStopped

func (o *CSignaling) IsSignalStopped(signals ...Signal) (stopped bool)

IsSignalStopped returns TRUE if the given signal is currently stopped.

Locking: none

func (*CSignaling) PassSignal

func (o *CSignaling) PassSignal(signals ...Signal)

PassSignal disables propagation of the given signal with an EVENT_PASS

Locking: write

func (*CSignaling) ResumeSignal

func (o *CSignaling) ResumeSignal(signals ...Signal)

ResumeSignal enables propagation of the given signal if the signal is currently stopped.

Locking: write

func (*CSignaling) StopSignal

func (o *CSignaling) StopSignal(signals ...Signal)

StopSignal disables propagation of the given signal with an EVENT_STOP

Locking: write

func (*CSignaling) Thaw

func (o *CSignaling) Thaw()

Thaw restores all signal emissions after a Freeze call.

Locking: write

type CType

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

func (*CType) Add

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

func (*CType) Aliases

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

func (*CType) Buildable

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

func (*CType) Items

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

func (*CType) New

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

func (*CType) Remove

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

type CTypeItem

type CTypeItem struct {
	sync.RWMutex
	// 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() uuid.UUID

func (*CTypeItem) ObjectName

func (o *CTypeItem) ObjectName() string

func (*CTypeItem) ObjectShortID added in v0.5.9

func (o *CTypeItem) ObjectShortID() (short string)

func (*CTypeItem) Self

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 {
	// contains filtered or unexported fields
}

func (*CTypeRegistry) AddType

func (r *CTypeRegistry) AddType(tag TypeTag, constructor func() interface{}, aliases ...string) error

func (*CTypeRegistry) AddTypeAlias

func (r *CTypeRegistry) AddTypeAlias(tag TypeTag, aliases ...string)

func (*CTypeRegistry) AddTypeItem

func (r *CTypeRegistry) AddTypeItem(tag TypeTag, item interface{}) (id uuid.UUID, err error)

func (*CTypeRegistry) GetBuildableInfo

func (r *CTypeRegistry) GetBuildableInfo() (info map[string]TypeTag)

func (*CTypeRegistry) GetType

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

func (*CTypeRegistry) GetTypeItemByID

func (r *CTypeRegistry) GetTypeItemByID(id uuid.UUID) interface{}

func (*CTypeRegistry) GetTypeItemByName

func (r *CTypeRegistry) GetTypeItemByName(name string) interface{}

func (*CTypeRegistry) GetTypeItems

func (r *CTypeRegistry) GetTypeItems(tag TypeTag) []interface{}

func (*CTypeRegistry) GetTypeTagByAlias

func (r *CTypeRegistry) GetTypeTagByAlias(alias string) (tt TypeTag, ok bool)

func (*CTypeRegistry) GetTypeTags

func (r *CTypeRegistry) GetTypeTags() (tags []TypeTag)

func (*CTypeRegistry) HasID

func (r *CTypeRegistry) HasID(index uuid.UUID) bool

func (*CTypeRegistry) HasType

func (r *CTypeRegistry) HasType(tag TypeTag) (exists bool)

func (*CTypeRegistry) MakeType

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 TypeApplication CTypeTag = "cdk-application"
const TypeApplicationServer CTypeTag = "cdk-application-server"
const TypeClipboard CTypeTag = "cdk-clipboard"
const (
	TypeDisplayManager CTypeTag = "cdk-display"
)
const (
	TypeNil CTypeTag = ""
)
const TypeObject CTypeTag = "cdk-object"
const (
	TypeOffscreenWindow CTypeTag = "cdk-offscreen-window"
)
const (
	TypeSignaling CTypeTag = "cdk-signaling"
)

func NewTypeTag

func NewTypeTag(tag string) CTypeTag

constructs a new Concrete TypeTag instance

func (CTypeTag) ClassName

func (tag CTypeTag) ClassName() string

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

func (CTypeTag) Equals

func (tag CTypeTag) Equals(tt TypeTag) bool

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

func (CTypeTag) GladeString

func (tag CTypeTag) GladeString() string

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

func (CTypeTag) Less

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

func (tag CTypeTag) Valid() bool

type CWindow

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

Basic window type

func (*CWindow) Destroy

func (w *CWindow) Destroy()

func (*CWindow) Draw

func (w *CWindow) Draw() enums.EventFlag

func (*CWindow) GetDisplay

func (w *CWindow) GetDisplay() Display

func (*CWindow) GetTitle

func (w *CWindow) GetTitle() string

func (*CWindow) GetWindowType added in v0.4.5

func (w *CWindow) GetWindowType() (value enums.WindowType)

GetWindowType returns the type of the window. See: enums.WindowType.

func (*CWindow) Init

func (w *CWindow) Init() bool

func (*CWindow) ProcessEvent

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

func (*CWindow) SetDisplay

func (w *CWindow) SetDisplay(d Display)

func (*CWindow) SetTitle

func (w *CWindow) SetTitle(title string)

func (*CWindow) SetWindowType added in v0.4.5

func (w *CWindow) SetWindowType(hint enums.WindowType)

SetWindowType updates the type of the window. See: enums.WindowType

type CellBuffer

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

CellBuffer represents a two dimensional array of character cells. This is primarily intended for use by Screen 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 paint.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) GetCell

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

GetCell 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) SetCell

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

SetCell 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 Clipboard added in v0.5.10

type Clipboard interface {
	Object

	GetText() (text string)
	SetText(text string)
	Copy(text string)
	Paste(text string)
}

Clipboard Hierarchy:

Object
  +- Clipboard

type Config

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

type Display

type Display interface {
	Object

	Init() (already bool)
	App() *CApplication
	Destroy()
	GetTitle() string
	SetTitle(title string)
	GetTtyPath() string
	SetTtyPath(ttyPath string)
	GetTtyHandle() *os.File
	SetTtyHandle(ttyHandle *os.File)
	GetCompressEvents() bool
	SetCompressEvents(compress bool)
	Screen() Screen
	DisplayCaptured() bool
	CaptureDisplay() (err error)
	ReleaseDisplay()
	CallEnabled() (enabled bool, err error)
	Call(fn cexec.Callback) (err error)
	Command(name string, argv ...string) (err error)
	IsMonochrome() bool
	Colors() (numberOfColors int)
	CaptureCtrlC()
	ReleaseCtrlC()
	CapturedCtrlC() bool
	GetClipboard() (clipboard Clipboard)
	FocusedWindow() Window
	FocusWindow(w Window)
	FocusNextWindow()
	FocusPreviousWindow()
	MapWindow(w Window)
	MapWindowWithRegion(w Window, region ptypes.Region)
	UnmapWindow(w Window)
	IsMappedWindow(w Window) (mapped bool)
	GetWindows() (windows []Window)
	GetWindowAtPoint(point ptypes.Point2I) (window Window)
	CursorPosition() (position ptypes.Point2I, moving bool)
	SetEventFocus(widget Object) error
	GetEventFocus() (widget Object)
	GetPriorEvent() (event Event)
	ProcessEvent(evt Event) enums.EventFlag
	RequestDraw()
	RequestShow()
	RequestSync()
	RequestQuit()
	IsRunning() bool
	StartupComplete()
	AsyncCall(fn DisplayCallbackFn) error
	AwaitCall(fn DisplayCallbackFn) error
	AsyncCallMain(fn DisplayCallbackFn) error
	AwaitCallMain(fn DisplayCallbackFn) error
	PostEvent(evt Event) error
	Run() (err error)
	Startup() (ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup, err error)
	Main(ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup) (err error)
	MainFinish()
	HasPendingEvents() (pending bool)
	HasBufferedEvents() (hasEvents bool)
	IterateBufferedEvents() (refreshed bool)
}

type DisplayCallbackFn

type DisplayCallbackFn = func(d Display) error

type DisplayCommandFn added in v0.5.0

type DisplayCommandFn = func(in, out *os.File) error

type DisplayManagerFn

type DisplayManagerFn func(d Display)

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

func (ev *EventError) Clone() *EventError

func (*EventError) Err

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 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) KeyAsRune added in v0.4.4

func (ev *EventKey) KeyAsRune() rune

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) RuneAsKey added in v0.4.4

func (ev *EventKey) RuneAsKey() Key

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

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

func (ev *EventMouse) Clone() Event

func (*EventMouse) CloneForPosition

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) Point2I added in v0.4.5

func (ev *EventMouse) Point2I() (point ptypes.Point2I)

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

Start 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 EventQuit added in v0.5.10

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

EventQuit is sent when the display needs to render the screen

func NewEventQuit added in v0.5.10

func NewEventQuit() *EventQuit

func (*EventQuit) When added in v0.5.10

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

When returns the time when the EventQuit was created

type EventRender added in v0.5.10

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

EventRender is sent when the display needs to render the screen

func NewEventDraw added in v0.5.10

func NewEventDraw() *EventRender

NewEventDraw creates an EventRender

func NewEventDrawAndShow added in v0.5.10

func NewEventDrawAndShow() *EventRender

NewEventDrawAndShow creates an EventRender configured to also request a show after the draw cycle completes

func NewEventDrawAndSync added in v0.5.10

func NewEventDrawAndSync() *EventRender

NewEventDrawAndSync creates an EventRender configured to also request a sync after the draw cycle completes

func NewEventRender added in v0.5.10

func NewEventRender(draw, show, sync bool) *EventRender

func NewEventShow added in v0.5.10

func NewEventShow() *EventRender

NewEventShow creates an EventRender configured to just show the screen

func NewEventSync added in v0.5.10

func NewEventSync() *EventRender

NewEventSync creates an EventRender configured to just sync the screen

func (*EventRender) Draw added in v0.5.10

func (ev *EventRender) Draw() bool

Draw returns true when the EventRender was created with one of the NewEventDraw*() functions

func (*EventRender) Show added in v0.5.10

func (ev *EventRender) Show() bool

Show returns true when the EventRender was created with either of the NewEventShow() or NewDrawAndShow() functions

func (*EventRender) Sync added in v0.5.10

func (ev *EventRender) Sync() bool

Sync returns true when the EventRender was created with either of the NewEventSync() or NewDrawAndSync() functions

func (*EventRender) When added in v0.5.10

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

When returns the time when the EventRender 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 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 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 LookupKeyByName added in v0.5.6

func LookupKeyByName(name string) Key

func LookupKeyRune

func LookupKeyRune(r rune) Key

type MetaData

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) (buildable 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
	GetFloat64Property(name Property) (value float64, err error)
	GetFloatProperty(name Property) (value float64, err error)
	SetFloatProperty(name Property, value float64) error
	GetColorProperty(name Property) (value paint.Color, err error)
	SetColorProperty(name Property, value paint.Color) error
	GetStyleProperty(name Property) (value paint.Style, err error)
	SetStyleProperty(name Property, value paint.Style) error
	GetThemeProperty(name Property) (value paint.Theme, err error)
	SetThemeProperty(name Property, value paint.Theme) error
	GetPointProperty(name Property) (value ptypes.Point2I, err error)
	SetPointProperty(name Property, value ptypes.Point2I) error
	GetRectangleProperty(name Property) (value ptypes.Rectangle, err error)
	SetRectangleProperty(name Property, value ptypes.Rectangle) error
	GetRegionProperty(name Property) (value ptypes.Region, err error)
	SetRegionProperty(name Property, value ptypes.Region) error
	GetStructProperty(name Property) (value interface{}, err error)
	SetStructProperty(name Property, value interface{}) error
	GetTimeProperty(name Property) (value time.Duration, err error)
	SetTimeProperty(name Property, value time.Duration) 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

func (m ModMask) String() string

type MouseFlags

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 paint.Theme)
	SetTheme(theme paint.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 OffScreen

type OffScreen 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 screen.  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 screen 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)

	Screen
}

OffScreen represents a screen simulation. This is intended to be a superset of normal Screens, but also adds some important interfaces for testing.

func MakeOffScreen

func MakeOffScreen(charset string) (OffScreen, error)

func NewOffScreen

func NewOffScreen(charset string) OffScreen

NewOffScreen returns a OffScreen. Note that OffScreen is also a Display.

func NewTestingScreen

func NewTestingScreen(t *testing.T, charset string) OffScreen

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 paint.Style

	// Runes is the list of runes, unadulterated, in UTF-8.
	Runes []rune
}

OffscreenCell represents a simulated screen cell. The purpose of this is to track on screen content.

type OffscreenWindow

type OffscreenWindow interface {
	Object

	Init() bool
	GetWindowType() (value enums.WindowType)
	SetWindowType(hint enums.WindowType)
	SetTitle(title string)
	GetTitle() string
	GetDisplay() Display
	SetDisplay(d Display)
	Draw() enums.EventFlag
	ProcessEvent(evt Event) enums.EventFlag
}

Basic window interface

type Property

type Property string
const (
	PropertyDisplayName Property = "display-name"
	PropertyDisplayUser Property = "display-user"
	PropertyDisplayHost Property = "display-host"
)
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 PropertyText Property = "text"
const PropertyTheme Property = "theme"

func (Property) String

func (p Property) String() string

type PropertyType

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"
	TimeProperty      PropertyType = "time"
)

func (PropertyType) String

func (p PropertyType) String() string

type Screen

type Screen interface {
	// Init initializes the screen for use.
	Init() error
	InitWithFilePath(fp string) error
	InitWithFileHandle(fh *os.File) error

	TtyKeepFileHandle(keeping bool)
	TtyKeepingFileHandle() (keeping bool)
	TtyCloseWithStiRead(enabled bool)
	GetTtyCloseWithStiRead() (enabled bool)
	GetTermType() (ttyType cterm.TermType)

	// Close finalizes the screen also releasing resources.
	Close()

	// Clear erases the screen.  The contents of any screen buffers
	// will also be cleared.  This has the logical effect of
	// filling the screen with spaces, using the global default style.
	Clear()

	// Fill fills the screen with the given character and style.
	Fill(rune, paint.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 paint.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 screen cells; most often this will be 1, but some East Asian
	// characters require two cells.
	GetContent(x, y int) (mainc rune, combc []rune, style paint.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 displayed 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 paint.Style)

	// SetStyle sets the default style to use when clearing the screen
	// or when StyleDefault is specified.  If it is also StyleDefault,
	// then whatever system/terminal default is relevant will be used.
	SetStyle(style paint.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 screen, the cursor will be hidden.
	ShowCursor(x int, y int)

	// HideCursor is used to hide the cursor.  It's an alias for
	// ShowCursor(-1, -1).
	HideCursor()

	// Size returns the screen 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 Screen is finalized.
	PollEvent() Event

	// PollEventChan provides a PollEvent() call response through a channel
	// for the purposes of using a select statement to poll for new events
	PollEventChan() (next chan 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 screen.
	//
	// 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 screen, 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 screen 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

	// RegisterRuneFallback adds a fallback for runes that are not
	// part of the character set -- for example one could register
	// o as a fallback for ø.  This should be done cautiously for
	// characters that might be displayed ordinarily in language
	// specific text -- characters that could change the meaning of
	// of written text would be dangerous.  The intention here is to
	// facilitate fallback characters in pseudo-graphical applications.
	//
	// If the terminal has fallbacks already in place via an alternate
	// character set, those are used in preference.  Also, standard
	// fallbacks for graphical characters in the ACSC terminfo string
	// are registered implicitly.
	//
	// 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)

	RegisterConsoleFallback(r rune, subst rune)
	UnregisterConsoleFallback(r rune)

	// CanDisplay returns true if the given rune can be displayed on
	// this screen.  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

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

	HostClipboardEnabled() (enabled bool)
	CopyToClipboard(s string)
	PasteFromClipboard() (s string, ok bool)
	EnableHostClipboard(enabled bool)
	EnableTermClipboard(enabled bool)
}

Screen represents the physical (or emulated) display. This can be a terminal window or a physical console. Platforms implement this differently.

func NewScreen

func NewScreen() (Screen, error)

NewScreen returns a Screen 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 Sensitive

type Sensitive interface {
	ProcessEvent(evt Event) enums.EventFlag
}

type ServerAuthHandler added in v0.3.2

type ServerAuthHandler interface {
	Init() (already bool)
	ID() (id uuid.UUID)
	Attach(server ApplicationServer) (err error)
	Detach() (err error)
	Reload(ctx *cli.Context) (err error)
	HasArgument(arg string) (has bool)
	RegisterArgument(flag cli.Flag)
}

func NewDefaultServerAuthHandler added in v0.3.2

func NewDefaultServerAuthHandler() (handler ServerAuthHandler)

type ServerAuthPasswordHandler added in v0.3.2

type ServerAuthPasswordHandler interface {
	ServerAuthHandler

	PasswordCallback(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error)
}

type Signal

type Signal string
const (
	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"
	SignalEventPaste          Signal = "event-paste"
	SignalSetEventFocus       Signal = "set-event-focus"
	SignalStartupComplete     Signal = "startup-complete"
	SignalDisplayStartup      Signal = "display-startup"
	SignalDisplayShutdown     Signal = "display-shutdown"
	SignalMappedWindow        Signal = "mapped-window"
	SignalUnmappedWindow      Signal = "unmapped-window"
	SignalFocusedWindow       Signal = "focused-window"
	SignalFocusNextWindow     Signal = "focus-next-window"
	SignalFocusPreviousWindow Signal = "focus-previous-window"
)
const SignalActivate Signal = "activate"
const SignalChanged Signal = "changed"
const SignalCopy Signal = "copy"
const SignalDestroy Signal = "destroy"

emitted when the object instance is destroyed

const SignalNotifyStartupComplete Signal = "notify-startup-complete"
const SignalPaste Signal = "paste"
const SignalPrepare Signal = "prepare"
const SignalPrepareStartup Signal = "prepare-startup"
const SignalReconfigure Signal = "reconfigure"
const SignalSetupDisplay Signal = "setup-display"
const SignalShutdown Signal = "shutdown"
const SignalStartup Signal = "startup"

func (Signal) String

func (s Signal) String() string

type SignalListenerData

type SignalListenerData []interface{}

type SignalListenerFn

type SignalListenerFn func(data []interface{}, argv ...interface{}) enums.EventFlag

func WithArgvApplicationSignalPrepareStartup added in v0.5.20

func WithArgvApplicationSignalPrepareStartup(fn ApplicationPrepareStartupFn) SignalListenerFn

func WithArgvApplicationSignalStartup added in v0.4.2

func WithArgvApplicationSignalStartup(fn ApplicationStartupFn) SignalListenerFn

func WithArgvNoneSignal added in v0.4.2

func WithArgvNoneSignal(fn func(), eventFlag enums.EventFlag) SignalListenerFn

func WithArgvNoneWithFlagsSignal added in v0.4.2

func WithArgvNoneWithFlagsSignal(fn func() enums.EventFlag) SignalListenerFn

type Signaling

type Signaling interface {
	TypeItem

	Init() (already bool)
	Handled(signal Signal, handle string) (found bool)
	Connect(signal Signal, handle string, c SignalListenerFn, data ...interface{})
	Disconnect(signal Signal, handle string) error
	Emit(signal Signal, argv ...interface{}) enums.EventFlag
	HasListeners(signal Signal) (has bool)
	DisconnectAll()
	StopSignal(signals ...Signal)
	IsSignalStopped(signals ...Signal) (stopped bool)
	PassSignal(signals ...Signal)
	IsSignalPassed(signals ...Signal) (passed bool)
	ResumeSignal(signals ...Signal)
	Freeze()
	Thaw()
	IsFrozen() (frozen bool)
}

type TimerCallbackFn

type TimerCallbackFn = func() enums.EventFlag

type Type

type Type interface {
	New() interface{}
	Buildable() (hasConstructor bool)
	Items() []interface{}
	Add(item interface{})
	Remove(item TypeItem) error
	Aliases() []string

	Lock()
	Unlock()
	RLock()
	RUnlock()
}

func NewType

func NewType(tag TypeTag, constructor func() interface{}, aliases ...string) Type

type TypeItem

type TypeItem interface {
	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() uuid.UUID
	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)

	Lock()
	Unlock()
	RLock()
	RUnlock()
}

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 uuid.UUID, err error)
	HasID(index uuid.UUID) bool
	GetTypeItems(tag TypeTag) []interface{}
	GetTypeItemByID(id uuid.UUID) 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

func MakeTypeTag(tag string) TypeTag

constructs a new TypeTag instance

type Window

type Window interface {
	Object

	Init() bool
	Destroy()
	GetWindowType() (value enums.WindowType)
	SetWindowType(hint enums.WindowType)
	SetTitle(title string)
	GetTitle() string
	GetDisplay() Display
	SetDisplay(d Display)
	Draw() enums.EventFlag
	ProcessEvent(evt Event) enums.EventFlag
}

Basic window interface

func NewOffscreenWindow

func NewOffscreenWindow(title string) Window

func NewWindow

func NewWindow(title string, d Display) Window

Jump to

Keyboard shortcuts

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