menu

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

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

Go to latest
Published: Jul 12, 2022 License: GPL-3.0 Imports: 23 Imported by: 6

README

menu

Well, this got a little bit out of control.

A cross-platform user menu, that turned into a popup launcher and more.

There are currently three programs available: a system tray menu, a popup menu, and a popup launcher.

Features

UMH has picked up a lot of different abilities. It can scan your network for other machines and services, publish services of its own, launch applications, open files to edit, open urls and run shell commands.

Tray menu

The tray menu sits in the system tray(Windows) or the menu bar (Mac). It displays the user-defined menu, as well as several auto-generated menus, like the Applications menu, and the network services menu.

Popup Menu

Similar to the tray menu, but the menu appears in the center of the screen.

Popup launcher

The popup launcher works similar to the built-in search on macosx. Press a button (F12), and the launcher will appear. Type your search, then use the up and down arrows to select your choice.

The options that appear in the popup launcher are not all automatically generated, they come from a file (~/.menu.recall.text). You can always find this file by searching for "Edit Recall Menu", then selecting that option from the list.

The different ways to launch a file or program are described below.

Use

Run tray_menu.exe. This starts the tray menu, and from there you can start the popup launcher from the user menu.

For command line scripting, there is a command line program that does the same as the hotkey: universal_menu_command_line_toggle.exe. This works with AppleScript and other scripting platforms. I use it with the program "My TouchBar, My Rules" to add a touchbar button that will open and close the launcher.

There is also a program called universal_menu_hotkey_monitor this program watches for the hotkey, then runs a program that you give it as the first argument on the command line.

Build

Use the provided build scripts, build.bat and build.sh

Command format

UMH uses urls where ever possible, and adds its own extensions. These URLs can be used in the UMH system menu, and in the ~/.menu.recall.text file.

  • http://,https:// - Will open a web browser to this url
  • shell:// - will run a shell command exactly as written. The shell will be cmd.exe or bash.
  • exec:// - attempt to run this program. You can add simple arguments after the program name, as if you were in the shell (but in a really dumb shell)
  • file:// - Open the file for display or editing using the default program
  • internal:// - There are several internal commands provided, e.g. RunAtStartup
  • clipboard:// - Copy the rest of this text to the clipboard(minus the clipboard:// part). You probably shouldn't put your passwords here, but I do anyway

You can also substitute in a few variables using the Go template syntax e.g. {{.AppDir}} will be replaced with the program directory.

AppDir      The directory containing the UMH program file
ConfigDir   The config and data directory, usually "~/.umh"
Cwd         The current operations directory, as stored in "~/.umh/cwd"
Command     The command that is currently being run

~/.menu.recall.text

The recall file holds your custom commands. You can always find this file to edit by typing "Edit Recall Menu" into the Launcher, and then selecting the option that appears.

The file format looks like this

Some text that you can search for | url://something that should happen

e.g.

Documentation

Overview

nodes.go

Index

Constants

This section is empty.

Variables

View Source
var RecallCache [][]string

Functions

func Activate

func Activate(value string) bool

func ActiveBufferAppend

func ActiveBufferAppend(gc *GlobalConfig, txt string)

func AddActiveBuffer

func AddActiveBuffer(gc *GlobalConfig, text string, fileName string)

Create a new buffer, make it active and set its contents. file name is required for a unique key to index it If a buffer called fileName already exists, its data will be replaced with the new data

func AppendNode

func AppendNode(menu, item *Node)

func Apps

func Apps() [][]string

Get a list of all (major gui) apps installed on the system

func BuffAppend

func BuffAppend(gc *GlobalConfig, buffId int, txt string)

func DeleteLeft

func DeleteLeft(t string, p int) string

func Dispatch

func Dispatch(command string, gc *GlobalConfig)

This function carries out commands. It is the interface between your scripting, and the actual engine operation

func DoPageDown

func DoPageDown(gc *GlobalConfig, buf *Buffer)

func DumpBuffer

func DumpBuffer(gc *GlobalConfig, b *Buffer)

func ExciseSelection

func ExciseSelection(buf *Buffer)

func GetSummaries

func GetSummaries(maxItems int, username, password []byte) [][]string

username := goof.CatFile("username") password := goof.CatFile("password")

func IncreaseFont

func IncreaseFont(buf *Buffer)

func Is_space

func Is_space(l string) bool

func LoadFileIfNotLoaded

func LoadFileIfNotLoaded(gc *GlobalConfig, fileName string)

