mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Use ColorCLI in tmux panes
This commit is contained in:
@@ -149,4 +149,28 @@ class ColorCLI
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply ANSI color code to a string and return it (does not render)
|
||||
*
|
||||
* @param string $string The string to colorize
|
||||
* @param string $color The color name
|
||||
* @return string The colored string with ANSI codes
|
||||
*/
|
||||
public function ansiString(string $string, string $color): string
|
||||
{
|
||||
$colors = [
|
||||
'black' => '0;30',
|
||||
'red' => '0;31',
|
||||
'green' => '0;32',
|
||||
'yellow' => '0;33',
|
||||
'blue' => '0;34',
|
||||
'magenta' => '0;35',
|
||||
'cyan' => '0;36',
|
||||
'white' => '0;37',
|
||||
];
|
||||
|
||||
$code = $colors[$color] ?? '0;37';
|
||||
return "\033[{$code}m{$string}\033[0m";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,8 +481,8 @@ class TmuxOutput extends Tmux
|
||||
['Slow', '/.*\bSlow[^:]*?: (\d+)\b.*/'],
|
||||
['QPS', '/.*\bQueries[^:]*?: (\d+)\b.*/'],
|
||||
] as $v) {
|
||||
$pieces[] = color($v[0].' = ')->green.
|
||||
color(preg_replace($v[1], '$1', $info))->yellow;
|
||||
$pieces[] = $this->colorCli->ansiString($v[0].' = ', 'green').
|
||||
$this->colorCli->ansiString(preg_replace($v[1], '$1', $info), 'yellow');
|
||||
}
|
||||
$buffer .= PHP_EOL.implode(', ', $pieces).PHP_EOL;
|
||||
|
||||
@@ -515,11 +515,11 @@ class TmuxOutput extends Tmux
|
||||
|
||||
protected function _setColourMasks(): void
|
||||
{
|
||||
$this->_colourMasks[1] = color('%-18s')->yellow.' '.color('%-60.60s')->yellow->dark.PHP_EOL;
|
||||
$this->_colourMasks['2.0'] = color('%-20s')->magenta->dark.' '.color('%-33.33s')->yellow->dark.PHP_EOL;
|
||||
$this->_colourMasks['2.1'] = color('%-20s')->yellow.' '.color('%-33.33s')->yellow->dark.PHP_EOL;
|
||||
$this->_colourMasks[3] = color('%-16.16s %25.25s %25.25s')->yellow.PHP_EOL;
|
||||
$this->_colourMasks[4] = color('%-16.16s')->green.' '.color('%25.25s %25.25s')->yellow->dark.PHP_EOL;
|
||||
$this->_colourMasks[5] = color('%-16.16s %25.25s %25.25s')->yellow->dark.PHP_EOL;
|
||||
$this->_colourMasks[1] = $this->colorCli->ansiString('%-18s', 'yellow').' '.$this->colorCli->ansiString('%-60.60s', 'yellow').PHP_EOL;
|
||||
$this->_colourMasks['2.0'] = $this->colorCli->ansiString('%-20s', 'magenta').' '.$this->colorCli->ansiString('%-33.33s', 'yellow').PHP_EOL;
|
||||
$this->_colourMasks['2.1'] = $this->colorCli->ansiString('%-20s', 'yellow').' '.$this->colorCli->ansiString('%-33.33s', 'yellow').PHP_EOL;
|
||||
$this->_colourMasks[3] = $this->colorCli->ansiString('%-16.16s %25.25s %25.25s', 'yellow').PHP_EOL;
|
||||
$this->_colourMasks[4] = $this->colorCli->ansiString('%-16.16s', 'green').' '.$this->colorCli->ansiString('%25.25s %25.25s', 'yellow').PHP_EOL;
|
||||
$this->_colourMasks[5] = $this->colorCli->ansiString('%-16.16s %25.25s %25.25s', 'yellow').PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ use App\Models\Release;
|
||||
use Blacklight\NZB;
|
||||
use Blacklight\utility\Utility;
|
||||
use Blacklight\XXX;
|
||||
use Colors\Color;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
use GuzzleHttp\Cookie\SetCookie;
|
||||
@@ -147,13 +146,6 @@ if (! function_exists('getSimilarName')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('color')) {
|
||||
function color(string $string = ''): Color
|
||||
{
|
||||
return new Color($string);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('human_filesize')) {
|
||||
/**
|
||||
* @param int $decimals
|
||||
|
||||
@@ -63,7 +63,6 @@
|
||||
"imdbphp/imdbphp": "^8.3",
|
||||
"intervention/image": "^3.11",
|
||||
"jrean/laravel-user-verification": "^13.0",
|
||||
"kevinlebrun/colors.php": "^1.0",
|
||||
"laravel/framework": "^12.28",
|
||||
"laravel/horizon": "^5.31",
|
||||
"laravel/pulse": "^1.4",
|
||||
@@ -136,10 +135,6 @@
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/DariusIII/Net_NNTP"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/DariusIII/html"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/DariusIII/tmdbapi"
|
||||
|
||||
Generated
+1
-56
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "6eaa140f91ed2bbcc198d0d60b7a95cc",
|
||||
"content-hash": "32b40f0d4ebbdcc3116e8bfd91316751",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aharen/omdbapi",
|
||||
@@ -2933,61 +2933,6 @@
|
||||
},
|
||||
"time": "2025-04-22T19:38:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "kevinlebrun/colors.php",
|
||||
"version": "1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/kevinlebrun/colors.php.git",
|
||||
"reference": "cdda5eee41314b87cd5a8bb91b1ffc7c0210e673"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/kevinlebrun/colors.php/zipball/cdda5eee41314b87cd5a8bb91b1ffc7c0210e673",
|
||||
"reference": "cdda5eee41314b87cd5a8bb91b1ffc7c0210e673",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "3.7.*",
|
||||
"satooshi/php-coveralls": "1.0.*",
|
||||
"squizlabs/php_codesniffer": "1.*"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Colors": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kevin Le Brun",
|
||||
"email": "lebrun.k@gmail.com",
|
||||
"homepage": "http://kevinlebrun.fr",
|
||||
"role": "developer"
|
||||
}
|
||||
],
|
||||
"description": "Colors for PHP CLI scripts",
|
||||
"homepage": "https://github.com/kevinlebrun/colors.php",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"color",
|
||||
"colors",
|
||||
"console",
|
||||
"shell"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/kevinlebrun/colors.php/issues",
|
||||
"source": "https://github.com/kevinlebrun/colors.php/tree/master"
|
||||
},
|
||||
"time": "2018-05-30T08:34:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "khill/php-duration",
|
||||
"version": "1.1.0",
|
||||
|
||||
Reference in New Issue
Block a user