From 85e2191a9ac31d3c01f16b45756234f3d2d19212 Mon Sep 17 00:00:00 2001 From: makeworld Date: Wed, 1 Jul 2020 20:08:07 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Hardwrap=20help=20table=20cells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ NOTES.md | 6 ++++-- display/help.go | 32 ++++++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fb94f8..c9abde3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Bottom bar now says `URL/Num./Search: ` when space is pressed - Update to [go-gemini](https://github.com/makeworld-the-better-one/go-gemini) v0.6.0 +- Help layout doesn't have borders anymore ### Fixed - Actual unicode bullet symbol is used for lists: U+2022 @@ -25,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Doesn't crash when wrapping certain complex lines (#20) - Input fields are always in focus when they appear (#5) - Reloading the new tab page doesn't cause an error popup +- Help table cells are hardwrapped so the text can still be read entirely on an 80-column terminal ## [1.1.0] - 2020-06-24 ### Added diff --git a/NOTES.md b/NOTES.md index ebd28f3..0a221fc 100644 --- a/NOTES.md +++ b/NOTES.md @@ -5,7 +5,7 @@ - And then just one single map of tab number to `tab` - URL for each tab should not be stored as a string - in the current code there's lots of reparsing the URL -## Bugs +## Upstream Bugs - Wrapping messes up on brackets - Filed [issue 23](https://gitlab.com/tslocum/cview/-/issues/23) - Wrapping panics on strings with brackets and Asian characters @@ -17,4 +17,6 @@ - Filed [issue 26](https://gitlab.com/tslocum/cview/-/issues/26) - Add some bold back into modal text after this is fixed - Bookmark keys aren't deleted, just set to `""` - - Waiting on [this viper PR](https://github.com/spf13/viper/pull/519) to be merged \ No newline at end of file + - Waiting on [this viper PR](https://github.com/spf13/viper/pull/519) to be merged +- Help table cells aren't dynamically wrapped + - Filed [issue 29](https://gitlab.com/tslocum/cview/-/issues/29) \ No newline at end of file diff --git a/display/help.go b/display/help.go index 948a604..caaaedc 100644 --- a/display/help.go +++ b/display/help.go @@ -18,12 +18,18 @@ b, Alt-Left|Go back in the history f, Alt-Right|Go forward in the history g|Go to top of document G|Go to bottom of document -spacebar|Open bar at the bottom - type a URL, link number, or search term. You can also type two dots (..) to go up a directory in the URL, as well as new:N to open link number N in a new tab instead of the current one. -Enter|On a page this will start link highlighting. Press Tab and Shift-Tab to pick different links. Press Enter again to go to one, or Esc to stop. +spacebar|Open bar at the bottom - type a URL, link number, search term. +|You can also type two dots (..) to go up a directory in the URL. +|Typing new:N will open link number N in a new tab +|instead of the current one. +Enter|On a page this will start link highlighting. +|Press Tab and Shift-Tab to pick different links. +|Press Enter again to go to one, or Esc to stop. Shift-NUMBER|Go to a specific tab. Shift-0, )|Go to the last tab. Ctrl-H|Go home -Ctrl-T|New tab, or if a link is selected, this will open the link in a new tab. +Ctrl-T|New tab, or if a link is selected, +|this will open the link in a new tab. Ctrl-W|Close tab. For now, only the right-most tab can be closed. Ctrl-R, R|Reload a page, discarding the cached version. Ctrl-B|View bookmarks @@ -33,7 +39,7 @@ q, Ctrl-Q, Ctrl-C|Quit var helpTable = cview.NewTable(). SetSelectable(false, false). - SetBorders(true). + SetBorders(false). SetBordersColor(tcell.ColorGray) // Help displays the help and keybindings. @@ -55,17 +61,27 @@ func helpInit() { strings.ReplaceAll(helpCells, "\n", "|"), "|") cell := 0 + extraRows := 0 // Rows continued from the previous, without spacing for r := 0; r < rows; r++ { for c := 0; c < 2; c++ { var tableCell *cview.TableCell if c == 0 { - tableCell = cview.NewTableCell(cells[cell]). + // First column, the keybinding + tableCell = cview.NewTableCell(" " + cells[cell]). SetAttributes(tcell.AttrBold). - SetAlign(cview.AlignCenter) + SetAlign(cview.AlignLeft) } else { - tableCell = cview.NewTableCell(" " + cells[cell]) + tableCell = cview.NewTableCell(" " + cells[cell]) + } + if c == 0 && cells[cell] == "" || (cell > 0 && cells[cell-1] == "" && c == 1) { + // The keybinding column for this row was blank, meaning the explanation + // column is continued from the previous row. + // The row should be added without any spacing rows + helpTable.SetCell(((2*r)-extraRows/2)-1, c, tableCell) + extraRows++ + } else { + helpTable.SetCell((2*r)-extraRows/2, c, tableCell) // Every other row, for readability } - helpTable.SetCell(r, c, tableCell) cell++ } }