diff --git a/README.md b/README.md index f5583717..283348b5 100644 --- a/README.md +++ b/README.md @@ -75,17 +75,17 @@ JEDITOR achieves up to **1000% faster performance** compared to the original JEd | Category | Features | |---|---| -| **Editor** | Multi-tab editing, syntax highlighting, auto-completion (Jedi), line numbers, current line highlighting, search & replace (regex), code folding, bookmarks, occurrence highlighting, line operations | +| **Editor** | Multi-tab editing, syntax highlighting for twelve languages, auto-completion (Jedi and language servers), multiple carets with selections, snippets with mirrored placeholders, split view, minimap, code folding (indentation and braces), bookmarks, occurrence highlighting, line operations | | **Navigation** | Command palette, quick open (go to file), go to symbol, document outline, navigation history (back/forward), TODO/FIXME task panel | | **Execution** | Run Python scripts (F5), debug mode (F9), shell commands, virtual environment detection | -| **Code Quality** | YAPF formatting, PEP8 checking, Ruff linting, JSON reformatting | -| **Git** | Branch management, commit history, side-by-side diff viewer, staging, audit logging | +| **Code Quality** | YAPF formatting, format on save, PEP8 checking, Ruff linting with a problems panel, language-server diagnostics and quick fixes, pytest panel with tracebacks and coverage, JSON reformatting | +| **Git** | Branch management, commit history, side-by-side diff viewer, gutter change markers, per-change staging and revert, inline blame, stash, conflict resolution, audit logging | | **AI** | OpenAI GPT integration via LangChain, interactive chat widget, configurable models & prompts | | **Console** | Interactive shell, Jupyter/IPython console, command history, multi-shell support | | **Browser** | Embedded web browser, URL navigation, in-page search | | **Plugins** | Custom syntax highlighting, UI translations, run configurations, auto-discovery | -| **UI** | Dark/light themes (Qt Material), font customization, dockable panels, system tray, toolbar | -| **i18n** | English, Traditional Chinese, extensible via plugins | +| **UI** | Dark/light themes (Qt Material) with matching editor colours, configurable keyboard shortcuts, font customization, dockable panels, system tray, toolbar, status bar | +| **i18n** | English, Traditional Chinese, Simplified Chinese, Japanese; follows the system language, switches without restarting, extensible via plugins | | **Files** | Auto-save, multi-encoding support (UTF-8, GBK, Latin-1, etc.), recent files, multi-file session restore | --- @@ -174,19 +174,19 @@ The editor launches in a maximized window with a dark amber theme by default. - **Auto-completion** -- Context-aware code suggestions powered by Jedi. - **Line numbers** -- Displayed alongside the editor with current line highlighting. - **Search & Replace** -- Search within the current file, across folders, or project-wide with regex and case-sensitive options. Runs in background threads for large projects. -- **Code Folding** -- Collapse and expand indented blocks (functions, classes, loops) from the gutter fold triangles or the keyboard. Folding is indentation-based and only toggles line visibility -- it never modifies the text, so saving always writes the complete file. Folds self-heal after edits: a fold whose header no longer exists simply reopens instead of hiding the wrong lines. +- **Code Folding** -- Collapse and expand blocks from the gutter fold triangles or the keyboard. Python and other indented files fold on indentation; the C-family languages (JavaScript, TypeScript, Rust, Go, C/C++, Java, JSON) fold on brace pairs instead, so a brace on its own line still opens a region. Braces inside strings and comments are skipped, since one in a string would throw every pair after it out of step. Folding only toggles line visibility -- it never modifies the text, so saving always writes the complete file. Folds self-heal after edits: a fold whose header no longer exists simply reopens instead of hiding the wrong lines. - **Bookmarks** -- Mark lines and jump between them with the keyboard, or click the gutter to toggle. Bookmarks are anchored to the text (via `QTextCursor`), so they follow their code when lines are inserted or removed above them instead of drifting. -- **Multiple Carets** -- `Ctrl+Shift+L` puts a caret at the end of every selected line, and `Alt`-click adds or removes one anywhere. Typing and Backspace then apply at all of them as a single undo step; `Esc` or a plain click returns to one caret. +- **Multiple Carets** -- `Ctrl+Shift+L` puts a caret at the end of every selected line, `Ctrl+Alt+N` adds one at the next occurrence of the word under the caret, `Ctrl+Alt+Shift+Up` / `Down` adds one on the line above or below, and `Alt`-click adds or removes one anywhere. All of them move together with the arrow keys, Home and End, and `Shift` with any of those extends a selection at every caret. Typing, Backspace and Delete apply at all of them as a single undo step, replacing each selection where there is one; `Ctrl+Shift+Esc` or a plain click returns to one caret. - **Split View** (`Ctrl+Alt+\`) -- A second view of the same file, sharing one document: an edit in either side shows up in the other at once, while scrolling and the caret stay independent. -- **Minimap** (`Ctrl+Alt+M`) -- An overview of the whole file drawn as bars following each line's length and indentation, with a band marking what is on screen. Click or drag to jump. Large files are sampled rather than drawn line by line. -- **Snippets** -- Type a trigger word and press Tab to expand it, then Tab through the placeholders with each default value selected. Uses the usual `$1` / `${2:default}` / `$0` notation, so existing snippets drop straight into `snippets.json`; a missing or broken file falls back to the built-in Python set. -- **Test Panel** -- Run pytest from a dock panel and read the results, failures first, with the summary as the status line. Double-click a row to open that test, jumping to the failing line. -- **Language Server Support** -- Non-Python files complete through a language server over stdio (TypeScript, Rust, Go, C/C++, Lua, JSON and more, configurable per suffix), while Python keeps using jedi. A server that is not installed simply means no completions rather than an error. +- **Minimap** (`Ctrl+Alt+M`) -- An overview of the whole file drawn as bars following each line's length and indentation, with a band marking what is on screen. Marks down the sides show lint diagnostics, git changes, and whatever you are currently looking for -- the search box's hits while a search is open, and otherwise the other occurrences of the word under the caret. Click or drag to jump. Large files are sampled rather than drawn line by line. +- **Snippets** -- Type a trigger word and press Tab to expand it, then Tab through the placeholders with each default value selected. A placeholder used more than once only has to be typed once: the repeats follow as you type. Uses the usual `$1` / `${2:default}` / `$0` notation, so existing snippets drop straight into `snippets.json`, and there are per-language sets on top of the shared ones. Edit them from Tab > Edit Snippets rather than by hand; a missing or broken file falls back to the built-in Python set. +- **Test Panel** -- Run pytest from a dock panel and read the results, failures first, with the summary as the status line. Selecting a failure shows its traceback in a pane below the list, and a coverage box adds the total beside the summary (which needs `pytest-cov` in the project being tested). Run everything, only the selection, or only what failed last time; double-click a row to open that test at the failing line. +- **Language Server Support** -- Non-Python files get completion, hover, go-to-definition, rename, formatting, signature help, find-references, quick fixes and document symbols from a language server over stdio (TypeScript, Rust, Go, C/C++, Lua, JSON and more, configurable per suffix), while Python keeps using jedi. One server is shared by every tab that needs it, keyed by command and project root, rather than one process per open file. Diagnostics appear in the same underlines and Problems panel as ruff's. A server that is not installed simply means no completions rather than an error. - **Encoding & Line Endings** -- A file's encoding and line-ending style are detected when it opens and written back unchanged when it saves, so editing one line of a CRLF file no longer rewrites every line. Both can be changed from the File menu; changing the encoding re-reads an unmodified file so mojibake can be fixed in place, and never discards unsaved work. - **Format on Save** -- Optionally run yapf when a file is saved, keeping the caret on its line. Source that cannot be parsed is left alone rather than blocking the save. - **Indent Guides & Trailing Whitespace** -- A vertical guide at each indentation level and shading on stray end-of-line whitespace, both toggleable from the Style menu. - **Lint Diagnostics** -- Findings from `ruff` are underlined in the editor and listed in a Problems dock panel (rule, message, line), with double-click to jump. The **buffer** is checked, not the file on disk, so unsaved edits are covered; the run happens on a worker thread after typing pauses, and a stale result from a superseded run is discarded. If `ruff` is not installed, or a run fails, the editor simply shows no diagnostics rather than reporting an error. -- **Git Change Markers** -- The gutter shows how the file differs from its last commit: a green bar for added lines, orange for modified, and a thin red line where lines were deleted. Jump between changes with `Ctrl+Alt+Down` / `Ctrl+Alt+Up`, revert the change under the caret back to its committed form with `Ctrl+Alt+Z` (one undo step), and open a side-by-side diff of the whole file against HEAD from the Git menu. `Ctrl+Alt+B` toggles inline blame, showing the commit, author and summary that last touched each line. The committed version is read on a background thread when the file opens, and the comparison itself is a pure in-memory diff, recomputed only after typing pauses -- so editing never waits on git. Files outside a repository, or not yet committed, simply show no markers. +- **Git Change Markers** -- The gutter shows how the file differs from its last commit: a green bar for added lines, orange for modified, and a thin red line where lines were deleted. Jump between changes with `F7` / `Shift+F7`, revert the change under the caret back to its committed form with `Ctrl+Alt+Z` (one undo step), and stage just that change from the right-click menu. `Ctrl+Alt+B` toggles inline blame, showing the commit, author and summary that last touched each line. The Git menu opens a side-by-side diff of the whole file against HEAD, or against what is staged -- after staging change by change, that second one is what shows which parts actually went into the index. The right-click menu also unstages the file and commits what is staged. The committed version is read on a background thread when the file opens, and the comparison itself is a pure in-memory diff, recomputed only after typing pauses -- so editing never waits on git. Files outside a repository, or not yet committed, simply show no markers. - **Occurrence Highlighting** -- Placing the caret on an identifier highlights every other whole-word occurrence of it in the file. Keywords and single characters are ignored, and the scan is skipped on very large files to keep caret movement instant. - **Line Operations** -- Delete the current line or selection (`Ctrl+Shift+D`), sort selected lines (`Ctrl+Alt+S`), join selected lines into one (`Ctrl+Shift+J`), and (from the Text menu) natural sort, remove duplicate lines, remove blank lines, reverse line order, or align lines on a delimiter (e.g. `=`). Each is a single undo step. - **Duplicate** (`Ctrl+D`) -- Duplicates the selection when there is one (selecting the new copy), or the whole line when there isn't. @@ -195,7 +195,8 @@ The editor launches in a maximized window with a dark amber theme by default. - **Increment / Decrement Number** -- Bump the integer under the caret up or down (`Ctrl+Alt+Up` / `Ctrl+Alt+Down`), handling negative signs and growing widths. - **Rename in File** (`F2`) -- Rename every whole-word occurrence of the identifier under the caret across the file as a single undo step. Word boundaries protect partial matches (renaming `val` never touches `value`). - **Navigation History** -- Jump back and forward through your cursor-jump history like a browser (`Alt+Left` / `Alt+Right`). A jump records both where you came from and where you went, so "back" returns to where you started. -- **Document Outline** -- A dockable tree of the current file's classes, methods, functions and module variables (parsed with `ast`, so no code runs). Double-click to jump to a definition. +- **Document Outline** -- A dockable tree of the current file's classes, methods, functions and module variables. Python is parsed with `ast`, so no code runs; other languages are asked of their language server, so a TypeScript or Rust file gets an outline too. Double-click to jump to a definition. +- **Keyboard Shortcuts** (Style > Keyboard Shortcuts) -- Every command's keys in one list, editable. Two commands claiming the same keys cannot be saved, because Qt runs neither of them when that happens; a change takes effect immediately, and only what differs from a default is stored. - **Variable Inspector** -- Inspect and debug variables during code execution. ### Navigation @@ -243,7 +244,9 @@ JEDITOR includes a full-featured Git client: - **Commit history** -- View commit metadata (author, date, message) in a table view. - **Side-by-side diff viewer** -- Color-highlighted code comparison with line numbers. - **Multi-file diff** -- Compare changes across multiple files. -- **Staging** -- Stage and unstage individual file changes. +- **Staging** -- Stage and unstage individual file changes, or one change at a time from the editor's gutter. +- **Stash** -- Put the current changes away, list what is stashed, and take one back. +- **Conflict resolution** -- List the files left in conflict after a merge and settle one by keeping either side. - **Audit logging** -- All Git operations are logged for tracking and compliance. ### AI Assistant @@ -292,9 +295,11 @@ Plugins are automatically discovered from the `jeditor_plugins/` directory. See ### Multi-Language UI -- **English** -- Full English interface (default). -- **Traditional Chinese** (繁體中文) -- Complete Traditional Chinese translation. -- **Extensible** -- Add new languages via the plugin system. +- **English**, **Traditional Chinese** (繁體中文), **Simplified Chinese** (简体中文) and **Japanese** (日本語) -- each complete. Simplified Chinese is written in mainland vocabulary rather than converted from the traditional text, where 檔案/文件, 資料夾/文件夹 and 程式/程序 all differ. +- **Follows the system on a first run** -- the language is taken from the system locale rather than defaulting to English, with Chinese resolved by script: `zh-Hant` and the Taiwan, Hong Kong and Macau regions get traditional characters, and anything else simplified. What is detected is recorded, so from then on it is simply the chosen language. +- **Changes without restarting** -- picking a language relabels the menus, toolbar, panels, tabs and status bar at once. File and branch names on tabs are left alone. +- **Falls back to English** -- a key a language has not translated shows the English text rather than a blank label, so a language can be added before it is finished. +- **Extensible** -- add new languages via the plugin system. Locale rules for Korean, Spanish, French, German, Russian and Portuguese are already in place; each needs only its dictionary. --- @@ -326,12 +331,9 @@ Plugins are automatically discovered from the `jeditor_plugins/` directory. See | `Ctrl+Alt+Up` | Increment number under caret | | `Ctrl+Alt+Down` | Decrement number under caret | | `F2` | Rename occurrences in file | -| `Ctrl+D` | Duplicate line / selection | -| `Alt+Up` / `Alt+Down` | Move line up / down | -| `Ctrl+/` | Toggle comment | | `Ctrl+Shift+L` | Caret at the end of every selected line | | `Ctrl+Alt+N` | Add caret at next occurrence | -| `Ctrl+Alt+Shift+Up` / `Down` | Add caret above / below | +| `Ctrl+Alt+Shift+Up` / `Ctrl+Alt+Shift+Down` | Add caret above / below | | `Ctrl+Shift+Esc` | Back to a single caret | | `Ctrl+Shift+R` | Start / stop macro recording | | `Ctrl+Shift+G` | Play macro | @@ -345,6 +347,11 @@ Plugins are automatically discovered from the `jeditor_plugins/` directory. See | `Ctrl+Shift+Y` | YAPF Python format | | `Ctrl+Alt+P` | PEP8 format checker | | `Ctrl+F` | Find text (editor, browser) | +| `Ctrl+Shift+F` | Search across files | +| `Alt+W` | Word wrap | +| `Ctrl+Shift+P` | Install a package with pip | +| `Ctrl+Shift+U` | Upgrade and install packages | +| `Ctrl+Shift+V` | Change the Python interpreter | | `Ctrl+H` | Find and replace | | `Ctrl+G` | Go to line | | `F5` | Run program | @@ -355,6 +362,19 @@ Plugins are automatically discovered from the `jeditor_plugins/` directory. See | `F10` / `F11` / `Shift+F11` | Debugger: step over / into / out | | `Up/Down` | Command history (console) | +Every shortcut above can be reassigned from **Style > Keyboard Shortcuts**. The keys +below are handled by the editing area itself, so they are fixed: + +| Shortcut | Action | +|---|---| +| `Ctrl+D` | Duplicate line / selection | +| `Ctrl+/` | Toggle comment | +| `Alt+Up` / `Alt+Down` | Move line up / down | +| `Ctrl+B` | Jump to the definition under the caret | +| `Ctrl+Shift+\` | Jump to the matching bracket | +| `Ctrl++` / `Ctrl+-` | Zoom the editor font in / out | +| `Tab` / `Shift+Tab` | Indent / unindent the line or selection | + --- ## Project Architecture @@ -367,8 +387,15 @@ je_editor/ │ │ ├── auto_save/ # Automatic file saving │ │ ├── bookmark/ # Bookmark manager (QTextCursor-anchored) │ │ ├── code_format/ # YAPF & PEP8 formatting +│ │ ├── breakpoint/ # Breakpoint markers │ │ ├── code_process/ # Program execution (ExecManager) │ │ ├── folding/ # Code folding manager +│ │ ├── git_diff/ # Gutter change markers and inline blame +│ │ ├── lint/ # Lint diagnostics for one editor +│ │ ├── lsp/ # Language server client and shared sessions +│ │ ├── minimap/ # Minimap widget +│ │ ├── multi_cursor/ # Extra caret management +│ │ ├── snippets/ # Snippet expansion │ │ ├── shell_process/ # Shell execution (ShellManager) │ │ ├── syntax/ # Syntax highlighting engine │ │ ├── plaintext_code_edit/ # Plain text editor widget @@ -391,8 +418,11 @@ je_editor/ │ ├── menu/ # Menu bar system │ ├── outline_panel/ # Document outline (symbol tree) │ ├── plugin_browser/ # Plugin management UI -│ ├── save_settings/ # Settings persistence +│ ├── problems_panel/ # Lint diagnostics panel +│ ├── retranslate.py # Relabels the interface when the language changes +│ ├── save_settings/ # Settings persistence, shortcuts and colours │ ├── system_tray/ # System tray integration +│ ├── test_panel/ # pytest results, tracebacks and coverage │ ├── todo_panel/ # TODO/FIXME task panel │ └── toolbar/ # Toolbar actions ├── code_scan/ # Code scanning @@ -408,28 +438,44 @@ je_editor/ ├── utils/ # Utilities │ ├── align/ # Align lines on a delimiter (Qt-free) │ ├── bookmark/ # Bookmark navigation logic (Qt-free) +│ ├── browser/ # Embedded Chromium flags (Qt-free) │ ├── case_convert/ # Naming-style conversion (Qt-free) -│ ├── code_folding/ # Fold region computation (Qt-free) +│ ├── code_folding/ # Fold regions, by indentation and by braces (Qt-free) │ ├── command_palette/ # Fuzzy matching & ranking (Qt-free) +│ ├── debugger/ # pdb command building (Qt-free) │ ├── encode_decode/ # Base64/URL/HTML/JSON transforms (Qt-free) │ ├── encodings/ # Encoding detection │ ├── exception/ # Custom exceptions │ ├── file/ # File I/O (open/save) +│ ├── file_diff/ # Line status, hunks and unified diff (Qt-free) │ ├── file_scan/ # Shared ignore rules, file indexer, TODO scanner +│ ├── format_code/ # yapf formatting (Qt-free) │ ├── indentation/ # Tab/space conversion + indent detection (Qt-free) │ ├── json_format/ # JSON formatting │ ├── line_ops/ # Line operation transforms (Qt-free) +│ ├── lint/ # Ruff diagnostic parsing (Qt-free) │ ├── logging/ # Logging setup -│ ├── multi_language/ # i18n (English, Traditional Chinese) +│ ├── lsp/ # LSP framing, protocol and server registry (Qt-free) +│ ├── macro/ # Keystroke macro recording (Qt-free) +│ ├── minimap/ # Minimap geometry and sampling (Qt-free) +│ ├── multi_cursor/ # Extra caret positions and edit shifting (Qt-free) +│ ├── multi_language/ # i18n: English, Traditional and Simplified Chinese, +│ │ # Japanese, locale matching, live relabelling │ ├── navigation/ # Cursor jump history (Qt-free) │ ├── number_ops/ # Number-under-caret adjustment (Qt-free) │ ├── occurrence/ # Word occurrence finding + whole-word rename (Qt-free) │ ├── redirect_manager/ # Output stream redirection -│ ├── selection/ # Smart selection ranges (Qt-free) +│ ├── selection/ # Smart selection ranges + surround (Qt-free) │ ├── session/ # Multi-file session restore (Qt-free) -│ ├── symbols/ # Python symbol extraction + outline tree (ast-based) +│ ├── shortcuts/ # The keyboard shortcut table (Qt-free) +│ ├── snippets/ # Snippet expansion and tab stops (Qt-free) +│ ├── status/ # Status bar text (Qt-free) +│ ├── symbols/ # Symbol extraction: ast for Python, the server elsewhere +│ ├── syntax/ # Per-language highlighting rules (Qt-free) +│ ├── test_runner/ # pytest output parsing (Qt-free) │ ├── text_cleanup/ # Trailing whitespace / newline cleanup (Qt-free) │ ├── text_stats/ # Line/word/char statistics (Qt-free) +│ ├── theme/ # Dark and light editor colours (Qt-free) │ └── venv_check/ # Virtual environment detection ├── __init__.py # Public API ├── __main__.py # CLI entry point @@ -493,8 +539,9 @@ JEDITOR stores user settings in the `.jeditor/` directory: | File | Content | |---|---| -| `user_setting.json` | General preferences (font, theme, recent files) | -| `user_color_setting.json` | Syntax highlighting color scheme | +| `user_setting.json` | General preferences (font, theme, language, recent files, open tabs, reassigned shortcuts) | +| `user_color_setting.json` | Editor and output colors, including syntax highlighting | +| `ai_config.json` | AI assistant settings — read at startup, never written; create it yourself | --- diff --git a/README/README_zh-CN.md b/README/README_zh-CN.md index 1508d77a..ec3035ca 100644 --- a/README/README_zh-CN.md +++ b/README/README_zh-CN.md @@ -43,6 +43,7 @@ - [快速开始](#快速开始) - [功能详情](#功能详情) - [代码编辑](#代码编辑) + - [导航](#导航) - [程序执行与调试](#程序执行与调试) - [代码质量与格式化](#代码质量与格式化) - [文件操作](#文件操作) @@ -75,17 +76,18 @@ JEDITOR 是原始 JEditor 项目的完全重写版本,从零开始重新打造 | 类别 | 功能 | |---|---| -| **编辑器** | 多标签页编辑、语法高亮、自动补全(Jedi)、行号显示、当前行高亮、搜索与替换(支持正则表达式) | +| **编辑器** | 多标签页编辑、十二种语言的语法高亮、自动补全(Jedi 与语言服务器)、可选中的多光标、支持联动占位符的代码片段、分屏视图、缩略图、代码折叠(缩进与花括号)、书签、出现处高亮、行操作 | +| **导航** | 命令面板、快速打开(转到文件)、转到符号、文档大纲、导航历史(前进/后退)、TODO/FIXME 任务面板 | | **执行** | 运行 Python 脚本(F5)、调试模式(F9)、Shell 命令、虚拟环境检测 | -| **代码质量** | YAPF 格式化、PEP8 检查、Ruff 静态分析、JSON 重新格式化 | -| **Git** | 分支管理、提交历史、并排差异查看器、暂存区操作、审计日志 | +| **代码质量** | YAPF 格式化、保存时格式化、PEP8 检查、Ruff 静态分析与问题面板、语言服务器诊断与快速修复、带 traceback 与覆盖率的 pytest 面板、JSON 重新格式化 | +| **Git** | 分支管理、提交历史、并排差异查看器、行号区变更标记、逐处变更暂存与还原、行内 blame、贮藏(stash)、冲突解决、审计日志 | | **AI** | 通过 LangChain 集成 OpenAI GPT、交互式聊天面板、可配置模型与提示词 | | **控制台** | 交互式 Shell、Jupyter/IPython 控制台、命令历史、多 Shell 支持 | | **浏览器** | 内嵌网页浏览器、URL 导航、页面内搜索 | | **插件** | 自定义语法高亮、UI 翻译、运行配置、自动发现 | -| **界面** | 深色/浅色主题(Qt Material)、字体自定义、可停靠面板、系统托盘、工具栏 | -| **国际化** | 英文、繁体中文,可通过插件扩展 | -| **文件** | 自动保存、多编码支持(UTF-8、GBK、Latin-1 等)、最近打开的文件 | +| **界面** | 深色/浅色主题(Qt Material)与配套的编辑器配色、可配置的键盘快捷键、字体自定义、可停靠面板、系统托盘、工具栏、状态栏 | +| **国际化** | 英文、繁体中文、简体中文、日本語;跟随系统语言、无需重启即可切换、可通过插件扩展 | +| **文件** | 自动保存、多编码支持(UTF-8、GBK、Latin-1 等)、最近打开的文件、多文件会话恢复 | --- @@ -173,12 +175,42 @@ start_editor() - **自动补全** -- 由 Jedi 驱动的上下文感知代码建议。 - **行号显示** -- 编辑器旁显示行号,并高亮当前行。 - **搜索与替换** -- 支持在当前文件、文件夹或整个项目中搜索,提供正则表达式与区分大小写选项。大型项目使用后台线程处理。 +- **代码折叠** -- 从行号区的折叠三角或键盘展开与收起代码块。Python 等以缩进表达层级的文件按缩进折叠;C 系语言(JavaScript、TypeScript、Rust、Go、C/C++、Java、JSON)则按花括号配对折叠,因此单独一行的花括号同样能开启一个区域。位于字符串与注释中的花括号会被跳过——字符串里的一个括号会让后面每一组配对全部错位。折叠只切换行的显示与否,完全不修改文本,因此保存时一定写入完整文件。折叠还能自我修复:标题行已不存在的折叠会直接展开,而不是藏错行。 +- **书签** -- 标记行并用键盘在书签之间跳转,也可点击行号区切换。书签锚定在文本上(通过 `QTextCursor`),因此在其上方插入或删除行时会跟着代码移动,而不会跑偏。 +- **多光标** -- `Ctrl+Shift+L` 在每个选中行的行尾放一个光标,`Ctrl+Alt+N` 在光标所在词的下一个出现处加一个,`Ctrl+Alt+Shift+Up` / `Down` 在上一行或下一行加一个,`Alt` + 点击则可在任意位置添加或移除。所有光标会随方向键、Home 与 End 一起移动,按住 `Shift` 配合这些键则在每个光标各自扩大选区。输入、Backspace 与 Delete 会在所有光标上生效并算作一次撤销,有选区的位置则以输入内容替换;`Ctrl+Shift+Esc` 或直接点击即可回到单个光标。 +- **分屏视图**(`Ctrl+Alt+\`)-- 同一文件的第二个视图,两者共用同一份文档:任一侧的编辑会立刻反映到另一侧,而滚动位置与光标各自独立。 +- **缩略图**(`Ctrl+Alt+M`)-- 以长条呈现每一行长度与缩进的整文件概览,并用色带标示当前屏幕上的范围。两侧的标记显示 lint 诊断、git 变更,以及您当前正在查找的内容——搜索框打开时是搜索命中处,否则是光标所在词的其他出现处。点击或拖动即可跳转。大文件采用采样绘制,而非逐行绘制。 +- **代码片段** -- 输入触发词后按 Tab 展开,再用 Tab 在占位符之间移动,每个默认值都会自动选中。重复出现的占位符只需输入一次,其余位置会随着输入同步更新。采用常见的 `$1` / `${2:default}` / `$0` 记法,因此已有片段可直接放进 `snippets.json`,并支持各语言专属的片段集。请从 Tab > 编辑代码片段 进行编辑,而不要手动改文件;文件缺失或损坏时会回退到内置的 Python 片段集。 +- **测试面板** -- 从停靠面板运行 pytest 并查看结果,失败项排在最前面,摘要作为状态行。选中一条失败会在列表下方的窗格显示其 traceback,覆盖率框则在摘要旁显示总覆盖率(需要被测项目安装 `pytest-cov`)。可运行全部、仅运行选中项,或只重跑上次失败的项;双击一行可在失败的那一行打开该测试。 +- **语言服务器支持** -- 非 Python 的文件可通过 stdio 从语言服务器获得补全、hover、转到定义、重命名、格式化、函数签名提示、查找引用、快速修复与文档符号(TypeScript、Rust、Go、C/C++、Lua、JSON 等,可按扩展名配置),Python 则继续使用 jedi。每个需要服务器的标签页共用同一个服务器实例,以「命令 + 项目根目录」为键,而不是每打开一个文件就起一个进程。诊断会与 ruff 的诊断显示在同样的下划线与问题面板中。未安装的服务器只意味着没有补全,不会产生错误。 +- **编码与换行符** -- 文件的编码与换行符会在打开时检测、保存时原样写回,因此修改 CRLF 文件的一行不会再重写整个文件。两者都可从 File 菜单更改;更改编码会重新读取未修改的文件,让乱码可以就地修正,且永远不会丢弃未保存的内容。 +- **保存时格式化** -- 可选择在保存文件时运行 yapf,并让光标停留在原来的行上。无法解析的代码会原样保留,而不会阻挡保存。 +- **缩进参考线与行尾空白** -- 每个缩进层级的竖直参考线,以及行尾多余空白的标示,两者都可从 UI 风格菜单切换。 +- **Lint 诊断** -- `ruff` 的检查结果会在编辑器中以下划线标示,并列在问题(Problems)停靠面板中(规则、信息、行号),双击即可跳转。检查的是 **缓冲区** 而非磁盘上的文件,因此未保存的编辑同样会被检查;检查在停止输入后于工作线程执行,被取代的过时结果会被丢弃。若未安装 `ruff` 或运行失败,编辑器只会不显示诊断,而不会报错。 +- **Git 变更标记** -- 行号区显示文件与最后一次提交的差异:绿色长条表示新增、橙色表示修改、细红线表示该处有行被删除。用 `F7` / `Shift+F7` 在变更之间跳转,用 `Ctrl+Alt+Z` 将光标所在的变更还原成已提交的内容(一次撤销),也可从右键菜单只暂存那一处变更。`Ctrl+Alt+B` 切换行内 blame,显示最后改动每一行的提交、作者与摘要。Git 菜单可打开整个文件与 `HEAD` 的并排差异,或与暂存区内容的差异——在逐处变更暂存之后,后者正好显示哪些部分真的进了索引。右键菜单同时提供取消整个文件的暂存与提交已暂存的内容。已提交的版本在文件打开时于后台线程读取,比对本身则是纯内存中的 diff,只在停止输入后重新计算,因此编辑永远不必等待 git。不在仓库中或尚未提交的文件就单纯不显示标记。 +- **出现处高亮** -- 将光标放在标识符上时,文件中该标识符的其他全词出现处都会被高亮。关键字与单个字符会被忽略,超大文件则跳过扫描,以保持光标移动的即时性。 +- **行操作** -- 删除当前行或选中内容(`Ctrl+Shift+D`)、排序选中的行(`Ctrl+Alt+S`)、将选中的行合并成一行(`Ctrl+Shift+J`),以及(在 Text 菜单中)自然排序、删除重复行、删除空行、反转行顺序,或按分隔符(例如 `=`)对齐。每一项都算作一次撤销。 +- **复制行**(`Ctrl+D`)-- 有选区时复制选中内容并选中新的副本,没有时则复制整行。 +- **大小写转换**(Text 菜单)-- 将选中内容转为大写或小写,并保持选中状态。 +- **智能选择** -- 由词 → 行 → 外层缩进块 → 整个文件逐步向外扩大选区(`Ctrl+Alt+Right`),并可逐步收回(`Ctrl+Alt+Left`)。收回只会回溯之前的扩大,手动改变选区则会重置历史。 +- **数字加减** -- 将光标处的整数加一或减一(`Ctrl+Alt+Up` / `Ctrl+Alt+Down`),并正确处理负号与位数变化。 +- **文件内重命名**(`F2`)-- 将光标所在标识符在整个文件中的每个全词出现处一次改名,算作一次撤销。词边界可保护部分匹配的情况(改 `val` 绝不会动到 `value`)。 +- **导航历史** -- 像浏览器一样在光标跳转历史中前进后退(`Alt+Left` / `Alt+Right`)。一次跳转会同时记录来源与目的地,因此「后退」会回到您原本所在的位置。 +- **文档大纲** -- 可停靠的树状面板,列出当前文件的类、方法、函数与模块级变量。Python 用 `ast` 解析,不会执行任何代码;其他语言则向其语言服务器询问,因此 TypeScript 或 Rust 文件同样有大纲。双击即可跳到定义。 +- **键盘快捷键**(UI 风格 > 键盘快捷键)-- 所有命令的按键集中在一份可编辑的列表中。两个命令不能共用同一组按键,因为发生这种情况时 Qt 两个都不会执行;改动立即生效,而且只有与默认值不同的项会被记录。 - **变量检查器** -- 在程序执行期间检查与调试变量。 +### 导航 + +- **命令面板**(Ctrl+Shift+A)-- 以名称或菜单路径模糊搜索任何菜单命令并直接执行,不必在菜单中翻找。结果按词边界、连续字符与前缀排序,每一行也会显示该命令自己的快捷键。 +- **快速打开/转到文件**(Ctrl+P)-- 以文件名 *或* 文件夹路径模糊搜索项目树。索引在后台线程建立,并跳过版本控制、缓存、虚拟环境与构建目录以及二进制文件类型。开头输入 `>` 可将同一个选择器切换成命令模式。 +- **转到符号**(Ctrl+Shift+O)-- 跳到当前 Python 文件中的任何类、函数、方法或模块级变量。符号用标准库的 `ast` 模块解析,因此绝不会执行用户代码;无法解析的文件在您输入时只会没有符号,而不会报错。 +- **TODO 面板**(Tab > 工具,或作为停靠面板)-- 扫描项目中的 `TODO`、`FIXME`、`HACK`、`XXX`、`BUG`、`NOTE` 与 `OPTIMIZE` 注释,涵盖 Python、C 系、HTML、SQL 等注释风格。可按标签筛选,双击一行即可在该行打开文件。标签只有出现在注释符之后才会被报告,因此普通字符串不会被误判。 + ### 程序执行与调试 - **运行 Python 脚本**(F5)-- 执行当前文件并实时流式输出。 -- **调试模式**(F9)-- 启动 Python 调试器进行逐步调试。 +- **调试模式**(F9)-- 启动 Python 调试器进行逐步调试:`Ctrl+F9` 切换断点、`Ctrl+F5` 继续执行、`F10` / `F11` / `Shift+F11` 分别为单步跳过/进入/跳出。断点锚定在文本上,因此会跟着代码移动。 - **Shell 命令** -- 在编辑器内直接执行任意 Shell/终端命令。 - **虚拟环境检测** -- 自动检测并激活 Python 虚拟环境。 - **进程管理** -- 停止单个或所有运行中的进程。 @@ -190,12 +222,18 @@ start_editor() - **PEP8 检查**(Ctrl+Alt+P)-- 验证代码是否符合 PEP8 风格指南。 - **Ruff 静态分析** -- 在后台线程中执行快速且全面的 Python 静态分析。 - **JSON 重新格式化**(Ctrl+J)-- 美化打印并验证 JSON 内容。 +- **删除行尾空白**(Text 菜单)-- 去除每一行结尾的空白,算作一次撤销,并保留光标位置。 +- **转换缩进**(Text 菜单)-- 在 Tab 与空格之间转换前导缩进(按您设置的缩进大小)。只处理前导空白,因此字符串内的 Tab 与空格永远不会被改动。 +- **可配置的缩进宽度** -- Tab 缩进、取消缩进与 Enter 自动缩进都遵循设置的缩进大小(`Text > Indent Size`),而打开文件时也会从文件本身的内容自动检测缩进宽度。 +- **文本转换**(Text 菜单)-- 大小写转换(大写/小写/互换/标题式)、命名风格转换(`snake_case` / `camelCase` / `PascalCase` / `kebab-case`)、进制转换(十六进制/十进制/二进制),以及编码解码工具(Base64、URL、HTML 实体、JSON 字符串转义)。解码失败时原文保持不变。 +- **统计**(Text 菜单)-- 整个文档或当前选区的行数、词数与字符数。 ### 文件操作 - **创建、打开、保存**文件,使用标准快捷键(Ctrl+N、Ctrl+O、Ctrl+S)。 - **打开文件夹**(Ctrl+K)-- 浏览项目目录结构。 - **自动保存** -- 自动定期保存文件,防止数据丢失。 +- **会话恢复** -- 重新打开上次关闭时所有打开的文件,而不只是最后一个。不存在、重复与已打开的文件会被跳过,列表有上限,损坏或手工改过的配置文件也绝不会挡住启动。可在 `.jeditor/user_setting.json` 中将 `restore_session` 设为 `false` 禁用。 - **多编码支持** -- 无缝处理 UTF-8、GBK、Latin-1 及其他编码,具备自动检测功能。 - **最近打开的文件** -- 快速访问之前打开的文件。 @@ -207,7 +245,9 @@ JEDITOR 内置完整的 Git 客户端: - **提交历史** -- 以表格形式查看提交的元数据(作者、日期、信息)。 - **并排差异查看器** -- 具有行号的彩色高亮代码比较。 - **多文件差异** -- 比较多个文件间的变更。 -- **暂存区操作** -- 暂存或取消暂存单个文件的变更。 +- **暂存区操作** -- 暂存或取消暂存单个文件的变更,也可从编辑器的行号区逐处变更暂存。 +- **贮藏(Stash)** -- 把当前的变更先收起来、列出贮藏的内容,并可取回其中一条。 +- **冲突解决** -- 列出合并后仍处于冲突的文件,并可选择保留其中一方来解决。 - **审计日志** -- 记录所有 Git 操作,方便追踪与合规。 ### AI 助手 @@ -248,7 +288,7 @@ JEDITOR 支持模块化的插件架构,提供四种插件类型: ### 主题与自定义 -- **深色/浅色主题** -- Qt Material 主题,琥珀色配色方案。 +- **深色/浅色主题** -- Qt Material 主题,琥珀色配色方案。编辑器本身的颜色会跟随窗口样式,您自己挑过的颜色则不会被覆盖。 - **字体自定义** -- 更改编辑器与 UI 的字体族与大小。 - **可停靠面板** -- 通过停靠/取消停靠面板重新排列 UI 布局。 - **系统托盘** -- 将编辑器最小化至系统托盘。 @@ -256,9 +296,11 @@ JEDITOR 支持模块化的插件架构,提供四种插件类型: ### 多语言界面 -- **英文** -- 完整的英文界面(默认)。 -- **繁体中文** -- 完整的繁体中文翻译。 -- **可扩展** -- 通过插件系统添加更多语言。 +- **英文**、**繁体中文**、**简体中文** 与 **日本語** -- 四种都是完整的。简体中文以中国大陆的用词直接撰写,而非由繁体转换——文件/檔案、文件夹/資料夾、程序/程式 这些词在两地并不相同。 +- **首次启动跟随系统** -- 语言取自系统的区域设置,而不是一律默认英文;中文按书写系统判断:`zh-Hant` 以及台湾、香港、澳门地区使用繁体,其余使用简体。检测到的结果会被记录下来,之后就单纯是您所选的语言。 +- **无需重启即可切换** -- 选择语言后,菜单、工具栏、面板、标签页与状态栏会立刻换成新语言。标签页上的文件名与分支名保持不变。 +- **回退英文** -- 某个语言尚未翻译的字符串会显示英文原文,而不是空白标签,因此一种语言可以在尚未完成时就先加入。 +- **可扩展** -- 通过插件系统添加更多语言。韩文、西班牙文、法文、德文、俄文与葡萄牙文的区域判断规则都已就绪,各自只差一份词典。 --- @@ -270,15 +312,70 @@ JEDITOR 支持模块化的插件架构,提供四种插件类型: | `Ctrl+O` | 打开文件 | | `Ctrl+K` | 打开文件夹 | | `Ctrl+S` | 保存文件 | +| `Ctrl+Shift+S` | 保存所有已修改的标签页 | +| `Ctrl+Shift+A` | 命令面板 | +| `Ctrl+P` | 快速打开(转到文件) | +| `Ctrl+Shift+O` | 转到符号 | +| `Ctrl+Shift+[` | 切换光标所在的折叠 | +| `Ctrl+Alt+[` | 全部折叠 | +| `Ctrl+Alt+]` | 全部展开 | +| `Ctrl+Alt+K` | 切换书签 | +| `Ctrl+Alt+L` | 下一个书签 | +| `Ctrl+Alt+J` | 上一个书签 | +| `Alt+Left` | 后退 | +| `Alt+Right` | 前进 | +| `Ctrl+Shift+D` | 删除当前行/选中内容 | +| `Ctrl+Alt+S` | 排序选中的行 | +| `Ctrl+Shift+J` | 合并选中的行 | +| `Ctrl+Alt+Right` | 扩大选区 | +| `Ctrl+Alt+Left` | 收回选区 | +| `Ctrl+Alt+Up` | 光标处的数字加一 | +| `Ctrl+Alt+Down` | 光标处的数字减一 | +| `F2` | 文件内重命名所有出现处 | +| `Ctrl+Shift+L` | 在每个选中行的行尾放一个光标 | +| `Ctrl+Alt+N` | 在下一个出现处加一个光标 | +| `Ctrl+Alt+Shift+Up` / `Ctrl+Alt+Shift+Down` | 在上一行/下一行加一个光标 | +| `Ctrl+Shift+Esc` | 回到单个光标 | +| `Ctrl+Shift+R` | 开始/结束录制宏 | +| `Ctrl+Shift+G` | 回放宏 | +| `Ctrl+Alt+E` | 最近位置 | +| `Ctrl+Alt+\` | 切换分屏视图 | +| `Ctrl+Alt+M` | 切换缩略图 | +| `F7` / `Shift+F7` | 下一处/上一处变更 | +| `Ctrl+Alt+Z` | 还原光标所在的变更 | +| `Ctrl+Alt+B` | 切换行内 blame | | `Ctrl+J` | 重新格式化 JSON | | `Ctrl+Shift+Y` | YAPF Python 格式化 | | `Ctrl+Alt+P` | PEP8 格式检查 | -| `Ctrl+F` | 搜索文字(浏览器) | +| `Ctrl+F` | 搜索文字(编辑器、浏览器) | +| `Ctrl+Shift+F` | 跨文件搜索 | +| `Alt+W` | 自动换行 | +| `Ctrl+Shift+P` | 用 pip 安装包 | +| `Ctrl+Shift+U` | 升级与安装包 | +| `Ctrl+Shift+V` | 切换 Python 解释器 | +| `Ctrl+H` | 搜索与替换 | +| `Ctrl+G` | 跳到指定行 | | `F5` | 运行程序 | | `F9` | 调试 | | `Shift+F5` | 停止程序 | +| `Ctrl+F9` | 切换断点 | +| `Ctrl+F5` | 调试器:继续执行 | +| `F10` / `F11` / `Shift+F11` | 调试器:单步跳过/进入/跳出 | | `上/下方向键` | 命令历史(控制台) | +上表所有快捷键都可从 **UI 风格 > 键盘快捷键** 重新指定。以下按键由编辑区本身处理, +因此是固定的: + +| 快捷键 | 操作 | +|---|---| +| `Ctrl+D` | 复制行/选中内容 | +| `Ctrl+/` | 切换注释 | +| `Alt+Up` / `Alt+Down` | 将该行上移/下移 | +| `Ctrl+B` | 跳到光标处符号的定义 | +| `Ctrl+Shift+\` | 跳到匹配的括号 | +| `Ctrl++` / `Ctrl+-` | 放大/缩小编辑器字体 | +| `Tab` / `Shift+Tab` | 将该行或选中内容缩进/取消缩进 | + --- ## 项目架构 @@ -289,8 +386,17 @@ je_editor/ │ ├── browser/ # 内嵌网页浏览器 │ ├── code/ # 核心代码编辑 │ │ ├── auto_save/ # 自动保存 +│ │ ├── bookmark/ # 书签管理(以 QTextCursor 锚定) +│ │ ├── breakpoint/ # 断点标记 │ │ ├── code_format/ # YAPF 与 PEP8 格式化 │ │ ├── code_process/ # 程序执行(ExecManager) +│ │ ├── folding/ # 代码折叠管理 +│ │ ├── git_diff/ # 行号区变更标记与行内 blame +│ │ ├── lint/ # 单个编辑器的 lint 诊断 +│ │ ├── lsp/ # 语言服务器客户端与共享连接 +│ │ ├── minimap/ # 缩略图组件 +│ │ ├── multi_cursor/ # 额外光标管理 +│ │ ├── snippets/ # 代码片段展开 │ │ ├── shell_process/ # Shell 执行(ShellManager) │ │ ├── syntax/ # 语法高亮引擎 │ │ ├── plaintext_code_edit/ # 纯文本编辑器组件 @@ -305,14 +411,20 @@ je_editor/ │ │ └── git_client/ # 分支与提交 UI │ └── main_ui/ # 主编辑器窗口 │ ├── ai_widget/ # AI 聊天面板 +│ ├── command_palette/ # 命令面板、快速打开、转到符号 │ ├── console_widget/ # 交互式控制台 │ ├── dock/ # 可停靠组件管理 │ ├── editor/ # 标签页式编辑器 │ ├── ipython_widget/ # Jupyter/IPython 控制台 │ ├── menu/ # 菜单栏系统 +│ ├── outline_panel/ # 文档大纲(符号树) │ ├── plugin_browser/ # 插件管理 UI -│ ├── save_settings/ # 设置持久化 +│ ├── problems_panel/ # lint 诊断面板 +│ ├── retranslate.py # 语言变更时重新标注整个界面 +│ ├── save_settings/ # 设置持久化、快捷键与配色 │ ├── system_tray/ # 系统托盘集成 +│ ├── test_panel/ # pytest 结果、traceback 与覆盖率 +│ ├── todo_panel/ # TODO/FIXME 任务面板 │ └── toolbar/ # 工具栏操作 ├── code_scan/ # 代码扫描 │ ├── ruff_thread.py # Ruff 静态分析(多线程) @@ -325,13 +437,46 @@ je_editor/ ├── plugins/ # 插件系统 │ └── plugin_loader.py # 动态插件加载 ├── utils/ # 工具程序 +│ ├── align/ # 按分隔符对齐行(不依赖 Qt) +│ ├── bookmark/ # 书签导航逻辑(不依赖 Qt) +│ ├── browser/ # 内嵌 Chromium 标志(不依赖 Qt) +│ ├── case_convert/ # 命名风格转换(不依赖 Qt) +│ ├── code_folding/ # 折叠区域:按缩进与按花括号(不依赖 Qt) +│ ├── command_palette/ # 模糊匹配与排序(不依赖 Qt) +│ ├── debugger/ # 组装 pdb 命令(不依赖 Qt) +│ ├── encode_decode/ # Base64/URL/HTML/JSON 转换(不依赖 Qt) │ ├── encodings/ # 编码检测 │ ├── exception/ # 自定义异常 │ ├── file/ # 文件 I/O(打开/保存) +│ ├── file_diff/ # 行状态、hunk 与 unified diff(不依赖 Qt) +│ ├── file_scan/ # 共享忽略规则、文件索引、TODO 扫描 +│ ├── format_code/ # yapf 格式化(不依赖 Qt) +│ ├── indentation/ # Tab/空格转换与缩进检测(不依赖 Qt) │ ├── json_format/ # JSON 格式化 +│ ├── line_ops/ # 行操作转换(不依赖 Qt) +│ ├── lint/ # Ruff 诊断解析(不依赖 Qt) │ ├── logging/ # 日志设置 -│ ├── multi_language/ # 国际化(英文、繁体中文) +│ ├── lsp/ # LSP 分包、协议与服务器注册表(不依赖 Qt) +│ ├── macro/ # 按键宏录制(不依赖 Qt) +│ ├── minimap/ # 缩略图几何与采样(不依赖 Qt) +│ ├── multi_cursor/ # 额外光标位置与编辑位移(不依赖 Qt) +│ ├── multi_language/ # 国际化:英文、繁体与简体中文、日文、 +│ │ # 区域匹配、实时重新标注 +│ ├── navigation/ # 光标跳转历史(不依赖 Qt) +│ ├── number_ops/ # 光标处数字加减(不依赖 Qt) +│ ├── occurrence/ # 词出现处查找与全词重命名(不依赖 Qt) │ ├── redirect_manager/ # 输出流重定向 +│ ├── selection/ # 智能选区与包围(不依赖 Qt) +│ ├── session/ # 多文件会话恢复(不依赖 Qt) +│ ├── shortcuts/ # 键盘快捷键表(不依赖 Qt) +│ ├── snippets/ # 片段展开与 tab stop(不依赖 Qt) +│ ├── status/ # 状态栏文本(不依赖 Qt) +│ ├── symbols/ # 符号提取:Python 用 ast,其余问服务器 +│ ├── syntax/ # 各语言的高亮规则(不依赖 Qt) +│ ├── test_runner/ # pytest 输出解析(不依赖 Qt) +│ ├── text_cleanup/ # 行尾空白/换行清理(不依赖 Qt) +│ ├── text_stats/ # 行/词/字符统计(不依赖 Qt) +│ ├── theme/ # 深色与浅色的编辑器配色(不依赖 Qt) │ └── venv_check/ # 虚拟环境检测 ├── __init__.py # 公共 API ├── __main__.py # CLI 入口点 @@ -395,8 +540,9 @@ JEDITOR 将用户设置存储在 `.jeditor/` 目录中: | 文件 | 内容 | |---|---| -| `user_setting.json` | 通用偏好设置(字体、主题、最近打开的文件) | -| `user_color_setting.json` | 语法高亮配色方案 | +| `user_setting.json` | 通用偏好设置(字体、主题、语言、最近打开的文件、打开的标签页、重新指定过的快捷键) | +| `user_color_setting.json` | 编辑器与输出的配色,含语法高亮 | +| `ai_config.json` | AI 助手设置——启动时读取、从不写入,需自行创建 | --- diff --git a/README/README_zh-TW.md b/README/README_zh-TW.md index 380fec18..87e0d052 100644 --- a/README/README_zh-TW.md +++ b/README/README_zh-TW.md @@ -43,6 +43,7 @@ - [快速開始](#快速開始) - [功能詳情](#功能詳情) - [程式碼編輯](#程式碼編輯) + - [導覽](#導覽) - [程式執行與除錯](#程式執行與除錯) - [程式碼品質與格式化](#程式碼品質與格式化) - [檔案操作](#檔案操作) @@ -75,17 +76,18 @@ JEDITOR 是原始 JEditor 專案的完全重寫版本,從零開始重新打造 | 類別 | 功能 | |---|---| -| **編輯器** | 多分頁編輯、語法高亮、自動補全(Jedi)、行號顯示、目前行高亮、搜尋與取代(支援正則表達式) | +| **編輯器** | 多分頁編輯、十二種語言的語法高亮、自動補全(Jedi 與語言伺服器)、可選取的多重游標、支援連動佔位符的程式碼片段、分割檢視、縮圖、程式碼折疊(縮排與大括號)、書籤、出現處高亮、行操作 | +| **導覽** | 指令面板、快速開啟(前往檔案)、前往符號、文件大綱、導覽歷史(往前/往後)、TODO/FIXME 任務面板 | | **執行** | 執行 Python 腳本(F5)、除錯模式(F9)、Shell 指令、虛擬環境偵測 | -| **程式碼品質** | YAPF 格式化、PEP8 檢查、Ruff 靜態分析、JSON 重新格式化 | -| **Git** | 分支管理、提交歷史、並排差異檢視器、暫存區操作、稽核日誌 | +| **程式碼品質** | YAPF 格式化、儲存時格式化、PEP8 檢查、Ruff 靜態分析與問題面板、語言伺服器診斷與快速修正、含 traceback 與覆蓋率的 pytest 面板、JSON 重新格式化 | +| **Git** | 分支管理、提交歷史、並排差異檢視器、行號區變更標記、逐個變更暫存與還原、行內 blame、擱置(stash)、衝突解決、稽核日誌 | | **AI** | 透過 LangChain 整合 OpenAI GPT、互動式聊天面板、可設定模型與提示詞 | | **主控台** | 互動式 Shell、Jupyter/IPython 主控台、指令歷史、多 Shell 支援 | | **瀏覽器** | 內嵌網頁瀏覽器、URL 導覽、頁面內搜尋 | | **外掛** | 自訂語法高亮、UI 翻譯、執行設定、自動探索 | -| **介面** | 深色/淺色主題(Qt Material)、字型自訂、可停靠面板、系統匣、工具列 | -| **國際化** | 英文、繁體中文,可透過外掛擴展 | -| **檔案** | 自動儲存、多編碼支援(UTF-8、GBK、Latin-1 等)、最近開啟的檔案 | +| **介面** | 深色/淺色主題(Qt Material)與配套的編輯器配色、可設定的鍵盤快捷鍵、字型自訂、可停靠面板、系統匣、工具列、狀態列 | +| **國際化** | 英文、繁體中文、简体中文、日本語;跟隨系統語言、不需重啟即可切換、可透過外掛擴展 | +| **檔案** | 自動儲存、多編碼支援(UTF-8、GBK、Latin-1 等)、最近開啟的檔案、多檔案工作階段還原 | --- @@ -173,12 +175,42 @@ start_editor() - **自動補全** -- 由 Jedi 驅動的上下文感知程式碼建議。 - **行號顯示** -- 編輯器旁顯示行號,並高亮目前行。 - **搜尋與取代** -- 支援在目前檔案、資料夾或整個專案中搜尋,提供正則表達式與區分大小寫選項。大型專案使用背景執行緒處理。 +- **程式碼折疊** -- 從行號區的折疊三角形或鍵盤展開與收合區塊。Python 等以縮排表達區塊的檔案依縮排折疊;C 家族語言(JavaScript、TypeScript、Rust、Go、C/C++、Java、JSON)則以大括號配對折疊,因此單獨一行的大括號一樣能開啟一個區塊。位於字串與註解中的大括號會被略過——字串裡的一個括號會讓後面每一組配對全部錯位。折疊只切換行的顯示與否,完全不修改文字,因此儲存時一定寫入完整檔案。折疊也能自我修復:標頭已不存在的折疊會直接展開,而不是藏錯行。 +- **書籤** -- 標記行並以鍵盤在書籤之間跳轉,也可點擊行號區切換。書籤錨定在文字上(透過 `QTextCursor`),因此在其上方插入或刪除行時會跟著程式碼移動,而不會飄掉。 +- **多重游標** -- `Ctrl+Shift+L` 在每個選取行的行尾放一個游標,`Ctrl+Alt+N` 在游標所在字詞的下一個出現處加一個,`Ctrl+Alt+Shift+Up` / `Down` 在上一行或下一行加一個,`Alt` + 點擊則可在任意位置新增或移除。所有游標會隨方向鍵、Home 與 End 一起移動,按住 `Shift` 搭配這些鍵則在每個游標各自擴大選取。輸入、Backspace 與 Delete 會在所有游標上生效並算作單一步復原,有選取範圍的位置則以輸入內容取代;`Ctrl+Shift+Esc` 或直接點擊即可回到單一游標。 +- **分割檢視**(`Ctrl+Alt+\`)-- 同一份檔案的第二個檢視,兩者共用同一份文件:任一側的編輯會立刻反映到另一側,而捲動位置與游標各自獨立。 +- **縮圖**(`Ctrl+Alt+M`)-- 以長條呈現每一行長度與縮排的整檔總覽,並用色帶標示目前螢幕上的範圍。兩側的標記顯示 lint 診斷、git 變更,以及您目前正在尋找的內容——搜尋框開啟時是搜尋命中處,否則是游標所在字詞的其他出現處。點擊或拖曳即可跳轉。大型檔案採取樣繪製,而非逐行繪製。 +- **程式碼片段** -- 輸入觸發字後按 Tab 展開,再以 Tab 在佔位符之間移動,每個預設值都會自動選取。重複出現的佔位符只需輸入一次,其餘位置會隨著輸入同步更新。採用常見的 `$1` / `${2:default}` / `$0` 記法,因此既有片段可直接放進 `snippets.json`,並支援各語言專屬的片段集。請從 Tab > 編輯程式碼片段 編輯,而不要手動改檔;檔案缺失或損壞時會退回內建的 Python 片段集。 +- **測試面板** -- 從停靠面板執行 pytest 並檢視結果,失敗的項目排在最前面,摘要作為狀態列。選取一筆失敗會在清單下方的窗格顯示其 traceback,覆蓋率方塊則在摘要旁顯示總覆蓋率(需要受測專案安裝 `pytest-cov`)。可執行全部、僅執行選取的項目,或只重跑上次失敗的項目;雙擊一列可在失敗的那一行開啟該測試。 +- **語言伺服器支援** -- 非 Python 的檔案可透過 stdio 從語言伺服器取得補全、hover、前往定義、重新命名、格式化、函式簽章提示、尋找參考處、快速修正與文件符號(TypeScript、Rust、Go、C/C++、Lua、JSON 等,可依副檔名設定),Python 則繼續使用 jedi。每個需要伺服器的分頁共用同一個伺服器實例,以「指令 + 專案根目錄」為鍵,而不是每開一個檔案就啟一個行程。診斷會與 ruff 的診斷顯示在同樣的底線與問題面板中。未安裝的伺服器只代表沒有補全,不會產生錯誤。 +- **編碼與換行字元** -- 檔案的編碼與換行字元會在開啟時偵測、儲存時原樣寫回,因此修改 CRLF 檔案的一行不會再重寫整份檔案。兩者都可從 File 選單變更;變更編碼會重新讀取未修改的檔案,讓亂碼可以就地修正,且永遠不會丟棄未儲存的內容。 +- **儲存時格式化** -- 可選擇在儲存檔案時執行 yapf,並讓游標停留在原本的行上。無法解析的程式碼會原樣保留,而不會阻擋儲存。 +- **縮排參考線與行尾空白** -- 每個縮排層級的垂直參考線,以及行尾多餘空白的標示,兩者都可從 UI 風格選單切換。 +- **Lint 診斷** -- `ruff` 的檢查結果會在編輯器中以底線標示,並列在問題(Problems)停靠面板中(規則、訊息、行號),雙擊即可跳轉。檢查的是 **緩衝區** 而非磁碟上的檔案,因此未儲存的編輯同樣會被檢查;檢查在停止輸入後於工作執行緒執行,被取代的過時結果會被丟棄。若未安裝 `ruff` 或執行失敗,編輯器只會不顯示診斷,而不會報錯。 +- **Git 變更標記** -- 行號區顯示檔案與最後一次提交的差異:綠色長條表示新增、橘色表示修改、細紅線表示該處有行被刪除。以 `F7` / `Shift+F7` 在變更之間跳轉,以 `Ctrl+Alt+Z` 將游標所在的變更還原成已提交的內容(單一步復原),也可從右鍵選單只暫存那一個變更。`Ctrl+Alt+B` 切換行內 blame,顯示最後更動每一行的提交、作者與摘要。Git 選單可開啟整份檔案與 `HEAD` 的並排差異,或與暫存區內容的差異——在逐個變更暫存之後,後者正好顯示哪些部分真的進了索引。右鍵選單同時提供取消整個檔案的暫存與提交已暫存的內容。已提交的版本在檔案開啟時於背景執行緒讀取,比對本身則是純記憶體內的 diff,只在停止輸入後重新計算,因此編輯永遠不必等待 git。不在儲存庫中或尚未提交的檔案就單純不顯示標記。 +- **出現處高亮** -- 將游標放在識別字上時,檔案中該識別字的其他完整字詞出現處都會被高亮。關鍵字與單一字元會被忽略,超大檔案則略過掃描,以維持游標移動的即時性。 +- **行操作** -- 刪除目前行或選取內容(`Ctrl+Shift+D`)、排序選取的行(`Ctrl+Alt+S`)、將選取的行合併成一行(`Ctrl+Shift+J`),以及(在 Text 選單中)自然排序、移除重複行、移除空白行、反轉行順序,或依分隔符(例如 `=`)對齊。每一項都算作單一步復原。 +- **複製行**(`Ctrl+D`)-- 有選取範圍時複製選取內容並選取新的副本,沒有時則複製整行。 +- **大小寫轉換**(Text 選單)-- 將選取內容轉為大寫或小寫,並保持選取狀態。 +- **智慧選取** -- 由字詞 → 行 → 外層縮排區塊 → 整份檔案逐步向外擴大選取(`Ctrl+Alt+Right`),並可逐步縮回(`Ctrl+Alt+Left`)。縮回只會回溯先前的擴大,手動改變選取則會重置歷史。 +- **數字加減** -- 將游標處的整數加一或減一(`Ctrl+Alt+Up` / `Ctrl+Alt+Down`),並正確處理負號與位數變化。 +- **檔案內重新命名**(`F2`)-- 將游標所在識別字在整份檔案中的每個完整字詞出現處一次改名,算作單一步復原。字詞邊界可保護部分符合的情況(改 `val` 絕不會動到 `value`)。 +- **導覽歷史** -- 像瀏覽器一樣在游標跳轉歷史中往前往後(`Alt+Left` / `Alt+Right`)。一次跳轉會同時記錄來源與目的地,因此「返回」會回到您原本所在的位置。 +- **文件大綱** -- 可停靠的樹狀面板,列出目前檔案的類別、方法、函式與模組層級變數。Python 以 `ast` 解析,不會執行任何程式碼;其他語言則向其語言伺服器詢問,因此 TypeScript 或 Rust 檔案同樣有大綱。雙擊即可跳到定義。 +- **鍵盤快捷鍵**(UI 風格 > 鍵盤快捷鍵)-- 所有指令的按鍵集中在一份可編輯的清單中。兩個指令不能共用同一組按鍵,因為發生這種情況時 Qt 兩個都不會執行;改動立即生效,而且只有與預設值不同的項目會被記錄。 - **變數檢查器** -- 在程式執行期間檢查與除錯變數。 +### 導覽 + +- **指令面板**(Ctrl+Shift+A)-- 以名稱或選單路徑模糊搜尋任何選單指令並直接執行,不必在選單中翻找。結果依照字詞邊界、連續字元與前綴排序,每一列也會顯示該指令自己的快捷鍵。 +- **快速開啟/前往檔案**(Ctrl+P)-- 以檔名 *或* 資料夾路徑模糊搜尋專案樹。索引在背景執行緒建立,並略過版本控制、快取、虛擬環境與建置目錄以及二進位檔案類型。開頭輸入 `>` 可將同一個選擇器切換成指令模式。 +- **前往符號**(Ctrl+Shift+O)-- 跳到目前 Python 檔案中的任何類別、函式、方法或模組層級變數。符號以標準函式庫的 `ast` 模組解析,因此絕不會執行使用者程式碼;無法解析的檔案在您輸入時只會沒有符號,而不會報錯。 +- **TODO 面板**(Tab > 工具,或作為停靠面板)-- 掃描專案中的 `TODO`、`FIXME`、`HACK`、`XXX`、`BUG`、`NOTE` 與 `OPTIMIZE` 註解,涵蓋 Python、C 系、HTML、SQL 等註解樣式。可依標籤篩選,雙擊一列即可在該行開啟檔案。標籤只有出現在註解符號之後才會被回報,因此一般字串不會被誤判。 + ### 程式執行與除錯 - **執行 Python 腳本**(F5)-- 執行目前檔案並即時串流輸出。 -- **除錯模式**(F9)-- 啟動 Python 除錯器進行逐步除錯。 +- **除錯模式**(F9)-- 啟動 Python 除錯器進行逐步除錯:`Ctrl+F9` 切換中斷點、`Ctrl+F5` 繼續執行、`F10` / `F11` / `Shift+F11` 分別為逐步跳過/進入/跳出。中斷點錨定在文字上,因此會跟著程式碼移動。 - **Shell 指令** -- 在編輯器內直接執行任意 Shell/終端機指令。 - **虛擬環境偵測** -- 自動偵測並啟用 Python 虛擬環境。 - **程序管理** -- 停止單一或所有執行中的程序。 @@ -190,12 +222,18 @@ start_editor() - **PEP8 檢查**(Ctrl+Alt+P)-- 驗證程式碼是否符合 PEP8 風格指南。 - **Ruff 靜態分析** -- 在背景執行緒中執行快速且全面的 Python 靜態分析。 - **JSON 重新格式化**(Ctrl+J)-- 美化列印並驗證 JSON 內容。 +- **移除行尾空白**(Text 選單)-- 去除每一行結尾的空白,算作單一步復原,並保留游標位置。 +- **轉換縮排**(Text 選單)-- 在 Tab 與空格之間轉換前導縮排(依您設定的縮排大小)。只處理前導空白,因此字串內的 Tab 與空格永遠不會被更動。 +- **可設定的縮排寬度** -- Tab 縮排、取消縮排與 Enter 自動縮排都依照設定的縮排大小(`Text > Indent Size`),而開啟檔案時也會從檔案本身的內容自動偵測縮排寬度。 +- **文字轉換**(Text 選單)-- 大小寫轉換(大寫/小寫/互換/標題式)、命名風格轉換(`snake_case` / `camelCase` / `PascalCase` / `kebab-case`)、進位制轉換(十六進位/十進位/二進位),以及編碼解碼工具(Base64、URL、HTML 實體、JSON 字串跳脫)。解碼失敗時原文保持不變。 +- **統計**(Text 選單)-- 整份文件或目前選取範圍的行數、字數與字元數。 ### 檔案操作 - **建立、開啟、儲存**檔案,使用標準快捷鍵(Ctrl+N、Ctrl+O、Ctrl+S)。 - **開啟資料夾**(Ctrl+K)-- 瀏覽專案目錄結構。 - **自動儲存** -- 自動定期儲存檔案,防止資料遺失。 +- **工作階段還原** -- 重新開啟上次關閉時所有開著的檔案,而不只是最後一個。不存在、重複與已開啟的檔案會被略過,清單有上限,損壞或手動改過的設定檔也絕不會擋住啟動。可在 `.jeditor/user_setting.json` 中將 `restore_session` 設為 `false` 停用。 - **多編碼支援** -- 無縫處理 UTF-8、GBK、Latin-1 及其他編碼,具備自動偵測功能。 - **最近開啟的檔案** -- 快速存取先前開啟的檔案。 @@ -207,7 +245,9 @@ JEDITOR 內建完整的 Git 用戶端: - **提交歷史** -- 以表格形式檢視提交的中繼資料(作者、日期、訊息)。 - **並排差異檢視器** -- 具有行號的彩色高亮程式碼比較。 - **多檔案差異** -- 比較多個檔案間的變更。 -- **暫存區操作** -- 暫存或取消暫存個別檔案的變更。 +- **暫存區操作** -- 暫存或取消暫存個別檔案的變更,也可從編輯器的行號區逐個變更暫存。 +- **擱置(Stash)** -- 把目前的變更先收起來、列出擱置的內容,並可取回其中一筆。 +- **衝突解決** -- 列出合併後仍處於衝突的檔案,並可選擇保留其中一方來解決。 - **稽核日誌** -- 記錄所有 Git 操作,方便追蹤與合規。 ### AI 助手 @@ -248,7 +288,7 @@ JEDITOR 支援模組化的外掛架構,提供四種外掛類型: ### 主題與自訂 -- **深色/淺色主題** -- Qt Material 主題,琥珀色配色方案。 +- **深色/淺色主題** -- Qt Material 主題,琥珀色配色方案。編輯器本身的顏色會跟隨視窗樣式,您自己挑過的顏色則不會被蓋掉。 - **字型自訂** -- 變更編輯器與 UI 的字型家族與大小。 - **可停靠面板** -- 透過停靠/取消停靠面板重新排列 UI 布局。 - **系統匣** -- 將編輯器最小化至系統匣。 @@ -256,9 +296,11 @@ JEDITOR 支援模組化的外掛架構,提供四種外掛類型: ### 多語言介面 -- **英文** -- 完整的英文介面(預設)。 -- **繁體中文** -- 完整的繁體中文翻譯。 -- **可擴展** -- 透過外掛系統新增更多語言。 +- **英文**、**繁體中文**、**简体中文** 與 **日本語** -- 四種都是完整的。简体中文以中國大陸的用詞直接撰寫,而非由繁體轉換——檔案/文件、資料夾/文件夹、程式/程序 這些詞在兩地並不相同。 +- **首次啟動跟隨系統** -- 語言取自系統的地區設定,而不是一律預設英文;中文依書寫系統判斷:`zh-Hant` 以及台灣、香港、澳門地區使用繁體,其餘使用簡體。偵測到的結果會被記錄下來,之後就單純是您所選的語言。 +- **不需重啟即可切換** -- 選擇語言後,選單、工具列、面板、分頁與狀態列會立刻換成新語言。分頁上的檔名與分支名稱保持不變。 +- **回退英文** -- 某個語言尚未翻譯的字串會顯示英文原文,而不是空白標籤,因此一種語言可以在尚未完成時就先加入。 +- **可擴展** -- 透過外掛系統新增更多語言。韓文、西班牙文、法文、德文、俄文與葡萄牙文的地區判斷規則都已就緒,各自只差一份字典。 --- @@ -270,15 +312,70 @@ JEDITOR 支援模組化的外掛架構,提供四種外掛類型: | `Ctrl+O` | 開啟檔案 | | `Ctrl+K` | 開啟資料夾 | | `Ctrl+S` | 儲存檔案 | +| `Ctrl+Shift+S` | 儲存所有已修改的分頁 | +| `Ctrl+Shift+A` | 指令面板 | +| `Ctrl+P` | 快速開啟(前往檔案) | +| `Ctrl+Shift+O` | 前往符號 | +| `Ctrl+Shift+[` | 切換游標所在的折疊 | +| `Ctrl+Alt+[` | 全部折疊 | +| `Ctrl+Alt+]` | 全部展開 | +| `Ctrl+Alt+K` | 切換書籤 | +| `Ctrl+Alt+L` | 下一個書籤 | +| `Ctrl+Alt+J` | 上一個書籤 | +| `Alt+Left` | 往前導覽 | +| `Alt+Right` | 往後導覽 | +| `Ctrl+Shift+D` | 刪除目前行/選取內容 | +| `Ctrl+Alt+S` | 排序選取的行 | +| `Ctrl+Shift+J` | 合併選取的行 | +| `Ctrl+Alt+Right` | 擴大選取範圍 | +| `Ctrl+Alt+Left` | 縮回選取範圍 | +| `Ctrl+Alt+Up` | 游標處的數字加一 | +| `Ctrl+Alt+Down` | 游標處的數字減一 | +| `F2` | 檔案內重新命名所有出現處 | +| `Ctrl+Shift+L` | 在每個選取行的行尾放一個游標 | +| `Ctrl+Alt+N` | 在下一個出現處加一個游標 | +| `Ctrl+Alt+Shift+Up` / `Ctrl+Alt+Shift+Down` | 在上一行/下一行加一個游標 | +| `Ctrl+Shift+Esc` | 回到單一游標 | +| `Ctrl+Shift+R` | 開始/結束錄製巨集 | +| `Ctrl+Shift+G` | 重播巨集 | +| `Ctrl+Alt+E` | 最近位置 | +| `Ctrl+Alt+\` | 切換分割檢視 | +| `Ctrl+Alt+M` | 切換縮圖 | +| `F7` / `Shift+F7` | 下一個/上一個變更 | +| `Ctrl+Alt+Z` | 還原游標所在的變更 | +| `Ctrl+Alt+B` | 切換行內 blame | | `Ctrl+J` | 重新格式化 JSON | | `Ctrl+Shift+Y` | YAPF Python 格式化 | | `Ctrl+Alt+P` | PEP8 格式檢查 | -| `Ctrl+F` | 搜尋文字(瀏覽器) | +| `Ctrl+F` | 搜尋文字(編輯器、瀏覽器) | +| `Ctrl+Shift+F` | 跨檔案搜尋 | +| `Alt+W` | 自動換行 | +| `Ctrl+Shift+P` | 以 pip 安裝套件 | +| `Ctrl+Shift+U` | 升級與安裝套件 | +| `Ctrl+Shift+V` | 切換 Python 直譯器 | +| `Ctrl+H` | 搜尋與取代 | +| `Ctrl+G` | 跳到指定行 | | `F5` | 執行程式 | | `F9` | 除錯 | | `Shift+F5` | 停止程式 | +| `Ctrl+F9` | 切換中斷點 | +| `Ctrl+F5` | 除錯器:繼續執行 | +| `F10` / `F11` / `Shift+F11` | 除錯器:逐步跳過/進入/跳出 | | `上/下方向鍵` | 指令歷史(主控台) | +上表所有快捷鍵都可從 **UI 風格 > 鍵盤快捷鍵** 重新指派。以下按鍵由編輯區本身處理, +因此是固定的: + +| 快捷鍵 | 動作 | +|---|---| +| `Ctrl+D` | 複製行/選取內容 | +| `Ctrl+/` | 切換註解 | +| `Alt+Up` / `Alt+Down` | 將該行上移/下移 | +| `Ctrl+B` | 跳到游標處符號的定義 | +| `Ctrl+Shift+\` | 跳到對應的括號 | +| `Ctrl++` / `Ctrl+-` | 放大/縮小編輯器字型 | +| `Tab` / `Shift+Tab` | 將該行或選取內容縮排/取消縮排 | + --- ## 專案架構 @@ -289,8 +386,17 @@ je_editor/ │ ├── browser/ # 內嵌網頁瀏覽器 │ ├── code/ # 核心程式碼編輯 │ │ ├── auto_save/ # 自動儲存 +│ │ ├── bookmark/ # 書籤管理(以 QTextCursor 錨定) +│ │ ├── breakpoint/ # 中斷點標記 │ │ ├── code_format/ # YAPF 與 PEP8 格式化 │ │ ├── code_process/ # 程式執行(ExecManager) +│ │ ├── folding/ # 程式碼折疊管理 +│ │ ├── git_diff/ # 行號區變更標記與行內 blame +│ │ ├── lint/ # 單一編輯器的 lint 診斷 +│ │ ├── lsp/ # 語言伺服器用戶端與共用連線 +│ │ ├── minimap/ # 縮圖元件 +│ │ ├── multi_cursor/ # 額外游標管理 +│ │ ├── snippets/ # 程式碼片段展開 │ │ ├── shell_process/ # Shell 執行(ShellManager) │ │ ├── syntax/ # 語法高亮引擎 │ │ ├── plaintext_code_edit/ # 純文字編輯器元件 @@ -305,14 +411,20 @@ je_editor/ │ │ └── git_client/ # 分支與提交 UI │ └── main_ui/ # 主編輯器視窗 │ ├── ai_widget/ # AI 聊天面板 +│ ├── command_palette/ # 指令面板、快速開啟、前往符號 │ ├── console_widget/ # 互動式主控台 │ ├── dock/ # 可停靠元件管理 │ ├── editor/ # 分頁式編輯器 │ ├── ipython_widget/ # Jupyter/IPython 主控台 │ ├── menu/ # 選單列系統 +│ ├── outline_panel/ # 文件大綱(符號樹) │ ├── plugin_browser/ # 外掛管理 UI -│ ├── save_settings/ # 設定持久化 +│ ├── problems_panel/ # lint 診斷面板 +│ ├── retranslate.py # 語言變更時重新標示整個介面 +│ ├── save_settings/ # 設定持久化、快捷鍵與配色 │ ├── system_tray/ # 系統匣整合 +│ ├── test_panel/ # pytest 結果、traceback 與覆蓋率 +│ ├── todo_panel/ # TODO/FIXME 任務面板 │ └── toolbar/ # 工具列操作 ├── code_scan/ # 程式碼掃描 │ ├── ruff_thread.py # Ruff 靜態分析(多執行緒) @@ -325,13 +437,46 @@ je_editor/ ├── plugins/ # 外掛系統 │ └── plugin_loader.py # 動態外掛載入 ├── utils/ # 工具程式 +│ ├── align/ # 依分隔符對齊行(不依賴 Qt) +│ ├── bookmark/ # 書籤導覽邏輯(不依賴 Qt) +│ ├── browser/ # 內嵌 Chromium 旗標(不依賴 Qt) +│ ├── case_convert/ # 命名風格轉換(不依賴 Qt) +│ ├── code_folding/ # 折疊區塊:依縮排與依大括號(不依賴 Qt) +│ ├── command_palette/ # 模糊比對與排序(不依賴 Qt) +│ ├── debugger/ # 組出 pdb 指令(不依賴 Qt) +│ ├── encode_decode/ # Base64/URL/HTML/JSON 轉換(不依賴 Qt) │ ├── encodings/ # 編碼偵測 │ ├── exception/ # 自訂例外 │ ├── file/ # 檔案 I/O(開啟/儲存) +│ ├── file_diff/ # 行狀態、hunk 與 unified diff(不依賴 Qt) +│ ├── file_scan/ # 共用忽略規則、檔案索引、TODO 掃描 +│ ├── format_code/ # yapf 格式化(不依賴 Qt) +│ ├── indentation/ # Tab/空格轉換與縮排偵測(不依賴 Qt) │ ├── json_format/ # JSON 格式化 +│ ├── line_ops/ # 行操作轉換(不依賴 Qt) +│ ├── lint/ # Ruff 診斷解析(不依賴 Qt) │ ├── logging/ # 日誌設定 -│ ├── multi_language/ # 國際化(英文、繁體中文) +│ ├── lsp/ # LSP 封包、協定與伺服器登錄(不依賴 Qt) +│ ├── macro/ # 按鍵巨集錄製(不依賴 Qt) +│ ├── minimap/ # 縮圖幾何與取樣(不依賴 Qt) +│ ├── multi_cursor/ # 額外游標位置與編輯位移(不依賴 Qt) +│ ├── multi_language/ # 國際化:英文、繁體與簡體中文、日文、 +│ │ # 地區判斷、即時重新標示 +│ ├── navigation/ # 游標跳轉歷史(不依賴 Qt) +│ ├── number_ops/ # 游標處數字加減(不依賴 Qt) +│ ├── occurrence/ # 字詞出現處搜尋與整字重新命名(不依賴 Qt) │ ├── redirect_manager/ # 輸出串流重導向 +│ ├── selection/ # 智慧選取範圍與包圍(不依賴 Qt) +│ ├── session/ # 多檔案工作階段還原(不依賴 Qt) +│ ├── shortcuts/ # 鍵盤快捷鍵表(不依賴 Qt) +│ ├── snippets/ # 片段展開與 tab stop(不依賴 Qt) +│ ├── status/ # 狀態列文字(不依賴 Qt) +│ ├── symbols/ # 符號擷取:Python 用 ast,其餘問伺服器 +│ ├── syntax/ # 各語言的高亮規則(不依賴 Qt) +│ ├── test_runner/ # pytest 輸出解析(不依賴 Qt) +│ ├── text_cleanup/ # 行尾空白/換行清理(不依賴 Qt) +│ ├── text_stats/ # 行/字/字元統計(不依賴 Qt) +│ ├── theme/ # 深色與淺色的編輯器配色(不依賴 Qt) │ └── venv_check/ # 虛擬環境偵測 ├── __init__.py # 公開 API ├── __main__.py # CLI 進入點 @@ -395,8 +540,9 @@ JEDITOR 將使用者設定儲存在 `.jeditor/` 目錄中: | 檔案 | 內容 | |---|---| -| `user_setting.json` | 一般偏好設定(字型、主題、最近開啟的檔案) | -| `user_color_setting.json` | 語法高亮配色方案 | +| `user_setting.json` | 一般偏好設定(字型、主題、語言、最近開啟的檔案、開啟中的分頁、重新指派過的快捷鍵) | +| `user_color_setting.json` | 編輯器與輸出的配色,含語法高亮 | +| `ai_config.json` | AI 助手設定——啟動時讀取、從不寫入,需自行建立 | --- diff --git a/docs/source/docs/Eng/ai_assistant.rst b/docs/source/docs/Eng/ai_assistant.rst index 4741fb4e..c3d484ea 100644 --- a/docs/source/docs/Eng/ai_assistant.rst +++ b/docs/source/docs/Eng/ai_assistant.rst @@ -28,9 +28,25 @@ Before using the AI assistant, you need to configure it: * - **System Prompt** - A template that sets the AI's behavior and context -Configuration is saved to ``.jeditor/ai_config.json`` and persists between sessions. - -You can also configure the API key via environment variables. +What you enter in the dialog applies to the current session. To have the settings loaded +on every launch, write them to ``.jeditor/ai_config.json`` yourself — the editor reads +that file at startup but never writes it, so your key is only ever stored where you put +it: + +.. code-block:: json + + { + "AI_model": { + "ai_base_url": "https://api.openai.com/v1", + "ai_api_key": "...", + "chat_model": "gpt-4", + "prompt_template": "" + } + } + +``.jeditor/`` is worth adding to ``.gitignore`` so the key is never committed. Once a +model is configured, the editor exports ``OPENAI_BASE_URL``, ``OPENAI_API_KEY`` and +``CHAT_MODEL`` into the environment for the LangChain packages to pick up. Chat Interface --------------- diff --git a/docs/source/docs/Eng/api_reference.rst b/docs/source/docs/Eng/api_reference.rst index 237457b4..832cdb25 100644 --- a/docs/source/docs/Eng/api_reference.rst +++ b/docs/source/docs/Eng/api_reference.rst @@ -140,22 +140,40 @@ Multi-Language language_wrapper ^^^^^^^^^^^^^^^^^ -A function that returns the translated string for a given key, based on the current language. +The single ``LanguageWrapper`` instance holding the current language and its dictionary. .. code-block:: python from je_editor import language_wrapper - label = language_wrapper("file_menu_label") # Returns "File" or translated equivalent + label = language_wrapper.language_word_dict.get("file_menu_label") # "File", or its translation + + language_wrapper.available_languages() # ['English', 'Traditional_Chinese', ...] + language_wrapper.display_name("Japanese") # '日本語' + language_wrapper.reset_language("Japanese") # swap the dictionary + +``reset_language`` only swaps the dictionary. The **Language** menu follows it with +``retranslate_ui(main_window, previous_words)``, which is what relabels the live +interface — no restart is needed. + +A key a language has not translated falls back to English rather than to a blank, so a +language can be registered before its dictionary is complete: + +.. code-block:: python + + language_wrapper.register_language("Korean", {"file_menu_label": "파일"}, display_name="한국어") english_word_dict / traditional_chinese_word_dict ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Built-in translation dictionaries. +Built-in translation dictionaries. Simplified Chinese and Japanese are available from +their own modules. .. code-block:: python from je_editor import english_word_dict, traditional_chinese_word_dict + from je_editor.utils.multi_language.simplified_chinese import simplified_chinese_word_dict + from je_editor.utils.multi_language.japanese import japanese_word_dict Plugin API ----------- diff --git a/docs/source/docs/Eng/code_execution.rst b/docs/source/docs/Eng/code_execution.rst index 694d15c7..9649be1c 100644 --- a/docs/source/docs/Eng/code_execution.rst +++ b/docs/source/docs/Eng/code_execution.rst @@ -24,11 +24,37 @@ You can also manually select a Python interpreter from the **Python Env** menu. Debugging ---------- -Press **F9** to launch the current Python file in debug mode: +Press **F9** to launch the current Python file in debug mode. The debugger is +``python -m pdb``, driven from the editor rather than from a separate terminal. -- Python debugger (pdb) integration -- Variable inspection during execution (see Variable Inspector below) -- Step-through debugging capabilities +**Breakpoints** + +``Ctrl+F9`` toggles a breakpoint on the current line, and a red dot appears in the +gutter. Breakpoints are anchored to the text, so they follow their code when lines are +inserted or removed above them. Every breakpoint in the file is sent to pdb when the +debug run starts, and toggling one during a run takes effect immediately. + +**Stepping** + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Shortcut + - Action + * - ``Ctrl+F5`` + - Continue to the next breakpoint + * - ``F10`` + - Step over the current line + * - ``F11`` + - Step into the call on the current line + * - ``Shift+F11`` + - Step out of the current function + +The same commands are on the **Run > Debug** menu, and anything pdb understands can be +typed directly into the debugger input. + +Variable inspection during execution is covered by the Variable Inspector below. Stop Execution ^^^^^^^^^^^^^^^ diff --git a/docs/source/docs/Eng/code_quality.rst b/docs/source/docs/Eng/code_quality.rst index 9840b3b0..242f1363 100644 --- a/docs/source/docs/Eng/code_quality.rst +++ b/docs/source/docs/Eng/code_quality.rst @@ -14,6 +14,11 @@ to conform to the Google style guide. - Applies consistent indentation, spacing, and line breaks - Available from the **Check Code Style** menu +**Format on Save:** + +YAPF can also run every time a file is saved, keeping the caret on its line. Source that +cannot be parsed is left alone rather than blocking the save. + PEP 8 Checking ---------------- @@ -36,6 +41,30 @@ in the background: - Comprehensive Python linting rules covering hundreds of checks - Results are reported without blocking your workflow +The **buffer** is checked, not the file on disk, so unsaved edits are covered, and a +stale result from a superseded run is discarded. If ``ruff`` is not installed, or a run +fails, the editor simply shows no diagnostics rather than reporting an error. + +Problems Panel +--------------- + +Every diagnostic — from ruff for Python, and from the language server for other +languages — is underlined in the editor and listed in the Problems dock panel with its +rule, message and line. Double-click a row to jump to it. + +Test Panel +----------- + +Run pytest from a dock panel and read the results, failures first, with the summary as +the status line: + +- Run everything, only the selection, or only what failed last time +- Selecting a failure shows its traceback in a pane below the list +- Double-click a row to open that test at the failing line +- A coverage box adds the total beside the summary, which needs ``pytest-cov`` installed + in the project being tested +- The run happens in a background process, so the editor stays usable + JSON Reformatting ------------------ @@ -45,3 +74,30 @@ JEditor can format and validate JSON files: - Pretty-prints JSON with proper indentation - Validates JSON syntax and reports errors - Available from the **Check Code Style** menu + +Text Transforms +---------------- + +The **Text** menu applies whole-document or selection-wide edits, each as a single undo +step: + +- **Trim Trailing Whitespace** — strip trailing whitespace from every line, preserving + the caret position +- **Convert Indentation** — convert leading indentation between tabs and spaces, using + the configured indent size. Only leading whitespace is touched, so tabs and spaces + inside strings are never altered +- **Case conversion** — upper, lower, swap or title case +- **Naming style** — ``snake_case`` / ``camelCase`` / ``PascalCase`` / ``kebab-case`` +- **Number base** — hex, decimal and binary +- **Encode / decode** — Base64, URL, HTML entities and JSON string escaping. A decoder + that fails leaves the text untouched +- **Line operations** — natural sort, remove duplicate lines, remove blank lines, reverse + line order, or align lines on a delimiter such as ``=`` +- **Statistics** — line, word and character counts for the document or the selection + +Indent Size +------------ + +Tab-indent, unindent and ``Enter`` auto-indent all honour the configured indent size +(**Text > Indent Size**), and the indent width is auto-detected from a file's own content +when it is opened. diff --git a/docs/source/docs/Eng/configuration.rst b/docs/source/docs/Eng/configuration.rst index 8f8c6598..4ca39992 100644 --- a/docs/source/docs/Eng/configuration.rst +++ b/docs/source/docs/Eng/configuration.rst @@ -18,30 +18,37 @@ The main settings file controls editor behavior and appearance: * - Setting - Description - * - ``ui_font_family`` + * - ``ui_font`` - Font family for the main UI (menus, panels, dialogs) * - ``ui_font_size`` - Font size for the main UI - * - ``editor_font_family`` + * - ``font`` - Font family for the code editor - * - ``editor_font_size`` + * - ``font_size`` - Font size for the code editor * - ``language`` - - UI language (``English``, ``Traditional Chinese``, or plugin-provided) - * - ``theme`` - - UI theme style (dark or light material themes) + - UI language (``English``, ``Traditional Chinese``, ``Simplified Chinese``, + ``Japanese``, or plugin-provided). Taken from the system locale on a first run. + * - ``ui_style`` + - UI theme style file, e.g. ``dark_amber.xml`` * - ``encoding`` - - Default file encoding (``UTF-8``, ``GBK``, ``Latin-1``) - * - ``last_open_file`` + - Default file encoding (``utf-8``, ``GBK``, ``latin-1``) + * - ``last_file`` - Path to the last opened file (restored on launch) * - ``python_compiler`` - Path to the Python interpreter for code execution - * - ``max_output_lines`` + * - ``max_line_of_output`` - Maximum lines in the output panel (default: 200,000) * - ``recent_files`` - List of recently opened files * - ``indent_size`` - Indentation size in spaces (default: 4) + * - ``open_files`` + - The tabs that were open at the last shutdown + * - ``restore_session`` + - Whether to reopen those tabs on launch (default: ``true``) + * - ``shortcuts`` + - Keys the user reassigned; only what differs from a default is stored user_color_setting.json ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -55,19 +62,38 @@ Controls the color scheme for the editor and output: * - Setting - Description * - ``line_number_color`` - - RGB color for line number text - * - ``line_number_bg_color`` - - RGB color for the line number gutter background + - Line number text + * - ``line_number_background_color`` + - Line number gutter background * - ``current_line_color`` - - RGB color for the current line highlight - * - ``normal_output_color`` - - RGB color for normal output text - * - ``error_output_color`` - - RGB color for error output text - * - ``warning_output_color`` - - RGB color for warning output text - -All colors are specified as RGB arrays, e.g., ``[255, 0, 0]`` for red. + - Current line highlight + * - ``normal_output_color`` / ``error_output_color`` / ``warning_output_color`` + - Output panel text + * - ``syntax_keyword_color`` / ``syntax_string_color`` / + ``syntax_comment_color`` / ``syntax_number_color`` + - Syntax highlighting + * - ``diff_added_marker_color`` / ``diff_modified_marker_color`` / + ``diff_removed_marker_color`` + - Git change markers in the gutter + * - ``blame_annotation_color`` + - Inline blame text + * - ``lint_underline_color`` + - Underline under a lint diagnostic + * - ``bookmark_marker_color`` / ``fold_marker_color`` / + ``breakpoint_marker_color`` + - Gutter markers + * - ``occurrence_highlight_color`` + - Other occurrences of the word under the caret + * - ``extra_cursor_color`` + - Additional carets + * - ``indent_guide_color`` / ``trailing_whitespace_color`` + - Indent guides and trailing whitespace shading + * - ``minimap_background_color`` / ``minimap_line_color`` / + ``minimap_viewport_color`` + - Minimap + +All colors are specified as RGB arrays, e.g., ``[255, 0, 0]`` for red. Any key left out +falls back to the current theme's value, so a partial file is fine. ai_config.json ^^^^^^^^^^^^^^^ @@ -79,6 +105,9 @@ AI assistant configuration (see :doc:`ai_assistant` for details): - Model name - System prompt template +Unlike the two files above, this one is read but never written — create it yourself if +you want the settings loaded on every launch. + Theming -------- @@ -86,7 +115,9 @@ JEditor supports dark and light themes via `qt-material `_ for intelligent Python - Runs in a background thread so the UI stays responsive - Configurable case-sensitivity and completion behavior +Language Server Support +------------------------ + +Files that are not Python are served by a language server over stdio, so the editor +offers the same assistance for them as jedi gives Python: + +- Completion, hover documentation and signature help while typing +- Go to definition, find references and rename across the project +- Whole-file formatting and quick fixes for reported problems +- Document symbols, which feed the outline panel + +One server is shared by every tab that needs it, keyed by its command and the project +root, rather than one process per open file. Servers are configured per file suffix — +TypeScript, Rust, Go, C/C++, Lua and JSON are set up out of the box. A server that is +not installed simply means no completions for that language; it is never an error. + +Diagnostics reported by the server appear in the same underlines and Problems panel as +ruff's. + Line Numbers ------------- @@ -111,8 +130,8 @@ When you open a folder (``Ctrl+K``), JEditor displays a file tree on the left si - Supports expanding and collapsing directories - Scrollable navigation for large projects -Encoding Support ------------------ +Encoding and Line Endings +-------------------------- JEditor supports multiple file encodings: @@ -123,6 +142,14 @@ JEditor supports multiple file encodings: - Per-file encoding selection from the **File > Encoding** menu - Encoding is preserved when saving files +Changing the encoding re-reads an unmodified file, so mojibake can be fixed in place. +Unsaved work is never discarded: if the tab has been edited, the file is not re-read. + +A file's line-ending style (LF, CRLF or CR) is detected when it opens and written back +unchanged when it saves, so editing one line of a CRLF file no longer rewrites every +line. Both the encoding and the line ending of the current tab are shown in the status +bar, and the line ending can be changed from **File > Line Ending**. + Search & Replace ----------------- @@ -145,3 +172,130 @@ JEditor provides powerful search and replace functionality: - Replace single occurrences or all matches at once - Supports the same options as search (case, regex) + +Navigation +----------- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Feature + - Description + * - **Command Palette** (``Ctrl+Shift+A``) + - Fuzzy-search every menu command by name or menu path and run it. Matches are + ranked by word boundaries, consecutive characters and prefixes, and each row + shows the command's own shortcut. + * - **Quick Open** (``Ctrl+P``) + - Fuzzy-search the project tree by file name or folder path. Indexing runs in a + background thread and skips VCS, cache, virtualenv and build directories. + Typing ``>`` first switches the same picker into command mode. + * - **Go to Symbol** (``Ctrl+Shift+O``) + - Jump to any class, function, method or module-level variable in the current + file. Python is parsed with the standard library ``ast`` module, so no code is + executed; a file that does not parse simply yields no symbols. + * - **Navigation History** (``Alt+Left`` / ``Alt+Right``) + - Move back and forward through cursor jumps like a browser. A jump records both + where you came from and where you went, so "back" returns to where you started. + * - **Recent Locations** (``Ctrl+Alt+E``) + - Pick from the places you have jumped to recently. + +Document Outline +----------------- + +A dockable tree of the current file's classes, methods, functions and module-level +variables. Python is parsed with ``ast``, so no code runs; other languages are asked of +their language server, so a TypeScript or Rust file gets an outline too. Double-click a +row to jump to the definition. + +Multiple Carets +---------------- + +Edit in several places at once: + +- ``Ctrl+Shift+L`` puts a caret at the end of every selected line +- ``Ctrl+Alt+N`` adds one at the next occurrence of the word under the caret +- ``Ctrl+Alt+Shift+Up`` / ``Ctrl+Alt+Shift+Down`` adds one on the line above or below +- ``Alt``-click adds or removes a caret anywhere +- ``Ctrl+Shift+Esc``, or a plain click, returns to a single caret + +Every caret moves together with the arrow keys, ``Home`` and ``End``, and ``Shift`` +with any of those extends a selection at each one. Typing, ``Backspace`` and ``Delete`` +apply at all of them as a single undo step, replacing each selection where there is one. + +Code Folding +------------- + +Collapse and expand blocks from the gutter fold triangles or the keyboard +(``Ctrl+Shift+[`` for the fold at the caret, ``Ctrl+Alt+[`` / ``Ctrl+Alt+]`` for all). + +- Python and other indented files fold on indentation +- The C-family languages (JavaScript, TypeScript, Rust, Go, C/C++, Java, JSON) fold on + brace pairs instead, so a brace on its own line still opens a region +- Braces inside strings and comments are skipped — one in a string would otherwise throw + every pair after it out of step +- Folding only toggles line visibility; it never modifies the text, so saving always + writes the complete file +- Folds self-heal after edits: a fold whose header no longer exists reopens rather than + hiding the wrong lines + +Bookmarks +---------- + +Mark lines with ``Ctrl+Alt+K`` (or click the gutter) and jump between them with +``Ctrl+Alt+L`` and ``Ctrl+Alt+J``. Bookmarks are anchored to the text, so they follow +their code when lines are inserted or removed above them instead of drifting. + +Snippets +--------- + +Type a trigger word and press ``Tab`` to expand it, then ``Tab`` through the +placeholders with each default value selected. A placeholder used more than once only +has to be typed once — the repeats follow as you type. + +Snippets use the usual ``$1`` / ``${2:default}`` / ``$0`` notation, so existing snippets +drop straight into ``snippets.json``, and there are per-language sets on top of the +shared ones. Edit them from **Tab > Edit Snippets** rather than by hand; a missing or +broken file falls back to the built-in Python set. + +Minimap +-------- + +``Ctrl+Alt+M`` toggles an overview of the whole file, drawn as bars following each +line's length and indentation, with a band marking what is on screen. Marks down the +sides show lint diagnostics, git changes, and whatever you are currently looking for — +the search box's hits while a search is open, and otherwise the other occurrences of the +word under the caret. Click or drag to jump. Large files are sampled rather than drawn +line by line. + +Split View +----------- + +``Ctrl+Alt+\`` opens a second view of the same file. Both views share one document, so +an edit in either side shows up in the other at once, while scrolling and the caret stay +independent. + +Lint Diagnostics +----------------- + +Findings from ``ruff`` are underlined in the editor and listed in a Problems dock panel +(rule, message, line); double-click a row to jump to it. The **buffer** is checked, not +the file on disk, so unsaved edits are covered. The run happens on a worker thread after +typing pauses, and a stale result from a superseded run is discarded. If ``ruff`` is not +installed, or a run fails, the editor simply shows no diagnostics rather than reporting +an error. + +Occurrence Highlighting +------------------------ + +Placing the caret on an identifier highlights every other whole-word occurrence of it in +the file. Keywords and single characters are ignored, and the scan is skipped on very +large files to keep caret movement instant. + +Customizing Shortcuts +---------------------- + +**Style > Keyboard Shortcuts** lists every command's keys in one editable table. Two +commands cannot be given the same keys — Qt runs neither of them when that happens — so +the dialog refuses to save a clash. A change takes effect immediately, and only what +differs from a default is stored. See :doc:`keyboard_shortcuts` for the full list. diff --git a/docs/source/docs/Eng/getting_started.rst b/docs/source/docs/Eng/getting_started.rst index 9cc95a23..7b26df65 100644 --- a/docs/source/docs/Eng/getting_started.rst +++ b/docs/source/docs/Eng/getting_started.rst @@ -97,8 +97,9 @@ Project Structure When JEditor starts, it creates a ``.jeditor/`` directory in the current working directory to store: -- ``user_setting.json`` — UI preferences, font, language, recent files +- ``user_setting.json`` — UI preferences, font, language, recent files, open tabs and any + reassigned shortcuts - ``user_color_setting.json`` — Color scheme for editor and output -- ``ai_config.json`` — AI assistant configuration (if enabled) -These files are created automatically on first launch. +Both are created automatically on first launch. A third file, ``ai_config.json``, is read +if you write it yourself; see :doc:`ai_assistant`. diff --git a/docs/source/docs/Eng/git_integration.rst b/docs/source/docs/Eng/git_integration.rst index 9173ebe0..76f96f87 100644 --- a/docs/source/docs/Eng/git_integration.rst +++ b/docs/source/docs/Eng/git_integration.rst @@ -59,16 +59,66 @@ JEditor provides a powerful side-by-side diff viewer: - **Multi-file diff** — View changes across multiple files in a single session - **Read-only display** — Diff view is read-only to prevent accidental edits +Change Markers in the Editor +---------------------------- + +The editor's gutter shows how the open file differs from its last commit: + +- A **green** bar for added lines +- An **orange** bar for modified lines +- A thin **red** line where lines were deleted + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Shortcut + - Action + * - ``F7`` / ``Shift+F7`` + - Jump to the next / previous change + * - ``Ctrl+Alt+Z`` + - Revert the change under the caret back to its committed form, as one undo step + * - ``Ctrl+Alt+B`` + - Toggle inline blame — the commit, author and summary that last touched each line + +The right-click menu stages just the change under the caret, unstages the whole file, or +commits what is currently staged. The Git menu opens a side-by-side diff of the file +against ``HEAD``, or against what is staged — after staging change by change, that second +one shows which parts actually went into the index. + +The committed version is read on a background thread when the file opens, and the +comparison itself is a pure in-memory diff recomputed only after typing pauses, so +editing never waits on Git. Files outside a repository, or not yet committed, simply show +no markers. + Staging & Committing --------------------- Perform full Git workflows within the editor: -1. **Stage changes** — Select individual files to stage +1. **Stage changes** — Select individual files to stage, or stage a single change from + the editor's gutter 2. **Unstage changes** — Remove files from the staging area 3. **Write commit message** — Enter a descriptive commit message 4. **Commit** — Create a new commit with the staged changes +Stash +------ + +Set the current changes aside without committing them: + +- **Stash** — Save the working tree's changes, optionally with a message +- **List** — See what is currently stashed +- **Pop** — Take a stash back and remove it from the list + +Conflict Resolution +-------------------- + +After a merge leaves files in conflict, JEditor lists them and settles one by keeping +either side — **ours** or **theirs**. The chosen content is written to the file and +staged, which clears the conflict. A file that is not actually in conflict is refused +rather than silently staged. + Remote Operations ------------------ diff --git a/docs/source/docs/Eng/keyboard_shortcuts.rst b/docs/source/docs/Eng/keyboard_shortcuts.rst index a3fe50e3..977cce56 100644 --- a/docs/source/docs/Eng/keyboard_shortcuts.rst +++ b/docs/source/docs/Eng/keyboard_shortcuts.rst @@ -4,6 +4,13 @@ Keyboard Shortcuts JEditor provides keyboard shortcuts for common operations, making your workflow faster and more efficient. +Most of the shortcuts on this page can be reassigned from **Style → Keyboard +Shortcuts**. Two commands cannot be given the same keys: Qt runs neither of them when +that happens, so the settings dialog refuses to save a clash. A change takes effect +immediately, and only what differs from a default is stored. The few keys handled +directly by the editing area — listed under `Fixed Keys`_ — are not in that list and +cannot be reassigned. + File Operations ---------------- @@ -21,9 +28,116 @@ File Operations - Open a folder (project) * - ``Ctrl+S`` - Save the current file + * - ``Ctrl+Shift+S`` + - Save every modified tab + +Search and Navigation +---------------------- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 -Code Execution ---------------- + * - Shortcut + - Action + * - ``Ctrl+F`` + - Find text in the file (also the browser's in-page search) + * - ``Ctrl+H`` + - Find and replace + * - ``Ctrl+Shift+F`` + - Search across files + * - ``Ctrl+G`` + - Go to line + * - ``Ctrl+P`` + - Quick open (go to file) + * - ``Ctrl+Shift+A`` + - Command palette + * - ``Ctrl+Shift+O`` + - Go to symbol + * - ``Alt+Left`` / ``Alt+Right`` + - Navigate back / forward through cursor jumps + * - ``Ctrl+Alt+E`` + - Recent locations + +Code Editing +------------- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Shortcut + - Action + * - ``Ctrl+Shift+D`` + - Delete the current line or selection + * - ``Ctrl+Shift+J`` + - Join the selected lines + * - ``Ctrl+Alt+S`` + - Sort the selected lines + * - ``Ctrl+Alt+Right`` / ``Ctrl+Alt+Left`` + - Expand / shrink the selection + * - ``Ctrl+Alt+Up`` / ``Ctrl+Alt+Down`` + - Increment / decrement the number under the caret + * - ``F2`` + - Rename every occurrence in the file + +Multiple Carets +---------------- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Shortcut + - Action + * - ``Ctrl+Shift+L`` + - Put a caret at the end of every selected line + * - ``Ctrl+Alt+N`` + - Add a caret at the next occurrence + * - ``Ctrl+Alt+Shift+Up`` / ``Ctrl+Alt+Shift+Down`` + - Add a caret above / below + * - ``Ctrl+Shift+Esc`` + - Back to a single caret + +Arrow keys, ``Home`` and ``End`` move every caret together, and ``Shift`` with any +of them extends a selection at each one. + +Folding and Bookmarks +---------------------- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Shortcut + - Action + * - ``Ctrl+Shift+[`` + - Toggle the fold at the caret + * - ``Ctrl+Alt+[`` / ``Ctrl+Alt+]`` + - Fold / unfold everything + * - ``Ctrl+Alt+K`` + - Toggle a bookmark + * - ``Ctrl+Alt+L`` / ``Ctrl+Alt+J`` + - Next / previous bookmark + +Git +---- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Shortcut + - Action + * - ``F7`` / ``Shift+F7`` + - Next / previous change + * - ``Ctrl+Alt+Z`` + - Revert the change under the caret + * - ``Ctrl+Alt+B`` + - Toggle inline blame + +Code Execution and Debugging +----------------------------- .. list-table:: :header-rows: 1 @@ -37,6 +151,12 @@ Code Execution - Debug the current Python file * - ``Shift+F5`` - Stop all running processes + * - ``Ctrl+F9`` + - Toggle a breakpoint + * - ``Ctrl+F5`` + - Continue + * - ``F10`` / ``F11`` / ``Shift+F11`` + - Step over / into / out Code Quality ------------- @@ -54,8 +174,8 @@ Code Quality * - ``Ctrl+J`` - Reformat / validate JSON -Browser --------- +Macros and View +---------------- .. list-table:: :header-rows: 1 @@ -63,8 +183,32 @@ Browser * - Shortcut - Action - * - ``Ctrl+F`` - - In-page text search (browser) + * - ``Ctrl+Shift+R`` + - Start / stop recording a macro + * - ``Ctrl+Shift+G`` + - Play the macro back + * - ``Ctrl+Alt+\`` + - Toggle the split view + * - ``Ctrl+Alt+M`` + - Toggle the minimap + * - ``Alt+W`` + - Toggle word wrap + +Python Environment +------------------- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Shortcut + - Action + * - ``Ctrl+Shift+P`` + - Install a package with pip + * - ``Ctrl+Shift+U`` + - Upgrade and install packages + * - ``Ctrl+Shift+V`` + - Change the Python interpreter Console -------- @@ -79,3 +223,33 @@ Console - Previous command in history * - ``Down`` - Next command in history + +Fixed Keys +----------- + +These are handled by the editing area itself rather than by a command, so they do not +appear in the shortcut settings and cannot be reassigned: + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - Shortcut + - Action + * - ``Ctrl+D`` + - Duplicate the line or selection + * - ``Ctrl+/`` + - Toggle comment + * - ``Alt+Up`` / ``Alt+Down`` + - Move the line up / down + * - ``Ctrl+B`` + - Jump to the definition under the caret + * - ``Ctrl+Shift+\`` + - Jump to the matching bracket + * - ``Ctrl++`` / ``Ctrl+-`` + - Zoom the editor font in / out + * - ``Tab`` / ``Shift+Tab`` + - Indent / unindent the line or selection + +Typing ``(``, ``[``, ``{``, ``"`` or ``'`` with text selected surrounds the selection +with that pair instead of replacing it. diff --git a/docs/source/docs/Zh/ai_assistant.rst b/docs/source/docs/Zh/ai_assistant.rst index 90ef8d0b..062c3e68 100644 --- a/docs/source/docs/Zh/ai_assistant.rst +++ b/docs/source/docs/Zh/ai_assistant.rst @@ -27,9 +27,24 @@ AI 聊天助手。AI 面板讓您可以直接在編輯器內與大型語言模 * - **System Prompt** - 設定 AI 行為與上下文的範本 -設定會儲存到 ``.jeditor/ai_config.json``,在不同工作階段之間持續保留。 - -您也可以透過環境變數設定 API 金鑰。 +在對話框中輸入的內容只套用於目前這次執行。若希望每次啟動都載入設定,請自行撰寫 +``.jeditor/ai_config.json``——編輯器只在啟動時讀取這個檔案,從不寫入它,因此您的金鑰 +只會存在您自己放的地方: + +.. code-block:: json + + { + "AI_model": { + "ai_base_url": "https://api.openai.com/v1", + "ai_api_key": "...", + "chat_model": "gpt-4", + "prompt_template": "" + } + } + +建議把 ``.jeditor/`` 加進 ``.gitignore``,金鑰才不會被提交。設定好模型之後,編輯器會把 +``OPENAI_BASE_URL``、``OPENAI_API_KEY`` 與 ``CHAT_MODEL`` 匯出到環境變數,供 LangChain +套件取用。 聊天介面 --------- diff --git a/docs/source/docs/Zh/api_reference.rst b/docs/source/docs/Zh/api_reference.rst index 58e8a969..bbf30da4 100644 --- a/docs/source/docs/Zh/api_reference.rst +++ b/docs/source/docs/Zh/api_reference.rst @@ -139,22 +139,38 @@ user_setting_color_dict language_wrapper ^^^^^^^^^^^^^^^^^ -根據目前語言返回指定鍵值的翻譯字串。 +唯一的 ``LanguageWrapper`` 實例,持有目前的語言與其字典。 .. code-block:: python from je_editor import language_wrapper - label = language_wrapper("file_menu_label") # 返回 "File" 或對應的翻譯 + label = language_wrapper.language_word_dict.get("file_menu_label") # "File" 或其翻譯 + + language_wrapper.available_languages() # ['English', 'Traditional_Chinese', ...] + language_wrapper.display_name("Japanese") # '日本語' + language_wrapper.reset_language("Japanese") # 換掉字典 + +``reset_language`` 只負責換字典。**Language** 選單在其後會呼叫 +``retranslate_ui(main_window, previous_words)``,那才是真正重新標示執行中介面的部分—— +因此不需要重新啟動。 + +某個語言尚未翻譯的鍵會退回英文而不是空白,因此可以先註冊語言、之後再補齊字典: + +.. code-block:: python + + language_wrapper.register_language("Korean", {"file_menu_label": "파일"}, display_name="한국어") english_word_dict / traditional_chinese_word_dict ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -內建的翻譯字典。 +內建的翻譯字典。簡體中文與日文可從各自的模組取得。 .. code-block:: python from je_editor import english_word_dict, traditional_chinese_word_dict + from je_editor.utils.multi_language.simplified_chinese import simplified_chinese_word_dict + from je_editor.utils.multi_language.japanese import japanese_word_dict 插件 API --------- diff --git a/docs/source/docs/Zh/code_execution.rst b/docs/source/docs/Zh/code_execution.rst index cf964fb6..b7477cf4 100644 --- a/docs/source/docs/Zh/code_execution.rst +++ b/docs/source/docs/Zh/code_execution.rst @@ -24,11 +24,35 @@ JEditor 會自動偵測專案根目錄中的 ``venv`` 資料夾,並使用虛 除錯模式 --------- -按下 **F9** 以除錯模式啟動目前的 Python 檔案: +按下 **F9** 以除錯模式啟動目前的 Python 檔案。除錯器就是 ``python -m pdb``,由編輯器 +驅動,不必另外開終端機。 -- 整合 Python 除錯器(pdb) -- 執行期間檢視變數(詳見下方「變數檢視器」) -- 支援逐步除錯 +**中斷點** + +``Ctrl+F9`` 可在目前行切換中斷點,行號區會出現一個紅點。中斷點錨定在文字上,因此在其 +上方插入或刪除行時會跟著程式碼移動。開始除錯時,檔案中的所有中斷點都會送給 pdb;除錯 +進行中切換中斷點也會立即生效。 + +**逐步執行** + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - 快捷鍵 + - 動作 + * - ``Ctrl+F5`` + - 繼續執行到下一個中斷點 + * - ``F10`` + - 逐步跳過目前這一行 + * - ``F11`` + - 逐步進入這一行的呼叫 + * - ``Shift+F11`` + - 跳出目前的函式 + +同樣的指令也在 **Run > Debug** 選單中,而 pdb 認得的任何指令都可以直接輸入除錯器輸入框。 + +執行期間的變數檢視請見下方的「變數檢視器」。 停止執行 ^^^^^^^^^ @@ -41,12 +65,12 @@ JEditor 會自動偵測專案根目錄中的 ``venv`` 資料夾,並使用虛 透過插件系統,JEditor 支援執行其他語言的檔案: -**直譯式語言**(直接執行): +**直譯式語言**\ (直接執行): - **Go** — ``go run file.go`` - **Java** — ``java file.java`` -**編譯式語言**(先編譯再執行): +**編譯式語言**\ (先編譯再執行): - **C** — ``gcc file.c -o file && ./file`` - **C++** — ``g++ file.cpp -o file && ./file`` diff --git a/docs/source/docs/Zh/code_quality.rst b/docs/source/docs/Zh/code_quality.rst index d292eb67..5cccfc3e 100644 --- a/docs/source/docs/Zh/code_quality.rst +++ b/docs/source/docs/Zh/code_quality.rst @@ -6,7 +6,7 @@ JEditor 整合了多種程式碼品質工具,幫助您撰寫乾淨、一致的 YAPF Python 格式化 -------------------- -`YAPF `_(Yet Another Python Formatter)將 Python 程式碼 +`YAPF `_\ (Yet Another Python Formatter)將 Python 程式碼 重新格式化為符合 Google 風格指南的格式。 - **快捷鍵:** ``Ctrl+Shift+Y`` @@ -14,6 +14,11 @@ YAPF Python 格式化 - 套用一致的縮排、間距和換行 - 可從 **Check Code Style** 選單使用 +**儲存時格式化:** + +YAPF 也可以在每次儲存檔案時執行,並讓游標停留在原本的行上。無法解析的程式碼會原樣保留, +而不會阻擋儲存。 + PEP 8 檢查 ------------ @@ -36,6 +41,26 @@ Ruff 靜態分析 - 涵蓋數百條 Python 檢查規則 - 結果回報不會阻塞您的工作流程 +檢查的是 **緩衝區** 而非磁碟上的檔案,因此未儲存的編輯同樣會被檢查;被更新結果取代的 +過時結果會被丟棄。若未安裝 ``ruff`` 或執行失敗,編輯器只會不顯示診斷,而不會報錯。 + +問題面板 +--------- + +所有診斷——Python 來自 ruff,其他語言來自語言伺服器——都會在編輯器中以底線標示,並列在 +問題(Problems)停靠面板中,包含規則、訊息與行號。雙擊該列即可跳轉。 + +測試面板 +--------- + +從停靠面板執行 pytest 並檢視結果,失敗的項目排在最前面,摘要則作為狀態列: + +- 可執行全部、僅執行選取的項目,或只重跑上次失敗的項目 +- 選取一筆失敗會在清單下方的窗格顯示其 traceback +- 雙擊一列可在失敗的那一行開啟該測試 +- 覆蓋率方塊會在摘要旁顯示總覆蓋率,這需要受測專案安裝 ``pytest-cov`` +- 測試在背景行程中執行,因此編輯器保持可用 + JSON 格式化 ------------- @@ -45,3 +70,25 @@ JEditor 可以格式化與驗證 JSON 檔案: - 以適當的縮排美化顯示 JSON - 驗證 JSON 語法並回報錯誤 - 可從 **Check Code Style** 選單使用 + +文字轉換 +--------- + +**Text** 選單提供針對整份文件或選取範圍的編輯,每一項都算作單一步復原: + +- **移除行尾空白** — 去除每一行結尾的空白,並保留游標位置 +- **轉換縮排** — 在 Tab 與空格之間轉換前導縮排,依照設定的縮排大小。只處理前導空白, + 因此字串內的 Tab 與空格永遠不會被更動 +- **大小寫轉換** — 全大寫、全小寫、大小寫互換或標題式 +- **命名風格轉換** — ``snake_case`` / ``camelCase`` / ``PascalCase`` / ``kebab-case`` +- **進位制轉換** — 十六進位、十進位與二進位 +- **編碼/解碼** — Base64、URL、HTML 實體與 JSON 字串跳脫。解碼失敗時原文保持不變 +- **行操作** — 自然排序、移除重複行、移除空白行、反轉行順序,或依分隔符(例如 ``=``) + 對齊 +- **統計** — 整份文件或選取範圍的行數、字數與字元數 + +縮排大小 +--------- + +Tab 縮排、取消縮排與 ``Enter`` 自動縮排都依照設定的縮排大小(**Text > Indent Size**), +而開啟檔案時也會從檔案本身的內容自動偵測縮排寬度。 diff --git a/docs/source/docs/Zh/configuration.rst b/docs/source/docs/Zh/configuration.rst index 8c5514c5..a300b7dd 100644 --- a/docs/source/docs/Zh/configuration.rst +++ b/docs/source/docs/Zh/configuration.rst @@ -18,30 +18,37 @@ user_setting.json * - 設定項目 - 說明 - * - ``ui_font_family`` + * - ``ui_font`` - 主 UI 的字型系列(選單、面板、對話框) * - ``ui_font_size`` - 主 UI 的字型大小 - * - ``editor_font_family`` + * - ``font`` - 程式碼編輯器的字型系列 - * - ``editor_font_size`` + * - ``font_size`` - 程式碼編輯器的字型大小 * - ``language`` - - UI 語言(``English``、``Traditional Chinese`` 或插件提供的語言) - * - ``theme`` - - UI 主題風格(深色或淺色 Material 主題) + - UI 語言(``English``、``Traditional Chinese``、``Simplified Chinese``、 + ``Japanese`` 或插件提供的語言)。首次啟動時取自系統地區設定。 + * - ``ui_style`` + - UI 主題樣式檔,例如 ``dark_amber.xml`` * - ``encoding`` - - 預設檔案編碼(``UTF-8``、``GBK``、``Latin-1``) - * - ``last_open_file`` + - 預設檔案編碼(``utf-8``、``GBK``、``latin-1``) + * - ``last_file`` - 上次開啟的檔案路徑(啟動時恢復) * - ``python_compiler`` - 用於程式碼執行的 Python 直譯器路徑 - * - ``max_output_lines`` + * - ``max_line_of_output`` - 輸出面板的最大行數(預設:200,000) * - ``recent_files`` - 最近開啟的檔案清單 * - ``indent_size`` - 縮排大小(空格數,預設:4) + * - ``open_files`` + - 上次關閉時開啟的分頁 + * - ``restore_session`` + - 啟動時是否重新開啟這些分頁(預設:``true``) + * - ``shortcuts`` + - 使用者改過的快捷鍵;只記錄與預設值不同的項目 user_color_setting.json ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -55,19 +62,38 @@ user_color_setting.json * - 設定項目 - 說明 * - ``line_number_color`` - - 行號文字的 RGB 顏色 - * - ``line_number_bg_color`` - - 行號區域背景的 RGB 顏色 + - 行號文字 + * - ``line_number_background_color`` + - 行號區域背景 * - ``current_line_color`` - - 目前行高亮的 RGB 顏色 - * - ``normal_output_color`` - - 正常輸出文字的 RGB 顏色 - * - ``error_output_color`` - - 錯誤輸出文字的 RGB 顏色 - * - ``warning_output_color`` - - 警告輸出文字的 RGB 顏色 - -所有顏色以 RGB 陣列指定,例如 ``[255, 0, 0]`` 代表紅色。 + - 目前行高亮 + * - ``normal_output_color`` / ``error_output_color`` / ``warning_output_color`` + - 輸出面板文字 + * - ``syntax_keyword_color`` / ``syntax_string_color`` / + ``syntax_comment_color`` / ``syntax_number_color`` + - 語法高亮 + * - ``diff_added_marker_color`` / ``diff_modified_marker_color`` / + ``diff_removed_marker_color`` + - 行號區的 Git 變更標記 + * - ``blame_annotation_color`` + - 行內 blame 文字 + * - ``lint_underline_color`` + - lint 診斷的底線 + * - ``bookmark_marker_color`` / ``fold_marker_color`` / + ``breakpoint_marker_color`` + - 行號區的各種標記 + * - ``occurrence_highlight_color`` + - 游標所在字詞的其他出現處 + * - ``extra_cursor_color`` + - 額外的游標 + * - ``indent_guide_color`` / ``trailing_whitespace_color`` + - 縮排參考線與行尾空白的標示 + * - ``minimap_background_color`` / ``minimap_line_color`` / + ``minimap_viewport_color`` + - 縮圖 + +所有顏色以 RGB 陣列指定,例如 ``[255, 0, 0]`` 代表紅色。未列出的項目會沿用目前主題的 +數值,因此只寫部分設定也沒問題。 ai_config.json ^^^^^^^^^^^^^^^ @@ -79,6 +105,9 @@ AI 助手設定(詳見 :doc:`ai_assistant`): - 模型名稱 - 系統提示詞範本 +與上面兩個檔案不同,這個檔案只會被讀取、不會被寫入——若希望每次啟動都載入設定,請自行 +建立它。 + 主題 ----- @@ -86,7 +115,8 @@ JEditor 透過 `qt-material `_ 支援 - **預設:** Dark Amber 主題 - 從 **UI Style** 選單切換主題 -- 主題變更可能需要重新啟動應用程式才能完全生效 +- 編輯器本身的顏色會跟隨視窗樣式:切換到淺色主題時,行號區、目前行與語法顏色也會換成 + 淺色的一組。您自己挑過的顏色不會被蓋掉——只有仍是預設值的項目會跟著主題走 字型自訂 --------- @@ -114,9 +144,13 @@ JEditor 的 UI 採用 Qt 的停靠元件系統,面板可重新排列: - **檔案樹** — 專案目錄瀏覽器 - **主控台** — Shell / IPython 主控台 - **AI 聊天** — AI 助手面板 -- **Git** — Git 客戶端面板 +- **Git** — Git 客戶端面板、分支樹與差異檢視器 - **瀏覽器** — 內建網頁瀏覽器 - **變數檢視器** — 執行期間的變數除錯 +- **問題** — lint 與語言伺服器的診斷 +- **大綱** — 目前檔案的類別、函式與變數 +- **測試** — pytest 的結果、失敗與覆蓋率 +- **TODO** — 掃描整個專案找到的 ``TODO`` / ``FIXME`` / ``HACK`` 註解 所有面板都可以: @@ -137,16 +171,33 @@ JEditor 支援系統匣整合: 多語言 UI ---------- -JEditor 支援多種 UI 語言: - **內建語言:** -- English(預設) +- English - 繁體中文 +- 简体中文 +- 日本語 -**透過插件新增語言:** +四種語言都是完整的。简体中文是以中國大陸的用詞直接撰寫,而非由繁體轉換——檔案/文件、 +資料夾/文件夹、程式/程序 這些詞在兩地並不相同。 + +**跟隨系統:** + +首次啟動時,語言取自系統的地區設定,而不是一律預設英文。中文依書寫系統判斷: +``zh-Hant`` 以及台灣、香港、澳門地區使用繁體,其餘使用簡體。偵測到的結果會寫入 +``user_setting.json``,之後就單純是您所選的語言。 -可透過插件系統新增額外語言(詳見 :doc:`plugins`)。 -語言變更在重新啟動應用程式後生效。 +**切換語言:** + +從 **Language** 選單選擇語言。不需要重新啟動——選單、工具列、面板、分頁與狀態列會立刻 +換成新語言。分頁上的檔名與分支名稱則保持不變。 + +**回退機制:** + +某個語言尚未翻譯的字串會顯示英文原文,而不是空白標籤,因此一種語言可以在尚未完成時就 +先加入。 + +**透過插件新增語言:** -從 **Language** 選單切換語言。 +可透過插件系統新增額外語言(詳見 :doc:`plugins`)。韓文、西班牙文、法文、德文、俄文與 +葡萄牙文的地區判斷規則都已就緒,各自只差一份字典。 diff --git a/docs/source/docs/Zh/editor.rst b/docs/source/docs/Zh/editor.rst index 16892203..0338c251 100644 --- a/docs/source/docs/Zh/editor.rst +++ b/docs/source/docs/Zh/editor.rst @@ -85,6 +85,23 @@ JEditor 整合了 `Jedi `_ 提供智慧型 Python - 在背景執行緒中運行,UI 始終保持回應 - 可設定大小寫敏感度與補全行為 +語言伺服器支援 +--------------- + +非 Python 的檔案會透過 stdio 交由語言伺服器服務,因此它們也能得到與 jedi 為 Python +提供的同等協助: + +- 輸入時的補全、hover 說明與函式簽章提示 +- 前往定義、尋找參考處,以及跨專案重新命名 +- 整份檔案格式化,以及針對回報問題的快速修正 +- 文件符號,用來填入大綱面板 + +每個需要伺服器的分頁共用同一個伺服器實例,以「指令 + 專案根目錄」為鍵,而不是每開一個 +檔案就啟一個行程。伺服器依副檔名設定,TypeScript、Rust、Go、C/C++、Lua 與 JSON 皆已 +預先配置。未安裝的伺服器只代表該語言沒有補全,不會產生錯誤。 + +伺服器回報的診斷會與 ruff 的診斷顯示在同樣的底線與問題面板中。 + 行號顯示 --------- @@ -110,18 +127,25 @@ JEditor 整合了 `Jedi `_ 提供智慧型 Python - 支援展開與收合目錄 - 大型專案可捲動瀏覽 -編碼支援 ---------- +編碼與換行字元 +--------------- JEditor 支援多種檔案編碼: -- **UTF-8**(預設) +- **UTF-8**\ (預設) - **GBK** - **Latin-1** - 開啟檔案時自動偵測編碼 - 可從 **File > Encoding** 選單為個別檔案選擇編碼 - 儲存時保留檔案原有編碼 +變更編碼時會重新讀取未修改的檔案,因此亂碼可以就地修正。已編輯但尚未儲存的分頁不會被 +重新讀取,所以不會遺失任何未儲存的內容。 + +檔案的換行字元(LF、CRLF 或 CR)會在開啟時偵測、儲存時原樣寫回,因此修改 CRLF 檔案的 +一行不會再重寫整份檔案。目前分頁的編碼與換行字元都顯示在狀態列上,換行字元可從 +**File > Line Ending** 變更。 + 搜尋與取代 ----------- @@ -144,3 +168,114 @@ JEditor 提供強大的搜尋與取代功能: - 取代單一匹配或一次取代全部 - 支援與搜尋相同的選項(大小寫、正規表達式) + +導覽 +----- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - 功能 + - 說明 + * - **指令面板**\ (``Ctrl+Shift+A``) + - 以名稱或選單路徑模糊搜尋任何選單指令並直接執行。結果依照字詞邊界、連續字元與 + 前綴排序,每一列也會顯示該指令自己的快捷鍵。 + * - **快速開啟**\ (``Ctrl+P``) + - 以檔名或資料夾路徑模糊搜尋專案樹。索引在背景執行緒建立,並略過版本控制、快取、 + 虛擬環境與建置目錄。開頭輸入 ``>`` 可將同一個選擇器切換成指令模式。 + * - **前往符號**\ (``Ctrl+Shift+O``) + - 跳到目前檔案中的任何類別、函式、方法或模組層級變數。Python 以標準函式庫的 + ``ast`` 解析,不會執行任何程式碼;無法解析的檔案只會沒有符號,不會報錯。 + * - **導覽歷史**\ (``Alt+Left`` / ``Alt+Right``) + - 像瀏覽器一樣在游標跳轉歷史中往前往後。一次跳轉會同時記錄來源與目的地,因此 + 「返回」會回到您原本所在的位置。 + * - **最近位置**\ (``Ctrl+Alt+E``) + - 從最近跳轉過的位置中挑選。 + +文件大綱 +--------- + +可停靠的樹狀面板,列出目前檔案的類別、方法、函式與模組層級變數。Python 以 ``ast`` +解析,不會執行程式碼;其他語言則向其語言伺服器詢問,因此 TypeScript 或 Rust 檔案同樣 +有大綱。雙擊即可跳到該定義。 + +多重游標 +--------- + +同時在多個位置編輯: + +- ``Ctrl+Shift+L`` 在每個選取行的行尾放一個游標 +- ``Ctrl+Alt+N`` 在游標所在字詞的下一個出現處加一個游標 +- ``Ctrl+Alt+Shift+Up`` / ``Ctrl+Alt+Shift+Down`` 在上一行或下一行加一個游標 +- ``Alt`` + 點擊可在任意位置新增或移除游標 +- ``Ctrl+Shift+Esc`` 或直接點擊即可回到單一游標 + +所有游標會隨方向鍵、``Home`` 與 ``End`` 一起移動,按住 ``Shift`` 搭配這些鍵則會在每個 +游標各自擴大選取範圍。輸入文字、``Backspace`` 與 ``Delete`` 會在所有游標上生效並算作 +單一步復原;有選取範圍的位置則以輸入內容取代該選取。 + +程式碼折疊 +----------- + +可從行號區的折疊三角形或鍵盤展開與收合區塊(``Ctrl+Shift+[`` 折疊游標所在區塊, +``Ctrl+Alt+[`` / ``Ctrl+Alt+]`` 全部折疊或展開)。 + +- Python 等以縮排表達區塊的檔案依縮排折疊 +- C 家族語言(JavaScript、TypeScript、Rust、Go、C/C++、Java、JSON)改以大括號配對 + 折疊,因此單獨一行的大括號一樣能開啟一個區塊 +- 位於字串與註解中的大括號會被略過——字串裡的一個括號會讓後面每一組配對全部錯位 +- 折疊只切換行的顯示與否,完全不修改文字,因此儲存時一定寫入完整檔案 +- 折疊具備自我修復能力:標頭已不存在的折疊會直接展開,而不是藏錯行 + +書籤 +----- + +以 ``Ctrl+Alt+K`` 標記行(也可點擊行號區切換),再以 ``Ctrl+Alt+L`` 與 ``Ctrl+Alt+J`` +在書籤之間跳轉。書籤錨定在文字上,因此在其上方插入或刪除行時會跟著程式碼移動,而不會 +飄掉。 + +程式碼片段 +----------- + +輸入觸發字後按 ``Tab`` 展開,接著以 ``Tab`` 在各個佔位符之間移動,每個預設值都會自動 +選取。重複出現的佔位符只需輸入一次,其餘位置會隨著輸入同步更新。 + +片段採用常見的 ``$1`` / ``${2:default}`` / ``$0`` 記法,因此既有片段可直接放進 +``snippets.json``;除了共用片段外也支援各語言專屬的片段集。請從 **Tab > 編輯程式碼片段** +編輯,而不要手動改檔;檔案缺失或損壞時會退回內建的 Python 片段集。 + +縮圖 +----- + +``Ctrl+Alt+M`` 切換整份檔案的縮圖總覽,以長條呈現每一行的長度與縮排,並用一個色帶標示 +目前螢幕上的範圍。兩側的標記顯示 lint 診斷、git 變更,以及您目前正在尋找的內容——搜尋框 +開啟時是搜尋命中處,否則是游標所在字詞的其他出現處。點擊或拖曳即可跳轉。大型檔案會採 +取樣繪製,而非逐行繪製。 + +分割檢視 +--------- + +``Ctrl+Alt+\`` 會開啟同一份檔案的第二個檢視。兩個檢視共用同一份文件,因此任一側的編輯 +會立刻反映到另一側,而捲動位置與游標各自獨立。 + +Lint 診斷 +---------- + +``ruff`` 的檢查結果會在編輯器中以底線標示,並列在問題(Problems)停靠面板中(規則、 +訊息、行號),雙擊即可跳轉。檢查的是 **緩衝區** 而非磁碟上的檔案,因此未儲存的編輯同樣 +會被檢查。檢查在停止輸入後於工作執行緒執行,被更新的結果取代的過時結果會被丟棄。若未 +安裝 ``ruff`` 或執行失敗,編輯器只會不顯示診斷,而不會報錯。 + +出現處高亮 +----------- + +將游標放在識別字上時,檔案中該識別字的其他完整字詞出現處都會被高亮。關鍵字與單一字元會 +被忽略,超大檔案則會略過掃描,以維持游標移動的即時性。 + +自訂快捷鍵 +----------- + +**UI 風格 → 鍵盤快捷鍵** 以一份可編輯的清單列出所有指令的按鍵。兩個指令不能共用同一組 +按鍵——發生這種情況時 Qt 兩個都不會執行——因此對話框會拒絕儲存衝突。改動立即生效,而且 +只有與預設值不同的項目會被記錄。完整清單請參閱 :doc:`keyboard_shortcuts`。 diff --git a/docs/source/docs/Zh/getting_started.rst b/docs/source/docs/Zh/getting_started.rst index 8d14adb5..f8ede8bb 100644 --- a/docs/source/docs/Zh/getting_started.rst +++ b/docs/source/docs/Zh/getting_started.rst @@ -96,8 +96,9 @@ JEditor 會自動安裝以下依賴套件: JEditor 啟動時會在目前工作目錄下建立 ``.jeditor/`` 資料夾,用於儲存: -- ``user_setting.json`` — UI 偏好設定、字型、語言、最近開啟的檔案 +- ``user_setting.json`` — UI 偏好設定、字型、語言、最近開啟的檔案、開啟中的分頁,以及 + 重新指派過的快捷鍵 - ``user_color_setting.json`` — 編輯器與輸出的色彩配置 -- ``ai_config.json`` — AI 助手設定(如有啟用) -這些檔案會在首次啟動時自動建立。 +這兩個檔案會在首次啟動時自動建立。第三個檔案 ``ai_config.json`` 需要您自行撰寫,編輯器 +只會讀取它;詳見 :doc:`ai_assistant`。 diff --git a/docs/source/docs/Zh/git_integration.rst b/docs/source/docs/Zh/git_integration.rst index 0e205afb..2fa8ce0a 100644 --- a/docs/source/docs/Zh/git_integration.rst +++ b/docs/source/docs/Zh/git_integration.rst @@ -59,16 +59,62 @@ JEditor 提供強大的並排差異檢視器: - **多檔案差異** — 在同一次檢視中查看多個檔案的變更 - **唯讀顯示** — 差異檢視為唯讀模式,防止意外修改 +編輯器中的變更標記 +------------------- + +編輯器的行號區會顯示開啟中的檔案與其最後一次提交的差異: + +- **綠色** 長條表示新增的行 +- **橘色** 長條表示修改的行 +- 細細的 **紅色** 線表示該處有行被刪除 + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - 快捷鍵 + - 動作 + * - ``F7`` / ``Shift+F7`` + - 跳到下一個/上一個變更 + * - ``Ctrl+Alt+Z`` + - 將游標所在的變更還原成已提交的內容,算作單一步復原 + * - ``Ctrl+Alt+B`` + - 切換行內 blame — 顯示最後更動每一行的提交、作者與摘要 + +右鍵選單可以只暫存游標所在的那一個變更、取消整個檔案的暫存,或提交目前已暫存的內容。 +Git 選單可開啟該檔案與 ``HEAD`` 的並排差異,或與暫存區內容的並排差異——在逐個變更暫存 +之後,後者正好顯示哪些部分真的進了索引。 + +已提交的版本會在檔案開啟時於背景執行緒讀取,而比對本身是純記憶體內的 diff,只在停止 +輸入後重新計算,因此編輯永遠不必等待 Git。不在儲存庫中或尚未提交的檔案就單純不顯示 +標記。 + 暫存與提交 ----------- 在編輯器內執行完整的 Git 工作流程: -1. **暫存變更** — 選擇個別檔案進行暫存 +1. **暫存變更** — 選擇個別檔案進行暫存,或從編輯器的行號區逐個變更暫存 2. **取消暫存** — 將檔案從暫存區移除 3. **撰寫提交訊息** — 輸入描述性的提交訊息 4. **提交** — 以暫存的變更建立新的提交 +擱置(Stash) +-------------- + +不必提交也能把目前的變更先收起來: + +- **擱置** — 儲存工作目錄的變更,可附上訊息 +- **列出** — 檢視目前擱置了哪些內容 +- **取回(Pop)** — 取回一筆擱置並將其從清單中移除 + +衝突解決 +--------- + +合併之後若有檔案處於衝突狀態,JEditor 會將它們列出,並可選擇保留其中一方—— +**ours** 或 **theirs**——來解決。選定的內容會寫入檔案並加入暫存區,衝突即告解除。 +若指定的檔案其實並未處於衝突狀態,操作會被拒絕,而不會被默默暫存。 + 遠端操作 --------- diff --git a/docs/source/docs/Zh/how_to_extend_using_pyside.rst b/docs/source/docs/Zh/how_to_extend_using_pyside.rst index a5034a2d..0297d4f3 100644 --- a/docs/source/docs/Zh/how_to_extend_using_pyside.rst +++ b/docs/source/docs/Zh/how_to_extend_using_pyside.rst @@ -58,7 +58,7 @@ JEditor 基於 PySide6(Qt for Python)打造,您可以透過自訂的 Qt 提示 ^^^^^ -- 您的元件類別必須繼承自 ``QWidget``(或其子類別) +- 您的元件類別必須繼承自 ``QWidget``\ (或其子類別) - 使用佈局(``QGridLayout``、``QVBoxLayout`` 等)實現響應式設計 - 您可以透過公開 API 存取 JEditor 的內部元件 - 可以多次呼叫 ``update()`` 或傳入包含多個項目的字典來註冊多個自訂分頁 diff --git a/docs/source/docs/Zh/keyboard_shortcuts.rst b/docs/source/docs/Zh/keyboard_shortcuts.rst index 6eb0805f..4dba185c 100644 --- a/docs/source/docs/Zh/keyboard_shortcuts.rst +++ b/docs/source/docs/Zh/keyboard_shortcuts.rst @@ -3,6 +3,11 @@ JEditor 提供常用操作的鍵盤快捷鍵,讓您的工作流程更快速、更有效率。 +本頁大部分的快捷鍵都可以在 **UI 風格 → 鍵盤快捷鍵** 中重新指派。兩個指令不能共用 +同一組按鍵:發生這種情況時 Qt 兩個都不會執行,因此設定對話框會拒絕儲存衝突的組合。 +改動立即生效,而且只有與預設值不同的項目會被記錄下來。少數由編輯區直接處理的按鍵 +(列在 `固定按鍵`_ 一節)不在該清單中,無法重新指派。 + 檔案操作 --------- @@ -20,10 +25,117 @@ JEditor 提供常用操作的鍵盤快捷鍵,讓您的工作流程更快速、 - 開啟資料夾(專案) * - ``Ctrl+S`` - 儲存目前檔案 + * - ``Ctrl+Shift+S`` + - 儲存所有已修改的分頁 + +搜尋與導覽 +----------- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 -程式碼執行 + * - 快捷鍵 + - 動作 + * - ``Ctrl+F`` + - 在檔案中搜尋文字(也是瀏覽器的頁內搜尋) + * - ``Ctrl+H`` + - 搜尋與取代 + * - ``Ctrl+Shift+F`` + - 跨檔案搜尋 + * - ``Ctrl+G`` + - 跳到指定行 + * - ``Ctrl+P`` + - 快速開啟(前往檔案) + * - ``Ctrl+Shift+A`` + - 指令面板 + * - ``Ctrl+Shift+O`` + - 前往符號 + * - ``Alt+Left`` / ``Alt+Right`` + - 在游標跳轉歷史中往前/往後 + * - ``Ctrl+Alt+E`` + - 最近位置 + +程式碼編輯 ----------- +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - 快捷鍵 + - 動作 + * - ``Ctrl+Shift+D`` + - 刪除目前行或選取內容 + * - ``Ctrl+Shift+J`` + - 合併選取的行 + * - ``Ctrl+Alt+S`` + - 排序選取的行 + * - ``Ctrl+Alt+Right`` / ``Ctrl+Alt+Left`` + - 擴大/縮回選取範圍 + * - ``Ctrl+Alt+Up`` / ``Ctrl+Alt+Down`` + - 游標處的數字加一/減一 + * - ``F2`` + - 重新命名檔案內所有出現處 + +多重游標 +--------- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - 快捷鍵 + - 動作 + * - ``Ctrl+Shift+L`` + - 在每個選取行的行尾放一個游標 + * - ``Ctrl+Alt+N`` + - 在下一個出現處加一個游標 + * - ``Ctrl+Alt+Shift+Up`` / ``Ctrl+Alt+Shift+Down`` + - 在上一行/下一行加一個游標 + * - ``Ctrl+Shift+Esc`` + - 回到單一游標 + +方向鍵、``Home`` 與 ``End`` 會讓所有游標一起移動;按住 ``Shift`` 再按這些鍵, +則會在每個游標各自擴大選取範圍。 + +折疊與書籤 +----------- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - 快捷鍵 + - 動作 + * - ``Ctrl+Shift+[`` + - 切換游標所在的折疊 + * - ``Ctrl+Alt+[`` / ``Ctrl+Alt+]`` + - 全部折疊/全部展開 + * - ``Ctrl+Alt+K`` + - 切換書籤 + * - ``Ctrl+Alt+L`` / ``Ctrl+Alt+J`` + - 下一個/上一個書籤 + +Git +---- + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - 快捷鍵 + - 動作 + * - ``F7`` / ``Shift+F7`` + - 下一個/上一個變更 + * - ``Ctrl+Alt+Z`` + - 還原游標所在的變更 + * - ``Ctrl+Alt+B`` + - 切換行內 blame + +程式碼執行與除錯 +----------------- + .. list-table:: :header-rows: 1 :widths: 30 70 @@ -33,9 +145,15 @@ JEditor 提供常用操作的鍵盤快捷鍵,讓您的工作流程更快速、 * - ``F5`` - 執行目前的 Python 檔案 * - ``F9`` - - 以除錯模式執行目前的 Python 檔案 + - 對目前的 Python 檔案執行除錯器 * - ``Shift+F5`` - - 停止所有正在執行的程序 + - 停止所有執行中的程式 + * - ``Ctrl+F9`` + - 切換中斷點 + * - ``Ctrl+F5`` + - 繼續執行 + * - ``F10`` / ``F11`` / ``Shift+F11`` + - 逐步跳過/逐步進入/跳出 程式碼品質 ----------- @@ -47,14 +165,14 @@ JEditor 提供常用操作的鍵盤快捷鍵,讓您的工作流程更快速、 * - 快捷鍵 - 動作 * - ``Ctrl+Shift+Y`` - - 使用 YAPF 格式化 Python 程式碼 + - 以 YAPF 格式化 Python 程式碼 * - ``Ctrl+Alt+P`` - - 檢查 PEP 8 合規性 + - 檢查 PEP 8 相容性 * - ``Ctrl+J`` - - 格式化 / 驗證 JSON + - 重新格式化/驗證 JSON -瀏覽器 -------- +巨集與檢視 +----------- .. list-table:: :header-rows: 1 @@ -62,8 +180,32 @@ JEditor 提供常用操作的鍵盤快捷鍵,讓您的工作流程更快速、 * - 快捷鍵 - 動作 - * - ``Ctrl+F`` - - 頁面內文字搜尋(瀏覽器) + * - ``Ctrl+Shift+R`` + - 開始/結束錄製巨集 + * - ``Ctrl+Shift+G`` + - 重播巨集 + * - ``Ctrl+Alt+\`` + - 切換分割檢視 + * - ``Ctrl+Alt+M`` + - 切換縮圖 + * - ``Alt+W`` + - 切換自動換行 + +Python 環境 +------------ + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - 快捷鍵 + - 動作 + * - ``Ctrl+Shift+P`` + - 以 pip 安裝套件 + * - ``Ctrl+Shift+U`` + - 升級與安裝套件 + * - ``Ctrl+Shift+V`` + - 切換 Python 直譯器 主控台 ------- @@ -74,7 +216,37 @@ JEditor 提供常用操作的鍵盤快捷鍵,讓您的工作流程更快速、 * - 快捷鍵 - 動作 - * - ``上`` - - 上一個歷史命令 - * - ``下`` - - 下一個歷史命令 + * - ``Up`` + - 歷史中的上一個指令 + * - ``Down`` + - 歷史中的下一個指令 + +固定按鍵 +--------- + +以下按鍵由編輯區本身處理,而不是透過指令,因此不會出現在快捷鍵設定中,也無法重新 +指派: + +.. list-table:: + :header-rows: 1 + :widths: 30 70 + + * - 快捷鍵 + - 動作 + * - ``Ctrl+D`` + - 複製目前行或選取內容 + * - ``Ctrl+/`` + - 切換註解 + * - ``Alt+Up`` / ``Alt+Down`` + - 將該行上移/下移 + * - ``Ctrl+B`` + - 跳到游標處符號的定義 + * - ``Ctrl+Shift+\`` + - 跳到對應的括號 + * - ``Ctrl++`` / ``Ctrl+-`` + - 放大/縮小編輯器字型 + * - ``Tab`` / ``Shift+Tab`` + - 將該行或選取內容縮排/取消縮排 + +在有選取內容時輸入 ``(``、``[``、``{``、``"`` 或 ``'``,會以該組符號包住選取內容, +而不是取代它。 diff --git a/docs/source/docs/Zh/plugins.rst b/docs/source/docs/Zh/plugins.rst index 78be670f..a1f3b214 100644 --- a/docs/source/docs/Zh/plugins.rst +++ b/docs/source/docs/Zh/plugins.rst @@ -233,7 +233,7 @@ JEditor 支援四種類型的插件: 定義如何執行特定類型的檔案。 -**直譯式語言**(直接執行): +**直譯式語言**\ (直接執行): .. code-block:: python @@ -245,7 +245,7 @@ JEditor 支援四種類型的插件: } # 執行:go run file.go -**編譯式語言**(先編譯再執行): +**編譯式語言**\ (先編譯再執行): .. code-block:: python