Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
284ec069
Commit
284ec069
authored
Jun 25, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented ANSI strlen helper
issue #746
parent
708e6646
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
BaseConsole.php
framework/helpers/BaseConsole.php
+11
-2
No files found.
framework/helpers/BaseConsole.php
View file @
284ec069
...
...
@@ -330,6 +330,15 @@ class BaseConsole
}
/**
* Returns the length of the string without ANSI color codes.
* @param string $string the string to measure
* @return int the length of the string not counting ANSI format characters
*/
public
static
function
ansiStrlen
(
$string
)
{
return
mb_strlen
(
static
::
stripAnsiFormat
(
$string
));
}
/**
* Converts an ANSI formatted string to HTML
*
* Note: xTerm 256 bit colors are currently not supported.
...
...
@@ -876,7 +885,7 @@ class BaseConsole
}
else
{
self
::
$_progressPrefix
=
$prefix
;
}
$width
-=
mb_s
trlen
(
$prefix
);
$width
-=
static
::
ansiS
trlen
(
$prefix
);
$percent
=
(
$total
==
0
)
?
1
:
$done
/
$total
;
$info
=
sprintf
(
"%d%% (%d/%d)"
,
$percent
*
100
,
$done
,
$total
);
...
...
@@ -888,7 +897,7 @@ class BaseConsole
$info
.=
sprintf
(
' ETA: %d sec.'
,
$rate
*
(
$total
-
$done
));
}
$width
-=
3
+
mb_s
trlen
(
$info
);
$width
-=
3
+
static
::
ansiS
trlen
(
$info
);
// skipping progress bar on very small display or if forced to skip
if
(
$width
<
5
)
{
static
::
stdout
(
"
\r
$prefix$info
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment