Archived
1
0
Fork 0

Chat formatting

This commit is contained in:
Braiden Vasco 2017-07-21 16:23:15 +00:00
parent 306913acb5
commit f4736b8ce9
2 changed files with 7 additions and 1 deletions

View file

@ -54,6 +54,8 @@ private
Curses.init_pair 3, Curses::COLOR_BLUE, Curses::COLOR_BLACK
Curses.init_pair 4, Curses::COLOR_BLACK, Curses::COLOR_BLUE
Curses.init_pair 5, Curses::COLOR_BLACK, Curses::COLOR_CYAN
Curses.init_pair 6, Curses::COLOR_CYAN, Curses::COLOR_BLACK
Curses.init_pair 7, Curses::COLOR_GREEN, Curses::COLOR_BLACK
initials
end

View file

@ -36,17 +36,21 @@ module Widgets
end
def render_message(offset, time, name, text)
Curses.attron Curses.color_pair 1
Curses.setpos y + offset, x
info_length = time.length + 1 + name.length + 2
head_length = width - info_length
head = text[0...head_length]
Curses.attron Curses.color_pair 6
Curses.addstr time
Curses.addstr ' '
Curses.attron Curses.color_pair 7
Curses.attron Curses::A_BOLD
Curses.addstr name
Curses.addstr ': '
Curses.attroff Curses::A_BOLD
Curses.attron Curses.color_pair 1
Curses.addstr head
tail_length = [0, text.length - head_length].max