File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ def _linescroller(getch, cfg):
3636 """
3737 term_size = TermSize (0 , 0 )
3838 _update_term_size (term_size )
39+ use_colors = cfg ["main" ].getboolean ("color" )
3940 argv = {}
4041 argv ["min_scroll_line" ] = 0
4142 scroller = CharacterScroller (cfg , term_size , ** argv )
@@ -49,6 +50,8 @@ def _linescroller(getch, cfg):
4950 win_text = text
5051 else :
5152 win_text = text [:- 1 ]
53+ if use_colors :
54+ win_text = _apply_colors (win_text )
5255 print (win_text , end = "\r " )
5356 if IS_WINDOWS :
5457 sleep (.15 )
@@ -63,6 +66,17 @@ def _linescroller(getch, cfg):
6366 print (f"{ UP_ONE_ROW } " , end = "" )
6467
6568
69+ def _apply_colors (win_text ):
70+ i = 31
71+ new_text = ""
72+ for ch in win_text :
73+ new_text += f"\033 [{ i } m" + ch
74+ i += 1
75+ if i > 39 :
76+ i = 31
77+ return new_text
78+
79+
6680def _check_input (getch ):
6781 """
6882 Use getchtimeout to get a character. If "Q" or "q" is given, then it raises SystemExit
You can’t perform that action at this time.
0 commit comments