openhab-scripting 5.46.1 → 5.47.0
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.
- checksums.yaml +4 -4
- data/lib/openhab/console/irb.rb +3 -2
- data/lib/openhab/console/stdio.rb +41 -5
- data/lib/openhab/dsl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 489e56f9a2fe2f2e158736a7a03708b99a26f422f5f3640755d4270b010530fb
|
|
4
|
+
data.tar.gz: 4ccffffac019fd74bda95219dcdd0f126738da018d96f92f4f979a69171c915f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d577c0e485492f29c72662a7ec16d15d2db88851ff194f460d754162290aa173d7304959805ef3bf6295001960d2a3dcc67111a34d6e0e56afea954cc3a5a759
|
|
7
|
+
data.tar.gz: 47093891a302abe04e205584880f000664183ab1cd064a9d7eb145439b4a2bde37f3553520cf9dbf4ee86a68b3388e7d480ddac07b06f122c381bfc13ec2b9a4
|
data/lib/openhab/console/irb.rb
CHANGED
|
@@ -67,6 +67,7 @@ module OpenHAB
|
|
|
67
67
|
|
|
68
68
|
def completion_candidates(_preposing, target, _postposing, bind:)
|
|
69
69
|
return super unless defined?(OpenHAB::Core::EntityLookup)
|
|
70
|
+
return super if target.empty?
|
|
70
71
|
return super unless VALID_ENTITY_PREFIXES.include?(target[0])
|
|
71
72
|
|
|
72
73
|
this = bind.eval("self")
|
|
@@ -88,8 +89,8 @@ module OpenHAB
|
|
|
88
89
|
end
|
|
89
90
|
end
|
|
90
91
|
|
|
91
|
-
# disable Reline
|
|
92
|
-
IRB.conf[:USE_MULTILINE] = false
|
|
92
|
+
# Uncomment to disable Reline and use Readline or StdioInputMethod
|
|
93
|
+
# IRB.conf[:USE_MULTILINE] = false
|
|
93
94
|
# Uncomment to disable Readline and force StdioInputMethod
|
|
94
95
|
# IRB.conf[:USE_SINGLELINE] = false
|
|
95
96
|
|
|
@@ -39,6 +39,11 @@ module OpenHAB
|
|
|
39
39
|
|
|
40
40
|
@byte_stream = terminal.input
|
|
41
41
|
@buffer = StringIO.new.set_encoding(external_encoding)
|
|
42
|
+
@eof = false
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def eof?
|
|
46
|
+
@buffer.eof? && @eof
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
def getbyte
|
|
@@ -47,6 +52,7 @@ module OpenHAB
|
|
|
47
52
|
@buffer.truncate(0) if @buffer.eof?
|
|
48
53
|
return b
|
|
49
54
|
end
|
|
55
|
+
return nil if eof?
|
|
50
56
|
|
|
51
57
|
b = @byte_stream.read
|
|
52
58
|
return nil if b.negative?
|
|
@@ -60,6 +66,8 @@ module OpenHAB
|
|
|
60
66
|
@buffer.truncate(0) if @buffer.eof?
|
|
61
67
|
return c
|
|
62
68
|
end
|
|
69
|
+
return nil if eof?
|
|
70
|
+
|
|
63
71
|
bytes = (+"").force_encoding(Encoding::BINARY)
|
|
64
72
|
loop do
|
|
65
73
|
b = getbyte
|
|
@@ -110,7 +118,9 @@ module OpenHAB
|
|
|
110
118
|
end
|
|
111
119
|
|
|
112
120
|
def read(bytes)
|
|
113
|
-
r = readpartial(bytes)
|
|
121
|
+
r = readpartial(bytes) if !eof? || (@buffer.size - @buffer.tell).positive?
|
|
122
|
+
return nil if r.nil?
|
|
123
|
+
|
|
114
124
|
r.concat(readpartial(bytes - r.bytesize)) while r.bytesize < bytes
|
|
115
125
|
r
|
|
116
126
|
end
|
|
@@ -124,6 +134,8 @@ module OpenHAB
|
|
|
124
134
|
return r
|
|
125
135
|
end
|
|
126
136
|
|
|
137
|
+
raise EOFError, "end of file reached" if eof?
|
|
138
|
+
|
|
127
139
|
buffer = Java::byte[bytes].new
|
|
128
140
|
read = @byte_stream.read_buffered(buffer)
|
|
129
141
|
buffer = buffer[0..read] if read != bytes
|
|
@@ -134,19 +146,43 @@ module OpenHAB
|
|
|
134
146
|
def wait_readable(timeout = nil)
|
|
135
147
|
return true if (@buffer.size - @buffer.tell).positive?
|
|
136
148
|
|
|
137
|
-
|
|
149
|
+
return @byte_stream.available.positive? ? self : nil if timeout == 0 # rubocop:disable Style/NumericPredicate
|
|
150
|
+
|
|
151
|
+
timeout = timeout ? timeout * 1000 : 0
|
|
138
152
|
char = @byte_stream.read(timeout)
|
|
153
|
+
if char == -1
|
|
154
|
+
@eof = true
|
|
155
|
+
# this is not normal behavior for wait_readable, but it seems like when the SSH client
|
|
156
|
+
# disconnects, JLine just "closes" the NonBlockingPumpInputStream, and doesn't trigger
|
|
157
|
+
# any signals. On the other end, Reline just keeps calling this repetitively forever
|
|
158
|
+
# if we're at EOF, with the only way to break out to be check signals. So raise an exception
|
|
159
|
+
# here.
|
|
160
|
+
raise EOFError, "end of file reached"
|
|
161
|
+
end
|
|
139
162
|
return nil if char.negative? # timeout
|
|
140
163
|
|
|
141
164
|
ungetc(char.chr(external_encoding))
|
|
142
165
|
self
|
|
143
166
|
end
|
|
144
167
|
|
|
145
|
-
def raw(
|
|
146
|
-
previous_attributes = @terminal.
|
|
168
|
+
def raw(min: nil, time: nil, intr: nil)
|
|
169
|
+
previous_attributes = @terminal.attributes
|
|
170
|
+
new_attributes = @terminal.attributes
|
|
171
|
+
new_attributes.set_local_flags(java.util.EnumSet.of(org.jline.terminal.Attributes::LocalFlag::ICANON,
|
|
172
|
+
org.jline.terminal.Attributes::LocalFlag::ECHO,
|
|
173
|
+
org.jline.terminal.Attributes::LocalFlag::IEXTEN),
|
|
174
|
+
false)
|
|
175
|
+
new_attributes.set_local_flag(org.jline.terminal.Attributes::LocalFlag::ISIG, !!intr) # rubocop:disable Style/DoubleNegation
|
|
176
|
+
new_attributes.set_input_flags(java.util.EnumSet.of(org.jline.terminal.Attributes::InputFlag::IXON,
|
|
177
|
+
org.jline.terminal.Attributes::InputFlag::ICRNL,
|
|
178
|
+
org.jline.terminal.Attributes::InputFlag::INLCR),
|
|
179
|
+
false)
|
|
180
|
+
new_attributes.set_control_char(org.jline.terminal.Attributes::ControlChar::VMIN, min || 1)
|
|
181
|
+
new_attributes.set_control_char(org.jline.terminal.Attributes::ControlChar::VTIME, ((time || 0) * 10).to_i)
|
|
182
|
+
@terminal.attributes = new_attributes
|
|
147
183
|
yield self
|
|
148
184
|
ensure
|
|
149
|
-
@terminal.set_attributes(previous_attributes)
|
|
185
|
+
@terminal.set_attributes(previous_attributes) if previous_attributes
|
|
150
186
|
end
|
|
151
187
|
end
|
|
152
188
|
|
data/lib/openhab/dsl/version.rb
CHANGED