Categorygithub.com/go-curses/cdk
modulepackage
0.5.23
Repository: https://github.com/go-curses/cdk.git
Documentation: pkg.go.dev

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

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetDefaultDisplay returns the default display for the current app context.
GetEncoding is used by Display implementors who want to locate an encoding for the given character set name.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
LoadApplicationFromPlugin is a wrapper around LoadApplicationFromPluginWithExport, using a default exported symbol name of `CdkApp`.
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.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
constructs a new TypeTag instance.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewEventDraw creates an EventRender.
NewEventDrawAndShow creates an EventRender configured to also request a show after the draw cycle completes.
NewEventDrawAndSync creates an EventRender configured to also request a sync after the draw cycle completes.
NewEventError creates an ErrorEvent with the given error payload.
NewEventInterrupt creates an EventInterrupt with the given payload.
NewEventKey attempts to create a suitable event.
NewEventMouse is used to create a new mouse event.
NewEventPaste returns a new EventPaste.
No description provided by the author
No description provided by the author
NewEventResize creates an EventResize with the new updated window size, which is given in character cells.
NewEventShow creates an EventRender configured to just show the screen.
NewEventSync creates an EventRender configured to just sync the screen.
NewEventTime creates a Time Event for the given time.
NewOffScreen returns a OffScreen.
No description provided by the author
No description provided by the author
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.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
constructs a new Concrete TypeTag instance.
No description provided by the author
No description provided by the author
RegisterEncoding may be called by the application to register an encoding.
SetEncodingFallback changes the behavior of GetEncoding when a suitable encoding is not found.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Usually left mouse button.
Usually the middle mouse button.
Usually the right mouse button.
Often a side button (thumb/next).
Often a side button (thumb/prev).
These are the actual button values.
These are the actual button values.
These are the actual button values.
These are the actual button values.
No button or wheel events.
These are the actual button values.
These are the actual button values.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EncodingFallbackASCII behaviore causes GetEncoding to fall back to a 7-bit ASCII encoding, if no other encoding can be found.
EncodingFallbackFail behavior causes GetEncoding to fail when it cannot find an encoding.
EncodingFallbackUTF8 behavior causes GetEncoding to assume UTF8 can pass unmodified upon failure.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
These are the defined ASCII values for key codes.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
These keys are aliases for other names.
These keys are aliases for other names.
This is the list of named keys.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
This is the list of named keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
This is the list of named keys.
This is the list of named keys.
ASCII Keys.
ASCII Keys.
These are the defined ASCII values for key codes.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
Escape.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the control keys.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
This is the list of named keys.
These are the defined ASCII values for key codes.
ASCII Keys.
ASCII Keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
ASCII Keys.
These are the defined ASCII values for key codes.
This is the list of named keys.
These are the defined ASCII values for key codes.
These keys are aliases for other names.
These are the defined ASCII values for key codes.
ASCII Keys.
These keys are aliases for other names.
These are the defined ASCII values for key codes.
These keys are aliases for other names.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
ASCII Keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
These are the defined ASCII values for key codes.
ASCII Keys.
ASCII Keys.
These are the defined ASCII values for key codes.
ASCII Keys.
ASCII Keys.
These are the defined ASCII values for key codes.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
These are the defined ASCII values for key codes.
ASCII Keys.
These are the defined ASCII values for key codes.
ASCII Keys.
These are the defined ASCII values for key codes.
ASCII Keys.
ASCII Keys.
This is the list of named keys.
ASCII Keys.
ASCII Keys.
This is the list of named keys.
This is the list of named keys.
ASCII Keys.
This is the list of named keys.
ASCII Keys.
This is the list of named keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
These are the defined ASCII values for key codes.
This is the list of named keys.
ASCII Keys.
ASCII Keys.
These are the defined ASCII values for key codes.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
ASCII Keys.
ASCII Keys.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
These are the defined ASCII values for key codes.
These keys are aliases for other names.
These are the defined ASCII values for key codes.
ASCII Keys.
ASCII Keys.
ASCII Keys.
ASCII Keys.
This is the list of named keys.
This is the list of named keys.
This is the list of named keys.
These are the defined ASCII values for key codes.
ASCII Keys.
These are the defined ASCII values for key codes.
ASCII Keys.
Highest mask value.
These are the modifiers keys that can be sent either with a key press, or a mouse event.
These are the modifiers keys that can be sent either with a key press, or a mouse event.
These are the modifiers keys that can be sent either with a key press, or a mouse event.
These are the modifiers keys that can be sent either with a key press, or a mouse event.
These are the modifiers keys that can be sent either with a key press, or a mouse event.
No description provided by the author
No description provided by the author
Click events only.
Click-drag events (includes button events).
All mouse events (includes click and drag events).
No description provided by the author
No description provided by the author
No description provided by the author
request that the object be rendered with additional features useful to debugging custom Widget development.
No description provided by the author
No description provided by the author
No description provided by the author
property wrapper around the CTypeItem name field.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
emitted when the object instance is destroyed.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Wheel motion down/towards user.
Wheel motion to left.
Wheel motion to right.
Wheel motion up/away from user.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DisplayCallCapacity limits the number of concurrent calls on main threads.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ErrEventQFull indicates that the event queue is full, and cannot accept more events.
ErrNoCharset indicates that the locale environment the program is not supported by the program, because no suitable encoding was found for it.
ErrNoDisplay indicates that no suitable display could be found.
ErrTermNotFound indicates that a suitable terminal entry could not be found.
No description provided by the author
No description provided by the author
No description provided by the author
Setting these globals will enable command line flags and their corresponding features.
Setting these globals will enable command line flags and their corresponding features.
Setting these globals will enable command line flags and their corresponding features.
Setting these globals will enable command line flags and their corresponding features.
Setting these globals will enable command line flags and their corresponding features.
Setting these globals will enable command line flags and their corresponding features.
Setting these globals will enable command line flags and their corresponding features.
Setting these globals will enable command line flags and their corresponding features.
Setting these globals will enable command line flags and their corresponding features.
Setting these globals will enable command line flags and their corresponding features.
KeyNames holds the written names of special keys.
MainDrawInterval is the interval between renders (milliseconds).
MainIterateDelay is the event iteration loop delay.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Basic display type.
CellBuffer represents a two dimensional array of character cells.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Basic window type.
No description provided by the author
No description provided by the author
CScreen represents a screen backed by a terminfo implementation.
CServerAuthHandler is the base type for application server authentication handler implementations.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Basic window type.
An EventError is an event representing some sort of error, and carries an error payload.
EventInterrupt is a generic wakeup event.
EventKey represents a key press.
EventMouse is a mouse event.
EventPaste is used to mark the start and end of a bracketed paste.
EventQuit is sent when the display needs to render the screen.
EventRender is sent when the display needs to render the screen.
EventResize is sent when the window size changes.
EventTime is a simple base event class, suitable for easy reuse.
OffscreenCell represents a simulated screen cell.

# Interfaces

No description provided by the author
No description provided by the author
Clipboard Hierarchy: Object +- Clipboard.
No description provided by the author
Event is a generic interface used for passing around Events.
EventHandler is anything that handles events.
No description provided by the author
No description provided by the author
No description provided by the author
This is the base type for all complex CDK object types.
OffScreen represents a screen simulation.
Basic window interface.
Screen represents the physical (or emulated) display.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Basic window interface.

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ButtonMask is a mask of mouse buttons and wheel events.
No description provided by the author
denotes a concrete type identity.
No description provided by the author
No description provided by the author
No description provided by the author
EncodingFallback describes how the system behavees when the locale requires a character set that we do not support.
No description provided by the author
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.
ModMask is a mask of modifier keys.
MouseFlags are options to modify the handling of mouse events.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author