Skip to content

Commit

Permalink
Fixed readline prompt and gem dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
keita committed Jul 11, 2008
1 parent ef1bd56 commit 75488e7
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/rtask/ui/curses.rb
Expand Up @@ -90,7 +90,6 @@ def <<(msg)
def input(msg, val = "")
clear
setpos(0, 0)
addstr("> #{msg}: ")
refresh

# setup io config
Expand All @@ -100,7 +99,7 @@ def input(msg, val = "")

# read
Readline::HISTORY << val.to_s
res = Readline.readline
res = Readline.readline("> #{msg}: ")

# restore io config
tio.lflag &= ~Termios::ECHO
Expand Down Expand Up @@ -164,7 +163,6 @@ def start
when ?d, ::Curses::KEY_DOWN ; down
when ?c, ::Curses::KEY_CTRL_J ; change
when ?b; build_gem
when ?g; gemspec
when ?s; save
when ?i; IncludedFiles.new(parent.files)
when ?q; quit
Expand Down Expand Up @@ -241,14 +239,19 @@ def change
val = parent.spec.send(name)
res = case @spec.type_of(name)
when :array
msg = "#{name.to_s.capitalize}(Split by ';')"
res = (parent.input msg, val).strip.split(";")
msg = "#{name.to_s.capitalize}(Split by ',')"
(parent.input msg, val.join(",")).strip.split(",")
when :bool
!val
when :string
parent.input name.to_s.capitalize, val
end
parent.spec.send("#{name}=", res)
if name == :dependencies
parent.spec.dependencies.clear
res.each {|dep| parent.spec.add_runtime_dependency dep}
else
parent.spec.send("#{name}=", res)
end
parent.message "Updated '#{name}'"
@changed = true
end
Expand All @@ -272,7 +275,12 @@ def show_attribute(name, highlight)
addstr " ".rjust(@key_width - key_width + 1)

# value
addstr(val.inspect) unless val.nil?
case val
when Array
addstr val.join(", ")
else
addstr val.to_s
end unless val.nil?

attroff(highlight ? ::Curses::A_UNDERLINE : 0)
end
Expand Down

0 comments on commit 75488e7

Please sign in to comment.