Skip to content

Instantly share code, notes, and snippets.

@ssh0
Last active August 29, 2015 14:23
Show Gist options
  • Save ssh0/379755588114484e7a1f to your computer and use it in GitHub Desktop.
Save ssh0/379755588114484e7a1f to your computer and use it in GitHub Desktop.
best cropping for ranger/ext/img_display.py
def clear(self, start_x, start_y, width, height):
if not self.is_initialized or self.process.poll() is not None:
self.initialize()
fontw, fonth = _get_font_dimensions()
cmd = "6;{x};{y};{w};{h}\n4;\n3;\n".format(
x = int((start_x - 0.2) * fontw),
y = int((start_y + 0.6) * fonth),
w = int((width + 0.4)* fontw),
h = int((height - 1) * fonth))
self.process.stdin.write(cmd)
self.process.stdin.flush()
self.process.stdout.readline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment