From f4736b8ce9abc9ea603e18d1913bd9d02c947193 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Fri, 21 Jul 2017 16:23:15 +0000 Subject: [PATCH] Chat formatting --- lib/main.rb | 2 ++ lib/widgets/chat.rb | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/main.rb b/lib/main.rb index e8e7ade..ff1e306 100644 --- a/lib/main.rb +++ b/lib/main.rb @@ -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 diff --git a/lib/widgets/chat.rb b/lib/widgets/chat.rb index f7e4650..36fcfce 100644 --- a/lib/widgets/chat.rb +++ b/lib/widgets/chat.rb @@ -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