extend regex, up version, fix enter on android tv

This commit is contained in:
2026-08-09 12:33:01 +03:00
parent 01c197379a
commit 009e25b846
3 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ plugins {
alias(libs.plugins.convention.ktor.client)
}
val appVersion = "1.25.2"
val appVersion = "1.25.3"
android {
buildFeatures { buildConfig = true }
@@ -6,7 +6,7 @@ import ru.shadowsparky.chat.domain.TextToken
@Factory
class MovieTextParser : ChatTextParser {
private val regex = Regex("«(.*?)»|\"(.*?)\"")
private val regex = Regex("«(.*?)»|\"(.*?)\"|\\*\\*(.*?)\\*\\*")
override fun parse(content: String): List<TextToken> {
val tokens = mutableListOf<TextToken>()
@@ -16,11 +16,11 @@ class MovieTextParser : ChatTextParser {
tokens.add(TextToken.Plain(content.substring(lastIndex, matchResult.range.first)))
}
val movieTitle = matchResult.groupValues[1].takeIf { it.isNotEmpty() }
?: matchResult.groupValues[2]
tokens.add(TextToken.Link(text = movieTitle))
?: matchResult.groupValues[2].takeIf { it.isNotEmpty() }
?: matchResult.groupValues[3]
tokens.add(TextToken.Link(movieTitle))
lastIndex = matchResult.range.last + 1
}
if (lastIndex < content.length) {
tokens.add(TextToken.Plain(content.substring(lastIndex)))
}
@@ -247,7 +247,8 @@ private fun MessageBubble(
boxModifier = boxModifier.focusBorder(false).onKeyEvent {
if (it.type == KeyEventType.KeyDown) {
when (it.key) {
Key.Enter -> dialog = true
Key.Enter,
Key.DirectionCenter -> dialog = true
else -> onKeyEvent(it)
}
}
@@ -362,7 +363,7 @@ private fun ScrollableMessage(
true
}
Key.Enter -> {
Key.Enter, Key.DirectionCenter -> {
onEnter()
true
}