On Wed, Sep 26, 2012 at 10:20:56PM +0200, steve wrote: > Hi, > > Is it possible, while reading a mail, to keep the headers fixed while > scrolling > down the message? I experienced many times when I have to go back to the top > of > the message to see who has been CCied for example. Keeping chosen headers > fixed > would be really useful (in some circumstances). > I tried to dig the archives for a solution but since I'm not sure I've got the > right keywords, my search failed.
rough but I think it does what you need, but I would not use it m
#!/usr/bin/env python # vim: set encoding=utf8 : import sys import curses KEY_UP = (curses.KEY_UP, ord('k')) KEY_DOWN = (curses.KEY_DOWN, ord('j')) KEY_LEFT = (curses.KEY_LEFT, ord('h')) KEY_RIGHT = (curses.KEY_RIGHT, ord('l')) def print_body(pager, body_l, r, c, y=0, x=0): pager.erase() for i, line in enumerate(body_l[y:r+y]): pager.addstr(i, 0, line[x:c+x]) pager.refresh() def do(stdscr): with open(sys.argv[1]) as fp: email = fp.read() status, headers, body = email.split('\n\n', 2) headers_l = headers.split('\n') body_l = body.split('\n') y, x = stdscr.getmaxyx() num_h = len(headers_l) num_b = len(body_l) r, c = y - num_h - 1, x # maxx = max(map(len, body_l)) pager = stdscr.subpad(r, c, num_h+1, 0) for i, line in enumerate(headers_l): stdscr.addstr(i, 0, line) stdscr.refresh() cur_line = 0 cur_col = 0 touched = True while 1: if touched: print_body(pager, body_l, r, c, cur_line, cur_col) touched = False ch = stdscr.getch() if ch == ord('q'): break elif ch in KEY_DOWN: if cur_line < num_b - r: cur_line += 1 touched = True elif ch in KEY_UP: if cur_line > 0: cur_line -= 1 touched = True elif ch in KEY_LEFT: if cur_col > 0: cur_col -= 1 touched = True elif ch in KEY_RIGHT: cur_col += 1 touched = True curses.wrapper(do)