put-items: added a command to put a dirty item
This commit is contained in:
parent
174bab36c3
commit
16cb6bdc6b
5 changed files with 152 additions and 14 deletions
|
|
@ -14,6 +14,10 @@ import (
|
|||
var (
|
||||
markedRowStyle = lipgloss.NewStyle().
|
||||
Background(lipgloss.Color("#e1e1e1"))
|
||||
dirtyRowStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#e13131"))
|
||||
newRowStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#31e131"))
|
||||
)
|
||||
|
||||
type itemTableRow struct {
|
||||
|
|
@ -24,6 +28,8 @@ type itemTableRow struct {
|
|||
|
||||
func (mtr itemTableRow) Render(w io.Writer, model table.Model, index int) {
|
||||
isMarked := mtr.resultSet.Marked(mtr.itemIndex)
|
||||
isDirty := mtr.resultSet.IsDirty(mtr.itemIndex)
|
||||
isNew := mtr.resultSet.IsNew(mtr.itemIndex)
|
||||
|
||||
sb := strings.Builder{}
|
||||
for i, colName := range mtr.resultSet.Columns {
|
||||
|
|
@ -42,15 +48,20 @@ func (mtr itemTableRow) Render(w io.Writer, model table.Model, index int) {
|
|||
sb.WriteString("(other)")
|
||||
}
|
||||
}
|
||||
|
||||
var style lipgloss.Style
|
||||
|
||||
if index == model.Cursor() {
|
||||
style := model.Styles.SelectedRow
|
||||
if isMarked {
|
||||
style = style.Copy().Inherit(markedRowStyle)
|
||||
}
|
||||
fmt.Fprintln(w, style.Render(sb.String()))
|
||||
} else if isMarked {
|
||||
fmt.Fprintln(w, markedRowStyle.Render(sb.String()))
|
||||
} else {
|
||||
fmt.Fprintln(w, sb.String())
|
||||
style = model.Styles.SelectedRow
|
||||
}
|
||||
if isMarked {
|
||||
style = style.Copy().Inherit(markedRowStyle)
|
||||
}
|
||||
if isNew {
|
||||
style = style.Copy().Inherit(newRowStyle)
|
||||
} else if isDirty {
|
||||
style = style.Copy().Inherit(dirtyRowStyle)
|
||||
}
|
||||
|
||||
fmt.Fprintln(w, style.Render(sb.String()))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue