Commit 798ed50b authored by Bram Schoenmakers's avatar Bram Schoenmakers

Make column width configurable

Use this in the configuration file:

[columns]
column_width = 42
parent 016d330f
......@@ -66,6 +66,9 @@ append_parent_contexts = 0
;listcontext = lscon
;listcontexts = lscon
[columns]
column_width = 40
[column_keymap]
; Keymap configuration for column-mode
gg = home
......
......@@ -52,6 +52,7 @@ class _Config:
'add',
'aliases',
'colorscheme',
'columns',
'dep',
'ls',
'sort',
......@@ -117,6 +118,10 @@ class _Config:
'listcontexts': 'lscon',
},
'columns': {
'column_width': '40',
},
'column_keymap': {
'gg': 'home',
'G': 'end',
......@@ -383,6 +388,18 @@ class _Config:
""" Returns the list format used by `ls` """
return self.cp.get('ls', 'list_format')
def column_width(self):
try:
width = self.cp.getint('columns', 'column_width')
if width < 1:
# read default
raise ValueError
return width
except ValueError:
return int(self.defaults['columns']['column_width'])
def column_keymap(self):
""" Returns keymap and keystates used in column mode """
keystates = set()
......
......@@ -95,12 +95,14 @@ class UIApplication(CLIApplicationBase):
self._process_flags()
self.column_width = config().column_width()
self.todofile = TodoFile.TodoFile(config().todotxt())
self.todolist = TodoList.TodoList(self.todofile.read())
self.marked_todos = []
self.columns = urwid.Columns([], dividechars=0, min_width=COLUMN_WIDTH)
self.columns = urwid.Columns([], dividechars=0,
min_width=config().column_width())
self.commandline = CommandLineWidget('topydo> ')
self.keystate_widget = KeystateWidget()
self.status_line = urwid.Columns([
......@@ -442,7 +444,7 @@ class UIApplication(CLIApplicationBase):
options = self.columns.options(
width_type='given',
width_amount=COLUMN_WIDTH,
width_amount=config().column_width(),
box_widget=True
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment