aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2023-11-22 14:26:49 +0100
committerGitHub <noreply@github.com>2023-11-22 14:26:49 +0100
commitdd2a77f37504f81e09806e1c277451957ea455ac (patch)
tree9453880145ce14e14ccc2a9adcb09f7fbcf6b332 /src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
parentcebe991e0f997035e9e0be0f49fd460be20c5a20 (diff)
downloadskyhanni-dd2a77f37504f81e09806e1c277451957ea455ac.tar.gz
skyhanni-dd2a77f37504f81e09806e1c277451957ea455ac.tar.bz2
skyhanni-dd2a77f37504f81e09806e1c277451957ea455ac.zip
fishing profit tracker (#703)
Fishing Tracker #703
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index dd114d8fd..d5365703a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -36,14 +36,18 @@ object StringUtils {
return first + lowercase.substring(1)
}
- fun String.removeColor(): String {
+ private val formattingChars by lazy { "kmolnr".toCharArray() + "kmolnr".uppercase().toCharArray() }
+
+ fun String.removeColor(keepFormatting: Boolean = false): String {
val builder = StringBuilder(this.length)
var counter = 0
while (counter < this.length) {
if (this[counter] == 'ยง') {
- counter += 2
- continue
+ if (!keepFormatting || this[counter + 1] !in formattingChars) {
+ counter += 2
+ continue
+ }
}
builder.append(this[counter])
counter++
@@ -132,7 +136,6 @@ object StringUtils {
}
}
-
fun String.removeWordsAtEnd(i: Int) = split(" ").dropLast(i).joinToString(" ")
fun String.splitLines(width: Int): String {