engine/i18n with catalogs, plural forms and module catalogs; tools/i18n extract and check; the editor UI, menus, panels and notices in Russian with the author's terms; overflow test and tooltip wrapping; the English log.
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package shell
|
|
|
|
import (
|
|
"aego/editor/core/command"
|
|
pd "aego/editor/core/playdiff"
|
|
"aego/engine/i18n"
|
|
)
|
|
|
|
const CommandPlayDiffMode = "play.diff_mode"
|
|
|
|
func (a *App) beforeStop() {
|
|
m := a.ctx.Docs
|
|
play := m.PlayDoc()
|
|
if play == nil || a.diffMode == pd.ModeNever {
|
|
return
|
|
}
|
|
edit := m.Get(play.ID)
|
|
if edit == nil {
|
|
return
|
|
}
|
|
hist := pd.FromHistory(edit, play)
|
|
if hist.Empty() && len(hist.Created)+len(hist.Removed) == 0 {
|
|
return
|
|
}
|
|
a.diffPending, a.diffDoc, a.diffRes, a.diffFull = true, edit.ID, hist, pd.Full(edit, play, hist)
|
|
}
|
|
|
|
func (a *App) showPlayDiff() {
|
|
if !a.diffPending || a.ctx.Docs.InPlay() {
|
|
return
|
|
}
|
|
a.diffPending = false
|
|
a.playDiff.Open(a.ctx.UI, a.diffDoc, a.diffRes, a.diffFull)
|
|
a.diffRes, a.diffFull = pd.Result{}, pd.Result{}
|
|
}
|
|
|
|
func (a *App) registerPlayDiff() error {
|
|
for i, m := range []pd.Mode{pd.ModeIfChanges, pd.ModeAlways, pd.ModeNever} {
|
|
mode := m
|
|
names := [...]i18n.Text{
|
|
i18n.T("editor.playdiff.mode.if_changes", "Show Play Changes When Something Changed"),
|
|
i18n.T("editor.playdiff.mode.always", "Always Show Play Changes"),
|
|
i18n.T("editor.playdiff.mode.never", "Never Show Play Changes"),
|
|
}
|
|
name := names[i]
|
|
if err := a.ctx.Commands.Register(command.Desc{
|
|
ID: CommandPlayDiffMode + "." + mode.String(), Name: name.En, Label: name.String, Category: "Play", Order: 520 + i,
|
|
Checked: func() bool { return a.diffMode == mode },
|
|
Run: func() error { a.diffMode = mode; return nil },
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (a *App) PlayDiffOpen() bool {
|
|
return a.playDiff.Active() || a.diffPending
|
|
}
|