FxTermuxTui 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fxtermuxtui-0.1.0/FxTermuxTui/Downloads.py +18 -0
- fxtermuxtui-0.1.0/FxTermuxTui/FxTermuxTui.py +398 -0
- fxtermuxtui-0.1.0/FxTermuxTui/__init__.py +0 -0
- fxtermuxtui-0.1.0/FxTermuxTui/base.py +24 -0
- fxtermuxtui-0.1.0/FxTermuxTui/files.py +11 -0
- fxtermuxtui-0.1.0/FxTermuxTui/popup.py +54 -0
- fxtermuxtui-0.1.0/FxTermuxTui/shell.py +11 -0
- fxtermuxtui-0.1.0/FxTermuxTui/web.py +11 -0
- fxtermuxtui-0.1.0/FxTermuxTui.egg-info/PKG-INFO +31 -0
- fxtermuxtui-0.1.0/FxTermuxTui.egg-info/SOURCES.txt +16 -0
- fxtermuxtui-0.1.0/FxTermuxTui.egg-info/dependency_links.txt +1 -0
- fxtermuxtui-0.1.0/FxTermuxTui.egg-info/entry_points.txt +2 -0
- fxtermuxtui-0.1.0/FxTermuxTui.egg-info/requires.txt +2 -0
- fxtermuxtui-0.1.0/FxTermuxTui.egg-info/top_level.txt +1 -0
- fxtermuxtui-0.1.0/LICENSE +21 -0
- fxtermuxtui-0.1.0/PKG-INFO +31 -0
- fxtermuxtui-0.1.0/pyproject.toml +17 -0
- fxtermuxtui-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from textual.widgets import Button
|
|
2
|
+
from textual.containers import Vertical
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def build_downloads_menu(panel: Vertical):
|
|
6
|
+
for child in panel.children:
|
|
7
|
+
child.remove()
|
|
8
|
+
items = [
|
|
9
|
+
("cargo", "cargo"),
|
|
10
|
+
("npm", "npm"),
|
|
11
|
+
("pip", "pip"),
|
|
12
|
+
("pkg", "pkg"),
|
|
13
|
+
("apt", "apt"),
|
|
14
|
+
]
|
|
15
|
+
for label, cmd_id in items:
|
|
16
|
+
panel.mount(Button(label, id=cmd_id))
|
|
17
|
+
panel.mount(Button("返回", id="back_downloads_root"))
|
|
18
|
+
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import asyncio
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
6
|
+
|
|
7
|
+
from textual.app import App, ComposeResult
|
|
8
|
+
from textual.widgets import Header, Button, Static
|
|
9
|
+
from textual.containers import Horizontal, Vertical
|
|
10
|
+
from textual import events
|
|
11
|
+
from textual_tty import Terminal
|
|
12
|
+
|
|
13
|
+
from FxTermuxTui.shell import build_shell_submenu
|
|
14
|
+
from FxTermuxTui.base import build_base_menu
|
|
15
|
+
from FxTermuxTui.files import build_files_menu
|
|
16
|
+
from FxTermuxTui.Downloads import build_downloads_menu
|
|
17
|
+
from FxTermuxTui.web import build_web_menu
|
|
18
|
+
from FxTermuxTui.popup import CmdInputScreen
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class RamBar(Static):
|
|
22
|
+
def __init__(self, bar_len: int = 12):
|
|
23
|
+
super().__init__("ram: --")
|
|
24
|
+
self.bar_len = bar_len
|
|
25
|
+
|
|
26
|
+
def refresh_ram(self):
|
|
27
|
+
try:
|
|
28
|
+
import psutil
|
|
29
|
+
mem = psutil.virtual_memory()
|
|
30
|
+
pct = mem.percent
|
|
31
|
+
used_gb = mem.used / (1024 ** 3)
|
|
32
|
+
total_gb = mem.total / (1024 ** 3)
|
|
33
|
+
except Exception:
|
|
34
|
+
self.update("[red]ram: unavailable[/]")
|
|
35
|
+
return
|
|
36
|
+
|
|
37
|
+
fill = int(self.bar_len * pct / 100)
|
|
38
|
+
bar = f"[green]{'█' * fill}[/][dim]{'░' * (self.bar_len - fill)}[/]"
|
|
39
|
+
self.update(f"{bar} {pct:.0f}% {used_gb:.1f}/{total_gb:.1f}g")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class FxTermuxTui(App):
|
|
43
|
+
TITLE = "FxTermuxTui"
|
|
44
|
+
CSS = """
|
|
45
|
+
Horizontal { height: 100%; }
|
|
46
|
+
Vertical#btn_panel {
|
|
47
|
+
width: 22;
|
|
48
|
+
height: 100%;
|
|
49
|
+
background: $surface;
|
|
50
|
+
border: solid $primary;
|
|
51
|
+
padding: 1;
|
|
52
|
+
}
|
|
53
|
+
#ram_top {
|
|
54
|
+
height: auto;
|
|
55
|
+
margin-bottom: 1;
|
|
56
|
+
}
|
|
57
|
+
#menu_container {
|
|
58
|
+
height: 1fr;
|
|
59
|
+
}
|
|
60
|
+
Terminal { width: 1fr; height: 100%; }
|
|
61
|
+
Button { margin: 1; }
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
SPEC = {
|
|
65
|
+
"apt": {
|
|
66
|
+
"remove": ("包名", "", "", ""),
|
|
67
|
+
"install": ("包名", "", "", ""),
|
|
68
|
+
"reinstall": ("包名", "", "", ""),
|
|
69
|
+
"show": ("包名", "", "", ""),
|
|
70
|
+
"search": ("关键词", "", "", ""),
|
|
71
|
+
"update": ("", "", "", ""),
|
|
72
|
+
"upgrade": ("", "", "", ""),
|
|
73
|
+
"full-upgrade": ("", "", "", ""),
|
|
74
|
+
"autoremove": ("", "", "", ""),
|
|
75
|
+
"clean": ("", "", "", ""),
|
|
76
|
+
"list": ("", "", "", ""),
|
|
77
|
+
},
|
|
78
|
+
"pkg": {
|
|
79
|
+
"uninstall": ("包名", "", "", ""),
|
|
80
|
+
"install": ("包名", "", "", ""),
|
|
81
|
+
"reinstall": ("包名", "", "", ""),
|
|
82
|
+
"show": ("包名", "", "", ""),
|
|
83
|
+
"search": ("关键词", "", "", ""),
|
|
84
|
+
"update": ("", "", "", ""),
|
|
85
|
+
"upgrade": ("", "", "", ""),
|
|
86
|
+
"full-upgrade": ("", "", "", ""),
|
|
87
|
+
"autoremove": ("", "", "", ""),
|
|
88
|
+
"clean": ("", "", "", ""),
|
|
89
|
+
"autoclean": ("", "", "", ""),
|
|
90
|
+
"list-all": ("", "", "", ""),
|
|
91
|
+
"list-installed": ("", "", "", ""),
|
|
92
|
+
},
|
|
93
|
+
"cargo": {
|
|
94
|
+
"update": ("包名(可选)", "", "", ""),
|
|
95
|
+
"search": ("关键词", "", "", ""),
|
|
96
|
+
"install": ("包名", "", "", ""),
|
|
97
|
+
"uninstall": ("包名", "", "", ""),
|
|
98
|
+
},
|
|
99
|
+
"pip": {
|
|
100
|
+
"install": ("包名", "", "", ""),
|
|
101
|
+
"uninstall": ("包名", "", "", ""),
|
|
102
|
+
},
|
|
103
|
+
"npm": {
|
|
104
|
+
"install": ("包名", "", "", ""),
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
def __init__(self):
|
|
109
|
+
super().__init__()
|
|
110
|
+
self.selected_shell = "fish"
|
|
111
|
+
self.menu_state = "main"
|
|
112
|
+
self.ram_widget = RamBar()
|
|
113
|
+
|
|
114
|
+
def compose(self) -> ComposeResult:
|
|
115
|
+
yield Header()
|
|
116
|
+
with Horizontal():
|
|
117
|
+
with Vertical(id="btn_panel"):
|
|
118
|
+
yield self.ram_widget
|
|
119
|
+
yield Vertical(id="menu_container")
|
|
120
|
+
yield Terminal(command=[self.selected_shell])
|
|
121
|
+
|
|
122
|
+
async def on_mount(self) -> None:
|
|
123
|
+
self.show_main_menu()
|
|
124
|
+
|
|
125
|
+
async def ram_loop():
|
|
126
|
+
while True:
|
|
127
|
+
self.ram_widget.refresh_ram()
|
|
128
|
+
await asyncio.sleep(2)
|
|
129
|
+
|
|
130
|
+
self.run_worker(ram_loop, exclusive=False)
|
|
131
|
+
|
|
132
|
+
def get_menu_container(self):
|
|
133
|
+
return self.query_one("#menu_container", Vertical)
|
|
134
|
+
|
|
135
|
+
def clear_menu(self):
|
|
136
|
+
c = self.get_menu_container()
|
|
137
|
+
for child in c.children:
|
|
138
|
+
child.remove()
|
|
139
|
+
|
|
140
|
+
def show_main_menu(self) -> None:
|
|
141
|
+
self.menu_state = "main"
|
|
142
|
+
self.clear_menu()
|
|
143
|
+
self.get_menu_container().mount(Button("tools", id="tools"))
|
|
144
|
+
|
|
145
|
+
def show_tools_menu(self) -> None:
|
|
146
|
+
self.menu_state = "tools"
|
|
147
|
+
self.clear_menu()
|
|
148
|
+
c = self.get_menu_container()
|
|
149
|
+
c.mount(Button("shell", id="shell"))
|
|
150
|
+
c.mount(Button("base", id="base"))
|
|
151
|
+
c.mount(Button("files", id="files"))
|
|
152
|
+
c.mount(Button("web", id="web"))
|
|
153
|
+
c.mount(Button("Downloads", id="Downloads"))
|
|
154
|
+
c.mount(Button("返回", id="back_main"))
|
|
155
|
+
|
|
156
|
+
def show_shell_submenu(self) -> None:
|
|
157
|
+
self.menu_state = "shell_sub"
|
|
158
|
+
self.clear_menu()
|
|
159
|
+
build_shell_submenu(self.get_menu_container())
|
|
160
|
+
|
|
161
|
+
def show_base_submenu(self) -> None:
|
|
162
|
+
self.menu_state = "base_sub"
|
|
163
|
+
self.clear_menu()
|
|
164
|
+
build_base_menu(self.get_menu_container())
|
|
165
|
+
|
|
166
|
+
def show_files_submenu(self) -> None:
|
|
167
|
+
self.menu_state = "files_sub"
|
|
168
|
+
self.clear_menu()
|
|
169
|
+
build_files_menu(self.get_menu_container())
|
|
170
|
+
|
|
171
|
+
def show_web_submenu(self) -> None:
|
|
172
|
+
self.menu_state = "web_sub"
|
|
173
|
+
self.clear_menu()
|
|
174
|
+
build_web_menu(self.get_menu_container())
|
|
175
|
+
|
|
176
|
+
def show_downloads_submenu(self) -> None:
|
|
177
|
+
self.menu_state = "downloads_sub"
|
|
178
|
+
self.clear_menu()
|
|
179
|
+
build_downloads_menu(self.get_menu_container())
|
|
180
|
+
|
|
181
|
+
def switch_shell(self, shell_cmd: str) -> None:
|
|
182
|
+
self.selected_shell = shell_cmd
|
|
183
|
+
old_term = self.query_one(Terminal)
|
|
184
|
+
parent = old_term.parent
|
|
185
|
+
old_term.remove()
|
|
186
|
+
parent.mount(Terminal(command=[shell_cmd]))
|
|
187
|
+
|
|
188
|
+
def send_command_to_terminal(self, cmd_line: str) -> None:
|
|
189
|
+
term = self.query_one(Terminal)
|
|
190
|
+
term.focus()
|
|
191
|
+
for ch in cmd_line:
|
|
192
|
+
term.post_message(events.Key(key=ch, character=ch))
|
|
193
|
+
term.post_message(events.Key(key="enter", character="\r"))
|
|
194
|
+
|
|
195
|
+
def run_base_cmd(self, cmd_id: str) -> None:
|
|
196
|
+
cfg = {
|
|
197
|
+
"cd": ("输入目标路径", "~/", "", ""),
|
|
198
|
+
"mkdir": ("目录名", "", "附加参数", ""),
|
|
199
|
+
"rm": ("文件/路径", "", "附加参数", ""),
|
|
200
|
+
"rip": ("目标", "", "附加参数", ""),
|
|
201
|
+
"zoxide": ("跳转路径", "", "", ""),
|
|
202
|
+
"ls": ("路径", ".", "附加参数", "-la"),
|
|
203
|
+
"eza": ("路径", ".", "附加参数", "-l"),
|
|
204
|
+
"find": ("起始目录", ".", "搜索条件", ""),
|
|
205
|
+
"clear": ("", "", "", ""),
|
|
206
|
+
"cat": ("文件名", "", "", ""),
|
|
207
|
+
"bat": ("文件名", "", "", ""),
|
|
208
|
+
}
|
|
209
|
+
p1, d1, p2, d2 = cfg[cmd_id]
|
|
210
|
+
|
|
211
|
+
def callback(res: tuple[str, str] | None) -> None:
|
|
212
|
+
if res is None:
|
|
213
|
+
return
|
|
214
|
+
v1, v2 = res
|
|
215
|
+
parts = [cmd_id]
|
|
216
|
+
if v1:
|
|
217
|
+
parts.append(v1)
|
|
218
|
+
if v2:
|
|
219
|
+
parts.append(v2)
|
|
220
|
+
self.send_command_to_terminal(" ".join(parts))
|
|
221
|
+
|
|
222
|
+
if not p1 and not p2:
|
|
223
|
+
callback(("", ""))
|
|
224
|
+
else:
|
|
225
|
+
self.push_screen(CmdInputScreen(p1, d1, p2, d2), callback)
|
|
226
|
+
|
|
227
|
+
def run_downloads_action(self, tool: str, action: str) -> None:
|
|
228
|
+
spec = self.SPEC
|
|
229
|
+
if tool not in spec or action not in spec:
|
|
230
|
+
return
|
|
231
|
+
p1, d1, p2, d2 = spec[tool][action]
|
|
232
|
+
|
|
233
|
+
def callback(res: tuple[str, str] | None) -> None:
|
|
234
|
+
if res is None:
|
|
235
|
+
return
|
|
236
|
+
v1, v2 = res
|
|
237
|
+
cmd_parts = [tool, action]
|
|
238
|
+
if v1:
|
|
239
|
+
cmd_parts.append(v1)
|
|
240
|
+
if v2:
|
|
241
|
+
cmd_parts.append(v2)
|
|
242
|
+
self.send_command_to_terminal(" ".join(cmd_parts))
|
|
243
|
+
|
|
244
|
+
if not p1 and not p2:
|
|
245
|
+
callback(("", ""))
|
|
246
|
+
else:
|
|
247
|
+
self.push_screen(CmdInputScreen(p1, d1, p2, d2), callback)
|
|
248
|
+
|
|
249
|
+
def run_web_browser(self, browser: str) -> None:
|
|
250
|
+
def callback(res: tuple[str, str] | None) -> None:
|
|
251
|
+
if res is None:
|
|
252
|
+
return
|
|
253
|
+
url, _ = res
|
|
254
|
+
url = url.strip()
|
|
255
|
+
if url:
|
|
256
|
+
self.send_command_to_terminal(f"{browser} {url}")
|
|
257
|
+
|
|
258
|
+
self.push_screen(CmdInputScreen("输入网址", "https://", "", ""), callback)
|
|
259
|
+
|
|
260
|
+
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
261
|
+
bid = event.button.id
|
|
262
|
+
if bid is None:
|
|
263
|
+
return
|
|
264
|
+
|
|
265
|
+
if self.menu_state == "main":
|
|
266
|
+
if bid == "tools":
|
|
267
|
+
self.show_tools_menu()
|
|
268
|
+
|
|
269
|
+
elif self.menu_state == "tools":
|
|
270
|
+
if bid == "shell":
|
|
271
|
+
self.show_shell_submenu()
|
|
272
|
+
elif bid == "base":
|
|
273
|
+
self.show_base_submenu()
|
|
274
|
+
elif bid == "files":
|
|
275
|
+
self.show_files_submenu()
|
|
276
|
+
elif bid == "web":
|
|
277
|
+
self.show_web_submenu()
|
|
278
|
+
elif bid == "Downloads":
|
|
279
|
+
self.show_downloads_submenu()
|
|
280
|
+
elif bid == "back_main":
|
|
281
|
+
self.show_main_menu()
|
|
282
|
+
|
|
283
|
+
elif self.menu_state == "shell_sub":
|
|
284
|
+
if bid in {"bash", "zsh", "fish"}:
|
|
285
|
+
self.switch_shell(bid)
|
|
286
|
+
elif bid == "back_shell":
|
|
287
|
+
self.show_tools_menu()
|
|
288
|
+
|
|
289
|
+
elif self.menu_state == "base_sub":
|
|
290
|
+
base_actions = {
|
|
291
|
+
"cd",
|
|
292
|
+
"mkdir",
|
|
293
|
+
"rm",
|
|
294
|
+
"rip",
|
|
295
|
+
"zoxide",
|
|
296
|
+
"ls",
|
|
297
|
+
"eza",
|
|
298
|
+
"find",
|
|
299
|
+
"clear",
|
|
300
|
+
"cat",
|
|
301
|
+
"bat",
|
|
302
|
+
}
|
|
303
|
+
if bid in base_actions:
|
|
304
|
+
self.run_base_cmd(bid)
|
|
305
|
+
elif bid == "back_base":
|
|
306
|
+
self.show_tools_menu()
|
|
307
|
+
|
|
308
|
+
elif self.menu_state == "files_sub":
|
|
309
|
+
if bid in {"mc", "nnn", "vifm"}:
|
|
310
|
+
self.send_command_to_terminal(bid)
|
|
311
|
+
elif bid == "back_files":
|
|
312
|
+
self.show_tools_menu()
|
|
313
|
+
|
|
314
|
+
elif self.menu_state == "web_sub":
|
|
315
|
+
if bid == "lynx":
|
|
316
|
+
self.run_web_browser("lynx")
|
|
317
|
+
elif bid == "w3m":
|
|
318
|
+
self.run_web_browser("w3m")
|
|
319
|
+
elif bid == "back_web":
|
|
320
|
+
self.show_tools_menu()
|
|
321
|
+
|
|
322
|
+
elif self.menu_state == "downloads_sub":
|
|
323
|
+
if bid == "apt":
|
|
324
|
+
self.menu_state = "apt_sub"
|
|
325
|
+
self.clear_menu()
|
|
326
|
+
c = self.get_menu_container()
|
|
327
|
+
for a in self.SPEC["apt"]:
|
|
328
|
+
c.mount(Button(a, id=a))
|
|
329
|
+
c.mount(Button("返回", id="back_apt"))
|
|
330
|
+
elif bid == "pkg":
|
|
331
|
+
self.menu_state = "pkg_sub"
|
|
332
|
+
self.clear_menu()
|
|
333
|
+
c = self.get_menu_container()
|
|
334
|
+
for a in self.SPEC["pkg"]:
|
|
335
|
+
c.mount(Button(a, id=a))
|
|
336
|
+
c.mount(Button("返回", id="back_pkg"))
|
|
337
|
+
elif bid == "cargo":
|
|
338
|
+
self.menu_state = "cargo_sub"
|
|
339
|
+
self.clear_menu()
|
|
340
|
+
c = self.get_menu_container()
|
|
341
|
+
for a in self.SPEC["cargo"]:
|
|
342
|
+
c.mount(Button(a, id=a))
|
|
343
|
+
c.mount(Button("返回", id="back_cargo"))
|
|
344
|
+
elif bid == "pip":
|
|
345
|
+
self.menu_state = "pip_sub"
|
|
346
|
+
self.clear_menu()
|
|
347
|
+
c = self.get_menu_container()
|
|
348
|
+
for a in self.SPEC["pip"]:
|
|
349
|
+
c.mount(Button(a, id=a))
|
|
350
|
+
c.mount(Button("返回", id="back_pip"))
|
|
351
|
+
elif bid == "npm":
|
|
352
|
+
self.menu_state = "npm_sub"
|
|
353
|
+
self.clear_menu()
|
|
354
|
+
c = self.get_menu_container()
|
|
355
|
+
for a in self.SPEC["npm"]:
|
|
356
|
+
c.mount(Button(a, id=a))
|
|
357
|
+
c.mount(Button("返回", id="back_npm"))
|
|
358
|
+
elif bid == "back_downloads_root":
|
|
359
|
+
self.show_tools_menu()
|
|
360
|
+
|
|
361
|
+
elif self.menu_state == "apt_sub":
|
|
362
|
+
if bid in self.SPEC["apt"]:
|
|
363
|
+
self.run_downloads_action("apt", bid)
|
|
364
|
+
elif bid == "back_apt":
|
|
365
|
+
self.show_downloads_submenu()
|
|
366
|
+
|
|
367
|
+
elif self.menu_state == "pkg_sub":
|
|
368
|
+
if bid in self.SPEC["pkg"]:
|
|
369
|
+
self.run_downloads_action("pkg", bid)
|
|
370
|
+
elif bid == "back_pkg":
|
|
371
|
+
self.show_downloads_submenu()
|
|
372
|
+
|
|
373
|
+
elif self.menu_state == "cargo_sub":
|
|
374
|
+
if bid in self.SPEC["cargo"]:
|
|
375
|
+
self.run_downloads_action("cargo", bid)
|
|
376
|
+
elif bid == "back_cargo":
|
|
377
|
+
self.show_downloads_submenu()
|
|
378
|
+
|
|
379
|
+
elif self.menu_state == "pip_sub":
|
|
380
|
+
if bid in self.SPEC["pip"]:
|
|
381
|
+
self.run_downloads_action("pip", bid)
|
|
382
|
+
elif bid == "back_pip":
|
|
383
|
+
self.show_downloads_submenu()
|
|
384
|
+
|
|
385
|
+
elif self.menu_state == "npm_sub":
|
|
386
|
+
if bid in self.SPEC["npm"]:
|
|
387
|
+
self.run_downloads_action("npm", bid)
|
|
388
|
+
elif bid == "back_npm":
|
|
389
|
+
self.show_downloads_submenu()
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def main() -> None:
|
|
393
|
+
FxTermuxTui().run()
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
if __name__ == "__main__":
|
|
397
|
+
main()
|
|
398
|
+
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from textual.widgets import Button
|
|
2
|
+
from textual.containers import Vertical
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def build_base_menu(panel: Vertical):
|
|
6
|
+
for child in panel.children:
|
|
7
|
+
child.remove()
|
|
8
|
+
cmds = [
|
|
9
|
+
("cd", "cd"),
|
|
10
|
+
("mkdir", "mkdir"),
|
|
11
|
+
("rm", "rm"),
|
|
12
|
+
("rip", "rip"),
|
|
13
|
+
("zoxide", "zoxide"),
|
|
14
|
+
("ls", "ls"),
|
|
15
|
+
("eza", "eza"),
|
|
16
|
+
("find", "find"),
|
|
17
|
+
("clear", "clear"),
|
|
18
|
+
("cat", "cat"),
|
|
19
|
+
("bat", "bat"),
|
|
20
|
+
]
|
|
21
|
+
for label, cmd_id in cmds:
|
|
22
|
+
panel.mount(Button(label, id=cmd_id))
|
|
23
|
+
panel.mount(Button("返回", id="back_base"))
|
|
24
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from textual.widgets import Button
|
|
2
|
+
from textual.containers import Vertical
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def build_files_menu(panel: Vertical):
|
|
6
|
+
for child in panel.children:
|
|
7
|
+
child.remove()
|
|
8
|
+
for cmd_id in ("mc", "nnn", "vifm"):
|
|
9
|
+
panel.mount(Button(cmd_id, id=cmd_id))
|
|
10
|
+
panel.mount(Button("返回", id="back_files"))
|
|
11
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from textual.app import ComposeResult
|
|
2
|
+
from textual.screen import ModalScreen
|
|
3
|
+
from textual.widgets import Button, Input, Label
|
|
4
|
+
from textual.containers import Vertical, Horizontal
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CmdInputScreen(ModalScreen[tuple[str, str] | None]):
|
|
8
|
+
CSS = """
|
|
9
|
+
Screen {
|
|
10
|
+
align: center middle;
|
|
11
|
+
}
|
|
12
|
+
Vertical {
|
|
13
|
+
width: 60;
|
|
14
|
+
background: $panel;
|
|
15
|
+
border: solid $primary;
|
|
16
|
+
padding: 1;
|
|
17
|
+
}
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
prompt1: str,
|
|
23
|
+
default1: str,
|
|
24
|
+
prompt2: str,
|
|
25
|
+
default2: str,
|
|
26
|
+
**kwargs,
|
|
27
|
+
):
|
|
28
|
+
super().__init__(**kwargs)
|
|
29
|
+
self.prompt1 = prompt1
|
|
30
|
+
self.default1 = default1
|
|
31
|
+
self.prompt2 = prompt2
|
|
32
|
+
self.default2 = default2
|
|
33
|
+
|
|
34
|
+
def compose(self) -> ComposeResult:
|
|
35
|
+
with Vertical():
|
|
36
|
+
if self.prompt1:
|
|
37
|
+
yield Label(self.prompt1)
|
|
38
|
+
yield Input(value=self.default1, id="i1")
|
|
39
|
+
if self.prompt2:
|
|
40
|
+
yield Label(self.prompt2)
|
|
41
|
+
yield Input(value=self.default2, id="i2")
|
|
42
|
+
with Horizontal():
|
|
43
|
+
yield Button("确定", id="ok")
|
|
44
|
+
yield Button("取消", id="cancel")
|
|
45
|
+
|
|
46
|
+
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
47
|
+
if event.button.id == "ok":
|
|
48
|
+
v1 = self.query_one("#i1", Input).value if self.prompt1 else ""
|
|
49
|
+
v2 = self.query_one("#i2", Input).value if self.prompt2 else ""
|
|
50
|
+
self.dismiss((v1, v2))
|
|
51
|
+
else:
|
|
52
|
+
self.dismiss(None)
|
|
53
|
+
|
|
54
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from textual.widgets import Button
|
|
2
|
+
from textual.containers import Vertical
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def build_shell_submenu(panel: Vertical):
|
|
6
|
+
for child in panel.children:
|
|
7
|
+
child.remove()
|
|
8
|
+
for name in ("bash", "zsh", "fish"):
|
|
9
|
+
panel.mount(Button(name, id=name))
|
|
10
|
+
panel.mount(Button("返回", id="back_shell"))
|
|
11
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from textual.widgets import Button
|
|
2
|
+
from textual.containers import Vertical
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def build_web_menu(panel: Vertical) -> None:
|
|
6
|
+
for child in panel.children:
|
|
7
|
+
child.remove()
|
|
8
|
+
panel.mount(Button("lynx", id="lynx"))
|
|
9
|
+
panel.mount(Button("w3m", id="w3m"))
|
|
10
|
+
panel.mount(Button("返回", id="back_web"))
|
|
11
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: FxTermuxTui
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: FxTermuxTui: TUI for Termux
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 kksk
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: textual
|
|
30
|
+
Requires-Dist: textual-tty
|
|
31
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
pyproject.toml
|
|
3
|
+
FxTermuxTui/Downloads.py
|
|
4
|
+
FxTermuxTui/FxTermuxTui.py
|
|
5
|
+
FxTermuxTui/__init__.py
|
|
6
|
+
FxTermuxTui/base.py
|
|
7
|
+
FxTermuxTui/files.py
|
|
8
|
+
FxTermuxTui/popup.py
|
|
9
|
+
FxTermuxTui/shell.py
|
|
10
|
+
FxTermuxTui/web.py
|
|
11
|
+
FxTermuxTui.egg-info/PKG-INFO
|
|
12
|
+
FxTermuxTui.egg-info/SOURCES.txt
|
|
13
|
+
FxTermuxTui.egg-info/dependency_links.txt
|
|
14
|
+
FxTermuxTui.egg-info/entry_points.txt
|
|
15
|
+
FxTermuxTui.egg-info/requires.txt
|
|
16
|
+
FxTermuxTui.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
FxTermuxTui
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kksk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: FxTermuxTui
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: FxTermuxTui: TUI for Termux
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 kksk
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: textual
|
|
30
|
+
Requires-Dist: textual-tty
|
|
31
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "FxTermuxTui"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "FxTermuxTui: TUI for Termux"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"textual",
|
|
12
|
+
"textual-tty",
|
|
13
|
+
]
|
|
14
|
+
license = { file = "LICENSE" }
|
|
15
|
+
[project.scripts]
|
|
16
|
+
FxTermuxTui = "FxTermuxTui.FxTermuxTui:main"
|
|
17
|
+
|