show feedback when processing input and copying result

This commit is contained in:
Jorge Morante 2023-09-27 09:29:49 +02:00
parent 33016aa171
commit 9c1004d13b
3 changed files with 11 additions and 5 deletions

View File

@ -136,7 +136,8 @@ module Fingers::Commands
hinter: hinter,
state: state,
output: pane_printer,
original_pane: target_pane
original_pane: target_pane,
tmux: tmux
)
end

View File

@ -12,12 +12,14 @@ module Fingers
@state : State
@output : Printer
@original_pane : Tmux::Pane
@tmux : Tmux
def initialize(
@hinter,
@output,
@original_pane,
@state
@state,
@tmux
)
end
@ -51,6 +53,8 @@ module Fingers
match: state.result,
original_pane: original_pane
).run
tmux.display_message("Copied: #{state.result}", 500) unless state.result.empty?
end
private def hide_cursor
@ -67,6 +71,7 @@ module Fingers
match = hinter.lookup(state.input)
handle_match(match) if match
tmux.display_message(state.input, 300)
end
private def process_multimode
@ -80,7 +85,7 @@ module Fingers
end
end
private getter :output, :hinter, :original_pane, :state
private getter :output, :hinter, :original_pane, :state, :tmux
private def handle_match(match)
if state.multi_mode

View File

@ -279,8 +279,8 @@ class Tmux
socket
end
def display_message(msg)
exec("display-message \"#{msg}\"")
def display_message(msg, delay = 100)
exec(Process.quote(["display-message", "-d", delay.to_s, msg]))
end
private def exec(cmd)