display output on a different line from the prompt

git-svn-id: file:///home/svn/framework3/trunk@4643 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2007-04-04 02:38:15 +00:00
parent a319b8e582
commit 67e39c15a1
4 changed files with 54 additions and 6 deletions

View File

@ -55,6 +55,22 @@ class Output
def flush
end
#
# Called to tell the output medium that we're at a prompt.
# This is used to allow the output medium to display an extra
# carriage return
#
def prompting(v = true)
@at_prompt = v
end
#
# Returns whether or not we're at a prompt currently
#
def prompting?
@at_prompt
end
end
end

View File

@ -19,28 +19,40 @@ module Subscriber
# Wraps user_output.print_line
#
def print_line(msg='')
user_output.print_line(msg) if (user_output)
if (user_output)
print_blank_line if user_output.prompting?
user_output.print_line(msg)
end
end
#
# Wraps user_output.print_status
#
def print_status(msg='')
user_output.print_status(msg) if (user_output)
if (user_output)
print_blank_line if user_output.prompting?
user_output.print_status(msg)
end
end
#
# Wraps user_output.print_error
#
def print_error(msg='')
user_output.print_error(msg) if (user_output)
if (user_output)
print_blank_line if user_output.prompting?
user_output.print_error(msg)
end
end
#
# Wraps user_output.print_good
#
def print_good(msg='')
user_output.print_good(msg) if (user_output)
if (user_output)
print_blank_line if user_output.prompting?
user_output.print_good(msg)
end
end
#
@ -61,6 +73,16 @@ module Subscriber
# The user output handle.
#
attr_accessor :user_output
protected
#
# Prints a blank line. Used when the input is prompting.
#
def print_blank_line
user_output.prompting(false)
user_output.print_line
end
end

View File

@ -129,12 +129,17 @@ begin
# Prompt-based getline using readline.
#
def pgets
if (readline_status)
$stderr.puts "ERROR: pgets called inside of thread mode: " + caller(1).to_s
return ''
end
if ((line = ::Readline.readline(prompt, true)))
output.prompting
line = ::Readline.readline(prompt, true)
output.prompting(false)
if line
HISTORY.pop if (line.empty?)
return line + "\n"
else

View File

@ -24,7 +24,12 @@ module Shell
def pgets
output.print(prompt)
output.flush
gets
output.prompting
buf = gets
output.prompting(false)
buf
end
end