coolline 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,7 +31,7 @@ class Coolline
31
31
  Handler.new("\C-k", &:kill_line),
32
32
  Handler.new("\C-f", &:forward_char),
33
33
  Handler.new("\C-b", &:backward_char),
34
- Handler.new("\C-d", &:kill_current_char),
34
+ Handler.new("\C-d", &:kill_current_char_or_leave),
35
35
  Handler.new("\C-c") { Process.kill(:INT, Process.pid) },
36
36
  Handler.new("\C-w", &:kill_backward_word),
37
37
  Handler.new("\C-t", &:transpose_chars),
@@ -162,11 +162,14 @@ class Coolline
162
162
  @history_index = @history.size
163
163
  @history_moved = false
164
164
 
165
+ @should_exit = false
166
+
165
167
  print "\r\e[0m\e[0K"
166
168
  print @prompt
167
169
 
168
170
  until (char = @input.getch) == "\r"
169
171
  handle(char)
172
+ return if @should_exit
170
173
 
171
174
  if @history_moved
172
175
  @history_moved = false
@@ -264,7 +267,6 @@ class Coolline
264
267
 
265
268
  # Prompts the user to search for a line
266
269
  def interactive_search
267
- initial_index = @history_index
268
270
  found_index = @history_index
269
271
 
270
272
  # Use another coolline instance for the search! :D
@@ -297,6 +299,14 @@ class Coolline
297
299
  @history_moved = true
298
300
  end
299
301
 
302
+ def kill_current_char_or_leave
303
+ if @line.empty?
304
+ @should_exit = true
305
+ else
306
+ kill_current_char
307
+ end
308
+ end
309
+
300
310
  # @return [String] The string to be completed (useful in the completion proc)
301
311
  def completed_word
302
312
  line[word_beginning_before(pos)...pos]
@@ -1,3 +1,3 @@
1
1
  class Coolline
2
- Version = "0.0.1"
2
+ Version = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coolline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riot
16
- requirement: &13926040 !ruby/object:Gem::Requirement
16
+ requirement: &23189860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *13926040
24
+ version_requirements: *23189860
25
25
  description: ! 'A readline-like library that allows to change how the input
26
26
 
27
27
  is displayed.