def modify(self, modstring): # If no modstring was passed as argument, ask the user interactively if not modstring: with util.current_line_highlighted(): modstring = util.get_input("Enter modifications: ") # We might have two same tasks in the range, make sure we do not pass the # same uuid twice unique_tasks = set(vimwikitask.task['uuid'] for vimwikitask in self.tasks) uuids = list(unique_tasks) # Generate the arguments from the modstring args = util.tw_modstring_to_args(modstring) # Modify all tasks at once output = util.tw_execute_safely(self.tw, uuids + ['mod'] + args) # Update the touched tasks in buffer, if needed cache.load_tasks() cache.update_vwtasks_from_tasks() cache.update_vwtasks_in_buffer() # Output the feedback from TW if output: print(output[-1])
def modify(self, modstring): # If no modstring was passed as argument, ask the user interactively if not modstring: with util.current_line_highlighted(): modstring = util.get_input("Enter modifications: ") # We might have two same tasks in the range, make sure we do not pass the # same uuid twice unique_tasks = set(vimwikitask.task['uuid'] for vimwikitask in self.tasks) uuids = list(unique_tasks) # Generate the arguments from the modstring args = util.tw_modstring_to_args(modstring) # Modify all tasks at once output = util.tw_execute_safely(self.tw, uuids + ['mod'] + args) # Update the touched tasks in buffer, if needed cache.load_tasks() cache.update_vwtasks_from_tasks() cache.update_vwtasks_in_buffer() # Output the feedback from TW if output: print(output[-1]) cache.buffer.push()
def update_from_tw(): """ Updates all the incomplete tasks in the vimwiki file if the info from TW is different. """ cache.load_tasks() cache.load_vwtasks() cache.update_vwtasks_from_tasks() cache.update_vwtasks_in_buffer() cache.evaluate_viewports()
def update_to_tw(): """ Updates all tasks that differ from their TaskWarrior representation. """ cache.reset() cache.load_tasks() cache.load_vwtasks() cache.save_tasks() cache.update_vwtasks_in_buffer() cache.evaluate_viewports()
def update_from_tw(): """ Updates all the incomplete tasks in the vimwiki file if the info from TW is different. """ cache.reset() cache.load_tasks() cache.load_vwtasks(buffer_has_authority=False) cache.load_viewports() cache.update_vwtasks_from_tasks() cache.update_vwtasks_in_buffer() cache.evaluate_viewports() cache.buffer.push()
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)