conquer-dzen 0.1.2 → 0.1.3
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/conquer/dzen/interaction/tooltip_listener.rb +30 -13
- data/lib/conquer/dzen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f305b9b87b16a67532e4b46cf7de063bdbab24c9
|
4
|
+
data.tar.gz: 1b1197177d069587a8b85cc579f463553bd14953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10962e1f4b4b1b48213ee608c93bd244bae611d9ac675b4f4c4d844abb4a473c7a74d2cc2b5dd71603384873df544e5fd9bbb92b51a075855f3013cf7df686b3
|
7
|
+
data.tar.gz: a98ca3c54381f41541fcab9066b536cd18ca9494e7834f9da80bcedce8c0acc681cbe2710259268213f4313b7bdebcf9761c338304035d8def47a2f61355e448
|
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'celluloid/current'
|
2
|
+
require 'conquer/dzen/positioning'
|
2
3
|
|
3
4
|
module Conquer
|
4
5
|
module Dzen
|
5
6
|
module Interaction
|
6
7
|
class TooltipListener
|
8
|
+
MARGIN = 5
|
9
|
+
|
7
10
|
include Celluloid
|
8
11
|
include Celluloid::Notifications
|
12
|
+
include Positioning
|
9
13
|
|
10
14
|
def initialize
|
11
15
|
@current_tooltip = nil
|
@@ -13,24 +17,37 @@ module Conquer
|
|
13
17
|
end
|
14
18
|
|
15
19
|
def show_tooltip(_, title, text, width = 150)
|
16
|
-
Process.kill('TERM', @current_tooltip) if @current_tooltip
|
20
|
+
Process.kill('TERM', @current_tooltip.pid) if @current_tooltip
|
21
|
+
lines = text.lines.map { |line| shift(MARGIN) { line } }
|
22
|
+
mouse = mouse_location
|
23
|
+
dzen_command = dzen_command(mouse, lines.size, width + 2 * MARGIN)
|
24
|
+
async.run_dzen(dzen_command, title, lines.join)
|
25
|
+
end
|
17
26
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
'dzen2', '-x', mouse[:x], '-y', mouse[:y], '-l', lines.to_s,
|
27
|
+
private
|
28
|
+
|
29
|
+
def dzen_command(mouse, line_count, width)
|
30
|
+
[
|
31
|
+
'dzen2', '-x', mouse[:x], '-y', mouse[:y], '-l', line_count.to_s,
|
24
32
|
'-w', width.to_s, '-e', 'onstart=uncollapse;button1=exit',
|
25
33
|
'-xs', mouse[:screen]
|
26
34
|
]
|
27
|
-
|
28
|
-
|
35
|
+
end
|
36
|
+
|
37
|
+
def run_dzen(dzen_command, title, text)
|
38
|
+
::IO.popen(dzen_command, 'w+') do |pipe|
|
39
|
+
@current_tooltip = pipe
|
40
|
+
pipe.puts title
|
41
|
+
pipe.puts text
|
42
|
+
pipe.flush
|
43
|
+
loop { sleep(100) }
|
44
|
+
end
|
45
|
+
end
|
29
46
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
47
|
+
def mouse_location
|
48
|
+
`xdotool getmouselocation`.match(
|
49
|
+
/^x:(?<x>\d+) y:(?<y>\d+) screen:(?<screen>\d+)/
|
50
|
+
)
|
34
51
|
end
|
35
52
|
end
|
36
53
|
end
|
data/lib/conquer/dzen/version.rb
CHANGED