manager

package module
v0.0.0-...-afb5167 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const PlaceholderDelimiter = "$$"
View Source
const PlaceholderDelimiterEscaped = `$\$`
View Source
const PlaceholderMacro = "@"

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func New

func New(db *sql.DB) (*Manager, error)

New initialises and returns a Snippet Manager.

func (*Manager) AddSetting

func (m *Manager) AddSetting(tx *sql.Tx, key string, value string) error

AddSetting creates a new setting with given key and value.

func (*Manager) AddSnippet

func (m *Manager) AddSnippet(tx *sql.Tx, abbreviation string, body string) (*snippet.Snippet, error)

AddSnippet creates a new Snippet with a unique ID.

func (*Manager) CopySnippet

func (m *Manager) CopySnippet(abbreviation string, skipLastUsed bool) error

CopySnippet copies an expanded snippet into the clipboard.

func (*Manager) GetExpandedBodyForAbbreviation

func (m *Manager) GetExpandedBodyForAbbreviation(abbreviation string) (body string, cursorOffset int, err error)

GetExpandedBodyForAbbreviation expands placeholders in returned body along with cursor offset.

func (*Manager) GetSetting

func (m *Manager) GetSetting(tx *sql.Tx, key string) (string, error)

GetSetting returns a setting value for a given key.

func (*Manager) GetSnippetWithAbbreviation

func (m *Manager) GetSnippetWithAbbreviation(abbreviation string) (*snippet.Snippet, error)

GetSnippetWithAbbreviation for a given abbreviation.

func (*Manager) GetSnippetWithID

func (m *Manager) GetSnippetWithID(id uuid.UUID) (*snippet.Snippet, error)

GetSnippetWithID for a given ID.

func (*Manager) GetSnippets

func (m *Manager) GetSnippets(search string, orderByLastUsed bool) ([]*snippet.Snippet, error)

GetSnippets returns all Snippets where their abbreviation or body includes given search string.

func (*Manager) GetSnippetsEndingWithAbbreviation

func (m *Manager) GetSnippetsEndingWithAbbreviation(abbreviation string) ([]*snippet.Snippet, error)

GetSnippetsEndingWithAbbreviation returns all Snippets that end with given abbreviation fragment.

func (*Manager) InsertSnippet

func (m *Manager) InsertSnippet(tx *sql.Tx, snippet *snippet.Snippet) (*snippet.Snippet, error)

InsertSnippet saves a Snippet, with generated ID if not set.

func (*Manager) RemoveSetting

func (m *Manager) RemoveSetting(tx *sql.Tx, key string) error

RemoveSetting removes a setting with given key.

func (*Manager) RemoveSnippetWithID

func (m *Manager) RemoveSnippetWithID(tx *sql.Tx, id uuid.UUID) error

RemoveSnippetWithID deletes a snippet given its ID.

func (*Manager) UpdateSetting

func (m *Manager) UpdateSetting(tx *sql.Tx, key string, value string) (int64, error)

UpdateSetting updates a setting with the given key and value, and returns how many records were updated.

func (*Manager) UpdateSnippetWithID

func (m *Manager) UpdateSnippetWithID(tx *sql.Tx, id uuid.UUID, snippet *snippet.Snippet) error

UpdateSnippetWithID saves changes to the Snippet with given ID.

Jump to

Keyboard shortcuts

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