weechat.js: support 1/2/3/4 attributes too

This commit is contained in:
Philippe Proulx 2013-10-26 13:50:53 -04:00
parent c1612f4c46
commit 647e8c5af1

View file

@ -194,10 +194,17 @@
*/ */
WeeChatProtocol._attrNameFromChar = function(ch) { WeeChatProtocol._attrNameFromChar = function(ch) {
var chars = { var chars = {
// WeeChat protocol
'*': 'bold', '*': 'bold',
'!': 'reverse', '!': 'reverse',
'/': 'italic', '/': 'italic',
'_': 'underline' '_': 'underline',
// some extension often used (IRC?)
'\x01': 'bold',
'\x02': 'reverse',
'\x03': 'italic',
'\x04': 'underline'
}; };
if (ch in chars) { if (ch in chars) {
@ -323,7 +330,7 @@
// foreground color with F // foreground color with F
// "F" + (A)STD // "F" + (A)STD
// "F" + (A)EXT // "F" + (A)EXT
regex: /^F(?:([*!\/_|]*)(\d{2})|@([*!\/_|]*)(\d{5}))/, regex: /^F(?:([*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5}))/,
fn: function(m) { fn: function(m) {
var ret = { var ret = {
bgColor: null bgColor: null
@ -359,7 +366,7 @@
// "*" + (A)STD + "," + EXT // "*" + (A)STD + "," + EXT
// "*" + (A)EXT + "," + STD // "*" + (A)EXT + "," + STD
// "*" + (A)EXT + "," + EXT // "*" + (A)EXT + "," + EXT
regex: /^\*(?:([*!\/_|]*)(\d{2})|@([*!\/_|]*)(\d{5})),(\d{2}|@\d{5})/, regex: /^\*(?:([\x01\x02\x03\x04*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5})),(\d{2}|@\d{5})/,
fn: function(m) { fn: function(m) {
var ret = {}; var ret = {};
@ -379,7 +386,7 @@
// foreground color with * (+ attributes) (fall back, must be checked before previous case) // foreground color with * (+ attributes) (fall back, must be checked before previous case)
// "*" + (A)STD // "*" + (A)STD
// "*" + (A)EXT // "*" + (A)EXT
regex: /^\*([*!\/_|]*)(\d{2}|@\d{5})/, regex: /^\*([\x01\x02\x03\x04*!\/_|]*)(\d{2}|@\d{5})/,
fn: function(m) { fn: function(m) {
return { return {
fgColor: WeeChatProtocol._getColorObj(m[2]), fgColor: WeeChatProtocol._getColorObj(m[2]),