func Log2Buff

func Log2Buff(gc *GlobalConfig, s string)

func NextBuffer

func NextBuffer(gc *GlobalConfig)

func NodesToStringArray

func NodesToStringArray(ns []*Node) []string

func PageDown

func PageDown(buf *Buffer)

func PageUp

func PageUp(buf *Buffer, w, h int)

func PasteFromClipBoard

func PasteFromClipBoard(gc *GlobalConfig, buf *Buffer)

func Predict

func Predict(newString []byte) ([]string, []string)

func PreviousBuffer

func PreviousBuffer(gc *GlobalConfig)

func PreviousCharacter

func PreviousCharacter(buf *Buffer)

func ProcessPort

func ProcessPort(gc *GlobalConfig, r io.Reader)

func Recall

func Recall() [][]string

func RecallFilePath

func RecallFilePath() string

func ReduceFont

func ReduceFont(buf *Buffer)

func SOL

func SOL(txt string, c int) int

func SOT

func SOT(txt string, c int) int

func SSHAgent

func SSHAgent() ssh.AuthMethod

func SaveFile

func SaveFile(gc *GlobalConfig, fname string, txt string)

func ScanToEndOfLine

func ScanToEndOfLine(txt string, c int) int

func ScanToNextLine

func ScanToNextLine(txt string, c int) int

func ScanToNextPara

func ScanToNextPara(txt string, c int) int

func ScanToPrevLine

func ScanToPrevLine(txt string, c int) int

func ScanToPrevPara

func ScanToPrevPara(txt string, c int) int

func ScrollToCursor

func ScrollToCursor(buf *Buffer)

func SearchBackPage

func SearchBackPage(txtBuf string, orig_f *glim.FormatParams, screenWidth, screenHeight int) int

Does a page up, by searching backwards util the old top line is off the bottom of the screen

func SetFont

func SetFont(buf *Buffer, size float64)

func ToggleVerticalMode

func ToggleVerticalMode(gc *GlobalConfig)

Types

type Buffer

type Buffer struct {
	Data      *BufferData
	InputMode bool
	Formatter *glim.FormatParams
}

func FindByFileName

func FindByFileName(gc *GlobalConfig, fileName string) (int, *Buffer)

func NewBuffer

func NewBuffer() *Buffer

type BufferData

type BufferData struct {
	Text     string //FIXME rename Buffer to View, have proper text buffer manager
	FileName string
}

type GlobalConfig

type GlobalConfig struct {
	ActiveBuffer   *Buffer
	ActiveBufferId int
	BufferList     []*Buffer
	LogBuffer      *Buffer
	StatusBuffer   *Buffer
	CommandBuffer  *Buffer
}

func NewEditor

func NewEditor() *GlobalConfig

type Node

type Node struct {
	Name     string
	SubNodes []*Node
	Command  string
	Data     string
	Function func() `json:"-"`
}

func AddTextNodesFromCommands

func AddTextNodesFromCommands(startNode *Node, lines []string) *Node

func AddTextNodesFromStrStr

func AddTextNodesFromStrStr(startNode *Node, lines [][]string) *Node

func AddTextNodesFromStrStrStr

func AddTextNodesFromStrStrStr(startNode *Node, lines [][]string) *Node

func AddTextNodesFromString

func AddTextNodesFromString(startNode *Node, src string) *Node

func AddTextNodesFromStringList

func AddTextNodesFromStringList(startNode *Node, lines []string) *Node

func AppsMenu

func AppsMenu() *Node

func ControlMenu

func ControlMenu() *Node

func Dir2Menu

func Dir2Menu(parent *Node) *Node

func FindNode

func FindNode(n *Node, name string) *Node

func HistoryMenu

func HistoryMenu() *Node

func MakeNodeLong

func MakeNodeLong(name string, subNodes []*Node, command, data string) *Node

func MakeNodeShort

func MakeNodeShort(name string, subNodes []*Node) *Node

func MakeStartNode

func MakeStartNode() *Node

func TieredAppsMenu

func TieredAppsMenu() *Node

func (*Node) String

func (n *Node) String() string

func (*Node) ToString

func (n *Node) ToString() string

Directories

Path Synopsis
gui.go
gui.go
gui.go
gui.go
main
main
gui.go
gui.go
gui.go
gui.go
gui.go
gui.go
old
nodes.go
nodes.go
gui.go
gui.go
gui.go
gui.go
gui.go
gui.go
ui.go
ui.go

Jump to

Keyboard shortcuts

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