u
This commit is contained in:
29
.ui-order.mjs
Normal file
29
.ui-order.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createElement as h, useState } from 'react';
|
||||
import { render, Box, useInput } from 'ink';
|
||||
import TextInput from 'ink-text-input';
|
||||
|
||||
const order = [];
|
||||
function Gate() {
|
||||
useInput((input, key) => {
|
||||
if (key.ctrl && input === 'o') order.push('gate');
|
||||
});
|
||||
return null;
|
||||
}
|
||||
function App() {
|
||||
const [v, setV] = useState('');
|
||||
return h(
|
||||
Box,
|
||||
null,
|
||||
h(Gate, { key: 'g' }),
|
||||
h(TextInput, {
|
||||
key: 't',
|
||||
value: v,
|
||||
onChange: (nv) => { order.push('onChange:' + JSON.stringify(nv)); setV(nv); },
|
||||
}),
|
||||
);
|
||||
}
|
||||
render(h(App), { exitOnCtrlC: false });
|
||||
setTimeout(() => {
|
||||
process.stdout.write('\nORDER=' + JSON.stringify(order) + '\n');
|
||||
process.exit(0);
|
||||
}, 1200);
|
||||
Reference in New Issue
Block a user