aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorJohannes Thyssen Tishman <johannes@thyssentishman.com>2024-03-26 23:00:50 +0100
committerRobin Jarry <robin@jarry.cc>2024-04-02 22:22:33 +0200
commit3d529aa09330f383298a5735a18549b44bc3098f (patch)
treea075dbdde8c4ecbfda22dc92ce97949a8d6b69b2 /config
parent1ce82f50d0981a9ee047e75d94c7ab496070bd4a (diff)
downloadaerc-3d529aa09330f383298a5735a18549b44bc3098f.tar.gz
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 <johannes@thyssentishman.com> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config')
-rw-r--r--config/ui.go24
1 files changed, 24 insertions, 0 deletions
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) {