Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
54a74cc6
Commit
54a74cc6
authored
9 years ago
by
Etienne Kneuss
Browse files
Options
Downloads
Patches
Plain Diff
Allow ANSI escape codes within ASCII helpers
parent
d7391f63
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/leon/utils/ASCIIHelpers.scala
+16
-4
16 additions, 4 deletions
src/main/scala/leon/utils/ASCIIHelpers.scala
with
16 additions
and
4 deletions
src/main/scala/leon/utils/ASCIIHelpers.scala
+
16
−
4
View file @
54a74cc6
...
@@ -28,7 +28,7 @@ object ASCIIHelpers {
...
@@ -28,7 +28,7 @@ object ASCIIHelpers {
val
cols
=
constraints
.
getOrElse
(
k
,
1
)
val
cols
=
constraints
.
getOrElse
(
k
,
1
)
val
size
=
c
.
vString
.
leng
th
val
size
=
c
.
printableWid
th
constraints
+=
k
->
(
cols
max
size
)
constraints
+=
k
->
(
cols
max
size
)
...
@@ -86,13 +86,14 @@ object ASCIIHelpers {
...
@@ -86,13 +86,14 @@ object ASCIIHelpers {
if
(
i
>
0
)
{
if
(
i
>
0
)
{
sb
append
" "
sb
append
" "
}
}
val
size
=
(
i
to
i
+
c
.
spanning
-
1
).
map
(
colSizes
).
sum
+
(
c
.
spanning
-
1
)
*
2
val
size
=
(
i
to
i
+
c
.
spanning
-
1
).
map
(
colSizes
).
sum
+
(
c
.
spanning
-
1
)
*
2
if
(
size
>=
0
)
{
if
(
size
>=
0
)
{
if
(
c
.
align
==
Left
)
{
if
(
c
.
align
==
Left
)
{
sb
append
(
"%-"
+
size
+
"s"
).
format
(
c
.
vString
)
sb
append
(
"%-"
+
(
size
+
c
.
invisibleWidth
)+
"s"
).
format
(
c
.
vString
)
}
else
{
}
else
{
sb
append
(
"%"
+
size
+
"s"
).
format
(
c
.
vString
)
sb
append
(
"%"
+
(
size
+
c
.
invisibleWidth
)+
"s"
).
format
(
c
.
vString
)
}
}
}
else
{
}
else
{
sb
append
c
.
vString
sb
append
c
.
vString
...
@@ -122,7 +123,13 @@ object ASCIIHelpers {
...
@@ -122,7 +123,13 @@ object ASCIIHelpers {
case
class
Cell
(
v
:
Any
,
spanning
:
Int
=
1
,
align
:
Alignment
=
Left
)
{
case
class
Cell
(
v
:
Any
,
spanning
:
Int
=
1
,
align
:
Alignment
=
Left
)
{
require
(
spanning
>=
1
)
lazy
val
vString
=
v
.
toString
lazy
val
vString
=
v
.
toString
lazy
val
printableWidth
=
trimNonPrintable
(
vString
).
length
lazy
val
fullWidth
=
vString
.
length
lazy
val
invisibleWidth
=
fullWidth
-
printableWidth
}
}
def
title
(
str
:
String
,
width
:
Int
=
80
)
:
String
=
{
def
title
(
str
:
String
,
width
:
Int
=
80
)
:
String
=
{
...
@@ -135,8 +142,13 @@ object ASCIIHelpers {
...
@@ -135,8 +142,13 @@ object ASCIIHelpers {
def
line
(
str
:
String
,
sep
:
String
,
width
:
Int
=
80
)
:
String
=
{
def
line
(
str
:
String
,
sep
:
String
,
width
:
Int
=
80
)
:
String
=
{
val
middle
=
" "
+
str
+
" "
val
middle
=
" "
+
str
+
" "
val
remSize
=
width
-
middle
.
length
val
middlePrintable
=
trimNonPrintable
(
middle
)
val
remSize
=
width
-
middlePrintable
.
length
sep
*
math
.
floor
(
remSize
/
2
).
toInt
+
middle
+
sep
*
math
.
ceil
(
remSize
/
2
).
toInt
sep
*
math
.
floor
(
remSize
/
2
).
toInt
+
middle
+
sep
*
math
.
ceil
(
remSize
/
2
).
toInt
}
}
def
trimNonPrintable
(
str
:
String
)
:
String
=
{
str
.
replaceAll
(
"\u001b\\[[0-9;]*m"
,
""
)
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment