@@ -56,8 +56,12 @@ class TextEditorActivity : AppCompatActivity() {
5656 " py" to " python"
5757 )
5858
59- // Cho phép dòng đầu tiên của nội dung khai báo ngôn ngữ thực tế của file,
60- // ví dụ "# python" hoặc "#!/usr/bin/env python", bất kể phần mở rộng file là gì.
59+ // Cho phép dòng đầu tiên của nội dung khai báo ngôn ngữ thực tế của file, ví dụ:
60+ // "# python", "#!/usr/bin/env python", hoặc shebang trỏ tới binary Termux
61+ // được bundle riêng trong thư mục dữ liệu của app (com.tool.tree), ví dụ:
62+ // #!/data/data/com.tool.tree/files/home/termux/bin/python
63+ // #!/data/data/com.tool.tree/files/home/bin/bash
64+ // (vẫn hỗ trợ cả dạng /data/user/<id>/... phòng khi thiết bị multi-user)
6165 private val FIRST_LINE_LANG_PATTERN = Regex (
6266 """ ^#!?\s*(?:/usr/bin/env\s+)?(?:/data/(?:data|user/\d+)/com\.tool\.tree/\S*/)?(python3?|py|bash|sh|shell)\b""" ,
6367 RegexOption .IGNORE_CASE
@@ -103,6 +107,7 @@ class TextEditorActivity : AppCompatActivity() {
103107 private var mainListBaseBottomMargin = 0
104108 private var syntaxHighlighter: SyntaxHighlighter ? = null
105109 private var placeholderText: String = " "
110+ private var titleText: String = " "
106111 private var lastLanguageOverride: String? = null
107112
108113 private data class EditorSnapshot (val text : String , val cursor : Int )
@@ -146,6 +151,7 @@ class TextEditorActivity : AppCompatActivity() {
146151 absoluteFilePath = resolveAbsolutePath(configDir, filePath)
147152 wrapEnabled = intent.getBooleanExtra(EXTRA_WRAP , true )
148153 placeholderText = intent.getStringExtra(EXTRA_PLACEHOLDER ).orEmpty()
154+ titleText = intent.getStringExtra(EXTRA_TITLE ).orEmpty()
149155
150156 applyWrapState()
151157 setupCursorAutoScroll()
@@ -639,7 +645,7 @@ class TextEditorActivity : AppCompatActivity() {
639645
640646 private fun runScript (interpreter : String ) {
641647 val runNode = ActionNode (absoluteFilePath).apply {
642- title = File (absoluteFilePath).name
648+ title = titleText.ifEmpty { File (absoluteFilePath).name }
643649 interruptable = true
644650 shell = RunnableNode .shellModeDefault
645651 }
@@ -654,4 +660,4 @@ class TextEditorActivity : AppCompatActivity() {
654660 ).apply { isCancelable = false }
655661 .show(supportFragmentManager, " editor-run-test" )
656662 }
657- }
663+ }
0 commit comments