diff --git a/backends/x/event.go b/backends/x/event.go index c2ac74d..7a49f26 100644 --- a/backends/x/event.go +++ b/backends/x/event.go @@ -39,13 +39,18 @@ func (backend *Backend) handleConfigureNotify ( width, height := backend.calculateBufferSize() backend.application.SetSize(width, height) - // position buffer in the center of the screen - frameWidth := width * backend.metrics.cellWidth - frameHeight := height * backend.metrics.cellHeight - backend.metrics.paddingX = - (backend.metrics.windowWidth - frameWidth) / 2 - backend.metrics.paddingY = - (backend.metrics.windowHeight - frameHeight) / 2 + if backend.config.Center() { + // position buffer in the center of the screen + frameWidth := width * backend.metrics.cellWidth + frameHeight := height * backend.metrics.cellHeight + backend.metrics.paddingX = + (backend.metrics.windowWidth - frameWidth) / 2 + backend.metrics.paddingY = + (backend.metrics.windowHeight - frameHeight) / 2 + } else { + backend.metrics.paddingX = backend.metrics.padding + backend.metrics.paddingY = backend.metrics.padding + } backend.windowBoundsClean = false } diff --git a/config.go b/config.go index d08a7c9..1cbf732 100644 --- a/config.go +++ b/config.go @@ -12,6 +12,7 @@ import "path/filepath" type Config struct { colors [8]color.Color padding int + center bool fontSize int fontName string } @@ -29,6 +30,13 @@ func (config *Config) Padding () (padding int) { return } +// Center returns whether the buffer should be displayed in the center of the +// window like in kitty, or aligned to one corner like in gnome-terminal. +func (config *Config) Center () (center bool) { + center = config.center + return +} + // FontSize specifies how big the font should be. func (config *Config) FontSize () (fontSize int) { fontSize = config.fontSize @@ -98,8 +106,14 @@ func (config *Config) loadFile (path string) { } key = strings.TrimSpace(key) value = strings.TrimSpace(value) + var valueInt int var valueColor color.Color + var valueBoolean bool + + if value == "true" { + valueBoolean = true + } if value[0] == '#' { if len(value) != 7 { @@ -134,6 +148,8 @@ func (config *Config) loadFile (path string) { config.fontSize = valueInt case "padding": config.padding = valueInt + case "center": + config.center = valueBoolean case "colorBackground": config.colors[ColorBackground] = valueColor case "colorForeground":