20 Commits

Author SHA1 Message Date
Dylan K. Taylor
eedea4998b Terminal: Added write() and writeLine() to allow easily emitting Minecraft-formatted text to the console 2019-06-16 14:16:14 +01:00
Dylan K. Taylor
22d9260a3b remove unused import 2019-04-26 13:56:32 +01:00
Dylan K. Taylor
c2c210e25a Fixed --enable-ansi and --disable-ansi not being respected on threads
this causes some breakage to the behaviour of Terminal, and for that reason this is going on 4.0.

Terminal::hasFormattingCodes() will no longer auto-detect whether colour codes are supported.
2019-04-26 12:30:24 +01:00
Dylan K. Taylor
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
Dylan K. Taylor
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
Dylan K. Taylor
dd11bcaf11 Fixed #1979: logger colours don't show on other threads when classes are not inherited 2018-05-09 18:07:12 +01:00
Dylan K. Taylor
b445825467 TextFormat: Moved toANSI() to Terminal, close #1995
This also removes a cyclic dependency between TextFormat and Terminal, meaning that TextFormat is now standalone without any external dependencies.

This is also an API break. Beware all ye who wander here, master = bleeding-edge!
2018-02-11 19:11:51 +00:00
Dylan K. Taylor
c601816586 Terminal::hasFormattingCodes() workaround for STDOUT not being defined
#1979

This isn't a full solution because formatting codes are still not applied correctly if the calling thread doesn't inherit classes.
2018-01-30 10:54:04 +00:00
Dylan K. Taylor
4f8e4f0522
Add EOF newlines where missing (bulk) (#1836)
This should solve issues with people making GitHub PRs and having the web editor messing things up. GitHub Web Editor sucks :(
2017-12-20 11:56:36 +00:00
Dylan K. Taylor
bdee746e46 Automatically enable ANSI colours on Windows versions that support it
Note that stream_isatty() and sapi_windows_vt100_support() are ONLY defined on PHP 7.2, and the latter is only available on Windows.
2017-09-17 19:57:20 +01:00
Dylan K. Taylor
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
Dylan K. Taylor
9004417456 Fixed file headers (#255) 2017-01-13 16:57:05 +00:00
Shoghi Cervantes
554bfb4855 Added methods for adding custom names directly to items 2015-08-06 21:09:37 +02:00
Shoghi Cervantes
fe55023761 Better Terminal detection 2015-06-05 14:07:32 +02:00
Shoghi Cervantes
514ce0fb04 Fixed colors not being shown on windows :s 2015-04-20 17:55:49 +02:00
Shoghi Cervantes
f71cf1c749
Added Fallback formatting codes to Windows/Android 2015-04-11 17:27:20 +02:00
Shoghi Cervantes
2ae095a15a Fixed disable-ansi not working 2015-04-10 10:16:57 +02:00
Shoghi Cervantes
0aa9586a52 Packet crashes fixed :D 2015-04-09 20:44:04 +02:00
Shoghi Cervantes
f9361aa931
Use new colors in terminal 2015-03-15 18:32:36 +01:00
Shoghi Cervantes
b0f8c14640
Added Terminal class, Improved normal generator speed 2015-03-15 00:15:24 +01:00