diff --git a/lib/widgets/base.rb b/lib/widgets/base.rb index 3c5cc73..6584283 100644 --- a/lib/widgets/base.rb +++ b/lib/widgets/base.rb @@ -26,7 +26,7 @@ module Widgets end def setpos(x, y) - Curses.setpos y, x + Curses.setpos self.y + y, self.x + x end end end diff --git a/lib/widgets/chat/history.rb b/lib/widgets/chat/history.rb index 9882781..2507707 100644 --- a/lib/widgets/chat/history.rb +++ b/lib/widgets/chat/history.rb @@ -32,7 +32,7 @@ module Widgets end def draw_message(offset, time, name, text) - setpos x, y + offset + setpos 0, offset info_length = time.length + 1 + name.length + 2 head_length = width - info_length @@ -58,7 +58,7 @@ module Widgets lines = (tail_length / width.to_f).ceil 1.upto lines do |line| - setpos x, y + offset + line + setpos 0, offset + line Curses.addstr tail[(width * (line - 1))...(width * line)] end diff --git a/lib/widgets/chat/info.rb b/lib/widgets/chat/info.rb index 6716214..47104ae 100644 --- a/lib/widgets/chat/info.rb +++ b/lib/widgets/chat/info.rb @@ -13,7 +13,7 @@ module Widgets end def draw - setpos x, y + setpos 0, 0 Style.default.online_mark do Curses.addstr '[Online]' end @@ -22,7 +22,7 @@ module Widgets Curses.addstr name end - setpos x, y + 1 + setpos 0, 1 Curses.addstr 'Public key: ' Curses.addstr public_key end diff --git a/lib/widgets/menu.rb b/lib/widgets/menu.rb index b4b98d7..7703804 100644 --- a/lib/widgets/menu.rb +++ b/lib/widgets/menu.rb @@ -17,17 +17,17 @@ module Widgets def draw @logo.draw - list_y = y + @logo.height - ITEMS.each_with_index do |item, index| + item_y = @logo.height + index * 4 + Style.default.menu_item do - setpos 2, 0 + list_y + index * 4 + setpos 2, item_y + 0 Curses.addstr ' ' * (width - 4) - setpos 2, 1 + list_y + index * 4 + setpos 2, item_y + 1 Curses.addstr " #{item}".ljust width - 4 - setpos 2, 2 + list_y + index * 4 + setpos 2, item_y + 2 Curses.addstr ' ' * (width - 4) end end diff --git a/lib/widgets/menu/logo.rb b/lib/widgets/menu/logo.rb index e5b38cb..99d7b8f 100644 --- a/lib/widgets/menu/logo.rb +++ b/lib/widgets/menu/logo.rb @@ -22,7 +22,7 @@ module Widgets def draw Style.default.logo do LOGO.each_with_index do |s, index| - setpos x, y + index + setpos 0, index Curses.addstr s end end diff --git a/lib/widgets/peers/list.rb b/lib/widgets/peers/list.rb index a8ab70c..f0525d4 100644 --- a/lib/widgets/peers/list.rb +++ b/lib/widgets/peers/list.rb @@ -23,7 +23,7 @@ module Widgets items[top...(top + height)].each_with_index.each do |item, offset| index = top + offset - setpos x, y + offset + setpos 0, offset if item[:online] Style.default.online_mark do diff --git a/lib/widgets/text.rb b/lib/widgets/text.rb index 7b7c2e6..03de128 100644 --- a/lib/widgets/text.rb +++ b/lib/widgets/text.rb @@ -17,7 +17,7 @@ module Widgets cut = text[start...start + total] - setpos x, y + setpos 0, 0 before_cursor = cut[0...cursor_pos] under_cursor = cut[cursor_pos] || ' '