twterm 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/twterm.rb +3 -1
- data/lib/twterm/app.rb +1 -0
- data/lib/twterm/extensions/string.rb +4 -0
- data/lib/twterm/filter_query_window.rb +32 -0
- data/lib/twterm/filterable_list.rb +35 -0
- data/lib/twterm/history/base.rb +5 -1
- data/lib/twterm/list.rb +4 -0
- data/lib/twterm/status.rb +1 -1
- data/lib/twterm/tab/base.rb +1 -3
- data/lib/twterm/tab/new/list.rb +13 -4
- data/lib/twterm/tab/new/search.rb +14 -5
- data/lib/twterm/tab/statuses_tab.rb +8 -39
- data/lib/twterm/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 01d68a787d82a916e9db6edf8801d3b774d70b62
|
|
4
|
+
data.tar.gz: 769b6645edd66d51ff21ae54d58a66ae8412e1dd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 668fd496ea6667035ba1a839ac308a6d92d3e76daf05b67ad5b3f685e25d7fcc52642a8a66588bc2ca8c310e9e597e82f37e81784bf492005019ebaed2435c49
|
|
7
|
+
data.tar.gz: e17fbe8226c4aa0c351d6d5d11a5d4619d54a024383f217f7e46fac255b1aebc0f90a5f5854a06690e4ec1887f3cbd63c650533bdad28714ebca583781f07aaf
|
data/lib/twterm.rb
CHANGED
|
@@ -23,6 +23,8 @@ require 'twterm/extensions/curses/window'
|
|
|
23
23
|
require 'twterm/extensions/enumerator/lazy'
|
|
24
24
|
require 'twterm/extensions/integer'
|
|
25
25
|
require 'twterm/extensions/string'
|
|
26
|
+
require 'twterm/filter_query_window'
|
|
27
|
+
require 'twterm/filterable_list'
|
|
26
28
|
require 'twterm/history/base'
|
|
27
29
|
require 'twterm/history/hashtag'
|
|
28
30
|
require 'twterm/history/screen_name'
|
|
@@ -58,6 +60,6 @@ require 'twterm/version'
|
|
|
58
60
|
|
|
59
61
|
module Twterm
|
|
60
62
|
class Conf
|
|
61
|
-
REQUIRE_VERSION = '1.0.
|
|
63
|
+
REQUIRE_VERSION = '1.0.12'
|
|
62
64
|
end
|
|
63
65
|
end
|
data/lib/twterm/app.rb
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Twterm
|
|
2
|
+
class FilterQueryWindow
|
|
3
|
+
include Curses
|
|
4
|
+
include Singleton
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@window = stdscr.subwin(1, stdscr.maxx, stdscr.maxy - 1, 0)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def input
|
|
11
|
+
clear
|
|
12
|
+
|
|
13
|
+
echo
|
|
14
|
+
stdscr.setpos(stdscr.maxy - 1, 0)
|
|
15
|
+
stdscr.addch '/'
|
|
16
|
+
|
|
17
|
+
query = getstr.chomp
|
|
18
|
+
noecho
|
|
19
|
+
|
|
20
|
+
query || ''
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def clear
|
|
24
|
+
stdscr.setpos(stdscr.maxy - 1, 0)
|
|
25
|
+
stdscr.addstr(' ' * window.maxx)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
attr_reader :window
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Twterm
|
|
2
|
+
module FilterableList
|
|
3
|
+
extend Forwardable
|
|
4
|
+
|
|
5
|
+
def filter
|
|
6
|
+
@filter_query = FilterQueryWindow.instance.input
|
|
7
|
+
|
|
8
|
+
if filter_query.empty?
|
|
9
|
+
reset_filter
|
|
10
|
+
elsif items.count == 0
|
|
11
|
+
query = filter_query
|
|
12
|
+
reset_filter
|
|
13
|
+
Notifier.instance.show_error "No matches found: \"#{query}\""
|
|
14
|
+
else
|
|
15
|
+
Notifier.instance.show_message "#{total_item_count} statuses found: \"#{filter_query}\""
|
|
16
|
+
scroller.move_to_top
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
refresh
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def filter_query
|
|
23
|
+
@filter_query ||= ''
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def items
|
|
27
|
+
fail NotImplementedError, 'items method must be implemented'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def reset_filter
|
|
31
|
+
FilterQueryWindow.instance.clear
|
|
32
|
+
@filter_query = ''
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/twterm/history/base.rb
CHANGED
data/lib/twterm/list.rb
CHANGED
data/lib/twterm/status.rb
CHANGED
data/lib/twterm/tab/base.rb
CHANGED
data/lib/twterm/tab/new/list.rb
CHANGED
|
@@ -3,6 +3,7 @@ module Twterm
|
|
|
3
3
|
module New
|
|
4
4
|
class List
|
|
5
5
|
include Base
|
|
6
|
+
include FilterableList
|
|
6
7
|
include Scrollable
|
|
7
8
|
|
|
8
9
|
@@lists = nil
|
|
@@ -12,7 +13,7 @@ module Twterm
|
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def drawable_item_count
|
|
15
|
-
(window.maxy -
|
|
16
|
+
(window.maxy - 6).div(3)
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def initialize
|
|
@@ -23,11 +24,13 @@ module Twterm
|
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def items
|
|
26
|
-
@@lists
|
|
27
|
+
(@@lists || []).select { |l| l.matches?(filter_query) }
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def respond_to_key(key)
|
|
30
31
|
case key
|
|
32
|
+
when ?d, 4
|
|
33
|
+
10.times { scroller.move_down }
|
|
31
34
|
when ?g
|
|
32
35
|
scroller.move_to_top
|
|
33
36
|
when ?G
|
|
@@ -40,6 +43,12 @@ module Twterm
|
|
|
40
43
|
TabManager.instance.switch(list_tab)
|
|
41
44
|
when ?k, 16, Curses::Key::UP
|
|
42
45
|
scroller.move_up
|
|
46
|
+
when ?q
|
|
47
|
+
reset_filter
|
|
48
|
+
when ?u, 21
|
|
49
|
+
10.times { scroller.move_up }
|
|
50
|
+
when ?/
|
|
51
|
+
filter
|
|
43
52
|
else
|
|
44
53
|
return false
|
|
45
54
|
end
|
|
@@ -47,13 +56,13 @@ module Twterm
|
|
|
47
56
|
end
|
|
48
57
|
|
|
49
58
|
def total_item_count
|
|
50
|
-
|
|
59
|
+
items.count
|
|
51
60
|
end
|
|
52
61
|
|
|
53
62
|
private
|
|
54
63
|
|
|
55
64
|
def current_list
|
|
56
|
-
@@lists.nil? ? nil :
|
|
65
|
+
@@lists.nil? ? nil : items[scroller.index]
|
|
57
66
|
end
|
|
58
67
|
|
|
59
68
|
def show_lists
|
|
@@ -4,6 +4,7 @@ module Twterm
|
|
|
4
4
|
class Search
|
|
5
5
|
include Base
|
|
6
6
|
include Readline
|
|
7
|
+
include FilterableList
|
|
7
8
|
include Scrollable
|
|
8
9
|
|
|
9
10
|
@@queries = []
|
|
@@ -13,7 +14,7 @@ module Twterm
|
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def drawable_item_count
|
|
16
|
-
(window.maxy -
|
|
17
|
+
(window.maxy - 6).div(3)
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
def initialize
|
|
@@ -53,7 +54,11 @@ module Twterm
|
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def items
|
|
56
|
-
|
|
57
|
+
if filter_query.empty?
|
|
58
|
+
['<Input search query>'] + @@queries
|
|
59
|
+
else
|
|
60
|
+
@@queries.select { |q| q.matches?(filter_query) }
|
|
61
|
+
end
|
|
57
62
|
end
|
|
58
63
|
|
|
59
64
|
def respond_to_key(key)
|
|
@@ -72,6 +77,10 @@ module Twterm
|
|
|
72
77
|
scroller.move_up
|
|
73
78
|
when ?u, 21
|
|
74
79
|
10.times { scroller.move_up }
|
|
80
|
+
when ?q
|
|
81
|
+
reset_filter
|
|
82
|
+
when ?/
|
|
83
|
+
filter
|
|
75
84
|
else
|
|
76
85
|
return false
|
|
77
86
|
end
|
|
@@ -80,7 +89,7 @@ module Twterm
|
|
|
80
89
|
end
|
|
81
90
|
|
|
82
91
|
def total_item_count
|
|
83
|
-
|
|
92
|
+
items.count
|
|
84
93
|
end
|
|
85
94
|
|
|
86
95
|
private
|
|
@@ -90,10 +99,10 @@ module Twterm
|
|
|
90
99
|
def open_search_tab_with_current_query
|
|
91
100
|
index = scroller.index
|
|
92
101
|
|
|
93
|
-
if
|
|
102
|
+
if filter_query.empty? && index.zero?
|
|
94
103
|
invoke_input
|
|
95
104
|
else
|
|
96
|
-
query =
|
|
105
|
+
query = items[index]
|
|
97
106
|
tab = Tab::SearchTab.new(query)
|
|
98
107
|
TabManager.instance.switch(tab)
|
|
99
108
|
end
|
|
@@ -2,6 +2,7 @@ module Twterm
|
|
|
2
2
|
module Tab
|
|
3
3
|
module StatusesTab
|
|
4
4
|
include Base
|
|
5
|
+
include FilterableList
|
|
5
6
|
include Scrollable
|
|
6
7
|
|
|
7
8
|
def append(status)
|
|
@@ -50,27 +51,6 @@ module Twterm
|
|
|
50
51
|
fail NotImplementedError, 'fetch method must be implemented'
|
|
51
52
|
end
|
|
52
53
|
|
|
53
|
-
def grep
|
|
54
|
-
reset_grep
|
|
55
|
-
|
|
56
|
-
Curses.echo
|
|
57
|
-
Curses.setpos(stdscr.maxy - 1, 0)
|
|
58
|
-
Curses.stdscr.addch '/'
|
|
59
|
-
@grep_query = Curses.getstr.chomp
|
|
60
|
-
Curses.noecho
|
|
61
|
-
|
|
62
|
-
if grep_query.empty?
|
|
63
|
-
reset_grep
|
|
64
|
-
elsif total_item_count == 0
|
|
65
|
-
Notifier.instance.show_error "No matches found: \"#{grep_query}\""
|
|
66
|
-
reset_grep
|
|
67
|
-
else
|
|
68
|
-
Notifier.instance.show_message "#{total_item_count} statuses found: \"#{grep_query}\""
|
|
69
|
-
scroller.move_to_top
|
|
70
|
-
refresh
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
54
|
def initialize
|
|
75
55
|
super
|
|
76
56
|
|
|
@@ -106,15 +86,6 @@ module Twterm
|
|
|
106
86
|
Tweetbox.instance.compose(highlighted_status)
|
|
107
87
|
end
|
|
108
88
|
|
|
109
|
-
def reset_grep
|
|
110
|
-
# TODO: replace with more general way (issue #170)
|
|
111
|
-
stdscr.clear
|
|
112
|
-
Screen.instance.refresh
|
|
113
|
-
|
|
114
|
-
@grep_query = ''
|
|
115
|
-
refresh
|
|
116
|
-
end
|
|
117
|
-
|
|
118
89
|
def respond_to_key(key)
|
|
119
90
|
case key
|
|
120
91
|
when ?c
|
|
@@ -146,9 +117,9 @@ module Twterm
|
|
|
146
117
|
when ?U
|
|
147
118
|
show_user
|
|
148
119
|
when ?/
|
|
149
|
-
|
|
120
|
+
filter
|
|
150
121
|
when ?q
|
|
151
|
-
|
|
122
|
+
reset_filter
|
|
152
123
|
else
|
|
153
124
|
return false
|
|
154
125
|
end
|
|
@@ -179,10 +150,10 @@ module Twterm
|
|
|
179
150
|
statuses = @status_ids.map { |id| Status.find(id) }.reject(&:nil?)
|
|
180
151
|
@status_ids = statuses.map(&:id)
|
|
181
152
|
|
|
182
|
-
if
|
|
153
|
+
if filter_query.empty?
|
|
183
154
|
statuses
|
|
184
155
|
else
|
|
185
|
-
statuses.select { |s| s.
|
|
156
|
+
statuses.select { |s| s.matches?(filter_query) }
|
|
186
157
|
end
|
|
187
158
|
end
|
|
188
159
|
|
|
@@ -191,7 +162,7 @@ module Twterm
|
|
|
191
162
|
end
|
|
192
163
|
|
|
193
164
|
def total_item_count
|
|
194
|
-
|
|
165
|
+
filter_query.empty? ? @status_ids.count : statuses.count
|
|
195
166
|
end
|
|
196
167
|
|
|
197
168
|
def update
|
|
@@ -260,15 +231,13 @@ module Twterm
|
|
|
260
231
|
end
|
|
261
232
|
|
|
262
233
|
line += 2
|
|
234
|
+
|
|
235
|
+
UserWindow.instance.update(highlighted_status.user)
|
|
263
236
|
end
|
|
264
237
|
end
|
|
265
238
|
|
|
266
239
|
private
|
|
267
240
|
|
|
268
|
-
def grep_query
|
|
269
|
-
@grep_query || ''
|
|
270
|
-
end
|
|
271
|
-
|
|
272
241
|
def highlighted_status
|
|
273
242
|
statuses[scroller.count - scroller.index - 1]
|
|
274
243
|
end
|
data/lib/twterm/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: twterm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryota Kameoka
|
|
@@ -162,6 +162,8 @@ files:
|
|
|
162
162
|
- lib/twterm/extensions/enumerator/lazy.rb
|
|
163
163
|
- lib/twterm/extensions/integer.rb
|
|
164
164
|
- lib/twterm/extensions/string.rb
|
|
165
|
+
- lib/twterm/filter_query_window.rb
|
|
166
|
+
- lib/twterm/filterable_list.rb
|
|
165
167
|
- lib/twterm/history/base.rb
|
|
166
168
|
- lib/twterm/history/hashtag.rb
|
|
167
169
|
- lib/twterm/history/screen_name.rb
|