add wrap to executor (#2679)

This commit is contained in:
Patrick Quist
2021-05-21 20:40:44 +02:00
committed by GitHub
parent 052661d895
commit ba6da76ffc
6 changed files with 263 additions and 7 deletions

View File

@@ -78,6 +78,8 @@ export class ClientStateNormalizer {
executor.argumentsVisible = component.componentState.argsPanelShown;
executor.stdin = component.componentState.execStdin;
executor.stdinVisible = component.componentState.stdinPanelShown;
if (component.componentState.wrap)
executor.wrap = true;
session.executors.push(executor);
} else if (component.componentName === 'ast') {
@@ -286,6 +288,7 @@ class GoldenLayoutComponents {
compilerOutShown: executor.compilerOutputVisible,
argsPanelShown: executor.argumentsVisible,
stdinPanelShown: executor.stdinVisible,
wrap: executor.wrap,
},
isClosable: true,
reorderEnabled: true,

View File

@@ -94,16 +94,18 @@ export class ClientStateCompiler {
export class ClientStateExecutor {
constructor(jsondata) {
this.compilerVisible = false;
this.compilerOutputVisible = false;
this.arguments = [];
this.argumentsVisible = false;
this.stdin = '';
this.stdinVisible = false;
if (jsondata) {
this.fromJsonData(jsondata);
} else {
this.compiler = new ClientStateCompiler();
this.compilerVisible = false;
this.compilerOutputVisible = false;
this.arguments = [];
this.argumentsVisible = false;
this.stdin = '';
this.stdinVisible = false;
this.wrap = false;
}
}
@@ -120,6 +122,8 @@ export class ClientStateExecutor {
this.stdin = jsondata.stdin;
if (typeof jsondata.stdinVisible !== 'undefined')
this.stdinVisible = jsondata.stdinVisible;
if (typeof jsondata.wrap !== 'undefined')
this.wrap = jsondata.wrap;
this.compiler = new ClientStateCompiler(jsondata.compiler);
}

View File

@@ -53,7 +53,8 @@
"compilerOutputVisible": true,
"compilerVisible": false,
"stdin": "",
"stdinVisible": false
"stdinVisible": false,
"wrap": false
}
]
}

View File

@@ -0,0 +1,179 @@
{
"settings": {
"hasHeaders": true,
"constrainDragToContainer": false,
"reorderEnabled": true,
"selectionEnabled": false,
"popoutWholeStack": false,
"blockedPopoutsThrowError": true,
"closePopoutsOnUnload": true,
"showPopoutIcon": false,
"showMaximiseIcon": true,
"showCloseIcon": true,
"responsiveMode": "onload",
"tabOverlapAllowance": 0,
"reorderOnTabMenuClick": true,
"tabControlOffset": 10
},
"dimensions": {
"borderWidth": 5,
"borderGrabWidth": 15,
"minItemHeight": 10,
"minItemWidth": 10,
"headerHeight": 20,
"dragProxyWidth": 300,
"dragProxyHeight": 200
},
"labels": {
"close": "close",
"maximise": "maximise",
"minimise": "minimise",
"popout": "open in new window",
"popin": "pop in",
"tabDropdown": "additional tabs"
},
"content": [
{
"type": "column",
"isClosable": true,
"reorderEnabled": true,
"title": "",
"content": [
{
"type": "stack",
"width": 100,
"height": 50,
"isClosable": true,
"reorderEnabled": true,
"title": "",
"activeItemIndex": 0,
"content": [
{
"type": "component",
"componentName": "codeEditor",
"componentState": {
"id": 1,
"source": "// Type your code here, or load an example.\nint square(int num) {\n return num * num;\n}",
"lang": "c++",
"selection": {
"startLineNumber": 2,
"startColumn": 12,
"endLineNumber": 2,
"endColumn": 19,
"selectionStartLineNumber": 2,
"selectionStartColumn": 19,
"positionLineNumber": 2,
"positionColumn": 12
},
"fontScale": 14,
"fontUsePx": true
},
"isClosable": true,
"reorderEnabled": true,
"title": "C++ source #1"
}
]
},
{
"type": "row",
"isClosable": true,
"reorderEnabled": true,
"title": "",
"height": 50,
"content": [
{
"type": "stack",
"header": {},
"isClosable": true,
"reorderEnabled": true,
"title": "",
"activeItemIndex": 0,
"height": 50,
"width": 50,
"content": [
{
"type": "component",
"componentName": "compiler",
"componentState": {
"id": 1,
"compiler": "g111",
"source": 1,
"options": "",
"filters": {
"binary": false,
"execute": false,
"intel": true,
"demangle": true,
"labels": true,
"libraryCode": true,
"directives": true,
"commentOnly": true,
"trim": false
},
"libs": [],
"lang": "c++",
"selection": {
"startLineNumber": 4,
"startColumn": 17,
"endLineNumber": 4,
"endColumn": 39,
"selectionStartLineNumber": 4,
"selectionStartColumn": 17,
"positionLineNumber": 4,
"positionColumn": 39
},
"fontScale": 14,
"fontUsePx": true
},
"isClosable": true,
"reorderEnabled": true,
"title": "x86-64 gcc 11.1 (Editor #1, Compiler #1) C++"
}
]
},
{
"type": "stack",
"header": {},
"isClosable": true,
"reorderEnabled": true,
"title": "",
"activeItemIndex": 0,
"width": 50,
"content": [
{
"type": "component",
"componentName": "executor",
"componentState": {
"id": 1,
"compiler": "g111",
"source": 1,
"options": "",
"execArgs": "",
"execStdin": "",
"libs": [],
"lang": "c++",
"compilationPanelShown": true,
"compilerOutShown": true,
"argsPanelShown": false,
"stdinPanelShown": false,
"wrap": true,
"fontScale": 14,
"fontUsePx": true
},
"isClosable": true,
"reorderEnabled": true,
"title": "x86-64 gcc 11.1 Executor (Editor #1) C++"
}
]
}
]
}
]
}
],
"isClosable": true,
"reorderEnabled": true,
"title": "",
"openPopouts": [],
"maximisedItemId": null
}

View File

@@ -0,0 +1,57 @@
{
"sessions": [
{
"id": 1,
"language": "c++",
"source": "// Type your code here, or load an example.\nint square(int num) {\n return num * num;\n}",
"conformanceview": false,
"compilers": [
{
"id": "g111",
"options": "",
"filters": {
"binary": false,
"commentOnly": true,
"demangle": true,
"directives": true,
"execute": false,
"intel": true,
"labels": true,
"trim": false
},
"libs": [],
"specialoutputs": [],
"tools": []
}
],
"executors": [
{
"compilerVisible": true,
"compilerOutputVisible": true,
"arguments": "",
"argumentsVisible": false,
"stdin": "",
"stdinVisible": false,
"compiler": {
"id": "g111",
"options": "",
"filters": {
"binary": false,
"commentOnly": true,
"demangle": true,
"directives": true,
"execute": false,
"intel": true,
"labels": true,
"trim": false
},
"libs": [],
"specialoutputs": [],
"tools": []
},
"wrap": true
}
]
}
]
}

View File

@@ -75,6 +75,18 @@ describe('Normalizing clientstate', () => {
normalizer.normalized.should.deep.equal(resultdata);
});
it('Should support newer features', () => {
const normalizer = new ClientStateNormalizer();
const data = JSON.parse(fs.readFileSync('test/state/executorwrap.json'));
normalizer.fromGoldenLayout(data);
const resultdata = JSON.parse(fs.readFileSync('test/state/executorwrap.json.normalized'));
normalizer.normalized.should.deep.equal(resultdata);
});
});
describe('ClientState parsing', () => {