From 3d529aa09330f383298a5735a18549b44bc3098f Mon Sep 17 00:00:00 2001 From: Johannes Thyssen Tishman Date: Tue, 26 Mar 2024 23:00:50 +0100 Subject: config: make popover dialogs configurable Add the [ui].dialog-{position,width,height} options in aerc.conf to set the position, width and height of popover dialogs such as the one from :menu, :envelope or :attach -m relative to the main window. Changelog-added: Add `[ui].dialog-{position,width,height}` to set the position, width and height of popover dialogs. Signed-off-by: Johannes Thyssen Tishman Reviewed-by: Tim Culverhouse Acked-by: Robin Jarry --- config/ui.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'config') diff --git a/config/ui.go b/config/ui.go index a6034d46..7b819192 100644 --- a/config/ui.go +++ b/config/ui.go @@ -70,6 +70,9 @@ type UIConfig struct { CompletionMinChars int `ini:"completion-min-chars" default:"1" parse:"ParseCompletionMinChars"` CompletionPopovers bool `ini:"completion-popovers" default:"true"` MsglistScrollOffset int `ini:"msglist-scroll-offset" default:"0"` + DialogPosition string `ini:"dialog-position" default:"center" parse:"ParseDialogPosition"` + DialogWidth int `ini:"dialog-width" default:"50" parse:"ParseDialogDimensions"` + DialogHeight int `ini:"dialog-height" default:"50" parse:"ParseDialogDimensions"` StyleSetDirs []string `ini:"stylesets-dirs" delim:":"` StyleSetName string `ini:"styleset-name" default:"default"` style StyleSet @@ -271,6 +274,27 @@ func (*UIConfig) ParseSplit(section *ini.Section, key *ini.Key) (p SplitParams, return } +func (*UIConfig) ParseDialogPosition(section *ini.Section, key *ini.Key) (string, error) { + match, _ := regexp.MatchString(`^\s*(top|center|bottom)\s*$`, key.String()) + if !(match) { + return "", fmt.Errorf("bad option value") + } + return key.String(), nil +} + +const ( + DIALOG_MIN_PROPORTION = 10 + DIALOG_MAX_PROPORTION = 100 +) + +func (*UIConfig) ParseDialogDimensions(section *ini.Section, key *ini.Key) (int, error) { + value, err := key.Int() + if value < DIALOG_MIN_PROPORTION || value > DIALOG_MAX_PROPORTION || err != nil { + return 0, fmt.Errorf("value out of range") + } + return value, nil +} + const MANUAL_COMPLETE = math.MaxInt func (*UIConfig) ParseCompletionMinChars(section *ini.Section, key *ini.Key) (int, error) { -- cgit