|
|
|
@ -18,13 +18,25 @@ openWindow = title content \
|
|
|
|
osState.palette.visible := False
|
|
|
|
osState.palette.visible := False
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
closeFocused = _ \
|
|
|
|
closeWindowByIndex = i \
|
|
|
|
i = osState.wm.focusedIndex;
|
|
|
|
focused = osState.wm.focusedIndex;
|
|
|
|
|
|
|
|
newFocused = (i < focused
|
|
|
|
|
|
|
|
| True \ focused - 1
|
|
|
|
|
|
|
|
| False \ (i == focused
|
|
|
|
|
|
|
|
| True \ max 0 (focused - 1)
|
|
|
|
|
|
|
|
| False \ focused));
|
|
|
|
|
|
|
|
|
|
|
|
batch [
|
|
|
|
batch [
|
|
|
|
osState.windows := (take i osState.windows) & (drop (i + 1) osState.windows),
|
|
|
|
osState.windows := (take i osState.windows) & (drop (i + 1) osState.windows),
|
|
|
|
osState.wm.focusedIndex := max 0 (osState.wm.focusedIndex - 1)
|
|
|
|
osState.wm.focusedIndex := min newFocused (len osState.windows - 2)
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
closeFocusedWindow = _ \ closeWindowByIndex osState.wm.focusedIndex;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
closeWindowById = id \
|
|
|
|
|
|
|
|
i = index id (map (w \ w.id) osState.windows);
|
|
|
|
|
|
|
|
closeWindowByIndex (unwrapOr 0 i);
|
|
|
|
|
|
|
|
|
|
|
|
onSelect = input \
|
|
|
|
onSelect = input \
|
|
|
|
result = eval input;
|
|
|
|
result = eval input;
|
|
|
|
result
|
|
|
|
result
|
|
|
|
@ -33,7 +45,6 @@ onSelect = input \
|
|
|
|
| Err msg \ openWindow "Error" (ui.text { content = msg, color = "red" });
|
|
|
|
| Err msg \ openWindow "Error" (ui.text { content = msg, color = "red" });
|
|
|
|
|
|
|
|
|
|
|
|
renderWindow = window isActive \
|
|
|
|
renderWindow = window isActive \
|
|
|
|
_ = debug "renderWindow" window.title;
|
|
|
|
|
|
|
|
titleBarHeight = 30;
|
|
|
|
titleBarHeight = 30;
|
|
|
|
ui.stack {
|
|
|
|
ui.stack {
|
|
|
|
children = [
|
|
|
|
children = [
|
|
|
|
@ -45,10 +56,31 @@ renderWindow = window isActive \
|
|
|
|
x = 0, y = 0,
|
|
|
|
x = 0, y = 0,
|
|
|
|
child = ui.stack {
|
|
|
|
child = ui.stack {
|
|
|
|
children = [
|
|
|
|
children = [
|
|
|
|
|
|
|
|
# background
|
|
|
|
ui.rect { w = window.width, h = titleBarHeight, color = (isActive | True \ "#a15f80" | False \ "#0f3348") },
|
|
|
|
ui.rect { w = window.width, h = titleBarHeight, color = (isActive | True \ "#a15f80" | False \ "#0f3348") },
|
|
|
|
|
|
|
|
ui.row {
|
|
|
|
|
|
|
|
children = [
|
|
|
|
|
|
|
|
# close button
|
|
|
|
|
|
|
|
ui.clickable {
|
|
|
|
|
|
|
|
event = closeWindowById window.id,
|
|
|
|
|
|
|
|
child = ui.stack {
|
|
|
|
|
|
|
|
children = [
|
|
|
|
|
|
|
|
# button background
|
|
|
|
|
|
|
|
ui.rect { w = titleBarHeight, h = titleBarHeight, color = "rgba(255,255,255,0.2)" },
|
|
|
|
|
|
|
|
# button text
|
|
|
|
|
|
|
|
ui.positioned {
|
|
|
|
|
|
|
|
x = 9, y = 7, child = ui.text { content = "x" }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# title
|
|
|
|
ui.positioned { x = 8, y = 8, child = ui.text { content = window.title, color = "white" } },
|
|
|
|
ui.positioned { x = 8, y = 8, child = ui.text { content = window.title, color = "white" } },
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
# content
|
|
|
|
# content
|
|
|
|
@ -63,12 +95,23 @@ renderWindow = window isActive \
|
|
|
|
]
|
|
|
|
]
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
windowComponent = config \ ui.stateful {
|
|
|
|
|
|
|
|
key = "window-" & (show config.index),
|
|
|
|
|
|
|
|
focusable = True,
|
|
|
|
|
|
|
|
init = {},
|
|
|
|
|
|
|
|
update = state event \ event
|
|
|
|
|
|
|
|
| Focused \ { state = state, emit = [osState.wm.focusedIndex := config.index] }
|
|
|
|
|
|
|
|
| ChildFocused \ { state = state, emit = [osState.wm.focusedIndex := config.index] }
|
|
|
|
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
|
|
|
|
view = state \ renderWindow config.window config.isActive
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
renderWindows = _ \
|
|
|
|
renderWindows = _ \
|
|
|
|
windows = osState.windows;
|
|
|
|
windows = osState.windows;
|
|
|
|
focused = osState.wm.focusedIndex;
|
|
|
|
focused = osState.wm.focusedIndex;
|
|
|
|
ui.row {
|
|
|
|
ui.row {
|
|
|
|
gap = 1,
|
|
|
|
gap = 1,
|
|
|
|
children = mapWithIndex (w i \ renderWindow w (i == focused)) windows
|
|
|
|
children = mapWithIndex (w i \ windowComponent { window = w, index = i, isActive = (i == focused) }) windows
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
os = ui.stateful {
|
|
|
|
os = ui.stateful {
|
|
|
|
@ -85,8 +128,8 @@ os = ui.stateful {
|
|
|
|
| Key { key = "ArrowRight", meta = True } \
|
|
|
|
| Key { key = "ArrowRight", meta = True } \
|
|
|
|
{ state = state, emit = [osState.wm.focusedIndex := min (len osState.windows - 1) (osState.wm.focusedIndex + 1)] }
|
|
|
|
{ state = state, emit = [osState.wm.focusedIndex := min (len osState.windows - 1) (osState.wm.focusedIndex + 1)] }
|
|
|
|
| Key { key = "d", meta = True } \
|
|
|
|
| Key { key = "d", meta = True } \
|
|
|
|
{ state = state, emit = [closeFocused 0] }
|
|
|
|
{ state = state, emit = [closeFocusedWindow 0] }
|
|
|
|
| _ \ _ = debug "key" []; { state = state, emit = [] },
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
|
|
|
|
|
|
|
|
view = state \
|
|
|
|
view = state \
|
|
|
|
ui.stack {
|
|
|
|
ui.stack {
|
|
|
|
|