hobostove 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,6 +25,12 @@ module Hobostove
25
25
  end
26
26
  end
27
27
 
28
+ refresh
29
+ end
30
+
31
+ private
32
+
33
+ def refresh
28
34
  Ncurses.werase(@win)
29
35
 
30
36
  @strings.last(height - 2).each_with_index do |string, i|
@@ -0,0 +1,15 @@
1
+ module Hobostove
2
+ class UserPanel < Panel
3
+ def add_user(username)
4
+ @strings.push(username)
5
+ @strings.sort!
6
+ refresh
7
+ end
8
+
9
+ def remove_user(username)
10
+ @strings.delete(username)
11
+ @strings.sort!
12
+ refresh
13
+ end
14
+ end
15
+ end
@@ -74,9 +74,13 @@ module Hobostove
74
74
  Notify.notify username, message[:body]
75
75
  @messages_panel << "#{username}: #{message[:body]}"
76
76
  when "EnterMessage"
77
- @messages_panel << "\t#{user(message[:user_id])[:name]} joined"
77
+ username = user(message[:user_id])[:name]
78
+ @messages_panel << "\t#{username} joined"
79
+ @users_panel.add_user(username)
78
80
  when "LeaveMessage"
79
- @messages_panel << "\t#{user(message[:user_id])[:name]} left"
81
+ username = user(message[:user_id])[:name]
82
+ @messages_panel << "\t#{username} left"
83
+ @users_panel.remove_user(username)
80
84
  end
81
85
  end
82
86
 
@@ -91,7 +95,7 @@ module Hobostove
91
95
  Ncurses.cbreak
92
96
  Ncurses.noecho
93
97
 
94
- @users_panel = Panel.new(Ncurses.LINES, 20, 0, Ncurses.COLS - 20)
98
+ @users_panel = UserPanel.new(Ncurses.LINES, 20, 0, Ncurses.COLS - 20)
95
99
  @messages_panel = Panel.new(Ncurses.LINES - 3, Ncurses.COLS - 20, 0, 0, :nowrap => true)
96
100
  @message_panel = InputPanel.new(3, Ncurses.COLS - 20, Ncurses.LINES - 3, 0)
97
101
 
@@ -111,7 +115,7 @@ module Hobostove
111
115
  def load_users
112
116
  room.users.each do |user|
113
117
  @user_names << user["name"]
114
- @users_panel << user["name"]
118
+ @users_panel.add_user(user["name"])
115
119
  end
116
120
  end
117
121
 
data/lib/hobostove.rb CHANGED
@@ -8,6 +8,7 @@ require 'notify'
8
8
  require 'hobostove/configuration'
9
9
  require 'hobostove/panel'
10
10
  require 'hobostove/input_panel'
11
+ require 'hobostove/user_panel'
11
12
  require 'hobostove/window'
12
13
  require 'hobostove/setup'
13
14
  require 'hobostove/upgrade'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobostove
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-29 00:00:00.000000000 Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tinder
@@ -137,6 +137,7 @@ files:
137
137
  - lib/hobostove/room_picker.rb
138
138
  - lib/hobostove/setup.rb
139
139
  - lib/hobostove/upgrade.rb
140
+ - lib/hobostove/user_panel.rb
140
141
  - lib/hobostove/window.rb
141
142
  - lib/hobostove.rb
142
143
  - bin/hobostove