From 1f268693a1050d12b7cf6792b7805097fd36be47 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Fri, 2 Jun 2023 21:39:44 +0200 Subject: [PATCH] Support for colors in buffer short name Took quite a few years before anyone tried that --- src/index.html | 2 +- src/js/handlers.js | 8 ++++++-- src/js/models.js | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/index.html b/src/index.html index 94cbe10..56d6c05 100644 --- a/src/index.html +++ b/src/index.html @@ -373,7 +373,7 @@ chown -R username:username ~username {{ buffer.$quickKey }} {{ ("0" + buffer.$jumpKey).slice(-2) }} - {{ buffer.trimmedName || buffer.fullName }} + {{ buffer.trimmedName || buffer.fullName }} diff --git a/src/js/handlers.js b/src/js/handlers.js index 8754330..0fe70a7 100644 --- a/src/js/handlers.js +++ b/src/js/handlers.js @@ -229,6 +229,8 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific // weechat properties -- short name can be changed buffer.shortName = message.short_name; buffer.trimmedName = buffer.shortName.replace(/^[#&+]/, ''); + // Use color from short name + buffer.nameClasses = models.parseRichText(message.short_name)[0].classes; buffer.title = message.title; buffer.number = message.number; buffer.hidden = message.hidden; @@ -288,6 +290,8 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific var old = models.getBuffer(buffer); old.fullName = obj.full_name; old.shortName = obj.short_name; + // Use color from short name + old.nameClasses = models.parseRichText(obj.short_name)[0].classes; // If it's a channel, trim away the prefix (#, &, or +). If that is empty and the buffer // has a short name, use a space (because the prefix will be displayed separately, and we don't want // prefix + fullname, which would happen otherwise). Else, use null so that full_name is used @@ -457,8 +461,8 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific //fill the nicklist nicklist.forEach(function(n) { var buffer = models.getBuffer(n.pointers[0]); - - //buffer nicklist + + //buffer nicklist if (n.group === 1) { var g = new models.NickGroup(n); group = g.name; diff --git a/src/js/models.js b/src/js/models.js index 6327dbc..49b2e5e 100644 --- a/src/js/models.js +++ b/src/js/models.js @@ -73,6 +73,7 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo // weechat properties var fullName = parseRichText(message.full_name)[0].text; var shortName = parseRichText(message.short_name)[0].text; + var classes = parseRichText(message.short_name)[0].classes; var hidden = message.hidden; // If it's a channel, trim away the prefix (#, &, or +). If that is empty and the buffer // has a short name, use a space (because the prefix will be displayed separately, and we don't want @@ -344,6 +345,7 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo shortName: shortName, hidden: hidden, trimmedName: trimmedName, + nameClasses: classes, prefix: prefix, number: number, title: title,