Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added left margin adjustment in config #653

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion NEMbox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self):
self._init = True
self.config_file_path = Constant.config_path
self.default_config = {
'version': 8,
'version': 9,
'cache': {
'value': False,
'default': False,
Expand Down Expand Up @@ -118,6 +118,11 @@ def __init__(self):
'value': False,
'default': False,
'describe': 'Set true to make curses transparency.'
},
'left_margin_ratio': {
'value': 5,
'default': 5,
'describe': 'Controls the ratio between width and left margin.'
}
}
self.config = {}
Expand Down Expand Up @@ -236,6 +241,13 @@ def check_version(self):
'default': [600, 60],
'describe': 'Desktop lyrics area size.'
}
elif self.config['version'] == 8:
self.config['version'] = 9
self.config['left_margin_ratio'] = {
'value': 5,
'default': 5,
'describe': 'Controls the ratio between width and left margin.'
}
self.check_version()
return False

Expand Down
9 changes: 6 additions & 3 deletions NEMbox/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ def __init__(self):
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)

self.config = Config()
# term resize handling
size = terminalsize.get_terminal_size()
self.x = max(size[0], 10)
self.y = max(size[1], 25)
self.startcol = int(float(self.x) / 5)
self.margin = self.config.get_item('left_margin_ratio')
self.startcol = int(float(self.x) / self.margin)
self.indented_startcol = max(self.startcol - 3, 0)
self.update_space()
self.lyric = ''
Expand All @@ -82,7 +85,6 @@ def __init__(self):
self.now_lyric_index = 0
self.tlyric = ''
self.storage = Storage()
self.config = Config()
self.newversion = False

def addstr(self, *args):
Expand Down Expand Up @@ -657,7 +659,8 @@ def update_size(self):

# update intendations
curses.resizeterm(self.y, self.x)
self.startcol = int(float(self.x) / 5)
self.margin = self.config.get_item('left_margin_ratio')
self.startcol = int(float(self.x) / self.margin)
self.indented_startcol = max(self.startcol - 3, 0)
self.update_space()
self.screen.clear()
Expand Down