equal
deleted
inserted
replaced
20 local ipairs = ipairs; |
20 local ipairs = ipairs; |
21 local type = type; |
21 local type = type; |
22 local s_gsub = string.gsub; |
22 local s_gsub = string.gsub; |
23 local s_sub = string.sub; |
23 local s_sub = string.sub; |
24 local s_find = string.find; |
24 local s_find = string.find; |
25 local os = os; |
|
26 |
25 |
27 local valid_utf8 = require "util.encodings".utf8.valid; |
26 local valid_utf8 = require "util.encodings".utf8.valid; |
28 |
27 |
29 local do_pretty_printing = not os.getenv("WINDIR"); |
28 local do_pretty_printing, termcolours = pcall(require, "util.termcolours"); |
30 local getstyle, getstring; |
|
31 if do_pretty_printing then |
|
32 local ok, termcolours = pcall(require, "util.termcolours"); |
|
33 if ok then |
|
34 getstyle, getstring = termcolours.getstyle, termcolours.getstring; |
|
35 else |
|
36 do_pretty_printing = nil; |
|
37 end |
|
38 end |
|
39 |
29 |
40 local xmlns_stanzas = "urn:ietf:params:xml:ns:xmpp-stanzas"; |
30 local xmlns_stanzas = "urn:ietf:params:xml:ns:xmpp-stanzas"; |
41 |
31 |
42 local _ENV = nil; |
32 local _ENV = nil; |
43 -- luacheck: std none |
33 -- luacheck: std none |
498 local function presence(attr) |
488 local function presence(attr) |
499 return new_stanza("presence", attr); |
489 return new_stanza("presence", attr); |
500 end |
490 end |
501 |
491 |
502 if do_pretty_printing then |
492 if do_pretty_printing then |
|
493 local getstyle, getstring = termcolours.getstyle, termcolours.getstring; |
503 local style_attrk = getstyle("yellow"); |
494 local style_attrk = getstyle("yellow"); |
504 local style_attrv = getstyle("red"); |
495 local style_attrv = getstyle("red"); |
505 local style_tagname = getstyle("red"); |
496 local style_tagname = getstyle("red"); |
506 local style_punc = getstyle("magenta"); |
497 local style_punc = getstyle("magenta"); |
507 |
498 |