ruby_jard 0.1.0 → 0.3.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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. data/.github/workflows/documentation.yml +65 -0
  6. data/.github/workflows/rspec.yml +96 -0
  7. data/.gitignore +1 -0
  8. data/.rubocop.yml +90 -2
  9. data/CHANGELOG.md +112 -0
  10. data/Gemfile +14 -4
  11. data/README.md +95 -3
  12. data/benchmark/path_filter_bench.rb +58 -0
  13. data/bin/console +1 -2
  14. data/lib/ruby_jard.rb +68 -32
  15. data/lib/ruby_jard/box_drawer.rb +175 -0
  16. data/lib/ruby_jard/color_scheme.rb +28 -0
  17. data/lib/ruby_jard/color_schemes.rb +54 -0
  18. data/lib/ruby_jard/color_schemes/256_color_scheme.rb +50 -0
  19. data/lib/ruby_jard/color_schemes/256_light_color_scheme.rb +50 -0
  20. data/lib/ruby_jard/color_schemes/deep_space_color_scheme.rb +49 -0
  21. data/lib/ruby_jard/color_schemes/gruvbox_color_scheme.rb +48 -0
  22. data/lib/ruby_jard/color_schemes/one_half_dark_color_scheme.rb +47 -0
  23. data/lib/ruby_jard/color_schemes/one_half_light_color_scheme.rb +49 -0
  24. data/lib/ruby_jard/column.rb +26 -0
  25. data/lib/ruby_jard/commands/color_helpers.rb +32 -0
  26. data/lib/ruby_jard/commands/continue_command.rb +4 -9
  27. data/lib/ruby_jard/commands/down_command.rb +9 -8
  28. data/lib/ruby_jard/commands/exit_command.rb +27 -0
  29. data/lib/ruby_jard/commands/frame_command.rb +13 -11
  30. data/lib/ruby_jard/commands/jard/color_scheme_command.rb +74 -0
  31. data/lib/ruby_jard/commands/jard/filter_command.rb +136 -0
  32. data/lib/ruby_jard/commands/jard/hide_command.rb +40 -0
  33. data/lib/ruby_jard/commands/jard/output_command.rb +36 -0
  34. data/lib/ruby_jard/commands/jard/show_command.rb +41 -0
  35. data/lib/ruby_jard/commands/jard_command.rb +52 -0
  36. data/lib/ruby_jard/commands/list_command.rb +31 -0
  37. data/lib/ruby_jard/commands/next_command.rb +11 -8
  38. data/lib/ruby_jard/commands/step_command.rb +11 -8
  39. data/lib/ruby_jard/commands/step_out_command.rb +34 -0
  40. data/lib/ruby_jard/commands/up_command.rb +10 -8
  41. data/lib/ruby_jard/commands/validation_helpers.rb +50 -0
  42. data/lib/ruby_jard/config.rb +61 -0
  43. data/lib/ruby_jard/console.rb +158 -0
  44. data/lib/ruby_jard/control_flow.rb +73 -0
  45. data/lib/ruby_jard/decorators/array_decorator.rb +79 -0
  46. data/lib/ruby_jard/decorators/attributes_decorator.rb +172 -0
  47. data/lib/ruby_jard/decorators/color_decorator.rb +80 -0
  48. data/lib/ruby_jard/decorators/hash_decorator.rb +74 -0
  49. data/lib/ruby_jard/decorators/inspection_decorator.rb +109 -0
  50. data/lib/ruby_jard/decorators/loc_decorator.rb +108 -119
  51. data/lib/ruby_jard/decorators/object_decorator.rb +122 -0
  52. data/lib/ruby_jard/decorators/path_decorator.rb +56 -60
  53. data/lib/ruby_jard/decorators/rails_decorator.rb +194 -0
  54. data/lib/ruby_jard/decorators/source_decorator.rb +3 -1
  55. data/lib/ruby_jard/decorators/string_decorator.rb +41 -0
  56. data/lib/ruby_jard/decorators/struct_decorator.rb +79 -0
  57. data/lib/ruby_jard/frame.rb +68 -0
  58. data/lib/ruby_jard/key_binding.rb +14 -0
  59. data/lib/ruby_jard/key_bindings.rb +96 -0
  60. data/lib/ruby_jard/keys.rb +48 -0
  61. data/lib/ruby_jard/layout.rb +17 -88
  62. data/lib/ruby_jard/layout_calculator.rb +168 -0
  63. data/lib/ruby_jard/layout_picker.rb +34 -0
  64. data/lib/ruby_jard/layouts.rb +52 -0
  65. data/lib/ruby_jard/layouts/narrow_horizontal_layout.rb +32 -0
  66. data/lib/ruby_jard/layouts/narrow_vertical_layout.rb +32 -0
  67. data/lib/ruby_jard/layouts/tiny_layout.rb +29 -0
  68. data/lib/ruby_jard/layouts/wide_layout.rb +50 -0
  69. data/lib/ruby_jard/pager.rb +112 -0
  70. data/lib/ruby_jard/path_classifier.rb +133 -0
  71. data/lib/ruby_jard/path_filter.rb +125 -0
  72. data/lib/ruby_jard/reflection.rb +97 -0
  73. data/lib/ruby_jard/repl_processor.rb +151 -89
  74. data/lib/ruby_jard/repl_proxy.rb +337 -0
  75. data/lib/ruby_jard/row.rb +31 -0
  76. data/lib/ruby_jard/row_renderer.rb +119 -0
  77. data/lib/ruby_jard/screen.rb +14 -41
  78. data/lib/ruby_jard/screen_adjuster.rb +104 -0
  79. data/lib/ruby_jard/screen_drawer.rb +25 -0
  80. data/lib/ruby_jard/screen_manager.rb +167 -82
  81. data/lib/ruby_jard/screen_renderer.rb +152 -0
  82. data/lib/ruby_jard/screens.rb +31 -12
  83. data/lib/ruby_jard/screens/backtrace_screen.rb +118 -116
  84. data/lib/ruby_jard/screens/menu_screen.rb +73 -45
  85. data/lib/ruby_jard/screens/source_screen.rb +86 -106
  86. data/lib/ruby_jard/screens/threads_screen.rb +103 -78
  87. data/lib/ruby_jard/screens/variables_screen.rb +224 -142
  88. data/lib/ruby_jard/session.rb +151 -16
  89. data/lib/ruby_jard/span.rb +23 -0
  90. data/lib/ruby_jard/templates/layout_template.rb +35 -0
  91. data/lib/ruby_jard/templates/screen_template.rb +34 -0
  92. data/lib/ruby_jard/thread_info.rb +69 -0
  93. data/lib/ruby_jard/version.rb +1 -1
  94. data/ruby_jard.gemspec +7 -8
  95. metadata +84 -50
  96. data/.travis.yml +0 -6
  97. data/lib/ruby_jard/commands/finish_command.rb +0 -31
  98. data/lib/ruby_jard/decorators/text_decorator.rb +0 -61
  99. data/lib/ruby_jard/layout_template.rb +0 -101
  100. data/lib/ruby_jard/screens/breakpoints_screen.rb +0 -23
  101. data/lib/ruby_jard/screens/empty_screen.rb +0 -13
  102. data/lib/ruby_jard/screens/expressions_sreen.rb +0 -22
@@ -1,62 +1,90 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyJard
4
- module Screens
4
+ class Screens
5
+ ##
6
+ # Display key binding guidelines and shortcuts.
5
7
  class MenuScreen < RubyJard::Screen
6
- def draw
7
- @output.print TTY::Cursor.move_to(@col, @row)
8
- frame = TTY::Box.frame(
9
- **default_frame_styles.merge(
10
- top: @row, left: @col, width: @layout.width, height: @layout.height,
11
- border: {
12
- left: false,
13
- top: :line,
14
- right: false,
15
- bottom: false
16
- },
17
- style: {
18
- fg: :white
19
- }
20
- )
21
- )
22
- @output.print frame
23
-
24
- margin = 0
25
- left_menu = generate_left_menu
26
- left_menu.each do |item|
27
- @output.print TTY::Cursor.move_to(@col + 1 + margin, @row + 1)
28
- @output.print item.content
29
- margin += item.length + 3
30
- end
8
+ def initialize(*args)
9
+ super(*args)
10
+ @filter = RubyJard.config.filter
11
+ @filter_included = RubyJard.config.filter_included
12
+ @filter_excluded = RubyJard.config.filter_excluded
13
+ @selected = 0
14
+ end
31
15
 
32
- margin = 0
33
- right_menu = generate_right_menu
34
- right_menu.reverse.each do |item|
35
- @output.print TTY::Cursor.move_to(@col + @layout.width - margin - item.length - 1, @row + 1)
36
- @output.print item.content
37
- margin += item.length + 3
38
- end
16
+ def build
17
+ left_spans = generate_left_spans
18
+ right_spans = generate_right_spans
19
+ @rows = [RubyJard::Row.new(
20
+ line_limit: 1,
21
+ columns: [
22
+ RubyJard::Column.new(
23
+ word_wrap: RubyJard::Column::WORD_WRAP_BREAK_WORD,
24
+ spans: [
25
+ left_spans,
26
+ align(left_spans, right_spans),
27
+ right_spans
28
+ ].flatten
29
+ )
30
+ ]
31
+ )]
39
32
  end
