Class: AnsiSys::Characters

Inherits:
Object
  • Object
show all
Defined in:
lib/ansisys.rb

Constant Summary collapse

WIDTHS =

widths of characters

{
	"\t" => 8,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, sgr) ⇒ Characters

Returns a new instance of Characters.



111
112
113
114
# File 'lib/ansisys.rb', line 111

def initialize(string, sgr)
	@string = string
	@sgr = sgr
end

Instance Attribute Details

#sgrObject (readonly)

Select Graphic Rendition associated with the text



109
110
111
# File 'lib/ansisys.rb', line 109

def sgr
  @sgr
end

#stringObject (readonly)

clear text



108
109
110
# File 'lib/ansisys.rb', line 108

def string
  @string
end

Instance Method Details

#echo_on(screen, cursor, kcode = nil) ⇒ Object

echo the string onto the screen with initial cursor as cursor cursor position will be changed as the string is echoed



118
119
120
121
122
123
124
125
126
# File 'lib/ansisys.rb', line 118

def echo_on(screen, cursor, kcode = nil)
	each_char(kcode) do |c|
		w = width(c)
		cursor.fit!(w)
		screen.write(c, w, cursor.cur_col, cursor.cur_row, @sgr.dup)
		cursor.advance!(w)
	end
	return self
end