Interface List<T>
One of the compositor's live collections, such as wm.windows. A list kept in a local stays up to date.
Implemented by WindowList, OutputList, LayerList, SeatList and DrawableList.
WARNING
A list is not a table. list[1] and #list raise an error that points to :get, :count and :all. table.insert(list, x) fails too.
lua
local windows = wm.windows
for index = 1, windows:count() do
print(index, windows:get(index).app_id)
endMethods
list:get(index: integer) -> T?get
The element at index, counting from 1.
- nil when out of range, including 0 and negative indexes.
list:all() -> T[]all
Every element, in a new plain table, in the same order as get. Use it to loop with ipairs or to sort.
- Changing the table changes nothing else.
- The table doesn't follow later changes.
lua
local by_title = wm.windows:all()
table.sort(by_title, function(a, b) return (a.title or "") < (b.title or "") end)list:count() -> integercount
The number of elements right now.