40
33
 
41
34
  private
42
35
 
43
- def generate_left_menu
44
- [
45
- decorate_text.with_highlight(true).text('Debug console (F5)', :bright_yellow),
46
- decorate_text.text('Program output (F6)', :white)
47
- ]
36
+ def generate_left_spans
37
+ filter_mode_span = RubyJard::Span.new(
38
+ content: "Filter (F2): #{@filter.to_s.gsub(/_/, ' ').capitalize}",
39
+ styles: :text_special
40
+ )
41
+ filter_details =
42
+ @filter_included.map { |f| "+#{f}" } +
43
+ @filter_excluded.map { |f| "-#{f}" }
44
+ if filter_details.empty?
45
+ [filter_mode_span]
46
+ else
47
+ filter_exceprt = filter_details.first(3).join(' ')
48
+ filter_more = filter_details.length > 3 ? " (#{filter_details.length - 3} more...)" : nil
49
+ filter_details_span = RubyJard::Span.new(
50
+ content: "#{filter_exceprt}#{filter_more}",
51
+ styles: :text_primary,
52
+ margin_left: 1
53
+ )
54
+ [
55
+ filter_mode_span,
56
+ filter_details_span
57
+ ]
58
+ end
48
59
  end
49
60
 
50
- def generate_right_menu
61
+ def generate_right_spans
51
62
  [
52
- decorate_text.text('Step (F7)', :white),
53
- decorate_text.text('Next (F8)', :white),
54
- decorate_text.text('Step out (Shift+F8)', :white),
55
- decorate_text.text('Continue (F9)', :white)
56
- ]
63
+ 'Step (F7)',
64
+ 'Step Out (Shift+F7)',
65
+ 'Next (F8)',
66
+ 'Continue (F9)'
67
+ ].map do |menu_item|
68
+ RubyJard::Span.new(
69
+ content: menu_item,
70
+ margin_left: 3,
71
+ styles: :text_primary
72
+ )
73
+ end
74
+ end
75
+
76
+ def align(left_spans, right_spans)
77
+ alignment =
78
+ @layout.width -
79
+ right_spans.map(&:content_length).sum -
80
+ left_spans.map(&:content_length).sum
81
+ RubyJard::Span.new(
82
+ content: ' ' * (alignment < 0 ? 0 : alignment),
83
+ styles: :background
84
+ )
57
85
  end
