Skip to content

Commit

Permalink
hex
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Alberto committed Jun 17, 2020
1 parent 4abb6a4 commit fef818f
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 0 deletions.
176 changes: 176 additions & 0 deletions resources/preview_module_doc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<style nonce="{nonce}">



h1,h2,h3,table {margin-left:5%;margin-right:5%;}
td,th,h1,h2,h3 {color: black;}
h1,h2 {font-weight:bold;}
tr:hover {background-color: #ddd;}
td, th {
border: 1px solid grey
}
p {color:black;}
p {margin:5%;}
th { background-color: #ffd78c;}
tr:nth-child(even){background-color: #f2f2f2;}

html,
body {
height: 100%;
overflow: hidden;
overflow-y:auto;
}

body {
background: white;
display: flex;
flex-direction: column;
margin: 0;
padding: 0;
}

.toolbar {
overflow: visible;
width: 100%;
top: 0;
position: absolute;
background: gray;
box-shadow: black 0 0 1em;
color: black;
display: flex;
font: 12px "Segoe UI", sans-serif;
padding: 0.25em;
white-space: nowrap;
z-index: 2;
}
.left-panel,
.center-panel,
.right-panel {
align-items: center;
display: flex;
flex: 1;
}

.center-panel {
justify-content: center;
}

.right-panel {
justify-content: flex-end;
}

.button {
background: dimgray;
border: none;
box-sizing: border-box;
color: whitesmoke;
cursor: default;
font: inherit;
margin: 0.25em;
outline: none !important;
padding: 0.5em;
text-align: center;
text-decoration: none !important;
transition: background ease-out 125ms, color ease-out 125ms;
user-select: none;
width: 10em;
}

.button:hover {
background: darkgray;
box-shadow: inset rgba(255, 255, 255, 0.25) 0 0 1em;
color: black;
}

.fancy-checkbox>input:checked+div,
.button:active {
background: silver;
box-shadow: inset rgba(0, 0, 0, 0.25) 0 0 1em;
color: black;
}

.fancy-checkbox>input {
display: none;
}

.separator {
width: 1em;
}

#zoom {
color: white;
margin: 0.5em;
}

#workspace {
cursor: crosshair;
flex: 1;
overflow: hidden;
position: relative;
user-select: none;
}

#workspace:focus {
outline: none;
}

#image {
box-shadow: rgba(0, 0, 0, 0.6) 0 0 3em;
max-height: none;
max-width: none;
position: absolute;
}

#status {
align-items: center;
background: rgba(0, 0, 0, 0.85);
color: white;
display: flex;
font: 16px Monaco, Menlo, Consolas, monospace;
height: 100%;
justify-content: center;
margin: 0;
position: absolute;
width: 100%;
z-index: 1;
}

#status:empty {
display: none;
}
</style>
<div class="toolbar">
<div class="center-panel">
<label class="fancy-checkbox">
<input id="export-as-markdown" name="zoom-mode" type="radio" value="fixed" />
<div class="button">Export markdown</div>
</label>
<label class="fancy-checkbox">
<input id="export-as-pdf" name="zoom-mode" type="radio" value="fit"/>
<div class="button">Export PDF</div>
</label>
<label class="fancy-checkbox">
<input id="export-as-html" name="zoom-mode" type="radio" value="fit" />
<div class="button">Export HTML</div>
</label>
<label class="fancy-checkbox">
<input id="export-as-image" name="zoom-mode" type="radio" value="fit" />
<div class="button">Export image</div>
</label>
</div>
</div>

<script>
const vscode = acquireVsCodeApi();
document.getElementById("export-as-markdown").onclick = function() {export_message("markdown")};
document.getElementById("export-as-pdf").onclick = function() {export_message("pdf")};
document.getElementById("export-as-html").onclick = function() {export_message("html")};
document.getElementById("export-as-image").onclick = function() {export_message("image")};

function export_message(message) {
vscode.postMessage({
command: 'export',
text: message
})
}
</script>
31 changes: 31 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,37 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.languages.registerDefinitionProvider(verilogSelector, defProvider));
context.subscriptions.push(vscode.workspace.onDidSaveTextDocument((doc) => { docProvider.onSave(doc);}));
/**************************************************************************/
// Hover Hexa
/**************************************************************************/
let aa = vscode.languages.registerHoverProvider({scheme: 'file', language: 'vhdl'}, {
provideHover(document, position, token) {
// const wordRange = document.getText(document.getWordRangeAtPosition(position,/\w[-\w\.\""]*/g));
let wordRange = document.getWordRangeAtPosition(position, /\w[-\w\.\"]*/g);
if (wordRange !== undefined){
let leadingText = document.getText(new vscode.Range(wordRange.start, wordRange.end));
if (/x"[0-9a-fA-F_]+"/g.test(leadingText)) {
const regex = /x"([0-9a-fA-F_]+)"/g;
let number = regex.exec(leadingText.replace('_',''));
if (number === null || number[1] === null){
return;
}
let x = parseInt(number[1], 16);
return new vscode.Hover(leadingText + ' = ' + x + ' (unsigned)');
}
else if (/[0-1_]+"/g.test(leadingText)) {
const regex = /([0-1_]+)"/g;
let number = regex.exec(leadingText.replace('_',''));
if (number === null || number[1] === null){
return;
}
let x = parseInt(number[0], 2);
return new vscode.Hover('"' + leadingText + ' = ' + x + ' (unsigned)');
}
}
}
});
context.subscriptions.push(aa);
/**************************************************************************/
// Test manager
/**************************************************************************/
// get the Test Explorer extension
Expand Down

0 comments on commit fef818f

Please sign in to comment.