Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ To open an existing file in the editor buffer, pass its relative or absolute pat
```shell
$ cargo run -- README.md
```
Directories and multiple arguments are rejected.
A folder opens as a project, as `Ctrl + C` `Ctrl + P` `A` does:
```shell
$ cargo run -- src
```
Multiple arguments are rejected.

### Packaging
#### Debian
Expand Down
6 changes: 5 additions & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ $ cargo run
```bash
$ cargo run -- README.md
```
同时传入多个文件、传入目录会被`ptre`拒绝
传入目录时会将其作为项目打开,效果与 `Ctrl + C` `Ctrl + P` `A` 相同:
```bash
$ cargo run -- src
```
同时传入多个路径会被`ptre`拒绝

### 打包
#### Debian
Expand Down
32 changes: 31 additions & 1 deletion doc/shortcuts/shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
## Terminal

* `Ctrl + C` `T` `T`: open or hide the terminal. Hiding it keeps the shell running.
* `Ctrl + X` `O`: switch focus between the editor and the visible terminal.
* `Ctrl + X` `O`: switch focus between the visible panes: the file tree, the editor and the terminal.
* `Ctrl + C` `T` `C`: run Clang-tidy.
* `Alt + V` / `Ctrl + V`: scroll terminal history up / down one page.
`Shift + PageUp` / `Shift + PageDown` also work. Up to 1000 history rows are kept.
Expand All @@ -30,3 +30,33 @@ The terminal opens below the editor when the workspace has at least 28 rows;
otherwise it opens on the right. It starts in the current file's directory,
or the editor's working directory for an unnamed file. After the shell exits,
hide and reopen the terminal to start a new session.

## File tree

* `Ctrl + C` `C` `T`: show or hide the file tree on the left, like Emacs Treemacs.
It is also in the WINDOW menu. Showing the tree gives it focus.
* `Ctrl + C` `Ctrl + P` `A`: open a project. Type a folder path and press `Enter`.
* `N` / `P`: next / previous row. `Down` / `Up` and `Ctrl + N` / `Ctrl + P` also work.
* `Tab`: open or close the selected folder.
* `Enter`: open the selected file in a new tab (or go to its tab when it is open already),
or open or close the selected folder.
* `U`: go to the parent folder.
* `G`: read the folders again.
* `Q`: hide the tree.

The tree starts at the project of the current file: the nearest folder above it that holds
`.git`, `Cargo.toml`, `CMakeLists.txt`, `compile_commands.json` or `compile_flags.txt`
(otherwise the file's own folder). For an unnamed file, it starts at the editor's working directory.
It opens the folders above the current file and selects it. The `.git` folder is not shown.
When the tree is shown again, it keeps its folder (such as an opened project) while the
current file is inside it.

## Tabs

* `Ctrl + X` `Right` / `Ctrl + X` `Left`: go to the next / previous tab. At the last tab, the next one is the first.
* `Ctrl + X` `K`: close the tab. If it has unsaved changes, a dialog asks first:
`Y` / `Enter` closes it without saving, `N` / `Esc` keeps it open.

The tab row is the first line of the editor. The active tab is highlighted, and `●` marks a tab
with unsaved changes. A file from the file tree opens in a new tab after the active one; an empty
unnamed tab is reused for it. Closing the last tab leaves an empty unnamed tab.
31 changes: 30 additions & 1 deletion doc/shortcuts/shortcuts.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
## 终端

* `Ctrl + C` `T` `T`:打开或隐藏终端。隐藏后 Shell 继续运行。
* `Ctrl + X` `O`:在编辑器和已显示的终端之间切换焦点。
* `Ctrl + X` `O`:在已显示的面板之间切换焦点:文件树、编辑器和终端。
* `Ctrl + C` `T` `C`:运行 Clang-tidy。
* `Alt + V` / `Ctrl + V`:向上 / 向下翻阅终端历史输出。
也支持 `Shift + PageUp` / `Shift + PageDown`,最多保留 1000 行历史。
Expand All @@ -28,3 +28,32 @@
工作区高度不少于 28 行时,终端显示在编辑器下方;否则显示在右侧。
Shell 在当前文件的目录启动;未命名文件则使用编辑器的工作目录。
Shell 退出后,隐藏并重新打开终端即可启动新会话。

## 文件树

* `Ctrl + C` `C` `T`:在左侧显示或隐藏文件树,类似 Emacs 的 Treemacs。
也可以从 WINDOW 菜单打开。显示文件树时焦点会移到文件树上。
* `Ctrl + C` `Ctrl + P` `A`:打开项目。输入目录路径后按 `Enter`。
* `N` / `P`:下一行 / 上一行。也支持 `Down` / `Up` 和 `Ctrl + N` / `Ctrl + P`。
* `Tab`:展开或折叠选中的目录。
* `Enter`:在新标签页中打开选中的文件(已打开的文件会切换到它的标签页),
或展开 / 折叠选中的目录。
* `U`:跳到上级目录。
* `G`:重新读取目录。
* `Q`:隐藏文件树。

文件树从当前文件所在的项目开始:即向上找到的第一个含有 `.git`、`Cargo.toml`、`CMakeLists.txt`、
`compile_commands.json` 或 `compile_flags.txt` 的目录(找不到时使用文件所在的目录)。
未命名文件则从编辑器的工作目录开始。
打开时会展开当前文件上层的目录并选中它。`.git` 目录不会显示。
再次显示文件树时,只要当前文件仍在原来的目录(例如打开的项目)中,就会继续显示该目录。

## 标签页

* `Ctrl + X` `Right` / `Ctrl + X` `Left`:切换到下一个 / 上一个标签页。在最后一个标签页时,下一个是第一个。
* `Ctrl + X` `K`:关闭标签页。有未保存的修改时会先弹出对话框询问:
`Y` / `Enter` 不保存直接关闭,`N` / `Esc` 保留标签页。

标签栏是编辑器的第一行。当前标签页会高亮显示,`●` 表示该标签页有未保存的修改。
从文件树打开的文件会在当前标签页之后新开一个标签页;如果当前是空的未命名标签页,则直接用它打开。
关闭最后一个标签页后,会留下一个空的未命名标签页。
Loading
Loading