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 ...@@ -66,6 +66,9 @@ append_parent_contexts = 0
;listcontext = lscon ;listcontext = lscon
;listcontexts = lscon ;listcontexts = lscon
[columns]
column_width = 40
[column_keymap] [column_keymap]
; Keymap configuration for column-mode ; Keymap configuration for column-mode
gg = home gg = home
......
...@@ -52,6 +52,7 @@ class _Config: ...@@ -52,6 +52,7 @@ class _Config:
'add', 'add',
'aliases', 'aliases',
'colorscheme', 'colorscheme',
'columns',
'dep', 'dep',
'ls', 'ls',
'sort', 'sort',
...@@ -117,6 +118,10 @@ class _Config: ...@@ -117,6 +118,10 @@ class _Config:
'listcontexts': 'lscon', 'listcontexts': 'lscon',
}, },
'columns': {
'column_width': '40',
},
'column_keymap': { 'column_keymap': {
'gg': 'home', 'gg': 'home',
'G': 'end', 'G': 'end',
...@@ -383,6 +388,18 @@ class _Config: ...@@ -383,6 +388,18 @@ class _Config:
""" Returns the list format used by `ls` """ """ Returns the list format used by `ls` """
return self.cp.get('ls', 'list_format') 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): def column_keymap(self):
""" Returns keymap and keystates used in column mode """ """ Returns keymap and keystates used in column mode """
keystates = set() keystates = set()
......
...@@ -95,12 +95,14 @@ class UIApplication(CLIApplicationBase): ...@@ -95,12 +95,14 @@ class UIApplication(CLIApplicationBase):
self._process_flags() self._process_flags()
self.column_width = config().column_width()
self.todofile = TodoFile.TodoFile(config().todotxt()) self.todofile = TodoFile.TodoFile(config().todotxt())
self.todolist = TodoList.TodoList(self.todofile.read()) self.todolist = TodoList.TodoList(self.todofile.read())
self.marked_todos = [] 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.commandline = CommandLineWidget('topydo> ')
self.keystate_widget = KeystateWidget() self.keystate_widget = KeystateWidget()
self.status_line = urwid.Columns([ self.status_line = urwid.Columns([
...@@ -442,7 +444,7 @@ class UIApplication(CLIApplicationBase): ...@@ -442,7 +444,7 @@ class UIApplication(CLIApplicationBase):
options = self.columns.options( options = self.columns.options(
width_type='given', width_type='given',
width_amount=COLUMN_WIDTH, width_amount=config().column_width(),
box_widget=True 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