Documentation ¶
Index ¶
- Constants
- func AttoFolderPath() (string, error)
- func ConfigPath() (string, error)
- func HighlightLine(l *BufferLine, s *Syntax)
- func IsInsertable(c rune) bool
- func IsSeparator(c rune) bool
- func Start(args []string)
- type Buffer
- type BufferLine
- type Config
- type CursorMove
- type Editor
- func (e *Editor) Ask(q, a string) (string, error)
- func (e *Editor) AskChar(q string, choices []rune) (rune, error)
- func (e *Editor) BufferCount() int
- func (e *Editor) Close(i int)
- func (e *Editor) DeletePromptChar()
- func (e *Editor) DirtyBufferCount() (count int)
- func (e *Editor) Draw()
- func (e *Editor) DrawBuffer()
- func (e *Editor) DrawStatusBar()
- func (e *Editor) DrawTitleBar()
- func (e *Editor) FB() *Buffer
- func (e *Editor) HandleEvent(event termbox.Event)
- func (e *Editor) InsertPromptChar(c rune)
- func (e *Editor) MoveCursor(move CursorMove)
- func (e *Editor) MovePromptCursor(move CursorMove)
- func (e *Editor) Open()
- func (e *Editor) Read(path string)
- func (e *Editor) Run(args []string)
- func (e *Editor) Save()
- func (e *Editor) ScrollView()
- func (e *Editor) SetStatusMessage(format string, args ...interface{})
- func (e *Editor) Shutdown()
- type FileType
- type HighlightType
- type Syntax
- type SyntaxPatterns
Constants ¶
const ( ProgramName string = "Atto" ProgramVersion string = "0.4.0" ProgramAuthor string = "Jon Palmisciano <jonpalmisc@gmail.com>" )
Variables ¶
This section is empty.
Functions ¶
func AttoFolderPath ¶
func ConfigPath ¶
ConfigPath returns the path of Atto's config file on the current platform.
func HighlightLine ¶
func HighlightLine(l *BufferLine, s *Syntax)
func IsInsertable ¶
func IsSeparator ¶
Types ¶
type Buffer ¶
type Buffer struct { Editor *Editor // The name and type of the file currently being edited. FileName string FileType FileType Lines []BufferLine IsDirty bool // The cursor's position. The Y value must always be decremented by one when // accessing buffer elements since the editor's title bar occupies the first // row of the screen. CursorDX is the cursor's X position, with compensation // for extra space introduced by rendering tabs. CursorX int CursorDX int CursorY int // The viewport's column and row offsets. OffsetX int OffsetY int }
func CreateBuffer ¶
CreateBuffer creates a new buffer for a given path.
func (*Buffer) BreakLine ¶
func (b *Buffer) BreakLine()
BreakLine inserts a newline character and breaks the line at the cursor.
func (*Buffer) DeleteChar ¶
func (b *Buffer) DeleteChar()
DeleteChar deletes the character to the left of the cursor.
func (*Buffer) FocusedRow ¶
func (b *Buffer) FocusedRow() *BufferLine
FocusedRow returns the buffer's focused row.
func (*Buffer) InsertChar ¶
InsertChar inserts a character at the cursor's position.
func (*Buffer) InsertLine ¶
InsertLine inserts a new line to the buffer at the given index.
func (*Buffer) RemoveLine ¶
RemoveLine removes the line at the given index from the buffer.
type BufferLine ¶
type BufferLine struct { Buffer *Buffer Text string DisplayText string Highlighting []HighlightType }
BufferLine represents a single line in a buffer.
func MakeBufferLine ¶
func MakeBufferLine(buffer *Buffer, text string) (bl BufferLine)
MakeBufferLine creates a new BufferLine with the given text.
func (*BufferLine) AdjustX ¶
func (l *BufferLine) AdjustX(x int) int
AdjustX corrects the cursor's X position to compensate for rendering effects.
func (*BufferLine) AppendString ¶
func (l *BufferLine) AppendString(s string)
AppendString appends a string to the line.
func (*BufferLine) DeleteChar ¶
func (l *BufferLine) DeleteChar(i int)
DeleteChar deletes a character from the line at the given index.
func (*BufferLine) IndentLength ¶
func (l *BufferLine) IndentLength() (indent int)
IndentLength gets the line's level of indentation in columns.
func (*BufferLine) InsertChar ¶
func (l *BufferLine) InsertChar(i int, c rune)
InsertChar inserts a character into the line at the given index.
type CursorMove ¶
type CursorMove int
CursorMove is a type of cursor movement.
const ( // CursorMoveUp moves the cursor up one row. CursorMoveUp CursorMove = 0 // CursorMoveDown moves the cursor down one row. CursorMoveDown CursorMove = 1 // CursorMoveLeft moves the cursor left one column. CursorMoveLeft CursorMove = 2 // CursorMoveRight moves the cursor right one column. CursorMoveRight CursorMove = 3 // CursorMoveLineStart moves the cursor to the first non-whitespace // character of the line, or the first character of the line if the cursor // is already on the first non-whitespace character. CursorMoveLineStart CursorMove = 4 // CursorMoveLineEnd moves the cursor to the end of the line. CursorMoveLineEnd CursorMove = 5 // CursorMovePageUp moves the cursor up by the height of the screen. CursorMovePageUp CursorMove = 6 // CursorMovePageDown moves the cursor down by the height of the screen. CursorMovePageDown CursorMove = 7 )
type Editor ¶
type Editor struct { // The editor's buffers and the index of the focused buffer. Buffers []Buffer FocusIndex int // The editor's height and width measured in rows and columns, respectively. Width int Height int // The current status message and the time it was set. StatusMessage string StatusMessageTime time.Time // The prompt question, answer, and whether it is active or not. PromptQuestion string PromptAnswer string PromptIsActive bool // The user's editor configuration. Config Config }
Editor is the editor instance and manages the UI.
func (*Editor) Ask ¶
Ask prompts the user to answer a question and assumes control over all input until the question is answered or the request is cancelled.
func (*Editor) BufferCount ¶
BufferCount is a shorthand for getting the number of open buffers.
func (*Editor) DeletePromptChar ¶
func (e *Editor) DeletePromptChar()
DeletePromptChar removes a character from the current prompt answer.
func (*Editor) DirtyBufferCount ¶
DirtyBufferCount returns the number of dirty buffers.
func (*Editor) Draw ¶
func (e *Editor) Draw()
Draw draws the entire editor - UI, buffer, etc. - to the screen & updates the cursor's position.
func (*Editor) DrawBuffer ¶
func (e *Editor) DrawBuffer()
DrawBuffer draws the editor's focused buffer.
func (*Editor) DrawStatusBar ¶
func (e *Editor) DrawStatusBar()
DrawStatusBar draws the editor's status bar on the bottom of the screen.
func (*Editor) DrawTitleBar ¶
func (e *Editor) DrawTitleBar()
DrawTitleBar draws the editor's title bar at the top of the screen.
func (*Editor) HandleEvent ¶
func (e *Editor) HandleEvent(event termbox.Event)
HandleEvent executes the appropriate code in response to an event.
func (*Editor) InsertPromptChar ¶
InsertPromptChar inserts a character into the current prompt answer.
func (*Editor) MoveCursor ¶
func (e *Editor) MoveCursor(move CursorMove)
MoveCursor moves the cursor according to the operation provided.
func (*Editor) MovePromptCursor ¶
func (e *Editor) MovePromptCursor(move CursorMove)
MovePromptCursor moves the cursor inside of the current prompt.
func (*Editor) Open ¶
func (e *Editor) Open()
Open prompts the user for a path and creates a new buffer for it.
func (*Editor) Save ¶
func (e *Editor) Save()
Save writes the current buffer back to the file it was read from.
func (*Editor) ScrollView ¶
func (e *Editor) ScrollView()
ScrollView recalculates the offsets for the view window.
func (*Editor) SetStatusMessage ¶
SetStatusMessage sets the status message and the time it was set at.
type FileType ¶
type FileType string
FileType represents a type of file.
const ( FileTypeMakefile FileType = "Makefile" FileTypeCMake FileType = "CMake" FileTypeGo FileType = "Go" FileTypeGoModule FileType = "Go Module" // -- C/C++ -- FileTypeC FileType = "C" FileTypeCPP FileType = "C++" // -- Text Files -- FileTypeMarkdown FileType = "Markdown" FileTypePlaintext FileType = "Plaintext" FileTypeUnknown FileType = "Unknown" )
func GuessFileType ¶
GuessFileType attempts to deduce a file's type from its name and extension.
type HighlightType ¶
type HighlightType int
const ( HighlightTypeNormal HighlightType = iota HighlightTypePrimaryKeyword HighlightTypeSecondaryKeyword HighlightTypeNumber HighlightTypeString HighlightTypeComment )
func (HighlightType) Color ¶
func (t HighlightType) Color() termbox.Attribute
type Syntax ¶
type Syntax struct { Keywords []string Patterns SyntaxPatterns }
Syntax represent's a language syntax for highlighting purposes.
var SyntaxC Syntax = Syntax{ Keywords: []string{ "#define", "#include", "NULL", "auto", "break", "case", "char", "const", "continue", "default", "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "int", "long", "register", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef", "union", "unsigned", "void", "volatile", "while", }, Patterns: SyntaxPatterns{ SingleLineCommentStart: "//", MultiLineCommendStart: "/*", MultiLineCommentEnd: "*/", }, }
SyntaxC defines the syntax of the C language.
var SyntaxGo Syntax = Syntax{ Keywords: []string{ "append", "bool", "break", "byte", "cap", "case", "chan", "close", "complex", "complex128", "complex64", "const", "continue", "copy", "default", "defer", "delete", "else", "error", "fallthrough", "false", "float32", "float64", "for", "func", "go", "goto", "if", "imag", "import", "int", "int16", "int32", "int64", "int8", "interface", "len", "make", "map", "new", "nil", "package", "panic", "range", "real", "recover", "return", "rune", "select", "string", "struct", "switch", "true", "type", "uint", "uint16", "uint32", "uint64", "uint8", "uintptr", "var", }, Patterns: SyntaxPatterns{ SingleLineCommentStart: "//", MultiLineCommendStart: "/*", MultiLineCommentEnd: "*/", }, }
SyntaxGo defines the syntax of the Go language.
type SyntaxPatterns ¶
type SyntaxPatterns struct { SingleLineCommentStart string MultiLineCommendStart string MultiLineCommentEnd string }
SyntaxPatterns is used to define syntax patterns for the highlighter.