Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/Format.qml

Raw
import QtQuick

// Tiny stateless text helper. Lives outside the Bar (a Variants delegate with
// no stable id) so its pure functions can be gate-tested over IPC.
QtObject {
    // Vertical-mode label shortener (user rule): drop vowels, truncate to 3;
    // if the vowel-dropped result is under 3 chars, fall back to the first 3
    // of the original.
    function abbreviate(text) {
        const s = String(text);
        const stripped = s.replace(/[aeiou]/gi, "");
        return (stripped.length >= 3 ? stripped : s).slice(0, 3);
    }

    function abbreviateSelfTest() {
        const cases = {
            "notify": "ntf",
            "code": "cod",
            "media": "med",
            "system": "sys",
            "audio": "aud",
            "power": "pwr",
            "idle": "idl",
            "tray": "try"
        };
        const failures = [];
        for (const key in cases) {
            const got = abbreviate(key);
            if (got !== cases[key])
                failures.push(`${key}: expected ${cases[key]}, got ${got}`);
        }
        return {
            "pass": failures.length === 0,
            "failures": failures
        };
    }
}