mirror of
https://github.com/makew0rld/amfora.git
synced 2024-11-03 02:37:23 -05:00
Center text, fixes #233
This commit is contained in:
parent
3823a46152
commit
034b4c019d
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
`)
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user