Further improve the remote font intergation: Better preload strategy, better loading and UI interation.

This commit is contained in:
NI
2019-12-13 14:35:23 +08:00
parent a5696d6b63
commit c018c7b4be
12 changed files with 223 additions and 78 deletions

View File

@@ -29,11 +29,13 @@ export class Result {
* @param {string} name Result type
* @param {Info} info Result info
* @param {object} control Result controller
* @param {string} ui User interfact this command will use
*/
constructor(name, info, control) {
constructor(name, info, control, ui) {
this.name = name;
this.info = info;
this.control = control;
this.ui = ui;
}
}
@@ -501,6 +503,16 @@ class Wizard {
return this.built.started();
}
/**
* Return the name of the control info of current wizard
*
* @returns {object}
*
*/
control() {
return this.built.control();
}
/**
* Close current wizard
*

View File

@@ -44,18 +44,17 @@ export class Controls {
* Get a control
*
* @param {string} type Type of the control
* @param {...any} data Data needed to build the control
*
* @returns {object} Control object
*
* @throws {Exception} When given control type is undefined
*
*/
get(type, ...data) {
get(type) {
if (typeof this.controls[type] !== "object") {
throw new Exception('Control "' + type + '" was undefined');
}
return this.controls[type].build(...data);
return this.controls[type];
}
}

View File

@@ -487,7 +487,7 @@ class Wizard {
credential: ""
};
this.step = subs;
this.controls = controls;
this.controls = controls.get("SSH");
this.history = history;
this.step.resolve(this.stepInitialPrompt());
@@ -497,6 +497,10 @@ class Wizard {
return this.hasStarted;
}
control() {
return this.controls;
}
close() {
this.step.resolve(
this.stepErrorDone(
@@ -603,7 +607,7 @@ class Wizard {
new command.Result(
configInput.user + "@" + configInput.host,
self.info,
self.controls.get("SSH", {
self.controls.build({
charset: configInput.charset,
send(data) {
return commandHandler.sendData(data);
@@ -615,7 +619,8 @@ class Wizard {
return commandHandler.sendResize(rows, cols);
},
events: commandHandler.events
})
}),
self.controls.ui()
)
)
);

View File

@@ -249,7 +249,7 @@ class Wizard {
this.config = config;
this.session = session;
this.step = subs;
this.controls = controls;
this.controls = controls.get("Telnet");
this.history = history;
this.step.resolve(this.stepInitialPrompt());
@@ -259,6 +259,10 @@ class Wizard {
return this.hasStarted;
}
control() {
return this.controls;
}
close() {
this.step.resolve(
this.stepErrorDone(
@@ -337,7 +341,7 @@ class Wizard {
new command.Result(
configInput.host,
self.info,
self.controls.get("Telnet", {
self.controls.build({
charset: parsedConfig.charset,
send(data) {
return commandHandler.sendData(data);
@@ -346,7 +350,8 @@ class Wizard {
return commandHandler.sendClose();
},
events: commandHandler.events
})
}),
self.controls.ui()
)
)
);