132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/irb/theme/rk2025.rb', line 132
def self.start
Reline::LineEditor.prepend Module.new {
def colorize_completion_dialog
dialog = @dialogs[0]
unless dialog&.contents
IRB2025Mikan.reset_params
return
end
canvas = Canvas.new(dialog.width, dialog.contents.size)
face = Reline::Face[:completion_dialog]
time = Time.now.to_f
original_contents = dialog.contents.instance_eval { @original ||= dup }
canvas.focus_line = original_contents.find_index { |line| line.include?(face[:enhanced]) }
uncolored_lines = original_contents.map do |line|
line.gsub(/\e\[[\d;]*m/, '')
end
canvas.lines = uncolored_lines
IRB2025Mikan.params.each do |param|
param in { cx:, cy:, segments:, theta:, rot:, bo:, bi:, bm:, radius:, color: }
cy = (cy - dialog.scroll_top) % 1500 - 100
theta += time * rot
canvas.draw(5 + (canvas.w - 5)*cx, cy, radius+0.5, color){|x,y|
z = x+y.i
a = z.arg
a2 = ((a-theta)/2/Math::PI*segments).round*2*Math::PI/segments+theta
(z*Complex.polar(1, -a2)).imag.abs > bi + 10**(10*(z.abs2 - 1 + bo + bm)) || (z.abs<1&&z.abs>1-bo)
}
end
dialog.contents[0..] = canvas.render_to_lines
end
def update_dialogs(...)
@_updating_dialogs = true
super(...)
colorize_completion_dialog
ensure
@_updating_dialogs = false
end
def _updating_dialogs?
@_updating_dialogs
end
def rerender
(@mutex ||= Mutex.new).synchronize { super }
end
}
Thread.new do
Reline.line_editor.instance_eval do
loop do
sleep 0.1
colorize_completion_dialog && rerender unless _updating_dialogs?
end
end
end
end
|