Skip to content

Commit

Permalink
feat: marginally better table styles
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Feb 2, 2024
1 parent 383d3f4 commit 0c9f034
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion pkg/cy/cy-boot.janet
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ For example:
(def sequence (as?-> binds x
(find |(= func ($ :function)) x)
(get x :sequence)
(string/join x " ")))
(string/join x " ")
(string " " x " ")))
(tuple [desc (string sequence)] func))
_)
(input/find _ :prompt "search: actions")
Expand Down
6 changes: 6 additions & 0 deletions pkg/cy/stories.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,10 @@ func init() {
stories.Wait(stories.ALot),
},
})

stories.Register("cy/palette-static", func(ctx context.Context) (mux.Screen, error) {
_, client, screen, err := createStory(ctx)
go client.execute(`(action/command-palette)`)
return screen, err
}, stories.Config{})
}
20 changes: 10 additions & 10 deletions pkg/fuzzy/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ func (f *Fuzzy) renderPreview(state *tty.State) {
}

func (f *Fuzzy) renderOptions(common, prompt lipgloss.Style, maxOptions int) string {
rowStyle := common.Copy().
MaxHeight(1)
rowStyle := f.render.NewStyle()
inactive := rowStyle.Copy().
Background(lipgloss.Color("#968C83")).
Foreground(lipgloss.Color("#20111B"))
Expand Down Expand Up @@ -169,7 +168,7 @@ func (f *Fuzzy) renderOptions(common, prompt lipgloss.Style, maxOptions int) str
rows = append(rows, columns)
}

table := strings.Split(table.New().
table := table.New().
Border(lipgloss.Border{}).
StyleFunc(func(row, col int) lipgloss.Style {
switch {
Expand All @@ -182,11 +181,12 @@ func (f *Fuzzy) renderOptions(common, prompt lipgloss.Style, maxOptions int) str
}
}).
Headers(headers...).
Width(common.GetWidth()+4).
Rows(rows...).
String(), "\n")
Width(common.GetWidth() + 3).
Rows(rows...)

if len(table) < 4 {
rendered := strings.Split(table.String(), "\n")

if len(rendered) < 4 {
return ""
}

Expand All @@ -195,13 +195,13 @@ func (f *Fuzzy) renderOptions(common, prompt lipgloss.Style, maxOptions int) str
if haveHeaders {
output = append(
output,
table[1],
rendered[1],
)
}

// Invert the lines of the table when `isUp`
lines := make([]string, 0)
for _, line := range table[3 : len(table)-1] {
for _, line := range rendered[3 : len(rendered)-1] {
if f.isUp {
lines = append([]string{line}, lines...)
} else {
Expand Down Expand Up @@ -299,7 +299,7 @@ func (f *Fuzzy) View(state *tty.State) {
Position: f.location,
Size: geom.Vec2{
R: screenSize.R - f.location.R,
C: 40,
C: 50,
},
}

Expand Down

0 comments on commit 0c9f034

Please sign in to comment.