ifilter 0.2.2 → 0.2.3

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: 0934f665f7cb1e6e4965d6aba967f88187510dc3
4
- data.tar.gz: bcec824ea7f1643c85af7f158e1c0d6031051105
3
+ metadata.gz: 01696dcf09c5878f8c3ec8a42507fb0cbe5c4509
4
+ data.tar.gz: 6537d31ec9da4eb91613e65bf61cb88903f57338
5
5
  SHA512:
6
- metadata.gz: b2dbaa49a527a3657102c08a5ddd36f0ff21ae3eff802ebcc3c209202e48f3db09ebb6747660ec1fffe7f3c6a4d4e4598acb253fd9a3629b4d5ab6cca1354d29
7
- data.tar.gz: ae32bbb0278299ca5b5d85ec059d222d86f72d1d4f2d8f93f8ed32bcd4ebd1356cb22f390ad3cb73e89057e0dd344489767798c7aaa3312384f2232bd41d1654
6
+ metadata.gz: 168780c7facb09fae521aa83f92cb35cb785cee7114ad2339830ab5b92fd1407718d1fcac7204264b3e4bdcc61d06ad6575c60e40a7861c170b932c36d57a0b6
7
+ data.tar.gz: 9f9eb1baf566ff3b2e582683171c8bcd56e67b08487f26c2493863edbff864781784e02c653c24b9f60ac92e3ab569ebf045dd4efcfdf5494ebecad1f298ea8c
@@ -1,3 +1,4 @@
1
+ require 'ifilter/monospaced_string'
1
2
  require 'ifilter/window'
2
3
  require 'ifilter/client'
3
4
  require 'ifilter/input'
@@ -2,6 +2,8 @@ require 'curses'
2
2
 
3
3
  module Ifilter
4
4
  class Client
5
+ using MonospacedString
6
+
5
7
  def initialize(name)
6
8
  @prompt = "#{name}> "
7
9
  @target = []
@@ -100,7 +102,7 @@ module Ifilter
100
102
  @window << match_string
101
103
  @window.attrunset(Curses.color_pair(3))
102
104
 
103
- @window << word[match_pos + match_string.size, (@window.maxx - 1) - (match_pos + @input.size)]
105
+ @window << word[match_pos + match_string.monospaced_bytesize, (@window.maxx - 1) - (match_pos + @input.monospaced_bytesize)]
104
106
  else
105
107
  @window << word[0, @window.maxx - 1]
106
108
  end
@@ -114,7 +116,7 @@ module Ifilter
114
116
  @window.setpos(0, @window.maxx)
115
117
 
116
118
  word = "[#{@page_number}/#{max_page_number.zero? ? 1 : max_page_number}]"
117
- @window << (' ' * (@window.maxx - @prompt.size - @input.size - word.size)) + word
119
+ @window << (' ' * (@window.maxx - @prompt.monospaced_bytesize - @input.monospaced_bytesize - word.monospaced_bytesize)) + word
118
120
  end
119
121
 
120
122
  def up_cursor_position
@@ -1,5 +1,7 @@
1
1
  module Ifilter
2
2
  class Input
3
+ using MonospacedString
4
+
3
5
  attr_accessor :text
4
6
 
5
7
  def initialize(text = '')
@@ -14,6 +16,10 @@ module Ifilter
14
16
  @text.size
15
17
  end
16
18
 
19
+ def monospaced_bytesize
20
+ @text.monospaced_bytesize
21
+ end
22
+
17
23
  def backspace!
18
24
  @text.chop!
19
25
  end
@@ -0,0 +1,7 @@
1
+ module MonospacedString
2
+ refine String do
3
+ def monospaced_bytesize
4
+ self.chars.map {|c| c.bytesize == 1 ? 1 : 2 }.reduce(&:+).to_i
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Ifilter
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ifilter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaihar4
@@ -114,6 +114,7 @@ files:
114
114
  - lib/ifilter.rb
115
115
  - lib/ifilter/client.rb
116
116
  - lib/ifilter/input.rb
117
+ - lib/ifilter/monospaced_string.rb
117
118
  - lib/ifilter/version.rb
118
119
  - lib/ifilter/window.rb
119
120
  homepage: https://github.com/kaihar4/ifilter