diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 0000000..a9e8abc --- /dev/null +++ b/CHANGELOG.txt @@ -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! \ No newline at end of file diff --git a/list/list.go b/list/list.go index 140d06e..cd6a8c4 100644 --- a/list/list.go +++ b/list/list.go @@ -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 { @@ -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 { diff --git a/termdbms b/termdbms new file mode 100755 index 0000000..2fa9097 Binary files /dev/null and b/termdbms differ diff --git a/viewer/snippets.go b/viewer/snippets.go index af9052f..bfe757f 100644 --- a/viewer/snippets.go +++ b/viewer/snippets.go @@ -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 @@ -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)) } }