mirror of
https://github.com/He4eT/cheap-glkote.git
synced 2026-05-05 00:47:28 +00:00
Extracting file processing handlers
This commit is contained in:
parent
b367e16941
commit
aa6f7cabf1
3 changed files with 16 additions and 8 deletions
12
src/stdio.js
12
src/stdio.js
|
|
@ -71,15 +71,21 @@ const onDisable = disable =>
|
|||
? detach_handlers()
|
||||
: attach_handlers()
|
||||
|
||||
const onFileNameRequest = (tosave, usage, callback) => {
|
||||
const onFileNameRequest = (tosave, usage, gameid, callback) => {
|
||||
stdout.write('\n')
|
||||
rl.question(
|
||||
'Please enter a file name (without an extension): ',
|
||||
'Please enter a file name: ',
|
||||
filename => callback(filename
|
||||
? { filename, usage }
|
||||
: null))
|
||||
}
|
||||
|
||||
const onFileRead = (dirent, israw) =>
|
||||
void console.log('onFileRead:', dirent)
|
||||
|
||||
const onFileWrite = (dirent, content, israw) =>
|
||||
void console.log('onFileWrite:', dirent, content.length)
|
||||
|
||||
const handle_char_input = (str, key) => {
|
||||
const key_replacements = {
|
||||
'\x7F': 'delete',
|
||||
|
|
@ -132,6 +138,8 @@ module.exports.handlers = {
|
|||
onDisable,
|
||||
onUpdateInputs,
|
||||
onFileNameRequest,
|
||||
onFileRead,
|
||||
onFileWrite,
|
||||
onExit,
|
||||
setSend
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue