hostty 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/assets/demo.svg +405 -126
- data/docs/features/stopping.md +12 -2
- data/lib/hostty/cli.rb +5 -1
- data/lib/hostty/config/loader.rb +4 -1
- data/lib/hostty/config/rules/path_settings.rb +3 -1
- data/lib/hostty/config/validator.rb +5 -1
- data/lib/hostty/ghostty/cell_reader.rb +1 -0
- data/lib/hostty/ghostty/mouse.rb +3 -1
- data/lib/hostty/ghostty/screen.rb +5 -1
- data/lib/hostty/ghostty/style_decoder.rb +3 -1
- data/lib/hostty/manager/child.rb +4 -1
- data/lib/hostty/manager/countdown.rb +39 -0
- data/lib/hostty/manager/events.rb +3 -1
- data/lib/hostty/manager.rb +47 -17
- data/lib/hostty/output.rb +8 -2
- data/lib/hostty/plain/app.rb +4 -1
- data/lib/hostty/plain/pipe.rb +9 -2
- data/lib/hostty/port_chooser.rb +18 -3
- data/lib/hostty/terminal/cell.rb +3 -1
- data/lib/hostty/terminal/style.rb +22 -5
- data/lib/hostty/tui/app.rb +14 -3
- data/lib/hostty/tui/blink.rb +5 -1
- data/lib/hostty/tui/canvas.rb +5 -1
- data/lib/hostty/tui/desktop.rb +11 -3
- data/lib/hostty/tui/display.rb +3 -1
- data/lib/hostty/tui/input.rb +7 -1
- data/lib/hostty/tui/mouse/idle.rb +4 -1
- data/lib/hostty/tui/mouse/pointer.rb +4 -1
- data/lib/hostty/tui/mouse/selecting.rb +4 -1
- data/lib/hostty/tui/mouse/target.rb +3 -1
- data/lib/hostty/tui/pane.rb +8 -1
- data/lib/hostty/tui/pty.rb +14 -0
- data/lib/hostty/tui/reactor.rb +4 -1
- data/lib/hostty/tui/regions/pane_view.rb +4 -1
- data/lib/hostty/tui/regions/tab_bar.rb +18 -4
- data/lib/hostty/tui/renderer.rb +5 -1
- data/lib/hostty/tui/selection.rb +3 -1
- data/lib/hostty/tui/sources/stdin.rb +4 -1
- data/lib/hostty/tui/tabs.rb +3 -1
- data/lib/hostty/tui/window.rb +5 -1
- data/lib/hostty/version.rb +1 -1
- data/lib/hostty.rb +1 -0
- metadata +2 -1
data/docs/features/stopping.md
CHANGED
|
@@ -45,10 +45,20 @@ Hostty prints each step:
|
|
|
45
45
|
12:10:00 hostty | jobs exited with code 143.
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
When a process
|
|
48
|
+
When a process is slow to exit, hostty names it and counts down:
|
|
49
49
|
|
|
50
50
|
```text
|
|
51
|
-
12:10:
|
|
51
|
+
12:10:01 hostty | Waiting for jobs, 9 seconds left. Press Ctrl-C to send KILL now.
|
|
52
|
+
12:10:04 hostty | Waiting for jobs, 6 seconds left. Press Ctrl-C to send KILL now.
|
|
53
|
+
12:10:07 hostty | Waiting for jobs, 3 seconds left. Press Ctrl-C to send KILL now.
|
|
54
|
+
12:10:10 hostty | Killing jobs.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
When a process still runs 5 seconds after KILL, hostty exits without it:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
12:10:11 hostty | Waiting for jobs, 4 seconds left. Press Ctrl-C to stop waiting.
|
|
61
|
+
12:10:15 hostty | Stopped waiting. Still running: jobs.
|
|
52
62
|
```
|
|
53
63
|
|
|
54
64
|
The `--timeout` option sets the first wait. It defaults to 10 seconds. Give a slow process, such as Solid Queue finishing its running jobs, more time with a higher value.
|
data/lib/hostty/cli.rb
CHANGED
|
@@ -73,7 +73,11 @@ module Hostty
|
|
|
73
73
|
|
|
74
74
|
def start
|
|
75
75
|
load_ghostty if tui?
|
|
76
|
-
|
|
76
|
+
|
|
77
|
+
config.notices.each do |notice|
|
|
78
|
+
output.notice(notice)
|
|
79
|
+
end
|
|
80
|
+
|
|
77
81
|
Domains.new(processes: config.processes, nginx:, output:).add
|
|
78
82
|
Manager.new(processes: config.processes, front_end:, output:, stop_timeout: options[:timeout]).run
|
|
79
83
|
end
|
data/lib/hostty/config/loader.rb
CHANGED
|
@@ -71,7 +71,10 @@ module Hostty
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def processes
|
|
74
|
-
@processes ||=
|
|
74
|
+
@processes ||=
|
|
75
|
+
definitions.map do |definition|
|
|
76
|
+
definition.build(port: ports.fetch(definition))
|
|
77
|
+
end
|
|
75
78
|
end
|
|
76
79
|
end
|
|
77
80
|
end
|
|
@@ -21,7 +21,9 @@ module Hostty
|
|
|
21
21
|
attr_reader :name, :settings
|
|
22
22
|
|
|
23
23
|
def invalid_keys
|
|
24
|
-
@invalid_keys ||= KEYS.select
|
|
24
|
+
@invalid_keys ||= KEYS.select do |key|
|
|
25
|
+
settings.key?(key) && !Text.new(settings[key]).present?
|
|
26
|
+
end
|
|
25
27
|
end
|
|
26
28
|
end
|
|
27
29
|
end
|
data/lib/hostty/ghostty/mouse.rb
CHANGED
|
@@ -90,7 +90,11 @@ module Hostty
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def send_bells
|
|
93
|
-
@ring =
|
|
93
|
+
@ring =
|
|
94
|
+
FFI::Function.new(:void, %i[pointer pointer]) do |_terminal, _userdata|
|
|
95
|
+
bell&.call
|
|
96
|
+
end
|
|
97
|
+
|
|
94
98
|
Library.ghostty_terminal_set(terminal, Library::TERMINAL_OPT_BELL, @ring)
|
|
95
99
|
end
|
|
96
100
|
|
data/lib/hostty/manager/child.rb
CHANGED
|
@@ -13,7 +13,10 @@ module Hostty
|
|
|
13
13
|
|
|
14
14
|
def start
|
|
15
15
|
@pid = launch.start(process)
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
Thread.new(pid) do |child_pid|
|
|
18
|
+
events.push(ProcessExited.new(name:, status: Process.wait2(child_pid).last))
|
|
19
|
+
end
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
def signal(signal_name)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hostty
|
|
4
|
+
class Manager
|
|
5
|
+
class Countdown
|
|
6
|
+
def initialize(seconds:)
|
|
7
|
+
@deadline = now + seconds
|
|
8
|
+
@reminder_at = now + FIRST_REMINDER
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def expired?
|
|
12
|
+
now >= deadline
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def next_wait
|
|
16
|
+
([deadline, reminder_at].min - now).clamp(0, nil)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def remind
|
|
20
|
+
return if now < reminder_at
|
|
21
|
+
|
|
22
|
+
@reminder_at = now + REMINDER_INTERVAL
|
|
23
|
+
yield (deadline - now).ceil
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
FIRST_REMINDER = 1
|
|
29
|
+
REMINDER_INTERVAL = 3
|
|
30
|
+
private_constant :FIRST_REMINDER, :REMINDER_INTERVAL
|
|
31
|
+
|
|
32
|
+
attr_reader :deadline, :reminder_at
|
|
33
|
+
|
|
34
|
+
def now
|
|
35
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/hostty/manager.rb
CHANGED
|
@@ -7,7 +7,11 @@ module Hostty
|
|
|
7
7
|
@output = output
|
|
8
8
|
@stop_timeout = stop_timeout
|
|
9
9
|
@events = Events.new
|
|
10
|
-
@children =
|
|
10
|
+
@children =
|
|
11
|
+
processes.to_h do |process|
|
|
12
|
+
[process.name, build_child(process)]
|
|
13
|
+
end
|
|
14
|
+
|
|
11
15
|
@running = {}
|
|
12
16
|
end
|
|
13
17
|
|
|
@@ -15,7 +19,10 @@ module Hostty
|
|
|
15
19
|
|
|
16
20
|
def run
|
|
17
21
|
with_signal_traps do
|
|
18
|
-
children.each_key
|
|
22
|
+
children.each_key do |name|
|
|
23
|
+
start(name)
|
|
24
|
+
end
|
|
25
|
+
|
|
19
26
|
front_end.wait(self)
|
|
20
27
|
ensure
|
|
21
28
|
stop
|
|
@@ -47,56 +54,79 @@ module Hostty
|
|
|
47
54
|
|
|
48
55
|
attr_reader :front_end, :output, :stop_timeout, :events, :children, :running
|
|
49
56
|
|
|
57
|
+
def running_names = running.keys.join(", ")
|
|
58
|
+
|
|
50
59
|
def build_child(process)
|
|
51
60
|
Child.new(process:, launch: front_end.launch_for(process), events:)
|
|
52
61
|
end
|
|
53
62
|
|
|
63
|
+
def trap_signal(signal)
|
|
64
|
+
trap(signal) do
|
|
65
|
+
events.push(SignalReceived.new(signal:))
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
54
69
|
def with_signal_traps
|
|
55
|
-
previous_handlers = SIGNALS.to_h
|
|
70
|
+
previous_handlers = SIGNALS.to_h do |signal|
|
|
71
|
+
[signal, trap_signal(signal)]
|
|
72
|
+
end
|
|
73
|
+
|
|
56
74
|
yield
|
|
57
75
|
ensure
|
|
58
|
-
previous_handlers&.each
|
|
76
|
+
previous_handlers&.each do |signal, handler|
|
|
77
|
+
trap(signal, handler || "DEFAULT")
|
|
78
|
+
end
|
|
59
79
|
end
|
|
60
80
|
|
|
61
81
|
def receive(timeout: nil)
|
|
62
|
-
next_event(timeout:)&.tap
|
|
82
|
+
next_event(timeout:)&.tap do |event|
|
|
83
|
+
event.announce(output)
|
|
84
|
+
end
|
|
63
85
|
end
|
|
64
86
|
|
|
65
87
|
def stop
|
|
66
88
|
unless running.empty?
|
|
67
89
|
output.notice("Stopping all processes.")
|
|
68
90
|
signal_children("TERM")
|
|
69
|
-
kill_children unless wait_for_children(timeout: stop_timeout)
|
|
91
|
+
kill_children unless wait_for_children(timeout: stop_timeout, hint: "Press Ctrl-C to send KILL now.")
|
|
70
92
|
end
|
|
71
93
|
|
|
72
94
|
children.each_value(&:finish)
|
|
73
95
|
end
|
|
74
96
|
|
|
75
|
-
def wait_for_children(timeout:)
|
|
76
|
-
|
|
97
|
+
def wait_for_children(timeout:, hint:)
|
|
98
|
+
countdown = Countdown.new(seconds: timeout)
|
|
77
99
|
|
|
78
100
|
until running.empty?
|
|
79
|
-
event = receive(timeout:
|
|
80
|
-
return false if event
|
|
101
|
+
event = receive(timeout: countdown.next_wait)
|
|
102
|
+
return false if event&.interrupt?
|
|
103
|
+
next if event
|
|
104
|
+
return false if countdown.expired?
|
|
105
|
+
|
|
106
|
+
countdown.remind do |seconds|
|
|
107
|
+
output.notice("Waiting for #{running_names}, #{seconds_left(seconds)}. #{hint}")
|
|
108
|
+
end
|
|
81
109
|
end
|
|
82
110
|
|
|
83
111
|
true
|
|
84
112
|
end
|
|
85
113
|
|
|
86
114
|
def kill_children
|
|
87
|
-
output.notice("Killing
|
|
115
|
+
output.notice("Killing #{running_names}.")
|
|
88
116
|
signal_children("KILL")
|
|
89
|
-
return if wait_for_children(timeout: KILL_TIMEOUT)
|
|
117
|
+
return if wait_for_children(timeout: KILL_TIMEOUT, hint: "Press Ctrl-C to stop waiting.")
|
|
90
118
|
|
|
91
|
-
output.notice("Stopped waiting
|
|
119
|
+
output.notice("Stopped waiting. Still running: #{running_names}.")
|
|
92
120
|
end
|
|
93
121
|
|
|
94
|
-
def
|
|
95
|
-
|
|
122
|
+
def seconds_left(seconds)
|
|
123
|
+
"#{seconds} #{(seconds == 1) ? "second" : "seconds"} left"
|
|
96
124
|
end
|
|
97
125
|
|
|
98
|
-
def
|
|
99
|
-
|
|
126
|
+
def signal_children(signal_name)
|
|
127
|
+
children.each_value do |child|
|
|
128
|
+
child.signal(signal_name)
|
|
129
|
+
end
|
|
100
130
|
end
|
|
101
131
|
end
|
|
102
132
|
end
|
data/lib/hostty/output.rb
CHANGED
|
@@ -5,14 +5,20 @@ module Hostty
|
|
|
5
5
|
def initialize(names:, io:)
|
|
6
6
|
@io = io
|
|
7
7
|
@width = [*names, NOTICE_NAME].map(&:length).max
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
@colors = names.each_with_index.to_h do |name, index|
|
|
10
|
+
[name, COLORS[index % COLORS.size]]
|
|
11
|
+
end
|
|
12
|
+
|
|
9
13
|
@mutex = Mutex.new
|
|
10
14
|
end
|
|
11
15
|
|
|
12
16
|
def line(name, text)
|
|
13
17
|
prefix = "#{Time.now.strftime("%H:%M:%S")} #{name.ljust(width)} |"
|
|
14
18
|
|
|
15
|
-
mutex.synchronize
|
|
19
|
+
mutex.synchronize do
|
|
20
|
+
io.puts("#{colorize(prefix, colors.fetch(name, NOTICE_COLOR))} #{text}")
|
|
21
|
+
end
|
|
16
22
|
end
|
|
17
23
|
|
|
18
24
|
def notice(text)
|
data/lib/hostty/plain/app.rb
CHANGED
data/lib/hostty/plain/pipe.rb
CHANGED
|
@@ -10,7 +10,12 @@ module Hostty
|
|
|
10
10
|
def start(process)
|
|
11
11
|
reader, writer = IO.pipe
|
|
12
12
|
pid = spawn_process(process, writer)
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
@reader_thread =
|
|
15
|
+
Thread.new do
|
|
16
|
+
forward(process.name, reader)
|
|
17
|
+
end
|
|
18
|
+
|
|
14
19
|
pid
|
|
15
20
|
ensure
|
|
16
21
|
writer&.close
|
|
@@ -44,7 +49,9 @@ module Hostty
|
|
|
44
49
|
end
|
|
45
50
|
|
|
46
51
|
def forward(name, reader)
|
|
47
|
-
reader.each_line
|
|
52
|
+
reader.each_line do |text|
|
|
53
|
+
output.line(name, text.chomp)
|
|
54
|
+
end
|
|
48
55
|
rescue IOError
|
|
49
56
|
nil
|
|
50
57
|
ensure
|
data/lib/hostty/port_chooser.rb
CHANGED
|
@@ -25,7 +25,8 @@ module Hostty
|
|
|
25
25
|
|
|
26
26
|
RANDOM_PORTS = 10_000..59_999
|
|
27
27
|
MOVE_LIMIT = 100
|
|
28
|
-
|
|
28
|
+
LISTEN_HOSTS = %w[0.0.0.0 127.0.0.1 ::1].freeze
|
|
29
|
+
private_constant :RANDOM_PORTS, :MOVE_LIMIT, :LISTEN_HOSTS
|
|
29
30
|
|
|
30
31
|
attr_reader :skip_used_ports, :random, :owners
|
|
31
32
|
|
|
@@ -34,10 +35,18 @@ module Hostty
|
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def in_use?(port)
|
|
37
|
-
|
|
38
|
+
LISTEN_HOSTS.any? do |host|
|
|
39
|
+
bound_on?(host, port)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def bound_on?(host, port)
|
|
44
|
+
TCPServer.new(host, port).close
|
|
38
45
|
false
|
|
39
46
|
rescue Errno::EADDRINUSE, Errno::EACCES
|
|
40
47
|
true
|
|
48
|
+
rescue Errno::EADDRNOTAVAIL
|
|
49
|
+
false
|
|
41
50
|
end
|
|
42
51
|
|
|
43
52
|
def claim(port, name)
|
|
@@ -45,9 +54,15 @@ module Hostty
|
|
|
45
54
|
port
|
|
46
55
|
end
|
|
47
56
|
|
|
57
|
+
def first_free_port(candidates)
|
|
58
|
+
candidates.find do |candidate|
|
|
59
|
+
free?(candidate)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
48
63
|
def next_free_port(name, port)
|
|
49
64
|
candidates = (port + 1)..(port + MOVE_LIMIT)
|
|
50
|
-
candidates
|
|
65
|
+
first_free_port(candidates) or
|
|
51
66
|
raise ConfigError, "No free port for #{name} from #{candidates.begin} to #{candidates.end}."
|
|
52
67
|
end
|
|
53
68
|
|
data/lib/hostty/terminal/cell.rb
CHANGED
|
@@ -10,7 +10,11 @@ module Hostty
|
|
|
10
10
|
def initialize(fg: nil, bg: nil, **flags)
|
|
11
11
|
@fg = fg
|
|
12
12
|
@bg = bg
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
FLAG_CODES.each_key do |flag|
|
|
15
|
+
instance_variable_set(:"@#{flag}", flags.fetch(flag, false))
|
|
16
|
+
end
|
|
17
|
+
|
|
14
18
|
freeze
|
|
15
19
|
end
|
|
16
20
|
|
|
@@ -23,7 +27,9 @@ module Hostty
|
|
|
23
27
|
def hash = to_h.hash
|
|
24
28
|
|
|
25
29
|
def to_h
|
|
26
|
-
ATTRIBUTES.to_h
|
|
30
|
+
ATTRIBUTES.to_h do |attribute|
|
|
31
|
+
[attribute, public_send(attribute)]
|
|
32
|
+
end
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
def background
|
|
@@ -32,7 +38,11 @@ module Hostty
|
|
|
32
38
|
|
|
33
39
|
def sgr
|
|
34
40
|
codes = [0]
|
|
35
|
-
|
|
41
|
+
|
|
42
|
+
FLAG_CODES.each do |flag, code|
|
|
43
|
+
codes << code if public_send(flag)
|
|
44
|
+
end
|
|
45
|
+
|
|
36
46
|
codes.concat(color_codes(fg, base: 30, extended: 38))
|
|
37
47
|
codes.concat(color_codes(bg, base: 40, extended: 48))
|
|
38
48
|
"\e[#{codes.join(";")}m"
|
|
@@ -43,11 +53,18 @@ module Hostty
|
|
|
43
53
|
end
|
|
44
54
|
|
|
45
55
|
def self.shared(attributes)
|
|
46
|
-
styles.fetch(attributes.values)
|
|
56
|
+
styles.fetch(attributes.values) do
|
|
57
|
+
new(**attributes)
|
|
58
|
+
end
|
|
47
59
|
end
|
|
48
60
|
|
|
49
61
|
def self.styles
|
|
50
|
-
@styles ||=
|
|
62
|
+
@styles ||=
|
|
63
|
+
Flyweight.new.tap do |styles|
|
|
64
|
+
styles.fetch(plain.to_h.values) do
|
|
65
|
+
plain
|
|
66
|
+
end
|
|
67
|
+
end
|
|
51
68
|
end
|
|
52
69
|
private_class_method :styles
|
|
53
70
|
|
data/lib/hostty/tui/app.rb
CHANGED
|
@@ -14,14 +14,25 @@ module Hostty
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def launch_for(process)
|
|
17
|
-
Pane.new(name: process.name, url: process.url, rows: layout.pane_rows, cols: layout.cols).tap
|
|
17
|
+
Pane.new(name: process.name, url: process.url, rows: layout.pane_rows, cols: layout.cols).tap do |pane|
|
|
18
|
+
tabs.add(pane)
|
|
19
|
+
end
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def wait(manager)
|
|
21
23
|
@manager = manager
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
|
|
25
|
+
tabs.each do |pane|
|
|
26
|
+
pane.subscribe(activity)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
with_terminal do
|
|
30
|
+
cycle until outcome.decided?
|
|
31
|
+
end
|
|
32
|
+
|
|
24
33
|
outcome.exit_code
|
|
34
|
+
ensure
|
|
35
|
+
tabs.each(&:discard_output)
|
|
25
36
|
end
|
|
26
37
|
|
|
27
38
|
private
|
data/lib/hostty/tui/blink.rb
CHANGED
data/lib/hostty/tui/canvas.rb
CHANGED
data/lib/hostty/tui/desktop.rb
CHANGED
|
@@ -38,17 +38,25 @@ module Hostty
|
|
|
38
38
|
def copy_with_command(text)
|
|
39
39
|
return unless clipboard_command
|
|
40
40
|
|
|
41
|
-
IO.popen(clipboard_command, "w", err: File::NULL)
|
|
41
|
+
IO.popen(clipboard_command, "w", err: File::NULL) do |pipe|
|
|
42
|
+
pipe.write(text)
|
|
43
|
+
end
|
|
42
44
|
rescue SystemCallError, IOError
|
|
43
45
|
nil
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
def clipboard_command
|
|
47
|
-
@clipboard_command ||=
|
|
49
|
+
@clipboard_command ||=
|
|
50
|
+
CLIPBOARD_COMMANDS.find do |command|
|
|
51
|
+
installed?(command.first)
|
|
52
|
+
end
|
|
48
53
|
end
|
|
49
54
|
|
|
50
55
|
def installed?(name)
|
|
51
|
-
ENV
|
|
56
|
+
ENV
|
|
57
|
+
.fetch("PATH", "")
|
|
58
|
+
.split(File::PATH_SEPARATOR)
|
|
59
|
+
.any? { |dir| File.executable?(File.join(dir, name)) }
|
|
52
60
|
end
|
|
53
61
|
end
|
|
54
62
|
end
|
data/lib/hostty/tui/display.rb
CHANGED
data/lib/hostty/tui/input.rb
CHANGED
|
@@ -58,11 +58,17 @@ module Hostty
|
|
|
58
58
|
button: (code.anybits?(64) ? WHEEL_BUTTONS : BUTTONS)[code & 0b11],
|
|
59
59
|
row: match[3].to_i - 1,
|
|
60
60
|
col: match[2].to_i - 1,
|
|
61
|
-
modifiers:
|
|
61
|
+
modifiers: mouse_modifiers(code)
|
|
62
62
|
)
|
|
63
63
|
Events::MouseReport.new(mouse: event) if event.button
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
def mouse_modifiers(code)
|
|
67
|
+
MODIFIER_BITS.filter_map do |name, bit|
|
|
68
|
+
name if code.anybits?(bit)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
66
72
|
def mouse_action(code, final)
|
|
67
73
|
return :release if final == "m"
|
|
68
74
|
|
|
@@ -19,7 +19,10 @@ module Hostty
|
|
|
19
19
|
def tick(_target) = self
|
|
20
20
|
|
|
21
21
|
def press(event, target)
|
|
22
|
-
target.press(event)
|
|
22
|
+
target.press(event) do |pointer|
|
|
23
|
+
return Selecting.new(pointer:, clock:)
|
|
24
|
+
end
|
|
25
|
+
|
|
23
26
|
self
|
|
24
27
|
end
|
|
25
28
|
|