muby 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ require 'ncurses'
4
4
  module Muby
5
5
 
6
6
 
7
- VERSION = "0.7.1" unless defined?(Muby::VERSION)
7
+ VERSION = "0.7.2" unless defined?(Muby::VERSION)
8
8
 
9
9
  #
10
10
  # The class that encapsulates all configuration.
@@ -7,24 +7,29 @@ module Muby
7
7
  execute_with_verbosity(:debug, command, *args)
8
8
  end
9
9
 
10
+ def do_execute(command, *args)
11
+ result = nil
12
+ if Proc === command
13
+ result = command.call(*args[0...(command.arity)])
14
+ elsif String === command
15
+ result = eval(command)
16
+ elsif Symbol === command
17
+ method = self.method(command)
18
+ args = args[0...(method.arity)]
19
+ result = method.call(*args)
20
+ elsif Array === command
21
+ method = self.method(command.first)
22
+ args = (command[1..-1] + args)[0...(method.arity)]
23
+ result = method.call(*args)
24
+ else
25
+ result = command
26
+ end
27
+ result
28
+ end
29
+
10
30
  def execute_with_verbosity(verbosity, command, *args)
11
31
  begin
12
- result = nil
13
- if Proc === command
14
- result = command.call(*args[0...(command.arity)])
15
- elsif String === command
16
- result = eval(command)
17
- elsif Symbol === command
18
- method = self.method(command)
19
- args = args[0...(method.arity)]
20
- result = method.call(*args)
21
- elsif Array === command
22
- method = self.method(command.first)
23
- args = (command[1..-1] + args)[0...(method.arity)]
24
- result = method.call(*args)
25
- else
26
- result = command
27
- end
32
+ result = do_execute(command, *args)
28
33
  unless result.nil?
29
34
  case result
30
35
  when String
@@ -32,6 +32,17 @@ class Muby::InputWindow
32
32
  # Start working!
33
33
  #
34
34
  def go
35
+ # Ensure our size is calculable
36
+ begin
37
+ height
38
+ width
39
+ top
40
+ left
41
+ rescue Exception => e
42
+ Ncurses.endwin
43
+ raise "Unable to calculate input window geometry: #{e}\n\nCheck your config file (#{conf.loaded_rc_file}) for errors in 'conf.input_window_geometry!\n\n"
44
+ end
45
+
35
46
  # Init all the default values
36
47
  @buffer = ""
37
48
  @cursorPosition = 0
@@ -43,6 +54,12 @@ class Muby::InputWindow
43
54
  @recent_escape = []
44
55
  @handle_mode = :append_buffer!
45
56
 
57
+ resize!
58
+
59
+ help unless conf.user_edited_config_file
60
+ end
61
+
62
+ def resize!
46
63
  # Init the input box
47
64
  @inputBorder = Ncurses.newwin(height, width, top, left)
48
65
  @inputBorder.box(0,0)
@@ -55,31 +72,26 @@ class Muby::InputWindow
55
72
  @inputWindow.scrollok(true)
56
73
  @inputWindow.nodelay(true)
57
74
  @inputWindow.refresh
58
-
59
- help unless conf.user_edited_config_file
60
75
  end
61
76
 
62
77
  def reload!
63
- @left = nil
64
- @top = nil
65
- @width = nil
66
- @height = nil
78
+ do_startup_triggers
67
79
  end
68
80
 
69
81
  def left
70
- @left ||= execute_with_verbosity(:trace, conf.input_window_geometry[:left])
82
+ do_execute(conf.input_window_geometry[:left])
71
83
  end
72
84
 
73
85
  def top
74
- @top ||= execute_with_verbosity(:trace, conf.input_window_geometry[:top])
86
+ do_execute(conf.input_window_geometry[:top])
75
87
  end
76
88
 
77
89
  def width
78
- @width ||= execute_with_verbosity(:trace, conf.input_window_geometry[:width])
90
+ do_execute(conf.input_window_geometry[:width])
79
91
  end
80
92
 
81
93
  def height
82
- @height ||= execute_with_verbosity(:trace, conf.input_window_geometry[:height])
94
+ do_execute(conf.input_window_geometry[:height])
83
95
  end
