Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 64 lines (55 sloc) 1.737 kB
044322a @headius Committing most recent, changes for the swing IRB console...additiona…
headius authored
1 #!/usr/bin/env jruby
2 #
3 # IRB in swing
4 #
5 # Damian Steer (pldms@mac.com)
6
7 require 'jruby'
8 require 'irb'
9 require 'irb/completion'
10
3d51e60 @vvs JRUBY-4327: JIRB in signed-jirb.jnlp is broken
vvs authored
11 if ARGV.empty?
12 # default options, esp. useful for jrubyw
13 ARGV << '--readline' << '--prompt' << 'inf-ruby'
14 end
15
044322a @headius Committing most recent, changes for the swing IRB console...additiona…
headius authored
16 import java.awt.Color
17 import java.awt.Font
76c9ef9 @headius Damian's fix for JRUBY-975, make the swing IRB console quit when the …
headius authored
18 import javax.swing.JFrame
c0ad660 @vvs JRUBY-2445: Regression: jirb_swing broken, prints out to the stdin,
vvs authored
19 import java.awt.EventQueue
044322a @headius Committing most recent, changes for the swing IRB console...additiona…
headius authored
20
21 # Try to find preferred font family, use otherwise -- err -- otherwise
22 def find_font(otherwise, style, size, *families)
23 avail_families = java.awt.GraphicsEnvironment.local_graphics_environment.available_font_family_names
24 fontname = families.find(proc {otherwise}) { |name| avail_families.include? name }
25 Font.new(fontname, style, size)
26 end
27
28 text = javax.swing.JTextPane.new
c0ad660 @vvs JRUBY-2445: Regression: jirb_swing broken, prints out to the stdin,
vvs authored
29 text.font = find_font('Monospaced', Font::PLAIN, 14, 'Monaco', 'Andale Mono')
044322a @headius Committing most recent, changes for the swing IRB console...additiona…
headius authored
30 text.margin = java.awt.Insets.new(8,8,8,8)
31 text.caret_color = Color.new(0xa4, 0x00, 0x00)
32 text.background = Color.new(0xf2, 0xf2, 0xf2)
33 text.foreground = Color.new(0xa4, 0x00, 0x00)
34
35 pane = javax.swing.JScrollPane.new
36 pane.viewport_view = text
76c9ef9 @headius Damian's fix for JRUBY-975, make the swing IRB console quit when the …
headius authored
37 frame = JFrame.new('JRuby IRB Console (tab will autocomplete)')
38 frame.default_close_operation = JFrame::EXIT_ON_CLOSE
044322a @headius Committing most recent, changes for the swing IRB console...additiona…
headius authored
39 frame.set_size(700, 600)
40 frame.content_pane.add(pane)
c0ad660 @vvs JRUBY-2445: Regression: jirb_swing broken, prints out to the stdin,
vvs authored
41 tar = org.jruby.demo.TextAreaReadline.new(text,
b2b064e @enebo Display Ruby version so we know which which irb we chose (mostly for …
enebo authored
42 " Welcome to the JRuby IRB Console [#{JRUBY_VERSION} (#{RUBY_VERSION})]\n\n")
f31a311 @vvs JRUBY-2240: Ability to enable full ObjectSpace support from within
vvs authored
43 JRuby.objectspace = true # useful for code completion
c0ad660 @vvs JRUBY-2445: Regression: jirb_swing broken, prints out to the stdin,
vvs authored
44 tar.hook_into_runtime_with_streams(JRuby.runtime)
45
46 # We need to show the frame on EDT,
47 # to avoid deadlocks.
c08ee54 @headius Fix JRUBY-5554: Simplify jirb_swing script
headius authored
48 EventQueue.invoke_later {
49 frame.visible = true
50 }
044322a @headius Committing most recent, changes for the swing IRB console...additiona…
headius authored
51
52 # From vanilla IRB
53 if __FILE__ == $0
54 IRB.start(__FILE__)
55 else
56 # check -e option
57 if /^-e$/ =~ $0
58 IRB.start(__FILE__)
59 else
60 IRB.setup(__FILE__)
61 end
62 end
423b3fc @vvs Additional fix for JRUBY-2025.
vvs authored
63 frame.dispose
Something went wrong with that request. Please try again.