Fenrir can now create aliases for application overrides and put them in your clipboard.
This commit is contained in:
1 parent
7df1fa3ecb
commit
7d82105d1d
15 files changed
+594
-114
No files matched your search
@@ -16,6 +16,7 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/i18n"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/presentation"
|
||||
"git.stormux.org/storm/fenrir/internal/prompt"
|
||||
"git.stormux.org/storm/fenrir/internal/reader"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
@@ -119,12 +120,20 @@ func (a *application) install_override(saved overrideSnapshot, terminal int) {
|
||||
// A synthesizer selection can require asynchronous restoration. Until it
|
||||
// completes, no new context is installed and all settings mutations are gated.
|
||||
func (a *application) restore_override(done func()) bool {
|
||||
return a.restore_override_result(func(err error) {
|
||||
if err == nil {
|
||||
done()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (a *application) restore_override_result(done func(error)) bool {
|
||||
current := a.overrideCurrent
|
||||
if current == nil {
|
||||
current = a.overrideFailed
|
||||
}
|
||||
if current == nil {
|
||||
done()
|
||||
done(nil)
|
||||
return true
|
||||
}
|
||||
if a.speechPending || a.saver.busy || a.overrideTransition || a.overrideRestoreFailed {
|
||||
@@ -141,7 +150,7 @@ func (a *application) restore_override(done func()) bool {
|
||||
a.overrideCurrent = nil
|
||||
a.overrideFailed = nil
|
||||
current.adapter.Reset()
|
||||
done()
|
||||
done(nil)
|
||||
}
|
||||
if same_speech_selection(a.settings.live.Presentation.Speech, current.underlying.settings.live.Presentation.Speech) {
|
||||
restore()
|
||||
@@ -161,6 +170,7 @@ func (a *application) restore_override(done func()) bool {
|
||||
a.overrideCurrent, a.overrideFailed = nil, current
|
||||
current.adapter.Reset()
|
||||
a.voice.Say(i18n.Format("Could not restore application settings: {0}", err.Error()))
|
||||
done(err)
|
||||
return
|
||||
}
|
||||
restore()
|
||||
@@ -177,8 +187,21 @@ func (a *application) select_override(id string) {
|
||||
if terminal == 0 || !a.lastActive {
|
||||
return
|
||||
}
|
||||
a.select_override_result(id, func(string) {})
|
||||
}
|
||||
|
||||
// Completion means selected, not recognized or profile-loaded: launchers must
|
||||
// be able to select an override before starting the application. Callers check
|
||||
// the ID and busy/terminal gates before entering this path.
|
||||
func (a *application) select_override_result(id string, done func(string)) {
|
||||
terminal := a.lastTerminal
|
||||
a.overrideRestoreFailed = false // An explicit selection retries restoration.
|
||||
a.restore_override(func() {
|
||||
a.restore_override_result(func(err error) {
|
||||
if err != nil {
|
||||
done("Could not restore application settings: " + err.Error())
|
||||
return
|
||||
}
|
||||
a.ui.close()
|
||||
a.overrideDirty = true
|
||||
if old := a.overrides[terminal]; old != nil {
|
||||
old.adapter.Close()
|
||||
@@ -186,6 +209,7 @@ func (a *application) select_override(id string) {
|
||||
}
|
||||
if id == "default" {
|
||||
a.voice.Say(i18n.T("Default settings restored"))
|
||||
done("")
|
||||
return
|
||||
}
|
||||
var adapter applicationoverrides.Adapter
|
||||
@@ -211,6 +235,7 @@ func (a *application) select_override(id string) {
|
||||
selected.shell.Observe(a.lastSnapshot)
|
||||
a.overrides[terminal] = selected
|
||||
a.voice.Say(i18n.Format("{0} application override selected", i18n.T(adapter.Name())))
|
||||
done("")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -329,6 +354,7 @@ func (a *application) open_applications() {
|
||||
}
|
||||
session, err := interaction.New_session(interaction.Form{Type: interaction.TabForm, Title: "Applications", Tabs: []interaction.Tab{{ID: "applications", Label: "Applications", Controls: []interaction.Control{
|
||||
{ID: "application", Label: "Application", Kind: interaction.List, Items: items, Selected: position, Action: "activate"},
|
||||
{ID: "copy_alias", Label: "Copy alias to clipboard", Kind: interaction.Button, Action: "copy_alias"},
|
||||
{ID: "cancel", Label: "Cancel", Kind: interaction.Button, Action: "cancel"},
|
||||
}}}})
|
||||
if err != nil {
|
||||
@@ -351,6 +377,17 @@ func (a *application) open_applications() {
|
||||
a.ui.close()
|
||||
a.select_override(ids[selected])
|
||||
}
|
||||
if action == "copy_alias" {
|
||||
selected := session.Values()["applications.application"].Selected
|
||||
text := application_alias(ids[selected], a.settings.live.Remote.SocketFile)
|
||||
if text == "" {
|
||||
a.voice.Say(i18n.T("Default has no application alias"))
|
||||
return
|
||||
}
|
||||
if a.clipboards.add(text, true) {
|
||||
a.present(i18n.T("Application alias copied to clipboard"), presentation.CopyToClipboard)
|
||||
}
|
||||
}
|
||||
}
|
||||
a.voice.Say(session.Open())
|
||||
}
|
||||
Reference in new issue
Block a user