ofs | hex dump | ascii |
---|
0000 | 25 50 44 46 2d 31 2e 32 0a 25 c7 ec 8f a2 0a 35 20 30 20 6f 62 6a 0a 3c 3c 2f 4c 65 6e 67 74 68 | %PDF-1.2.%.....5.0.obj.<</Length |
0020 | 20 36 20 30 20 52 2f 46 69 6c 74 65 72 20 2f 46 6c 61 74 65 44 65 63 6f 64 65 3e 3e 0a 73 74 72 | .6.0.R/Filter./FlateDecode>>.str |
0040 | 65 61 6d 0a 78 9c 2b 54 30 d0 33 54 30 00 41 28 9d 9c cb 55 c8 a5 1f 64 ae 90 5e cc 55 a8 60 6c | eam.x.+T0.3T0.A(...U...d..^.U.`l |
0060 | 6a 09 11 36 35 b4 30 57 30 34 32 36 d4 33 52 30 32 30 37 d6 33 03 a9 d4 0f b2 50 70 c9 e7 0a 04 | j..65.0W0426.3R0207.3.....Pp.... |
0080 | 43 00 53 5c 0f 71 65 6e 64 73 74 72 65 61 6d 0a 65 6e 64 6f 62 6a 0a 36 20 30 20 6f 62 6a 0a 36 | C.S\.qendstream.endobj.6.0.obj.6 |
00a0 | 36 0a 65 6e 64 6f 62 6a 0a 31 35 20 30 20 6f 62 6a 0a 3c 3c 2f 4c 65 6e 67 74 68 20 31 36 20 30 | 6.endobj.15.0.obj.<</Length.16.0 |
00c0 | 20 52 2f 46 69 6c 74 65 72 20 2f 46 6c 61 74 65 44 65 63 6f 64 65 3e 3e 0a 73 74 72 65 61 6d 0a | .R/Filter./FlateDecode>>.stream. |
00e0 | 78 9c 9d 58 4d 8f db 36 10 bd fb 57 f8 96 04 88 19 89 a2 be 7a 29 d0 22 41 f7 96 b4 0b 04 05 7a | x..XM..6...W........z)."A......z |
0100 | 61 6c 7a ad ae 25 39 92 1c 67 ff 54 7f 63 87 1c 7e 8c 28 ed 36 28 f6 b0 30 45 72 66 de bc 99 37 | alz..%9..g.T.c..~.(.6(..0Erf...7 |
0120 | d2 d7 6d c2 d2 6d a2 ff ec ff 7d bb f9 ba f9 ba 4d cd 9a fb b7 6f b7 bf dc 6f de fd 9e 66 db 94 | ..m..m....}.....M....o...o...f.. |
0140 | b3 3c e7 f5 f6 fe b8 c1 03 29 6c e2 5b 51 e5 2c e7 db fb 76 f3 fa 63 3f bc b9 ff 7b 93 d6 ac e6 | .<.......)l.[Q.,...v..c?...{.... |
0160 | f0 fc fe b0 79 3d 8d 7a 05 cf 57 ac e2 b5 d0 e7 77 b8 85 27 35 e3 95 d9 c7 b9 de 97 67 fa 37 9e | ....y=.z..W.....w..'5.......g.7. |
0180 | fc d0 9c 95 3b 5c 83 25 26 8a a4 d2 87 33 5e 6b 83 3b 91 e0 d1 fe a2 3a bd 6f 97 a5 39 ab 84 7e | ....;\.%&....3^k.;.....:.o..9..~ |
01a0 | c0 32 6e 1e 5d ac 43 19 13 c2 39 f4 56 af 64 09 67 69 b1 dd 95 29 2b 0b b3 9e 55 25 1a e3 9c 1a | .2n.].C...9.V.d.gi...)+...U%.... |
01c0 | db f1 3a 67 7c 9b 15 9c 15 c2 6c 1c 94 3c 98 2b cc 4a 32 5b e3 82 d5 05 00 5a f2 24 41 0f 76 7a | ..:g|.....l..<.+.J2[.....Z.$A.vz |
01e0 | b9 60 3c ab eb 7a bb a3 4f ce 4d a7 e2 7b 0e cd 78 39 cb 27 03 45 ca 52 07 e2 78 ea 6f f1 56 b7 | .`<..z..O.M..{..x9.'.E.R..x.o.V. |
0200 | f6 ac 49 51 ad db cb dd 0d 9d ba b9 b5 1d cf 72 56 c0 81 ba 62 18 65 ab 86 07 35 f6 c3 64 1e 43 | ..IQ...........rV...b.e...5..d.C |
0220 | 5e 34 e2 80 23 9f c5 bb e3 80 14 ac 27 05 b3 c9 38 42 d6 52 0f 64 cd 44 2a 0a 43 99 9d 30 49 10 | ^4..#.......'...8B.R.d.D*.C..0I. |
0240 | b5 bd e2 af d7 c6 19 b8 57 3b 08 9e 22 44 b3 d0 2a 9d 47 74 f6 15 ee 2e 73 bd 89 6e 7e e1 1e b9 | ........W;.."D..*.Gt....s..n~... |
0260 | 1f fa d1 50 28 ab 59 e1 f2 7f 32 11 73 20 b3 5b ba 76 cd 37 65 0d fa c5 c1 1c 4c d3 40 48 65 5d | ...P(.Y...2.s..[.v.7e.....L.@He] |
0280 | 28 92 24 9d bb f0 c6 6c 4d 58 35 b7 ef b1 80 7b ab 95 13 50 05 dc a4 09 ac e4 3f 8e 4a c6 12 a1 | (.$....lMX5....{...P......?.J... |
02a0 | 13 9e c2 93 3c 64 3c d7 9e ee 66 eb 2e bd 60 3f a9 22 20 97 51 bc a6 4f 66 a6 a1 c0 3a 43 ca 2c | ....<d<...f...`?."..Q..Of...:C., |
02c0 | d3 05 86 17 9d a5 bd dc fa f3 63 78 f0 17 f1 28 4c 5b 78 11 0f 01 de e5 f3 a2 23 34 d1 26 32 92 | ..........cx...(L[x.......#4.&2. |
02e0 | 4a ba 1f 8d 00 2f f3 59 81 43 65 0b e8 44 02 4a c5 6c fb ac 77 55 50 68 06 a0 90 79 5d 19 36 72 | J..../.Y.Ce..D.J.l..wUPh...y].6r |
0300 | 25 b1 ad 94 da 4d 57 4c e8 0b 04 ed 90 6e 4c 57 4a 4d 8a 71 e5 d7 93 bc 4c ca 9c c5 1e 85 cb 3c | %....MWL.....nLWJM.q....L......< |
0320 | 31 1b 85 ee 48 b8 e2 52 9d 06 b8 a7 3e be cd c7 9f 05 37 8e 43 df 9a 35 53 ce 33 c6 a7 ee f7 a3 | 1...H..R....>.....7.C..5S.3..... |
0340 | 7a fa d2 cb c1 9c 15 79 e8 32 b2 73 21 f8 26 73 1b 9a 49 d9 fb c4# Copyright (C) 2009, 2010 Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""The BrowserView manages a set of BrowserColumns."""
from . import Widget
from .browsercolumn import BrowserColumn
from .pager import Pager
from ..displayable import DisplayableContainer
class BrowserView(Widget, DisplayableContainer):
ratios = None
preview = True
preview_available = True
stretch_ratios = None
need_clear = False
def __init__(self, win, ratios, preview = True):
DisplayableContainer.__init__(self, win)
self.ratios = ratios
self.preview = preview
# normalize ratios:
ratio_sum = float(sum(ratios))
self.ratios = tuple(x / ratio_sum for x in ratios)
if len(self.ratios) >= 2:
self.stretch_ratios = self.ratios[:-2] + \
((self.ratios[-2] + self.ratios[-1] * 0.9),
(self.ratios[-1] * 0.1))
offset = 1 - len(ratios)
if preview: offset += 1
for level in range(len(ratios)):
fl = BrowserColumn(self.win, level + offset)
self.add_child(fl)
try:
self.main_column = self.container[preview and -2 or -1]
except IndexError:
self.main_column = None
else:
self.main_column.display_infostring = True
self.main_column.main_column = True
self.pager = Pager(self.win, embedded=True)
self.pager.visible = False
self.add_child(self.pager)
def draw(self):
try:
if self.env.cmd.show_obj.draw_bookmarks:
self._draw_bookmarks()
except AttributeError:
if self.need_clear:
self.win.erase()
self.need_redraw = True
self.need_clear = False
DisplayableContainer.draw(self)
def finalize(self):
if self.pager.visible:
try:
self.fm.ui.win.move(self.main_column.y, self.main_column.x)
except:
pass
else:
try:
x = self.main_column.x
y = self.main_column.y + self.main_column.target.pointer\
- self.main_column.scroll_begin
self.fm.ui.win.move(y, x)
except:
pass
def _draw_bookmarks(self):
self.need_clear = True
sorted_bookmarks = sorted(item for item in self.fm.bookmarks \
if '/.' not in item[1].path)
def generator():
return zip(range(self.hei), sorted_bookmarks)
try:
maxlen = max(len(item[1].path) for i, item in generator())
except ValueError:
return
maxlen = min(maxlen + 5, self.wid)
for line, items in generator():
key, mark = items
string = " " + key + ": " + mark.path
self.addnstr(line, 0, string.ljust(maxlen), self.wid)
def resize(self, y, x, hei, wid):
"""Resize all the columns according to the given ratio"""
DisplayableContainer.resize(self, y, x, hei, wid)
left = 0
cut_off_last = self.preview and not self.preview_available \
and self.stretch_ratios
if cut_off_last:
generator = enumerate(self.stretch_ratios)
else:
generator = enumerate(self.ratios)
last_i = len(self.ratios) - 1
for i, ratio in generator:
wid = int(ratio * self.wid)
if i == last_i:
wid = int(self.wid - left + 1)
if i == last_i - 1:
self.pager.resize(0, left, hei, max(1, self.wid - left))
try:
self.container[i].resize(0, left, hei, max(1, wid-1))
except KeyError:
pass
left += wid
def click(self, event):
n = event.ctrl() and 1 or 3
if event.pressed(4):
self.main_column.scroll(relative = -n)
elif event.pressed(2) or event.key_invalid():
self.main_column.scroll(relative = n)
else:
DisplayableContainer.click(self, event)
def open_pager(self):
self.pager.visible = True
self.pager.focused = True
self.pager.open()
try:
self.container[-2].visible = False
self.container[-3].visible = False
except IndexError:
pass
def close_pager(self):
self.pager.visible = False
self.pager.focused = False
self.pager.close()
try:
self.container[-2].visible = True
self.container[-3].visible = True
except IndexError:
pass
def poke(self):
DisplayableContainer.poke(self)
if self.settings.collapse_preview and self.preview:
has_preview = self.container[-2].has_preview()
if self.preview_available != has_preview:
self.preview_available = has_preview
self.resize(self.y, self.x, self.hei, self.wid)
|