Skip to content

Commit 582acaf

Browse files
committed
feat: Support MaxWidth < 0 for left-alignment
1 parent e03496f commit 582acaf

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ index0shortcut = -1
272272
maxWidth = 70
273273
# width of each page is max(<terminalWidth>, maxWidth)
274274
# set to 0 to always use the terminal width.
275+
# set to negative X to use a maxWidth of X but disable centering.
275276

276277
useCertificates = [
277278
# default: [] (see details below)

client.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,12 @@ func (c *Client) ParseGeminiPage(page *Page) string {
268268
}
269269
width := termWidth
270270
sides := 0
271-
if c.conf.MaxWidth != 0 && width > c.conf.MaxWidth {
271+
if c.conf.MaxWidth > 0 && width > c.conf.MaxWidth {
272272
width = c.conf.MaxWidth
273-
// sides := int((termWidth - width) / 2)
274-
// XXX: Huh?
275-
sides = termWidth - width
273+
sides = int((termWidth - width) / 2)
274+
}
275+
if c.conf.MaxWidth < 0 && width > (-c.conf.MaxWidth) {
276+
width = -c.conf.MaxWidth
276277
}
277278

278279
preformatted := false

gelim.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ columns wide for gemtext documents, and centered.
230230
.P
231231
Set to \fI0\fR to always use the terminal width.
232232
.P
233+
Set to negative X to use a maxWidth of X but disable centering.
234+
.P
233235
For plain text documents, Nex directories, and gophermaps, the page will be
234236
centered based on the maximum width of the text in the document.
235237
.P

gelim.1.scd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ Keys are case-insensitive.
147147

148148
Set to _0_ to always use the terminal width.
149149

150+
Set to negative X to use a maxWidth of X but disable centering.
151+
150152
For plain text documents, Nex directories, and gophermaps, the page will be
151153
centered based on the maximum width of the text in the document.
152154

0 commit comments

Comments
 (0)