3
# irbtkw.rb : IRB console with Ruby/Tk
5
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
13
require File.join(File.dirname(File.expand_path(__FILE__)), 'tktextio.rb')
19
top = TkToplevel.new(:title=>'IRB console')
20
top.protocol(:WM_DELETE_WINDOW){ Tk.exit }
22
console = TkTextIO.new(top, :mode=>:console,
23
:width=>80).pack(:side=>:left,
24
:expand=>true, :fill=>:both)
25
console.yscrollbar(TkScrollbar.new(top, :width=>10).pack(:before=>console,
32
irb_thread.kill if irb_thread
35
# window position control
38
r_x = root.winfo_rootx
39
r_y = root.winfo_rooty
40
r_w = root.winfo_width
49
s_w = (ratio * root.winfo_screenwidth).to_i
54
if t_x + t_w + r_w + delta < s_w
55
r_x = t_x + t_w + delta
56
elsif t_w + r_w + delta < s_w
64
root.geometry("+#{r_x}+#{r_y}")
65
top.geometry("+#{t_x}+#{t_y}")
75
# dummy for rubyw.exe on Windows
82
IRB.conf[:USE_READLINE] = false
85
IRB.conf[:MAIN_CONTEXT] = irb.context
87
class IRB::StdioInputMethod
89
prompt = "\n" << @prompt
98
@line[@line_no += 1] = $stdin.gets
103
$stdout.print("*** IRB console on Ruby/Tk (#{release}) ")
104
irb_thread = Thread.new{
115
console.bind('Control-c'){
116
console.insert('end', "^C\n")
117
irb_thread.raise RubyLex::TerminateLineInput