Skip to content

Commit

Permalink
manager: support clear command
Browse files Browse the repository at this point in the history
  • Loading branch information
Admirepowered committed Jan 7, 2025
1 parent dc1ea97 commit 6079a1c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import java.util.Locale
@Destination<RootGraph>
fun ExecuteAPMActionScreen(navigator: DestinationsNavigator, moduleId: String) {
var text by rememberSaveable { mutableStateOf("") }
var tempText : String
val logContent = rememberSaveable { StringBuilder() }
val snackBarHost = LocalSnackbarHost.current
val scope = rememberCoroutineScope()
Expand All @@ -63,7 +64,12 @@ fun ExecuteAPMActionScreen(navigator: DestinationsNavigator, moduleId: String) {
runAPModuleAction(
moduleId,
onStdout = {
text += "$it\n"
tempText = "$it\n"
if (tempText.startsWith("")) { // clear command
text = tempText.substring(6)
} else {
text += tempText
}
logContent.append(it).append("\n")
},
onStderr = {
Expand Down
15 changes: 13 additions & 2 deletions app/src/main/java/me/bmax/apatch/ui/screen/Install.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ enum class MODULE_TYPE {
@Destination<RootGraph>
fun InstallScreen(navigator: DestinationsNavigator, uri: Uri, type: MODULE_TYPE) {
var text by rememberSaveable { mutableStateOf("") }
var tempText : String
val logContent = rememberSaveable { StringBuilder() }
var showFloatAction by rememberSaveable { mutableStateOf(false) }

Expand All @@ -76,10 +77,20 @@ fun InstallScreen(navigator: DestinationsNavigator, uri: Uri, type: MODULE_TYPE)
showFloatAction = true
}
}, onStdout = {
text += "$it\n"
tempText = "$it\n"
if (tempText.startsWith("")) { // clear command
text = tempText.substring(6)
} else {
text += tempText
}
logContent.append(it).append("\n")
}, onStderr = {
text += "$it\n"
tempText = "$it\n"
if (tempText.startsWith("")) { // clear command
text = tempText.substring(6)
} else {
text += tempText
}
logContent.append(it).append("\n")
})
}
Expand Down

0 comments on commit 6079a1c

Please sign in to comment.