=================================================================== Remaining drawing functions (not in helpers.go) ===================================================================
(content string, width int, opts *options.Options, l10n localization.L10n)
| 109 | // =================================================================== |
| 110 | |
| 111 | func addFrame(content string, width int, opts *options.Options, l10n localization.L10n) string { |
| 112 | if opts.NoCaption { |
| 113 | return content |
| 114 | } |
| 115 | |
| 116 | lines := strings.Split(strings.TrimRight(content, "\n"), "\n") |
| 117 | for i := range lines { |
| 118 | spacesNumber := width - len(lines[i]) |
| 119 | if spacesNumber < 0 { |
| 120 | spacesNumber = 0 |
| 121 | } |
| 122 | lines[i] = "│" + lines[i] + strings.Repeat(" ", spacesNumber) + "│" |
| 123 | } |
| 124 | |
| 125 | title := l10n.Text("CAPTION_WEATHER_REPORT_FOR") |
| 126 | if opts.Superquiet { |
| 127 | title = "" |
| 128 | } else if !opts.Quiet || !opts.NoCity { |
| 129 | title += " " + opts.Location |
| 130 | } else if opts.Quiet { |
| 131 | title = opts.Location |
| 132 | } |
| 133 | |
| 134 | caption := "" |
| 135 | if !opts.Superquiet { |
| 136 | caption = "┤ " + title + " ├" |
| 137 | } |
| 138 | |
| 139 | frameTop := "┌" + caption + strings.Repeat("─", width-utf8.RuneCountInString(caption)) + "┐\n" |
| 140 | |
| 141 | return frameTop + strings.Join(lines, "\n") + "\n" + |
| 142 | "└" + strings.Repeat("─", width) + "┘\n" |
| 143 | } |