2011-10-05 13:04:44 -04:00
|
|
|
require 'coderay'
|
|
|
|
|
|
|
|
class Pry
|
2012-04-25 01:45:22 -04:00
|
|
|
# Load io-console if possible, so that we can use $stdout.winsize.
|
2012-04-13 04:21:20 -04:00
|
|
|
begin
|
|
|
|
require 'io/console'
|
|
|
|
rescue LoadError
|
|
|
|
end
|
|
|
|
|
2011-10-05 13:04:44 -04:00
|
|
|
##
|
|
|
|
# Pry::Indent is a class that can be used to indent a number of lines
|
|
|
|
# containing Ruby code similar as to how IRB does it (but better). The class
|
|
|
|
# works by tokenizing a string using CodeRay and then looping over those
|
|
|
|
# tokens. Based on the tokens in a line of code that line (or the next one)
|
2011-10-09 03:31:06 -04:00
|
|
|
# will be indented or un-indented by correctly.
|
2011-10-05 13:04:44 -04:00
|
|
|
#
|
|
|
|
class Indent
|
2012-04-18 19:53:53 -04:00
|
|
|
include Helpers::BaseHelpers
|
|
|
|
|
2012-07-28 04:39:41 -04:00
|
|
|
# Raised if {#module_nesting} would not work.
|
|
|
|
class UnparseableNestingError < StandardError; end
|
|
|
|
|
2012-07-12 07:13:13 -04:00
|
|
|
# @return [String] String containing the spaces to be inserted before the next line.
|
2011-10-09 04:31:28 -04:00
|
|
|
attr_reader :indent_level
|
2012-07-28 04:39:41 -04:00
|
|
|
|
2012-07-12 07:13:13 -04:00
|
|
|
# @return [Array<String>] The stack of open tokens.
|
|
|
|
attr_reader :stack
|
2011-10-05 13:04:44 -04:00
|
|
|
|
|
|
|
# The amount of spaces to insert for each indent level.
|
2011-10-09 03:43:47 -04:00
|
|
|
SPACES = ' '
|
2011-10-05 13:04:44 -04:00
|
|
|
|
2011-10-08 09:30:06 -04:00
|
|
|
# Hash containing all the tokens that should increase the indentation
|
|
|
|
# level. The keys of this hash are open tokens, the values the matching
|
|
|
|
# tokens that should prevent a line from being indented if they appear on
|
|
|
|
# the same line.
|
2011-10-09 03:43:47 -04:00
|
|
|
OPEN_TOKENS = {
|
2011-10-08 09:30:06 -04:00
|
|
|
'def' => 'end',
|
|
|
|
'class' => 'end',
|
|
|
|
'module' => 'end',
|
|
|
|
'do' => 'end',
|
|
|
|
'if' => 'end',
|
2011-10-10 00:34:16 -04:00
|
|
|
'unless' => 'end',
|
2011-10-08 09:30:06 -04:00
|
|
|
'while' => 'end',
|
2011-10-10 00:34:16 -04:00
|
|
|
'until' => 'end',
|
2011-10-08 09:30:06 -04:00
|
|
|
'for' => 'end',
|
2011-10-09 04:39:42 -04:00
|
|
|
'case' => 'end',
|
2011-10-25 23:57:19 -04:00
|
|
|
'begin' => 'end',
|
2011-10-08 09:30:06 -04:00
|
|
|
'[' => ']',
|
|
|
|
'{' => '}',
|
2011-10-09 03:04:54 -04:00
|
|
|
'(' => ')'
|
2011-10-08 09:30:06 -04:00
|
|
|
}
|
2011-10-05 13:04:44 -04:00
|
|
|
|
2011-10-10 00:34:16 -04:00
|
|
|
# Which tokens can either be open tokens, or appear as modifiers on
|
|
|
|
# a single-line.
|
2011-10-25 23:57:19 -04:00
|
|
|
SINGLELINE_TOKENS = %w(if while until unless rescue)
|
2011-10-10 00:34:16 -04:00
|
|
|
|
2012-12-28 10:37:55 -05:00
|
|
|
# Which tokens can be followed by an optional "do" keyword.
|
2012-12-30 21:13:03 -05:00
|
|
|
OPTIONAL_DO_TOKENS = %w(for while until)
|
2012-12-28 10:37:55 -05:00
|
|
|
|
2011-10-05 13:04:44 -04:00
|
|
|
# Collection of token types that should be ignored. Without this list
|
|
|
|
# keywords such as "class" inside strings would cause the code to be
|
|
|
|
# indented incorrectly.
|
2011-11-27 13:39:47 -05:00
|
|
|
#
|
|
|
|
# :pre_constant and :preserved_constant are the CodeRay 0.9.8 and 1.0.0
|
|
|
|
# classifications of "true", "false", and "nil".
|
2012-04-22 03:22:49 -04:00
|
|
|
IGNORE_TOKENS = [:space, :content, :string, :method, :ident,
|
2011-11-27 13:39:47 -05:00
|
|
|
:constant, :pre_constant, :predefined_constant]
|
2011-10-05 13:04:44 -04:00
|
|
|
|
2011-10-09 03:04:54 -04:00
|
|
|
# Tokens that indicate the end of a statement (i.e. that, if they appear
|
|
|
|
# directly before an "if" indicates that that if applies to the same line,
|
|
|
|
# not the next line)
|
2011-10-28 02:45:15 -04:00
|
|
|
#
|
|
|
|
# :reserved and :keywords are the CodeRay 0.9.8 and 1.0.0 respectively
|
|
|
|
# classifications of "super", "next", "return", etc.
|
2012-04-22 03:22:49 -04:00
|
|
|
STATEMENT_END_TOKENS = IGNORE_TOKENS + [:regexp, :integer, :float, :keyword,
|
|
|
|
:delimiter, :reserved]
|
2011-10-09 03:04:54 -04:00
|
|
|
|
2011-10-09 04:31:28 -04:00
|
|
|
# Collection of tokens that should appear dedented even though they
|
|
|
|
# don't affect the surrounding code.
|
2011-10-27 03:29:39 -04:00
|
|
|
MIDWAY_TOKENS = %w(when else elsif ensure rescue)
|
2011-10-05 13:04:44 -04:00
|
|
|
|
2012-07-28 04:39:41 -04:00
|
|
|
# Clean the indentation of a fragment of ruby.
|
|
|
|
#
|
|
|
|
# @param [String] str
|
|
|
|
# @return [String]
|
|
|
|
def self.indent(str)
|
|
|
|
new.indent(str)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Get the module nesting at the given point in the given string.
|
|
|
|
#
|
|
|
|
# NOTE If the line specified contains a method definition, then the nesting
|
|
|
|
# at the start of the method definition is used. Otherwise the nesting from
|
|
|
|
# the end of the line is used.
|
|
|
|
#
|
2012-11-03 23:59:21 -04:00
|
|
|
# @param [String] str The ruby code to analyze
|
|
|
|
# @param [Fixnum] line_number The line number (starting from 1)
|
2012-07-28 04:39:41 -04:00
|
|
|
# @return [Array<String>]
|
|
|
|
def self.nesting_at(str, line_number)
|
|
|
|
indent = new
|
|
|
|
lines = str.split("\n")
|
|
|
|
n = line_number - 1
|
|
|
|
to_indent = lines[0...n] + (lines[n] || "").split("def").first(1)
|
|
|
|
indent.indent(to_indent.join("\n") + "\n")
|
|
|
|
indent.module_nesting
|
|
|
|
end
|
|
|
|
|
2011-10-05 13:04:44 -04:00
|
|
|
def initialize
|
2011-10-09 03:31:06 -04:00
|
|
|
reset
|
2011-10-05 13:04:44 -04:00
|
|
|
end
|
|
|
|
|
2011-10-09 03:31:06 -04:00
|
|
|
# reset internal state
|
2011-10-08 13:21:26 -04:00
|
|
|
def reset
|
2011-10-09 03:31:06 -04:00
|
|
|
@stack = []
|
2011-10-09 04:31:28 -04:00
|
|
|
@indent_level = ''
|
2012-04-22 03:22:49 -04:00
|
|
|
@heredoc_queue = []
|
|
|
|
@close_heredocs = {}
|
|
|
|
@string_start = nil
|
2012-07-28 04:39:41 -04:00
|
|
|
@awaiting_class = false
|
|
|
|
@module_nesting = []
|
2011-10-09 03:04:54 -04:00
|
|
|
self
|
2011-10-08 13:21:26 -04:00
|
|
|
end
|
|
|
|
|
2011-10-05 13:04:44 -04:00
|
|
|
# Indents a string and returns it. This string can either be a single line
|
|
|
|
# or multiple ones.
|
|
|
|
#
|
|
|
|
# @example
|
|
|
|
# str = <<TXT
|
|
|
|
# class User
|
|
|
|
# attr_accessor :name
|
|
|
|
# end
|
|
|
|
# TXT
|
|
|
|
#
|
|
|
|
# # This would result in the following being displayed:
|
|
|
|
# #
|
|
|
|
# # class User
|
|
|
|
# # attr_accessor :name
|
|
|
|
# # end
|
|
|
|
# #
|
|
|
|
# puts Pry::Indent.new.indent(str)
|
|
|
|
#
|
|
|
|
# @param [String] input The input string to indent.
|
|
|
|
# @return [String] The indented version of +input+.
|
|
|
|
#
|
|
|
|
def indent(input)
|
2012-05-28 19:37:02 -04:00
|
|
|
output = ''
|
2011-10-09 03:04:54 -04:00
|
|
|
prefix = indent_level
|
2011-10-05 13:04:44 -04:00
|
|
|
|
|
|
|
input.lines.each do |line|
|
2012-04-22 03:22:49 -04:00
|
|
|
|
|
|
|
if in_string?
|
|
|
|
tokens = tokenize("#{open_delimiters_line}\n#{line}")
|
|
|
|
tokens = tokens.drop_while{ |token, type| !(String === token && token.include?("\n")) }
|
|
|
|
previously_in_string = true
|
|
|
|
else
|
|
|
|
tokens = tokenize(line)
|
|
|
|
previously_in_string = false
|
|
|
|
end
|
2011-10-05 13:04:44 -04:00
|
|
|
|
2011-10-09 03:31:06 -04:00
|
|
|
before, after = indentation_delta(tokens)
|
2011-10-05 13:04:44 -04:00
|
|
|
|
2011-10-09 03:43:47 -04:00
|
|
|
before.times{ prefix.sub! SPACES, '' }
|
2012-04-22 03:22:49 -04:00
|
|
|
new_prefix = prefix + SPACES * after
|
|
|
|
|
|
|
|
line = prefix + line.lstrip unless previously_in_string
|
|
|
|
|
|
|
|
output += line
|
|
|
|
|
|
|
|
prefix = new_prefix
|
2011-10-05 13:04:44 -04:00
|
|
|
end
|
|
|
|
|
2011-10-09 04:31:28 -04:00
|
|
|
@indent_level = prefix
|
2011-10-09 03:04:54 -04:00
|
|
|
|
2012-07-18 12:24:31 -04:00
|
|
|
return output
|
2011-10-05 13:04:44 -04:00
|
|
|
end
|
2011-10-08 08:40:39 -04:00
|
|
|
|
2012-04-22 03:22:49 -04:00
|
|
|
# Get the indentation for the start of the next line.
|
|
|
|
#
|
|
|
|
# This is what's used between the prompt and the cursor in pry.
|
|
|
|
#
|
|
|
|
# @return String The correct number of spaces
|
|
|
|
#
|
|
|
|
def current_prefix
|
|
|
|
in_string? ? '' : indent_level
|
|
|
|
end
|
|
|
|
|
2011-10-09 03:31:06 -04:00
|
|
|
# Get the change in indentation indicated by the line.
|
|
|
|
#
|
|
|
|
# By convention, you remove indent from the line containing end tokens,
|
|
|
|
# but add indent to the line *after* that which contains the start tokens.
|
|
|
|
#
|
|
|
|
# This method returns a pair, where the first number is the number of closings
|
|
|
|
# on this line (i.e. the number of indents to remove before the line) and the
|
|
|
|
# second is the number of openings (i.e. the number of indents to add after
|
|
|
|
# this line)
|
2011-10-08 09:30:06 -04:00
|
|
|
#
|
|
|
|
# @param [Array] tokens A list of tokens to scan.
|
2011-10-09 03:31:06 -04:00
|
|
|
# @return [Array[Integer]]
|
2011-10-08 09:30:06 -04:00
|
|
|
#
|
2011-10-09 03:31:06 -04:00
|
|
|
def indentation_delta(tokens)
|
2011-10-09 04:31:28 -04:00
|
|
|
|
|
|
|
# We need to keep track of whether we've seen a "for" on this line because
|
|
|
|
# if the line ends with "do" then that "do" should be discounted (i.e. we're
|
|
|
|
# only opening one level not two) To do this robustly we want to keep track
|
|
|
|
# of the indent level at which we saw the for, so we can differentiate
|
|
|
|
# between "for x in [1,2,3] do" and "for x in ([1,2,3].map do" properly
|
|
|
|
seen_for_at = []
|
|
|
|
|
|
|
|
# When deciding whether an "if" token is the start of a multiline statement,
|
|
|
|
# or just the middle of a single-line if statement, we just look at the
|
|
|
|
# preceding token, which is tracked here.
|
2011-10-09 03:04:54 -04:00
|
|
|
last_token, last_kind = [nil, nil]
|
|
|
|
|
2011-10-09 04:31:28 -04:00
|
|
|
# delta keeps track of the total difference from the start of each line after
|
|
|
|
# the given token, 0 is just the level at which the current line started for
|
|
|
|
# reference.
|
|
|
|
remove_before, add_after = [0, 0]
|
2011-10-08 09:30:06 -04:00
|
|
|
|
|
|
|
# If the list of tokens contains a matching closing token the line should
|
|
|
|
# not be indented (and thus we should return true).
|
|
|
|
tokens.each do |token, kind|
|
2011-10-10 00:34:16 -04:00
|
|
|
is_singleline_if = (SINGLELINE_TOKENS.include?(token)) && end_of_statement?(last_token, last_kind)
|
2011-10-09 04:31:28 -04:00
|
|
|
is_optional_do = (token == "do" && seen_for_at.include?(add_after - 1))
|
2011-10-09 03:04:54 -04:00
|
|
|
|
|
|
|
last_token, last_kind = token, kind unless kind == :space
|
2011-10-09 03:43:47 -04:00
|
|
|
next if IGNORE_TOKENS.include?(kind)
|
2011-10-08 09:30:06 -04:00
|
|
|
|
2012-07-28 04:39:41 -04:00
|
|
|
track_module_nesting(token, kind)
|
|
|
|
|
2012-12-28 10:37:55 -05:00
|
|
|
seen_for_at << add_after if OPTIONAL_DO_TOKENS.include?(token)
|
2011-10-09 04:31:28 -04:00
|
|
|
|
2012-04-22 03:22:49 -04:00
|
|
|
if kind == :delimiter
|
|
|
|
track_delimiter(token)
|
|
|
|
elsif OPEN_TOKENS.keys.include?(token) && !is_optional_do && !is_singleline_if
|
2011-10-09 04:31:28 -04:00
|
|
|
@stack << token
|
|
|
|
add_after += 1
|
|
|
|
elsif token == OPEN_TOKENS[@stack.last]
|
2012-07-28 04:39:41 -04:00
|
|
|
popped = @stack.pop
|
|
|
|
track_module_nesting_end(popped)
|
2011-10-09 04:31:28 -04:00
|
|
|
if add_after == 0
|
|
|
|
remove_before += 1
|
2011-10-09 03:04:54 -04:00
|
|
|
else
|
2011-10-09 04:31:28 -04:00
|
|
|
add_after -= 1
|
2011-10-09 03:04:54 -04:00
|
|
|
end
|
2011-10-09 04:31:28 -04:00
|
|
|
elsif MIDWAY_TOKENS.include?(token)
|
|
|
|
if add_after == 0
|
|
|
|
remove_before += 1
|
|
|
|
add_after += 1
|
2011-10-09 03:04:54 -04:00
|
|
|
end
|
2011-10-08 09:30:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-09 04:31:28 -04:00
|
|
|
return [remove_before, add_after]
|
2011-10-09 03:04:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# If the code just before an "if" or "while" token on a line looks like the end of a statement,
|
|
|
|
# then we want to treat that "if" as a singleline, not multiline statement.
|
|
|
|
def end_of_statement?(last_token, last_kind)
|
2011-10-27 03:38:41 -04:00
|
|
|
(last_token =~ /^[)\]}\/]$/ || STATEMENT_END_TOKENS.include?(last_kind))
|
2011-10-08 09:30:06 -04:00
|
|
|
end
|
2011-10-08 08:40:39 -04:00
|
|
|
|
2012-04-22 03:22:49 -04:00
|
|
|
# Are we currently in the middle of a string literal.
|
|
|
|
#
|
|
|
|
# This is used to determine whether to re-indent a given line, we mustn't re-indent
|
|
|
|
# within string literals because to do so would actually change the value of the
|
|
|
|
# String!
|
|
|
|
#
|
|
|
|
# @return Boolean
|
|
|
|
def in_string?
|
|
|
|
!open_delimiters.empty?
|
|
|
|
end
|
|
|
|
|
|
|
|
# Given a string of Ruby code, use CodeRay to export the tokens.
|
|
|
|
#
|
2012-06-27 01:30:00 -04:00
|
|
|
# @param [String] string The Ruby to lex
|
|
|
|
# @return [Array] An Array of pairs of [token_value, token_type]
|
2012-04-22 03:22:49 -04:00
|
|
|
def tokenize(string)
|
|
|
|
tokens = CodeRay.scan(string, :ruby)
|
|
|
|
tokens = tokens.tokens.each_slice(2) if tokens.respond_to?(:tokens) # Coderay 1.0.0
|
2012-04-25 02:55:13 -04:00
|
|
|
tokens.to_a
|
2012-04-22 03:22:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Update the internal state about what kind of strings are open.
|
|
|
|
#
|
|
|
|
# Most of the complication here comes from the fact that HEREDOCs can be nested. For
|
|
|
|
# normal strings (which can't be nested) we assume that CodeRay correctly pairs
|
|
|
|
# open-and-close delimiters so we don't bother checking what they are.
|
|
|
|
#
|
2012-06-27 01:30:00 -04:00
|
|
|
# @param [String] token The token (of type :delimiter)
|
2012-04-22 03:22:49 -04:00
|
|
|
def track_delimiter(token)
|
|
|
|
case token
|
|
|
|
when /^<<-(["'`]?)(.*)\\1/
|
|
|
|
@heredoc_queue << token
|
|
|
|
@close_heredocs[token] = /^\s*$2/
|
|
|
|
when @close_heredocs[@heredoc_queue.first]
|
|
|
|
@heredoc_queue.shift
|
|
|
|
else
|
|
|
|
if @string_start
|
|
|
|
@string_start = nil
|
|
|
|
else
|
|
|
|
@string_start = token
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# All the open delimiters, in the order that they first appeared.
|
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
def open_delimiters
|
|
|
|
@heredoc_queue + [@string_start].compact
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return a string which restores the CodeRay string status to the correct value by
|
|
|
|
# opening HEREDOCs and strings.
|
|
|
|
#
|
|
|
|
# @return String
|
|
|
|
def open_delimiters_line
|
|
|
|
"puts #{open_delimiters.join(", ")}"
|
|
|
|
end
|
|
|
|
|
2012-07-28 04:39:41 -04:00
|
|
|
# Update the internal state relating to module nesting.
|
|
|
|
#
|
|
|
|
# It's responsible for adding to the @module_nesting array, which looks
|
|
|
|
# something like:
|
|
|
|
#
|
|
|
|
# [ ["class", "Foo"], ["module", "Bar::Baz"], ["class <<", "self"] ]
|
|
|
|
#
|
|
|
|
# A nil value in the @module_nesting array happens in two places: either
|
|
|
|
# when @awaiting_token is true and we're still waiting for the string to
|
|
|
|
# fill that space, or when a parse was rejected.
|
|
|
|
#
|
|
|
|
# At the moment this function is quite restricted about what formats it will
|
|
|
|
# parse, for example we disallow expressions after the class keyword. This
|
|
|
|
# could maybe be improved in the future.
|
|
|
|
#
|
|
|
|
# @param [String] token a token from Coderay
|
|
|
|
# @param [Symbol] kind the kind of that token
|
|
|
|
def track_module_nesting(token, kind)
|
|
|
|
if kind == :keyword && (token == "class" || token == "module")
|
|
|
|
@module_nesting << [token, nil]
|
|
|
|
@awaiting_class = true
|
|
|
|
elsif @awaiting_class
|
|
|
|
if kind == :operator && token == "<<" && @module_nesting.last[0] == "class"
|
|
|
|
@module_nesting.last[0] = "class <<"
|
|
|
|
@awaiting_class = true
|
|
|
|
elsif kind == :class && token =~ /\A(self|[A-Z:][A-Za-z0-9_:]*)\z/
|
|
|
|
@module_nesting.last[1] = token if kind == :class
|
|
|
|
@awaiting_class = false
|
|
|
|
else
|
|
|
|
# leave @nesting[-1][
|
|
|
|
@awaiting_class = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update the internal state relating to module nesting on 'end'.
|
|
|
|
#
|
|
|
|
# If the current 'end' pairs up with a class or a module then we should
|
|
|
|
# pop an array off of @module_nesting
|
|
|
|
#
|
|
|
|
# @param [String] token a token from Coderay
|
|
|
|
# @param [Symbol] kind the kind of that token
|
|
|
|
def track_module_nesting_end(token, kind=:keyword)
|
|
|
|
if kind == :keyword && (token == "class" || token == "module")
|
|
|
|
@module_nesting.pop
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return a list of strings which can be used to re-construct the Module.nesting at
|
|
|
|
# the current point in the file.
|
|
|
|
#
|
|
|
|
# Returns nil if the syntax of the file was not recognizable.
|
|
|
|
#
|
|
|
|
# @return [Array<String>]
|
|
|
|
def module_nesting
|
|
|
|
@module_nesting.map do |(kind, token)|
|
|
|
|
raise UnparseableNestingError, @module_nesting.inspect if token.nil?
|
|
|
|
|
|
|
|
"#{kind} #{token}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-09 15:13:39 -04:00
|
|
|
# Return a string which, when printed, will rewrite the previous line with
|
|
|
|
# the correct indentation. Mostly useful for fixing 'end'.
|
2011-10-08 09:30:06 -04:00
|
|
|
#
|
2012-04-02 03:31:22 -04:00
|
|
|
# @param [String] prompt The user's prompt
|
|
|
|
# @param [String] code The code the user just typed in.
|
2011-10-09 22:09:42 -04:00
|
|
|
# @param [Fixnum] overhang (0) The number of chars to erase afterwards (i.e.,
|
|
|
|
# the difference in length between the old line and the new one).
|
2011-10-09 15:13:39 -04:00
|
|
|
# @return [String]
|
2012-04-02 03:31:22 -04:00
|
|
|
def correct_indentation(prompt, code, overhang=0)
|
|
|
|
full_line = prompt + code
|
2012-04-25 01:45:22 -04:00
|
|
|
whitespace = ' ' * overhang
|
|
|
|
|
2012-11-29 05:51:08 -05:00
|
|
|
_, cols = TerminalInfo.screen_size
|
2012-05-10 05:32:15 -04:00
|
|
|
|
|
|
|
cols = cols.to_i
|
|
|
|
lines = cols != 0 ? (full_line.length / cols + 1) : 1
|
2012-04-25 01:45:22 -04:00
|
|
|
|
2012-06-23 18:06:32 -04:00
|
|
|
if Pry::Helpers::BaseHelpers.windows_ansi?
|
2011-11-05 02:10:10 -04:00
|
|
|
move_up = "\e[#{lines}F"
|
|
|
|
move_down = "\e[#{lines}E"
|
2011-10-28 02:43:55 -04:00
|
|
|
else
|
2011-11-05 02:10:10 -04:00
|
|
|
move_up = "\e[#{lines}A\e[0G"
|
|
|
|
move_down = "\e[#{lines}B\e[0G"
|
2011-10-28 02:43:55 -04:00
|
|
|
end
|
2011-10-08 08:40:39 -04:00
|
|
|
|
2012-04-18 19:53:53 -04:00
|
|
|
"#{move_up}#{prompt}#{colorize_code(code)}#{whitespace}#{move_down}"
|
2011-10-08 08:40:39 -04:00
|
|
|
end
|
2011-10-09 03:31:06 -04:00
|
|
|
end
|
|
|
|
end
|