Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next previous buffer #54

Merged
merged 5 commits into from
Jan 2, 2025
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
33 changes: 33 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Configuration

The editor is configured using a toml file, by default searched for at `$XDG_CONFIG_HOME/pike/pike.toml`.
You can run pike with `-c/--config [path]` for a custom config path.

### Keymap

Located in the `keymaps` section. The keybinds follow VSCode notation, e.g. `ctrl+shift+p`, `ctrl+alt+del` and
are defined as key-value pairs. Example:

```toml
[keymaps]
"ctrl+s" = "open_file"
"ctrl+y" = "open_file"
```

The following actions are bindable:

| Action | Description | Default | Config definition |
|---------------------------|-------------------------------------------------------------------|--------------------------|----------------------------------|
| Open file | Opens a popup where a relative path should be inserted | ctrl+o | "open_file" |
| Open new buffer | Creates a new, empty buffer not bound to a file for editing | ctrl+n | "new_buffer" |
| Switch to next buffer | Moves focus to the next buffer in the list | ctrl+h | "next_buffer" |
| Switch to previous buffer | Moves focus to the previous buffer in the list | ctrl+l | "previous_buffer" |
| Search in current buffer | Searches for a specific term within the currently active buffer | ctrl+f | "search_in_current_buffer" |
| Replace in current buffer | Replaces text within the current buffer based on a search query | ctrl+j | "replace_in_current_buffer" |
| Save changes | Saves the current buffer to its associated file | ctrl+s | "save" |
| Undo last change | Reverts the most recent change in the current buffer | ctrl+z | "undo" |
| Redo last change | Reapplies the most recently undone change in the current buffer | ctrl+y | "redo" |
| Quit | Closes the application | ctrl+q | "quit" |

Keybindings which contain multiple modifiers are not yet supported and will be added
in the future (<https://docs.rs/crossterm/latest/crossterm/event/struct.KeyboardEnhancementFlags.html>).
30 changes: 12 additions & 18 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ impl Default for Config {
Operation::CreateNewBuffer,
),
(
KeyShortcut::new(KeyCode::Tab, KeyModifiers::CONTROL),
KeyShortcut::new(KeyCode::Char('h'), KeyModifiers::CONTROL),
Operation::SwitchToNextBuffer,
),
(
KeyShortcut::new(KeyCode::Tab, KeyModifiers::SHIFT | KeyModifiers::CONTROL),
KeyShortcut::new(KeyCode::Char('l'), KeyModifiers::CONTROL),
Operation::SwitchToPreviousBuffer,
),
(
Expand All @@ -142,18 +142,15 @@ impl Default for Config {
Operation::SearchInCurrentBuffer,
),
(
KeyShortcut::new(KeyCode::Char('h'), KeyModifiers::CONTROL),
KeyShortcut::new(KeyCode::Char('j'), KeyModifiers::CONTROL),
Operation::SearchAndReplaceInCurrentBuffer,
),
(
KeyShortcut::new(KeyCode::Char('z'), KeyModifiers::CONTROL),
Operation::Undo,
),
(
KeyShortcut::new(
KeyCode::Char('z'),
KeyModifiers::SHIFT | KeyModifiers::CONTROL,
),
KeyShortcut::new(KeyCode::Char('y'), KeyModifiers::CONTROL),
Operation::Redo,
),
(
Expand Down Expand Up @@ -208,16 +205,20 @@ mod config_test {
),
Operation::OpenFile,
),
(
KeyShortcut::new(KeyCode::Char('s'), KeyModifiers::CONTROL),
Operation::SaveBufferToFile,
),
(
KeyShortcut::new(KeyCode::Char('n'), KeyModifiers::CONTROL),
Operation::CreateNewBuffer,
),
(
KeyShortcut::new(KeyCode::Tab, KeyModifiers::CONTROL),
KeyShortcut::new(KeyCode::Char('h'), KeyModifiers::CONTROL),
Operation::SwitchToNextBuffer,
),
(
KeyShortcut::new(KeyCode::Tab, KeyModifiers::SHIFT | KeyModifiers::CONTROL),
KeyShortcut::new(KeyCode::Char('l'), KeyModifiers::CONTROL),
Operation::SwitchToPreviousBuffer,
),
(
Expand All @@ -229,22 +230,15 @@ mod config_test {
Operation::SearchInCurrentBuffer,
),
(
KeyShortcut::new(KeyCode::Char('h'), KeyModifiers::CONTROL),
KeyShortcut::new(KeyCode::Char('j'), KeyModifiers::CONTROL),
Operation::SearchAndReplaceInCurrentBuffer,
),
(
KeyShortcut::new(KeyCode::Char('s'), KeyModifiers::CONTROL),
Operation::SaveBufferToFile,
),
(
KeyShortcut::new(KeyCode::Char('z'), KeyModifiers::CONTROL),
Operation::Undo,
),
(
KeyShortcut::new(
KeyCode::Char('z'),
KeyModifiers::SHIFT | KeyModifiers::CONTROL,
),
KeyShortcut::new(KeyCode::Char('y'), KeyModifiers::CONTROL),
Operation::Redo,
),
(
Expand Down
8 changes: 4 additions & 4 deletions src/pike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ impl Pike {
}

/// Switch to the previous buffer
fn previous_buffer(&mut self) {
todo!()
pub fn previous_buffer(&mut self) {
self.workspace.previous_buffer();
}

/// Switch to the next buffer
fn next_buffer(&mut self) {
todo!()
pub fn next_buffer(&mut self) {
self.workspace.next_buffer();
}

/// Search for a query in the current buffer and return
Expand Down
Loading