// 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, "") }