twterm 1.1.0.beta1 → 1.1.0

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: 21bc4a036d064d1a1a4755eb3655f187ebca6514
4
- data.tar.gz: 03be117b59f4775d71aaad2fef2384f916eb4c92
3
+ metadata.gz: 6899ab95b0be06317c390cbb3a0a8638f73b1ead
4
+ data.tar.gz: 5414fbb91b92079b03f2f4f001ac49e9379357ad
5
5
  SHA512:
6
- metadata.gz: 096afbe0caffeaa8d861e8119b8f35144c93e5ff116e996c4f93c67e8e06eff3a3b9bddf46575441c3f777b222760a4867f78d48f1832773886d4a48c94a429e
7
- data.tar.gz: 29a3516e9f86141dea2b74c4b76ebafcd8f3b68cef94284809d3d17507462a6f60f4c7ba832f3df8bfc6b4129081ecd0eafcde46d26750eae493fda29613a45d
6
+ metadata.gz: b0b7bfcaa4aea696889614b2c7e804fb873c5abd25ab288093005dfcbd8e1037a05b2bb0137c26bda64fcefa60cb647c38ab6f9276e172a755345025ee9a8be7
7
+ data.tar.gz: b47ef4cb13b9c371d15287e328e7c5b1701dc10446ffd9e054af8aa8d90878d8e5b33506f7abc465d8458ba92128d16e0f24ce03b9fb100d420591e20203c75b
@@ -9,15 +9,63 @@ module Twterm
9
9
 
10
10
  def input
11
11
  clear
12
-
13
- echo
14
12
  stdscr.setpos(stdscr.maxy - 1, 0)
15
13
  stdscr.addch '/'
16
14
 
17
- query = getstr.chomp
18
- noecho
15
+ Curses.timeout = 10
16
+ raw
17
+
18
+ chars = []
19
+ str = ''
20
+
21
+ loop do
22
+ char = getch
23
+
24
+ if char.nil?
25
+ case chars.first
26
+ when 3, 27 # cancel with <C-c> / Esc
27
+ str = ''
28
+ clear
29
+ break
30
+ when 4 # cancel with <C-d> when query is empty
31
+ if str.empty?
32
+ clear
33
+ break
34
+ end
35
+ when 10 # submit with <C-j>
36
+ break
37
+ when 127 # backspace
38
+ if str.empty?
39
+ clear
40
+ break
41
+ end
42
+
43
+ str.chop!
44
+ chars = []
45
+ clear
46
+ stdscr.setpos(stdscr.maxy - 1, 0)
47
+ stdscr.addstr("/#{str}")
48
+ when 0..31
49
+ # ignore control codes (\x00 - \x1f)
50
+ else
51
+ str << chars
52
+ .map { |x| x.is_a?(String) ? x.ord : x }
53
+ .pack('c*')
54
+ .force_encoding('utf-8')
55
+ chars = []
56
+ end
57
+ else
58
+ chars << char
59
+ end
60
+
61
+ stdscr.setpos(stdscr.maxy - 1, 1)
62
+ stdscr.addstr(str)
63
+ end
64
+
65
+ Curses.timeout = 0
66
+ cbreak
19
67
 
20
- query || ''
68
+ str
21
69
  end
22
70
 
23
71
  def clear
@@ -19,26 +19,27 @@ module Twterm
19
19
  '[Q]' => 'Quit twterm'
20
20
  },
21
21
  'Tabs' => {
22
- '[h] [C-b] [LEFT]' => 'Show previous tab',
23
- '[l] [C-f] [RIGHT]' => 'Show next tab',
24
- '[N]' => 'Open new tab',
22
+ '[h] [C-b] [LEFT]' => 'Previous tab',
23
+ '[l] [C-f] [RIGHT]' => 'Next tab',
24
+ '[N]' => 'New tab',
25
25
  '[C-R]' => 'Reload',
26
26
  '[w]' => 'Close tab',
27
- '[q]' => 'Quit filtering mode',
28
- '[/]' => 'Filter items in tab'
27
+ '[q]' => 'Quit filter mode',
28
+ '[/]' => 'Filter mode'
29
29
  },
30
30
  'Tweets' => {
31
- '[D]' => 'Delete tweet',
31
+ '[c]' => 'Conversation',
32
+ '[D]' => 'Delete',
32
33
  '[F]' => 'Add to favorite',
33
- '[n]' => 'Compose new tweet',
34
- '[o]' => 'Open URLs in tweet',
34
+ '[n]' => 'New tweet',
35
+ '[o]' => 'Open URLs',
35
36
  '[r]' => 'Reply',
36
37
  '[R]' => 'Retweet',
37
- '[U]' => 'Show user'
38
+ '[U]' => 'User'
38
39
  },
39
40
  'Others' => {
40
- '[P]' => 'View my profile',
41
- '[?]' => 'Open key assignments cheatsheet'
41
+ '[P]' => 'My profile',
42
+ '[?]' => 'Key assignments cheatsheet'
42
43
  }
43
44
  }
44
45
 
@@ -48,7 +49,7 @@ module Twterm
48
49
 
49
50
  def initialize
50
51
  super
51
- scroller.set_cursor_free!
52
+ scroller.set_no_cursor_mode!
52
53
  end
53
54
 
54
55
  def respond_to_key(key)
@@ -43,14 +43,14 @@ module Twterm
43
43
  index == offset + i
44
44
  end
45
45
 
46
- def cursor_free?
47
- !!@cursor_free
46
+ def no_cursor_mode?
47
+ !!@no_cursor_mode
48
48
  end
49
49
 
50
50
  def initialize
51
51
  @index = 0
52
52
  @offset = 0
53
- @cursor_free_mode = false
53
+ @no_cursor_mode = false
54
54
  end
55
55
 
56
56
  def drawable_items
@@ -73,7 +73,7 @@ module Twterm
73
73
  # return when there are no items or cursor is at the bottom
74
74
 
75
75
  @index += 1
76
- @offset += 1 if (cursor_free? || cursor_on_the_downside?) && !last_item_shown?
76
+ @offset += 1 if (no_cursor_mode? || cursor_on_the_downside?) && !last_item_shown?
77
77
 
78
78
  hook :after_move
79
79
  end
@@ -132,8 +132,8 @@ module Twterm
132
132
  true
133
133
  end
134
134
 
135
- def set_cursor_free!
136
- @cursor_free = true
135
+ def set_no_cursor_mode!
136
+ @no_cursor_mode = true
137
137
  end
138
138
 
139
139
  private
@@ -69,6 +69,8 @@ module Twterm
69
69
  status = highlighted_status
70
70
  urls = status.urls.map(&:expanded_url) + status.media.map(&:expanded_url)
71
71
  urls.each(&Launchy.method(:open))
72
+ rescue Launchy::CommandNotFoundError
73
+ Notifier.instance.show_error 'Cannot find web browser'
72
74
  end
73
75
 
74
76
  def prepend(status)
@@ -1,3 +1,3 @@
1
1
  module Twterm
2
- VERSION = '1.1.0.beta1'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twterm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.beta1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Kameoka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-09 00:00:00.000000000 Z
11
+ date: 2015-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -223,9 +223,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
223
  version: 2.1.0
224
224
  required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  requirements:
226
- - - ">"
226
+ - - ">="
227
227
  - !ruby/object:Gem::Version
228
- version: 1.3.1
228
+ version: '0'
229
229
  requirements: []
230
230
  rubyforge_project:
231
231
  rubygems_version: 2.4.7