Skip to content

Commit

Permalink
Added support for non-visible chars to CPAsciiTable + some bug fixes.…
Browse files Browse the repository at this point in the history
… 0.9.2 release.
  • Loading branch information
nivanov committed Jul 22, 2023
1 parent 96f6b9c commit c786966
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ Prerequisites:

Using SBT:
```scala
libraryDependencies += "org.cosplayengine" % "cosplay" % "0.9.1"
libraryDependencies += "org.cosplayengine" % "cosplay" % "0.9.2"
```
Using [Maven](https://mvnrepository.com/artifact/org.cosplayengine/cosplay):
```xml
<dependency>
<groupId>org.cosplayengine</groupId>
<artifactId>cosplay</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
All rights reserved.
*/

val cosPlayVer = "0.9.1"
val cosPlayVer = "0.9.2"

val scalaMajVer = "3"
val scalaMinVer = "3.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/cosplay/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>org.cosplayengine</groupId>
<artifactId>cosplay-parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
5 changes: 0 additions & 5 deletions modules/cosplay/src/main/scala/org/cosplay/CPAsciiTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,6 @@ class CPAsciiTable:
// Top margin.
for _ <- 0 until margin.top do tbl ++= " \n"

/**
*
* @param crs
* @param cor
*/
def mkAsciiLine(crs: String, cor: String): String =
s"${space(margin.left)}$crs${dash(cor, tableW)}$crs${space(margin.right)}\n"

Expand Down
5 changes: 3 additions & 2 deletions modules/cosplay/src/main/scala/org/cosplay/CPEngine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ extension[T](t: T)
def seq: Seq[T] = Seq(t)

extension(s: String)
def isVis(ch: Char): Boolean = ch == '\n' || ch == '\t' || !ch.isControl
/** Length of the string taking into account printable characters only. */
inline def visLength: Int = s.count(!_.isControl)
inline def visLength: Int = s.count(isVis)
/** String with all non-printable characters removed. */
inline def visOnly: String = s.filter(!_.isControl)
inline def visOnly: String = s.filter(isVis)

extension[R, T](opt: Option[T])
@targetName("optEqual")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ object CPVersion:
Version("0.8.10", LocalDate.of(2023, 4, 30)),
Version("0.9.0", LocalDate.of(2023, 6, 18)),
Version("0.9.1", LocalDate.of(2023, 6, 19)),
Version("0.9.2", LocalDate.of(2023, 7, 22)),
).sortBy(_.semver)
// +==================================================+
// | UPDATE ABOVE SEQUENCE FOR EACH RELEASE MANUALLY. |
Expand Down
14 changes: 10 additions & 4 deletions modules/cosplay/src/test/scala/org/cosplay/CPAsciiTableTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ object CPAsciiTableTests:
def visLengthTest(): Unit =
val s = s"$c"
assertTrue(s.visLength == 0)
val s1 = s"ab$c${c}ef$c"
assertTrue(s1.visLength == 4)
assertTrue(s1.visOnly == "abef")
val s1 = s"ab$c${c}ef$c\n"
println(
"""ab$c${c}ef$c""" + "='" + s1 + "'"
)
println(
"""ab$c${c}ef$c""" + "='" + s1.visOnly + "'"
)
assertTrue(s1.visLength == 5)
assertTrue(s1.visOnly == "abef\n")
val s2 = s"$c "
assertTrue(s2.visLength == 1)

Expand All @@ -55,4 +61,4 @@ object CPAsciiTableTests:
tbl += ("Cell 1.1", "Cell 1.2", s"Cell $c 1.3")
tbl.addSeparator()
tbl += (s"Cell $c$c$c$c$c$c${c}2.1", "Cell 2.2", "Cell 2.3")
println(tbl.toString)
println(tbl.toString.visOnly)
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<name>CosPlay Parent</name>
<groupId>org.cosplayengine</groupId>
<artifactId>cosplay-parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
<packaging>pom</packaging>
<description>An open-source 2D ASCII game engine for Scala3</description>
<url>https://github.com/nivanov/cosplay</url>
Expand Down

0 comments on commit c786966

Please sign in to comment.