36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
// Copyright (c) 2026 Storm Dragon
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package networkmanager
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"git.stormux.org/storm/fenrir/internal/applicationoverrides"
|
|
"git.stormux.org/storm/fenrir/internal/command"
|
|
"git.stormux.org/storm/fenrir/internal/config"
|
|
"git.stormux.org/storm/fenrir/internal/presentation"
|
|
"git.stormux.org/storm/fenrir/internal/screen"
|
|
)
|
|
|
|
type Adapter struct{}
|
|
|
|
func (*Adapter) Name() string { return "NetworkManager" }
|
|
func (*Adapter) Configure(settings *config.Settings) { settings.Reading.Mode = "highlight" }
|
|
func (*Adapter) Reset() {}
|
|
func (*Adapter) Close() {}
|
|
func (*Adapter) Command(command.ID) (presentation.CommandResult, bool) {
|
|
return presentation.CommandResult{}, false
|
|
}
|
|
|
|
func (*Adapter) Observe(snapshot screen.Snapshot) applicationoverrides.Frame {
|
|
// nmtui's newt dialogs retain a border and their standard title/action text.
|
|
text := string(snapshot.Cells)
|
|
border := strings.ContainsAny(text, "┌┐└┘╔╗╚╝") || strings.Contains(text, "+---")
|
|
title := false
|
|
for _, label := range []string{"NetworkManager", "Edit Connection", "Activate a connection", "Set Hostname", "Select a connection", "Edit a connection"} {
|
|
title = title || strings.Contains(text, label)
|
|
}
|
|
return applicationoverrides.Frame{Recognized: border && title}
|
|
}
|