237: def display_tasks_and_comments
238: displayable_tasks = tasks.select { |t|
239: (options.show_all_tasks || t.comment) && t.name =~ options.show_task_pattern
240: }
241: case options.show_tasks
242: when :tasks
243: width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
244: max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
245:
246: displayable_tasks.each do |t|
247: printf "#{name} %-#{width}s # %s\n",
248: t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
249: end
250: when :describe
251: displayable_tasks.each do |t|
252: puts "#{name} #{t.name_with_args}"
253: comment = t.full_comment || ""
254: comment.split("\n").each do |line|
255: puts " #{line}"
256: end
257: puts
258: end
259: when :lines
260: displayable_tasks.each do |t|
261: t.locations.each do |loc|
262: printf "#{name} %-30s %s\n",t.name_with_args, loc
263: end
264: end
265: else
266: fail "Unknown show task mode: '#{options.show_tasks}'"
267: end
268: end