Skip to content

Target dependency graph #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmakels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug)
if((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR (CMAKE_C_COMPILER_ID STREQUAL "Clang"))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-limit-debug-info")
endif()
endif()

include(CTest)
Expand Down
3 changes: 2 additions & 1 deletion cmakels/clients/vscode/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [{
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
Expand Down
11 changes: 11 additions & 0 deletions cmakels/clients/vscode/content/browseTemplate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TITLE</title>
</head>
<body>
PLACEHOLDER
</body>
</html>
134 changes: 134 additions & 0 deletions cmakels/clients/vscode/content/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions cmakels/clients/vscode/content/previewTemplate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="scaling.js"></script>
<title>Graph preview</title>
<style>
.toolbarElement { height: 26px }
</style>
</head>
<body onload="initializeScale(1,false,false)">
<div style="position: fixed; bottom: 3px; left: 3px; font-size: 200%">
<input id="scalePercent" value="100"
style="width: 50px" type="number"
onchange="setScale(this.value/100.0)"
class="toolbarElement"/><span style="font-size: 50%; color: gray">%</span>
<button onclick="larger()" title="Make the graph 50% larger." class="toolbarElement">▲</button>
<button onclick="smaller()" title="Make the graph 50% smaller." class="toolbarElement">▼</button>
<button onclick="original()" title="Reset to 100% zoom." class="toolbarElement">1:1</button>
<button id="fitToWidth"
onclick="fitToWidth()"
ondblclick="setFitToWidthMode(!fitToWidthToggledOn)"
title="Fit to window width. Double-click to toggle it on permanently for dynamic graphs."
class="toolbarElement">↔</button>
<button id="fitToHeight"
onclick="fitToHeight()"
ondblclick="setFitToHeightMode(!fitToHeightToggledOn)"
title="Fit to window height. Double-click to toggle it on permanently for dynamic graphs."
class="toolbarElement">↕</button>
<button id="download"
onclick="exportSvg()"
title="Export to a .svg file..."
class="toolbarElement">↓</button>
<button id="openInBrowser"
onclick="openInBrowser()"
title="Open in the default web browser"
class="toolbarElement">⇱</button>
</div>

PLACEHOLDER
</body>
</html>
148 changes: 148 additions & 0 deletions cmakels/clients/vscode/content/scaling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
var originalWidth = 100;
var originalWidthUnit = "%";

var originalHeight = 100;
var originalHeightUnit = "%";

var svg = null;

var scale = 1;
var fitToHeightToggledOn = false;
var fitToWidthToggledOn = false;

var vscode = null;
try {
vscode = acquireVsCodeApi();
}catch(error){
console.error(error);
// swallow, so in the script can be tested in a browser
}

function initializeScale(initialScale, initialFitToWidthMode, initialFitToHeightMode) {
var svgEls = document.getElementsByTagName("svg");
if (svgEls.length < 1) {
console.error("Cannot find any 'svg' element in the document.");
return;
}

svg = svgEls[0];
var sizePattern = /^([\d.]+)(em|px|%|cm|mm|in|pt|pc)$/g;

var match = sizePattern.exec(svg.getAttribute("width"));
if (match) {
originalWidth = match[1];
originalWidthUnit = match[2];
}

sizePattern.lastIndex = -1;
var match = sizePattern.exec(svg.getAttribute("height"));
if (match) {
originalHeight = match[1];
originalHeightUnit = match[2];
}

// apply initial values
setScale(initialScale);
if (initialFitToWidthMode) fitToWidth();
setFitToWidthMode(initialFitToWidthMode);
if (initialFitToHeightMode) fitToHeight();
setFitToHeightMode(initialFitToHeightMode);

// update the html, but do not send message to extension
update(false);
}

function larger() {
untoggleModes();
scale*=1.5;
update();
}

function smaller() {
untoggleModes();
scale/=1.5;
update();
}

function original() {
untoggleModes();
scale=1;
update();
}

/**
* Used when the user sets the scale manually, or the page is re-initialized.
*/
function setScale(value) {
scale = value;
untoggleModes();
update();
}

function fitToWidth() {
redefineAsPx();
setFitToHeightMode(false);
scale=(window.innerWidth-30)/originalWidth;
update();
}

function fitToHeight() {
redefineAsPx();
setFitToWidthMode(false);
scale=(window.innerHeight-80)/originalHeight;
update();
}

const toggledOnStyle = "background-color: black;color: white;";

function untoggleModes() {
setFitToWidthMode(false);
setFitToHeightMode(false);
}

function setFitToHeightMode(value) {
if (fitToHeightToggledOn == value) return;
fitToHeightToggledOn = value;
var newStyle = fitToHeightToggledOn ? toggledOnStyle : "";
document.getElementById("fitToHeight").setAttribute("style", newStyle);

// post message to the extension, so the fit-to-height toggle is respected after the webview is updated
postMessage({command: 'fitToHeight', value: fitToHeightToggledOn});
}

function setFitToWidthMode(value) {
if (fitToWidthToggledOn == value) return;
fitToWidthToggledOn = value;
var newStyle = fitToWidthToggledOn ? toggledOnStyle : "";
document.getElementById("fitToWidth").setAttribute("style", newStyle);

// post message to the extension, so the fit-to-width toggle is respected after the webview is updated
postMessage({command: 'fitToWidth', value: fitToWidthToggledOn});
}

function redefineAsPx() {
originalWidthUnit = originalHeightUnit = "px";
}

function update(sendMessage=true) {
if (svg) {
svg.setAttribute("style", "width: "+(originalWidth*scale)+originalWidthUnit+
"; height: "+(originalHeight*scale)+originalHeightUnit);
}
document.getElementById("scalePercent").setAttribute("value", (scale*100).toFixed(0));

// post message to the extension, so the scale is respected after the webview is updated
if (sendMessage) postMessage({command: 'scale', value: scale});
}

function exportSvg() {
postMessage({command: 'export'})
}

function openInBrowser() {
postMessage({command: 'open'})
}

function postMessage(message) {
if (vscode) vscode.postMessage(message);
}
Loading