Since Windows 10 'November Update' (10.0.10586) there are two console hosts, the legacy and modern one. The latter natively supports ANSI sequences, allowing Prosody to output console log without having to alter output. This is not the case for legacy console host that has to switch bg/text color every time we have to change it. On startup, Prosody will throw a warning if it was run either in legacy conhost on supported system or an outdated version of Windows. Both warnings can be suppressed by command line arguments, as well as an option to keep ANSI output on legacy console host is there.
-- You received this message because you are subscribed to the Google Groups "prosody-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prosody-dev/68280958b439bcf35063.1678832668%40EI08_MatisseX.
# HG changeset patch # User Vitaly Orekhov <[email protected]> # Date 1678832618 -10800 # Wed Mar 15 01:23:38 2023 +0300 # Branch trunk-win32 # Node ID 68280958b439bcf35063e356cd6ddf03a9292b2c # Parent 5dce4cd13f90c195998a8632dfda691029b20252 util.startup: Make use of Windows console host type detection Since Windows 10 'November Update' (10.0.10586) there are two console hosts, the legacy and modern one. The latter natively supports ANSI sequences, allowing Prosody to output console log without having to alter output. This is not the case for legacy console host that has to switch bg/text color every time we have to change it. On startup, Prosody will throw a warning if it was run either in legacy conhost on supported system or an outdated version of Windows. Both warnings can be suppressed by command line arguments, as well as an option to keep ANSI output on legacy console host is there. diff -r 5dce4cd13f90 -r 68280958b439 util/startup.lua --- a/util/startup.lua Tue Mar 14 02:31:49 2023 +0300 +++ b/util/startup.lua Wed Mar 15 01:23:38 2023 +0300 @@ -242,6 +242,59 @@ prosody.platform = "unknown"; if os.getenv("WINDIR") then prosody.platform = "windows"; + local get_consoletype, get_windowsbuild = require "util.windows".get_consoletype, require "util.windows".get_windowsbuild; + local evtp_start = require "util.windows".evtp_start; + build = tonumber(get_windowsbuild():match("^(%d+)%.")); + + if not get_consoletype() and prosody.opts.force_ansi ~= true then + prosody.legacy_color = true; + end + + if not prosody.opts.compat_aware then + if not get_consoletype() then + if build >= 10586 then + print( +[[ +***************************************************************************** +You are running Command Prompt in legacy mode. This will not allow you to see +proper ANSI formatting of console output. + +To enable ANSI sequences support, right-click Command Prompt title bar, click +Properties and uncheck 'Use legacy console' and restart Command Prompt. + +Learn more: +https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences + +Log lines that have custom color for log level will be fully painted. +To hide this warning, restart Prosody with -compat_aware argument. +***************************************************************************** +]] + ); + else + if prosody.opts.force_ansi ~= true then + print( +[[ +******************** OUTDATED VERSION OF WINDOWS IS USED! ******************** +Prosody doesn't target Windows and likely to not have polyfills for caveats of +Windows versions prior to 10.0.10586, also known as Windows 10 November Update. + +We recommend you to update at least to this version of Windows to get native +ANSI sequences support in your command prompt. + +If you see this message when you use third-party command prompts, please add +-force_ansi argument, otherwise, add -compat_aware. +Learn more: +https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences + +Log lines that have custom color for log level will be fully painted. +***************************************************************************** +]] + ); + end + end + end + end + evtp_start(); elseif package.config:sub(1,1) == "/" then prosody.platform = "posix"; end
