Documentation ¶
Index ¶
- type Editor
- func (e *Editor) Draw()
- func (e *Editor) DrawInfoBar()
- func (e *Editor) DrawStatusBar()
- func (e *Editor) DrawStatusMsg()
- func (e *Editor) GetColOff() int
- func (e *Editor) GetHeight() int
- func (e *Editor) GetRowOff() int
- func (e *Editor) GetText() []rune
- func (e *Editor) GetWidth() int
- func (e *Editor) GetX() int
- func (e *Editor) GetY() int
- func (e *Editor) IncColOff(inc int)
- func (e *Editor) IncRowOff(inc int)
- func (e *Editor) MoveCursor(x, y int)
- func (e *Editor) SendDraw()
- func (e *Editor) SetSize(w, h int)
- func (e *Editor) SetText(text string)
- func (e *Editor) SetX(x int)
- type EditorConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Editor ¶
type Editor struct { // Text contains the editor's content. Text []rune // Cursor represents the cursor position of the editor. Cursor int // Width represents the terminal's width in characters. Width int // Height represents the terminal's width in characters. Height int // ColOff is the number of columns between the start of a line and the left of the editor window ColOff int // RowOff is the number of rows between the beginning of the text and the top of the editor window RowOff int // ShowMsg acts like a switch for the status bar. ShowMsg bool // StatusMsg holds the text to be displayed in the status bar. StatusMsg string // StatusChan is used to send and receive status messages. StatusChan chan string // StatusMu protects against concurrent reads and writes to status bar info. StatusMu sync.Mutex // Users holds the names of all users connected to the server, displayed in the status bar. Users []string // ScrollEnabled determines whether or not the user can scroll past the initial editor // window. It is set by the EditorConfig. ScrollEnabled bool // IsConnected shows whether the editor is currently connected to the server. IsConnected bool // DrawChan is used to send and receive signals to update the terminal display. DrawChan chan int // contains filtered or unexported fields }
Editor represents the editor's skeleton. The editor is composed of two components: 1. an editable text area; which acts as the primary interactive area. 2. a status bar; which displays messages on different events, for example, when an user joins a session, etc.
func NewEditor ¶
func NewEditor(conf EditorConfig) *Editor
NewEditor returns a new instance of the editor.
func (*Editor) Draw ¶
func (e *Editor) Draw()
Draw updates the UI by setting cells with the editor's content.
func (*Editor) DrawInfoBar ¶ added in v1.2.1
func (e *Editor) DrawInfoBar()
DrawInfoBar draws the editor's debug information and the names of the active users in the editing session at the bottom of the termbox window.
func (*Editor) DrawStatusBar ¶ added in v1.2.1
func (e *Editor) DrawStatusBar()
DrawStatusBar shows all status and debug information on the bottom line of the editor.
func (*Editor) DrawStatusMsg ¶ added in v1.2.1
func (e *Editor) DrawStatusMsg()
DrawStatusMsg draws the editor's status message at the bottom of the termbox window.
func (*Editor) GetColOff ¶ added in v1.2.1
GetColOff returns the horizontal offset of the editor window from the start of a line.
func (*Editor) GetRowOff ¶ added in v1.2.1
GetRowOff returns the vertical offset of the editor window from the start of the text.
func (*Editor) IncColOff ¶ added in v1.2.1
IncColOff increments the horizontal offset of the editor window from the start of a line by inc.
func (*Editor) IncRowOff ¶ added in v1.2.1
IncRowOff increments the vertical offset of the editor window from the start of the text by inc.
func (*Editor) MoveCursor ¶
MoveCursor updates the cursor position horizontally by a given x increment, and vertically by one line in the direction indicated by y. The positive directions are right and down, respectively. This is used by the UI layer, where it updates the cursor position on keypresses.
func (*Editor) SendDraw ¶ added in v1.2.1
func (e *Editor) SendDraw()
SendDraw sends a draw signal to the drawLoop. Use this function to ensure concurrency safety for rendering the editor.
type EditorConfig ¶ added in v1.2.1
type EditorConfig struct {
ScrollEnabled bool
}