aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_option.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-29 04:41:40 -0400
committerhistoria <[not public]>2026-06-29 04:41:40 -0400
commit71ce47ca37566be8dc390434df4cd01422298094 (patch)
treec688dc5ff84af8c03a5c825dd6a3926281a8cae3 /internal/game/cmd_option.go
parent0fe67cfd5def4ac3e919fd611fe5acc55ca2d253 (diff)
downloadthehouseoficarus-71ce47ca37566be8dc390434df4cd01422298094.tar.gz
fix: long fields truncated better in tables
Diffstat (limited to 'internal/game/cmd_option.go')
-rw-r--r--internal/game/cmd_option.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/internal/game/cmd_option.go b/internal/game/cmd_option.go
index 958fc0b..f404c2e 100644
--- a/internal/game/cmd_option.go
+++ b/internal/game/cmd_option.go
@@ -26,7 +26,7 @@ func (g *Game) doOption(sess *net.Session, input string) {
}
for _, def := range player.OptionDefs {
val := formatOptionValue(p, &def)
- val = truncateForTable(val)
+ val = truncateForTable(val, p.OptionBool("unicode"))
valid := formatValidValues(&def)
table.Rows = append(table.Rows, []string{
color.Render(mode, color.Parse("4B"), def.Name),
@@ -150,9 +150,12 @@ func parseOptionValue(def *player.OptionDef, input string) (any, bool) {
return nil, false
}
-func truncateForTable(s string) string {
- if len(s) <= 10 {
+func truncateForTable(s string, unicode bool) string {
+ ellipsis := color.Ellipsis(unicode)
+ ellipLen := len([]rune(ellipsis))
+ if len([]rune(s)) <= 10 {
return s
}
- return s[:7] + "..."
+ runes := []rune(s)
+ return string(runes[:10-ellipLen]) + ellipsis
}