listpager 1.0.3 → 1.0.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: 1cb09a07756c07b56bc85e800cc44c160c164c0e
4
- data.tar.gz: ccfa85c999c3b235699461e3ef78dd9e428c9a16
3
+ metadata.gz: 1a76d00d0defcb6f0059184e756d5e6c7b1c68e0
4
+ data.tar.gz: 12a88ebbf65da53305230e555d156533b1608b2d
5
5
  SHA512:
6
- metadata.gz: 7d83d8ee3ed4476a2e19e1b11a75a5233d8bd215994481a559a455bc055903355b1baa6b9f83d2d8cfe2d82d48a5e21b0e435b016d50cb7e3148da704ba3acc2
7
- data.tar.gz: 218bbe3375248ba86926f6a9244e2457acbd93e77c747c2bcf2498ee513a11dbcd686381aa95d006e0eff617dad24876c6096351b04a5d54848d60708123bb65
6
+ metadata.gz: aacf79209dc13dd433bc76df5465062f9791766dcf7a15c12270f8236d6c8721f08d03dc1b7d1e70ae910baf0e115becba852e38896ac26ea9afe684d9015647
7
+ data.tar.gz: 02efcac4125245b0c0b8f2330af64e6ff50058aea957ac7e48858d12af9eec9c1bc05c8029e51c950e10007addd6bb1a166e6bf0f93935fe9674515500711ada
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  /Gemfile.lock
4
4
  /_yardoc/
5
5
  /coverage/
6
- /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
data/README.md CHANGED
@@ -16,7 +16,10 @@ interactive mode is a specially-crafted tmux session consisting of tools that
16
16
  talk to each other. listpager is the node selection widget.
17
17
 
18
18
  So basically, you may want to `popen` listpager, print a list of somethings to
19
- its `stdin`, and listen on its `stdout`.
19
+ its `stdin`, and listen on its `stdout`. It'll go something like this:
20
+
21
+ ![socat Listpager session](/doc/netcat-example.gif?raw=true "Controlling Listpager via TCP")
22
+
20
23
 
21
24
  ```ruby
22
25
  listpager = IO.popen('listpager', 'r+')
Binary file
Binary file
@@ -2,6 +2,7 @@ require 'ncursesw'
2
2
  require 'shellwords'
3
3
  require 'optparse'
4
4
  require 'io/console'
5
+ require 'io/nonblock'
5
6
 
6
7
  require 'listpager/color'
7
8
  require 'listpager/list'
@@ -48,7 +49,7 @@ module Listpager
48
49
  def connect_list
49
50
  cterm = self
50
51
  list.define_singleton_method :on_select_change do
51
- cterm.cmd!('is-selected', selected, selected_value, observe_lock: true)
52
+ cterm.cmd!('selected-is', selected, selected_value, observe_lock: true)
52
53
  end
53
54
 
54
55
  list.define_singleton_method :on_key_press do |k|
@@ -104,6 +105,7 @@ module Listpager
104
105
  list.values = []
105
106
  list.selected = 0
106
107
  list.dirty!
108
+ wake_up
107
109
 
108
110
  when 'append'
109
111
  list.values.push(args.fetch(0))
@@ -131,12 +133,22 @@ module Listpager
131
133
  cmd! 'selected-is', list.selected, list.selected_value
132
134
  when 'set-selected'
133
135
  list.selected = args.fetch(0).to_i
134
- cmd! 'seleted-is', list.selected, list.selected_value
135
136
 
136
137
  when 'get-item'
137
138
  cmd! 'item-is', args.fetch(0), list.values[args.fetch(0).to_i]
138
139
  when 'set-item'
139
- cmd! 'item-is'
140
+ list.values[args.fetch(0).to_i] = args.fetch(1)
141
+ list.dirty!
142
+ cmd! 'item-is', args.fetch(0), list.values[args.fetch(0).to_i]
143
+ end
144
+ end
145
+
146
+ def wake_up
147
+ self_pipe[1].tap do |fd|
148
+ fd.nonblock do
149
+ fd.write('R')
150
+ fd.flush
151
+ end
140
152
  end
141
153
  end
142
154
 
@@ -226,10 +238,7 @@ module Listpager
226
238
 
227
239
  def run
228
240
  trap 'WINCH' do
229
- self_pipe[1].tap do |fd|
230
- fd.write 'R'
231
- fd.flush
232
- end
241
+ wake_up
233
242
  end
234
243
 
235
244
  begin
@@ -122,7 +122,7 @@ module Listpager
122
122
  def space_pad(s, w)
123
123
  nspaces = (w - s.size)
124
124
  nspaces = 0 if nspaces < 0
125
- s + (BLANK_SPACE * (w - s.size))
125
+ s + (BLANK_SPACE * nspaces)
126
126
  end
127
127
 
128
128
  def render_title
@@ -1,3 +1,3 @@
1
1
  module Listpager
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listpager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Owens
@@ -67,6 +67,7 @@ files:
67
67
  - Rakefile
68
68
  - bin/console
69
69
  - bin/setup
70
+ - doc/netcat-example.gif
70
71
  - doc/screenshot.png
71
72
  - exe/listpager
72
73
  - lib/listpager.rb