From 08f9a80381b63927fa1e8e2a46a966abdc97bf96 Mon Sep 17 00:00:00 2001 From: salexdv Date: Thu, 25 Aug 2022 12:09:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=B7=D0=BD?= =?UTF-8?q?=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D1=85=20=D1=87=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B7=20tree.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor.js | 82 +++++++++++++++++++++++++++++++++++++++++++++++--- src/index.html | 11 +++++++ src/test.html | 11 +++++++ 3 files changed, 99 insertions(+), 5 deletions(-) diff --git a/src/editor.js b/src/editor.js index 109e9ae..d814029 100644 --- a/src/editor.js +++ b/src/editor.js @@ -192,7 +192,8 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit 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; 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()); - 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() { setFontFamily("Courier New"); @@ -1586,6 +1622,7 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit // #region editor events function initEditorEventListenersAndProperies() { + editor.sendEvent = sendEvent; editor.decorations = []; editor.bookmarks = new Map(); editor.checkBookmarks = true; @@ -2187,7 +2224,6 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit else if (element.classList.contains('detected-link-active')) { let href = getNativeLinkHref(element, null); - if (href) { sendEvent("EVENT_ON_LINK_CLICK", { label: href, href: href }); setTimeout(() => { @@ -2842,7 +2878,7 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit updateStatusBar(); } - + function createDiffWidget(e) { if (inlineDiffWidget) { @@ -3062,6 +3098,36 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit bslHelper.setText('', editor.getModel().getFullModelRange(), false); 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 @@ -3120,6 +3186,12 @@ define(['bslGlobals', 'bslMetadata', 'snippets', 'bsl_language', 'vs/editor/edit resizeStatusBar(); }, true); + + document.getElementById("display-close").addEventListener("click", (event) => { + + hideVariablesDisplay(); + + }); // #endregion }); diff --git a/src/index.html b/src/index.html index 0952574..b54ca8c 100644 --- a/src/index.html +++ b/src/index.html @@ -6,6 +6,7 @@ +