Files
Storm Dragon 3dbd7f2554 Avoid repeating Mumble server labels across columns
Collapse identical full-row labels only for Mumble while preserving mixed column data and repeated values from other providers. Add Qt native coverage and document live saved-server listening confirmation.
2026-11-07 20:12:25 -05:00

39 lines
1.3 KiB
Go

// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
package atspi
import (
"regexp"
"strings"
)
var mumbleTimestamp = regexp.MustCompile(`^\[\d{2}:\d{2}:\d{2}\]\s*`)
// Mumble supplies the same accessible label for every server-list column,
// including Ping and Users. Collapse only a whole row of identical labels;
// ordinary equal-valued columns and rows containing other data retain them.
func mumbleTableRowText(snapshot Snapshot) string {
if snapshot.ApplicationProcess == "mumble" && snapshot.GUITable &&
snapshot.Role == "table cell" && snapshot.Name != "" &&
snapshot.TableColumnCount > 1 && snapshot.TableColumnCount <= 32 &&
snapshot.TableRowText == snapshot.Name+strings.Repeat(", "+snapshot.Name, snapshot.TableColumnCount-1) {
return snapshot.Name
}
return snapshot.TableRowText
}
// Match legacy Mumble's inserted-message cleanup. Qt can insert the timestamp
// separately, and uses paragraph separators and noncharacters in its log.
func mumbleMessageText(text string) string {
text = strings.Map(func(character rune) rune {
if character >= '\ufdd0' && character <= '\ufdef' {
return -1
}
return character
}, text)
text = strings.Join(strings.Fields(text), " ")
return mumbleTimestamp.ReplaceAllString(text, "")
}