fix: hiddenInput & remove viewportState
This commit is contained in:
7
input.go
7
input.go
@ -123,7 +123,7 @@ func handleCommand(cmd, hiddenInput string) tea.Msg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func hidePasswordInput(m *model) {
|
func hidePasswordInput(m *model) {
|
||||||
val := m.input.Value()
|
val := strings.TrimSpace(m.input.Value())
|
||||||
|
|
||||||
if len(val) == 0 {
|
if len(val) == 0 {
|
||||||
return
|
return
|
||||||
@ -138,10 +138,11 @@ func hidePasswordInput(m *model) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmds[1] == "create" && len(cmds) > 3 || cmds[1] == "unlock" && len(cmds) > 2 {
|
if cmds[1] == "create" && len(cmds) > 3 ||
|
||||||
|
cmds[1] == "unlock" && len(cmds) > 2 {
|
||||||
lastChar := string(val[len(val)-1])
|
lastChar := string(val[len(val)-1])
|
||||||
m.hiddenInput += lastChar
|
|
||||||
if lastChar != " " {
|
if lastChar != " " {
|
||||||
|
m.hiddenInput += lastChar
|
||||||
newCmd := []rune(val)
|
newCmd := []rune(val)
|
||||||
newCmd[len(val)-1] = '*'
|
newCmd[len(val)-1] = '*'
|
||||||
m.input.SetValue(string(newCmd))
|
m.input.SetValue(string(newCmd))
|
||||||
|
40
model.go
40
model.go
@ -67,7 +67,6 @@ type model struct {
|
|||||||
statusViewport viewport.Model
|
statusViewport viewport.Model
|
||||||
statusViewportLines []string
|
statusViewportLines []string
|
||||||
statusViewportReady bool
|
statusViewportReady bool
|
||||||
viewportState int
|
|
||||||
|
|
||||||
profiles profiles
|
profiles profiles
|
||||||
profileState int
|
profileState int
|
||||||
@ -139,6 +138,24 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
cmds []tea.Cmd
|
cmds []tea.Cmd
|
||||||
)
|
)
|
||||||
|
|
||||||
|
m.input, cmd = m.input.Update(msg)
|
||||||
|
cmds = append(cmds, cmd)
|
||||||
|
|
||||||
|
m.statusViewport, cmd = m.statusViewport.Update(msg)
|
||||||
|
cmds = append(cmds, cmd)
|
||||||
|
|
||||||
|
for _, p := range m.profiles {
|
||||||
|
p.statusViewport, cmd = p.statusViewport.Update(msg)
|
||||||
|
cmds = append(cmds, cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.showWelcomeMessage {
|
||||||
|
cmds = append(cmds, m.sendStatusCmd(
|
||||||
|
strings.Split(welcomeMessage, "\n")...,
|
||||||
|
))
|
||||||
|
m.showWelcomeMessage = false
|
||||||
|
}
|
||||||
|
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case tea.WindowSizeMsg:
|
case tea.WindowSizeMsg:
|
||||||
m.width = msg.Width
|
m.width = msg.Width
|
||||||
@ -321,24 +338,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
cmds = append(cmds, m.sendStatusCmd(msg.Error()))
|
cmds = append(cmds, m.sendStatusCmd(msg.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
m.input, cmd = m.input.Update(msg)
|
|
||||||
cmds = append(cmds, cmd)
|
|
||||||
|
|
||||||
m.statusViewport, cmd = m.statusViewport.Update(msg)
|
|
||||||
cmds = append(cmds, cmd)
|
|
||||||
|
|
||||||
for _, p := range m.profiles {
|
|
||||||
p.statusViewport, cmd = p.statusViewport.Update(msg)
|
|
||||||
cmds = append(cmds, cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.showWelcomeMessage {
|
|
||||||
cmds = append(cmds, m.sendStatusCmd(
|
|
||||||
strings.Split(welcomeMessage, "\n")...,
|
|
||||||
))
|
|
||||||
m.showWelcomeMessage = false
|
|
||||||
}
|
|
||||||
|
|
||||||
return m, tea.Batch(cmds...)
|
return m, tea.Batch(cmds...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,15 +357,12 @@ func (m model) View() string {
|
|||||||
switch m.menuState {
|
switch m.menuState {
|
||||||
case 0:
|
case 0:
|
||||||
chosenViewport = m.statusViewport
|
chosenViewport = m.statusViewport
|
||||||
m.viewportState = 0
|
|
||||||
default:
|
default:
|
||||||
if m.menuState > len(m.profiles) {
|
if m.menuState > len(m.profiles) {
|
||||||
chosenViewport = m.statusViewport
|
chosenViewport = m.statusViewport
|
||||||
m.viewportState = 0
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
chosenViewport = m.profiles[m.menuState-1].statusViewport
|
chosenViewport = m.profiles[m.menuState-1].statusViewport
|
||||||
m.viewportState = m.menuState - 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var renderedCmdHelp []string
|
var renderedCmdHelp []string
|
||||||
|
Reference in New Issue
Block a user