lib/deadline/timer.rb in deadline-0.0.4 vs lib/deadline/timer.rb in deadline-0.1.0

- old
+ new

@@ -18,18 +18,26 @@ Curses.start_color Curses.init_pair LABEL_GREEN, Curses::COLOR_GREEN, Curses::COLOR_BLACK Curses.init_pair LABEL_RED, Curses::COLOR_RED, Curses::COLOR_BLACK Curses.init_pair LABEL_WHITE, Curses::COLOR_WHITE, Curses::COLOR_BLACK + past_task_num = Task.all.size + loop do Task.refresh tasks = Task.all if tasks.size == 0 Curses.close_screen break end + if tasks.size < past_task_num + Curses.close_screen + Curses.init_screen + end + past_task_num = tasks.size + tasks.each_with_index do |task, idx| last_time = "" line_pos = Curses.lines / 2 if idx == 0 last_time = special_last_time_of(task) @@ -54,11 +62,9 @@ Curses.addstr(top_label) end Curses.refresh sleep(1) - Curses.close_screen - Curses.init_screen end end def self.special_last_time_of(task) last_time = task[:deadline] - Time.now