-
Notifications
You must be signed in to change notification settings - Fork 0
/
statusbar.py
29 lines (25 loc) · 1008 Bytes
/
statusbar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# coding=UTF-8
'''
@Author: cenmmy
@LastEditors: cenmmy
@Description:
@Date: 2019-04-19 11:34:56
@LastEditTime: 2019-04-21 20:46:25
'''
import curses
from pad import Pad
class StatusBar(Pad):
def __init__(self, stdscr, nlines, ncols, sminrow, smincol, smaxrow, smaxcol, mode="NORMAL", other="", fgcolor=curses.COLOR_WHITE, bgcolor=curses.COLOR_BLACK, color_pair=5):
Pad.__init__(self, stdscr, nlines, ncols, sminrow, smincol, smaxrow, smaxcol, fgcolor, bgcolor, color_pair)
self.mode = mode
self.other = other
self.smile = '☺'
def content(self):
try:
self.pad.addstr(0, 0, self.mode + ''.join([' ' for _ in range(self.ncols - len(self.mode) - len(self.other) - len(self.smile) - 1)]) + self.other + ' ' + self.smile, curses.color_pair(self.color_pair))
self.pad.chgat(0, 0, -1, curses.color_pair(self.color_pair))
except curses.error:
pass
def draw(self):
self.content()