58
86
  end
59
87
  end
60
88
  end
61
89
 
62
- RubyJard::Screens.add_screen(:menu, RubyJard::Screens::MenuScreen)
90
+ RubyJard::Screens.add_screen('menu', RubyJard::Screens::MenuScreen)
@@ -1,133 +1,113 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyJard
4
- module Screens
4
+ class Screens
5
+ ##
6
+ # Display source code of current stopping line and surrounding lines
5
7
  class SourceScreen < RubyJard::Screen
6
- def draw
7
- @output.print TTY::Box.frame(
8
- **default_frame_styles.merge(
9
- top: @row, left: @col, width: @layout.width, height: @layout.height
10
- )
11
- )
12
-
13
- @output.print TTY::Cursor.move_to(@col + 2, @row)
14
- @output.print decorate_text
15
- .with_highlight(true)
16
- .text(' Source', :bright_yellow)
17
- .text(' (', :bright_yellow)
18
- .text(file_path, :bright_yellow)
19
- .text(') ', :bright_yellow)
20
- .content
21
-
22
- decorate_codes.each_with_index do |decorated_loc, index|
23
- @output.print TTY::Cursor.move_to(@col + 1, @row + 1 + index)
24
- @output.print decorated_loc.content
8
+ def initialize(*args)
9
+ super
10
+ @frame_file = @session.current_frame&.frame_file
11
+ @frame_line = @session.current_frame&.frame_line
12
+
13
+ if !@frame_file.nil? && !@frame_line.nil?
14
+ @path_decorator = RubyJard::Decorators::PathDecorator.new
15
+ @loc_decorator = RubyJard::Decorators::LocDecorator.new
16
+ @source_decorator = RubyJard::Decorators::SourceDecorator.new(@frame_file, @frame_line, @layout.height)
25
17
  end
26
- end
27
-
28
- private
29
18
 
30
- def data_size
31
- @layout.height - 1
19
+ @selected = 0
32
20
  end
33
21
 
34
- def decorate_codes
35
- return [] if RubyJard.current_session.frame.nil?
22
+ def title
23
+ return 'Source' if @frame_file.nil? || @frame_line.nil?
36
24
 
37
- decorated_source = decorate_source(current_file, current_line, data_size)
38
-
39
- lineno_padding = decorated_source.window_end.to_s.length
40
-
41
- decorated_source.codes.map.with_index do |loc, index|
42
- lineno = decorated_source.window_start + index
43
- decorated_loc = decorate_loc(loc, current_line == lineno)
44
-
45
- if current_line == lineno
46
- decorate_text
47
- .with_highlight(true)
48
- .text('→ ')
49
- .text(lineno.to_s.ljust(lineno_padding), :bright_yellow)
50
- .text(' ')
51
- .text(decorated_loc.loc)
52
- .text(inline_variables(decorated_loc.tokens))
53
- else
54
- decorate_text
55
- .with_highlight(false)
56
- .text(' ')
57
- .text(lineno.to_s.ljust(lineno_padding), :white)
58
- .text(' ')
59
- .text(decorated_loc.loc)
60
- end
61
- end
25
+ _, path_label = @path_decorator.decorate(@frame_file, @frame_line)
26
+ ['Source', path_label]
62
27
  end
63
28
 
