diff options
Diffstat (limited to 'internal/game/cmd_look.go')
| -rw-r--r-- | internal/game/cmd_look.go | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/internal/game/cmd_look.go b/internal/game/cmd_look.go index f01b83c..1de58f8 100644 --- a/internal/game/cmd_look.go +++ b/internal/game/cmd_look.go @@ -133,33 +133,46 @@ func wrapText(text string, width int) []string { } func (g *Game) writeLookSideBySide(sess *net.Session, p *player.Player, contentLines []string, mapLines []string, descWidth int) { - total := len(contentLines) - if len(mapLines) > total { - total = len(mapLines) - } - leftMap := p.OptionString("tiny_map") == "left" mapWidth := descWidth if mapWidth <= 0 { mapWidth = 70 } + // Wrap any content line that would overrun the map column. Without this a + // long table status writes through the minimap; with it the status wraps + // and the map keeps its own column. + content := make([]string, 0, len(contentLines)) + for _, line := range contentLines { + if visibleLen(line) <= mapWidth { + content = append(content, line) + continue + } + for _, part := range strings.Split(color.WrapANSI(line, mapWidth), "\r\n") { + content = append(content, part) + } + } + total := len(content) + if len(mapLines) > total { + total = len(mapLines) + } + leftMap := p.OptionString("tiny_map") == "left" for i := 0; i < total; i++ { - content := "" - if i < len(contentLines) { - content = contentLines[i] + piece := "" + if i < len(content) { + piece = content[i] } if i < len(mapLines) { mapLine := mapLines[i] if leftMap { - sess.WriteLine(fmt.Sprintf("%s %s", mapLine, content)) + sess.WriteLine(fmt.Sprintf("%s %s", mapLine, piece)) } else { - pad := mapWidth - visibleLen(content) + pad := mapWidth - visibleLen(piece) if pad < 0 { pad = 0 } - sess.WriteLine(content + strings.Repeat(" ", pad) + " " + mapLine) + sess.WriteLine(piece + strings.Repeat(" ", pad) + " " + mapLine) } } else { - sess.WriteLine(content) + sess.WriteLine(piece) } } } |
