mirror of
https://github.com/Morantron/tmux-fingers.git
synced 2026-09-10 07:26:32 -04:00
wip
This commit is contained in:
parent
463d28a1a6
commit
f7414e9a94
12
channel.cr
Normal file
12
channel.cr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
puts "ola"
|
||||
|
||||
spawn do
|
||||
puts "spawn"
|
||||
end
|
||||
|
||||
puts "after spawn"
|
||||
|
||||
loop do
|
||||
sleep 1
|
||||
puts "zzz"
|
||||
end
|
||||
|
|
@ -13,8 +13,10 @@ module Fingers::Commands
|
|||
end
|
||||
|
||||
def run(arguments, options) : Nil
|
||||
puts "hello from report tty :)"
|
||||
socket = InputSocket.new
|
||||
|
||||
|
||||
tty_val = tty
|
||||
Log.info { "reporting tty: #{tty_val}" }
|
||||
socket.send_message("tty:#{tty_val}")
|
||||
|
|
|
|||
|
|
@ -97,37 +97,22 @@ module Fingers::Commands
|
|||
|
||||
track_tmux_state
|
||||
|
||||
ch = Channel(String).new
|
||||
|
||||
#handle_input(ch)
|
||||
|
||||
display_popup_over(target_pane)
|
||||
|
||||
#loop do
|
||||
#Log.info { "waiting for cmd" }
|
||||
#input = ch.receive
|
||||
|
||||
#cmd, val = input.split(":")
|
||||
|
||||
#if cmd == "tty"
|
||||
#@popup_tty = val
|
||||
#show_hints
|
||||
#else
|
||||
#view.process_input(input)
|
||||
#break if state.exiting
|
||||
#end
|
||||
#end
|
||||
#input_socket.remove_socket_file
|
||||
|
||||
wait_for_tty
|
||||
spawn display_popup_over(target_pane)
|
||||
|
||||
if Fingers.config.benchmark_mode == "1"
|
||||
exit(0)
|
||||
end
|
||||
|
||||
Log.info { "pues nada nos vamos" }
|
||||
#process_result
|
||||
#teardown
|
||||
end
|
||||
|
||||
private def display_popup_over(pane : Tmux::Pane)
|
||||
Log.info { "displaying pane" }
|
||||
coords = pane.coords
|
||||
|
||||
return nil unless coords
|
||||
|
|
@ -214,17 +199,21 @@ module Fingers::Commands
|
|||
|
||||
Log.info { "showing hints: #{@popup_tty}" }
|
||||
view.render
|
||||
tmux.swap_panes(fingers_window.pane_id, target_pane.pane_id)
|
||||
#tmux.swap_panes(fingers_window.pane_id, target_pane.pane_id)
|
||||
end
|
||||
|
||||
private def handle_input(channel)
|
||||
private def wait_for_tty
|
||||
Log.info { "wait for tty" }
|
||||
input_socket = InputSocket.new
|
||||
input_socket.remove_socket_file
|
||||
|
||||
#tmux.disable_prefix
|
||||
#tmux.set_key_table "fingers"
|
||||
input_socket.on_input do |msg|
|
||||
cmd, val = msg.split(":")
|
||||
|
||||
input_socket.on_input do |input|
|
||||
channel.send(input)
|
||||
@popup_tty = val if cmd == "tty"
|
||||
|
||||
input_socket.server.close
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,18 @@ module Fingers
|
|||
def on_input
|
||||
remove_socket_file
|
||||
|
||||
loop do
|
||||
Log.info { "waiting for socket" }
|
||||
socket = server.accept
|
||||
while socket = server.accept?
|
||||
Fiber.yield
|
||||
|
||||
Log.info { "input socket: WAITING FOR CONN" }
|
||||
break if socket.nil?
|
||||
|
||||
Fiber.yield
|
||||
|
||||
message = socket.gets
|
||||
|
||||
Fiber.yield
|
||||
|
||||
yield (message || "")
|
||||
end
|
||||
end
|
||||
|
|
@ -32,8 +39,6 @@ module Fingers
|
|||
remove_socket_file
|
||||
end
|
||||
|
||||
private getter :path
|
||||
|
||||
def server
|
||||
@server ||= UNIXServer.new(path)
|
||||
end
|
||||
|
|
@ -41,5 +46,7 @@ module Fingers
|
|||
def remove_socket_file
|
||||
`rm -rf #{path}`
|
||||
end
|
||||
|
||||
private getter :path
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ module Fingers
|
|||
end
|
||||
|
||||
def render
|
||||
Log.info { "view render" }
|
||||
clear_screen
|
||||
hide_cursor
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue