about summary refs log tree commit diff stats
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2020-05-31 12:37:46 +0100
committerReto Brunner <reto@labrat.space>2020-06-09 08:48:47 +0200
commit543510f5c146aa6e4d3344ec7d109ad7945fa106 (patch)
tree7356a64e28c2ab9123e84a76381e2cd99e82849a /widgets/msgviewer.go
parent3877b1aa719569d3666bce227e351afcbc2628af (diff)
downloadaerc-543510f5c146aa6e4d3344ec7d109ad7945fa106.tar.gz
Make grid sizes dynamic
The grid used static sizes which meant that changing settings didn't
have an effect on elements of the ui, notably the sidebar width. This
patch makes the `Size` parameter of a cell a function which returns the
`int`, allowing for dynamic sizes.

A `Const` function is also included for ease of use for static sizes.
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index ce85970..f06b787 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -69,7 +69,7 @@ func NewMessageViewer(acct *AccountView,
 	)
 
 	rows := []ui.GridSpec{
-		{ui.SIZE_EXACT, headerHeight},
+		{ui.SIZE_EXACT, ui.Const(headerHeight)},
 	}
 
 	if msg.PGPDetails() != nil {
@@ -77,16 +77,16 @@ func NewMessageViewer(acct *AccountView,
 		if msg.PGPDetails().IsSigned && msg.PGPDetails().IsEncrypted {
 			height = 2
 		}
-		rows = append(rows, ui.GridSpec{ui.SIZE_EXACT, height})
+		rows = append(rows, ui.GridSpec{ui.SIZE_EXACT, ui.Const(height)})
 	}
 
 	rows = append(rows, []ui.GridSpec{
-		{ui.SIZE_EXACT, 1},
-		{ui.SIZE_WEIGHT, 1},
+		{ui.SIZE_EXACT, ui.Const(1)},
+		{ui.SIZE_WEIGHT, ui.Const(1)},
 	}...)
 
 	grid := ui.NewGrid().Rows(rows).Columns([]ui.GridSpec{
-		{ui.SIZE_WEIGHT, 1},
+		{ui.SIZE_WEIGHT, ui.Const(1)},
 	})
 
 	switcher := &PartSwitcher{}
@@ -373,7 +373,7 @@ func (ps *PartSwitcher) MouseEvent(localX int, localY int, event tcell.Event) {
 			if localY < y && ps.parts[ps.selected].term != nil {
 				ps.parts[ps.selected].term.MouseEvent(localX, localY, event)
 			}
-			for i, _ := range ps.parts {
+			for i := range ps.parts {
 				if localY != y+i {
 					continue
 				}
@@ -511,11 +511,11 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig,
 	}
 
 	grid := ui.NewGrid().Rows([]ui.GridSpec{
-		{ui.SIZE_EXACT, 3}, // Message
-		{ui.SIZE_EXACT, 1}, // Selector
-		{ui.SIZE_WEIGHT, 1},
+		{ui.SIZE_EXACT, ui.Const(3)}, // Message
+		{ui.SIZE_EXACT, ui.Const(1)}, // Selector
+		{ui.SIZE_WEIGHT, ui.Const(1)},
 	}).Columns([]ui.GridSpec{
-		{ui.SIZE_WEIGHT, 1},
+		{ui.SIZE_WEIGHT, ui.Const(1)},
 	})
 
 	selecter := NewSelecter([]string{"Save message", "Pipe to command"}, 0).