Use custom titles for register select info boxes
Previously all register selection info boxes had "Registers" as the title. That was particularly confusing for `copy_between_registers` which presents two info boxes back-to-back.
This commit is contained in:
parent
b8912adbbf
commit
e0da129727
2 changed files with 18 additions and 6 deletions
|
@ -5544,7 +5544,10 @@ fn wonly(cx: &mut Context) {
|
|||
}
|
||||
|
||||
fn select_register(cx: &mut Context) {
|
||||
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
|
||||
cx.editor.autoinfo = Some(Info::from_registers(
|
||||
"Select register",
|
||||
&cx.editor.registers,
|
||||
));
|
||||
cx.on_next_key(move |cx, event| {
|
||||
cx.editor.autoinfo = None;
|
||||
if let Some(ch) = event.char() {
|
||||
|
@ -5554,7 +5557,10 @@ fn select_register(cx: &mut Context) {
|
|||
}
|
||||
|
||||
fn insert_register(cx: &mut Context) {
|
||||
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
|
||||
cx.editor.autoinfo = Some(Info::from_registers(
|
||||
"Insert register",
|
||||
&cx.editor.registers,
|
||||
));
|
||||
cx.on_next_key(move |cx, event| {
|
||||
cx.editor.autoinfo = None;
|
||||
if let Some(ch) = event.char() {
|
||||
|
@ -5571,7 +5577,10 @@ fn insert_register(cx: &mut Context) {
|
|||
}
|
||||
|
||||
fn copy_between_registers(cx: &mut Context) {
|
||||
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
|
||||
cx.editor.autoinfo = Some(Info::from_registers(
|
||||
"Copy from register",
|
||||
&cx.editor.registers,
|
||||
));
|
||||
cx.on_next_key(move |cx, event| {
|
||||
cx.editor.autoinfo = None;
|
||||
|
||||
|
@ -5585,7 +5594,10 @@ fn copy_between_registers(cx: &mut Context) {
|
|||
};
|
||||
let values: Vec<_> = values.map(|value| value.to_string()).collect();
|
||||
|
||||
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
|
||||
cx.editor.autoinfo = Some(Info::from_registers(
|
||||
"Copy into register",
|
||||
&cx.editor.registers,
|
||||
));
|
||||
cx.on_next_key(move |cx, event| {
|
||||
cx.editor.autoinfo = None;
|
||||
|
||||
|
|
|
@ -57,13 +57,13 @@ impl Info {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_registers(registers: &Registers) -> Self {
|
||||
pub fn from_registers(title: impl Into<Cow<'static, str>>, registers: &Registers) -> Self {
|
||||
let body: Vec<_> = registers
|
||||
.iter_preview()
|
||||
.map(|(ch, preview)| (ch.to_string(), preview))
|
||||
.collect();
|
||||
|
||||
let mut infobox = Self::new("Registers", &body);
|
||||
let mut infobox = Self::new(title, &body);
|
||||
infobox.width = 30; // copied content could be very long
|
||||
infobox
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue