This commit is contained in:
锦恢 2024-05-17 20:46:54 +08:00
commit 87e49a0bff
12 changed files with 62 additions and 41 deletions

2
.gitignore vendored
View File

@ -10,4 +10,4 @@ out-js/
*.pyd *.pyd
resources/hdlParser/parser.js resources/hdlParser/parser.js
resources/hdlParser/parser.wasm resources/hdlParser/parser.wasm
resources/dide-viewer/view/ resources/dide-viewer/view/*

View File

@ -566,21 +566,21 @@ img {
.diagram-container .digrame-port-item { .diagram-container .digrame-port-item {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
height: 60px; height: 40px;
} }
.diagram-container .i-port-name { .diagram-container .i-port-name {
font-size: 20px; font-size: 16px;
padding: 3px 8px; padding: 3px 8px;
} }
.diagram-container .o-port-name { .diagram-container .o-port-name {
font-size: 20px; font-size: 16px;
padding: 3px 8px; padding: 3px 8px;
} }
.diagram-container .io-port-name { .diagram-container .io-port-name {
font-size: 20px; font-size: 16px;
padding: 3px 8px; padding: 3px 8px;
} }
@ -600,7 +600,7 @@ img {
} }
.diagram-container .arrow-wrapper { .diagram-container .arrow-wrapper {
height: 60px; height: 40px;
} }
.diagram-container .port-width-left-caption { .diagram-container .port-width-left-caption {

View File

@ -693,6 +693,11 @@
"when": "resourceLangId == vhdl", "when": "resourceLangId == vhdl",
"command": "digital-ide.vhdl2vlog", "command": "digital-ide.vhdl2vlog",
"group": "navigation@9" "group": "navigation@9"
},
{
"when": "resourceLangId == verilog || resourceLangId == systemverilog || resourceLangId == vhdl",
"command": "digital-ide.hdlDoc.exportFile",
"group": "navigation@10"
} }
], ],
"explorer/context": [ "explorer/context": [
@ -735,6 +740,11 @@
"when": "resourceLangId == vhdl", "when": "resourceLangId == vhdl",
"command": "digital-ide.vhdl2vlog", "command": "digital-ide.vhdl2vlog",
"group": "navigation@12" "group": "navigation@12"
},
{
"when": "resourceLangId == verilog || resourceLangId == systemverilog || resourceLangId == vhdl",
"command": "digital-ide.hdlDoc.exportFile",
"group": "navigation@13"
} }
] ]
}, },

View File

@ -28,8 +28,8 @@
"digital-ide.hard.gui.title": "打开界面", "digital-ide.hard.gui.title": "打开界面",
"digital-ide.hard.exit.title": "退出当前项目", "digital-ide.hard.exit.title": "退出当前项目",
"digital-ide.pickLibrary.title": "从自定义选择自由和普遍", "digital-ide.pickLibrary.title": "从自定义选择自由和普遍",
"digital-ide.pl.setSrcTop.title": "设置为 源文件src的顶层文件", "digital-ide.pl.setSrcTop.title": "设置为 src 的顶层文件",
"digital-ide.pl.setSimTop.title": "设置为 测试文件(sim 的顶层文件", "digital-ide.pl.setSimTop.title": "设置为 sim 的顶层文件",
"digital-ide.pl.addDevice.title": "添加 device", "digital-ide.pl.addDevice.title": "添加 device",
"digital-ide.pl.delDevice.title": "删除 device", "digital-ide.pl.delDevice.title": "删除 device",
"digital-ide.pl.addFile.title": "添加文件", "digital-ide.pl.addFile.title": "添加文件",

View File

@ -0,0 +1 @@
// require view folder

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -52,7 +52,14 @@ function catString(...strings: string[]): string {
return strings.join(''); return strings.join('');
} }
const ThemeColorConfig : { specify: undefined | ThemeType } = {
specify: undefined
};
function getThemeColorKind(): ThemeType { function getThemeColorKind(): ThemeType {
if (ThemeColorConfig.specify !== undefined) {
return ThemeColorConfig.specify;
}
const currentColorKind = vscode.window.activeColorTheme.kind; const currentColorKind = vscode.window.activeColorTheme.kind;
if (currentColorKind === vscode.ColorThemeKind.Dark || if (currentColorKind === vscode.ColorThemeKind.Dark ||
currentColorKind === vscode.ColorThemeKind.HighContrast) { currentColorKind === vscode.ColorThemeKind.HighContrast) {
@ -175,7 +182,7 @@ abstract class RenderString {
this.type = type; this.type = type;
} }
abstract render(): string; abstract render(userStyle?: ThemeType): string;
} }
interface MarkdownStringValue { interface MarkdownStringValue {
@ -390,5 +397,6 @@ export {
makeWaveDromSVG, makeWaveDromSVG,
getWavedromsFromFile, getWavedromsFromFile,
getThemeColorKind, getThemeColorKind,
Count Count,
ThemeColorConfig
}; };

View File

@ -6,7 +6,8 @@ import { hdlFile, hdlPath } from "../../hdlFs";
import { HdlModuleParam, HdlModulePort, HdlModulePortType } from "../../hdlParser/common"; import { HdlModuleParam, HdlModulePort, HdlModulePortType } from "../../hdlParser/common";
import { getThemeColorKind } from "./common"; import { getThemeColorKind } from "./common";
const arrowSvgCache: Record<string, string> = {
const lightArrowSvgCache: Record<string, string> = {
'left': '', 'left': '',
'right': '', 'right': '',
'left-right': '', 'left-right': '',
@ -14,10 +15,21 @@ const arrowSvgCache: Record<string, string> = {
'right-dot': '' 'right-dot': ''
}; };
const darkArrowSvgCache: Record<string, string> = {
'left': '',
'right': '',
'left-right': '',
'left-dot': '',
'right-dot': ''
};
function getArrowSvgString(name: 'left' | 'right' | 'left-right' | 'left-dot' | 'right-dot'): string { function getArrowSvgString(name: 'left' | 'right' | 'left-right' | 'left-dot' | 'right-dot'): string {
const themeType = getThemeColorKind();
const arrowSvgCache = (themeType === ThemeType.Light) ? lightArrowSvgCache: darkArrowSvgCache;
let svgString = arrowSvgCache[name]; let svgString = arrowSvgCache[name];
if (svgString.length === 0) { if (svgString.length === 0) {
const themeType = getThemeColorKind();
const iconFile = name + '-arrow.svg'; const iconFile = name + '-arrow.svg';
const svgDir = hdlPath.join(opeParam.extensionPath, 'images', 'svg'); const svgDir = hdlPath.join(opeParam.extensionPath, 'images', 'svg');
const svgPath = hdlPath.join(svgDir, themeType, iconFile); const svgPath = hdlPath.join(svgDir, themeType, iconFile);

View File

@ -4,9 +4,10 @@ import * as fs from 'fs';
import { opeParam, MainOutput, AbsPath } from '../../global'; import { opeParam, MainOutput, AbsPath } from '../../global';
import { Count, MarkdownString, WavedromString } from './common'; import { Count, MarkdownString, ThemeColorConfig, WavedromString } from './common';
import { getRenderList, getCurrentRenderList } from './markdown'; import { getRenderList, getCurrentRenderList } from './markdown';
import { hdlPath, hdlIcon, hdlFile } from '../../hdlFs'; import { hdlPath, hdlIcon, hdlFile } from '../../hdlFs';
import { ThemeType } from '../../global/enum';
const _cache = { const _cache = {
css : '' css : ''
@ -102,15 +103,17 @@ function makeWavedromRenderErrorHTML() {
* @description make the html string of a finial display style * @description make the html string of a finial display style
* @param usage in whick module is used * @param usage in whick module is used
*/ */
async function makeShowHTML(usage: string): Promise<string> { async function makeShowHTML(usage: 'webview' | 'pdf' | 'html' | 'markdown'): Promise<string> {
// start to render the real html
let body = '';
const userStyle = (usage === 'webview' || usage === 'markdown') ? undefined : ThemeType.Light;
ThemeColorConfig.specify = userStyle;
const renderList = await getCurrentRenderList(); const renderList = await getCurrentRenderList();
if (!renderList || renderList.length === 0) { if (!renderList || renderList.length === 0) {
return ''; return '';
} }
// start to render the real html
let body = '';
for (const r of renderList) { for (const r of renderList) {
const renderResult = r.render(); const renderResult = r.render();
if (renderResult) { if (renderResult) {
@ -134,6 +137,8 @@ async function makeShowHTML(usage: string): Promise<string> {
cssString = cssString.replace(/\.vscode-light/g, '#write'); cssString = cssString.replace(/\.vscode-light/g, '#write');
} }
const html = makeFinalHTML(body, cssString); const html = makeFinalHTML(body, cssString);
ThemeColorConfig.specify = undefined;
return html; return html;
} }

View File

@ -11,7 +11,7 @@ import { MarkdownString, RenderString, RenderType,
import { hdlPath, hdlFile } from '../../hdlFs'; import { hdlPath, hdlFile } from '../../hdlFs';
import { getSymbolComments } from '../lsp/util/feature'; import { getSymbolComments } from '../lsp/util/feature';
import { HdlLangID } from '../../global/enum'; import { HdlLangID, ThemeType } from '../../global/enum';
import { makeDiagram } from './diagram'; import { makeDiagram } from './diagram';
@ -125,7 +125,7 @@ async function getDocsFromModule(module: HdlModule): Promise<MarkdownString> {
const infos = [ const infos = [
`**File:** ${fspath.basename(module.file.path)}`, `**File:** ${fspath.basename(module.file.path)}`,
`${portNum} params, ${paramNum} ports`, `${paramNum} params, ${portNum} ports`,
'top module ' + topModuleDesc 'top module ' + topModuleDesc
]; ];
md.addUnorderedList(infos); md.addUnorderedList(infos);

View File

@ -99,6 +99,10 @@ async function exportCurrentFileDocAsPDF() {
fs.writeFileSync(tempHtmlPath, html); fs.writeFileSync(tempHtmlPath, html);
await htmlFile2PdfFile(tempHtmlPath, pdfPath); await htmlFile2PdfFile(tempHtmlPath, pdfPath);
hdlFile.rmSync(tempHtmlPath); hdlFile.rmSync(tempHtmlPath);
// 在当前编辑器中打开生成的 pdf
vscode.window.showInformationMessage('pdf generated at ' + pdfPath);
} catch (error) { } catch (error) {
MainOutput.report("error happen in export pdf: " + error, ReportType.Error); MainOutput.report("error happen in export pdf: " + error, ReportType.Error);
} }