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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target/
/mutants.out*/
*.tmp-*
.fast-agent/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Mouse controls:
- Click a comment to edit it.
- Use the wheel to scroll the document or active editor.
- Saved ranges keep a green rail beside every source line they cover.
- Long source lines wrap to the available terminal width.

Keyboard controls:

Expand All @@ -81,7 +82,7 @@ Keyboard controls:
| `Esc` | Cancel selection or editing |
| `e` / `d` | Edit or delete a focused comment or one on the cursor line |
| `[` / `]` | Jump to the previous/next comment |
| `h` / `l` | Scroll long source lines horizontally |
| `Alt-Z` | Toggle source-line word wrapping (on by default) |
| `q` | Write output and quit |

Pass `--no-mouse` when terminal mouse capture is undesirable. Native terminal text
Expand Down
25 changes: 23 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ impl CommentEditor {
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WordWrap {
On,
Off,
}

#[derive(Debug)]
pub struct App {
pub source: SourceBuffer,
Expand All @@ -77,7 +83,7 @@ pub struct App {
pub editor: Option<CommentEditor>,
pub active_comment_id: Option<u64>,
pub scroll_row: usize,
pub horizontal_scroll: usize,
pub word_wrap: WordWrap,
pub should_quit: bool,
pub follow_cursor: bool,
pub mouse_drag_anchor: Option<usize>,
Expand All @@ -97,7 +103,7 @@ impl App {
editor: None,
active_comment_id: None,
scroll_row: 0,
horizontal_scroll: 0,
word_wrap: WordWrap::On,
should_quit: false,
follow_cursor: true,
mouse_drag_anchor: None,
Expand All @@ -107,6 +113,21 @@ impl App {
}
}

pub fn toggle_word_wrap(&mut self) {
self.word_wrap = match self.word_wrap {
WordWrap::On => WordWrap::Off,
WordWrap::Off => WordWrap::On,
};
self.follow_cursor = true;
self.status = Some(
match self.word_wrap {
WordWrap::On => "Word wrap on",
WordWrap::Off => "Word wrap off",
}
.into(),
);
}

pub fn move_cursor(&mut self, delta: isize) {
let maximum = self.source.line_count();
self.cursor_line = self
Expand Down
Loading