mirror of
https://github.com/gchq/CyberChef
synced 2025-01-06 01:28:48 +00:00
EOL sequences are now preserved between tabs
This commit is contained in:
parent
bdb8c02d5a
commit
f6ae89587c
3 changed files with 34 additions and 3 deletions
|
@ -470,6 +470,7 @@ class InputWaiter {
|
||||||
* @param {string} status
|
* @param {string} status
|
||||||
* @param {number} progress
|
* @param {number} progress
|
||||||
* @param {number} encoding
|
* @param {number} encoding
|
||||||
|
* @param {string} eolSequence
|
||||||
* @param {boolean} [silent=false] - If false, fires the manager statechange event
|
* @param {boolean} [silent=false] - If false, fires the manager statechange event
|
||||||
*/
|
*/
|
||||||
async set(inputNum, inputData, silent=false) {
|
async set(inputNum, inputData, silent=false) {
|
||||||
|
@ -477,8 +478,16 @@ class InputWaiter {
|
||||||
const activeTab = this.manager.tabs.getActiveTab("input");
|
const activeTab = this.manager.tabs.getActiveTab("input");
|
||||||
if (inputNum !== activeTab) return;
|
if (inputNum !== activeTab) return;
|
||||||
|
|
||||||
|
// Update current character encoding
|
||||||
this.inputChrEnc = inputData.encoding;
|
this.inputChrEnc = inputData.encoding;
|
||||||
|
|
||||||
|
// Update current eol sequence
|
||||||
|
this.inputEditorView.dispatch({
|
||||||
|
effects: this.inputEditorConf.eol.reconfigure(
|
||||||
|
EditorState.lineSeparator.of(inputData.eolSequence)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
if (inputData.file) {
|
if (inputData.file) {
|
||||||
this.setFile(inputNum, inputData);
|
this.setFile(inputNum, inputData);
|
||||||
} else {
|
} else {
|
||||||
|
@ -634,7 +643,8 @@ class InputWaiter {
|
||||||
inputNum: inputNum,
|
inputNum: inputNum,
|
||||||
buffer: buffer,
|
buffer: buffer,
|
||||||
stringSample: stringSample,
|
stringSample: stringSample,
|
||||||
encoding: this.getChrEnc()
|
encoding: this.getChrEnc(),
|
||||||
|
eolSequence: this.inputEditorView.state.lineBreak
|
||||||
}
|
}
|
||||||
}, transferable);
|
}, transferable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,13 @@ class OutputWaiter {
|
||||||
eolChange(eolVal) {
|
eolChange(eolVal) {
|
||||||
const oldOutputVal = this.getOutput();
|
const oldOutputVal = this.getOutput();
|
||||||
|
|
||||||
|
const currentTabNum = this.manager.tabs.getActiveTab("output");
|
||||||
|
if (currentTabNum >= 0) {
|
||||||
|
this.outputs[currentTabNum].eolSequence = eolVal;
|
||||||
|
} else {
|
||||||
|
throw new Error("Cannot change output eol sequence to " + eolVal);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the EOL value
|
// Update the EOL value
|
||||||
this.outputEditorView.dispatch({
|
this.outputEditorView.dispatch({
|
||||||
effects: this.outputEditorConf.eol.reconfigure(EditorState.lineSeparator.of(eolVal))
|
effects: this.outputEditorConf.eol.reconfigure(EditorState.lineSeparator.of(eolVal))
|
||||||
|
@ -336,7 +343,8 @@ class OutputWaiter {
|
||||||
status: "inactive",
|
status: "inactive",
|
||||||
bakeId: -1,
|
bakeId: -1,
|
||||||
progress: false,
|
progress: false,
|
||||||
encoding: 0
|
encoding: 0,
|
||||||
|
eolSequence: "\u000a"
|
||||||
};
|
};
|
||||||
|
|
||||||
this.outputs[inputNum] = newOutput;
|
this.outputs[inputNum] = newOutput;
|
||||||
|
@ -491,6 +499,13 @@ class OutputWaiter {
|
||||||
|
|
||||||
const outputFile = document.getElementById("output-file");
|
const outputFile = document.getElementById("output-file");
|
||||||
|
|
||||||
|
// Update the EOL value
|
||||||
|
this.outputEditorView.dispatch({
|
||||||
|
effects: this.outputEditorConf.eol.reconfigure(
|
||||||
|
EditorState.lineSeparator.of(output.eolSequence)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
// If pending or baking, show loader and status message
|
// If pending or baking, show loader and status message
|
||||||
// If error, style the tab and handle the error
|
// If error, style the tab and handle the error
|
||||||
// If done, display the output if it's the active tab
|
// If done, display the output if it's the active tab
|
||||||
|
|
|
@ -31,6 +31,7 @@ self.pendingFiles = [];
|
||||||
* @property {string} status
|
* @property {string} status
|
||||||
* @property {number} progress
|
* @property {number} progress
|
||||||
* @property {number} encoding
|
* @property {number} encoding
|
||||||
|
* @property {string} eolSequence
|
||||||
*/
|
*/
|
||||||
self.inputs = {};
|
self.inputs = {};
|
||||||
self.loaderWorkers = [];
|
self.loaderWorkers = [];
|
||||||
|
@ -514,6 +515,7 @@ self.updateInputProgress = function(inputData) {
|
||||||
* @param {number} inputData.inputNum - The input that's having its value updated
|
* @param {number} inputData.inputNum - The input that's having its value updated
|
||||||
* @param {ArrayBuffer} inputData.buffer - The new value of the input as a buffer
|
* @param {ArrayBuffer} inputData.buffer - The new value of the input as a buffer
|
||||||
* @param {number} [inputData.encoding] - The character encoding of the input data
|
* @param {number} [inputData.encoding] - The character encoding of the input data
|
||||||
|
* @param {string} [inputData.eolSequence] - The end of line sequence of the input data
|
||||||
* @param {string} [inputData.stringSample] - A sample of the value as a string (truncated to 4096 chars)
|
* @param {string} [inputData.stringSample] - A sample of the value as a string (truncated to 4096 chars)
|
||||||
*/
|
*/
|
||||||
self.updateInputValue = function(inputData) {
|
self.updateInputValue = function(inputData) {
|
||||||
|
@ -527,6 +529,9 @@ self.updateInputValue = function(inputData) {
|
||||||
if ("encoding" in inputData) {
|
if ("encoding" in inputData) {
|
||||||
self.inputs[inputNum].encoding = inputData.encoding;
|
self.inputs[inputNum].encoding = inputData.encoding;
|
||||||
}
|
}
|
||||||
|
if ("eolSequence" in inputData) {
|
||||||
|
self.inputs[inputNum].eolSequence = inputData.eolSequence;
|
||||||
|
}
|
||||||
if (!("stringSample" in inputData)) {
|
if (!("stringSample" in inputData)) {
|
||||||
inputData.stringSample = Utils.arrayBufferToStr(inputData.buffer.slice(0, 4096));
|
inputData.stringSample = Utils.arrayBufferToStr(inputData.buffer.slice(0, 4096));
|
||||||
}
|
}
|
||||||
|
@ -762,7 +767,8 @@ self.addInput = function(
|
||||||
file: null,
|
file: null,
|
||||||
status: "pending",
|
status: "pending",
|
||||||
progress: 0,
|
progress: 0,
|
||||||
encoding: 0
|
encoding: 0,
|
||||||
|
eolSequence: "\u000a"
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
Loading…
Reference in a new issue