mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 09:42:34 +02:00
Add flags to history
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -159,7 +159,7 @@ func (m historyKeyMap) FullHelp() [][]key.Binding {
|
||||
h := keys.Keys.History
|
||||
g := keys.Keys.Global
|
||||
pageGlobals := []key.Binding{g.Up, g.Down, g.CycleFocus, g.ScrollUp, g.ScrollDown, g.Left, g.Right, g.Escape, g.SendToReplay, g.SendToDiff, g.Copy, g.CopyAs}
|
||||
all := []key.Binding{h.DeleteEntry, h.DeleteAll, h.Filter, h.SqlQuery}
|
||||
all := []key.Binding{h.Flag, h.DeleteEntry, h.DeleteAll, h.Filter, h.SqlQuery}
|
||||
all = append(all, pageGlobals...)
|
||||
all = append(all, g.CommonBindings()...)
|
||||
return keys.ChunkByWidth(all, m.width)
|
||||
|
||||
@@ -230,6 +230,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
case key.Matches(msg, h.Flag):
|
||||
if len(m.entries) > 0 && m.database != nil {
|
||||
m.database.ToggleFlag(m.entries[m.cursor].ID)
|
||||
return m, m.RefreshCmd()
|
||||
}
|
||||
|
||||
case key.Matches(msg, h.DeleteEntry):
|
||||
if len(m.entries) > 0 {
|
||||
id := m.entries[m.cursor].ID
|
||||
|
||||
@@ -113,7 +113,7 @@ func (m *Model) renderList() string {
|
||||
w := m.listViewport.Width()
|
||||
|
||||
statusStr := fmt.Sprintf("%3d", e.StatusCode)
|
||||
const fixedW = 2 + 7 + 1 + 3 + 1 + 10 + 1
|
||||
const fixedW = 2 + 2 + 7 + 1 + 3 + 1 + 10 + 1
|
||||
hostPathW := w - fixedW
|
||||
if hostPathW < 0 {
|
||||
hostPathW = 0
|
||||
@@ -121,12 +121,21 @@ func (m *Model) renderList() string {
|
||||
|
||||
ts := e.Timestamp.Format("15:04:05")
|
||||
statusSt := style.StatusStyle(e.StatusCode, 3)
|
||||
flagSt := lipgloss.NewStyle().Foreground(s.Primary)
|
||||
|
||||
var line string
|
||||
if selected {
|
||||
bg := lipgloss.NewStyle().Background(selBg)
|
||||
flagStr := " "
|
||||
if e.Flagged {
|
||||
flagStr = icons.I.Flag + " "
|
||||
if icons.I.Flag == "" {
|
||||
flagStr = "★ "
|
||||
}
|
||||
}
|
||||
line = lipgloss.JoinHorizontal(lipgloss.Top,
|
||||
bg.Bold(true).Foreground(s.Primary).Width(2).Render(">"),
|
||||
bg.Foreground(s.Primary).Width(2).Render(flagStr),
|
||||
s.Method(e.Method).Background(selBg).Render(e.Method),
|
||||
bg.Width(1).Render(""),
|
||||
statusSt.Background(selBg).Render(statusStr),
|
||||
@@ -136,8 +145,16 @@ func (m *Model) renderList() string {
|
||||
bg.Bold(true).Width(hostPathW).Render(e.Host+e.Path),
|
||||
)
|
||||
} else {
|
||||
flagStr := " "
|
||||
if e.Flagged {
|
||||
flagStr = icons.I.Flag + " "
|
||||
if icons.I.Flag == "" {
|
||||
flagStr = "★ "
|
||||
}
|
||||
}
|
||||
line = lipgloss.JoinHorizontal(lipgloss.Top,
|
||||
" ",
|
||||
flagSt.Width(2).Render(flagStr),
|
||||
s.Method(e.Method).Render(e.Method),
|
||||
" ",
|
||||
statusSt.Render(statusStr),
|
||||
|
||||
Reference in New Issue
Block a user