Skip to content

Commit 0504f7f

Browse files
committed
Merge branch 'Scarfsail-clipboard-osc52' into dev
2 parents 7c996cc + 4b3a0e3 commit 0504f7f

6 files changed

Lines changed: 120 additions & 72 deletions

File tree

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@babel/preset-env": "^7.29.5",
1313
"@babel/register": "^7.29.3",
1414
"@babel/runtime": "^7.29.2",
15+
"@xterm/addon-clipboard": "^0.2.0",
1516
"@xterm/addon-fit": "^0.11.0",
1617
"@xterm/addon-unicode11": "^0.9.0",
1718
"@xterm/addon-web-links": "^0.12.0",

ui/home.vue

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ export default {
204204
},
205205
data() {
206206
let history = home_history.build(this);
207-
208207
return {
209208
ticker: null,
210209
windows: {
@@ -234,17 +233,14 @@ export default {
234233
this.ticker = setInterval(() => {
235234
this.tick();
236235
}, 1000);
237-
238236
if (this.query.length > 1 && this.query.indexOf("+") === 0) {
239237
this.connectLaunch(this.query.slice(1, this.query.length), (success) => {
240238
if (!success) {
241239
return;
242240
}
243-
244241
this.$emit("navigate-to", "");
245242
});
246243
}
247-
248244
window.addEventListener("beforeunload", this.onBrowserClose);
249245
},
250246
beforeDestroy() {
@@ -266,7 +262,6 @@ export default {
266262
},
267263
tick() {
268264
let now = new Date();
269-
270265
this.socket.update(now, this);
271266
},
272267
closeAllWindow(e) {
@@ -288,25 +283,19 @@ export default {
288283
},
289284
async getStreamThenRun(run, end) {
290285
let errStr = null;
291-
292286
try {
293287
let conn = await this.connection.get(this.socket);
294-
295288
try {
296289
run(conn);
297290
} catch (e) {
298291
errStr = BACKEND_REQUEST_ERROR + e;
299-
300292
process.env.NODE_ENV === "development" && console.trace(e);
301293
}
302294
} catch (e) {
303295
errStr = BACKEND_CONNECT_ERROR + e;
304-
305296
process.env.NODE_ENV === "development" && console.trace(e);
306297
}
307-
308298
end();
309-
310299
if (errStr !== null) {
311300
alert(errStr);
312301
}
@@ -315,14 +304,11 @@ export default {
315304
if (this.connector.acquired) {
316305
return;
317306
}
318-
319307
this.connector.acquired = true;
320308
this.connector.busy = true;
321-
322309
this.getStreamThenRun(
323310
(stream) => {
324311
this.connector.busy = false;
325-
326312
callback(stream);
327313
},
328314
() => {
@@ -333,7 +319,6 @@ export default {
333319
},
334320
connectNew(connector) {
335321
const self = this;
336-
337322
self.runConnect((stream) => {
338323
self.connector.connector = {
339324
id: connector.id(),
@@ -349,13 +334,11 @@ export default {
349334
() => {},
350335
),
351336
};
352-
353337
self.connector.inputting = true;
354338
});
355339
},
356340
connectPreset(preset) {
357341
const self = this;
358-
359342
self.runConnect((stream) => {
360343
self.connector.connector = {
361344
id: preset.command.id(),
@@ -371,37 +354,28 @@ export default {
371354
() => {},
372355
),
373356
};
374-
375357
self.connector.inputting = true;
376358
});
377359
},
378360
getConnectorByType(type) {
379361
let connector = null;
380-
381362
for (let c in this.connector.connectors) {
382363
if (this.connector.connectors[c].name() !== type) {
383364
continue;
384365
}
385-
386366
connector = this.connector.connectors[c];
387367
}
388-
389368
return connector;
390369
},
391370
connectKnown(known) {
392371
const self = this;
393-
394372
self.runConnect((stream) => {
395373
let connector = self.getConnectorByType(known.type);
396-
397374
if (!connector) {
398375
alert("Unknown connector: " + known.type);
399-
400376
self.connector.inputting = false;
401-
402377
return;
403378
}
404-
405379
self.connector.connector = {
406380
id: connector.id(),
407381
name: connector.name(),
@@ -418,40 +392,31 @@ export default {
418392
},
419393
),
420394
};
421-
422395
self.connector.inputting = true;
423396
});
424397
},
425398
parseConnectLauncher(ll) {
426399
let llSeparatorIdx = ll.indexOf(":");
427-
428400
// Type must contain at least one charater
429401
if (llSeparatorIdx <= 0) {
430402
throw new Error("Invalid Launcher string");
431403
}
432-
433404
return {
434405
type: ll.slice(0, llSeparatorIdx),
435406
query: ll.slice(llSeparatorIdx + 1, ll.length),
436407
};
437408
},
438409
connectLaunch(launcher, done) {
439410
this.showConnectWindow();
440-
441411
this.runConnect((stream) => {
442412
let ll = this.parseConnectLauncher(launcher),
443413
connector = this.getConnectorByType(ll.type);
444-
445414
if (!connector) {
446415
alert("Unknown connector: " + ll.type);
447-
448416
this.connector.inputting = false;
449-
450417
return;
451418
}
452-
453419
const self = this;
454-
455420
this.connector.connector = {
456421
id: connector.id(),
457422
name: connector.name(),
@@ -468,35 +433,29 @@ export default {
468433
},
469434
),
470435
};
471-
472436
this.connector.inputting = true;
473437
});
474438
},
475439
buildknownLauncher(known) {
476440
let connector = this.getConnectorByType(known.type);
477-
478441
if (!connector) {
479442
return;
480443
}
481-
482444
return this.hostPath + "#+" + connector.launcher(known.data);
483445
},
484446
exportKnowns() {
485447
return this.connector.historyRec.export();
486448
},
487449
importKnowns(d) {
488450
this.connector.historyRec.import(d);
489-
490451
this.connector.knowns = this.connector.historyRec.all();
491452
},
492453
removeKnown(uid) {
493454
this.connector.historyRec.del(uid);
494-
495455
this.connector.knowns = this.connector.historyRec.all();
496456
},
497457
clearSessionKnown(uid) {
498458
this.connector.historyRec.clearSession(uid);
499-
500459
this.connector.knowns = this.connector.historyRec.all();
501460
},
502461
cancelConnection() {
@@ -507,9 +466,7 @@ export default {
507466
this.connector.inputting = false;
508467
this.connector.acquired = false;
509468
this.windows.connect = false;
510-
511469
this.addToTab(data);
512-
513470
this.$emit("tab-opened", this.tab.tabs);
514471
},
515472
async addToTab(data) {
@@ -525,6 +482,7 @@ export default {
525482
level: "",
526483
message: "",
527484
updated: false,
485+
callback: null,
528486
},
529487
status: {
530488
closing: false,
@@ -534,53 +492,45 @@ export default {
534492
},
535493
removeFromTab(index) {
536494
let isLast = index === this.tab.tabs.length - 1;
537-
538495
this.tab.tabs.splice(index, 1);
539496
this.tab.current = isLast ? this.tab.tabs.length - 1 : index;
540497
},
541498
async switchTab(to) {
542499
if (this.tab.current >= 0) {
543500
await this.tab.tabs[this.tab.current].control.disabled();
544501
}
545-
546502
this.tab.current = to;
547-
548503
this.tab.tabs[this.tab.current].indicator.updated = false;
549504
await this.tab.tabs[this.tab.current].control.enabled();
550505
},
551506
async retapTab(tab) {
552507
this.tab.tabs[tab].toolbar = !this.tab.tabs[tab].toolbar;
553-
554508
await this.tab.tabs[tab].control.retap(this.tab.tabs[tab].toolbar);
555509
},
556510
async closeTab(index) {
557511
if (this.tab.tabs[index].status.closing) {
558512
return;
559513
}
560-
561514
this.tab.tabs[index].status.closing = true;
562-
563515
try {
564516
this.tab.tabs[index].control.disabled();
565-
566517
await this.tab.tabs[index].control.close();
567518
} catch (e) {
568519
alert("Cannot close tab due to error: " + e);
569-
570520
process.env.NODE_ENV === "development" && console.trace(e);
571521
}
572-
573522
this.removeFromTab(index);
574-
575523
this.$emit("tab-closed", this.tab.tabs);
576524
},
577525
tabStopped(index, reason) {
578526
if (reason !== null) {
579527
this.tab.tabs[index].indicator.message = "" + reason;
580528
this.tab.tabs[index].indicator.level = "error";
529+
this.tab.tabs[index].indicator.callback = null;
581530
} else {
582531
this.tab.tabs[index].indicator.message = "";
583532
this.tab.tabs[index].indicator.level = "";
533+
this.tab.tabs[index].indicator.callback = null;
584534
}
585535
},
586536
tabMessage(index, msg, type) {
@@ -591,15 +541,14 @@ export default {
591541
) {
592542
return;
593543
}
594-
595544
this.tab.tabs[index].indicator.message = "";
596545
this.tab.tabs[index].indicator.level = "";
597-
546+
this.tab.tabs[index].indicator.callback = null;
598547
return;
599548
}
600-
601549
this.tab.tabs[index].indicator.message = msg.text;
602550
this.tab.tabs[index].indicator.level = type;
551+
this.tab.tabs[index].indicator.callback = msg.callback;
603552
},
604553
tabWarning(index, msg) {
605554
this.tabMessage(index, msg, "warning");
@@ -609,7 +558,6 @@ export default {
609558
},
610559
tabUpdated(index) {
611560
this.$emit("tab-updated", this.tab.tabs);
612-
613561
this.tab.tabs[index].indicator.updated = index !== this.tab.current;
614562
},
615563
},

0 commit comments

Comments
 (0)