mirror of
https://github.com/shokinn/hosts-go.git
synced 2025-08-23 16:43:02 +00:00
feat: save hosts file
This commit is contained in:
parent
e59af1cb02
commit
e813704f81
6 changed files with 60 additions and 23 deletions
|
@ -40,17 +40,18 @@ const (
|
|||
)
|
||||
|
||||
type Model struct {
|
||||
list list.Model
|
||||
detail viewport.Model
|
||||
hosts *core.HostsFile
|
||||
width int
|
||||
height int
|
||||
mode Mode
|
||||
focus pane
|
||||
list list.Model
|
||||
detail viewport.Model
|
||||
hosts *core.HostsFile
|
||||
hostsPath string
|
||||
width int
|
||||
height int
|
||||
mode Mode
|
||||
focus pane
|
||||
}
|
||||
|
||||
// NewModel constructs the TUI model from a parsed HostsFile.
|
||||
func NewModel(hf *core.HostsFile) Model {
|
||||
// NewModel constructs the TUI model from a parsed HostsFile and its path.
|
||||
func NewModel(hf *core.HostsFile, path string) Model {
|
||||
items := make([]list.Item, len(hf.Entries))
|
||||
for i, e := range hf.Entries {
|
||||
items[i] = entryItem{entry: e}
|
||||
|
@ -63,11 +64,12 @@ func NewModel(hf *core.HostsFile) Model {
|
|||
l.SetShowPagination(false)
|
||||
|
||||
m := Model{
|
||||
list: l,
|
||||
detail: viewport.New(0, 0),
|
||||
hosts: hf,
|
||||
mode: ViewMode,
|
||||
focus: listPane,
|
||||
list: l,
|
||||
detail: viewport.New(0, 0),
|
||||
hosts: hf,
|
||||
hostsPath: path,
|
||||
mode: ViewMode,
|
||||
focus: listPane,
|
||||
}
|
||||
m.refreshDetail()
|
||||
return m
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue