Skip to content

Commit de652f7

Browse files
committed
feat(devti): enhance file list UI and functionality #344
- Extract file name from path for display - Add hover effects and cursor change on file label - Implement bottom scrolling in SketchToolWindow
1 parent cf0ec0c commit de652f7

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/SketchToolWindow.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ open class SketchToolWindow(
334334
myList.revalidate()
335335
myList.repaint()
336336
}
337+
338+
scrollToBottom()
337339
}
338340

339341
fun createRenderSketch(code: CodeFence): JComponent? {

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/patch/SingleFileDiffSketch.kt

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,38 @@ class SingleFileDiffSketch(
7474
this@SingleFileDiffSketch.appliedPatch,
7575
this@SingleFileDiffSketch.patch
7676
)
77-
val filepathLabel = JBLabel(currentFile.name).apply {
77+
78+
val fileName = if (currentFile.name.contains("/")) {
79+
currentFile.name.substringAfterLast("/")
80+
} else {
81+
currentFile.name
82+
}
83+
84+
val filepathLabel = JBLabel(fileName).apply {
7885
icon = currentFile.fileType.icon
7986
border = BorderFactory.createEmptyBorder(2, 10, 2, 10)
80-
87+
88+
val originalColor = foreground
89+
val hoverColor = JBColor(0x4A7EB3, 0x589DF6) // Blue color for hover state
90+
8191
addMouseListener(object : MouseAdapter() {
8292
override fun mouseClicked(e: MouseEvent?) {
8393
FileEditorManager.getInstance(myProject).openFile(currentFile, true)
8494
}
85-
86-
override fun mouseEntered(e: MouseEvent) {
87-
patchActionPanel?.background = JBColor(DarculaColors.BLUE, DarculaColors.BLUE)
95+
96+
override fun mouseEntered(e: MouseEvent?) {
97+
foreground = hoverColor
98+
cursor = java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR)
99+
border = BorderFactory.createCompoundBorder(
100+
BorderFactory.createMatteBorder(0, 0, 1, 0, hoverColor),
101+
BorderFactory.createEmptyBorder(2, 10, 1, 10)
102+
)
88103
}
89-
90-
override fun mouseExited(e: MouseEvent) {
91-
patchActionPanel?.background = JBColor.PanelBackground
104+
105+
override fun mouseExited(e: MouseEvent?) {
106+
foreground = originalColor
107+
cursor = java.awt.Cursor.getDefaultCursor()
108+
border = BorderFactory.createEmptyBorder(2, 10, 2, 10)
92109
}
93110
})
94111
}
@@ -337,4 +354,4 @@ fun saveText(file: VirtualFile, text: String) {
337354
stream.write(text.toByteArray(charset))
338355
}
339356
}
340-
}
357+
}

0 commit comments

Comments
 (0)