hostty 0.1.0.alpha-x86_64-darwin
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 +7 -0
- data/.hostty.yml +18 -0
- data/.ruby-version +1 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +70 -0
- data/THIRD_PARTY_NOTICES.txt +247 -0
- data/docs/assets/demo.svg +168 -0
- data/docs/assets/hostty-dark-static.svg +27 -0
- data/docs/assets/hostty-dark.svg +92 -0
- data/docs/assets/hostty-light-static.svg +27 -0
- data/docs/assets/hostty-light.svg +92 -0
- data/docs/development/README.md +120 -0
- data/docs/development/architecture.md +169 -0
- data/docs/features/README.md +45 -0
- data/docs/features/command-line.md +46 -0
- data/docs/features/configuration.md +131 -0
- data/docs/features/domains.md +81 -0
- data/docs/features/plain-output.md +56 -0
- data/docs/features/stopping.md +69 -0
- data/docs/features/tabs.md +120 -0
- data/docs/features/terminal-emulator.md +66 -0
- data/exe/hostty +6 -0
- data/lib/hostty/cli.rb +86 -0
- data/lib/hostty/config.rb +78 -0
- data/lib/hostty/domains.rb +22 -0
- data/lib/hostty/exceptions.rb +7 -0
- data/lib/hostty/ghostty/frame.rb +203 -0
- data/lib/hostty/ghostty/libghostty-vt.dylib +0 -0
- data/lib/hostty/ghostty/library.rb +148 -0
- data/lib/hostty/ghostty/mouse.rb +77 -0
- data/lib/hostty/ghostty/screen.rb +112 -0
- data/lib/hostty/manager/child.rb +36 -0
- data/lib/hostty/manager/events.rb +27 -0
- data/lib/hostty/manager/process_exited.rb +28 -0
- data/lib/hostty/manager/signal_received.rb +23 -0
- data/lib/hostty/manager.rb +102 -0
- data/lib/hostty/output.rb +37 -0
- data/lib/hostty/plain/app.rb +23 -0
- data/lib/hostty/plain/pipe.rb +55 -0
- data/lib/hostty/port_chooser.rb +62 -0
- data/lib/hostty/process_config.rb +80 -0
- data/lib/hostty/terminal/cell.rb +35 -0
- data/lib/hostty/terminal/style.rb +87 -0
- data/lib/hostty/tui/app.rb +277 -0
- data/lib/hostty/tui/desktop.rb +51 -0
- data/lib/hostty/tui/input.rb +69 -0
- data/lib/hostty/tui/layout.rb +68 -0
- data/lib/hostty/tui/mouse_event.rb +36 -0
- data/lib/hostty/tui/pane.rb +125 -0
- data/lib/hostty/tui/pty.rb +62 -0
- data/lib/hostty/tui/renderer.rb +85 -0
- data/lib/hostty/tui/selection.rb +47 -0
- data/lib/hostty/version.rb +5 -0
- data/lib/hostty.rb +35 -0
- data/sig/hostty.rbs +4 -0
- metadata +130 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hostty
|
|
4
|
+
module Tui
|
|
5
|
+
class Renderer
|
|
6
|
+
def initialize(io:)
|
|
7
|
+
@io = io
|
|
8
|
+
@previous = []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def reset
|
|
12
|
+
@previous = []
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def render(layout:, panes:, selected:)
|
|
16
|
+
rows = [tab_row(layout, panes, selected), *pane_rows(selected), help_row(layout, selected)]
|
|
17
|
+
frame = +""
|
|
18
|
+
rows.each_with_index { |row, index| frame << "\e[#{index + 1};1H#{row}" unless @previous[index] == row }
|
|
19
|
+
@previous = rows
|
|
20
|
+
io.write(frame << cursor(selected))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
BAR = "\e[0;37;48;5;236m"
|
|
26
|
+
SELECTED_TAB = "\e[0;1;97;48;5;24m"
|
|
27
|
+
RUNNING_DOT = "\e[32m"
|
|
28
|
+
EXITED_DOT = "\e[31m"
|
|
29
|
+
RESET = "\e[0m"
|
|
30
|
+
private_constant :BAR, :SELECTED_TAB, :RUNNING_DOT, :EXITED_DOT, :RESET
|
|
31
|
+
|
|
32
|
+
attr_reader :io
|
|
33
|
+
|
|
34
|
+
def tab_row(layout, panes, selected)
|
|
35
|
+
text = layout.tabs.map { |tab| tab_label(panes[tab[:index]], selected) }.join
|
|
36
|
+
start = layout.url_start(selected.url)
|
|
37
|
+
return "#{text}#{BAR}#{" " * (layout.cols - layout.tabs_width)}#{RESET}" unless start
|
|
38
|
+
|
|
39
|
+
"#{text}#{BAR}#{" " * (start - layout.tabs_width)}#{selected.url} #{RESET}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def tab_label(pane, selected)
|
|
43
|
+
style = pane.equal?(selected) ? SELECTED_TAB : BAR
|
|
44
|
+
dot = pane.running? ? RUNNING_DOT : EXITED_DOT
|
|
45
|
+
"#{style} #{dot}●#{style} #{pane.name} "
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def pane_rows(pane)
|
|
49
|
+
pane.lines.each_with_index.map { |cells, row| line_text(cells, pane.selected_columns(row, cells.size)) }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def line_text(cells, selected_columns)
|
|
53
|
+
style = nil
|
|
54
|
+
text = +""
|
|
55
|
+
|
|
56
|
+
cells.each_with_index do |cell, col|
|
|
57
|
+
next if cell.continuation?
|
|
58
|
+
|
|
59
|
+
cell_style = selected_columns&.cover?(col) ? highlight(cell.style) : cell.style
|
|
60
|
+
text << cell_style.sgr unless cell_style.equal?(style)
|
|
61
|
+
style = cell_style
|
|
62
|
+
text << cell.char
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
text << RESET
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def highlight(style)
|
|
69
|
+
Terminal::Style.shared(style.to_h.merge(inverse: !style.inverse))
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def help_row(layout, pane)
|
|
73
|
+
text = layout.help_text(offset: pane.offset)[0, layout.cols].ljust(layout.cols)
|
|
74
|
+
"#{BAR}#{text.sub(Layout::RESTART_BUTTON, "\e[1;97m#{Layout::RESTART_BUTTON}#{BAR}")}#{RESET}"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def cursor(pane)
|
|
78
|
+
position = pane.screen.cursor
|
|
79
|
+
return "\e[?25l" unless pane.running? && pane.offset.zero? && position
|
|
80
|
+
|
|
81
|
+
"\e[#{position[0] + 2};#{position[1] + 1}H\e[?25h"
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hostty
|
|
4
|
+
module Tui
|
|
5
|
+
class Selection
|
|
6
|
+
def initialize(anchor:, head: anchor)
|
|
7
|
+
@anchor = anchor
|
|
8
|
+
@head = head
|
|
9
|
+
freeze
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def empty?
|
|
13
|
+
anchor == head
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def rows = first[0]..last[0]
|
|
17
|
+
|
|
18
|
+
def to(head)
|
|
19
|
+
self.class.new(anchor:, head:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def columns(row, width)
|
|
23
|
+
return unless rows.cover?(row)
|
|
24
|
+
|
|
25
|
+
start_col = (row == first[0]) ? first[1] : 0
|
|
26
|
+
end_col = (row == last[0]) ? last[1] : width - 1
|
|
27
|
+
start_col..end_col
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def text(lines)
|
|
31
|
+
rows.map { |row| row_text(lines[row] || [], row) }.join("\n")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
attr_reader :anchor, :head
|
|
37
|
+
|
|
38
|
+
def first = [anchor, head].min
|
|
39
|
+
|
|
40
|
+
def last = [anchor, head].max
|
|
41
|
+
|
|
42
|
+
def row_text(cells, row)
|
|
43
|
+
cells[columns(row, cells.size)].to_a.reject(&:continuation?).map(&:char).join.rstrip
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/lib/hostty.rb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "io/console"
|
|
4
|
+
require "optparse"
|
|
5
|
+
require "pty"
|
|
6
|
+
require "socket"
|
|
7
|
+
require "yaml"
|
|
8
|
+
require "ruby/nginx"
|
|
9
|
+
|
|
10
|
+
require_relative "hostty/version"
|
|
11
|
+
require_relative "hostty/exceptions"
|
|
12
|
+
require_relative "hostty/port_chooser"
|
|
13
|
+
require_relative "hostty/process_config"
|
|
14
|
+
require_relative "hostty/config"
|
|
15
|
+
require_relative "hostty/output"
|
|
16
|
+
require_relative "hostty/domains"
|
|
17
|
+
require_relative "hostty/terminal/style"
|
|
18
|
+
require_relative "hostty/terminal/cell"
|
|
19
|
+
require_relative "hostty/manager/events"
|
|
20
|
+
require_relative "hostty/manager/process_exited"
|
|
21
|
+
require_relative "hostty/manager/signal_received"
|
|
22
|
+
require_relative "hostty/manager/child"
|
|
23
|
+
require_relative "hostty/manager"
|
|
24
|
+
require_relative "hostty/plain/pipe"
|
|
25
|
+
require_relative "hostty/plain/app"
|
|
26
|
+
require_relative "hostty/tui/pty"
|
|
27
|
+
require_relative "hostty/tui/selection"
|
|
28
|
+
require_relative "hostty/tui/desktop"
|
|
29
|
+
require_relative "hostty/tui/pane"
|
|
30
|
+
require_relative "hostty/tui/layout"
|
|
31
|
+
require_relative "hostty/tui/mouse_event"
|
|
32
|
+
require_relative "hostty/tui/input"
|
|
33
|
+
require_relative "hostty/tui/renderer"
|
|
34
|
+
require_relative "hostty/tui/app"
|
|
35
|
+
require_relative "hostty/cli"
|
data/sig/hostty.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: hostty
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0.alpha
|
|
5
|
+
platform: x86_64-darwin
|
|
6
|
+
authors:
|
|
7
|
+
- Bert McCutchen
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: ffi
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.17'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '1.17'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: ruby-nginx
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1.0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '1.0'
|
|
40
|
+
description: Process manager with a CLI that runs the processes of a project and gives
|
|
41
|
+
each one an optional local domain with SSL through ruby-nginx.
|
|
42
|
+
email:
|
|
43
|
+
- mail@bertm.dev
|
|
44
|
+
executables:
|
|
45
|
+
- hostty
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- ".hostty.yml"
|
|
50
|
+
- ".ruby-version"
|
|
51
|
+
- LICENSE.txt
|
|
52
|
+
- README.md
|
|
53
|
+
- Rakefile
|
|
54
|
+
- THIRD_PARTY_NOTICES.txt
|
|
55
|
+
- docs/assets/demo.svg
|
|
56
|
+
- docs/assets/hostty-dark-static.svg
|
|
57
|
+
- docs/assets/hostty-dark.svg
|
|
58
|
+
- docs/assets/hostty-light-static.svg
|
|
59
|
+
- docs/assets/hostty-light.svg
|
|
60
|
+
- docs/development/README.md
|
|
61
|
+
- docs/development/architecture.md
|
|
62
|
+
- docs/features/README.md
|
|
63
|
+
- docs/features/command-line.md
|
|
64
|
+
- docs/features/configuration.md
|
|
65
|
+
- docs/features/domains.md
|
|
66
|
+
- docs/features/plain-output.md
|
|
67
|
+
- docs/features/stopping.md
|
|
68
|
+
- docs/features/tabs.md
|
|
69
|
+
- docs/features/terminal-emulator.md
|
|
70
|
+
- exe/hostty
|
|
71
|
+
- lib/hostty.rb
|
|
72
|
+
- lib/hostty/cli.rb
|
|
73
|
+
- lib/hostty/config.rb
|
|
74
|
+
- lib/hostty/domains.rb
|
|
75
|
+
- lib/hostty/exceptions.rb
|
|
76
|
+
- lib/hostty/ghostty/frame.rb
|
|
77
|
+
- lib/hostty/ghostty/libghostty-vt.dylib
|
|
78
|
+
- lib/hostty/ghostty/library.rb
|
|
79
|
+
- lib/hostty/ghostty/mouse.rb
|
|
80
|
+
- lib/hostty/ghostty/screen.rb
|
|
81
|
+
- lib/hostty/manager.rb
|
|
82
|
+
- lib/hostty/manager/child.rb
|
|
83
|
+
- lib/hostty/manager/events.rb
|
|
84
|
+
- lib/hostty/manager/process_exited.rb
|
|
85
|
+
- lib/hostty/manager/signal_received.rb
|
|
86
|
+
- lib/hostty/output.rb
|
|
87
|
+
- lib/hostty/plain/app.rb
|
|
88
|
+
- lib/hostty/plain/pipe.rb
|
|
89
|
+
- lib/hostty/port_chooser.rb
|
|
90
|
+
- lib/hostty/process_config.rb
|
|
91
|
+
- lib/hostty/terminal/cell.rb
|
|
92
|
+
- lib/hostty/terminal/style.rb
|
|
93
|
+
- lib/hostty/tui/app.rb
|
|
94
|
+
- lib/hostty/tui/desktop.rb
|
|
95
|
+
- lib/hostty/tui/input.rb
|
|
96
|
+
- lib/hostty/tui/layout.rb
|
|
97
|
+
- lib/hostty/tui/mouse_event.rb
|
|
98
|
+
- lib/hostty/tui/pane.rb
|
|
99
|
+
- lib/hostty/tui/pty.rb
|
|
100
|
+
- lib/hostty/tui/renderer.rb
|
|
101
|
+
- lib/hostty/tui/selection.rb
|
|
102
|
+
- lib/hostty/version.rb
|
|
103
|
+
- sig/hostty.rbs
|
|
104
|
+
homepage: https://github.com/bert-mccutchen/hostty
|
|
105
|
+
licenses:
|
|
106
|
+
- MIT
|
|
107
|
+
metadata:
|
|
108
|
+
homepage_uri: https://github.com/bert-mccutchen/hostty
|
|
109
|
+
source_code_uri: https://github.com/bert-mccutchen/hostty
|
|
110
|
+
changelog_uri: https://github.com/bert-mccutchen/hostty/releases
|
|
111
|
+
rubygems_mfa_required: 'true'
|
|
112
|
+
github_repo: ssh://github.com/bert-mccutchen/hostty
|
|
113
|
+
rdoc_options: []
|
|
114
|
+
require_paths:
|
|
115
|
+
- lib
|
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
118
|
+
- - ">="
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: 3.2.0
|
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - ">="
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
requirements: []
|
|
127
|
+
rubygems_version: 4.0.20
|
|
128
|
+
specification_version: 4
|
|
129
|
+
summary: Process manager that gives each process a local domain with NGINX.
|
|
130
|
+
test_files: []
|