mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
Compare commits
5 Commits
2.0.0-beta
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de7a7c93b8 | ||
|
|
fcec30d70a | ||
|
|
f6dc0098f7 | ||
|
|
ca7b30bdb0 | ||
|
|
f73e7f4214 |
@@ -16,7 +16,7 @@ commons-vfs2 = "2.10.0"
|
||||
swingx = "1.6.5-1"
|
||||
jgoodies-forms = "1.9.0"
|
||||
jfa = "1.2.0"
|
||||
oshi = "6.8.1"
|
||||
oshi = "6.9.0"
|
||||
versioncompare = "1.4.1"
|
||||
jna = "5.17.0"
|
||||
jSystemThemeDetector = "3.9.1"
|
||||
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
|
||||
|
||||
|
||||
project.version = "0.0.7"
|
||||
project.version = "0.0.8"
|
||||
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package app.termora.plugins.editor
|
||||
|
||||
import app.termora.DocumentAdaptor
|
||||
import app.termora.DynamicColor
|
||||
import app.termora.EnableManager
|
||||
import app.termora.Icons
|
||||
import app.termora.*
|
||||
import app.termora.database.DatabaseManager
|
||||
import com.formdev.flatlaf.FlatLaf
|
||||
import com.formdev.flatlaf.extras.components.FlatTextField
|
||||
@@ -39,6 +36,10 @@ class EditorPanel(private val window: JFrame, private val file: File) : JPanel(B
|
||||
|
||||
companion object {
|
||||
private val log = LoggerFactory.getLogger(EditorPanel::class.java)
|
||||
private val saveIcon = DynamicIcon(
|
||||
"icons/save.svg", "icons/save_dark.svg",
|
||||
loader = EditorPlugin::class.java.classLoader
|
||||
)
|
||||
}
|
||||
|
||||
private var text = file.readText(Charsets.UTF_8)
|
||||
@@ -54,6 +55,7 @@ class EditorPanel(private val window: JFrame, private val file: File) : JPanel(B
|
||||
private val prevBtn = JButton(Icons.up)
|
||||
private val context = SearchContext()
|
||||
private val softWrapBtn = JToggleButton(Icons.softWrap)
|
||||
private val saveBtn = JButton(saveIcon)
|
||||
private val scrollUpBtn = JButton(Icons.scrollUp)
|
||||
private val scrollEndBtn = JButton(Icons.scrollDown)
|
||||
private val prettyBtn = JButton(Icons.reformatCode)
|
||||
@@ -141,11 +143,18 @@ class EditorPanel(private val window: JFrame, private val file: File) : JPanel(B
|
||||
)
|
||||
|
||||
toolbar.orientation = VERTICAL
|
||||
toolbar.add(saveBtn)
|
||||
toolbar.add(scrollUpBtn)
|
||||
toolbar.add(prettyBtn)
|
||||
toolbar.add(softWrapBtn)
|
||||
toolbar.add(scrollEndBtn)
|
||||
|
||||
saveBtn.toolTipText = EditorI18n.getString("termora.plugins.editor.save")
|
||||
scrollUpBtn.toolTipText = EditorI18n.getString("termora.plugins.editor.first-line")
|
||||
scrollEndBtn.toolTipText = EditorI18n.getString("termora.plugins.editor.last-line")
|
||||
softWrapBtn.toolTipText = EditorI18n.getString("termora.plugins.editor.soft-wrap")
|
||||
prettyBtn.toolTipText = EditorI18n.getString("termora.plugins.editor.format")
|
||||
|
||||
val viewPanel = JPanel(BorderLayout())
|
||||
viewPanel.add(scrollPane, BorderLayout.CENTER)
|
||||
viewPanel.add(toolbar, BorderLayout.EAST)
|
||||
@@ -211,6 +220,8 @@ class EditorPanel(private val window: JFrame, private val file: File) : JPanel(B
|
||||
}
|
||||
})
|
||||
|
||||
saveBtn.addActionListener(textArea.actionMap.get("Save"))
|
||||
|
||||
textArea.actionMap.put("Format", object : AbstractAction() {
|
||||
override fun actionPerformed(e: ActionEvent) {
|
||||
format()
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
termora.plugins.editor.not-save=The file has not been saved. Are you sure you want to exit?
|
||||
|
||||
termora.plugins.editor.save=Save
|
||||
termora.plugins.editor.first-line=Jump to first line
|
||||
termora.plugins.editor.last-line=Jump to last line
|
||||
termora.plugins.editor.soft-wrap=Soft-wrap
|
||||
termora.plugins.editor.format=Format
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
termora.plugins.editor.not-save=Файл не сохранён. Вы уверены, что хотите выйти?
|
||||
termora.plugins.editor.not-save=Файл не сохранён. Вы уверены, что хотите выйти?
|
||||
termora.plugins.editor.save=Сохранить
|
||||
termora.plugins.editor.first-line=Перейти на первую строку
|
||||
termora.plugins.editor.last-line=Перейти на последнюю строку
|
||||
termora.plugins.editor.soft-wrap=Мягкий перенос
|
||||
termora.plugins.editor.format=Формат
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
termora.plugins.editor.not-save=文件尚未保存,你确定要退出吗?
|
||||
termora.plugins.editor.save=保存
|
||||
termora.plugins.editor.first-line=跳转到第一行
|
||||
termora.plugins.editor.last-line=跳转到最后一行
|
||||
termora.plugins.editor.soft-wrap=自动换行
|
||||
termora.plugins.editor.format=格式化
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
termora.plugins.editor.not-save=檔案尚未儲存,你確定要退出嗎?
|
||||
termora.plugins.editor.not-save=檔案尚未儲存,你確定要退出嗎?
|
||||
termora.plugins.editor.save=儲存
|
||||
termora.plugins.editor.first-line=跳到第一行
|
||||
termora.plugins.editor.last-line=跳到最後一行
|
||||
termora.plugins.editor.soft-wrap=自動換行
|
||||
termora.plugins.editor.format=格式化
|
||||
|
||||
4
plugins/editor/src/main/resources/icons/save.svg
Normal file
4
plugins/editor/src/main/resources/icons/save.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M5.5 3V5.5H10.5V3M4.5 13V9.5H11.5V13M2.5 13.5V2.5H11.5L13.5 4.5V13.5H2.5Z" stroke="#6C707E" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 357 B |
4
plugins/editor/src/main/resources/icons/save_dark.svg
Normal file
4
plugins/editor/src/main/resources/icons/save_dark.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M5.5 3V5.5H10.5V3M4.5 13V9.5H11.5V13M2.5 13.5V2.5H11.5L13.5 4.5V13.5H2.5Z" stroke="#CED0D6" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 357 B |
@@ -9,7 +9,7 @@ dependencies {
|
||||
implementation("com.aliyun.oss:aliyun-sdk-oss:3.18.3")
|
||||
implementation("javax.xml.bind:jaxb-api:2.3.1")
|
||||
implementation("javax.activation:activation:1.1.1")
|
||||
implementation("org.glassfish.jaxb:jaxb-runtime:2.3.3")
|
||||
implementation("org.glassfish.jaxb:jaxb-runtime:4.0.6")
|
||||
compileOnly(project(":"))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package app.termora.terminal
|
||||
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
open class SelectionModelImpl(private val terminal: Terminal) : SelectionModel {
|
||||
|
||||
private var startPosition = Position.unknown
|
||||
private var endPosition = Position.unknown
|
||||
private var block = false
|
||||
private val document = terminal.getDocument()
|
||||
|
||||
internal companion object {
|
||||
private val log = LoggerFactory.getLogger(SelectionModelImpl::class.java)
|
||||
|
||||
fun isPointInsideArea(start: Position, end: Position, x: Int, y: Int, cols: Int): Boolean {
|
||||
val top = min(start.y, end.y)
|
||||
val bottom = max(start.y, end.y)
|
||||
@@ -49,7 +53,13 @@ open class SelectionModelImpl(private val terminal: Terminal) : SelectionModel {
|
||||
}
|
||||
|
||||
// 设置新的选择区域
|
||||
setSelection(startPosition, endPosition)
|
||||
try {
|
||||
setSelection(startPosition, endPosition)
|
||||
} catch (e: Exception) {
|
||||
if (log.isTraceEnabled) {
|
||||
log.trace(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,26 @@ class NewHostTree : SimpleTree(), Disposable {
|
||||
}
|
||||
})
|
||||
|
||||
// 开启 ToolTip 功能
|
||||
ToolTipManager.sharedInstance().registerComponent(this)
|
||||
|
||||
// 设置鼠标移动提示
|
||||
addMouseMotionListener(object : java.awt.event.MouseMotionAdapter() {
|
||||
override fun mouseMoved(e: MouseEvent) {
|
||||
val path: TreePath? = getPathForLocation(e.x, e.y)
|
||||
if (path != null) {
|
||||
val node: HostTreeNode = path.lastPathComponent as HostTreeNode
|
||||
if (node.host.remark.isNotEmpty()){
|
||||
toolTipText = node.host.remark
|
||||
}else{
|
||||
toolTipText = null
|
||||
}
|
||||
} else {
|
||||
toolTipText = null
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
actionMap.put("copy", object : AnAction() {
|
||||
override fun actionPerformed(evt: AnActionEvent) {
|
||||
toolkit.systemClipboard.setContents(StringSelection(StringUtils.EMPTY), null)
|
||||
@@ -193,6 +213,9 @@ class NewHostTree : SimpleTree(), Disposable {
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
// 销毁
|
||||
ToolTipManager.sharedInstance().unregisterComponent(this)
|
||||
|
||||
val name = super.getName()
|
||||
if (name.isNullOrBlank().not()) {
|
||||
properties.putString("${name}.state", TreeUtils.saveExpansionState(this))
|
||||
@@ -1151,4 +1174,4 @@ class NewHostTree : SimpleTree(), Disposable {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user