lib/ansiterm/string.rb in ansiterm-0.2.0 vs lib/ansiterm/string.rb in ansiterm-0.3.0
- old
+ new
@@ -3,11 +3,11 @@
class String
def initialize(str="")
parse(str)
end
-
+
def to_str
out = ""
a = Attr.new
@str.length.times.each do |i|
if a != @attrs[i]
@@ -26,10 +26,14 @@
def length
@str.length
end
+ def index str, off = 0
+ @str.index(str,off)
+ end
+
def set(str,attrs)
@str, @attrs = str,Array(attrs)
end
def[] i
@@ -41,9 +45,15 @@
else
nil
end
end
+ def << str
+ str = self.class.new(str)
+ @str << str.raw
+ @attrs << str.attrs
+# parse(self.to_str + "\e[0m" + str.to_str)
+ end
private
def parse_color(par, params, a, attr_name)
col = par