mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-19 15:53:07 +02:00
taskwiki: Create a generic Split class for taskwarrior-based splits
This commit is contained in:
parent
67bd4843c3
commit
f8333f7da6
2 changed files with 47 additions and 19 deletions
|
@ -7,9 +7,9 @@ augroup taskwiki
|
||||||
execute "autocmd BufWrite *.".expand('%:e')." py WholeBuffer.update_to_tw()"
|
execute "autocmd BufWrite *.".expand('%:e')." py WholeBuffer.update_to_tw()"
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
command! -nargs=* TaskWikiProjects :py Splits.projects(<q-args>)
|
command! -nargs=* TaskWikiProjects :py SplitProjects(<q-args>).execute()
|
||||||
command! -nargs=* TaskWikiProjectsSummary :py Splits.summary(<q-args>)
|
command! -nargs=* TaskWikiProjectsSummary :py SplitSummary(<q-args>).execute()
|
||||||
command! -nargs=* TaskWikiBurndown :py Splits.burndown(<q-args>)
|
command! -nargs=* TaskWikiBurndown :py SplitBurndown(<q-args>).execute()
|
||||||
|
|
||||||
command! -range TaskWikiInfo :<line1>,<line2>py SelectedTasks().info()
|
command! -range TaskWikiInfo :<line1>,<line2>py SelectedTasks().info()
|
||||||
command! -range TaskWikiLink :<line1>,<line2>py SelectedTasks().link()
|
command! -range TaskWikiLink :<line1>,<line2>py SelectedTasks().link()
|
||||||
|
|
|
@ -9,6 +9,7 @@ sys.path.insert(0, vim.eval("s:plugin_path") + '/taskwiki')
|
||||||
import cache
|
import cache
|
||||||
import util
|
import util
|
||||||
import vwtask
|
import vwtask
|
||||||
|
import viewport
|
||||||
|
|
||||||
"""
|
"""
|
||||||
How this plugin works:
|
How this plugin works:
|
||||||
|
@ -54,10 +55,20 @@ class WholeBuffer(object):
|
||||||
cache.evaluate_viewports()
|
cache.evaluate_viewports()
|
||||||
|
|
||||||
|
|
||||||
class Splits(object):
|
class Split(object):
|
||||||
|
command = None
|
||||||
|
split_name = None
|
||||||
|
colorful = False
|
||||||
|
maxwidth = False
|
||||||
|
maxheight = False
|
||||||
|
vertical = False
|
||||||
|
tw_extra_args = []
|
||||||
|
|
||||||
@staticmethod
|
def __init__(self, args):
|
||||||
def _process_args(args):
|
self.args = self._process_args(args)
|
||||||
|
self.split_name = self.split_name or self.command
|
||||||
|
|
||||||
|
def _process_args(self, args):
|
||||||
tw_args = util.tw_modstring_to_args(args)
|
tw_args = util.tw_modstring_to_args(args)
|
||||||
|
|
||||||
# If only 'global' argument has been passed, then no
|
# If only 'global' argument has been passed, then no
|
||||||
|
@ -70,22 +81,39 @@ class Splits(object):
|
||||||
# If no argument has been passed, locate the closest viewport
|
# If no argument has been passed, locate the closest viewport
|
||||||
# and use its filter
|
# and use its filter
|
||||||
else:
|
else:
|
||||||
return viewport.ViewPort.find_closest().taskfilter or []
|
return viewport.ViewPort.find_closest(cache).taskfilter or []
|
||||||
|
|
||||||
@staticmethod
|
def execute(self):
|
||||||
def projects(args):
|
args = self.args + [self.command] + self.tw_extra_args
|
||||||
output = tw.execute_command(_process_args(args) + ['projects'])
|
if self.colorful:
|
||||||
util.show_in_split(output, name="projects", vertical=True)
|
output = util.tw_execute_colorful(tw, args,
|
||||||
|
maxwidth=self.maxwidth,
|
||||||
|
maxheight=self.maxheight)
|
||||||
|
else:
|
||||||
|
output = tw.execute_command(args)
|
||||||
|
|
||||||
@staticmethod
|
util.show_in_split(
|
||||||
def summary(args):
|
output,
|
||||||
output = util.tw_execute_colorful(tw, _process_args(args) + ['summary'])
|
name=self.split_name,
|
||||||
util.show_in_split(output, name="summary", vertical=True)
|
vertical=self.vertical,
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def burndown(args):
|
class SplitProjects(Split):
|
||||||
output = util.tw_execute_colorful(tw, _process_args(args) + ['burndown'], maxwidth=True)
|
command = 'projects'
|
||||||
util.show_in_split(output, name="burndown")
|
vertical = True
|
||||||
|
|
||||||
|
|
||||||
|
class SplitSummary(Split):
|
||||||
|
command = 'summary'
|
||||||
|
vertical = True
|
||||||
|
colorful = True
|
||||||
|
|
||||||
|
|
||||||
|
class SplitBurndown(Split):
|
||||||
|
command = 'burndown'
|
||||||
|
colorful = True
|
||||||
|
maxwidth = True
|
||||||
|
|
||||||
|
|
||||||
class SelectedTasks(object):
|
class SelectedTasks(object):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue