-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fa5807c
Showing
6 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.app |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
task :default => [:run] | ||
|
||
task :build do | ||
require 'hotcocoa/application_builder' | ||
ApplicationBuilder.build :file => "config/build.yml" | ||
end | ||
|
||
task :run => [:build] do | ||
require 'yaml' | ||
app_name = YAML.load(File.read("config/build.yml"))[:name] | ||
`open "#{app_name}.app"` | ||
end | ||
|
||
task :clean do | ||
require 'yaml' | ||
app_name = YAML.load(File.read("config/build.yml"))[:name] | ||
`rm -rf "#{app_name}.app"` | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:name: MacIrb | ||
:load: lib/application.rb | ||
:version: "1.0" | ||
:icon: resources/HotCocoa.icns | ||
:resources: | ||
- resources/**/*.* | ||
:sources: | ||
- lib/**/*.rb |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
require 'hotcocoa' | ||
framework 'webkit' | ||
|
||
class Application | ||
include HotCocoa | ||
|
||
def start | ||
@line_num = 1 | ||
@binding = TOPLEVEL_BINDING | ||
|
||
def base_html | ||
return <<-HTML | ||
<html> | ||
<body> | ||
<table> | ||
<tr> | ||
<td style="vertical-align: top;">>></td> | ||
<td style="width: 100%;"><div id="command_line" contentEditable="true"></div></td> | ||
</tr> | ||
</table> | ||
<script type="text/javascript"><!-- | ||
var command_line = document.getElementById('command_line'); | ||
command_line.focus(); | ||
//var selection = window.getSelection(); | ||
//selection.setBaseAndExtent(command_line, 0, command_line, command_line.innerText.length); | ||
//selection.deleteFromDocument(); | ||
--></script> | ||
</body> | ||
</html> | ||
HTML | ||
end | ||
|
||
application :name => "MacIrb" do |app| | ||
app.delegate = self | ||
|
||
window :frame => [100, 100, 900, 500], :title => "MacIrb" do |win| | ||
win.will_close { exit } | ||
@web_view = web_view(:layout => {:expand => [:width, :height]}) | ||
@web_view.mainFrame.loadHTMLString base_html, baseURL:nil | ||
win << @web_view | ||
end | ||
# @display = label(:text => '', :layout => {:expand => [:width, :height]}) | ||
# @command_line = text_field(:layout => {:expand => [:width]}) | ||
# win << @command_line | ||
# win << @display | ||
# @command_line.on_action do | ||
# self.perform_action | ||
# end | ||
end | ||
end | ||
|
||
def perform_action | ||
@line_num += 1 | ||
command = @command_line.to_s | ||
return if command.empty? | ||
eval_file = __FILE__ | ||
eval_line = -1 | ||
begin | ||
eval_line = __LINE__; value = eval(command, @binding, 'macirb', @line_num-1) | ||
@display.text = value.inspect | ||
rescue Exception => e | ||
backtrace = e.backtrace | ||
i = backtrace.index { |l| l.index("#{eval_file}:#{eval_line}") } | ||
puts "#{eval_file}:#{eval_line}" | ||
puts i | ||
backtrace = backtrace[0..i-1] if i | ||
@display.text = "#{e.class.name}: #{e.message}\n#{backtrace.join("\n")}" | ||
end | ||
@command_line.text = '' | ||
end | ||
|
||
# file/open | ||
def on_open(menu) | ||
end | ||
|
||
# file/new | ||
def on_new(menu) | ||
end | ||
|
||
# help menu item | ||
def on_help(menu) | ||
end | ||
|
||
# This is commented out, so the minimize menu item is disabled | ||
#def on_minimize(menu) | ||
#end | ||
|
||
# window/zoom | ||
def on_zoom(menu) | ||
end | ||
|
||
# window/bring_all_to_front | ||
def on_bring_all_to_front(menu) | ||
end | ||
end | ||
|
||
Application.new.start |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module HotCocoa | ||
def application_menu | ||
menu do |main| | ||
main.submenu :apple do |apple| | ||
apple.item :about, :title => "About #{NSApp.name}" | ||
apple.separator | ||
apple.item :preferences, :key => "," | ||
apple.separator | ||
apple.submenu :services | ||
apple.separator | ||
apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h" | ||
apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt] | ||
apple.item :show_all, :title => "Show All" | ||
apple.separator | ||
apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q" | ||
end | ||
main.submenu :file do |file| | ||
file.item :new, :key => "n" | ||
file.item :open, :key => "o" | ||
end | ||
main.submenu :window do |win| | ||
win.item :minimize, :key => "m" | ||
win.item :zoom | ||
win.separator | ||
win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o" | ||
end | ||
main.submenu :help do |help| | ||
help.item :help, :title => "#{NSApp.name} Help" | ||
end | ||
end | ||
end | ||
end |
Binary file not shown.