Skip to content

Commit

Permalink
style tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed May 2, 2009
1 parent 5dcc2e7 commit 2b3581f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 44 deletions.
80 changes: 42 additions & 38 deletions lib/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def should_close?
alert.beginSheetModalForWindow @window, modalDelegate: self, didEndSelector: "alertDidEnd:returnCode:contextInfo:", contextInfo: nil
false
end

FULL={:expand => [:window,:height]}
def start
@line_num = 1
@history = [ ]
Expand All @@ -51,7 +51,35 @@ def start
frame[0] = w.frame.origin.x + 20
frame[1] = w.frame.origin.y - 20
end
#@prompt = text_view(:frame => [0,0,500,100],:layout => {:expand => [:width,:height], :start => false})
#?@prompt.editingDelegate = self # for ? (will only work for nstextview vs nstextfield)

#TODO: need to set font to monaco
#TODO: need scroll bars (putting into scroll_view caused issues)

#TODO: need scrollbars. but this caused the text_field/view to become too small
#full_prompt= scroll_view(:frame => [0,0,600,100], :layout => {:expand => [:width,:height], :start => true})
#full_prompt.document_view = @prompt
#full_prompt=@prompt

@window = window(:frame => frame, :title => "HotConsole") do |win|
win << split_view(:frame => [0,0,600,400],:horizontal => true, :layout => FULL) do |sview|
#set a default size. (better way to do this?
sview << @web_view = web_view(:frame => [0,0,200,300],:layout => FULL) do |wv|
wv.editingDelegate = self # for webView:doCommandBySelector:
wv.frameLoadDelegate = self # for webView:didFinishLoadForFrame:
wv.url=local_page_path
end
sview << @prompt = text_field(:frame => [0,0,500,100],:layout => FULL,
:on_action => Proc.new { |p|
perform_action(p.to_s)
p.text='' #@prompt.text=''
}) do |tf|
tf.setFont(font(:name=>'Monaco', :size => 16))
end
end
win.contentView.margin = 5

win.should_close? { self.should_close? }
win.will_close {
$terminals.delete(self)
Expand All @@ -63,38 +91,6 @@ def start
$terminals.delete(self)
$terminals << self
}
win.contentView.margin = 0

#set a default size. (better way to do this?
@web_view = web_view(:frame => [0,0,200,300],:layout => {:expand => [:width, :height]})
@web_view.editingDelegate = self # for webView:doCommandBySelector:
@web_view.frameLoadDelegate = self # for webView:didFinishLoadForFrame:
# @web_view.mainFrame.loadHTMLString base_html, baseURL: nil
#@web_view.url='file:///Users/kbrock/projects/hotconsole/resources/index.html'
@web_view.url=blank_page_path

#@prompt = text_view(:frame => [0,0,500,100],:layout => {:expand => [:width,:height], :start => false})
#?@prompt.editingDelegate = self # for ? (will only work for nstextview vs nstextfield)

#TODO: need to set font to monaco
#TODO: need scroll bars (putting into scroll_view caused issues)
@prompt = text_field(:frame => [0,0,500,100],:layout => {:expand => [:width,:height], :start => false, :font => font(:name => "Monaco", :size => 16)},
:on_action => Proc.new { |p|
perform_action(p.to_s)
p.text='' #@prompt.text=''
})
#for some reason the font line above does not
@prompt.setFont(font(:name=>'Monaco', :size => 16))

#TODO: need scrollbars. but this caused the text_field/view to become too small
#full_prompt= scroll_view(:frame => [0,0,600,100], :layout => {:expand => [:width,:height], :start => true})
#full_prompt.document_view = @prompt
full_prompt=@prompt

win << split_view(:frame => [0,0,600,400],:horizontal => true, :layout => {:expand => [:width,:height], :start =>true}) do |sview|
sview << @web_view
sview << full_prompt
end
end

class << @window
Expand All @@ -107,7 +103,7 @@ class << @window
$terminals << self
end

def blank_page_path
def local_page_path
bundle=NSBundle.mainBundle
raise "no mainBundle" unless bundle
fullPath=NSBundle.pathForResource("index", :ofType => "html", :inDirectory => bundle.bundlePath)
Expand Down Expand Up @@ -252,14 +248,15 @@ def perform_action(command)
command||=@prompt.to_s
current_line_number = @line_num

new_command_div
write_command command #put it into the top view

@line_num += command.count("\n")+1
if command.strip.empty?
write_prompt
return
end

new_command_div
write_command command #put it into the top view

@line_num += command.count("\n")+1

@history.push(command)
@pos_in_history = @history.length
Expand All @@ -281,6 +278,11 @@ def back_from_eval(text)
write text
write_prompt
end
def back_from_eval_result(value)
return if @window_closed
write "=> #{value.inspect}\n" #inspect not necessary
write_prompt
end
end

class Application
Expand All @@ -291,6 +293,8 @@ def start
end
end

#menu options

def on_new(sender)
start_terminal
end
Expand Down
3 changes: 2 additions & 1 deletion lib/eval_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def run
begin
# eval_line must have exactly the line number where the eval call occurs
eval_line = __LINE__; value = eval(add_underscore_assignment(command), @binding, 'hotconsole', line_num)
back_from_eval "=> #{value.inspect}\n"
#back_from_eval "=> #{value.inspect}\n"
@target.send_on_main_thread :back_from_eval_result, value.inspect #would like to not send inspect, but fixes 'boolean' bug
rescue Exception => e
backtrace = e.backtrace
# we try to remove the backtrace of the call to eval itself
Expand Down
11 changes: 6 additions & 5 deletions resources/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,19 @@ h1 {
}
/* @end #header */
/* @group #content */
#content {}
.hentry {
position: relative;
border-bottom: 2px solid #000;
padding: 20px 0 13px 0;
margin: 0px 0 5px 0;
}
/* post markup */
h3 {
/* post markup (command) */
h3.hentry-title {
font-size: 16px;
line-height: 20px;
margin: -1px 0 21px 0; /*newline below command text */
margin: -1px 0 1px 0; /*make bottom 21px for newline after command*/
font-variant: small-caps;
}
/* @end #content */
#hentry-content {}

/* @end #content */

0 comments on commit 2b3581f

Please sign in to comment.