Cleaning up os 'app' launching, apps always return a function that takes a size for their window

master
Dustin Swan 5 days ago
parent 12a22cf55c
commit eccc14a714
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -1,4 +1,4 @@
inspector = config \
inspector = config \ size \
val = eval! config.name;
reflected = val
@ -10,6 +10,6 @@ inspector = config \
tree {
value = reflected,
path = config.name,
w = config.w,
h = config.h - textInputHeight
w = size.w,
h = size.h - textInputHeight
};

@ -1,4 +1,7 @@
pixelEditor = config \
c = config;
_ = debug! "pixEd config" c;
upArrow = state \ (
newRow = max 0 (state.selectedRow - 1);
{ state = state.{ selectedRow = newRow }, emit = [] });
@ -24,7 +27,7 @@ pixelEditor = config \
| False \ [...state.map, { x = col, y = row }];
{ state = state.{ map = newMap }, emit = [] });
ui.stateful {
size \ ui.stateful {
focusable = True,
autoFocus = True,
@ -61,7 +64,7 @@ pixelEditor = config \
cellWidth = state.pixelWidth * state.zoomMultiplier;
cellHeight = state.pixelHeight * state.zoomMultiplier;
ui.column {
grid = ui.column {
children = map (rIdx \
ui.row {
children = map (cIdx \
@ -75,5 +78,7 @@ pixelEditor = config \
) (range 0 state.pixelWidth)
}
) (range 0 state.pixelHeight)
}
};
center size.w size.h grid
};

@ -179,14 +179,16 @@ os =
onSelect = input \
result = eval! input;
result
| Defined name \ openOrFocus name (size \ inspector { name = name, w = size.w, h = size.h })
| Value v \ (isUI v
| True \ openOrFocus input (_ \ v)
| False \ (getSource input == ""
| True \ openOrFocus input (_ \ ui.text { content = show v, color = "white" })
| False \ openOrFocus input (size \ inspector { name = input, w = size.w, h = size.h })))
| Err msg \ (_ = debug! "Error" msg; noOp);
| Defined name \ openOrFocus name (inspector { name = name })
| Value v \ (isFunction v
| True \ openOrFocus input v
| False \ (isUI v
| True \ openOrFocus input (size \ v)
| False \ (getSource input == ""
| True \ openOrFocus input (_ \ ui.text { content = show v, color = "white" })
| False \ openOrFocus input (inspector { name = input }))))
| Err msg \ (_ = debug! "Error" msg; noOp);
handleFocusLeftEvent = state \
newIndex = max 0 (osState.wm.focusedIndex - 1);

@ -41,7 +41,7 @@ export const _rt = {
clip: (config: any) => ({ kind: 'clip', ...config }),
opacity: (config: any) => ({ kind: 'opacity', ...config }),
stateful: (config: any) => ({ kind: 'stateful', ...config }),
measure: (config: any) => ({ kind: 'measure', ...config }),
measure: measure,
measureText: (text: string) => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
@ -53,8 +53,6 @@ export const _rt = {
},
},
measure: measure,
batch: (events: any[]) => ({ _tag: 'Batch', _0: events }),
noOp: { _tag: 'NoOp' },
focus: (key: string) => ({ _tag: 'Focus', _0: key }),
@ -95,6 +93,7 @@ export const _rt = {
hasField: (field: string) => (obj: any) => ({
_tag: (typeof obj === 'object' && obj !== null && field in obj) ? 'True' : 'False'
}),
isFunction: (v: any) => ({ _tag: typeof v === 'function' ? 'True' : 'False' }),
storeSearch: (query: string) => {
return Object.keys(store)
.filter(name => _rt.fuzzyMatch(query)(name)._tag === 'True')

Loading…
Cancel
Save