Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
const BACKSPACE uint16 = 0x08
BACKSPACE is the backspace
const BACKTAB uint16 = 0x5b5a
BACKTAB indicates shift + tab
const CARRIAGE_RETURN uint16 = 0x0D
CARRIAGE_RETURN indicates "enter"
const CURSOR_DOWN uint16 = 0x5b42
CURSOR_DOWN (down arrow)
const CURSOR_LEFT uint16 = 0x5b43
CURSOR_LEFT (left arrow)
const CURSOR_RIGHT uint16 = 0x5b44
CURSOR_RIGHT (left arrow)
const CURSOR_UP uint16 = 0x5b41
CURSOR_UP (up arrow)
const DEL uint16 = 0x7f
DEL is the delete key
const ESC uint16 = 0x1b
ESC is the escape code.
const SCROLL_DOWN uint16 = 0x5b54
SCROLL_DOWN (page down)
const SCROLL_UP uint16 = 0x5b53
SCROLL_UP (page up)
const TAB uint16 = 0x09
TAB indicates the horizontal tab
const TERM_BLACK = uint(0)
TERM_BLACK represents black
const TERM_BLUE = uint(4)
TERM_BLUE represents blue
const TERM_CYAN = uint(6)
TERM_CYAN represents cyan
const TERM_GREEN = uint(2)
TERM_GREEN represents green
const TERM_MAGENTA = uint(5)
TERM_MAGENTA represents magenta
const TERM_RED = uint(1)
TERM_RED represents red
const TERM_WHITE = uint(7)
TERM_WHITE represents white
const TERM_YELLOW = uint(3)
TERM_YELLOW represents yellow
const UNKNOWN uint16 = 0x5bff
UNKNOWN is a fall-back for unknown escape sequences
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnsiEscape ¶
type AnsiEscape struct {
// contains filtered or unexported fields
}
AnsiEscape represents an ANSI escape code used for formatting text in a terminal.
func UnderlineAnsiEscape ¶
func UnderlineAnsiEscape() AnsiEscape
UnderlineAnsiEscape constructs a reset term.
func (AnsiEscape) Bg256Colour ¶
func (p AnsiEscape) Bg256Colour(col uint) AnsiEscape
Bg256Colour sets the background colour using 256-colour mode.
func (AnsiEscape) BgColour ¶
func (p AnsiEscape) BgColour(col uint) AnsiEscape
BgColour sets the foreground colour
func (AnsiEscape) Fg256Colour ¶
func (p AnsiEscape) Fg256Colour(col uint) AnsiEscape
Fg256Colour sets the foreground colour using 256-colour mode.
func (AnsiEscape) FgColour ¶
func (p AnsiEscape) FgColour(col uint) AnsiEscape
FgColour sets the foreground colour
type Canvas ¶
type Canvas interface { // Get the dimensions of this canvas. GetDimensions() (uint, uint) // Write a chunk to the canvas. Write(x, y uint, text FormattedText) }
Canvas represents a surface on which widgets can draw.
type FormattedText ¶
type FormattedText struct {
// contains filtered or unexported fields
}
FormattedText represents, as the name suggests, a chunk of formatted text.
func NewColouredText ¶
func NewColouredText(text string, colour uint) FormattedText
NewColouredText constructs a new (coloured) chunk of text.
func NewFormattedText ¶
func NewFormattedText(text string, format AnsiEscape) FormattedText
NewFormattedText constructs a new chunk of text with a given format.
func NewText ¶
func NewText(text string) FormattedText
NewText constructs a new (unformatted) chunk of text.
func (*FormattedText) Bytes ¶
func (p *FormattedText) Bytes() []byte
Bytes returns an ANSI-formatted byte representing of this chunk.
func (*FormattedText) ClearFormat ¶
func (p *FormattedText) ClearFormat()
ClearFormat clears any formatting for this chunk of text.
func (*FormattedText) Clip ¶
func (p *FormattedText) Clip(start uint, end uint)
Clip removes text from the start and end.
func (*FormattedText) Format ¶
func (p *FormattedText) Format(format AnsiEscape)
Format sets the format for this chunk of text.
func (*FormattedText) Len ¶
func (p *FormattedText) Len() uint
Len returns the number of characters [runes] in this chunk of formatted text. Observe that this does not include characters arising from the formatting escapes.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal provides a simple top-level window.
func (*Terminal) Add ¶
Add a new widget to this window. Widgets will be laid out vertically in the order they are added.
type Widget ¶
type Widget interface { // Get height of this widget, where MaxUint indicates widget expands to take // as much as it can. GetHeight() uint // Render this widget on the given canvas. Render(canvas Canvas) }
Widget is an abstract entity which can be displayed upon a terminal window.
type Window ¶
type Window interface { // Add a new widget to this window. Widgets will be laid out vertically in // the order they are added. Add(w Widget) // Render this window to the terminal. Render() error }
Window provides an abstraction over an interactive terminal session. This is fairly simplistic at this stage, and supports layout of widges in a vertical direction only.