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: 2 additions & 0 deletions crates/pullpen-ui/src/app/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub enum Cmd {
Title,
New,
Messages,
Mouse,
Clear,
Quit,
QuitAll,
Expand Down Expand Up @@ -57,6 +58,7 @@ pub const COMMANDS: &[CmdInfo] = &[
c("diff", Cmd::Diff, "open the diff"),
c("merge", Cmd::Merge, "merge now"),
c("messages", Cmd::Messages, "recent results and errors"),
c("mouse", Cmd::Mouse, "turn the mouse off, or back on"),
c("open", Cmd::Open, "open in the browser"),
c("q", Cmd::Quit, "back, or quit from the list"),
c("qa", Cmd::QuitAll, "quit from anywhere"),
Expand Down
6 changes: 6 additions & 0 deletions crates/pullpen-ui/src/app/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,12 @@ impl App {
self.input = Input::Messages;
vec![]
}
Cmd::Mouse => {
self.ui.mouse = !self.ui.mouse;
let now = if self.ui.mouse { "on" } else { "off: the terminal selects text again" };
self.say(markup(&format!("{{d|mouse {now}}}")), Mode::Normal);
vec![]
}
Cmd::Clear if self.view_is(self.active, pullpen_core::View::Merged) => self.clear_landed(),
Cmd::Clear => {
self.refused(":clear drops finished rows in Merged");
Expand Down
10 changes: 10 additions & 0 deletions crates/pullpen-ui/src/app/input/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,3 +603,13 @@ fn a_refused_new_pr_names_the_repo_not_a_number() {
}
assert!(said(&a).contains(":new acme/api: No commits between main and feat/retry"), "{}", said(&a));
}

#[test]
fn mouse_turns_the_mouse_off_and_the_next_one_turns_it_back_on() {
let mut a = app();
assert!(a.ui.mouse, "on unless asked");
command(&mut a, "mouse");
assert_eq!((a.ui.mouse, said(&a).as_str()), (false, "mouse off: the terminal selects text again"));
command(&mut a, "mouse");
assert_eq!((a.ui.mouse, said(&a).as_str()), (true, "mouse on"));
}
4 changes: 4 additions & 0 deletions crates/pullpen-ui/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ pub struct UiConfig {
pub delete_branch: bool,
/// How often a watched pipeline is asked for while it runs.
pub watch: std::time::Duration,
/// Whether the terminal is asked to report the mouse. While it is, the
/// terminal's own text selection needs Shift held.
pub mouse: bool,
}

impl Default for UiConfig {
Expand All @@ -118,6 +121,7 @@ impl Default for UiConfig {
default_method: DefaultMethod::Repo,
delete_branch: true,
watch: pipeline::WATCH,
mouse: true,
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions crates/pullpen/src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const HISTORY_MAX: usize = 500;

struct Term {
kitty: bool,
/// Whether mouse reporting is on, to follow `:mouse`.
mouse: bool,
/// The window title last sent, so it is sent again only when it changes.
title: String,
}
Expand All @@ -54,14 +56,14 @@ impl Term {
// escape sequence for every move of the pointer.
let hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
Term { kitty, title: String::new() }.modes_off();
Term { kitty, mouse: true, title: String::new() }.modes_off();
hook(info);
}));
// Save the window title on the terminal's own stack (XTWINOPS 22),
// so leaving can put back whatever the shell had; a terminal without
// the stack ignores it, and the shell's next prompt retitles anyway.
execute!(stdout(), Print("\x1b[22;0t"), SetTitle("pullpen"))?;
Ok((terminal, Term { kitty, title: "pullpen".into() }))
Ok((terminal, Term { kitty, mouse: true, title: "pullpen".into() }))
}

/// Best effort: the terminal may already be gone, and an error here
Expand Down Expand Up @@ -138,6 +140,10 @@ fn event_loop(terminal: &mut DefaultTerminal, term: &mut Term, l: &mut Loop) ->
execute!(stdout(), SetTitle(&title))?;
term.title = title;
}
if l.app.ui.mouse != term.mouse {
term.mouse = l.app.ui.mouse;
if term.mouse { execute!(stdout(), EnableMouseCapture)? } else { execute!(stdout(), DisableMouseCapture)? }
}
draw(terminal, l.app)?;
let mut effects = Vec::new();
if event::poll(TICK)? {
Expand Down
1 change: 1 addition & 0 deletions wiki/Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ names; `↑` `↓` walk history, filtered by what you have typed.
| `:refresh [all]` | fetch this section, or all |
| `:section <name>` | switch section |
| `:messages` | the last 200 results and errors |
| `:mouse` | turn the mouse off, and again to turn it back on, until you quit |
| `:clear` | in the Merged section, drop every finished row that is not failing |
| `:dismiss [#n]` | in Deploys, resolve a failing branch by hand |
| `:watch [#n]` | the PR's pipeline and its jobs' logs, live |
Expand Down
5 changes: 5 additions & 0 deletions wiki/Keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ Optional: everything below is also a key. Each line is a test in

A confirm prompt, the command line, a filter and `?` take keys only
(`a_click_at_a_confirm_prompt_changes_nothing`).

While pullpen has the mouse, most terminals select text only with `Shift`
held. `:mouse` hands the mouse back to the terminal, and again takes it
(`mouse_turns_the_mouse_off_and_the_next_one_turns_it_back_on` in
`crates/pullpen-ui/src/app/input/tests.rs`).
4 changes: 4 additions & 0 deletions wiki/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ check, a conflict or a draft, and the key that helps.
**A merge or an approval fails.** The message is the forge's own reason.
`:messages` keeps the last 200.

**Dragging does not select text, or clicks do odd things.** pullpen asks the
terminal for the mouse. Hold `Shift` while dragging to select, or type
`:mouse` to turn the mouse off until you quit.

**Something else.** The log is `~/.local/state/pullpen/pullpen.log`
(`%LOCALAPPDATA%\pullpen\state\pullpen.log` on Windows); it never contains a
token. Attach `pullpen config check` and `pullpen --version` to an
Expand Down
4 changes: 3 additions & 1 deletion wiki/Your-first-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ how many PRs are armed and failing, when it last synced, and each forge with
| `?` | every key |
| `q` | back, or quit |

[All the keys](Keys).
[All the keys](Keys). The mouse works too: click a tab or a row,
double-click to open, click the top row of a PR to go back, and scroll with
the wheel ([Mouse](Keys#mouse)).

## Walking away

Expand Down
Loading