hail.rb 2015.10.12.00.44 → 2015.10.13.02.41
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/hail/account.rb +7 -2
- data/lib/hail/gui.rb +56 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08aaebc776997e8e93d0fa92e3121430bafd4acf
|
4
|
+
data.tar.gz: b9942bc062494a03c52e8ac3c6b0c10b0726d474
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8934a534651a1b9bf655f386cb1d4e0e9e102b95fd53d635c065a11711ba86888209f6a20e4de827d9f7654028c87c6444ab76b344529c19701f3346c50fbe80
|
7
|
+
data.tar.gz: b2a81bce737c9ccec3e531a7b4f71fa4297c688da072ddb4127f526b4fc1cbb718b5881f8338ef754976015aa8808355427c64a0b895fbab4a95d65b688b57d3
|
data/lib/hail/account.rb
CHANGED
@@ -15,10 +15,15 @@ class Hail::Account
|
|
15
15
|
|
16
16
|
|
17
17
|
list = {name: [], subject: [], date: []}
|
18
|
+
|
19
|
+
list.each do |v|
|
20
|
+
v.hg_style = {selectable: true}
|
21
|
+
end
|
22
|
+
|
18
23
|
@imap.sort(["REVERSE", "SUBJECT"], ["ALL"], "US-ASCII").each do |message_id|
|
19
24
|
envelope = @imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
|
20
|
-
list[:name] << Hail::Mail.header_readable(envelope.from[0].name)
|
21
|
-
list[:subject] << Hail::Mail.header_readable(envelope.subject)
|
25
|
+
list[:name] << Hail::Mail.header_readable(envelope.from[0].name).to_s
|
26
|
+
list[:subject] << Hail::Mail.header_readable(envelope.subject).to_s
|
22
27
|
|
23
28
|
date = @imap.fetch(message_id, "INTERNALDATE")[0].attr["INTERNALDATE"]
|
24
29
|
date = DateTime.parse(date)
|
data/lib/hail/gui.rb
CHANGED
@@ -7,6 +7,8 @@ class Hail::GUI
|
|
7
7
|
@buffer = []
|
8
8
|
@render_buffer = 0
|
9
9
|
Curses.init_screen()
|
10
|
+
@win = Curses::Window.new(0, 0, 0, 0)
|
11
|
+
win.keypad true
|
10
12
|
end
|
11
13
|
|
12
14
|
def win
|
@@ -14,13 +16,11 @@ class Hail::GUI
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def render
|
17
|
-
@win = Curses::Window.new(0, 0, 0, 0)
|
18
19
|
area = {height: win.maxy, width: win.maxx, top: 0, left: 0}
|
19
|
-
|
20
20
|
win.clear
|
21
21
|
@buffer[@render_buffer].to_hg(area) if not @buffer[@render_buffer].nil?
|
22
22
|
win.refresh
|
23
|
-
win.getch
|
23
|
+
@buffer[@render_buffer].__hg_getch(win.getch)
|
24
24
|
end
|
25
25
|
|
26
26
|
def buffer=(buffer)
|
@@ -34,6 +34,16 @@ class Hail::GUI
|
|
34
34
|
end
|
35
35
|
|
36
36
|
class Hash
|
37
|
+
def hg_style=(style)
|
38
|
+
@__hg_style = style
|
39
|
+
end
|
40
|
+
|
41
|
+
def __hg_getch(ch)
|
42
|
+
self.each do |k,v|
|
43
|
+
v.__hg_getch(ch)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
37
47
|
def to_hg(area)
|
38
48
|
width = area[:width] / self.length
|
39
49
|
i = 0
|
@@ -44,6 +54,7 @@ class Hash
|
|
44
54
|
|
45
55
|
#List
|
46
56
|
subarea = {height: area[:height], width: i+1*width, top: area[:top] + header.__hg_height, left: area[:left]+(i*width)}
|
57
|
+
v.hg_style = {selectable: true}
|
47
58
|
v.to_hg(subarea)
|
48
59
|
i += 1
|
49
60
|
end
|
@@ -51,27 +62,49 @@ class Hash
|
|
51
62
|
end
|
52
63
|
|
53
64
|
class Array
|
65
|
+
def hg_style=(style)
|
66
|
+
@__hg_style = style
|
67
|
+
end
|
68
|
+
|
69
|
+
def __hg_getch(ch)
|
70
|
+
@__hg_selector = 0 if @__hg_selector.nil?
|
71
|
+
case ch
|
72
|
+
when Curses::KEY_UP
|
73
|
+
@__hg_selector -= 1
|
74
|
+
when Curses::KEY_DOWN
|
75
|
+
@__hg_selector += 1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
54
79
|
def __hg_height
|
55
80
|
height = 0
|
56
81
|
self.each do |v|
|
57
|
-
height += v.__hg_height
|
82
|
+
height += v.__hg_height
|
58
83
|
end
|
59
84
|
height
|
60
85
|
end
|
61
86
|
|
62
87
|
def to_hg(area)
|
88
|
+
@__hg_selector = 0 if @__hg_selector.nil?
|
89
|
+
@__hg_style = {} if @__hg_style.nil?
|
63
90
|
top = area[:top]
|
64
|
-
|
91
|
+
|
92
|
+
self.each_with_index do |v,k|
|
65
93
|
subarea = {height: area[:height]-top, width: area[:width], top: top, left: area[:left]}
|
66
|
-
if
|
67
|
-
v.
|
68
|
-
top = top + v.__hg_height
|
94
|
+
if @__hg_style[:selectable]
|
95
|
+
v.hg_style = {strong: (@__hg_selector == k)}
|
69
96
|
end
|
97
|
+
v.to_hg(subarea)
|
98
|
+
top = top + v.__hg_height
|
70
99
|
end
|
71
100
|
end
|
72
101
|
end
|
73
102
|
|
74
103
|
class String
|
104
|
+
def hg_style=(style)
|
105
|
+
@__hg_style = style
|
106
|
+
end
|
107
|
+
|
75
108
|
def __hg_height
|
76
109
|
1
|
77
110
|
end
|
@@ -91,9 +124,24 @@ class String
|
|
91
124
|
end
|
92
125
|
|
93
126
|
def to_hg(area)
|
127
|
+
@__hg_style = {} if @__hg_style.nil?
|
94
128
|
if area[:height] >= self.__hg_height
|
129
|
+
if @__hg_style[:strong]
|
130
|
+
Hail::GUI.instance.win.attrset(Curses::A_STANDOUT)
|
131
|
+
end
|
95
132
|
Hail::GUI.instance.win.setpos(area[:top], area[:left])
|
96
133
|
Hail::GUI.instance.win.addstr(self.__truncate(area[:width]-3))
|
134
|
+
Hail::GUI.instance.win.attrset(Curses::A_NORMAL)
|
97
135
|
end
|
98
136
|
end
|
99
137
|
end
|
138
|
+
|
139
|
+
class Fixnum
|
140
|
+
def __hg_height
|
141
|
+
1
|
142
|
+
end
|
143
|
+
|
144
|
+
def to_hg(area, style = {})
|
145
|
+
self.to_s.to_hg(area, style)
|
146
|
+
end
|
147
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hail.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2015.10.
|
4
|
+
version: 2015.10.13.02.41
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrien Jeser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email: adrien@jeser.me
|