muby 0.7.8 → 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/muby/configuration.rb +3 -1
- data/lib/muby/connection.rb +60 -33
- data/lib/muby/help.rb +1 -0
- metadata +12 -11
data/lib/muby/configuration.rb
CHANGED
@@ -4,7 +4,7 @@ require 'ncurses'
|
|
4
4
|
module Muby
|
5
5
|
|
6
6
|
|
7
|
-
VERSION = "0.7.
|
7
|
+
VERSION = "0.7.9" unless defined?(Muby::VERSION)
|
8
8
|
|
9
9
|
#
|
10
10
|
# The class that encapsulates all configuration.
|
@@ -50,6 +50,8 @@ module Muby
|
|
50
50
|
:width => "Ncurses.COLS",
|
51
51
|
:height => "conf.input_height + 2"
|
52
52
|
}
|
53
|
+
|
54
|
+
@single_shot_gags = []
|
53
55
|
|
54
56
|
@echo_keycodes = false
|
55
57
|
|
data/lib/muby/connection.rb
CHANGED
@@ -86,6 +86,31 @@ class Muby::Connection
|
|
86
86
|
exception(e)
|
87
87
|
end
|
88
88
|
end
|
89
|
+
returnValue = true if single_shot_gag(matchBuffer)
|
90
|
+
returnValue
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# Check if we want to gag the current matchBuffer with the single shot gags and debug about it.
|
95
|
+
# Remove all matching gags, and all gags producing regexp errors.
|
96
|
+
#
|
97
|
+
def single_shot_gag(matchBuffer)
|
98
|
+
returnValue = false
|
99
|
+
new_gags = []
|
100
|
+
conf.single_shot_gags.each do |gag|
|
101
|
+
this_gag_matched = false
|
102
|
+
begin
|
103
|
+
if matchBuffer.match(gag)
|
104
|
+
trace(matchBuffer + " matches " + gag.inspect + ": gag active (but only once)")
|
105
|
+
returnValue = true
|
106
|
+
this_gag_matched = true
|
107
|
+
end
|
108
|
+
rescue RegexpError => error
|
109
|
+
exception(e)
|
110
|
+
end
|
111
|
+
new_gags << gag unless this_gag_matched
|
112
|
+
end
|
113
|
+
conf.single_shot_gags = new_gags
|
89
114
|
returnValue
|
90
115
|
end
|
91
116
|
|
@@ -144,12 +169,6 @@ class Muby::Connection
|
|
144
169
|
nil
|
145
170
|
end
|
146
171
|
|
147
|
-
def getc
|
148
|
-
c = @socket.getc
|
149
|
-
log_input(c.chr) if c
|
150
|
-
c
|
151
|
-
end
|
152
|
-
|
153
172
|
unless defined?(TELNET_COMMANDS)
|
154
173
|
TELNET_COMMANDS = {
|
155
174
|
240 => :end_of_sub_negotiation,
|
@@ -166,19 +185,13 @@ class Muby::Connection
|
|
166
185
|
}
|
167
186
|
end
|
168
187
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
# Then check it for triggers.
|
174
|
-
#
|
175
|
-
def handle_regular_character(c)
|
176
|
-
@matchBuffer = @matchBuffer + c.chr
|
177
|
-
append_show_buffer(c.chr)
|
178
|
-
manage_buffers(c)
|
188
|
+
def getc
|
189
|
+
c = @socket.getc
|
190
|
+
log_input(c.chr) if c
|
191
|
+
c
|
179
192
|
end
|
180
193
|
|
181
|
-
def
|
194
|
+
def process(c)
|
182
195
|
#
|
183
196
|
# The telnet support (just so we dont explode or something)
|
184
197
|
#
|
@@ -214,6 +227,7 @@ class Muby::Connection
|
|
214
227
|
warn("Got an unknown TELNET command (#{c.chr}) which I don't know how to handle. Expect strange behaviour...")
|
215
228
|
end
|
216
229
|
end
|
230
|
+
return nil
|
217
231
|
elsif c == 27 # escape char! this is probably some ANSI color or shite
|
218
232
|
c = getc
|
219
233
|
if c.chr == "[" # this is an ansi-something that is more than one char long
|
@@ -287,17 +301,19 @@ class Muby::Connection
|
|
287
301
|
@showBuffer.push(style)
|
288
302
|
end
|
289
303
|
end
|
304
|
+
return nil
|
290
305
|
elsif !conf.broken_keycodes.include?(c)
|
291
|
-
|
306
|
+
return c
|
292
307
|
end
|
293
308
|
end
|
294
309
|
|
295
|
-
def
|
310
|
+
def append_buffers(c)
|
296
311
|
if String === @showBuffer.last
|
297
|
-
@showBuffer.last << c
|
312
|
+
@showBuffer.last << c.chr
|
298
313
|
else
|
299
|
-
@showBuffer << c
|
314
|
+
@showBuffer << c.chr
|
300
315
|
end
|
316
|
+
@matchBuffer = @matchBuffer + c.chr
|
301
317
|
end
|
302
318
|
|
303
319
|
#
|
@@ -305,11 +321,29 @@ class Muby::Connection
|
|
305
321
|
#
|
306
322
|
def listen
|
307
323
|
c = true
|
308
|
-
#
|
324
|
+
# While we get characters
|
309
325
|
while c
|
326
|
+
# While we have something to read within one second
|
310
327
|
while select([@socket],nil,nil,1) && c = getc
|
311
|
-
|
328
|
+
# If it is a regular character
|
329
|
+
if regular_char = process(c)
|
330
|
+
# Append it to our match and show buffers
|
331
|
+
append_buffers(regular_char)
|
332
|
+
# Trigger all remote character triggers on it
|
333
|
+
trigger(@matchBuffer, conf.remote_character_triggers, true)
|
334
|
+
# If it is a newline
|
335
|
+
if regular_char == 10
|
336
|
+
# Trigger all normal remote triggers on it
|
337
|
+
run_remote_triggers
|
338
|
+
display_buffer
|
339
|
+
@matchBuffer = ""
|
340
|
+
end
|
341
|
+
end
|
312
342
|
end
|
343
|
+
trigger(@matchBuffer, conf.remote_character_triggers, true)
|
344
|
+
run_remote_triggers
|
345
|
+
display_buffer if conf.flush
|
346
|
+
@matchBuffer = ""
|
313
347
|
end
|
314
348
|
status("Connection closed by remote end")
|
315
349
|
@inputWindow.disconnect
|
@@ -326,16 +360,9 @@ class Muby::Connection
|
|
326
360
|
end
|
327
361
|
end
|
328
362
|
|
329
|
-
def
|
330
|
-
trigger(@matchBuffer, conf.
|
331
|
-
|
332
|
-
display_buffer
|
333
|
-
if c == 10
|
334
|
-
trigger(@matchBuffer, conf.remote_triggers, false)
|
335
|
-
@matchBuffer = ""
|
336
|
-
@used_triggers = {}
|
337
|
-
end
|
338
|
-
end
|
363
|
+
def run_remote_triggers
|
364
|
+
trigger(@matchBuffer, conf.remote_triggers, false)
|
365
|
+
@used_triggers = {}
|
339
366
|
end
|
340
367
|
|
341
368
|
def homemade_split(s, r)
|
data/lib/muby/help.rb
CHANGED
@@ -4,6 +4,7 @@ module Muby
|
|
4
4
|
def self.configuration
|
5
5
|
{
|
6
6
|
:connect_timeout => "The number of seconds we will try to connect before giving up.",
|
7
|
+
:single_shot_gags => "The gags that will only be used once and then discarded. Usually created by triggers.",
|
7
8
|
:feed_completer_with_history => "If true, the completion command will use history to calculate possible completions.",
|
8
9
|
:feed_completer_with_input => "If true, the completion command will use everything seen from the remote end to calculate possible completions.",
|
9
10
|
:extra_completions => "Fill this array with words that you allways want to be able to complete to.",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Kihlgren, Sy Ali
|
@@ -9,11 +9,12 @@ autorequire: muby
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-09-27 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ncurses
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -30,20 +31,21 @@ extensions: []
|
|
30
31
|
extra_rdoc_files: []
|
31
32
|
|
32
33
|
files:
|
34
|
+
- lib/muby/completer.rb
|
35
|
+
- lib/muby/configuration.rb
|
33
36
|
- lib/muby/connection.rb
|
37
|
+
- lib/muby/displayer.rb
|
38
|
+
- lib/muby/help.rb
|
39
|
+
- lib/muby/inputwindow.rb
|
34
40
|
- lib/muby/logger.rb
|
41
|
+
- lib/muby/outputwindow.rb
|
35
42
|
- lib/muby/style.rb
|
36
43
|
- lib/muby/user_methods.rb
|
37
|
-
- lib/muby/helper_methods.rb
|
38
44
|
- lib/muby/application.rb
|
45
|
+
- lib/muby/helper_methods.rb
|
39
46
|
- lib/muby/user_window.rb
|
40
|
-
- lib/muby/configuration.rb
|
41
|
-
- lib/muby/inputwindow.rb
|
42
|
-
- lib/muby/help.rb
|
43
|
-
- lib/muby/outputwindow.rb
|
44
|
-
- lib/muby/completer.rb
|
45
|
-
- lib/muby/displayer.rb
|
46
47
|
- lib/muby.rb
|
48
|
+
- contrib/sy/cce.rb
|
47
49
|
- contrib/aardmud.org_4000/aliases/aard-aliases.rb
|
48
50
|
- contrib/aardmud.org_4000/gags/aard-gags.rb
|
49
51
|
- contrib/aardmud.org_4000/speedwalks/aard-sw-areas-vidblain.rb
|
@@ -64,7 +66,6 @@ files:
|
|
64
66
|
- contrib/aardmud.org_4000/misc/aard_consider_substitutions.rb
|
65
67
|
- contrib/aardmud.org_4000/aard-helpers.rb
|
66
68
|
- contrib/aardmud.org_4000/aard-config.rb
|
67
|
-
- contrib/sy/cce.rb
|
68
69
|
- contrib/aardmud.org_4000/README.txt
|
69
70
|
- LICENSE
|
70
71
|
has_rdoc: true
|
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
91
|
requirements: []
|
91
92
|
|
92
93
|
rubyforge_project:
|
93
|
-
rubygems_version: 1.
|
94
|
+
rubygems_version: 1.2.0
|
94
95
|
signing_key:
|
95
96
|
specification_version: 2
|
96
97
|
summary: A simple but powerful mud client.
|