djinni 1.3.3 → 1.3.4

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: 71ee1bc94a4982ddbece72b9a7095e0a5dbdf216
4
- data.tar.gz: a706d2c5fb5adfb3140139ebf2d6bee1cfa2ec7a
3
+ metadata.gz: 91e0e374025777f899f2842312e3330505070933
4
+ data.tar.gz: 01b5498b5360fd208d5f6ccd64d0dc4741904704
5
5
  SHA512:
6
- metadata.gz: b9eccaeb168de034599d6f3f0d058e1ce4b0c8d9e19c8eb0e1c953edac7c189d7f141a173d2b7b04d828dc052b28697ca25cb3d3ca69a43dfdebd4d3ef066e2c
7
- data.tar.gz: 31610e7bd01dc4fb18b18a7bd07be78023cd2712aa1b3747a13facd2fd8d6faff6a3c6315c553a7f59ffed49c38a7b37f9e11dae554a213c9f9e7306f7fc647d
6
+ metadata.gz: d34084799f17961d09785517aa0f6311ae8d17e1216cdf566c9bb17ab22408fdd90c75aa172c71df98b94cc1140658fcb99ad8d084fb4fdaf9a2109495331584
7
+ data.tar.gz: 4a2cbea7d9b71be603d7d073531477f9c4e2bf608238e045e1176736b5e6fcb339a911c372c9687aeed578d85b1045a447026c5dffa35050c6305fb5700afd3c
@@ -30,6 +30,7 @@ class Djinni
30
30
  wish = @wishes[name]
31
31
  complete = ""
32
32
  begin
33
+ djinni_env["djinni_input"] = input
33
34
  complete = wish.tab_complete(args, djinni_env)
34
35
  rescue SystemExit => e
35
36
  raise e
@@ -57,6 +58,7 @@ class Djinni
57
58
  @wishes.sort.map do |aliaz, wish|
58
59
  if (aliaz == name)
59
60
  begin
61
+ djinni_env["djinni_input"] = input
60
62
  wish.execute(args, djinni_env)
61
63
  rescue SystemExit => e
62
64
  raise e
@@ -142,14 +144,16 @@ class Djinni
142
144
  @interactive = true
143
145
 
144
146
  djinni_env["djinni_prompt"] = djinni_prompt
147
+ prev_len = 0
145
148
  buff = ""
146
149
  loop do
147
150
  djinni_prompt = djinni_env["djinni_prompt"]
148
151
  blank_line = Array.new(@width, " ").join
149
- fill_len = @width - djinni_prompt.length - buff.length + 1
150
152
 
151
- # Handle long line-wrapped prompts
152
- lines = (djinni_prompt.length + buff.length) / @width
153
+ # Handle long lines that get wrapped
154
+ buff_len = remove_colors(djinni_prompt).length + prev_len
155
+ lines = buff_len / @width
156
+ lines -= 1 if ((buff_len % @width) == 0)
153
157
  lines.times do
154
158
  print "\r#{blank_line}"
155
159
  print "\e[F"
@@ -170,6 +174,7 @@ class Djinni
170
174
  end
171
175
  end
172
176
  system("stty -raw echo")
177
+ prev_len = remove_colors(buff).length
173
178
  buff = grant_wish(buff + input, djinni_env)
174
179
 
175
180
  if (buff.nil?)
@@ -184,6 +189,11 @@ class Djinni
184
189
  end
185
190
  end
186
191
 
192
+ def remove_colors(str)
193
+ str.unpack("C*").pack("U*").gsub(/\e\[([0-9;]*m|K)/, "")
194
+ end
195
+ private :remove_colors
196
+
187
197
  def store_history(input)
188
198
  # Only keep newest wish if repeat
189
199
  # @history.delete(input)
@@ -1,5 +1,3 @@
1
- require "djinni/error.rb"
2
-
3
1
  class Djinni::Error::UnknownWishError < Djinni::Error
4
2
  def initialize(clas = "")
5
3
  super("Unknown wish class #{clas}!")
@@ -1,5 +1,3 @@
1
- require "djinni"
2
-
3
1
  class Djinni::Wish::Help < Djinni::Wish
4
2
  def aliases
5
3
  return [ "?", "help" ]
@@ -1,5 +1,3 @@
1
- require "djinni"
2
-
3
1
  class Djinni::Wish::History < Djinni::Wish
4
2
  def aliases
5
3
  return [ "hist", "history" ]
@@ -1,5 +1,3 @@
1
- require "djinni"
2
-
3
1
  class Djinni::Wish::Quit < Djinni::Wish
4
2
  def aliases
5
3
  return [ "bye", "exit", "q", "quit" ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: djinni
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -59,7 +59,7 @@ dependencies:
59
59
  version: '0.1'
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 0.1.1
62
+ version: 0.1.2
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -69,7 +69,7 @@ dependencies:
69
69
  version: '0.1'
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 0.1.1
72
+ version: 0.1.2
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: ruby-terminfo
75
75
  requirement: !ruby/object:Gem::Requirement