Documentation
¶
Overview ¶
Package system holds the few OS integrations the window needs that are not tied to any domain service — opening a URL in the user's default browser, opening a work-tree file in their editor, raising a desktop notification, and the handful of facts a bug report needs (version, platform, where the log lives).
Index ¶
- func ValidateExternalURL(rawURL string) error
- type AttachNativeOptions
- type Diagnostics
- type NativeHooks
- type QuitOptions
- type Service
- func (s *Service) AttachNative(_ context.Context, opts AttachNativeOptions) (api.None, error)
- func (s *Service) Diagnostics(_ context.Context, _ api.None) (Diagnostics, error)
- func (s *Service) Notify(_ context.Context, opts api.NotifyOptions) (api.None, error)
- func (s *Service) OpenExternal(_ context.Context, opts api.OpenExternalOptions) (api.None, error)
- func (s *Service) OpenFile(_ context.Context, opts api.OpenFileOptions) (api.None, error)
- func (s *Service) OpenFolder(_ context.Context, opts api.OpenFolderOptions) (api.None, error)
- func (s *Service) OpenFolderInEditor(_ context.Context, opts api.OpenFolderOptions) (string, error)
- func (s *Service) Quit(_ context.Context, opts QuitOptions) (api.None, error)
- func (s *Service) RevealLog(_ context.Context, _ api.None) (api.None, error)
- func (s *Service) SSHAgentKeys(_ context.Context, _ api.None) ([]string, error)
- func (s *Service) SandboxBackend(_ context.Context, _ api.None) (string, error)
- func (s *Service) SetEnv(env []string)
- func (s *Service) SetNativeWindow(hooks NativeHooks)
- func (s *Service) SetQuit(quit func() error)
- func (s *Service) ShowWindow(_ context.Context, opts ShowWindowOptions) (api.None, error)
- func (s *Service) TakeUncleanExit(_ context.Context, _ api.None) (bool, error)
- type ShowWindowOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateExternalURL ¶
ValidateExternalURL accepts absolute http/https URLs only.
Types ¶
type AttachNativeOptions ¶
type AttachNativeOptions = api.AttachNativeOptions
type Diagnostics ¶
type Diagnostics = api.Diagnostics
type NativeHooks ¶
type NativeHooks struct {
// Raise brings an open native window forward, false when none is connected.
Raise func() bool
// Launch starts the native window on this backend; exited hears how the
// process ended once it does.
Launch func(executable string, exited func(state string)) error
// Locate is the native window's binary, shipped beside lich's.
Locate func() (string, error)
// Failed hears why a native window could not open.
Failed func(reason string)
}
NativeHooks are how lich drives its window, the native one (`lich native`), wired by main.
type QuitOptions ¶
type QuitOptions = api.QuitOptions
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AttachNative ¶
AttachNative answers attachNative over RPC.
func (*Service) Diagnostics ¶
Diagnostics answers diagnostics over RPC.
func (*Service) Notify ¶
Notify raises a desktop notification through the OS's own notification service — the one channel that still reaches the user after they leave the lich window. summary is the headline, detail the second line (empty omits it).
Delivery only: the window decides when a notification is warranted, because it is the side that knows whether the window has focus and which session the user is looking at.
func (*Service) OpenExternal ¶
OpenExternal opens an http(s) URL in the default browser. Scheme-gated so a crafted terminal escape can never turn a click into a file:// or custom scheme launch. The launcher itself is per-OS (see the open_* files).
func (*Service) OpenFile ¶
OpenFile hands one work-tree file to the application the desktop opens its type with: an image viewer, a PDF reader. Unlike OpenFolderInEditor it never consults $VISUAL/$EDITOR, which would open a PNG in vim. opts.Rel goes through relpath.Resolve, as project.ReadFile does, so a symlink out of the checkout is refused rather than opened. The launcher is openFolder's: xdg-open, open and explorer each hand any path, file or folder, to its default handler.
func (*Service) OpenFolder ¶
OpenFolder shows a checkout in the platform's file manager. It never consults $VISUAL/$EDITOR: this is the way out of lich to the OS's own view of the folder, which is the one thing opening it in an editor does not give.
func (*Service) OpenFolderInEditor ¶
OpenFolderInEditor opens a session's checkout in the user's editor. It prefers $VISUAL, then $EDITOR, resolved from the login shell, so a GUI launch still sees rc exports. A terminal editor (vim, nvim, nano, …) is launched nothing: the shell command line to run in a lich terminal session comes back instead, since a detached launch would give it no controlling terminal. A GUI editor, or the file manager when none is set, is launched detached, and "" comes back.
func (*Service) Quit ¶
Quit ends lich: the window closes, every session's process ends with it, and the process exits. It returns once the exit is under way, so the reply can be lost to the exit it announces.
func (*Service) RevealLog ¶
RevealLog opens the log's directory with the platform's file manager, not the file itself: the rotated generation (*.old) is often the one holding the bug, and a log file handed to its default handler opens in an editor, not beside the sibling the reporter also needs.
func (*Service) SSHAgentKeys ¶
SSHAgentKeys answers sSHAgentKeys over RPC.
func (*Service) SandboxBackend ¶
SandboxBackend answers sandboxBackend over RPC.
func (*Service) SetEnv ¶
SetEnv replaces the resolved environment after a re-read of the login shell (internal/providers.Service.RefreshPath): an $EDITOR exported by an rc file the user edited while lich was open is found from the same re-check that finds a newly installed agent, rather than from the next launch.
func (*Service) SetNativeWindow ¶
func (s *Service) SetNativeWindow(hooks NativeHooks)
SetNativeWindow wires the native window. Called at startup.
func (*Service) ShowWindow ¶
ShowWindow starts the native window on the running backend, or brings it forward when it is open. It returns as soon as the window is asked for, not when it is on screen; a window that cannot open is reported to NativeHooks.Failed, not here.
type ShowWindowOptions ¶
type ShowWindowOptions = api.ShowWindowOptions