64
- def file_path
65
- return '' if RubyJard.current_session.frame.nil?
66
-
67
- decorated_path = decorate_path(current_file, current_line)
68
- if decorated_path.gem?
69
- "#{decorated_path.gem}: #{decorated_path.path}:#{decorated_path.lineno}"
70
- else
71
- "#{decorated_path.path}:#{decorated_path.lineno}"
29
+ def build
30
+ return 'Source' if @frame_file.nil? || @frame_line.nil?
31
+
32
+ # TODO: screen now supports window.
33
+ codes = @source_decorator.codes
34
+ @rows = codes.map.with_index do |loc, index|
35
+ lineno = @source_decorator.window_start + index
36
+ RubyJard::Row.new(
37
+ line_limit: 3,
38
+ columns: [
39
+ RubyJard::Column.new(
40
+ spans: [
41
+ span_mark(lineno),
42
+ span_lineno(lineno)
43
+ ]
44
+ ),
45
+ RubyJard::Column.new(
46
+ word_wrap: RubyJard::Column::WORD_WRAP_BREAK_WORD,
47
+ spans: loc_spans(loc)
48
+ )
49
+ ]
50
+ )
72
51
  end
73
52
  end
74
53
 
75
- def current_binding
76
- RubyJard.current_session.frame._binding
77
- end
54
+ private
78
55
 
79
- def current_frame_scope
80
- RubyJard.current_session.backtrace[RubyJard.current_session.frame.pos][1]
56
+ def handle_anonymous_evaluation
57
+ @rows = [
58
+ RubyJard::Row.new(
59
+ line_limit: 3,
60
+ columns: [
61
+ RubyJard::Column.new(
62
+ spans: [
63
+ RubyJard::Span.new(
64
+ content: 'This section is anonymous!',
65
+ styles: :normal_token
66
+ )
67
+ ]
68
+ )
69
+ ]
70
+ ),
71
+ RubyJard::Row.new(
72
+ line_limit: 3,
73
+ columns: [
74
+ RubyJard::Column.new(
75
+ spans: [
76
+ RubyJard::Span.new(
77
+ content: 'Maybe it is dynamically evaluated, or called via ruby-e, without file information.',
78
+ styles: :source_lineno
79
+ )
80
+ ]
81
+ )
82
+ ]
83
+ )
84
+ ]
81
85
  end
82
86
 
83
- def current_file
84
- RubyJard.current_session.frame.file
87
+ def span_mark(lineno)
88
+ RubyJard::Span.new(
89
+ margin_right: 1,
90
+ content: @frame_line == lineno ? '⮕' : ' ',
91
+ styles: :text_selected
92
+ )
85
93
  end
86
94
 
87
- def current_line
88
- RubyJard.current_session.frame.line
95
+ def span_lineno(lineno)
96
+ padded_lineno = lineno.to_s.rjust(@source_decorator.window_end.to_s.length)
97
+ RubyJard::Span.new(
98
+ content: padded_lineno,
99
+ styles: @frame_line == lineno ? :text_selected : :text_dim
100
+ )
89
101
  end
90
102
 
91
- def inline_variables(tokens)
92
- variables = {}
93
- local_variables = current_binding.local_variables
94
- instance_variables = current_frame_scope.instance_variables
95
-
96
- tokens.each_slice(2).each do |token, kind|
97
- token = token.to_sym
98
-
99
- if kind == :ident && local_variables.include?(token)
100
- var = current_binding.local_variable_get(token)
101
- elsif kind == :instance_variable && instance_variables.include?(token)
102
- var = current_frame_scope.instance_variable_get(token)
103
- else
104
- next
105
- end
106
-
107
- next if variables.key?(token)
108
-
109
- var_inspect = var.inspect
110
- # TODO: dynamic fill the rest of the line instead
111
- variables[token] = var_inspect if var_inspect.length < 30
112
- end
113
-
114
- return '' if variables.empty?
115
-
116
- variables_text = decorate_text.with_highlight(false).text(' #→ ', :white)
117
- variables.to_a.each_with_index do |(var_name, var_inspect), index|
118
- variables_text
119
- .with_highlight(false)
120
- .text(var_name.to_s, :white)
121
- .text('=', :white)
122
- .text(var_inspect, :white)
123
-
124
- variables_text.with_highlight(false).text(', ', :white) if index != variables.length - 1
125
- end
103
+ def loc_spans(loc)
104
+ return [] if @frame_file.nil?
126
105
 
