Documentation
¶
Overview ¶
Package etcell provides an github.com/hajimehoshi/ebiten/v2 to github.com/gdamore/tcell/v2 translation layer.
Index ¶
- type ETCell
- func (et *ETCell) Exit(err error)
- func (et *ETCell) GetGameSize() (width, height int)
- func (et *ETCell) NewGame() *ETCellGame
- func (et *ETCell) Run(runner func(screen tcell.Screen) error) error
- func (et *ETCell) Screen() *ETCellScreen
- func (et *ETCell) SetFont(face font.Face) *ETCell
- func (et *ETCell) SetScreenCursorColor(color tcell.Color) *ETCell
- func (et *ETCell) SetScreenSize(cols int, rows int) *ETCell
- type ETCellGame
- type ETCellScreen
- func (et *ETCellScreen) Beep() (err error)
- func (et *ETCellScreen) CanDisplay(r rune, checkFallbacks bool) (can bool)
- func (et *ETCellScreen) ChannelEvents(ch chan<- tcell.Event, quit <-chan struct{})
- func (et *ETCellScreen) CharacterSet() (charset string)
- func (et *ETCellScreen) Clear()
- func (et *ETCellScreen) Colors() (ncolors int)
- func (et *ETCellScreen) DisableFocus()
- func (et *ETCellScreen) DisableMouse()
- func (et *ETCellScreen) DisablePaste()
- func (et *ETCellScreen) EnableFocus()
- func (et *ETCellScreen) EnableMouse(flags ...tcell.MouseFlags)
- func (et *ETCellScreen) EnablePaste()
- func (et *ETCellScreen) Fill(r rune, style tcell.Style)
- func (et *ETCellScreen) Fini()
- func (et *ETCellScreen) GetClipboard()
- func (et *ETCellScreen) GetContent(x, y int) (primary rune, combining []rune, style tcell.Style, width int)
- func (et *ETCellScreen) HasKey(key tcell.Key) (has bool)
- func (et *ETCellScreen) HasMouse() (has bool)
- func (et *ETCellScreen) HasPendingEvent() (has bool)
- func (et *ETCellScreen) HideCursor()
- func (et *ETCellScreen) Init() (err error)
- func (et *ETCellScreen) LockRegion(x, y, width, height int, lock bool)
- func (et *ETCellScreen) PollEvent() (ev tcell.Event)
- func (et *ETCellScreen) PostEvent(ev tcell.Event) (err error)
- func (et *ETCellScreen) PostEventWait(ev tcell.Event)deprecated
- func (et *ETCellScreen) RegisterRuneFallback(r rune, subst string)
- func (et *ETCellScreen) Resize(int, int, int, int)
- func (et *ETCellScreen) Resume() (err error)
- func (et *ETCellScreen) SetCell(x int, y int, style tcell.Style, ch ...rune)
- func (et *ETCellScreen) SetClipboard(content []byte)
- func (et *ETCellScreen) SetContent(x int, y int, primary rune, combining []rune, style tcell.Style)
- func (et *ETCellScreen) SetCursorStyle(cs tcell.CursorStyle, colors ...tcell.Color)
- func (et *ETCellScreen) SetSize(int, int)
- func (et *ETCellScreen) SetStyle(style tcell.Style)
- func (et *ETCellScreen) SetTitle(title string)
- func (et *ETCellScreen) Show()
- func (et *ETCellScreen) ShowCursor(x int, y int)
- func (et *ETCellScreen) Size() (width, height int)
- func (et *ETCellScreen) Suspend() (err error)
- func (et *ETCellScreen) Sync()
- func (et *ETCellScreen) Tty() (tty tcell.Tty, is_tty bool)
- func (et *ETCellScreen) UnregisterRuneFallback(r rune)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ETCell ¶
type ETCell struct {
ETCellScreen
}
ETCell is the ebiten to tcell manager. An empty ETCell is valid, and ready to use. An ETCell should not be copied.
func (*ETCell) GetGameSize ¶
GetGameSize() returns the size of the image to draw (without GeoM scaling)
func (*ETCell) NewGame ¶
func (et *ETCell) NewGame() *ETCellGame
Game returns the a new ebiten.Game interface for this ETCell wrapper.
func (*ETCell) Screen ¶
func (et *ETCell) Screen() *ETCellScreen
Screen returns the singleton tcell.Screen interface for this ETCell wrapper.
func (*ETCell) SetScreenCursorColor ¶
SetScreenCursorColor sets the color of the text 'hardware' cursor.
type ETCellGame ¶
type ETCellGame struct {
*ETCell
GeoM ebiten.GeoM // This should only be set initially, or modified in Draw(), Update(), or Layout() overrides.
// contains filtered or unexported fields
}
func (*ETCellGame) Draw ¶
func (et *ETCellGame) Draw(dst *ebiten.Image)
Draw handles drawing in the game context. Used to implement a custom override for ETCellGame.
func (*ETCellGame) Layout ¶
func (et *ETCellGame) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)
Layout returns the integer layout.
func (*ETCellGame) LayoutF ¶
func (et *ETCellGame) LayoutF(outsideWidth, outsideHeight float64) (screenWidth, screenHeight float64)
LayoutF returns the floating point layout.
func (*ETCellGame) Update ¶
func (et *ETCellGame) Update() (err error)
Update processes ebiten.Game events. If Screen.Suspend() has been called, does nothing.
type ETCellScreen ¶
type ETCellScreen struct {
// contains filtered or unexported fields
}
func (*ETCellScreen) Beep ¶
func (et *ETCellScreen) Beep() (err error)
Beep attempts to sound an OS-dependent audible alert and returns an error when unsuccessful.
func (*ETCellScreen) CanDisplay ¶
func (et *ETCellScreen) CanDisplay(r rune, checkFallbacks bool) (can bool)
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.
func (*ETCellScreen) ChannelEvents ¶
func (et *ETCellScreen) ChannelEvents(ch chan<- tcell.Event, quit <-chan struct{})
ChannelEvents is an infinite loop that waits for an event and channels it into the user provided channel ch. Closing the quit channel and calling the Fini method are cancellation signals. When a cancellation signal is received the method returns after closing ch.
This method should be used as a goroutine.
NOTE: PollEvent should not be called while this method is running.
func (*ETCellScreen) CharacterSet ¶
func (et *ETCellScreen) CharacterSet() (charset string)
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.
func (*ETCellScreen) Clear ¶
func (et *ETCellScreen) Clear()
Clear logically erases the screen. This is effectively a short-cut for Fill(' ', StyleDefault).
func (*ETCellScreen) Colors ¶
func (et *ETCellScreen) Colors() (ncolors int)
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.
func (*ETCellScreen) DisableFocus ¶
func (et *ETCellScreen) DisableFocus()
DisableFocus disables reporting of focus events.
func (*ETCellScreen) DisableMouse ¶
func (et *ETCellScreen) DisableMouse()
DisableMouse disables the mouse.
func (*ETCellScreen) DisablePaste ¶
func (et *ETCellScreen) DisablePaste()
DisablePaste disables bracketed paste mode.
func (*ETCellScreen) EnableFocus ¶
func (et *ETCellScreen) EnableFocus()
EnableFocus enables reporting of focus events, if your terminal supports it.
func (*ETCellScreen) EnableMouse ¶
func (et *ETCellScreen) EnableMouse(flags ...tcell.MouseFlags)
EnableMouse enables the mouse. (If your terminal supports it.) If no flags are specified, then all events are reported, if the terminal supports them.
func (*ETCellScreen) EnablePaste ¶
func (et *ETCellScreen) EnablePaste()
EnablePaste enables bracketed paste mode, if supported.
func (*ETCellScreen) Fill ¶
func (et *ETCellScreen) Fill(r rune, style tcell.Style)
Fill fills the screen with the given character and style. The effect of filling the screen is not visible until Show is called (or Sync).
func (*ETCellScreen) Fini ¶
func (et *ETCellScreen) Fini()
Fini finalizes the screen also releasing resources.
func (*ETCellScreen) GetClipboard ¶
func (et *ETCellScreen) GetClipboard()
GetClipboard triggers an EventPaste with the clipboard as the Data() Not implemented.
func (*ETCellScreen) GetContent ¶
func (et *ETCellScreen) GetContent(x, y int) (primary rune, combining []rune, style tcell.Style, width int)
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 and emoji require two cells.
func (*ETCellScreen) HasKey ¶
func (et *ETCellScreen) HasKey(key tcell.Key) (has 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.
func (*ETCellScreen) HasMouse ¶
func (et *ETCellScreen) HasMouse() (has bool)
HasMouse returns true if the terminal (apparently) supports a mouse. Note that the return value of true doesn't guarantee that a mouse/pointing device is present; a false return definitely indicates no mouse support is available.
func (*ETCellScreen) HasPendingEvent ¶
func (et *ETCellScreen) HasPendingEvent() (has bool)
HasPendingEvent returns true if PollEvent would return an event without blocking. If the screen is stopped and PollEvent would return nil, then the return value from this function is unspecified. The purpose of this function is to allow multiple events to be collected at once, to minimize screen redraws.
func (*ETCellScreen) HideCursor ¶
func (et *ETCellScreen) HideCursor()
HideCursor is used to hide the cursor. It's an alias for ShowCursor(-1, -1).sim
func (*ETCellScreen) Init ¶
func (et *ETCellScreen) Init() (err error)
Init initializes the screen for use.
func (*ETCellScreen) LockRegion ¶
func (et *ETCellScreen) LockRegion(x, y, width, height int, lock bool)
LockRegion sets or unsets a lock on a region of cells. A lock on a cell prevents the cell from being redrawn.
func (*ETCellScreen) PollEvent ¶
func (et *ETCellScreen) PollEvent() (ev tcell.Event)
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.
func (*ETCellScreen) PostEvent ¶
func (et *ETCellScreen) PostEvent(ev tcell.Event) (err error)
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.
func (*ETCellScreen) PostEventWait
deprecated
func (et *ETCellScreen) PostEventWait(ev tcell.Event)
Deprecated: PostEventWait is unsafe, and will be removed in the future.
PostEventWait is like PostEvent, but if the queue is full, it blocks until there is space in the queue, making delivery reliable. However, it is VERY important that this function never be called from within whatever event loop is polling with PollEvent(), otherwise a deadlock may arise.
For this reason, when using this function, the use of a Goroutine is recommended to ensure no deadlock can occur.
func (*ETCellScreen) RegisterRuneFallback ¶
func (et *ETCellScreen) RegisterRuneFallback(r rune, subst 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 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 alternate character set 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.
func (*ETCellScreen) Resize ¶
func (et *ETCellScreen) Resize(int, int, int, int)
Resize does nothing, since it's generally not possible to ask a screen to resize, but it allows the Screen to implement the View interface.
func (*ETCellScreen) Resume ¶
func (et *ETCellScreen) Resume() (err error)
Resume resumes after Suspend().
func (*ETCellScreen) SetCell ¶
SetCell is an older API, and will be removed. Please use SetContent instead; SetCell is implemented in terms of SetContent.
func (*ETCellScreen) SetClipboard ¶
func (et *ETCellScreen) SetClipboard(content []byte)
SetClipboard sets the content of the system clipboard to the bytes given. Not implemented.
func (*ETCellScreen) SetContent ¶
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 and emoji) 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.
func (*ETCellScreen) SetCursorStyle ¶
func (et *ETCellScreen) SetCursorStyle(cs tcell.CursorStyle, colors ...tcell.Color)
SetCursorStyle is used to set the cursor style. If the style is not supported (or cursor styles are not supported at all), then this will have no effect.
func (*ETCellScreen) SetSize ¶
func (et *ETCellScreen) SetSize(int, int)
SetSize attempts to resize the window. It also invalidates the cells and calls the resize function. Note that if the window size is changed, it will not be restored upon application exit.
Many terminals cannot support this. Perversely, the "modern" Windows Terminal does not support application-initiated resizing, whereas the legacy terminal does. Also, some emulators can support this but may have it disabled by default.
func (*ETCellScreen) SetStyle ¶
func (et *ETCellScreen) SetStyle(style tcell.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.
func (*ETCellScreen) SetTitle ¶
func (et *ETCellScreen) SetTitle(title string)
SetTitle sets the title bar of the window. Not implemented.
func (*ETCellScreen) Show ¶
func (et *ETCellScreen) Show()
Show makes all the content changes made using SetContent() visible on the display.
It does so in the most efficient and least visually disruptive manner possible.
func (*ETCellScreen) ShowCursor ¶
func (et *ETCellScreen) ShowCursor(x int, y int)
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.
func (*ETCellScreen) Size ¶
func (et *ETCellScreen) Size() (width, height int)
Size returns the screen size as width, height. This changes in response to a call to Clear or Flush.
func (*ETCellScreen) Suspend ¶
func (et *ETCellScreen) Suspend() (err error)
Suspend pauses input and output processing. It also restores the terminal settings to what they were when the application started. This can be used to, for example, run a sub-shell.
func (*ETCellScreen) Sync ¶
func (et *ETCellScreen) Sync()
Sync works like Show(), but it updates every visible cell on the physical display, assuming that it is not synchronized with any internal model. This may be both expensive and visually jarring, so it should only be used when believed to actually be necessary.
Typically, this is called as a result of a user-requested redraw (e.g. to clear up on-screen corruption caused by some other program), or during a resize event.
func (*ETCellScreen) Tty ¶
func (et *ETCellScreen) Tty() (tty tcell.Tty, is_tty bool)
Tty returns the underlying Tty. If the screen is not a terminal, the returned bool will be false
func (*ETCellScreen) UnregisterRuneFallback ¶
func (et *ETCellScreen) UnregisterRuneFallback(r rune)
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.