diff options
| -rw-r--r-- | osd.lua | 14 | ||||
| -rw-r--r-- | rt.lua | 31 |
2 files changed, 30 insertions, 15 deletions
@@ -544,6 +544,11 @@ end function mt:redraw(state) self.redraw_time = os.time() + local next_redraw = math.huge + if self.redraw_timer then + self.redraw_timer:kill() + self.redraw_timer = nil + end local out_titles = {} local out_options = {} @@ -598,6 +603,8 @@ function mt:redraw(state) info.selected = true out_max[#out_max+1] = self:option_icons(opt, info) .. str + + next_redraw = math.min(next_redraw, opt._exp or math.huge) end self.out = { @@ -622,6 +629,13 @@ function mt:redraw(state) self:render() self.needs_redraw = false + + if next_redraw ~= math.huge then + local d = math.max(0.1, next_redraw - os.time()) + self.redraw_timer = mp.add_timeout(d, function() + self:redraw(state) + end) + end end function mt:toggle_hidden() @@ -401,32 +401,24 @@ local menu_option_mt = { end return ret elseif v.epg_channel_id then - if t._info_exp and - osd.redraw_time < - t._info_exp then + local time = osd.redraw_time + if t._exp and time < t._exp then return t._info end local prog = ctx.epg:scheduled_programme( - v.epg_channel_id, - osd.redraw_time) + v.epg_channel_id, time) local ret = prog and prog.title or '' local exp = prog and prog.stop if not prog then prog = ctx.epg:next_programme( - v.epg_channel_id, - osd.redraw_time) + v.epg_channel_id, time) exp = prog and prog.start - - if not prog then - rawset(t, 'info', ret) - return ret - end end - rawset(t, '_info_exp', exp) - rawset(t, '_info', ret) + rawset(t, exp and '_info' or 'info', ret) + rawset(t, '_exp', exp) return ret end end @@ -646,8 +638,17 @@ local epg_programme_mt = { __index = function(t, k) if k == 'active' then local time = osd.redraw_time + if t._exp and time < t._exp then + return t._active + end + local v = t.programme - return time >= v.start and time < v.stop + local ret = time >= v.start and time < v.stop + local exp = time < v.start and v.start or + ret and v.stop or nil + rawset(t, exp and '_active' or 'active', ret) + rawset(t, '_exp', exp) + return ret end end, } |
