-
-
Save gr33n7007h/06531866fd8090158c11be3cb69a6ea6 to your computer and use it in GitHub Desktop.
Manipulate dialog colours in IRB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# save this peice of code in your ~/.irbrc | |
module Reline | |
DUMMY = ->() { | |
# autocomplete | |
return nil unless config.autocompletion | |
if just_cursor_moving and completion_journey_data.nil? | |
# Auto complete starts only when edited | |
return nil | |
end | |
pre, target, post = retrieve_completion_block(true) | |
if target.nil? or target.empty? or (completion_journey_data&.pointer == -1 and target.size <= 3) | |
return nil | |
end | |
if completion_journey_data and completion_journey_data.list | |
result = completion_journey_data.list.dup | |
result.shift | |
pointer = completion_journey_data.pointer - 1 | |
else | |
result = call_completion_proc_with_checking_args(pre, target, post) | |
pointer = nil | |
end | |
if result and result.size == 1 and result[0] == target and pointer != 0 | |
result = nil | |
end | |
target_width = Reline::Unicode.calculate_width(target) | |
x = cursor_pos.x - target_width | |
if x < 0 | |
x = screen_width + x | |
y = -1 | |
else | |
y = 0 | |
end | |
cursor_pos_to_render = Reline::CursorPos.new(x, y) | |
if context and context.is_a?(Array) | |
context.clear | |
context.push(cursor_pos_to_render, result, pointer, dialog) | |
end | |
dialog.pointer = pointer | |
DialogRenderInfo.new( | |
pos: cursor_pos_to_render, | |
contents: result, | |
scrollbar: true, | |
height: [15, preferred_dialog_height].min, | |
bg_color: 40, ## *** modify me *** | |
pointer_bg_color: 32, ## *** modify me *** | |
fg_color: 92, ## *** modify me *** | |
pointer_fg_color: 90 ## *** modify me *** | |
) | |
} | |
end | |
Reline.add_dialog_proc(:dummy, Reline::DUMMY) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment