Cap output width to 80 characters max.
This commit is contained in:
parent
76225d1c50
commit
0f7e257f76
@ -3,6 +3,8 @@ import cliutils, uuids
|
||||
import std/strutils except alignLeft, capitalize, strip, toLower, toUpper
|
||||
import ./libpit
|
||||
|
||||
proc adjustedTerminalWidth(): int = min(terminalWidth(), 80)
|
||||
|
||||
proc getIssueContextDisplayName*(ctx: CliContext, context: string): string =
|
||||
if not ctx.contexts.hasKey(context):
|
||||
if context.isEmptyOrWhitespace: return "<default>"
|
||||
@ -128,11 +130,11 @@ proc formatSectionIssueList*(
|
||||
|
||||
proc formatSection(ctx: CliContext, issues: seq[Issue], state: IssueState,
|
||||
indent = "", verbose = false): string =
|
||||
let innerWidth = terminalWidth() - (indent.len * 2)
|
||||
let innerWidth = adjustedTerminalWidth() - (indent.len * 2)
|
||||
|
||||
result = termColor(fgBlue) &
|
||||
(indent & ".".repeat(innerWidth)) & "\n" &
|
||||
state.displayName.center(terminalWidth()) & "\n\n" &
|
||||
state.displayName.center(adjustedTerminalWidth()) & "\n\n" &
|
||||
termReset
|
||||
|
||||
let issuesByContext = issues.groupBy("context")
|
||||
@ -152,9 +154,9 @@ proc formatSection(ctx: CliContext, issues: seq[Issue], state: IssueState,
|
||||
|
||||
proc writeHeader*(ctx: CliContext, header: string) =
|
||||
stdout.setForegroundColor(fgRed, true)
|
||||
stdout.writeLine('_'.repeat(terminalWidth()))
|
||||
stdout.writeLine(header.center(terminalWidth()))
|
||||
stdout.writeLine('~'.repeat(terminalWidth()))
|
||||
stdout.writeLine('_'.repeat(adjustedTerminalWidth()))
|
||||
stdout.writeLine(header.center(adjustedTerminalWidth()))
|
||||
stdout.writeLine('~'.repeat(adjustedTerminalWidth()))
|
||||
stdout.resetAttributes
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user