1
0
mirror of https://github.com/salexdv/bsl_console.git synced 2024-11-24 08:33:29 +02:00

Вывод значений переменных через tree.js

This commit is contained in:
salexdv 2022-08-25 12:09:26 +03:00
parent 30ea25ebdf
commit 08f9a80381
3 changed files with 99 additions and 5 deletions

View File

@ -192,7 +192,8 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
setTheme = function (theme) { setTheme = function (theme) {
monaco.editor.setTheme(theme); monaco.editor.setTheme(theme);
setThemeVariablesDisplay(theme);
} }
@ -269,6 +270,7 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
version1C = version; version1C = version;
initContextMenuActions(); initContextMenuActions();
editor.layout();
} }
@ -406,10 +408,10 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
} }
getVarsNames = function () { getVarsNames = function (includeLineNumber = false) {
let bsl = new bslHelper(editor.getModel(), editor.getPosition()); let bsl = new bslHelper(editor.getModel(), editor.getPosition());
return bsl.getVarsNames(0); return bsl.getVarsNames(0, includeLineNumber);
} }
@ -1415,6 +1417,40 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
} }
showVariablesDescription = function(variablesJSON) {
try {
showVariablesDisplay();
const variables = JSON.parse(variablesJSON);
treeview = new Treeview("#variables-tree", editor, "./tree/icons/");
treeview.replaceData(variables);
return true;
}
catch (e) {
return { errorDescription: e.message };
}
}
updateVariableDescription = function(variableId, variableJSON) {
try {
const variables = JSON.parse(variableJSON);
treeview.replaceData(variables, variableId);
treeview.open(variableId);
return true;
}
catch (e) {
return { errorDescription: e.message };
}
}
setDefaultStyle = function() { setDefaultStyle = function() {
setFontFamily("Courier New"); setFontFamily("Courier New");
@ -1586,6 +1622,7 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
// #region editor events // #region editor events
function initEditorEventListenersAndProperies() { function initEditorEventListenersAndProperies() {
editor.sendEvent = sendEvent;
editor.decorations = []; editor.decorations = [];
editor.bookmarks = new Map(); editor.bookmarks = new Map();
editor.checkBookmarks = true; editor.checkBookmarks = true;
@ -2187,7 +2224,6 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
else if (element.classList.contains('detected-link-active')) { else if (element.classList.contains('detected-link-active')) {
let href = getNativeLinkHref(element, null); let href = getNativeLinkHref(element, null);
if (href) { if (href) {
sendEvent("EVENT_ON_LINK_CLICK", { label: href, href: href }); sendEvent("EVENT_ON_LINK_CLICK", { label: href, href: href });
setTimeout(() => { setTimeout(() => {
@ -2842,7 +2878,7 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
updateStatusBar(); updateStatusBar();
} }
function createDiffWidget(e) { function createDiffWidget(e) {
if (inlineDiffWidget) { if (inlineDiffWidget) {
@ -3062,6 +3098,36 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
bslHelper.setText('', editor.getModel().getFullModelRange(), false); bslHelper.setText('', editor.getModel().getFullModelRange(), false);
editor.checkBookmarks = true; editor.checkBookmarks = true;
}
function showVariablesDisplay() {
document.getElementById("container").style.height = "70%";
getActiveEditor().layout();
document.getElementById("display-title").innerHTML = engLang ? "Variables" : "Просмотр значений переменных:"
let element = document.getElementById("display");
element.style.height = "30%";
element.style.display = "block";
}
function hideVariablesDisplay() {
document.getElementById("container").style.height = "100%";
getActiveEditor().layout();
let element = document.getElementById("display");
element.style.height = "0";
element.style.display = "none";
}
function setThemeVariablesDisplay(theme) {
if (0 < theme.indexOf('dark'))
document.getElementById("display").classList.add('dark');
else
document.getElementById("display").classList.remove('dark');
} }
// #endregion // #endregion
@ -3120,6 +3186,12 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit
resizeStatusBar(); resizeStatusBar();
}, true); }, true);
document.getElementById("display-close").addEventListener("click", (event) => {
hideVariablesDisplay();
});
// #endregion // #endregion
}); });

View File

@ -6,6 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link href="./decorations.css" rel="stylesheet"> <link href="./decorations.css" rel="stylesheet">
<link href="./tree/tree.css" rel="stylesheet">
<style> <style>
html, html,
body { body {
@ -21,6 +22,15 @@
<body> <body>
<div id="container"></div> <div id="container"></div>
<div id="display">
<div id="display-header">
<div id="display-title"></div>
<div id="display-close"></div>
</div>
<div id="variables-display">
<div id="variables-tree"></div>
</div>
</div>
<button id="event-button"></button> <button id="event-button"></button>
<script> <script>
@ -33,6 +43,7 @@
<script src="./finder.js"></script> <script src="./finder.js"></script>
<script src="./bsl_helper.js"></script> <script src="./bsl_helper.js"></script>
<script src="./init.js"></script> <script src="./init.js"></script>
<script src="./tree/tree.js"></script>
</body> </body>

View File

@ -11,6 +11,7 @@
</script> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/2.0.0/chai.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/2.0.0/chai.js"></script>
<link href="./decorations.css" rel="stylesheet"> <link href="./decorations.css" rel="stylesheet">
<link href="./tree/tree.css" rel="stylesheet">
</head> </head>
<body> <body>
@ -210,6 +211,15 @@
</script> </script>
<div id="container" style="width:100%;height:400px;border:1px solid grey"></div> <div id="container" style="width:100%;height:400px;border:1px solid grey"></div>
<div id="display">
<div id="display-header">
<div id="display-title"></div>
<div id="display-close"></div>
</div>
<div id="variables-display">
<div id="variables-tree"></div>
</div>
</div>
<button id="event-button"></button> <button id="event-button"></button>
<script src="./vs/loader.js"></script> <script src="./vs/loader.js"></script>
@ -217,6 +227,7 @@
<script src="./finder.js"></script> <script src="./finder.js"></script>
<script src="./bsl_helper.js"></script> <script src="./bsl_helper.js"></script>
<script src="./test.js"></script> <script src="./test.js"></script>
<script src="./tree/tree.js"></script>
<div id="mocha"></div> <div id="mocha"></div>