Skip to content

Commit b13df80

Browse files
Eggsglange, ronkertairternt
1 parent 53aa301 commit b13df80

1 file changed

Lines changed: 58 additions & 42 deletions

File tree

apps/Terminal.js

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ let USE_ONRELOAD = true;
175175

176176
//This means that the terminal app window is reloaded by Ctrl+r (there is no onreload on the app)
177177
//let USE_ONRELOAD = false;
178+
178179
//let NO_ONRELOAD = false;
179180
//Terminal Imports«
180181
const NS = LOTW;
@@ -2019,9 +2020,10 @@ async updateHistory(str){//«
20192020
await this.appendToHistory(str);
20202021
}
20212022
}//»
2022-
async initHistory(termBuffer){//«
2023-
if (termBuffer) {
2024-
this.history = termBuffer;
2023+
async initHistory(history, historyNode){//«
2024+
if (history) {
2025+
this.history = history;
2026+
this.historyNode = historyNode;
20252027
return;
20262028
}
20272029
let arr = await this.getHistory();
@@ -2460,13 +2462,15 @@ async doCompletion(){//«
24602462
return this.doGetDirContents(use_dir, tok, tok0, arr_pos);
24612463
}
24622464
if (tokpos==1) {
2463-
contents = await this.getCommandArr(use_dir, Object.keys(this.ShellMod.activeCommands), tok)
2465+
//log(this.funcs);.concat(Object.keys(this.funcs));
2466+
// contents = await this.getCommandArr(use_dir, Object.keys(this.ShellMod.activeCommands), tok)
2467+
contents = await this.getCommandArr(use_dir, Object.keys(this.ShellMod.activeCommands).concat(Object.keys(this.funcs)), tok)
24642468
}
24652469
else {
2466-
if (tok0 == "help"){
2467-
contents = await this.getCommandArr(use_dir, Object.keys(this.ShellMod.activeCommands), tok)
2468-
}
2469-
else if (tok0 == "lib" || tok0 == "import"){
2470+
// if (tok0 == "help"){
2471+
// contents = await this.getCommandArr(use_dir, Object.keys(this.ShellMod.activeCommands), tok)
2472+
// }
2473+
if (tok0 == "lib" || tok0 == "import"){
24702474
contents = await this.getCommandArr(use_dir, await util.getList("/site/coms/"), tok)
24712475
}
24722476
else if (tok0 == "app" || tok0 == "appicon"){
@@ -2742,8 +2746,6 @@ responseEnd(opts={}) {//«
27422746
//Why does (did) this line exist???
27432747
// if (this.isPager) return;
27442748

2745-
// this.#doContinue = false;
2746-
27472749
this.setPrompt();
27482750
this.scrollIntoView();
27492751
this.sleeping = null;
@@ -2909,25 +2911,13 @@ this.numCtrlD++;
29092911
this.doOverlay(`Ctrl+d: ${this.numCtrlD}`);
29102912
//cwarn("Calling do_ctrl_D!!! (nothing doing)");
29112913
};//»
2914+
29122915
doCtrlC(){//«
2913-
if (this.curShell) {
2914-
this.env['?'] = 0;
2915-
if (this.curShell.stdin) {
2916-
this.curShell.stdin(null, true);
2917-
delete this.curShell.stdin;
2918-
}
2919-
}
2920-
else {
2921-
this.handleKey(null,"^".charCodeAt(), null, true);
2922-
this.handleKey(null,"C".charCodeAt(), null, true);
2923-
this.rootState = null;
2924-
this.bufPos = 0;
2925-
this.commandHold = null;
2926-
this.env['?'] = 0;
2927-
this.responseEnd();
2928-
}
2929-
}
2930-
//»
2916+
this.bufPos = 0;
2917+
this.commandHold = null;
2918+
this.response("^C");
2919+
this.responseEnd();
2920+
}//»
29312921
handleLetterPress(char_arg, no_render){//«
29322922
const{lines, w} = this;
29332923
const end=()=>{
@@ -3387,6 +3377,13 @@ handleReadlineEnter(){//«
33873377
this.forceNewline();
33883378
//log(this.curPromptLine);
33893379
}//»
3380+
cancelShell(){//«
3381+
this.curShell.cancel();
3382+
this.curShell = null;
3383+
this.sleeping = false;
3384+
this.response("^C");
3385+
this.responseEnd();
3386+
}//»
33903387
handleKey(sym, code, mod, ispress, e){//«
33913388
const{lines}=this;
33923389
if (this.sleeping) {
@@ -3395,11 +3392,7 @@ handleKey(sym, code, mod, ispress, e){//«
33953392
if (this.curShell){//«
33963393

33973394
if (sym==="c_C") {//«
3398-
this.curShell.cancel();
3399-
this.curShell = null;
3400-
this.sleeping = false;
3401-
this.response("^C");
3402-
this.responseEnd();
3395+
this.cancelShell();
34033396
return;
34043397
}//»
34053398
else if (this.getChCb){//«
@@ -3632,12 +3625,11 @@ onkeydown(e,sym,mod){//«
36323625
if (this.readLineCb){
36333626
if (sym=="c_C"){
36343627
//RMLDURHTJ
3635-
this.readLineCb(EOF);
3628+
// this.readLineCb(EOF);
36363629
this.readLineCb = null;
36373630
this.readLineStartLine = null;
3638-
this.doOverlay("Readline: cancelled");
3639-
this.curShell.cancel();
3640-
this.response("^C");
3631+
// this.doOverlay("Readline: cancelled");
3632+
this.cancelShell();
36413633
return;
36423634
}
36433635
this.handleKey(sym, code, mod, false, e);
@@ -3731,9 +3723,9 @@ async _onreload(){//«
37313723
//SGPEJGKH
37323724
//Just reload the shell (if working on a devtest command)
37333725
//log(this.env);
3734-
// await this._reloadShell();
3726+
await this._reloadShell();
37353727

3736-
await this._reloadLibs(["fs"]);
3728+
// await this._reloadLibs(["fs"]);
37373729
// await this._reloadLibs(["net.fs"]);
37383730
// await this._reloadLibs(RELOAD_LIBS);
37393731

@@ -3746,7 +3738,8 @@ onkill(if_dev_reload){//«
37463738
}
37473739

37483740
this.reInit={
3749-
termBuffer: this.history,
3741+
history: this.history,
3742+
historyNode: this.historyNode
37503743
// useOnDevReload: !!this.ondevreload
37513744
};
37523745

@@ -3774,13 +3767,13 @@ async onappinit(appargs={}){//«
37743767
//QDPLMRT
37753768
if (USE_ONRELOAD) this.onreload = this._onreload;
37763769
// let {termBuffer, addMessage, commandStr, histories, useOnDevReload} = reInit;
3777-
let {termBuffer, addMessage, commandStr, histories} = reInit;
3770+
let {history, historyNode, addMessage, commandStr} = reInit;
37783771
if (appargs.noKbReload){
37793772
if (!addMessage) addMessage = "";
37803773
addMessage += "Keyboard reloading: disabled";
37813774
this.Win.noKbReload = appargs.noKbReload;
37823775
}
3783-
await this.initHistory(termBuffer);
3776+
await this.initHistory(history, historyNode);
37843777
await this.initLibs(addMessage);
37853778
this.didInit = true;
37863779
this.sleeping = false;
@@ -3953,3 +3946,26 @@ quitNewScreen(screen, opts={}){//«
39533946

39543947
//»
39553948

3949+
3950+
/*
3951+
doCtrlC(){//«
3952+
if (this.curShell) {
3953+
this.env['?'] = 0;
3954+
if (this.curShell.stdin) {
3955+
this.curShell.stdin(null, true);
3956+
delete this.curShell.stdin;
3957+
}
3958+
}
3959+
else {
3960+
this.handleKey(null,"^".charCodeAt(), null, true);
3961+
this.handleKey(null,"C".charCodeAt(), null, true);
3962+
this.rootState = null;
3963+
this.bufPos = 0;
3964+
this.commandHold = null;
3965+
this.env['?'] = 0;
3966+
this.response("^C");
3967+
this.responseEnd();
3968+
}
3969+
}
3970+
//»
3971+
*/

0 commit comments

Comments
 (0)