mirror of
https://github.com/shokinn/hosts-go.git
synced 2025-08-23 16:43:02 +00:00
feat: add view mode status bar
This commit is contained in:
parent
49bf61f8e5
commit
9748c2dde8
5 changed files with 45 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hosts-go/internal/core"
|
||||
|
||||
list "github.com/charmbracelet/bubbles/list"
|
||||
|
@ -10,16 +11,31 @@ import (
|
|||
// entryItem wraps a HostEntry for display in a list component.
|
||||
type entryItem struct{ entry *core.HostEntry }
|
||||
|
||||
func (e entryItem) Title() string { return e.entry.Hostname }
|
||||
func (e entryItem) Title() string {
|
||||
prefix := "[ ]"
|
||||
if e.entry.Active {
|
||||
prefix = "[✓]"
|
||||
}
|
||||
return fmt.Sprintf("%s %s", prefix, e.entry.Hostname)
|
||||
}
|
||||
|
||||
func (e entryItem) Description() string { return e.entry.IP }
|
||||
func (e entryItem) FilterValue() string { return e.entry.Hostname }
|
||||
|
||||
// Model is the main Bubble Tea model for the application.
|
||||
type Mode int
|
||||
|
||||
const (
|
||||
ViewMode Mode = iota
|
||||
EditMode
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
list list.Model
|
||||
hosts *core.HostsFile
|
||||
width int
|
||||
height int
|
||||
mode Mode
|
||||
}
|
||||
|
||||
// NewModel constructs the TUI model from a parsed HostsFile.
|
||||
|
@ -38,6 +54,7 @@ func NewModel(hf *core.HostsFile) Model {
|
|||
return Model{
|
||||
list: l,
|
||||
hosts: hf,
|
||||
mode: ViewMode,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue