Documentation
¶
Overview ¶
CountLines does a quick (buffered) line(\n) count of a file.
package core contains the core data structures and functionality leveraged y the other other Goed packages.
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func BomEncoding(from string) encoding.Encoding
- func Cleanup()
- func CleanupDotGoed()
- func ClipboardRead() (string, error)
- func ClipboardWrite(s string) error
- func CopyFile(from, to string) error
- func CopyFromUTF8(from, to string, dstEnc encoding.Encoding) error
- func CopyToUTF8(from, to string, srcEnc encoding.Encoding) error
- func CountLines(r io.Reader) (int, error)
- func DetectColors() int
- func EnvWith(custom []string) []string
- func FindResource(relPath string) (absPath string)
- func GoedHome() string
- func GoedSocket(id int64) string
- func InitHome(id int64)
- func Instances() (ids []int64)
- func IsDir(loc string) bool
- func LookupLocation(dir, loc string) (string, bool)
- func MustAsset(name string) []byte
- func MvFile(from, to string) error
- func RandString(n int) string
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func RunesLen(runes []rune) int
- func RunesToString(runes [][]rune) string
- func StringToRunes(s string) [][]rune
- func SyntaxHighlighting() bool
- func TermColors()
- func UpdateResources()
- func UsesCrLf(file string) bool
- type Action
- type ActionDispatcher
- type AddCrLfTransformer
- type Backend
- type Commander
- type Config
- type CrLfEncoding
- type CursorMvmt
- type DropCrLfTransformer
- type Editable
- type FileOp
- type Highlighter
- type MockTerm
- func (t *MockTerm) Char(y, x int, c rune, fg, bg Style)
- func (t *MockTerm) CharAt(y, x int) rune
- func (t *MockTerm) Clear(fg, bg Style)
- func (t *MockTerm) Close()
- func (t *MockTerm) Flush()
- func (t *MockTerm) Init() error
- func (t *MockTerm) Listen()
- func (t *MockTerm) SetCursor(y, x int)
- func (t *MockTerm) SetExtendedColors(b bool)
- func (t *MockTerm) Size() (h, w int)
- type Rwsc
- type Selection
- type Slice
- type Style
- type StyledRune
- type Term
- type TextInfo
- type Theme
- type ViewType
- type Viewable
- type Widget
Constants ¶
const ( Plain uint16 = 1 << (8 + iota) Bold Underlined )
const ( CursorMvmtRight CursorMvmt = 0 CursorMvmtLeft = 1 CursorMvmtUp = 2 CursorMvmtDown = 3 CursorMvmtPgDown = 4 CursorMvmtPgUp = 5 CursorMvmtHome = 6 CursorMvmtEnd = 7 CursorMvmtTop = 8 CursorMvmtBottom = 9 CursorMvmtScrollDown = 10 CursorMvmtScrollUp = 11 )
const ( ViewTypeStandard ViewType = 0 // editable file ViewTypeShell = 1 // interactive shell ViewTypeCmdOutput = 2 // static command output ViewTypeDirListing = 3 // similar to 3 but specific to a dir listing )
const ApiVersion = "v1"
const Version = "0.1.2"
Variables ¶
var ApiPort int
var Colors int
Colors is the number of colors to use in the terminal
var ConfFile string
ConfigFile holds the path to the config file currently in use.
var Home string
Home represent the goed "home" folder.
var InstanceId int64 // instance ID
var LineSep = []byte{'\n'}
var LogFile *os.File
LogFile holds the path of the log file currently in use.
var OsLsArgs []string
var ShowEvents = false
var Socket string // instance RPC socket
var Terminal string
terminal as defined by $SHELL
var Testing bool
testing : whether we are in "unit test" mode.
var Trace = false
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/
foo.txt
img/
a.png
b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func BomEncoding ¶
Check if the file starts with a bom and if so return the encoding Returns nil if no BOM or unsupported encoding
func CleanupDotGoed ¶
func CleanupDotGoed()
func ClipboardRead ¶
func ClipboardWrite ¶
func DetectColors ¶
func DetectColors() int
func FindResource ¶
GetResource finds a GOED resource either from - GOED_HOME/<path> or - GOED/HOME/standard/<path>
func GoedSocket ¶
func LookupLocation ¶
LookupLocation will try to locate the given location if not found relative to dir, then try up the directory tree this works great to open GO import path for example
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RandString ¶
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func RunesToString ¶
RunesToString transforms a rune matrix as a string.
func StringToRunes ¶
StringToRunes transforms a string into a rune matrix.
func SyntaxHighlighting ¶
func SyntaxHighlighting() bool
func UpdateResources ¶
func UpdateResources()
UpdateResource creates or updates the bundled resources into GOED_HOME
Types ¶
type ActionDispatcher ¶
type ActionDispatcher interface {
Dispatch(action Action)
Flush()
Shutdown()
Start()
}
var Bus ActionDispatcher
type AddCrLfTransformer ¶
type AddCrLfTransformer struct{}
Replace "\n" with "\r\n" windows combos
func (AddCrLfTransformer) Reset ¶
func (t AddCrLfTransformer) Reset()
type Backend ¶
type Backend interface {
// SrcLoc returns the location of the original data.
SrcLoc() string
// BufferLoc is the location of the "copy" the backend works directly on.
BufferLoc() string
Insert(line, col int, text string) error
Append(text string) error
Remove(line1, col1, line2, col2 int) error
LineCount() int
// Save saves the edited data (BufferLoc) into the original (SrcLoc)
Save(loc string) error
SendBytes(data []byte)
// Slice gets a region of text ("rectangle") as a runes matrix
Slice(line1, col, line2, col2 int) *Slice
// Close closes the backend resources.
Close() error
// ViewId returns the "unique" viewid given to this buffer.
ViewId() int64
// Completely clears the buffer text (empty document)
Wipe()
// Reloads the text (from SrcLoc to BufferLoc)
Reload() error
// return the color style at a specific location (mem backends)
ColorAt(ln, col int) (fg, bg Style)
//SourceMd5 or ts?
//BufferMd5 or ts?
SetVtCols(cols int)
OnActivate()
OffsetAt(ln, col int) int64
}
Backend represent the backend(data operations) of a View. Backend implements the low level data handling.
type Commander ¶
type Commander interface {
Backspace()
Clear()
CursorMvmt(mvmt CursorMvmt)
Delete()
Insert(text string)
NewLine()
}
interafce for the command bar
type Config ¶
type Config struct {
SyntaxHighlighting bool
Theme string // ie: theme1.toml
MaxCmdBufferLines int // Max # of lines to keep in buffer when running a command
GuiFont string // full path to a monospace TTF font
GuiFontSize int
GuiFontDpi int
MinViewWidth int // preferred minimum view width (in characters)
LineWidthIndicator int // line width indicator (ie: 80 cols)
}
Config represents the Goed configuration data.
func LoadConfig ¶
type CrLfEncoding ¶
CrLfEncoding encode / decodes '\r\n' to '\n'
func (CrLfEncoding) NewDecoder ¶
func (c CrLfEncoding) NewDecoder() *encoding.Decoder
func (CrLfEncoding) NewEncoder ¶
func (c CrLfEncoding) NewEncoder() *encoding.Encoder
type CursorMvmt ¶
type CursorMvmt byte
type DropCrLfTransformer ¶
type DropCrLfTransformer struct{}
Drop Windows "\r\n" combos (in favor of plain "\n")
func (DropCrLfTransformer) Reset ¶
func (t DropCrLfTransformer) Reset()
type Editable ¶
type Editable interface {
Commandbar() Commander
CmdbarToggle()
Config() Config
CurViewId() int64
DelColByIndex(col int, check bool)
DelView(viewId int64, terminate bool)
DelViewCheck(viewId int64, terminate bool)
Dispatch(action Action)
FileEvent(op FileOp, loc string)
// CmdOn indicates whether the CommandBar is currently active
CmdOn() bool
// Open opens a file in the given view (new view if viewid<0)
// create -> create file at loc if does not exist yet
Open(loc string, viewId int64, rel string, create bool) (int64, error)
Quit()
QuitCheck() bool
// Render updates the whole editor UI
Render()
Resize(h, w int)
// SetStatusErr displays an error message in the status bar
SetStatusErr(err string)
// SetStatusErr displays a message in the status bar
SetStatus(status string)
SetCursor(y, x int)
// SetCmdOn activates or desactives the CommandBar
SetCmdOn(v bool)
Size() (h, w int)
StartTermView(args []string) int64
SwapViews(v1, v2 int64)
Start(locs []string)
TermChar(y, x int, c rune)
TermFB(fg, bg Style)
TermFill(c rune, y1, x1, y2, x2 int)
TermFlush()
TermStr(y, x int, s string)
TermStrv(y, x int, s string)
Theme() *Theme
ViewActivate(v int64)
ViewAt(ln, col int) int64
// ViewByLoc finds if there is an existing view for the given file (loc)
ViewById(id int64) Viewable
ViewsByLoc(loc string) []int64
ViewIndex(id int64) (row, col int) // column, row **index** in the editor UI
// Move a view
ViewMove(y1, x1, y2, x2 int)
// Navigate from a view to another
Views() []int64 // list of all opened views
}
Editable provides editor features entry poins.
var Ed Editable
Ed is thew editor singleton
type Highlighter ¶
type MockTerm ¶
type MockTerm struct {
// contains filtered or unexported fields
}
Mock Terminal implementation for testing
func NewMockTerm ¶
func NewMockTerm() *MockTerm
func (*MockTerm) SetExtendedColors ¶
type Selection ¶
type Selection struct {
LineFrom, ColFrom int // selection start point
LineTo, ColTo int // selection end point (colto=-1 means whole lines)
}
Selection represents some selected text in a view
func NewSelection ¶
type Slice ¶
type Slice struct {
sync.RWMutex
R1, C1, R2, C2 int //bounds
// contains filtered or unexported fields
}
Slice represents a "matrix" of text (runes) coordinates are of a rectangle (unlike a selection whihc is ptA to ptB)
func (*Slice) ContainsLine ¶
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
The format of a style as stored in a file is 4 bytes, HexaDecimal as follows: color, attr
func (Style) IsUnderlined ¶
func (*Style) UnmarshalText ¶
type StyledRune ¶
func (*StyledRune) UnmarshalText ¶
func (s *StyledRune) UnmarshalText(text []byte) error
type Term ¶
type Term interface {
Close()
Clear(fg, bg Style)
Char(y, x int, c rune, fg, bg Style)
Flush()
Init() error
Listen()
SetExtendedColors(bool)
SetCursor(y, x int)
Size() (y, x int)
}
Terminal interface
type TextInfo ¶
func CrLfTextInfo ¶
return TextInfo with extra CrLf encoding/decoding if needed
func ReadTextInfo ¶
ReadTextInfo checks if a file appears to be text or not(binary) Returns nil if the file appears binary or some unsupported encoding.
type Theme ¶
type Theme struct {
Bg Style // default to term bg
Fg Style // default to term fg
BgSelect Style // default to term bg
FgSelect Style // default to term fg
BgCursor Style
FgCursor Style
Comment Style
String Style
Number Style
Keyword1, Keyword2, Keyword3 Style
Symbol1, Symbol2, Symbol3 Style
Separator1, Separator2, Separator3 Style
FileClean StyledRune
FileDirty StyledRune
Scrollbar StyledRune
ScrollTab StyledRune
Statusbar StyledRune
StatusbarText Style
StatusbarTextErr Style
Cmdbar StyledRune
CmdbarText Style
CmdbarTextOn Style
Viewbar StyledRune
ViewbarText Style
MoreTextSide StyledRune
MoreTextUp StyledRune
MoreTextDown StyledRune
TabChar StyledRune
Margin StyledRune
Close StyledRune
}
Theme represents a goed theme data.
func ReadDefaultTheme ¶
type Viewable ¶
type Viewable interface {
Widget
Backspace()
Backend() Backend
ClearSelections()
Copy()
CurCol() int
CurLine() int
CursorMvmt(mvmt CursorMvmt)
Cut()
Delete(row1, col1, row, col2 int, undoable bool)
DeleteCur()
Dirty() bool
Id() int64
Insert(row, col int, text string, undoable bool)
InsertCur(text string)
InsertNewLineCur()
LastViewCol() int
LastViewLine() int
LineCount() int
// LineRunesTo returns the number of raw runes to the given line column
LineRunesTo(s *Slice, line, col int) int
// MoveCursor moves the cursor by the y, x offsets (in runes)
MoveCursor(y, x int)
MoveCursorRoll(y, x int)
OpenSelection(newView bool)
Paste()
// Reload reloads the view data from it's source (backend)
Reload()
// Reset reinitializes the view to it's startup state.
Reset()
Save() // Save from buffer to src
ScrollPos() (ln, col int)
SetBackend(backend Backend)
SetDirty(bool)
SelectAll()
SelectWord(ln, col int)
Selections() *[]Selection
// SetAutoScroll is used to make the view scroll contonuously in y,x increments
// keeps scrolling until x and y are set to 0.
SetAutoScroll(y, x int, isSelect bool)
SetCursorPos(y, x int)
SetScrollPct(ypct int)
SetScrollPos(y, x int)
SetTitle(title string)
SetViewType(t ViewType)
SetVtCols(cols int)
// Sets the view work directory, commands and "open" actions will be relative
// to this path.
SetWorkDir(dir string)
// Slice returns a view's text subset (rectangle)
Slice() *Slice
StretchSelection(prevl, prevc, ln, c int)
SyncSlice()
Title() string
Text(ln1, col1, ln2, col2 int) [][]rune
Type() ViewType
WorkDir() string
}
Viewable is the interface to a View
type Widget ¶
type Widget interface {
// Get the widget bounds (within parent)
Bounds() (y1, x1, y2, x2 int)
// Get parent widget or nil if none
GetParent() Widget
// Render forces re-rendering the view UI.
Render()
// Set the widget bounds (within parent)
SetBounds(y1, x1, y2, x2 int)
// Set the parent, typically internal use only
SetParent(w Widget)
}