Skip to content

Commit 27639a4

Browse files
committed
feat:codeView添加TryBlock标志
1 parent 137e16a commit 27639a4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/main/kotlin/me/yricky/abcde/page/CodeView.kt

+18-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import androidx.compose.foundation.shape.RoundedCornerShape
88
import androidx.compose.foundation.text.selection.DisableSelection
99
import androidx.compose.foundation.text.selection.SelectionContainer
1010
import androidx.compose.material3.*
11-
import androidx.compose.runtime.Composable
12-
import androidx.compose.runtime.CompositionLocalProvider
13-
import androidx.compose.runtime.remember
11+
import androidx.compose.runtime.*
1412
import androidx.compose.ui.Alignment
1513
import androidx.compose.ui.Modifier
1614
import androidx.compose.ui.draw.alpha
15+
import androidx.compose.ui.draw.clip
1716
import androidx.compose.ui.graphics.Color
1817
import androidx.compose.ui.platform.LocalClipboardManager
1918
import androidx.compose.ui.text.*
@@ -23,6 +22,7 @@ import androidx.compose.ui.unit.dp
2322
import me.yricky.abcde.ui.*
2423
import me.yricky.oh.abcd.cfm.AbcMethod
2524
import me.yricky.oh.abcd.code.Code
25+
import me.yricky.oh.abcd.code.TryBlock
2626

2727
val CODE_FONT = FontFamily(Font("fonts/jbMono/JetBrainsMono-Regular.ttf"))
2828
val commentColor = Color(0xff72737a)
@@ -42,24 +42,29 @@ fun CodeViewPage(modifier: Modifier, method: AbcMethod, code: Code?) {
4242
} to composeContent{
4343
Column(Modifier.fillMaxSize()) {
4444

45-
Text("寄存器数量:${code.numVRegs}, 参数数量:${code.numArgs}, 指令字节数:${code.codeSize}",modifier = Modifier.padding(horizontal = 4.dp))
45+
Text("寄存器数量:${code.numVRegs}, 参数数量:${code.numArgs}, 指令字节数:${code.codeSize}, TryCatch数:${code.triesSize}",modifier = Modifier.padding(horizontal = 4.dp))
4646
CompositionLocalProvider(
4747
LocalScrollbarStyle provides LocalScrollbarStyle.current.copy(
4848
unhoverColor = MaterialTheme.colorScheme.tertiary.copy(alpha = 0.2f),
4949
hoverColor = MaterialTheme.colorScheme.tertiary
5050
)
5151
){
5252
Box(Modifier.fillMaxWidth().weight(1f).padding(4.dp)
53+
.clip(RoundedCornerShape(8.dp))
5354
.border(2.dp,MaterialTheme.colorScheme.primaryContainer, RoundedCornerShape(8.dp))
5455
.padding(8.dp)
5556
) {
5657
SelectionContainer {
58+
var tryBlock by remember {
59+
mutableStateOf<TryBlock?>(null)
60+
}
5761
LazyColumnWithScrollBar {
5862
item {
5963
Text(method.defineStr(true), style = codeStyle)
6064
}
6165
itemsIndexed(code.asm.list){index,it ->
6266
Row {
67+
it.asm
6368
DisableSelection {
6469
val line = remember {
6570
"$index ".let {
@@ -69,7 +74,15 @@ fun CodeViewPage(modifier: Modifier, method: AbcMethod, code: Code?) {
6974
Text(line, style = codeStyle)
7075
}
7176
DisableSelection {
72-
Text(String.format("%04X ",it.codeOffset), style = codeStyle.copy(color = commentColor))
77+
Text(
78+
String.format("%04X ",it.codeOffset),
79+
style = codeStyle.copy(color = commentColor),
80+
modifier = with(Modifier){
81+
if(it.tryBlock != null){
82+
border(1.dp,Color.Yellow)
83+
}else this
84+
}
85+
)
7386
}
7487
TooltipArea(tooltip = {
7588
DisableSelection {

0 commit comments

Comments
 (0)