127
- variables_text
106
+ spans, _tokens = @loc_decorator.decorate(loc, @frame_file)
107
+ spans
128
108
  end
129
109
  end
130
110
  end
131
111
  end
132
112
 
133
- RubyJard::Screens.add_screen(:source, RubyJard::Screens::SourceScreen)
113
+ RubyJard::Screens.add_screen('source', RubyJard::Screens::SourceScreen)
@@ -1,68 +1,120 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyJard
4
- module Screens
4
+ class Screens
5
+ ##
6
+ # Display all current alive threads, excluding internal threads
5
7
  class ThreadsScreen < RubyJard::Screen
6
- def draw
7
- @output.print TTY::Box.frame(
8
- **default_frame_styles.merge(
9
- top: @row, left: @col, width: @layout.width, height: @layout.height
10
- )
11
- )
8
+ def initialize(*args)
9
+ super
10
+ @current_frame_location = @session.current_frame&.frame_location
11
+ @current_thread = @session.current_thread
12
+ @threads = @session.threads
12
13
 
13
- decorated_threads = decorate_threads
14
+ @selected = @threads.index { |c| current_thread?(c) }
15
+ @path_decorator = RubyJard::Decorators::PathDecorator.new
16
+ end
14
17
 
15
- @output.print TTY::Cursor.move_to(@col + 1, @row)
16
- @output.print decorate_text
17
- .with_highlight(true)
18
- .text(" Threads (#{RubyJard.current_session.contexts.length}) ", :bright_yellow)
19
- .content
18
+ def title
19
+ ['Threads', "#{@threads.length} threads"]
20
+ end
20
21
 
21
- decorated_threads.each_with_index do |thread, index|
22
- @output.print TTY::Cursor.move_to(@col + 1, @row + index + 1)
23
- @output.print thread.content
22
+ def build
23
+ threads = sort_threads(@threads)
24
+ @rows = threads.map do |thread|
25
+ RubyJard::Row.new(
26
+ line_limit: 2,
27
+ columns: [
28
+ RubyJard::Column.new(
29
+ spans: [
30
+ span_mark(thread),
31
+ span_thread_label(thread)
32
+ ]
33
+ ),
34
+ RubyJard::Column.new(
35
+ spans: [
36
+ span_thread_status(thread)
37
+ ]
38
+ ),
39
+ RubyJard::Column.new(
40
+ spans: [
41
+ span_thread_name(thread),
42
+ span_thread_location(thread)
43
+ ]
44
+ )
45
+ ]
46
+ )
24
47
  end
25
48
  end
26
49
 
27
50
  private
28
51
 
29
- def data_size
30
- @layout.height - 1
52
+ def span_mark(thread)
53
+ RubyJard::Span.new(
54
+ margin_right: 1,
55
+ content: thread.status == 'run' ? '▸' : '•',
56
+ styles: thread_status_style(thread)
57
+ )
31
58
  end
32
59
 
33
- def decorate_threads
34
- contexts = sort_contexts(RubyJard.current_session.contexts)
35
- num_padding = contexts.length.to_s.length
36
- contexts.first(data_size).map do |context|
37
- decorate_text
38
- .with_highlight(current_thread?(context))
39
- .text(current_thread?(context) ? '→ ' : ' ', :bright_white)
40
- .text(context_color(context, "T#{context.thread.object_id}"))
41
- .with_highlight(false)
42
- .text(" (#{context.thread.status}) ", :white)
43
- .with_highlight(current_thread?(context))
44
- .text(thread_name(context), :bright_white)
45
- end
60
+ def span_thread_label(thread)
61
+ RubyJard::Span.new(
62
+ content: "Thread #{thread.label}",
63
+ styles: :text_highlighted
64
+ )
65
+ end
66
+
67
+ def span_thread_status(thread)
68
+ RubyJard::Span.new(
69
+ content: "(#{thread.status})",
70
+ styles: thread_status_style(thread)
71
+ )
46
72
  end
