Documentation ¶
Overview ¶
Package ui contains the T user interface.
Package ui implements the T text editor UI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound indicates that a resource is not found.
Functions ¶
Types ¶
type NewColumnRequest ¶
type NewColumnRequest struct { // X is the left-side of the column // given as a fraction of the window width. // X where // 0 the left side of the window // 0.5 the center of the window // 1 the right side of the window // A new column may be restricted to a minimum width. X float64 `json:"x"` }
A NewColumnRequest requests a new column be created.
type NewSheetRequest ¶
type NewSheetRequest struct { // URL is either the root URL of an editor server, // or the URL of an existing editor server buffer. // // If URL is an existing buffer, that buffer will be used as the sheet body. // Otherwise, a new buffer is created on the editor server for the body. URL string `json:"url"` }
A NewSheetRequest requests a new sheet be created.
type NewWindowRequest ¶
type NewWindowRequest struct { // Width is the requested width. Width int `json:"width"` // Height is the requested height. Height int `json:"height"` }
A NewWindowRequest requests a new window be created.
type Server ¶
Server is a T user interface server
func NewServer ¶
NewServer returns a new Server for the given Screen. The editorURL must be the root URL of an editor server. Column and sheet tags use buffers created on this editor server.
func (*Server) RegisterHandlers ¶
RegisterHandlers registers handlers for the following paths and methods:
/windows is the list of opened windows. GET returns a Window list of the opened windows. Returns: • OK on success. • Internal Server Error on internal error. PUT creates a new window with a single column and returns its Window. The body must be a NewWindowRequest. Returns: • OK on success. • Internal Server Error on internal error. • Bad Request if the WindowRequest is malformed. /window/<ID> is the window with the given ID. DELETE deletes the window and all of its sheets. The server process exits when the last window is deleted. Returns: • OK on success. • Internal Server Error on internal error. • Not Found if the buffer is not found. /window/<ID>/columns is the list of the window's columns. PUT adds a column to the window. The body must be a NewColumnRequest. Returns: • OK on success. • Internal Server Error on internal error or if a new column cannot fit on the window. • Not Found if the window is not found. • Bad Request if the WindowRequest is malformed. /window/<ID>/sheets is the list of the window's sheets. PUT adds a sheet to the left-most column of the window and returns its Sheet. Returns: • OK on success. • Internal Server Error on internal error or if a new sheet cannot fit in the column. • Not Found if the window is not found. /sheets is the list of opened sheets. GET returns a Sheet list of the opened sheets. Returns: • OK on success. • Internal Server Error on internal error. /sheet/<ID> is the sheet with the given ID. DELETE deletes the sheet. Returns: • OK on success. • Internal Server Error on internal error. • Not Found if the sheet is not found.
Unless otherwise stated, the body of all error responses is the error message.
func (*Server) SetDoneHandler ¶
func (s *Server) SetDoneHandler(f func())
SetDoneHandler sets the function which is called if the last window is closed. By default, the done handler is a no-op.
type Sheet ¶
type Sheet struct { // ID is the ID of the sheet. ID string `json:"id"` // Path is the path to the sheet's resource. Path string `json:"path"` // WindowPath is the path to the sheet's window's resource. WindowPath string `json:"windowPath"` // TagURL is the URL of the tag's buffer. TagURL string `json:"tagUrl"` // BodyURL is the URL of the body's buffer. BodyURL string `json:"bodyUrl"` }
A Sheet describes an opened sheet.
type Window ¶
type Window struct { // ID is the ID of the window. ID string `json:"id"` // Path is the path of the window's resource. Path string `json:"path"` }
A Window describes an opened window.
Notes ¶
Bugs ¶
column 0 still ends up as column 1.