Skip to content

Commit

Permalink
Merge branch 'release/0.7-alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Farstad committed Oct 4, 2021
2 parents 1c1dcb4 + 34d312c commit 1d26f24
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## [Unreleased]
- MYSQL Support
- Database creation tools

##[0.7-alpha] - 10-4-2021
### Added
- SQL querying
- Clipboard for SQL queries

### Changed
- Refactored codebase to be easier to reason with and manage
- Many bug fixes I forgot about

This changelog was started with 0.7-alpha, so the details before this are a little hazy. But here's to better transparency going forward!
23 changes: 12 additions & 11 deletions list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ func (m Model) paginationView() string {
func (m Model) populatedView() string {
items := m.VisibleItems()

var b strings.Builder
b := strings.Builder{}

// Empty states
if len(items) == 0 {
Expand All @@ -1096,16 +1096,17 @@ func (m Model) populatedView() string {
// If there aren't enough items to fill up this page (always the last page)
// then we need to add some newlines to fill up the space where items would
// have been.
itemsOnPage := m.Paginator.ItemsOnPage(len(items))
if itemsOnPage < m.Paginator.PerPage {
n := (m.Paginator.PerPage - itemsOnPage) * (m.delegate.Height() + m.delegate.Spacing())
if len(items) == 0 {
n -= m.delegate.Height() - 1
}
fmt.Fprint(&b, strings.Repeat("\n", n))
}

return b.String()
//itemsOnPage := m.Paginator.ItemsOnPage(len(items))
//if itemsOnPage < m.Paginator.PerPage {
// n := (m.Paginator.PerPage - itemsOnPage) * (m.delegate.Height() + m.delegate.Spacing())
// if len(items) == 0 {
// n -= m.delegate.Height() - 1
// }
// fmt.Fprint(&b, strings.Repeat("\n", n))
//}
ret := b.String()

return ret
}

func (m Model) helpView() string {
Expand Down
Binary file added termdbms
Binary file not shown.
33 changes: 17 additions & 16 deletions viewer/snippets.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ func (s SQLSnippet) FilterValue() string {

type itemDelegate struct{}

func (d itemDelegate) Height() int { return 2 }
func (d itemDelegate) Height() int { return 1 }
func (d itemDelegate) Spacing() int { return 0 }
func (d itemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd {
return nil
}

func (d itemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
var localStyle lipgloss.Style
localStyle := style.Copy()
i, ok := listItem.(SQLSnippet)
if !ok {
return
Expand All @@ -44,30 +44,31 @@ func (d itemDelegate) Render(w io.Writer, m list.Model, index int, listItem list
digits := len(fmt.Sprintf("%d", len(m.Items()))) + 1
incomingDigits := len(fmt.Sprintf("%d", index+1))

if tuiutil.Ascii {
if !tuiutil.Ascii {
localStyle = style.Copy().Faint(true)
}

str := fmt.Sprintf("%d) %s%s\n\t%s", index+1, strings.Repeat(" ", digits-incomingDigits), i.Title(),
localStyle.Render(i.Query[0:Min(TUIWidth - 10, len(i.Query) - 1)])) // padding + tab + padding
if tuiutil.Ascii {
localStyle = style.Copy().PaddingLeft(4)
}
str := fmt.Sprintf("%d) %s%s | ", index+1, strings.Repeat(" ", digits-incomingDigits),
i.Title())
query := localStyle.Render(i.Query[0:Min(TUIWidth - 10, Max(len(i.Query) - 1, len(i.Query) - 1 - len(str)))]) // padding + tab + padding
str += strings.ReplaceAll(query, "\n", "")

localStyle = style.Copy().PaddingLeft(4)

fn := localStyle.Render
if index == m.Index() {
fn = func(s string) string {
if tuiutil.Ascii {
localStyle = style.Copy().
Foreground(lipgloss.Color(tuiutil.HeaderTopForeground())).
PaddingLeft(2)
}
if tuiutil.Ascii {
s = style.Render(s)
localStyle = style.Copy().
PaddingLeft(2)
if !tuiutil.Ascii {
localStyle = localStyle.
Foreground(lipgloss.Color(tuiutil.HeaderTopForeground()))
}

return lipgloss.JoinHorizontal(lipgloss.Left,
localStyle.
Render("> "),
s)
style.Render(s))
}
}

Expand Down

0 comments on commit 1d26f24

Please sign in to comment.