editors

package
v1.27.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MPL-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package editors is a Go Port of [GitHub Desktop's editor code](https://github.com/desktop/desktop/tree/development/app/src/lib/editors)

It was taken at this commit [a1ece18](https://github.com/desktop/desktop/tree/a1ece186bae3a742f206c5edeb0762e78fba2f7c/app/src/lib/editors)

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrEditorNotFound is returned when an editor is not found when called from
	// the Find function
	ErrEditorNotFound = goerrors.New("editor not found")
)

Functions

func LaunchExternalEditor

func LaunchExternalEditor(fullPath string, startLine int, startCol int, editor FoundEditor) error

LaunchExternalEditor opens a given file or folder in the desired external editor.

Types

type EditorName

type EditorName string

EditorName represents the name of an editor we display to a user

This file contains the full list of editors we support

const (
	AndroidStudio       EditorName = "Android Studio"
	AptanaStudio        EditorName = "Aptana Studio"
	Atom                EditorName = "Atom"
	AtomBeta            EditorName = "Atom (Beta)"
	AtomNightly         EditorName = "Atom (Nightly)"
	BBEdit              EditorName = "BBEdit"
	Brackets            EditorName = "Brackets"
	Code                EditorName = "Code"
	CodeRunner          EditorName = "CodeRunner"
	ColdFusionBuilder   EditorName = "ColdFusion Builder"
	Emacs               EditorName = "Emacs"
	Geany               EditorName = "Geany"
	GEdit               EditorName = "GEdit"
	GnomeBuilder        EditorName = "GNOME Builder"
	GnomeTextEditor     EditorName = "GNOME Text Editor"
	GVim                EditorName = "gVim"
	JetbrainsCLion      EditorName = "CLion"
	JetbrainsDataSpell  EditorName = "DataSpell"
	JetbrainsFleet      EditorName = "Fleet"
	JetbrainsGoLand     EditorName = "GoLand"
	JetbrainsIntelliJ   EditorName = "IntelliJ"
	JetbrainsIntelliJCE EditorName = "IntelliJ CE"
	JetbrainsPhpStorm   EditorName = "PhpStorm"
	JetbrainsPyCharm    EditorName = "PyCharm"
	JetbrainsPyCharmCE  EditorName = "PyCharm CE"
	JetbrainsRider      EditorName = "Rider"
	JetbrainsRubyMine   EditorName = "RubyMine"
	JetbrainsWebStorm   EditorName = "WebStorm"
	Kate                EditorName = "Kate"
	LiteXL              EditorName = "Lite XL"
	MacVim              EditorName = "MacVim"
	Mousepad            EditorName = "Mousepad"
	Neovim              EditorName = "Neovim"
	NeovimQt            EditorName = "Neovim-Qt"
	Neovide             EditorName = "Neovide"
	NotePadPlusPlus     EditorName = "Notepad++"
	Notepadqq           EditorName = "Notepadqq"
	Nova                EditorName = "Nova"
	Pulsar              EditorName = "Pulsar"
	RStudio             EditorName = "RStudio"
	SlickEdit           EditorName = "SlickEdit"
	Studio              EditorName = "Studio"
	SublimeText         EditorName = "Sublime Text"
	TextMate            EditorName = "TextMate"
	Typora              EditorName = "Typora"
	VimR                EditorName = "VimR"
	VSCode              EditorName = "VSCode"
	VSCodeInsiders      EditorName = "VSCode (Insiders)"
	VSCodium            EditorName = "VSCodium"
	VSCodiumInsiders    EditorName = "VSCodium (Insiders)"
	XCode               EditorName = "XCode"
	Zed                 EditorName = "Zed"
	ZedPreview          EditorName = "Zed (Preview)"
)

type FoundEditor

type FoundEditor struct {
	// The friendly name of the editor, to be used in labels
	Editor EditorName `json:"editor"`
	// The executable associated with the editor to launch
	Path string `json:"path"`
	// The editor requires a shell to spawn
	UsesShell bool `json:"usesShell,omitempty"`
}

FoundEditor is a found external editor on the user's machine

func Find

func Find(ctx context.Context, name EditorName) (FoundEditor, error)

Find searches to an editor by name, returning the editor if found, or ErrEditorNotFound if not found

func Resolve

func Resolve(ctx context.Context) ([]FoundEditor, error)

Resolve a list of installed editors on the user's machine, using the known install identifiers that each OS supports.

type LinuxExternalEditor

type LinuxExternalEditor struct {
	// Name of the editor. It will be used both as identifier and user-facing.
	Name EditorName

	// List of possible paths where the editor's executable might be located.
	Paths []string
}

LinuxExternalEditor represents an external editor on Linux

Jump to

Keyboard shortcuts

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