ruby_jard 0.2.0 → 0.2.1
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/.rubocop.yml +4 -1
- data/CHANGELOG.md +18 -0
- data/CNAME +1 -0
- data/README.md +206 -33
- data/_config.yml +1 -0
- data/docs/_config.yml +8 -0
- data/docs/demo.png +0 -0
- data/docs/index.md +238 -0
- data/docs/logo.jpg +0 -0
- data/docs/screen-backtrace.png +0 -0
- data/docs/screen-repl.png +0 -0
- data/docs/screen-source.png +0 -0
- data/docs/screen-threads.png +0 -0
- data/docs/screen-variables.png +0 -0
- data/images/bg_hr.png +0 -0
- data/images/blacktocat.png +0 -0
- data/images/body-bg.jpg +0 -0
- data/images/download-button.png +0 -0
- data/images/github-button.png +0 -0
- data/images/header-bg.jpg +0 -0
- data/images/highlight-bg.jpg +0 -0
- data/images/icon_download.png +0 -0
- data/images/sidebar-bg.jpg +0 -0
- data/images/sprite_download.png +0 -0
- data/javascripts/main.js +1 -0
- data/lib/ruby_jard.rb +3 -18
- data/lib/ruby_jard/box_drawer.rb +68 -22
- data/lib/ruby_jard/color_scheme.rb +28 -0
- data/lib/ruby_jard/color_schemes.rb +26 -0
- data/lib/ruby_jard/color_schemes/256_color_scheme.rb +64 -0
- data/lib/ruby_jard/color_schemes/deep_space_color_scheme.rb +63 -0
- data/lib/ruby_jard/column.rb +12 -6
- data/lib/ruby_jard/commands/continue_command.rb +1 -0
- data/lib/ruby_jard/commands/list_command.rb +29 -0
- data/lib/ruby_jard/commands/next_command.rb +1 -0
- data/lib/ruby_jard/commands/step_command.rb +1 -0
- data/lib/ruby_jard/commands/step_out_command.rb +1 -0
- data/lib/ruby_jard/console.rb +102 -18
- data/lib/ruby_jard/control_flow.rb +9 -8
- data/lib/ruby_jard/decorators/color_decorator.rb +46 -57
- data/lib/ruby_jard/decorators/inspection_decorator.rb +76 -0
- data/lib/ruby_jard/decorators/loc_decorator.rb +83 -107
- data/lib/ruby_jard/decorators/source_decorator.rb +1 -1
- data/lib/ruby_jard/keys.rb +1 -0
- data/lib/ruby_jard/layout.rb +9 -99
- data/lib/ruby_jard/layout_calculator.rb +151 -0
- data/lib/ruby_jard/layouts/narrow_layout.rb +41 -0
- data/lib/ruby_jard/layouts/wide_layout.rb +17 -103
- data/lib/ruby_jard/repl_processor.rb +5 -1
- data/lib/ruby_jard/repl_proxy.rb +2 -1
- data/lib/ruby_jard/row.rb +5 -5
- data/lib/ruby_jard/row_renderer.rb +108 -0
- data/lib/ruby_jard/screen.rb +20 -115
- data/lib/ruby_jard/screen_drawer.rb +8 -75
- data/lib/ruby_jard/screen_manager.rb +78 -55
- data/lib/ruby_jard/screen_renderer.rb +138 -0
- data/lib/ruby_jard/screens/backtrace_screen.rb +67 -69
- data/lib/ruby_jard/screens/menu_screen.rb +43 -38
- data/lib/ruby_jard/screens/source_screen.rb +43 -27
- data/lib/ruby_jard/screens/threads_screen.rb +91 -39
- data/lib/ruby_jard/screens/variables_screen.rb +72 -56
- data/lib/ruby_jard/session.rb +16 -0
- data/lib/ruby_jard/span.rb +8 -6
- data/lib/ruby_jard/version.rb +1 -1
- data/ruby_jard.gemspec +4 -4
- data/stylesheets/github-light.css +130 -0
- data/stylesheets/normalize.css +424 -0
- data/stylesheets/print.css +228 -0
- data/stylesheets/stylesheet.css +245 -0
- metadata +52 -21
- data/lib/ruby_jard/templates/column_template.rb +0 -17
- data/lib/ruby_jard/templates/row_template.rb +0 -22
- data/lib/ruby_jard/templates/space_template.rb +0 -15
- data/lib/ruby_jard/templates/span_template.rb +0 -25
data/lib/ruby_jard/keys.rb
CHANGED
data/lib/ruby_jard/layout.rb
CHANGED
@@ -1,111 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/MethodLength
|
4
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
5
3
|
module RubyJard
|
6
4
|
##
|
7
|
-
#
|
8
|
-
# visibility, data size of each children screen.
|
9
|
-
# TODO: Right now, the sizes are fixed regardless of current screen data size.
|
5
|
+
# Data object to store calculated layout
|
10
6
|
class Layout
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@
|
7
|
+
attr_accessor :template, :box_width, :box_height, :box_x, :box_y, :width, :height, :x, :y
|
8
|
+
|
9
|
+
def initialize(template:, width: 0, height: 0, x: 0, y: 0, box_width:, box_height:, box_x:, box_y:)
|
10
|
+
@template = template
|
11
|
+
@box_width = box_width
|
12
|
+
@box_height = box_height
|
13
|
+
@box_x = box_x
|
14
|
+
@box_y = box_y
|
17
15
|
@width = width
|
18
16
|
@height = height
|
19
17
|
@x = x
|
20
18
|
@y = y
|
21
19
|
end
|
22
|
-
|
23
|
-
def calculate
|
24
|
-
screens = []
|
25
|
-
calculate_layout(screens, @layout, @width, @height, @x, @y)
|
26
|
-
screens
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def calculate_layout(screens, layout, width, height, x, y)
|
32
|
-
if layout.is_a?(RubyJard::Templates::ScreenTemplate)
|
33
|
-
screens << [layout, width, height, x, y]
|
34
|
-
else
|
35
|
-
total_height = 0
|
36
|
-
total_width = 0
|
37
|
-
overflow_width = 0
|
38
|
-
child_x = x
|
39
|
-
child_y = y
|
40
|
-
max_height = 0
|
41
|
-
|
42
|
-
layout.children.each_with_index do |child_layout, index|
|
43
|
-
child_height = calculate_child_height(child_layout, layout, height, index, total_height)
|
44
|
-
child_width = calculate_child_width(child_layout, layout, width, index, total_width)
|
45
|
-
|
46
|
-
calculate_layout(screens, child_layout, child_width, child_height, child_x, child_y)
|
47
|
-
|
48
|
-
overflow_width += child_width
|
49
|
-
max_height = child_height if max_height < child_height
|
50
|
-
# Overflow. Break to next line
|
51
|
-
if overflow_width >= width
|
52
|
-
child_y += max_height - 1
|
53
|
-
child_x = x
|
54
|
-
overflow_width = 0
|
55
|
-
max_height = 0
|
56
|
-
else
|
57
|
-
child_x += child_width - 1
|
58
|
-
end
|
59
|
-
|
60
|
-
total_width += child_width - 1
|
61
|
-
total_height += child_height - 1
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def calculate_child_height(child_layout, parent_layout, parent_height, index, total_height)
|
67
|
-
height =
|
68
|
-
if !child_layout.height.nil?
|
69
|
-
child_layout.height
|
70
|
-
elsif child_layout.height_ratio.nil?
|
71
|
-
parent_height
|
72
|
-
else
|
73
|
-
parent_height * child_layout.height_ratio / 100
|
74
|
-
end
|
75
|
-
|
76
|
-
unless child_layout.min_height.nil?
|
77
|
-
height = child_layout.min_height if height < child_layout.min_height
|
78
|
-
end
|
79
|
-
|
80
|
-
if parent_layout.fill_height && index == parent_layout.children.length - 1
|
81
|
-
height = parent_height - total_height if height < (parent_height - total_height)
|
82
|
-
end
|
83
|
-
|
84
|
-
height
|
85
|
-
end
|
86
|
-
|
87
|
-
def calculate_child_width(child_layout, parent_layout, parent_width, index, total_width)
|
88
|
-
width =
|
89
|
-
if !child_layout.width.nil?
|
90
|
-
child_layout.width
|
91
|
-
elsif child_layout.width_ratio.nil?
|
92
|
-
parent_width
|
93
|
-
else
|
94
|
-
parent_width * child_layout.width_ratio / 100
|
95
|
-
end
|
96
|
-
|
97
|
-
unless child_layout.min_width.nil?
|
98
|
-
width = child_layout.min_width if width < child_layout.min_width
|
99
|
-
end
|
100
|
-
|
101
|
-
if parent_layout.fill_width && index == parent_layout.children.length - 1
|
102
|
-
width = parent_width - total_width if width < (parent_width - total_width)
|
103
|
-
end
|
104
|
-
|
105
|
-
width
|
106
|
-
end
|
107
20
|
end
|
108
21
|
end
|
109
|
-
|
110
|
-
# rubocop:enable Metrics/MethodLength
|
111
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable Metrics/MethodLength
|
4
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
5
|
+
module RubyJard
|
6
|
+
##
|
7
|
+
# Layout calculator based on screen resolution to decide the height, width,
|
8
|
+
# visibility, data size of each children screen.
|
9
|
+
# TODO: Right now, the sizes are fixed regardless of current screen data size.
|
10
|
+
class LayoutCalculator
|
11
|
+
def self.calculate(**args)
|
12
|
+
new(**args).calculate
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(layout_template:, width: 0, height: 0, x: 0, y: 0)
|
16
|
+
@layout_template = layout_template
|
17
|
+
@width = width
|
18
|
+
@height = height
|
19
|
+
@x = x
|
20
|
+
@y = y
|
21
|
+
@layouts = []
|
22
|
+
end
|
23
|
+
|
24
|
+
def calculate
|
25
|
+
@layouts = []
|
26
|
+
calculate_layout(@layout_template, @width, @height, @x, @y)
|
27
|
+
@layouts
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def calculate_layout(template, width, height, x, y)
|
33
|
+
if template.is_a?(RubyJard::Templates::ScreenTemplate)
|
34
|
+
layout = RubyJard::Layout.new(
|
35
|
+
template: template,
|
36
|
+
width: width - 2, height: height - 2, x: x + 1, y: y + 1,
|
37
|
+
box_width: width, box_height: height, box_x: x, box_y: y
|
38
|
+
)
|
39
|
+
adjust_layout_overlap(layout)
|
40
|
+
@layouts << layout
|
41
|
+
else
|
42
|
+
overflow_width = 0
|
43
|
+
child_x = x
|
44
|
+
child_y = y
|
45
|
+
max_height = 0
|
46
|
+
|
47
|
+
lines = [[]]
|
48
|
+
template.children.each do |child_template|
|
49
|
+
child_height = calculate_child_height(child_template, height)
|
50
|
+
child_width = calculate_child_width(child_template, width)
|
51
|
+
|
52
|
+
overflow_width += child_width
|
53
|
+
# Overflow. Break to next line
|
54
|
+
if overflow_width > width
|
55
|
+
child_y += max_height
|
56
|
+
child_x = x
|
57
|
+
overflow_width = 0
|
58
|
+
max_height = child_height
|
59
|
+
lines << []
|
60
|
+
else
|
61
|
+
max_height = child_height if max_height < child_height
|
62
|
+
end
|
63
|
+
|
64
|
+
lines.last << [child_template, child_width, child_height, child_x, child_y]
|
65
|
+
child_x += child_width
|
66
|
+
end
|
67
|
+
|
68
|
+
stretch_lines(template, width, height, lines)
|
69
|
+
lines.each do |line|
|
70
|
+
line.each do |child_template, child_width, child_height, xx, yy|
|
71
|
+
calculate_layout(child_template, child_width, child_height, xx, yy)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def adjust_layout_overlap(layout)
|
78
|
+
if layout.box_x != 0
|
79
|
+
layout.width += 1
|
80
|
+
layout.x -= 1
|
81
|
+
layout.box_width += 1
|
82
|
+
layout.box_x -= 1
|
83
|
+
end
|
84
|
+
|
85
|
+
if layout.box_y != 0
|
86
|
+
layout.height += 1
|
87
|
+
layout.y -= 1
|
88
|
+
layout.box_height += 1
|
89
|
+
layout.box_y -= 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def stretch_lines(parent_template, parent_width, parent_height, lines)
|
94
|
+
total_height = 0
|
95
|
+
lines.each_with_index do |line, line_index|
|
96
|
+
desired_height =
|
97
|
+
if line_index == lines.length - 1
|
98
|
+
parent_height - total_height
|
99
|
+
else
|
100
|
+
line.map { |_child_template, _child_width, child_height, _x, _y| child_height }.max
|
101
|
+
end
|
102
|
+
|
103
|
+
total_width = 0
|
104
|
+
line.map!.with_index do |(child_template, child_width, child_height, x, y), index|
|
105
|
+
child_height = desired_height if parent_template.fill_height
|
106
|
+
child_width = parent_width - total_width if parent_template.fill_width && index == line.length - 1
|
107
|
+
total_width += child_width
|
108
|
+
[child_template, child_width, child_height, x, y]
|
109
|
+
end
|
110
|
+
total_height += desired_height
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def calculate_child_height(child_template, parent_height)
|
115
|
+
height =
|
116
|
+
if !child_template.height.nil?
|
117
|
+
child_template.height
|
118
|
+
elsif child_template.height_ratio.nil?
|
119
|
+
parent_height
|
120
|
+
else
|
121
|
+
parent_height * child_template.height_ratio / 100
|
122
|
+
end
|
123
|
+
|
124
|
+
unless child_template.min_height.nil?
|
125
|
+
height = child_template.min_height if height < child_template.min_height
|
126
|
+
end
|
127
|
+
|
128
|
+
height
|
129
|
+
end
|
130
|
+
|
131
|
+
def calculate_child_width(child_template, parent_width)
|
132
|
+
width =
|
133
|
+
if !child_template.width.nil?
|
134
|
+
child_template.width
|
135
|
+
elsif child_template.width_ratio.nil?
|
136
|
+
parent_width
|
137
|
+
else
|
138
|
+
parent_width * child_template.width_ratio / 100
|
139
|
+
end
|
140
|
+
|
141
|
+
unless child_template.min_width.nil?
|
142
|
+
width = child_template.min_width if width < child_template.min_width
|
143
|
+
end
|
144
|
+
|
145
|
+
width
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# rubocop:enable Metrics/MethodLength
|
151
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyJard
|
4
|
+
module Layouts
|
5
|
+
NarrowLayout = RubyJard::Templates::LayoutTemplate.new(
|
6
|
+
min_width: 60,
|
7
|
+
min_height: 10,
|
8
|
+
children: [
|
9
|
+
RubyJard::Templates::LayoutTemplate.new(
|
10
|
+
height_ratio: 80,
|
11
|
+
width_ratio: 100,
|
12
|
+
min_height: 7,
|
13
|
+
fill_height: true,
|
14
|
+
children: [
|
15
|
+
RubyJard::Templates::ScreenTemplate.new(
|
16
|
+
screen: :source,
|
17
|
+
height_ratio: 60
|
18
|
+
),
|
19
|
+
RubyJard::Templates::LayoutTemplate.new(
|
20
|
+
height_ratio: 40,
|
21
|
+
width_ratio: 100,
|
22
|
+
fill_height: true,
|
23
|
+
children: [
|
24
|
+
RubyJard::Templates::ScreenTemplate.new(
|
25
|
+
screen: :variables,
|
26
|
+
width_ratio: 100,
|
27
|
+
height_ratio: 100,
|
28
|
+
min_height: 3
|
29
|
+
)
|
30
|
+
]
|
31
|
+
)
|
32
|
+
]
|
33
|
+
),
|
34
|
+
RubyJard::Templates::ScreenTemplate.new(
|
35
|
+
height: 2,
|
36
|
+
screen: :menu
|
37
|
+
)
|
38
|
+
]
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
@@ -6,130 +6,44 @@ module RubyJard
|
|
6
6
|
min_width: 120,
|
7
7
|
min_height: 10,
|
8
8
|
fill_width: true,
|
9
|
-
fill_height: false,
|
10
9
|
children: [
|
11
10
|
RubyJard::Templates::LayoutTemplate.new(
|
12
|
-
height_ratio:
|
11
|
+
height_ratio: 80,
|
12
|
+
width_ratio: 50,
|
13
13
|
min_height: 7,
|
14
|
-
|
14
|
+
fill_height: true,
|
15
15
|
children: [
|
16
16
|
RubyJard::Templates::ScreenTemplate.new(
|
17
17
|
screen: :source,
|
18
|
-
|
19
|
-
row_template: RubyJard::Templates::RowTemplate.new(
|
20
|
-
columns: [
|
21
|
-
RubyJard::Templates::ColumnTemplate.new(
|
22
|
-
margin_right: 1,
|
23
|
-
spans: [
|
24
|
-
RubyJard::Templates::SpanTemplate.new(:mark, margin_right: 1),
|
25
|
-
RubyJard::Templates::SpanTemplate.new(:lineno)
|
26
|
-
]
|
27
|
-
),
|
28
|
-
RubyJard::Templates::ColumnTemplate.new(
|
29
|
-
spans: [
|
30
|
-
RubyJard::Templates::SpanTemplate.new(:code)
|
31
|
-
]
|
32
|
-
)
|
33
|
-
]
|
34
|
-
)
|
18
|
+
height_ratio: 60
|
35
19
|
),
|
36
|
-
RubyJard::Templates::
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
screen: :variables,
|
42
|
-
width_ratio: 100,
|
43
|
-
height_ratio: 100,
|
44
|
-
min_height: 3,
|
45
|
-
row_template: RubyJard::Templates::RowTemplate.new(
|
46
|
-
line_limit: 3,
|
47
|
-
columns: [
|
48
|
-
RubyJard::Templates::ColumnTemplate.new(
|
49
|
-
spans: [
|
50
|
-
RubyJard::Templates::SpanTemplate.new(:inline, margin_right: 1)
|
51
|
-
]
|
52
|
-
),
|
53
|
-
RubyJard::Templates::ColumnTemplate.new(
|
54
|
-
margin_right: 1,
|
55
|
-
spans: [
|
56
|
-
RubyJard::Templates::SpanTemplate.new(:type)
|
57
|
-
]
|
58
|
-
),
|
59
|
-
RubyJard::Templates::ColumnTemplate.new(
|
60
|
-
spans: [
|
61
|
-
RubyJard::Templates::SpanTemplate.new(:name, margin_right: 1),
|
62
|
-
RubyJard::Templates::SpanTemplate.new(:size, margin_right: 1),
|
63
|
-
RubyJard::Templates::SpanTemplate.new(:indicator, margin_right: 1),
|
64
|
-
RubyJard::Templates::SpanTemplate.new(:inspection)
|
65
|
-
]
|
66
|
-
)
|
67
|
-
]
|
68
|
-
)
|
69
|
-
)
|
70
|
-
]
|
20
|
+
RubyJard::Templates::ScreenTemplate.new(
|
21
|
+
screen: :variables,
|
22
|
+
width_ratio: 100,
|
23
|
+
height_ratio: 40,
|
24
|
+
min_height: 3
|
71
25
|
)
|
72
26
|
]
|
73
27
|
),
|
74
28
|
RubyJard::Templates::LayoutTemplate.new(
|
75
|
-
height_ratio:
|
76
|
-
|
77
|
-
|
29
|
+
height_ratio: 80,
|
30
|
+
width_ratio: 50,
|
31
|
+
fill_height: true,
|
78
32
|
children: [
|
79
33
|
RubyJard::Templates::ScreenTemplate.new(
|
80
34
|
screen: :backtrace,
|
81
|
-
|
82
|
-
|
83
|
-
columns: [
|
84
|
-
RubyJard::Templates::ColumnTemplate.new(
|
85
|
-
margin_right: 1,
|
86
|
-
spans: [
|
87
|
-
RubyJard::Templates::SpanTemplate.new(:mark, margin_right: 1),
|
88
|
-
RubyJard::Templates::SpanTemplate.new(:frame_id)
|
89
|
-
]
|
90
|
-
),
|
91
|
-
RubyJard::Templates::ColumnTemplate.new(
|
92
|
-
spans: [
|
93
|
-
RubyJard::Templates::SpanTemplate.new(:klass_label, margin_right: 1),
|
94
|
-
RubyJard::Templates::SpanTemplate.new(:label_preposition, margin_right: 1),
|
95
|
-
RubyJard::Templates::SpanTemplate.new(:method_label, margin_right: 1),
|
96
|
-
RubyJard::Templates::SpanTemplate.new(:path_preposition, margin_right: 1),
|
97
|
-
RubyJard::Templates::SpanTemplate.new(:path)
|
98
|
-
]
|
99
|
-
)
|
100
|
-
]
|
101
|
-
)
|
35
|
+
height_ratio: 50,
|
36
|
+
fill_height: true
|
102
37
|
),
|
103
38
|
RubyJard::Templates::ScreenTemplate.new(
|
104
39
|
screen: :threads,
|
105
|
-
|
106
|
-
|
107
|
-
columns: [
|
108
|
-
RubyJard::Templates::ColumnTemplate.new(
|
109
|
-
margin_right: 1,
|
110
|
-
spans: [
|
111
|
-
RubyJard::Templates::SpanTemplate.new(:mark, margin_right: 1),
|
112
|
-
RubyJard::Templates::SpanTemplate.new(:thread_id)
|
113
|
-
]
|
114
|
-
),
|
115
|
-
RubyJard::Templates::ColumnTemplate.new(
|
116
|
-
margin_right: 1,
|
117
|
-
spans: [
|
118
|
-
RubyJard::Templates::SpanTemplate.new(:thread_status)
|
119
|
-
]
|
120
|
-
),
|
121
|
-
RubyJard::Templates::ColumnTemplate.new(
|
122
|
-
spans: [
|
123
|
-
RubyJard::Templates::SpanTemplate.new(:thread_name)
|
124
|
-
]
|
125
|
-
)
|
126
|
-
]
|
127
|
-
)
|
40
|
+
height_ratio: 50,
|
41
|
+
fill_height: true
|
128
42
|
)
|
129
43
|
]
|
130
44
|
),
|
131
45
|
RubyJard::Templates::ScreenTemplate.new(
|
132
|
-
height:
|
46
|
+
height: 2,
|
133
47
|
screen: :menu
|
134
48
|
)
|
135
49
|
]
|