summary refs log blame commit diff stats
path: root/contrib/plaintext.py
blob: 3a3267919ab862ec16e3988c07e934854113c74b (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                                               

                                                 








                                                               
#!/usr/bin/env python3
from colorama import Fore, Style
import sys
import re

# TODO: Wrap text to terminal width?

ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
# TODO: I guess this might vary from MUA to MUA. I've definitely seen localized
# versions in the wild
quote_prefix_re = re.compile(r"On .*, .* wrote:")
quote_re = re.compile(r">+")

mail = sys.stdin.read().replace("\r\n", "\n")
mail = ansi_escape.sub('', mail)

for line in mail.split("\n"):
    if quote_re.match(line) or quote_prefix_re.match(line):
        print(f"{Style.DIM}{Fore.CYAN}{line}{Style.RESET_ALL}")
    else:
        print(line)
p">#ifdef HAVE_NCURSESW_NCURSES_H #include <ncursesw/ncurses.h> #elif HAVE_NCURSES_H #include <ncurses.h> #elif HAVE_CURSES_H #include <curses.h> #endif #include "config/preferences.h" int _screen_line_row(int win_pos, int mainwin_pos) { int wrows = getmaxy(stdscr); if (win_pos == 1) { return 0; } if (win_pos == 2) { int row = 1; if (mainwin_pos == 1) { row = wrows - 3; } return row; } if (win_pos == 3) { int row = 2; if (mainwin_pos == 1 || mainwin_pos == 2) { row = wrows - 2; } return row; } return wrows - 1; } int screen_titlebar_row(void) { ProfWinPlacement* placement = prefs_get_win_placement(); int row = _screen_line_row(placement->titlebar_pos, placement->mainwin_pos); prefs_free_win_placement(placement); return row; } int screen_statusbar_row(void) { ProfWinPlacement* placement = prefs_get_win_placement(); int row = _screen_line_row(placement->statusbar_pos, placement->mainwin_pos); prefs_free_win_placement(placement); return row; } int screen_inputwin_row(void) { ProfWinPlacement* placement = prefs_get_win_placement(); int row = _screen_line_row(placement->inputwin_pos, placement->mainwin_pos); prefs_free_win_placement(placement); return row; } int screen_mainwin_row_start(void) { ProfWinPlacement* placement = prefs_get_win_placement(); int row = placement->mainwin_pos - 1; prefs_free_win_placement(placement); return row; } int screen_mainwin_row_end(void) { ProfWinPlacement* placement = prefs_get_win_placement(); int wrows = getmaxy(stdscr); int row = wrows - (5 - placement->mainwin_pos); prefs_free_win_placement(placement); return row; }