aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/headerlayout.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-10-09 13:52:20 +0200
committerRobin Jarry <robin@jarry.cc>2023-10-10 11:37:56 +0200
commit598e4a5803578ab3e291f232d6aad31b4efd8ea4 (patch)
treec55e16d60e2c3eea2d6de27d1bac18db5670ec77 /widgets/headerlayout.go
parent61bca76423ee87bd59084a146eca71c6bae085e1 (diff)
downloadaerc-598e4a5803578ab3e291f232d6aad31b4efd8ea4.tar.gz
widgets: rename package to app
This is the central point of all aerc. Having it named widgets is confusing. Rename it to app. It will make a cleaner transition when making the app.Aerc object available globally in the next commit. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'widgets/headerlayout.go')
-rw-r--r--widgets/headerlayout.go44
1 files changed, 0 insertions, 44 deletions
diff --git a/widgets/headerlayout.go b/widgets/headerlayout.go
deleted file mode 100644
index 8113cf89..00000000
--- a/widgets/headerlayout.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package widgets
-
-import (
- "git.sr.ht/~rjarry/aerc/lib/ui"
- "git.sr.ht/~rjarry/aerc/models"
-)
-
-type HeaderLayout [][]string
-
-type HeaderLayoutFilter struct {
- layout HeaderLayout
- keep func(msg *models.MessageInfo, header string) bool // filter criteria
-}
-
-// forMessage returns a filtered header layout, removing rows whose headers
-// do not appear in the provided message.
-func (filter HeaderLayoutFilter) forMessage(msg *models.MessageInfo) HeaderLayout {
- result := make(HeaderLayout, 0, len(filter.layout))
- for _, row := range filter.layout {
- // To preserve layout alignment, only hide rows if all columns are empty
- for _, col := range row {
- if filter.keep(msg, col) {
- result = append(result, row)
- break
- }
- }
- }
- return result
-}
-
-// grid builds a ui grid, populating each cell by calling a callback function
-// with the current header string.
-func (layout HeaderLayout) grid(cb func(string) ui.Drawable) (grid *ui.Grid, height int) {
- rowCount := len(layout)
- grid = ui.MakeGrid(rowCount, 1, ui.SIZE_EXACT, ui.SIZE_WEIGHT)
- for i, cols := range layout {
- r := ui.MakeGrid(1, len(cols), ui.SIZE_EXACT, ui.SIZE_WEIGHT)
- for j, col := range cols {
- r.AddChild(cb(col)).At(0, j)
- }
- grid.AddChild(r).At(i, 0)
- }
- return grid, rowCount
-}