diff --git a/CHANGELOG.md b/CHANGELOG.md index 915fbdb..86d634b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Syntax highlighting for preformatted text blocks with alt text (#252, #263, [wiki page](https://github.com/makeworld-the-better-one/amfora/wiki/Source-Code-Highlighting)) +### Changed +- Center text automatically, removing `left_margin` from the config (#233) +- `max_width` defaults to 80 columns instead of 100 (#233) + ### Fixed - Modal can't be closed when opening non-gemini text URLs from the commandline (#283, #284) - External programs started by Amfora remain as zombie processes (#219) diff --git a/config/config.go b/config/config.go index 6c4bf1b..bcd23bc 100644 --- a/config/config.go +++ b/config/config.go @@ -200,8 +200,7 @@ func Init() error { viper.SetDefault("a-general.highlight_style", "monokai") viper.SetDefault("a-general.bullets", true) viper.SetDefault("a-general.show_link", false) - viper.SetDefault("a-general.left_margin", 0.15) - viper.SetDefault("a-general.max_width", 100) + viper.SetDefault("a-general.max_width", 80) viper.SetDefault("a-general.downloads", "") viper.SetDefault("a-general.temp_downloads", "") viper.SetDefault("a-general.page_max_size", 2097152) diff --git a/config/default.go b/config/default.go index 82a7b3e..09b5099 100644 --- a/config/default.go +++ b/config/default.go @@ -70,11 +70,8 @@ bullets = true # Whether to show link after link text show_link = false -# A number from 0 to 1, indicating what percentage of the terminal width the left margin should take up. -left_margin = 0.15 - # The max number of columns to wrap a page's text to. Preformatted blocks are not wrapped. -max_width = 100 +max_width = 80 # 'downloads' is the path to a downloads folder. # An empty value means the code will find the default downloads folder for your system. diff --git a/default-config.toml b/default-config.toml index 7e034ed..7c42685 100644 --- a/default-config.toml +++ b/default-config.toml @@ -67,11 +67,8 @@ bullets = true # Whether to show link after link text show_link = false -# A number from 0 to 1, indicating what percentage of the terminal width the left margin should take up. -left_margin = 0.15 - # The max number of columns to wrap a page's text to. Preformatted blocks are not wrapped. -max_width = 100 +max_width = 80 # 'downloads' is the path to a downloads folder. # An empty value means the code will find the default downloads folder for your system. diff --git a/display/thanks.go b/display/thanks.go index d26a2fc..72ee3bf 100644 --- a/display/thanks.go +++ b/display/thanks.go @@ -29,4 +29,5 @@ Thank you to the following contributors, who have helped make Amfora great. FOSS * Michael McDonagh (@m-mcdonagh) * mooff (@awfulcooking) * Josias (@justjosias) +* mntn (@mntn-xyz) `) diff --git a/display/util.go b/display/util.go index f91f2a8..d789ea9 100644 --- a/display/util.go +++ b/display/util.go @@ -63,7 +63,14 @@ func isValidTab(t *tab) bool { } func leftMargin() int { - return int(float64(termW) * viper.GetFloat64("a-general.left_margin")) + // Return the left margin size that centers the text, assuming it's the max width + // https://github.com/makeworld-the-better-one/amfora/issues/233 + + lm := (termW - viper.GetInt("a-general.max_width")) / 2 + if lm < 0 { + return 0 + } + return lm } func textWidth() int { @@ -73,13 +80,11 @@ func textWidth() int { return viper.GetInt("a-general.max_width") } - rightMargin := leftMargin() - if leftMargin() > 10 { - // 10 is the max right margin - rightMargin = 10 - } + // Subtract left and right margin from total width to get text width + // Left and right margin are equal because text is automatically centered, see: + // https://github.com/makeworld-the-better-one/amfora/issues/233 - max := termW - leftMargin() - rightMargin + max := termW - leftMargin()*2 if max < viper.GetInt("a-general.max_width") { return max }