84
96
 
85
97
  #
@@ -159,20 +171,25 @@ class Muby::InputWindow
159
171
  end
160
172
  end
161
173
 
174
+ def do_startup_triggers
175
+ conf.startup_triggers.each do |trigger|
176
+ execute(trigger, self, Muby::OutputWindow.get_instance)
177
+ end
178
+ end
179
+
162
180
  #
163
181
  # Just keep listening to the keyboard input.
164
182
  #
165
183
  def process
166
184
  loadHistory
167
- conf.startup_triggers.each do |trigger|
168
- execute(trigger, self, Muby::OutputWindow.get_instance)
169
- end
185
+ do_startup_triggers
170
186
  # We need to check one key at a time due to triggers and conf.key_commands
171
187
  while c = @inputWindow.wgetch
172
188
  if c == Ncurses.const_get("ERR")
173
189
  sleep(0.01)
174
190
  else
175
191
  handle(c, conf.key_commands)
192
+ update
176
193
  end
177
194
  end # while c = @inputWindow.wgetch
178
195
  end # def process
@@ -28,6 +28,17 @@ class Muby::OutputWindow
28
28
  # Start working!
29
29
  #
30
30
  def go
31
+ # Ensure our size is calculable
32
+ begin
33
+ height
34
+ width
35
+ top
36
+ left
37
+ rescue Exception => e
38
+ Ncurses.endwin
39
+ raise "Unable to calculate output window geometry: #{e}\n\nCheck your config file (#{conf.loaded_rc_file}) for errors in 'conf.output_window_geometry!\n\n"
40
+ end
41
+
31
42
  @scrollback = 0
32
43
  @waitBuffer = []
33
44
  @lines = 0
@@ -47,27 +58,24 @@ class Muby::OutputWindow
47
58
  @ready = true
48
59
  end
49
60
 
50
- def reload!
51
- @left = nil
52
- @top = nil
53
- @width = nil
54
- @height = nil
61
+ def resize!
62
+ refresh
55
63
  end
56
64
 
57
65
  def left
58
- @left ||= execute_with_verbosity(:trace, conf.output_window_geometry[:left])
66
+ do_execute(conf.output_window_geometry[:left])
59
67
  end
60
68
 
61
69
  def top
62
- @top ||= execute_with_verbosity(:trace, conf.output_window_geometry[:top])
70
+ do_execute(conf.output_window_geometry[:top])
63
71
  end
64
72
 
65
73
  def width
66
- @width ||= execute_with_verbosity(:trace, conf.output_window_geometry[:width])
74
+ do_execute(conf.output_window_geometry[:width])
67
75
  end
68
76
 
69
77
  def height
70
- @height ||= execute_with_verbosity(:trace, conf.output_window_geometry[:height])
78
+ do_execute(conf.output_window_geometry[:height])
71
79
  end
72
80
 
73
81
  def show_version
@@ -41,7 +41,7 @@ configuration file.
41
41
  (Then, you could type /help or press F1 to get the help text again)
42
42
 
43
43
  The configuration file the system has tried to create for you
44
- is at #{conf.loaded_rc_file}.
44
+ is at #{File.expand_path(conf.loaded_rc_file)}.
45
45
  ENDTEXT
46
46
  info help
47
47
  end
@@ -229,10 +229,15 @@ ENDTEXT
229
229
  end
230
230
  nil
231
231
  end
232
+
233
+ def resize_application!
234
+ Muby::OutputWindow.get_instance.resize!
235
+ Muby::InputWindow.get_instance.resize!
236
+ end
232
237
 
233
238
  def reload_application!
239
+ resize_application!
234
240
  conf.reload_application!
235
- Muby::OutputWindow.get_instance.reload!
236
241
  Muby::InputWindow.get_instance.reload!
237
242
  end
238
243
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: muby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.1
7
- date: 2007-10-19 00:00:00 +02:00
6
+ version: 0.7.2
7
+ date: 2007-10-20 00:00:00 +02:00
8
8
  summary: A simple but powerful mud client.
9
9
  require_paths:
10
10
  - lib