Skip to content

Commit ab35bc3

Browse files
committed
I'm crushing your head!
1 parent 3c19ae5 commit ab35bc3

3 files changed

Lines changed: 73 additions & 37 deletions

File tree

apps/Terminal.js

Lines changed: 68 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ const RIGHT_KC = KC['RIGHT'];
138138
const UP_KC = KC['UP'];
139139
const DOWN_KC = KC['DOWN'];
140140
const DEL_KC = KC['DEL'];
141+
142+
const INT_ALNUM_RE = /[0-9\p{Letter}]/u;
141143
/*
142144
RIGHT
143145
UP
@@ -8099,7 +8101,7 @@ cerr("What is the array size different from the numStatLines????");
80998101
//»
81008102

81018103
//»
8102-
//Curses«
8104+
//Cursor/Curses«
81038105

81048106
getGrid(){//«
81058107

@@ -8328,36 +8330,28 @@ charRight(no_render){//«
83288330
}
83298331
}//»
83308332
wordOver(is_left){//«
8331-
const getch = ()=>{
8333+
// const INT_ALNUM_RE = /[0-9A-Za-z\u00C0-\u1FFF\u2800-\uFFFD]/;
8334+
const getch = () => {
83328335
return this.lines[this.y+this.scrollNum][this.x];
83338336
};
8334-
const curpos = ()=>{
8337+
const curpos = () => {
83358338
return [this.x, this.y+this.scrollNum];
83368339
};
8337-
const samepos = (pos1, pos2) =>{
8340+
const samepos = (pos1, pos2) => {
83388341
return pos1[0]===pos2[0] && pos1[1] === pos2[1];
83398342
};
8340-
/*
8341-
let kc1, kc2;
8342-
if (is_left) {
8343-
kc1 = LEFT_KEYCODE;
8344-
kc2 = RIGHT_KC;
8345-
}
8346-
else{
8347-
kc1 = RIGHT_KC;
8348-
kc2 = LEFT_KEYCODE;
8349-
}
8350-
*/
8351-
// this.handleArrow(kc1, "");
83528343
is_left ? this.charLeft(true) : this.charRight(true);
83538344
let pos1 = curpos();
83548345
let ch = getch();
8355-
let have_space = ch === " ";
8346+
// let have_space = (ch && !ch.match(/^[a-zA-Z0-9]$/));
8347+
let have_space = !INT_ALNUM_RE.test(ch);
83568348
if (have_space){
83578349
//Rewind to the end of a word
83588350
while (true){
83598351
is_left ? this.charLeft(true) : this.charRight(true);
8360-
if (getch() !== " ") break;
8352+
let ch = getch();
8353+
// if (ch && ch.match(/^[a-zA-Z0-9]$/)) break;
8354+
if (INT_ALNUM_RE.test(ch)) break;
83618355
let pos2 = curpos();
83628356
if (samepos(pos1, pos2)) break;
83638357
pos1 = pos2;
@@ -8368,11 +8362,17 @@ wordOver(is_left){//«
83688362
while (true){
83698363
is_left ? this.charLeft(true) : this.charRight(true);
83708364
let ch = getch();
8371-
if (ch==" "){
8365+
// if (ch==" "){
8366+
// if (ch && !ch.match(/^[a-zA-Z0-9]$/)){
8367+
if (ch && !INT_ALNUM_RE.test(ch)) {
83728368
is_left ? this.charRight(true) : null;
83738369
break;
83748370
}
8375-
else if ((is_left && this.x === 0 && ch && ch != " ") || (!is_left && !ch)){
8371+
// else if (is_left && ch && ch.match(/^[a-zA-Z0-9]$/)&& this.x === 0 && !this.lines[this.y+this.scrollNum]._contPrev){
8372+
else if (is_left && ch && INT_ALNUM_RE.test(ch) && this.x === 0 && !this.lines[this.y+this.scrollNum]._contPrev){
8373+
break;
8374+
}
8375+
else if (!is_left && !ch){
83768376
break;
83778377
}
83788378
let pos2 = curpos();
@@ -8459,11 +8459,16 @@ If not, we simply insert a new line, and call this a continuation.
84598459
//History/Saving«
84608460

84618461
historyUp(){//«
8462+
84628463
if (!(this.bufPos < this.history.length)) return;
84638464
if (this.commandHold == null && this.bufPos == 0) {
84648465
this.commandHold = this.getComArr().join("");
84658466
this.commandPosHold = this.getComPos() + this.promptLen;
84668467
}
8468+
else if (this.bufPos){
8469+
//Always update the history to include any edits made (that weren't entered as commands)
8470+
this.history[this.history.length - this.bufPos] = this.getComArr().join("");
8471+
}
84678472
this.bufPos++;
84688473
let str = this.history[this.history.length - this.bufPos];
84698474
if (!str) return;
@@ -8480,6 +8485,9 @@ historyDown(){//«
84808485

84818486
if (!(this.bufPos > 0)) return;
84828487

8488+
//Always update the history to include any edits made (that weren't entered as commands)
8489+
this.history[this.history.length - this.bufPos] = this.getComArr().join("");
8490+
84838491
this.bufPos--;
84848492
if (this.commandHold==null) return;
84858493
let pos = this.history.length - this.bufPos;
@@ -9329,7 +9337,7 @@ return;
93299337
out=" \n ";
93309338
}
93319339
else if (out.match(/\n$/)){
9332-
cwarn("Chomping ending NEWLINE!!!");
9340+
//cwarn("Chomping ending NEWLINE!!!");
93339341
out = out.replace(/\n$/,"");
93349342
}
93359343
out = out.split("\n");
@@ -9515,19 +9523,27 @@ handleLetterPress(char_arg, no_render){//«
95159523
handleInsert(val){//«
95169524
let arr = val.split("");
95179525
let gotspace = false;
9526+
let num_skipped = 0;
95189527
for (let ch of arr) {
95199528
let code = ch.charCodeAt();
9520-
if (!(code >= 32 && code <= 126)) {
9521-
if (code==10) continue;
9529+
if (INT_ALNUM_RE.test(ch)){}
9530+
// else if (code === 10) continue;
9531+
else {
95229532
code = 32;
9533+
num_skipped++;
95239534
}
9535+
// if (!(code >= 32 && code <= 126)) {
9536+
// if (code==10) continue;
9537+
// code = 32;
9538+
// }
95249539
if (code==32) {
95259540
if (gotspace) continue;
95269541
gotspace = true;
95279542
}
95289543
else gotspace = false;
9529-
this.handleKey(null,code, null, true);
9544+
this.handleKey(null, code, null, true);
95309545
}
9546+
if (num_skipped) this.doOverlay(`Skipped: ${num_skipped} chars`);
95319547
}
95329548
//»
95339549
handleLineStr(str, if_no_render){//«
@@ -9547,11 +9563,14 @@ handleLineStr(str, if_no_render){//«
95479563
}//»
95489564
if (str=="") {}
95499565
else if (!str) return;
9550-
let curnum = this.curPromptLine;
9566+
let cpl = this.curPromptLine;
9567+
// let curnum = this.curPromptLine;
9568+
let curnum = cpl;
95519569
let curx = this.promptLen;
95529570
this.linesHold2 = this.lines;
95539571
if (!this.comScrollMode) {
9554-
this.lines = copy_lines(this.lines, this.curPromptLine)
9572+
// this.lines = copy_lines(this.lines, this.curPromptLine)
9573+
this.lines = copy_lines(this.lines, cpl)
95559574
if (did_fail) {
95569575
this.clear();
95579576
return
@@ -9566,14 +9585,14 @@ handleLineStr(str, if_no_render){//«
95669585
let i;
95679586
let lastln;
95689587
if (!lnstr) {
9569-
if (curnum !== this.curPromptLine) {
9588+
// if (curnum !== this.curPromptLine) {
9589+
if (curnum !== cpl) {
95709590
this.lines[curnum] = [];
95719591
lastln = null;
95729592
}
95739593
curnum++;
95749594
continue;
95759595
}
9576-
//log();
95779596
//PAKJSHFK
95789597
for (i=curnum;lnstr.length>0;i++) {
95799598
let curln = this.lines[i];
@@ -9600,20 +9619,36 @@ handleLineStr(str, if_no_render){//«
96009619
}
96019620
curnum++;
96029621
}
9603-
this.scrollIntoView();
96049622
this.y = this.lines.length-1-this.scrollNum;
9623+
// this.scrollIntoView();
96059624
this.x = curx;
96069625
if (this.x==this.w) {
96079626
this.y++;
96089627
if (!this.lines[this.y+this.scrollNum]) {
96099628
this.lines.push([]);
96109629
}
96119630
this.x=0;
9612-
this.scrollIntoView();
96139631
}
9632+
this.scrollIntoView();
9633+
9634+
//If the prompt is offscreen, scroll forward as much as possible in order to show as much
9635+
//of the command as possible. For commands that take up too many lines, the prompt will
9636+
//always be offscreen, since we are keeping the cursor on the last line of the command.
9637+
if (cpl - this.scrollNum < 0){
9638+
let h_min_1 = this.h-1;
9639+
let y = this.y;
9640+
let scr_num = this.scrollNum;
9641+
while (y < h_min_1 && scr_num > 0) {
9642+
y++;
9643+
scr_num--;
9644+
if (scr_num === cpl) break;
9645+
}
9646+
this.y = y;
9647+
this.scrollNum = scr_num;
9648+
}
9649+
96149650
if (!if_no_render) this.render();
9615-
}
9616-
//»
9651+
}//»
96179652
handleTab(){//«
96189653
if (this.curShell) return;
96199654
this.doCompletion();
@@ -9829,8 +9864,7 @@ handleDelete(mod){//«
98299864
this.render();
98309865
}
98319866
}
9832-
}
9833-
//»
9867+
}//»
98349868
async handleEnter(opts={}){//«
98359869
if (this.sleeping) return;
98369870
this.bufPos = 0;

list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["README.md/2548","apps",["Audio.js/4093","BinView.js/9814","Folder.js/10944","Help.js/979","MediaPlayer.js/2074","Meta.js/2279","Music.js/4844","Something.js/32","Terminal.js/256361","TextEdit.js/5174","WorkMan.js/3808","YourApp.js/174","dev",["Ermpt.js/507","Grammar.js/15536","HTML.js/1348","Hands.js/15575","Launcher.js/20502","NewShell.js/84972","Player.js/2121","Poker5.js/4891","TakePicture.js/3475","Worker.js/1195","audio",["Blah.js/3601","MakeSomeBass.js/5879","Midi.js/3953","Noise.js/2048","Vowels.js/13141","cool",["RandomWalk.js/5090"],"zsave",["Faust.js/35023","Jazzed.js/18165","Jazzed2.js/31797","Karplus.js/30845","Noisecraft.js/11935"]],"svg",["SVG1.js/12599","SVG2.js/18599"],"zold",["Poker.js/26967","Poker2.js/76136","Poker3.js/65113","Poker4.js/36503"]],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/44729"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["ImageView.js/2696","Unicoder.js/16896"]],"bin",["ALLLIST/106","APPLIST/104","DIRGET/47","DOBEAUTIFY/71","DOLINKS/330","DOZIP/801","GITUP/396","MKLOTWLIST/136","MKSYMLINKS/487","PYSERV/84","SSLPYSERV.py/528","dojsbeautify/71","js",["getdir.js/665"],"vallgrep/398","vvallgrep/544"],"coms",["audio.js/1766","esprima.js/171279","extra.js/10807","fs.js/26835","mail.js/43901","shell.js/175037","template.js/475","test",["dummy.js/21"],"test.js/1982","yt.js/66863","zhold",["mail.js/22724"]],"doc",["EDITING/1847","START_HERE/2609","apis",["imap-flow.js/104043","imapflow.txt/38670"],"concepts",["DATA_IPC/4482"],"dev",["CHANGES/2853","DESK/50860","FS/7462","TERMINAL/149463","VIM/16037"]],"index.html/1100","init",["my_setup.js/1264"],"links",["index.html/546"],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"term",["email.js/10406","less.js/19368","log.js/13262","vim.js/150516"],"util",["math.js/12125","nn",["snake",["worker.js/29373"]],"pretty.js/93856","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7198","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"sys",["config.js/8753","desk.js/227147","fs.js/65390","util.js/20006"],"www",["blog.css/181","config",["bashrc.txt/692","desert.vim/2952","nano-hack.txt/2324","vimrc.txt/1443"],"desk.css/1930","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]],"zzhold",["DESK/1306","SHELL/17941","writes",["RUNTIME.js/4583","Terminal.js/80662"]]]
1+
["README.md/2548","apps",["Audio.js/4093","BinView.js/9814","Folder.js/10944","Help.js/979","MediaPlayer.js/2074","Meta.js/2279","Music.js/4844","Something.js/32","Terminal.js/257955","TextEdit.js/5174","WorkMan.js/3808","YourApp.js/174","dev",["Ermpt.js/507","Grammar.js/15536","HTML.js/1348","Hands.js/15575","Launcher.js/20502","NewShell.js/84972","Player.js/2121","Poker5.js/4891","TakePicture.js/3475","Worker.js/1195","audio",["Blah.js/3601","MakeSomeBass.js/5879","Midi.js/3953","Noise.js/2048","Vowels.js/13141","cool",["RandomWalk.js/5090"],"zsave",["Faust.js/35023","Jazzed.js/18165","Jazzed2.js/31797","Karplus.js/30845","Noisecraft.js/11935"]],"svg",["SVG1.js/12599","SVG2.js/18599"],"zold",["Poker.js/26967","Poker2.js/76136","Poker3.js/65113","Poker4.js/36503"]],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/44729"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["ImageView.js/2696","Unicoder.js/16896"]],"bin",["ALLLIST/106","APPLIST/104","DIRGET/47","DOBEAUTIFY/71","DOLINKS/330","DOZIP/801","GITUP/396","MKLOTWLIST/136","MKSYMLINKS/487","PYSERV/84","SSLPYSERV.py/528","dojsbeautify/71","js",["getdir.js/665"],"vallgrep/398","vvallgrep/544"],"coms",["audio.js/1766","esprima.js/171279","extra.js/10807","fs.js/26835","mail.js/43901","shell.js/175037","template.js/475","test",["dummy.js/21"],"test.js/1982","yt.js/66863","zhold",["mail.js/22724"]],"doc",["EDITING/1847","START_HERE/2609","apis",["imap-flow.js/104043","imapflow.txt/38670"],"concepts",["DATA_IPC/4482"],"dev",["CHANGES/2853","DESK/50860","FS/7462","TERMINAL/149463","VIM/16037"]],"index.html/1100","init",["my_setup.js/1264"],"links",["index.html/546"],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"term",["email.js/10406","less.js/19368","log.js/13262","vim.js/150516"],"util",["math.js/12125","nn",["snake",["worker.js/29373"]],"pretty.js/93856","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7198","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"sys",["config.js/8753","desk.js/227178","fs.js/65390","util.js/20006"],"www",["blog.css/181","config",["bashrc.txt/692","desert.vim/2952","nano-hack.txt/2324","vimrc.txt/1443"],"desk.css/1930","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]],"zzhold",["DESK/1306","SHELL/17941","writes",["RUNTIME.js/4583","Terminal.js/80662"]]]

sys/desk.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,12 +824,14 @@ const open_help=()=>{open_app("Help");}
824824

825825
const DESK_CONTEXT_MENU=[
826826
"New",[
827-
"Folder::Ctrl+Alt+d",
827+
// "Folder::Ctrl+Alt+d",
828+
"Folder",
828829
()=>{
829830
if (!SHOW_ICONS) return show_overlay(`SHOW_ICONS == ${SHOW_ICONS}`);
830831
make_new_icon(desk, FOLDER_APP)
831832
},
832-
"Text File::Ctrl+Alt+f",
833+
// "Text File::Ctrl+Alt+f",
834+
"Text File",
833835
()=>{
834836
if (!SHOW_ICONS) return show_overlay(`SHOW_ICONS == ${SHOW_ICONS}`);
835837
make_new_icon(desk, "Text")

0 commit comments

Comments
 (0)