From 0cb62033ef18d5ef05fc40d33e0ec1b448cc63f8 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sun, 2 Jun 2024 04:22:07 +0200 Subject: [PATCH] Add update partial method for listview --- listview.lua | 23 +++++++++++++++++++++++ requests.lua | 1 + 2 files changed, 24 insertions(+) diff --git a/listview.lua b/listview.lua index e0f40fc..4b53356 100644 --- a/listview.lua +++ b/listview.lua @@ -18,6 +18,10 @@ local function redrawLine(idx) frame.setCursorPos(1, idx-paginationOffset+1) if drawLine then drawLine(frame, backingList[idx]) + else + frame.setBackgroundColor(colors.red) + frame.clearLine() + frame.setBackgroundColor(colors.black) end end end @@ -59,6 +63,10 @@ local function redraw() end backingIdx = backingIdx + 1 end + else + frame.setBackgroundColor(colors.red) + frame.clear() + frame.setBackgroundColor(colors.black) end end @@ -69,6 +77,20 @@ local function updatePage(newOffset) end end +local function updatePartial(filter) + if drawLine then + local tw, th = frame.getSize() + local backingIdx = paginationOffset + for idx = 1, th, 1 do + frame.setCursorPos(1, idx) + if backingList[backingIdx] ~= nil and filter(backingList[backingIdx]) then + drawLine(frame, backingList[backingIdx]) + end + backingIdx = backingIdx + 1 + end + end +end + return { setTerm=setTerm, @@ -78,4 +100,5 @@ return { clearFrom=clearFrom, redraw=redraw, updatePage=updatePage, + updatePartial=updatePartial, } diff --git a/requests.lua b/requests.lua index f8d21e0..2122676 100644 --- a/requests.lua +++ b/requests.lua @@ -101,6 +101,7 @@ local function onTouch(self, touch_x, touch_y) else permset.add(allowed_items, obj.answer.name) end + listview.updatePartial(function (item) return item.answer ~= nil and item.answer.name == obj.answer.name end) return true end end