47
73
 
48
- def sort_contexts(contexts)
49
- # Sort: current context first
50
- # Sort: not debug context first
51
- # Sort: not suspended context first
74
+ def span_thread_name(thread)
75
+ RubyJard::Span.new(
76
+ margin_right: 1,
77
+ content: thread.name.nil? ? 'untitled' : thread.name,
78
+ styles: :text_primary
79
+ )
80
+ end
81
+
82
+ def span_thread_location(thread)
83
+ path_label, =
84
+ if current_thread?(thread)
85
+ @path_decorator.decorate(
86
+ @current_frame_location.path,
87
+ @current_frame_location.lineno
88
+ )
89
+ else
90
+ @path_decorator.decorate(
91
+ thread.backtrace_locations[1]&.path,
92
+ thread.backtrace_locations[1]&.lineno
93
+ )
94
+ end
95
+
96
+ RubyJard::Span.new(
97
+ content: path_label,
98
+ styles: :text_primary
99
+ )
100
+ end
101
+
102
+ def sort_threads(threads)
103
+ # Sort: current thread first
104
+ # Sort: not debug thread first
105
+ # Sort: not suspended thread first
52
106
  # Sort: sort by thread num
53
- contexts.sort do |a, b|
107
+ threads.sort do |a, b|
54
108
  [
55
109
  bool_to_int(current_thread?(a)),
56
- bool_to_int(b.ignored?),
57
- bool_to_int(b.suspended?),
58
- bool_to_int(b.thread.name.nil?),
59
- a.thread.object_id
110
+ bool_to_int(b.name.nil?),
111
+ a.name,
112
+ a.backtrace_locations[0].to_s
60
113
  ] <=> [
61
114
  bool_to_int(current_thread?(b)),
62
- bool_to_int(a.ignored?),
63
- bool_to_int(a.suspended?),
64
- bool_to_int(a.thread.name.nil?),
65
- b.thread.object_id
115
+ bool_to_int(a.name.nil?),
116
+ b.name,
117
+ b.backtrace_locations[0].to_s
66
118
  ]
67
119
  end
68
120
  end
@@ -71,46 +123,19 @@ module RubyJard
71
123
  bool == true ? -1 : 1
72
124
  end
73
125
 
74
- def current_thread?(context)
75
- context.thread == Thread.current
76
- end
77
-
78
- def context_color(context, text)
79
- if current_thread?(context)
80
- decorate_text
81
- .with_highlight(true)
82
- .text(text, :bright_yellow)
83
- elsif context.suspended?
84
- decorate_text
85
- .with_highlight(false)
86
- .text(text, :red)
87
- elsif context.ignored?
88
- decorate_text
89
- .with_highlight(false)
90
- .text(text, :white)
91
- else
92
- decorate_text
93
- .with_highlight(false)
94
- .text(text, :bright_white)
95
- end
126
+ def current_thread?(thread)
127
+ thread == @current_thread
96
128
  end
97
129
 
98
- def thread_name(context)
99
- if context.thread.name.nil?
100
- last_backtrace =
101
- if context == RubyJard.current_session.current_context
102
- context.backtrace[0][0]
103
- else
104
- context.thread.backtrace_locations[0]
105
- end
106
- location = decorate_path(last_backtrace.path, last_backtrace.lineno)
107
- "#{location.path}:#{location.lineno}"
130
+ def thread_status_style(thread)
131
+ if thread.status == 'run'
132
+ :text_selected
108
133
  else
109
- context.thread.name
134
+ :text_dim
110
135
  end
111
136
  end
112
137
  end
113
138
  end
114
139
  end
115
140
 
116
- RubyJard::Screens.add_screen(:threads, RubyJard::Screens::ThreadsScreen)
141
+ RubyJard::Screens.add_screen('threads', RubyJard::Screens::ThreadsScreen)