Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Update highlights to 1.0.0 and use new async API #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Designed annotated string persistence
  • Loading branch information
tmaxxdd committed Nov 3, 2024
commit 32a5bf48072aa97fa52d215ca6962e0bc09b9007
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.TextUnitType
import calculateFieldPhraseUpdate
import dev.snipme.highlights.DefaultHighlightsResultListener
import dev.snipme.highlights.Highlights
Expand Down Expand Up @@ -71,10 +69,29 @@ fun CodeEditText(

TextField3(
modifier = modifier.fillMaxWidth(),
onValueChange = {
val fieldUpdate = it.calculateFieldPhraseUpdate(translateTabToSpaces)
currentText.value = fieldUpdate
onValueChange(fieldUpdate.text)
onValueChange = { change ->
// val fieldUpdate = it.calculateFieldPhraseUpdate(translateTabToSpaces)
if (change.text != currentText.value.text)
onValueChange(change.text)
currentText.value = change.copy(
annotatedString = buildAnnotatedString {
append(change.text)

currentText.value.annotatedString.spanStyles.forEach {
try {
if (it.start >= 0 && it.end > it.start && it.end <= change.text.length) {
addStyle(
it.item,
maxOf(it.start, 0),
minOf(it.end, change.text.length - 1)
)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
)
},
value = currentText.value,
enabled = enabled,
Expand Down Expand Up @@ -135,8 +152,6 @@ fun CodeEditTextSwiftUi(
)
}



TextField3(
modifier = modifier.fillMaxWidth(),
value = currentText.value,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.