raise
Parameters
- self:*Subwindows
- *Subwindows
- id:Id
- Id
Source
Implementation
pub fn raise(self: *Subwindows, id: Id) error{CouldNotFindSubwindow}!void {
// don't check against subwindows[0] - that's that main window
const items = self.stack.items[1..];
for (items, 0..) |sw, i| {
if (sw.id == id) {
if (sw.stay_above_parent_window != null) {
//std.debug.print("raiseSubwindow: tried to raise a subwindow {x} with stay_above_parent_window set\n", .{subwindow_id});
return;
}
if (i == (items.len - 1)) {
// already on top
return;
}
// move it to the end, also move any stay_above_parent_window subwindows
// directly on top of it as well - we know from above that the
// first window does not have stay_above_parent_window so this loop ends
var first = true;
while (first or items[i].stay_above_parent_window != null) {
first = false;
const item = items[i];
for (items[i..(items.len - 1)], 0..) |*b, k| {
b.* = items[i + 1 + k];
}
items[items.len - 1] = item;
}
return;
}
}
return error.CouldNotFindSubwindow;
}