|
|
|
|
@ -31,7 +31,8 @@
|
|
|
|
|
# | None \ currentIndex);
|
|
|
|
|
|
|
|
|
|
paletteState = {
|
|
|
|
|
query = ""
|
|
|
|
|
query = "",
|
|
|
|
|
focusedIndex = 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nextSelectable = items index direction \
|
|
|
|
|
@ -42,13 +43,16 @@ nextSelectable = items index direction \
|
|
|
|
|
| None \ index;
|
|
|
|
|
|
|
|
|
|
palette = config \
|
|
|
|
|
focusedIndex = 0;
|
|
|
|
|
windowHeight = 400;
|
|
|
|
|
windowWidth = 600;
|
|
|
|
|
|
|
|
|
|
# results = take 8 (config.search paletteState.query);
|
|
|
|
|
results = config.search paletteState.query; # once you get scrolling..
|
|
|
|
|
|
|
|
|
|
effectiveIndex = nth paletteState.focusedIndex results
|
|
|
|
|
| Some (Section _) \ nextSelectable results paletteState.focusedIndex 1
|
|
|
|
|
| _ \ paletteState.focusedIndex;
|
|
|
|
|
|
|
|
|
|
dialogPadding = 0;
|
|
|
|
|
|
|
|
|
|
textInputHeight = 40;
|
|
|
|
|
@ -74,23 +78,22 @@ palette = config \
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# stateful, just so it can get keyboard events
|
|
|
|
|
ui.stateful {
|
|
|
|
|
key = "palette",
|
|
|
|
|
focusable = False,
|
|
|
|
|
|
|
|
|
|
init = {
|
|
|
|
|
focusedIndex = 0,
|
|
|
|
|
},
|
|
|
|
|
init = {},
|
|
|
|
|
|
|
|
|
|
update = state event \ event
|
|
|
|
|
| Key { printable = True } \ { state = state.{ focusedIndex = 0 }, emit = [] }
|
|
|
|
|
| Key { printable = True } \ { state = state, emit = [paletteState.focusedIndex := nextSelectable results 0 1] }
|
|
|
|
|
| Key { key = "ArrowUp" } \
|
|
|
|
|
{ state = state.{ focusedIndex = nextSelectable results state.focusedIndex (0 - 1) }, emit = [] }
|
|
|
|
|
{ state = state, emit = [paletteState.focusedIndex := nextSelectable results effectiveIndex (0 - 1)] }
|
|
|
|
|
| Key { key = "ArrowDown" } \
|
|
|
|
|
{ state = state.{ focusedIndex = nextSelectable results state.focusedIndex 1 }, emit = [] }
|
|
|
|
|
{ state = state, emit = [paletteState.focusedIndex := nextSelectable results effectiveIndex 1] }
|
|
|
|
|
| Key { key = "Enter" } \
|
|
|
|
|
(nth state.focusedIndex results
|
|
|
|
|
| Some (Item data) \ { state = state, emit = [config.onSelect data.label] }
|
|
|
|
|
(nth paletteState.focusedIndex results
|
|
|
|
|
| Some (Item data) \ { state = state, emit = [paletteState.focusedIndex := 0, config.onSelect data.label] }
|
|
|
|
|
| _ \ { state = state, emit = [] })
|
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
|
|
|
|
|
|
@ -109,7 +112,7 @@ palette = config \
|
|
|
|
|
children = [
|
|
|
|
|
textInput {
|
|
|
|
|
key = "palette-query",
|
|
|
|
|
initialValue = "",
|
|
|
|
|
initialValue = paletteState.query,
|
|
|
|
|
initialFocus = True,
|
|
|
|
|
color = "white",
|
|
|
|
|
backgroundColor = "rgba(0,0,0,0.2)",
|
|
|
|
|
@ -137,7 +140,7 @@ palette = config \
|
|
|
|
|
child = data.label,
|
|
|
|
|
w = contentWidth,
|
|
|
|
|
h = textInputHeight,
|
|
|
|
|
selected = (state.focusedIndex == i),
|
|
|
|
|
selected = (effectiveIndex == i),
|
|
|
|
|
onClick = config.onSelect data.label
|
|
|
|
|
}
|
|
|
|
|
| _ \ empty
|
|
|
|
|
|