From 8730f1ec6e20048f04298f866d4ed8b23836db57 Mon Sep 17 00:00:00 2001 From: mark-dawn Date: Fri, 23 Feb 2018 23:55:54 +0100 Subject: Fixed manpages, tmux handling Updated manapages Corrections to rc.conf Silenced the warning from pillow about image sizes Tmux session with kitty raises ImgDisplayUnsupportedError changed pager.py to also notify on ImgDispalyUnsupported Error --- doc/ranger.1 | 20 ++++++-------------- doc/ranger.pod | 1 + doc/rifle.1 | 4 ++-- ranger/config/rc.conf | 6 +++--- ranger/ext/img_display.py | 22 ++++++++++++++++------ ranger/gui/widgets/pager.py | 3 ++- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index a0fc79a1..8d373a64 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.1" "2018-05-14" "ranger manual" +.TH RANGER 1 "ranger-1.9.1" "05/29/2018" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -310,7 +310,8 @@ width of 8 and height of 11 are used. To use other values, set the options \fIterminology\fR .IX Subsection "terminology" .PP -This only works in terminology. It can render vectors graphics, but works only locally. +This only works in terminology. It can render vector graphics, but works only locally. +.PP To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR to terminology. .PP \fIurxvt\fR @@ -334,19 +335,10 @@ To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR t \fIkitty\fR .IX Subsection "kitty" .PP -This only works on Kitty. -It requires \s-1PIL\s0 or pillow at the moment to work. A nasty bug that can -corrupt the terminal window when scrolling quicly many images, that can -be solved by with the \f(CW\*(C`redraw_window\*(C'\fR command. -.PP -To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR to kitty -.PP -\fIkitty-network\fR -.IX Subsection "kitty-network" +This only works on Kitty. It requires \s-1PIL\s0 (or pillow) to work. +Allows remote image previews, for example in an ssh session. .PP -The same as kitty, but uses a streaming method to allow previews remotely, -for example in an ssh session. However the system is slighly more computationally taxing -and the quality of the preview is reduced for bandwidth considerations. +To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR to kitty. .SS "\s-1SELECTION\s0" .IX Subsection "SELECTION" The \fIselection\fR is defined as \*(L"All marked files \s-1IF THERE ARE ANY,\s0 otherwise diff --git a/doc/ranger.pod b/doc/ranger.pod index 46ca920e..b262ad44 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -223,6 +223,7 @@ C and C to the desired values. =head3 terminology This only works in terminology. It can render vector graphics, but works only locally. + To enable this feature, set the option C to terminology. =head3 urxvt diff --git a/doc/rifle.1 b/doc/rifle.1 index ad32e4f4..c53a6f39 100644 --- a/doc/rifle.1 +++ b/doc/rifle.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RIFLE 1" -.TH RIFLE 1 "rifle-1.9.1" "05.03.2018" "rifle manual" +.TH RIFLE 1 "rifle-1.9.1" "05/29/2018" "rifle manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 165e049b..5317dff5 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -102,10 +102,10 @@ set preview_images false # Preview images in full color using kitty image protocol. # Requires python PIL or pillow library. # If ranger does not share the local filesystem with kitty -# the transfer method is switched to encode the whole image in -# the protocol that, while slower, allows remote previews, +# the transfer method is changed to encode the whole image; +# while slower, this allows remote previews, # for example during an ssh session. -# Tmux support is untested. +# Tmux is unsupported. set preview_images_method w3m # Default iTerm2 font size (see: preview_images_method: iterm2) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 925a4054..17c730df 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -20,6 +20,7 @@ import imghdr import os import struct import sys +import warnings from subprocess import Popen, PIPE import termios @@ -495,10 +496,6 @@ class KittyImageDisplayer(ImageDisplayer): def __init__(self): self.temp_paths = [] - if "screen" in os.environ['TERM']: - # TODO: probably need to modify the preamble - pass - # the rest of the initializations that require reading stdio or raising exceptions # are delayed to the first draw call, since curses # and ranger exception handler are not online at __init__() time @@ -509,6 +506,14 @@ class KittyImageDisplayer(ImageDisplayer): self.pix_row, self.pix_col = (0, 0) def _late_init(self): + # tmux + if "screen" in os.environ['TERM']: + # this doesn't seem to work, ranger freezes... + # commenting out the response check does nothing + # self.protocol_start = b'\033Ptmux;\033' + self.protocol_start + # self.protocol_end += b'\033\\' + raise ImgDisplayUnsupportedException('tmux support is not implemented with kitty') + # automatic check if we share the filesystem using a dummy file with NamedTemporaryFile() as tmpf: tmpf.write(bytearray([0xFF] * 3)) @@ -561,8 +566,13 @@ class KittyImageDisplayer(ImageDisplayer): # finish initialization if it is the first call if self.needs_late_init: self._late_init() - - image = self.backend.open(path) + with warnings.catch_warnings(record=True): # as warn: + warnings.simplefilter('ignore', self.backend.DecompressionBombWarning) + image = self.backend.open(path) + # TODO: find a way to send a message to the user that + # doesn't stop the image from displaying + # if warn: + # raise ImageDisplayError(str(warn[-1].message)) box = (width * self.pix_row, height * self.pix_col) if image.width > box[0] or image.height > box[1]: diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index 42adf1e9..9afbfd15 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -109,8 +109,9 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes try: self.fm.image_displayer.draw(self.image, self.x, self.y, self.wid, self.hei) - except ImgDisplayUnsupportedException: + except ImgDisplayUnsupportedException as ex: self.fm.settings.preview_images = False + self.fm.notify(ex, bad=True) except Exception as ex: # pylint: disable=broad-except self.fm.notify(ex, bad=True) else: -- cgit 1.4.1-2-gfad0