mini_term 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3390b9651f5aeaf92e8492f85ef061675d70b0e
4
- data.tar.gz: 83dafaec60ff3e9b117cd3e323b7c11b59123593
3
+ metadata.gz: 25b254603c56b9961a9063fe65509530337a9a01
4
+ data.tar.gz: cb1b30afa508264e0fe728ad740b4f133ca17aff
5
5
  SHA512:
6
- metadata.gz: 5646e6678a067d6de0fdfe3236bfca2be7531ca35d9a286bbac96de1717b804403751f23d2e6a6344835088de073bb7c37efb9b85ce008b29cadf9edb7febbd4
7
- data.tar.gz: 5542f74ac659a59b11cbb07c477d1fe5d3f9650a45a9e25810d036c56670ac53ce66ab340d9b6b7a68b5968362ea7b5245bcf7abb734c3f35c6833910fdd9964
6
+ metadata.gz: b304e156337c860b4da1062095b27e49fa4aef1db86dabb3a1db1cae569adb3e725d3a2c567fd5bb6699a0af5b71a208d01bdd92b80f77d1c3439d6f99cef60d
7
+ data.tar.gz: 90a7c752afd6cd5b2d5937329276c83a5217442ceecbda2b8eaf3af0470707ef2a883f125e68369bfda32a256621a10e520c100febfea1848001a19cc85eaa6c
data/README.md CHANGED
@@ -194,6 +194,9 @@ MiniTerm.raw {|self| } # Execute the block with raw mode active.
194
194
  MiniTerm.raw? # Is raw mode active now?
195
195
  ```
196
196
 
197
+ Note that raw blocks may be nested to any depth without undesirable
198
+ side-effects. Infinite recursion is, however, strongly discouraged.
199
+
197
200
  *MiniTerm.get_raw_char, etc* - These methods deal with the keyboard in a raw
198
201
  mode. They do not echo or wait for the user to press enter or any of those
199
202
  other cooked mode things. Keyboard data in the raw!
@@ -8,7 +8,7 @@ module MiniTerm
8
8
 
9
9
  #Set up the keystroke mapper.
10
10
  def initialize
11
- @map = Hash.new {|_h, key| [:unmapped, key]}
11
+ @map = Hash.new {|_h, key| [:unmapped, key + MiniTerm.flush]}
12
12
  yield self
13
13
  end
14
14
 
@@ -3,6 +3,10 @@
3
3
  # Get input from the user in raw mode. (Common Code)
4
4
  module MiniTerm
5
5
 
6
+ # Control values for flush.
7
+ FLUSH_SLEEP = 0.01
8
+ FLUSH_COUNT = 3
9
+
6
10
  # Is input raw or cooked?
7
11
  @raw_input = false
8
12
 
@@ -21,13 +25,17 @@ module MiniTerm
21
25
 
22
26
  # Flush the keyboard buffer.
23
27
  def self.flush
28
+ result = ""
29
+
24
30
  raw do |input|
25
- while input.has_raw_char?
26
- input.get_raw_char
31
+ FLUSH_COUNT.times do
32
+ sleep(FLUSH_SLEEP)
33
+ break unless input.has_raw_char?
34
+ result << input.get_raw_char
27
35
  end
28
36
  end
29
37
 
30
- self
38
+ result
31
39
  end
32
40
 
33
41
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # A simple, portable terminal interface object.
4
4
  module MiniTerm
5
- VERSION = "0.1.0".freeze
5
+ VERSION = "0.1.1".freeze
6
6
 
7
7
  DESCRIPTION = "mini_term: A portable encapsulation of the console terminal.".freeze
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_term
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PeterCamilleri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-05 00:00:00.000000000 Z
11
+ date: 2019-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler