goacme

package module
v0.8.1-0...-25f3e2e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2020 License: BSD-3-Clause Imports: 9 Imported by: 2

README

goacme

goacme provides interface to Acme programming environment

Documentation

Overview

This file is part of goacme

Copyright (c) 2013, 2014, 2020 Alexander Sychev. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above

copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • The name of author may not be used to endorse or promote products derived from

this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Package goacme provides interface to acme programming environment

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidOrigin will be returned if a case of an unexpected origin of action
	ErrInvalidOrigin = errors.New("invalid origin of action")

	// ErrInvalidType will be returned if a case of an unexpected type of action
	ErrInvalidType = errors.New("invalid type of action")

	// ErrChannelAlreadyOpened will be returned
	// if channel of events is opened by call of EventChannel
	ErrChannelAlreadyOpened = errors.New("channel of events is already opened")
)

Functions

func DeleteAll

func DeleteAll()

DeleteAll deletes all the windows opened in a session

Types

type ActionOrigin

type ActionOrigin int

ActionOrigin is a origin of the action

const (
	Unknown ActionOrigin = 0
	// Edit is the origin for writes to the body or tag file
	Edit ActionOrigin = 1 << iota
	// File is the origin for through the window's other files
	File
	// Keyboard is the origin for keyboard actions
	Keyboard
	// Mouse is the origin for mouse actions
	Mouse
)

type ActionType

type ActionType int

ActionType is a type of the action

const (
	Delete ActionType = 1 << iota
	Insert
	Look
	Execute
	// Tag is a flag points out the event has occured in the tag of the window
	Tag
	// TagMask is a mask points out the event should be masked by tag
	TagMask
	AllTypes = Delete | Insert | Look | Execute
)

type Event

type Event struct {

	// Origin will be an origin of action with type ActionOrigin
	Origin ActionOrigin

	// Type will be an type of action with type ActionType
	Type ActionType

	// Begin is a start address of a text of the action
	Begin int

	// End is an end address of the text of the action
	End int

	// IsBuiltin is a flag the action is recognised like an \.{Acme}'s builtin
	IsBuiltin bool
	// NoLoad is a flag of acme can interpret the action without loading a new file
	NoLoad bool
	// IsFile is a flag the Text is a file or window name
	IsFile bool
	// Text is a text arguments of the action, perhaps with address
	Text string
	// Arg is a text of chorded argument if any
	Arg string
	// contains filtered or unexported fields
}

type Info

type Info struct {
	Id          int
	TagSize     int
	BodySize    int
	IsDirectory bool
	IsDirty     bool
	Tag         []string
}

type Infos

type Infos []*Info

func WindowsInfo

func WindowsInfo() (res Infos, err error)

WindowsInfo returns a list of the existing acme windows.

func (Infos) Get

func (this Infos) Get(id int) (*Info, error)

Get returns Info by id or an error

func (Infos) Len

func (this Infos) Len() int

func (Infos) Less

func (this Infos) Less(i, j int) bool

func (Infos) Swap

func (this Infos) Swap(i, j int)

type Log

type Log struct {
	// contains filtered or unexported fields
}

func OpenLog

func OpenLog() (*Log, error)

OpenLog opens the log and returns *Log or error

func (*Log) Close

func (this *Log) Close() error

Close close the log

func (*Log) EventChannel

func (this *Log) EventChannel(tmask OperationType) (<-chan *LogEvent, error)

EventChannel returns a channel of *LogEvent from which log events can be read or error. Only OperationType set in tmask are used. First call of EventChannel starts a goroutine to read events from the log and put them to the channel. Subsequent calls of EventChannel will return the same channel.

func (*Log) Read

func (this *Log) Read() (*LogEvent, error)

Read reads a log of window operations of the window from the log. Read returns LogEvent or error.

type LogEvent

type LogEvent struct {
	Id   int
	Type OperationType
	Name string
}

type OperationType

type OperationType int

OperationType is a type of the operation

const (
	NewWin OperationType = 1 << iota
	Zerox
	Get
	Put
	DelWin
	Focus
)

type Window

type Window struct {
	// contains filtered or unexported fields
}

Window is a structure to manipulate a particular acme's window.

func New

func New() (*Window, error)

New creates a new window and returns *Window or error

func Open

func Open(id int) (*Window, error)

Open opens a window with a specified id and returns *Window or error

func (*Window) Close

func (this *Window) Close() error

Close releases all resources of the window

func (*Window) Del

func (this *Window) Del(sure bool) error

Del deletes the window, without a prompt if sure is true.

func (*Window) EventChannel

func (this *Window) EventChannel(size int, tmask ActionType) (<-chan *Event, error)

EventChannel returns a channel of *Event with a buffer size from which events can be read or error. Only ActionTypes set in tmask are used. If TagMask is set in tmask, the event will be masked by tag. Otherwise Tag flag will be ignored. First call of EventChannel starts a goroutine to read events from "event" file and put them to the channel. Subsequent calls of EventChannel will return the same channel.

func (*Window) File

func (this *Window) File(file string) (io.ReadWriteSeeker, error)

File returns io.ReadWriteSeeker of corresponding file of the windows or error

func (*Window) Read

func (this *Window) Read(p []byte) (int, error)

Read reads len(p) bytes from "body" file of the window. Read returns a count of read bytes or error.

func (*Window) ReadAddr

func (this *Window) ReadAddr() (begin int, end int, err error)

ReadAddr reads the address of the next read/write operation from "addr" file of the window. ReadAddr return begin and end offsets in symbols or error

func (*Window) ReadCtl

func (this *Window) ReadCtl() (id int, tlen int, blen int, isdir bool, isdirty bool, wwidth int, font string, twidth int, err error)

ReadCtl reads the address of the next read/write operation from "ctl" file of the window. ReadCtl returns:

id - the window ID
tlen - number of characters (runes) in the tag;
blen - number of characters in the body;
isdir -  true if the window is a directory, false otherwise;
isdirty - true if the window is modified, false otherwise;
wwidth - the width of the window in pixels;
font - the name of the font used in the window;
twidth - the width of a tab character in pixels;
error - in case of any error.

func (*Window) ReadEvent

func (this *Window) ReadEvent() (*Event, error)

reads an event from "event" file of the window and returns *Event or error

func (*Window) Seek

func (this *Window) Seek(offset int64, whence int) (ret int64, err error)

Seek sets a position for the next Read or Write to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. Seek returns the new offset or error

func (*Window) UnreadEvent

func (this *Window) UnreadEvent(ev *Event) error

UnreadEvent writes event ev back to the "event" file, indicating to acme that it should be handled internally.

func (*Window) Write

func (this *Window) Write(p []byte) (int, error)

Write writes len(p) bytes to "body" file of the window. Write returns a count of written bytes or error.

func (*Window) WriteAddr

func (this *Window) WriteAddr(format string, args ...interface{}) error

WriteAddr writes format with args in "addr" file of the window

func (*Window) WriteCtl

func (this *Window) WriteCtl(format string, args ...interface{}) error

WriteCtl writes format with args in "ctl" file of the window In case format is not ended by newline, '\n' will be added to the end of format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL