tmcode 0.2.0__py3-none-any.whl
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.
- termcode/__init__.py +3 -0
- termcode/app.py +2236 -0
- termcode/buffers.py +168 -0
- termcode/cli.py +69 -0
- termcode/commands.py +234 -0
- termcode/completions.py +205 -0
- termcode/findbar.py +258 -0
- termcode/formatting.py +365 -0
- termcode/highlighting.py +61 -0
- termcode/modals.py +431 -0
- termcode/runner.py +725 -0
- termcode/search.py +105 -0
- termcode/styles.tcss +796 -0
- termcode/theme.py +99 -0
- termcode/workspace.py +271 -0
- tmcode-0.2.0.dist-info/METADATA +128 -0
- tmcode-0.2.0.dist-info/RECORD +21 -0
- tmcode-0.2.0.dist-info/WHEEL +5 -0
- tmcode-0.2.0.dist-info/entry_points.txt +3 -0
- tmcode-0.2.0.dist-info/licenses/LICENSE +21 -0
- tmcode-0.2.0.dist-info/top_level.txt +1 -0
termcode/theme.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""TermCode color tokens and the matching editor (TextArea) syntax theme.
|
|
2
|
+
|
|
3
|
+
The same hex values are declared as `$variables` at the top of styles.tcss.
|
|
4
|
+
Keep the two in sync when changing the palette.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from rich.style import Style
|
|
10
|
+
from textual.widgets.text_area import TextAreaTheme
|
|
11
|
+
|
|
12
|
+
# Surfaces: one blue-slate family, darkest at the edges, lightest where you type.
|
|
13
|
+
BG = "#14171c" # app chrome: sidebar, tab bar, status bar, output
|
|
14
|
+
SURFACE = "#191d23" # editor canvas
|
|
15
|
+
RAISED = "#20252d" # cursor line, hovered rows, inputs
|
|
16
|
+
LINE = "#2a303a" # hairlines between regions
|
|
17
|
+
# Text
|
|
18
|
+
TEXT = "#c7ccd4"
|
|
19
|
+
MUTED = "#6c7584"
|
|
20
|
+
FAINT = "#465061"
|
|
21
|
+
# One accent for focus and the active thing
|
|
22
|
+
ACCENT = "#8ea2ff"
|
|
23
|
+
# Run states, used only by the Output panel
|
|
24
|
+
OK = "#7ccf9e"
|
|
25
|
+
FAIL = "#f07a7d"
|
|
26
|
+
BUSY = "#e7bf72"
|
|
27
|
+
|
|
28
|
+
_SYNTAX = {
|
|
29
|
+
"comment": Style(color="#5f6878", italic=True),
|
|
30
|
+
"string": Style(color="#a9cc8c"),
|
|
31
|
+
"string.documentation": Style(color="#7f9a6b", italic=True),
|
|
32
|
+
"keyword": Style(color="#b6a0f2"),
|
|
33
|
+
"conditional": Style(color="#b6a0f2"),
|
|
34
|
+
"repeat": Style(color="#b6a0f2"),
|
|
35
|
+
"exception": Style(color="#b6a0f2"),
|
|
36
|
+
"include": Style(color="#b6a0f2"),
|
|
37
|
+
"keyword.function": Style(color="#b6a0f2"),
|
|
38
|
+
"keyword.return": Style(color="#b6a0f2"),
|
|
39
|
+
"keyword.operator": Style(color="#b6a0f2"),
|
|
40
|
+
"operator": Style(color="#8d97a8"),
|
|
41
|
+
"function": Style(color="#7fb6ec"),
|
|
42
|
+
"function.call": Style(color="#7fb6ec"),
|
|
43
|
+
"method": Style(color="#7fb6ec"),
|
|
44
|
+
"method.call": Style(color="#7fb6ec"),
|
|
45
|
+
"constructor": Style(color="#e5bd7f"),
|
|
46
|
+
"class": Style(color="#e5bd7f"),
|
|
47
|
+
"type": Style(color="#e5bd7f"),
|
|
48
|
+
"type.class": Style(color="#e5bd7f"),
|
|
49
|
+
"type.builtin": Style(color="#79c9c1"),
|
|
50
|
+
"number": Style(color="#ec9f7f"),
|
|
51
|
+
"float": Style(color="#ec9f7f"),
|
|
52
|
+
"boolean": Style(color="#ec9f7f"),
|
|
53
|
+
"constant.builtin": Style(color="#ec9f7f"),
|
|
54
|
+
"json.null": Style(color="#ec9f7f"),
|
|
55
|
+
"tag": Style(color="#e5bd7f"),
|
|
56
|
+
"yaml.field": Style(color="#7fb6ec"),
|
|
57
|
+
"json.label": Style(color="#7fb6ec"),
|
|
58
|
+
"toml.type": Style(color="#7fb6ec"),
|
|
59
|
+
"toml.datetime": Style(color="#ec9f7f"),
|
|
60
|
+
"css.property": Style(color="#7fb6ec"),
|
|
61
|
+
"heading": Style(color=TEXT, bold=True),
|
|
62
|
+
"heading.marker": Style(color=MUTED),
|
|
63
|
+
"bold": Style(bold=True),
|
|
64
|
+
"italic": Style(italic=True),
|
|
65
|
+
"strikethrough": Style(strike=True),
|
|
66
|
+
"link.label": Style(color="#b6a0f2"),
|
|
67
|
+
"link.uri": Style(color="#7fb6ec", underline=True),
|
|
68
|
+
"list.marker": Style(color=MUTED),
|
|
69
|
+
"inline_code": Style(color="#a9cc8c"),
|
|
70
|
+
"punctuation.bracket": Style(color="#8d97a8"),
|
|
71
|
+
"punctuation.delimiter": Style(color="#8d97a8"),
|
|
72
|
+
"punctuation.special": Style(color="#8d97a8"),
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
EDITOR_THEME_NAME = "termcode"
|
|
76
|
+
|
|
77
|
+
EDITOR_THEME = TextAreaTheme(
|
|
78
|
+
name=EDITOR_THEME_NAME,
|
|
79
|
+
base_style=Style(color=TEXT, bgcolor=SURFACE),
|
|
80
|
+
gutter_style=Style(color=FAINT, bgcolor=SURFACE),
|
|
81
|
+
cursor_style=Style(color=SURFACE, bgcolor=ACCENT),
|
|
82
|
+
cursor_line_style=Style(bgcolor=RAISED),
|
|
83
|
+
cursor_line_gutter_style=Style(color=TEXT, bgcolor=RAISED),
|
|
84
|
+
bracket_matching_style=Style(bgcolor="#323a48", bold=True),
|
|
85
|
+
selection_style=Style(bgcolor="#2f3b5c"),
|
|
86
|
+
syntax_styles=_SYNTAX,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
OUTPUT_THEME_NAME = "termcode-output"
|
|
90
|
+
|
|
91
|
+
OUTPUT_THEME = TextAreaTheme(
|
|
92
|
+
name=OUTPUT_THEME_NAME,
|
|
93
|
+
base_style=Style(color=TEXT, bgcolor=BG),
|
|
94
|
+
gutter_style=Style(color=FAINT, bgcolor=BG),
|
|
95
|
+
cursor_style=Style(color=BG, bgcolor=MUTED),
|
|
96
|
+
cursor_line_style=Style(bgcolor=BG),
|
|
97
|
+
selection_style=Style(bgcolor="#2f3b5c"),
|
|
98
|
+
syntax_styles={},
|
|
99
|
+
)
|
termcode/workspace.py
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"""Filesystem operations and safety guards for TermCode workspaces."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import shutil
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
from platformdirs import user_config_dir
|
|
12
|
+
except ImportError: # pragma: no cover
|
|
13
|
+
user_config_dir = None # type: ignore[assignment]
|
|
14
|
+
|
|
15
|
+
MAX_FILE_BYTES: int = 2 * 1024 * 1024 # 2 MB
|
|
16
|
+
IGNORED_DIRS: frozenset[str] = frozenset(
|
|
17
|
+
{
|
|
18
|
+
".git",
|
|
19
|
+
".venv",
|
|
20
|
+
"venv",
|
|
21
|
+
"__pycache__",
|
|
22
|
+
"node_modules",
|
|
23
|
+
".pytest_cache",
|
|
24
|
+
".mypy_cache",
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class WorkspaceError(Exception):
|
|
30
|
+
"""Base error for safe workspace file and folder operations."""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class BinaryFileError(WorkspaceError):
|
|
34
|
+
"""Raised when attempting to load a binary or non-UTF-8 file as text."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class FileTooLargeError(WorkspaceError):
|
|
38
|
+
"""Raised when attempting to load a file larger than the editor limit."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _validate_relative_name(raw_name: str, *, allow_nested: bool) -> Path:
|
|
42
|
+
cleaned = raw_name.strip()
|
|
43
|
+
if not cleaned:
|
|
44
|
+
raise WorkspaceError("Name cannot be empty.")
|
|
45
|
+
|
|
46
|
+
rel = Path(cleaned)
|
|
47
|
+
if rel.is_absolute():
|
|
48
|
+
raise WorkspaceError("Please enter a relative name, not an absolute path.")
|
|
49
|
+
|
|
50
|
+
parts = rel.parts
|
|
51
|
+
if not parts or any(part in ("", ".", "..") for part in parts):
|
|
52
|
+
raise WorkspaceError(f"Invalid path: {raw_name!r}")
|
|
53
|
+
|
|
54
|
+
if not allow_nested and (len(parts) != 1 or "/" in cleaned or "\\" in cleaned):
|
|
55
|
+
raise WorkspaceError("Rename target must be a single file or folder name.")
|
|
56
|
+
|
|
57
|
+
return rel
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def read_text_file(path: Path, max_bytes: int = MAX_FILE_BYTES) -> str:
|
|
61
|
+
"""Read a UTF-8 text file, rejecting binary files and files over max_bytes."""
|
|
62
|
+
try:
|
|
63
|
+
stat = path.stat()
|
|
64
|
+
except OSError as exc:
|
|
65
|
+
raise WorkspaceError(f"Cannot read {path.name}: {exc}") from exc
|
|
66
|
+
|
|
67
|
+
if not path.is_file():
|
|
68
|
+
raise WorkspaceError(f"Not a file: {path}")
|
|
69
|
+
|
|
70
|
+
if stat.st_size > max_bytes:
|
|
71
|
+
limit_mb = max_bytes / (1024 * 1024)
|
|
72
|
+
raise FileTooLargeError(
|
|
73
|
+
f"File is too large to open ({stat.st_size:,} bytes; limit {limit_mb:.1f} MB)."
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
raw = path.read_bytes()
|
|
78
|
+
except OSError as exc:
|
|
79
|
+
raise WorkspaceError(f"Cannot read {path.name}: {exc}") from exc
|
|
80
|
+
|
|
81
|
+
if b"\x00" in raw[:8192]:
|
|
82
|
+
raise BinaryFileError(f"Cannot open binary file: {path.name}")
|
|
83
|
+
|
|
84
|
+
try:
|
|
85
|
+
return raw.decode("utf-8", errors="strict")
|
|
86
|
+
except UnicodeDecodeError as exc:
|
|
87
|
+
raise BinaryFileError(f"Cannot open non-UTF-8 file: {path.name}") from exc
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def write_text_file(path: Path, content: str) -> None:
|
|
91
|
+
"""Write UTF-8 text content to path, creating parent directories if needed."""
|
|
92
|
+
try:
|
|
93
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
94
|
+
path.write_text(content, encoding="utf-8")
|
|
95
|
+
except OSError as exc:
|
|
96
|
+
raise WorkspaceError(f"Cannot save {path.name}: {exc}") from exc
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def create_file(base_dir: Path, relative_name: str) -> Path:
|
|
100
|
+
"""Create a new empty file (including nested parent dirs) under base_dir."""
|
|
101
|
+
rel = _validate_relative_name(relative_name, allow_nested=True)
|
|
102
|
+
target = base_dir / rel
|
|
103
|
+
if target.exists():
|
|
104
|
+
raise WorkspaceError(f"Already exists: {target.name}")
|
|
105
|
+
try:
|
|
106
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
107
|
+
target.write_text("", encoding="utf-8")
|
|
108
|
+
except OSError as exc:
|
|
109
|
+
raise WorkspaceError(f"Cannot create file {rel}: {exc}") from exc
|
|
110
|
+
return target
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def create_folder(base_dir: Path, relative_name: str) -> Path:
|
|
114
|
+
"""Create a new folder (including nested parent dirs) under base_dir."""
|
|
115
|
+
rel = _validate_relative_name(relative_name, allow_nested=True)
|
|
116
|
+
target = base_dir / rel
|
|
117
|
+
if target.exists():
|
|
118
|
+
raise WorkspaceError(f"Already exists: {target.name}")
|
|
119
|
+
try:
|
|
120
|
+
target.mkdir(parents=True, exist_ok=False)
|
|
121
|
+
except OSError as exc:
|
|
122
|
+
raise WorkspaceError(f"Cannot create folder {rel}: {exc}") from exc
|
|
123
|
+
return target
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def rename_path(target: Path, new_name: str) -> Path:
|
|
127
|
+
"""Rename a file or folder within its parent directory."""
|
|
128
|
+
if not target.exists():
|
|
129
|
+
raise WorkspaceError(f"Path does not exist: {target}")
|
|
130
|
+
rel = _validate_relative_name(new_name, allow_nested=False)
|
|
131
|
+
dest = target.parent / rel
|
|
132
|
+
if dest == target:
|
|
133
|
+
return target
|
|
134
|
+
if dest.exists():
|
|
135
|
+
raise WorkspaceError(f"Already exists: {dest.name}")
|
|
136
|
+
try:
|
|
137
|
+
target.rename(dest)
|
|
138
|
+
except OSError as exc:
|
|
139
|
+
raise WorkspaceError(f"Cannot rename {target.name}: {exc}") from exc
|
|
140
|
+
return dest
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def delete_path(target: Path) -> None:
|
|
144
|
+
"""Delete a file or recursively delete a directory."""
|
|
145
|
+
if not target.exists():
|
|
146
|
+
raise WorkspaceError(f"Path does not exist: {target}")
|
|
147
|
+
try:
|
|
148
|
+
if target.is_dir() and not target.is_symlink():
|
|
149
|
+
shutil.rmtree(target)
|
|
150
|
+
else:
|
|
151
|
+
target.unlink()
|
|
152
|
+
except OSError as exc:
|
|
153
|
+
raise WorkspaceError(f"Cannot delete {target.name}: {exc}") from exc
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def list_workspace_files(root: Path, limit: int = 2000) -> list[Path]:
|
|
157
|
+
"""Return sorted file paths under root, skipping ignored directories."""
|
|
158
|
+
results: list[Path] = []
|
|
159
|
+
if not root.is_dir():
|
|
160
|
+
return results
|
|
161
|
+
|
|
162
|
+
for current, dirs, files in os.walk(root):
|
|
163
|
+
dirs[:] = sorted(d for d in dirs if d not in IGNORED_DIRS)
|
|
164
|
+
cur_path = Path(current)
|
|
165
|
+
for filename in sorted(files):
|
|
166
|
+
results.append(cur_path / filename)
|
|
167
|
+
if len(results) >= limit:
|
|
168
|
+
return results
|
|
169
|
+
return results
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def default_recent_store() -> Path:
|
|
173
|
+
"""Return cross-OS path for TermCode's recent folders JSON file."""
|
|
174
|
+
if user_config_dir is not None:
|
|
175
|
+
return Path(user_config_dir("termcode")) / "recent.json"
|
|
176
|
+
return Path.home() / ".config" / "termcode" / "recent.json"
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def load_recent_folders(
|
|
180
|
+
*, store_path: Path | None = None, limit: int = 6
|
|
181
|
+
) -> list[Path]:
|
|
182
|
+
"""Load existing recently opened workspace folders, newest first."""
|
|
183
|
+
store = store_path or default_recent_store()
|
|
184
|
+
if not store.is_file():
|
|
185
|
+
return []
|
|
186
|
+
try:
|
|
187
|
+
raw = json.loads(store.read_text(encoding="utf-8"))
|
|
188
|
+
except (OSError, ValueError):
|
|
189
|
+
return []
|
|
190
|
+
if not isinstance(raw, list):
|
|
191
|
+
return []
|
|
192
|
+
|
|
193
|
+
folders: list[Path] = []
|
|
194
|
+
seen: set[Path] = set()
|
|
195
|
+
for item in raw:
|
|
196
|
+
if not isinstance(item, str):
|
|
197
|
+
continue
|
|
198
|
+
p = Path(item)
|
|
199
|
+
if p.is_dir():
|
|
200
|
+
resolved = p.resolve()
|
|
201
|
+
if resolved not in seen:
|
|
202
|
+
seen.add(resolved)
|
|
203
|
+
folders.append(resolved)
|
|
204
|
+
if len(folders) >= limit:
|
|
205
|
+
break
|
|
206
|
+
return folders
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def record_recent_folder(
|
|
210
|
+
folder: Path, *, store_path: Path | None = None, limit: int = 6
|
|
211
|
+
) -> None:
|
|
212
|
+
"""Record folder at the front of the recent folders list."""
|
|
213
|
+
store = store_path or default_recent_store()
|
|
214
|
+
resolved = folder.resolve()
|
|
215
|
+
existing = [p for p in load_recent_folders(store_path=store, limit=limit) if p != resolved]
|
|
216
|
+
updated = [resolved, *existing][:limit]
|
|
217
|
+
try:
|
|
218
|
+
store.parent.mkdir(parents=True, exist_ok=True)
|
|
219
|
+
store.write_text(
|
|
220
|
+
json.dumps([str(p) for p in updated], indent=2),
|
|
221
|
+
encoding="utf-8",
|
|
222
|
+
)
|
|
223
|
+
except OSError:
|
|
224
|
+
pass
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
_BRANCH_CACHE: dict[Path, tuple[float, str | None]] = {}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _find_git_head(root: Path) -> Path | None:
|
|
231
|
+
for folder in (root, *root.parents):
|
|
232
|
+
dot_git = folder / ".git"
|
|
233
|
+
if dot_git.is_dir():
|
|
234
|
+
return dot_git / "HEAD"
|
|
235
|
+
if dot_git.is_file(): # worktree or submodule: "gitdir: <path>"
|
|
236
|
+
try:
|
|
237
|
+
text = dot_git.read_text(encoding="utf-8").strip()
|
|
238
|
+
except OSError:
|
|
239
|
+
return None
|
|
240
|
+
if text.startswith("gitdir:"):
|
|
241
|
+
gitdir = Path(text.removeprefix("gitdir:").strip())
|
|
242
|
+
if not gitdir.is_absolute():
|
|
243
|
+
gitdir = folder / gitdir
|
|
244
|
+
return gitdir / "HEAD"
|
|
245
|
+
return None
|
|
246
|
+
return None
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def current_git_branch(root: Path) -> str | None:
|
|
250
|
+
"""Return the checked-out branch (or short SHA) for root, without running git.
|
|
251
|
+
|
|
252
|
+
Called on every keystroke via the status bar, so it only re-reads HEAD
|
|
253
|
+
when the file's mtime changes.
|
|
254
|
+
"""
|
|
255
|
+
head = _find_git_head(root)
|
|
256
|
+
if head is None:
|
|
257
|
+
return None
|
|
258
|
+
try:
|
|
259
|
+
mtime = head.stat().st_mtime
|
|
260
|
+
except OSError:
|
|
261
|
+
return None
|
|
262
|
+
cached = _BRANCH_CACHE.get(head)
|
|
263
|
+
if cached is not None and cached[0] == mtime:
|
|
264
|
+
return cached[1]
|
|
265
|
+
try:
|
|
266
|
+
ref = head.read_text(encoding="utf-8").strip()
|
|
267
|
+
except OSError:
|
|
268
|
+
return None
|
|
269
|
+
branch = ref.removeprefix("ref: refs/heads/") if ref.startswith("ref:") else ref[:7]
|
|
270
|
+
_BRANCH_CACHE[head] = (mtime, branch)
|
|
271
|
+
return branch
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tmcode
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: TmCode: a lightweight terminal code editor with run, find/replace, format-on-save and a real-terminal mode
|
|
5
|
+
Author: Abdullah Al Mamun
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/abdullahalmamun29/tmcode
|
|
8
|
+
Project-URL: Issues, https://github.com/abdullahalmamun29/tmcode/issues
|
|
9
|
+
Keywords: editor,terminal,tui,ide,textual
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Text Editors
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: textual[syntax]>=0.80.0
|
|
21
|
+
Requires-Dist: tree-sitter-c>=0.23.0
|
|
22
|
+
Requires-Dist: tree-sitter-cpp>=0.23.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# TermCode
|
|
29
|
+
|
|
30
|
+
Lightweight, cross-platform VS Code-style terminal code editor and runner for **Python**, **C**, and **C++**.
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- Launch right from any terminal (`termcode` from `~` opens the Home folder picker; `termcode` inside any project folder opens it directly)
|
|
35
|
+
- VS Code Dark Modern 3-pane layout: Explorer with `+F`/`+D` buttons, multi-tab + side-by-side split editor (`F12`), and draggable/resizable Terminal panel
|
|
36
|
+
- VS Code Dark+ syntax colors across **17 languages** (Python, C, C++, JS/TS, HTML, CSS, JSON, Java, Go, Rust, Bash, SQL, Markdown, YAML, TOML, XML, Regex)
|
|
37
|
+
- Lightweight offline code suggestions (language builtins + open-file words) and automatic indentation while typing
|
|
38
|
+
- Unified `/run` (`F5`) supporting **Python, C, C++, JavaScript, TypeScript, Bash, Go, Rust, Java, Ruby, PHP, Perl, and Lua** with live interactive keyboard input
|
|
39
|
+
- Real OS clipboard integration (Linux X11/Wayland, macOS, Windows), `Ctrl+A` select-all, and VS Code-style `Ctrl+C` (copies selection or current line)
|
|
40
|
+
- Searchable `/` command menu (`Ctrl+K` anywhere, or `/` outside text inputs) with a shortcut for every action
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
TmCode needs **Python 3.10+**. The easiest way is [pipx](https://pipx.pypa.io), which installs it in its own isolated environment and puts the `tmcode` command on your PATH.
|
|
45
|
+
|
|
46
|
+
### Linux / macOS
|
|
47
|
+
```bash
|
|
48
|
+
python3 -m pip install --user pipx # or: sudo apt install pipx / brew install pipx
|
|
49
|
+
python3 -m pipx ensurepath # then open a new terminal
|
|
50
|
+
pipx install tmcode
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Windows (PowerShell)
|
|
54
|
+
```powershell
|
|
55
|
+
py -m pip install --user pipx
|
|
56
|
+
py -m pipx ensurepath # then open a new terminal
|
|
57
|
+
pipx install tmcode
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Then run `tmcode` (the old `termcode` command works too).
|
|
61
|
+
|
|
62
|
+
**Update:** `pipx upgrade tmcode` · **Uninstall:** `pipx uninstall tmcode`
|
|
63
|
+
|
|
64
|
+
Install the latest code straight from GitHub instead of PyPI:
|
|
65
|
+
```bash
|
|
66
|
+
pipx install git+https://github.com/abdullahalmamun29/tmcode.git
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Optional extras
|
|
70
|
+
- To **run** code you need the language itself installed: `python3`, `gcc`/`g++` for C/C++, `node`, `go`, `rustc`, `java`, etc.
|
|
71
|
+
- **Format on save** works out of the box with a built-in re-indenter. If `ruff`/`black`, `clang-format`, `prettier`, `gofmt` or `rustfmt` are installed, TmCode uses them automatically.
|
|
72
|
+
- The resize pointer (↔ ↕ on panel edges) shows in kitty, WezTerm, Ghostty, foot and xterm; other terminals show the highlighted grip instead.
|
|
73
|
+
|
|
74
|
+
### From source (for development)
|
|
75
|
+
```bash
|
|
76
|
+
git clone https://github.com/abdullahalmamun29/tmcode.git
|
|
77
|
+
cd tmcode
|
|
78
|
+
python3 -m venv .venv
|
|
79
|
+
.venv/bin/pip install -e ".[dev]"
|
|
80
|
+
.venv/bin/pytest
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
termcode # From ~ opens the Home tab (folder selector & recent folders); from any project folder opens it directly
|
|
87
|
+
termcode . # Open current directory directly (from ~ this still shows the start page)
|
|
88
|
+
termcode path/to/project # Open a specific folder
|
|
89
|
+
termcode path/to/main.py # Open a specific file and its folder
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## `/` Command Menu & Shortcuts
|
|
93
|
+
|
|
94
|
+
Open the menu anytime with **`Ctrl+K`**, or press **`/`** when focus is on the file tree or terminal log.
|
|
95
|
+
|
|
96
|
+
| Command | Shortcut | Action |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `/run` | `F5` | Save and run active file in Terminal panel |
|
|
99
|
+
| `/stop` | `F7` | Stop currently running program |
|
|
100
|
+
| `/save` | `Ctrl+S` | Save active file |
|
|
101
|
+
| `/save-as` | `F8` | Save current buffer under a new name |
|
|
102
|
+
| `/new-file` | `Ctrl+N` | Create a new file in the selected folder |
|
|
103
|
+
| `/new-folder` | `F3` | Create a new folder in the selected folder |
|
|
104
|
+
| `/open-file` | `Ctrl+P` | Quick-select and open a file in this folder |
|
|
105
|
+
| `/open-folder` | `Ctrl+O` | Browse & open another folder as workspace root |
|
|
106
|
+
| `/rename` | `F2` | Rename selected file or folder |
|
|
107
|
+
| `/delete` | `F4` | Delete selected file or folder (with confirmation) |
|
|
108
|
+
| `/toggle-sidebar` | `Ctrl+B` | Show or hide the Explorer sidebar |
|
|
109
|
+
| `/toggle-terminal` | `Ctrl+J` | Show or hide the bottom Terminal panel |
|
|
110
|
+
| `/toggle-hidden` | `F9` | Show or hide hidden dotfiles in Explorer |
|
|
111
|
+
| `/terminal-grow` | `Ctrl+Up` | Increase Terminal panel height (or drag header bar) |
|
|
112
|
+
| `/terminal-shrink` | `Ctrl+Down` | Decrease Terminal panel height (or drag header bar) |
|
|
113
|
+
| `/copy-output` | `F10` | Copy selected or full Terminal output |
|
|
114
|
+
| `/clear-output` | `Ctrl+L` | Clear the Terminal output |
|
|
115
|
+
| `/next-tab` | `F11` | Switch to the next open file tab |
|
|
116
|
+
| `/close-tab` | `Ctrl+W` | Close the current file tab |
|
|
117
|
+
| `/split-editor` | `F12` | Toggle side-by-side split editor |
|
|
118
|
+
| `/quit` | `Ctrl+Q` | Exit TermCode |
|
|
119
|
+
|
|
120
|
+
## Running Tests
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
.venv/bin/pytest -v
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT © 2026 Abdullah Al Mamun. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
termcode/__init__.py,sha256=tMvAcseDVlRY2PGfanMgcTKThLyLDc2CWgrK41pV9HM,87
|
|
2
|
+
termcode/app.py,sha256=meLpzu9RIcDN47P_Wg0P7eZK0PYUaVczMHmDeZruNfw,88427
|
|
3
|
+
termcode/buffers.py,sha256=Vk0Qez4y3gWw7LcJVjsimZn5xD5OHhle3hWXE8UQWiE,5531
|
|
4
|
+
termcode/cli.py,sha256=mlCG5sPWdL6GGv3xO-XlCV4z4IdrnOqWg1gTXJE-t1w,2190
|
|
5
|
+
termcode/commands.py,sha256=tYAhVJUBfBO_vr8jAM-R4KhK3igfsBrGtrb6NC4GRuI,6430
|
|
6
|
+
termcode/completions.py,sha256=DHpmDgYPFwzPdESZlcX558D5ssv2le2T33n2jLOUvZs,9414
|
|
7
|
+
termcode/findbar.py,sha256=bt3b8Zx3n-FnIVskvQ1l6R0G2bR4zpnrE7-vkWH45Zo,9322
|
|
8
|
+
termcode/formatting.py,sha256=vre0CF2ZHXz2I4hd1BMRvYayVvs7cGyUXblG4j2u_Ts,13835
|
|
9
|
+
termcode/highlighting.py,sha256=JnqmeY6lEX5iPonS6t2D_TeqSPvWVGJF3HSASAwqykQ,1768
|
|
10
|
+
termcode/modals.py,sha256=sd7w4ithyJNGh_K3stb3BMEuZ14dyEJFcLJikWQzr4M,15869
|
|
11
|
+
termcode/runner.py,sha256=_zqPIMrL3IEe1YSf_-QTUTRy1rI5E6hecIhuFed8-3w,22907
|
|
12
|
+
termcode/search.py,sha256=5CI8JMWFOyhdtnyoCJSS62YEUGNonuaD7QBfx4NSFow,3100
|
|
13
|
+
termcode/styles.tcss,sha256=iAt9joDbsGMAaHIA-3kk716OGBkEOVSdrohRGsg3kvY,12986
|
|
14
|
+
termcode/theme.py,sha256=R0YVn3jqeGEYHuObAn6FXoVqgANK6UlyF9HSR_MN-C0,3590
|
|
15
|
+
termcode/workspace.py,sha256=43TYp9_2G8UcL73ncpixb6LxzNc6qsXIbRqyXqlII2k,8839
|
|
16
|
+
tmcode-0.2.0.dist-info/licenses/LICENSE,sha256=DZYvVXcCuHH-0HgheZ6LOzcQmtGHHzl8G97GR0CQTgM,1074
|
|
17
|
+
tmcode-0.2.0.dist-info/METADATA,sha256=1V5abaP9nDXrpONT6KDH6qvo8Lv_BOWiqDgrwqBFE_A,5716
|
|
18
|
+
tmcode-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
19
|
+
tmcode-0.2.0.dist-info/entry_points.txt,sha256=yxs8wLxO6MWnhYQYlZaKY0Zj-gjqQNNPztgtHWs1qFg,74
|
|
20
|
+
tmcode-0.2.0.dist-info/top_level.txt,sha256=Irhgb6bHgLHZG6ff4BdgJoZuEMK9uxOR9wcwJoXFxvY,9
|
|
21
|
+
tmcode-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Abdullah Al Mamun
|
|
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 @@
|
|
|
1
|
+
termcode
|