def find_closest(cls, cache): current_line = util.get_current_line_number() # Search lines in order: first all above, than all below line_numbers = itertools.chain( reversed(range(0, current_line + 1)), range(current_line + 1, len(vim.current.buffer))) for i in line_numbers: vwtask = cls.from_line(cache, i) if vwtask: return vwtask
def find_closest(cls, cache): current_line = util.get_current_line_number() # Search lines in order: first all above, than all below line_numbers = itertools.chain( reversed(range(0, current_line + 1)), range(current_line + 1, len(vim.current.buffer)) ) for i in line_numbers: vwtask = cls.from_line(cache, i) if vwtask: return vwtask
def task_info_or_vimwiki_follow_link(): # If the line under cursor contains task, toggle info # otherwise do the default VimwikiFollowLink position = util.get_current_line_number() if cache.vwtask[position] is not None: SelectedTasks().info() else: port = viewport.ViewPort.from_line(position, cache) if port is not None: Meta().inspect_viewport() else: vim.command('VimwikiFollowLink')
def inspect_viewport(self): position = util.get_current_line_number() port = viewport.ViewPort.from_line(position, cache) if port.meta.get('visible') is False: cache.reset() cache.load_vwtasks() cache.load_tasks() template = ( "ViewPort inspection:\n" "--------------------\n" "Name: {0}\n" "Filter used: {1}\n" "Defaults used: {2}\n" "Ordering used: {3}\n" "Matching taskwarrior tasks: {4}\n" "Displayed tasks: {5}\n" "Tasks to be added: {6}\n" "Tasks to be deleted: {7}\n" ) if port is not None: # Load the tasks under the viewport port.load_tasks() to_add, to_del = port.get_tasks_to_add_and_del() # Fill in the interesting info in the template template_formatted = template.format( port.name, port.raw_filter, port.raw_defaults, port.sort, len(port.matching_tasks), len(port.tasks), ', '.join(map(unicode, to_add)), ', '.join(map(unicode, to_del)), ) # Show in the split lines = template_formatted.splitlines() util.show_in_split(lines, activate_cursorline=True)
def from_current_line(cls, cache): line_number = util.get_current_line_number() return cls.from_line(cache, line_number)