fix(tui): resolve staticcheck lint errors in history view
- Replace deprecated LineUp/LineDown/HalfViewUp/HalfViewDown with ScrollUp/ScrollDown/HalfPageUp/HalfPageDown - Use tagged switch for mouse button dispatch - Use fmt.Fprintf instead of WriteString(Sprintf)
This commit is contained in:
@@ -138,9 +138,10 @@ func (m *Model) handleTick(t time.Time) (tea.Model, tea.Cmd) {
|
|||||||
|
|
||||||
func (m *Model) handleMouse(msg tea.MouseMsg) (tea.Model, tea.Cmd) {
|
func (m *Model) handleMouse(msg tea.MouseMsg) (tea.Model, tea.Cmd) {
|
||||||
if m.state == stateHistory {
|
if m.state == stateHistory {
|
||||||
if msg.Button == tea.MouseButtonWheelUp {
|
switch msg.Button {
|
||||||
|
case tea.MouseButtonWheelUp:
|
||||||
m.historyViewport.ScrollUp(3)
|
m.historyViewport.ScrollUp(3)
|
||||||
} else if msg.Button == tea.MouseButtonWheelDown {
|
case tea.MouseButtonWheelDown:
|
||||||
m.historyViewport.ScrollDown(3)
|
m.historyViewport.ScrollDown(3)
|
||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
@@ -266,13 +267,13 @@ func (m *Model) handleHistoryKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
case "q", "esc":
|
case "q", "esc":
|
||||||
m.state = stateDetail
|
m.state = stateDetail
|
||||||
case "up", "k":
|
case "up", "k":
|
||||||
m.historyViewport.LineUp(1)
|
m.historyViewport.ScrollUp(1)
|
||||||
case "down", "j":
|
case "down", "j":
|
||||||
m.historyViewport.LineDown(1)
|
m.historyViewport.ScrollDown(1)
|
||||||
case "pgup":
|
case "pgup":
|
||||||
m.historyViewport.HalfViewUp()
|
m.historyViewport.HalfPageUp()
|
||||||
case "pgdown":
|
case "pgdown":
|
||||||
m.historyViewport.HalfViewDown()
|
m.historyViewport.HalfPageDown()
|
||||||
case "home", "g":
|
case "home", "g":
|
||||||
m.historyViewport.GotoTop()
|
m.historyViewport.GotoTop()
|
||||||
case "end", "G":
|
case "end", "G":
|
||||||
|
|||||||
@@ -160,11 +160,11 @@ func (m Model) viewHistoryPanel() string {
|
|||||||
b.WriteString(" " + subtleStyle.Render(strings.Repeat("─", divWidth)) + "\n")
|
b.WriteString(" " + subtleStyle.Render(strings.Repeat("─", divWidth)) + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
b.WriteString(fmt.Sprintf(" %-18s %-17s %-12s %s\n",
|
fmt.Fprintf(&b, " %-18s %-17s %-12s %s\n",
|
||||||
subtleStyle.Render("TIME"),
|
subtleStyle.Render("TIME"),
|
||||||
subtleStyle.Render("TRANSITION"),
|
subtleStyle.Render("TRANSITION"),
|
||||||
subtleStyle.Render("DURATION"),
|
subtleStyle.Render("DURATION"),
|
||||||
subtleStyle.Render("REASON")))
|
subtleStyle.Render("REASON"))
|
||||||
|
|
||||||
if len(m.historyChanges) == 0 {
|
if len(m.historyChanges) == 0 {
|
||||||
b.WriteString("\n " + subtleStyle.Render("No state changes recorded") + "\n")
|
b.WriteString("\n " + subtleStyle.Render("No state changes recorded") + "\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user