Velocity/core/statusbar.py

44 lines
1.3 KiB
Python
Raw Normal View History

2022-03-14 07:21:55 +00:00
import curses
2022-03-15 15:37:38 +00:00
def themes(data):
if data["statusbar_theme"] == "bare":
# The theme colors
colors = (7, data["mode_color"] - 1, 13, 1)
2022-03-14 07:21:55 +00:00
2022-03-15 15:37:38 +00:00
# Add spaces before each part
icon = f" {data['icon']}"
mode = f" {data['mode'].upper()}"
2022-03-15 22:12:52 +00:00
file = f" {data['buffer_name']}"
2022-03-14 07:21:55 +00:00
else:
2022-03-15 15:37:38 +00:00
# The theme colors
colors = (8, data["mode_color"], 14, 2)
# Add spaces on either end
icon = f" {data['icon']} "
mode = f" {data['mode'].upper()} "
2022-03-15 22:12:52 +00:00
file = f" {data['buffer_name']} "
2022-03-15 15:37:38 +00:00
return colors, icon, mode, file
2022-03-14 07:21:55 +00:00
2022-03-15 15:37:38 +00:00
def refresh(stdscr, data):
colors, icon, mode, file = themes(data)
2022-03-14 07:21:55 +00:00
# Render icon
2022-03-15 15:37:38 +00:00
stdscr.addstr(data["height"] - 2, 0, icon,
curses.color_pair(colors[0]) | curses.A_BOLD)
2022-03-14 07:21:55 +00:00
# Render mode
2022-03-15 15:37:38 +00:00
stdscr.addstr(data["height"] - 2, len(icon), mode,
curses.color_pair(colors[1]) | curses.A_BOLD)
2022-03-14 07:21:55 +00:00
# Render file name
2022-03-15 15:37:38 +00:00
stdscr.addstr(data["height"] - 2, len(icon) + len(mode), file,
curses.color_pair(colors[2]) | curses.A_BOLD)
2022-03-14 07:21:55 +00:00
# Rest of the bar
2022-03-15 15:37:38 +00:00
stdscr.addstr(data["height"] - 2, len(icon) + len(mode) + len(file),
" " * (data["width"] - (len(icon) + len(mode) + len(file))),
2022-03-14 07:21:55 +00:00
curses.color_pair(colors[3]))