-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
96 lines (74 loc) · 2.31 KB
/
config.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/python
# -*- encoding: utf-8 -*-
from ui import Format
from termbox import BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE
from termbox import BOLD, UNDERLINE
#### Symbols
symbol_progress_e = u"─"
symbol_progress_c = u"╼"
symbol_progress_r = u"·"
symbol_player_states = {
"play": ">",
"stop": "[]",
"pause": "||"
}
#### Colors
color_playlist_number = (YELLOW, BLACK)
color_playlist_line = (WHITE, BLACK)
color_playlist_time = (RED, BLACK)
color_playlist_selected = (WHITE, CYAN)
# Browser
color_browser_number = (YELLOW, BLACK)
color_browser_line = (WHITE, BLACK)
color_browser_selected = (WHITE, CYAN)
# Progress bar
color_progress_elapsed = (WHITE, BLACK)
color_progress_remaining = (BLACK, BLACK)
# Message
color_msg = {
"info": (WHITE, BLACK),
"warning": (YELLOW, BLACK),
"error": (RED, BLACK)
}
# Command line
color_cmdline_number = (MAGENTA, BLACK)
color_cmdline_name = (WHITE, BLACK)
color_cmdline_description = (WHITE, BLACK)
#### Text strings
text_msg_prefix = {
"info": "Info",
"warning": "Warning",
"error": "Error"
}
def length_str(time):
m = time / 60
s = time % 60
if m <= 0 and s <= 0:
return "--:--"
elif m > 99:
return str(m) + "m"
return str(m).zfill(2) + ":" + str(s).zfill(2)
#### Formatting functions
def format_browser_item(node, pos, selected, w, numw):
f = Format()
f.add(str(pos + 1).rjust(numw), *color_browser_number)
f.add(" " + unicode(node), *color_browser_line)
if selected:
f.set_color(*color_browser_selected)
f.add("".ljust(max(0, w - len(f.s))), *color_browser_selected)
return f
def format_playlist_song(song, pos, selected, current, w, numw):
left, right = Format(), Format()
left.add(str(pos + 1).rjust(numw), *color_playlist_number)
left.add(" %s - %s (%s)" % (song.artist, song.title, song.album),
*color_playlist_line)
right.add(" [%s]" % length_str(song.time), *color_playlist_time)
if selected:
left.set_color(*color_playlist_selected)
right.set_color(*color_playlist_selected)
left.add("".ljust(max(0, w - len(left.s))), *color_playlist_selected)
if current:
left.set_bold()
right.set_bold()
left.replace(0, ">", BLUE, BLACK)
return left, right