Archived
1
0
Fork 0

Add method Widgets::Chat::History#draw_header

This commit is contained in:
Braiden Vasco 2017-07-26 07:27:17 +00:00
parent 1d571e79f3
commit ad31d7f808

View file

@ -20,6 +20,29 @@ module Widgets
end end
def draw_message(offset, out, time, name, text) def draw_message(offset, out, time, name, text)
draw_header offset, out, time, name
width = props[:width] / 3 * 2
left = out ? props[:width] - width : 0
lines = (text.length / width.to_f).ceil
1.upto lines do |line|
s = text[(width * (line - 1))...(width * line)]
if out && s.length != width
setpos left + width - s.length, offset + line
else
setpos left, offset + line
end
addstr s
end
1 + lines
end
def draw_header(offset, out, name, time)
if out if out
setpos props[:width] - name.length - time.length - 1, offset setpos props[:width] - name.length - time.length - 1, offset
@ -45,25 +68,6 @@ module Widgets
addstr name addstr name
end end
end end
width = props[:width] / 3 * 2
left = out ? props[:width] - width : 0
lines = (text.length / width.to_f).ceil
1.upto lines do |line|
s = text[(width * (line - 1))...(width * line)]
if out && s.length != width
setpos left + width - s.length, offset + line
else
setpos left, offset + line
end
addstr s
end
1 + lines
end end
end end
end end