mirror of
https://codeberg.org/TicklishHoneyBee/CLIte.git
synced 2026-03-11 09:04:37 +00:00
getBuffer for future io redirects
This commit is contained in:
parent
48aad6beba
commit
04a4b8ed87
1 changed files with 24 additions and 1 deletions
|
|
@ -1464,6 +1464,28 @@ clite.lib = {
|
|||
return 0;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
getBuffer:function() {
|
||||
return Object.create({
|
||||
buffer:{
|
||||
data:'',
|
||||
pos:0
|
||||
},
|
||||
read:function() {
|
||||
if (this.buffer.pos >= this.buffer.data.length)
|
||||
return null;
|
||||
var b = this.data.buffer.substring(this.buffer.pos,this.buffer.data.length-this.buffer.pos);
|
||||
var i = b.indexOf('\n');
|
||||
if (b < 0)
|
||||
return b;
|
||||
return b.substring(0,i);
|
||||
},
|
||||
write:function(txt) {
|
||||
this.buffer.data += txt;
|
||||
}
|
||||
});
|
||||
},
|
||||
exec:function(args,io) {
|
||||
}
|
||||
}
|
||||
clite.lib.api = { // this is passed to programs via include('stdlib')
|
||||
|
|
@ -1471,5 +1493,6 @@ clite.lib.api = { // this is passed to programs via include('stdlib')
|
|||
dirname:clite.lib.dirname,
|
||||
resolvePath:clite.lib.resolvePath,
|
||||
getFileType:clite.lib.getFileType,
|
||||
strToArgs:clite.lib.strToArgs
|
||||
strToArgs:clite.lib.strToArgs,
|
||||
exec:clite.lib.exec
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue