diff --git a/public/iconfont.css b/public/iconfont.css index bbf1148..ec852fe 100644 --- a/public/iconfont.css +++ b/public/iconfont.css @@ -1,6 +1,6 @@ @font-face { font-family: "iconfont"; /* Project id 4797805 */ - src: url('iconfont.woff2?t=1735470843861') format('woff2'); + src: url('iconfont.woff2?t=1735991360293') format('woff2'); } .iconfont { @@ -11,6 +11,22 @@ -moz-osx-font-smoothing: grayscale; } +.icon-link:before { + content: "\e6fa"; +} + +.icon-Listinterface:before { + content: "\e66b"; +} + +.icon-info-port:before { + content: "\f2e1"; +} + +.icon-sanjiao_fill-:before { + content: "\e6a0"; +} + .icon-memory-chip:before { content: "\e600"; } @@ -243,3 +259,7 @@ content: "\e693"; } +.icon-info-module:before { + content: "\f2e2"; +} + diff --git a/public/iconfont.woff2 b/public/iconfont.woff2 index eaf6e23..1a07a45 100644 Binary files a/public/iconfont.woff2 and b/public/iconfont.woff2 differ diff --git a/src/api/definition.js b/src/api/definition.js new file mode 100644 index 0000000..69be38e --- /dev/null +++ b/src/api/definition.js @@ -0,0 +1,81 @@ +import axios from 'axios'; +import { globalLookup } from "@/hook/global"; +import { pinkLog } from "@/hook/utils"; +import { mode } from "."; + + +/** + * + * @param {string} definition + */ +export async function gotoDefinition(definition) { + const defs = processDefinition(definition); + if (mode === 'debug') { + const res = await axios.post('http://localhost:3000/netlist/goto-definition', { defs }); + } else { + vscode.postMessage({ + command: 'save-as-svg', + data: { svgBuffer, moduleName } + }); + } +} + + +/** + * + * @typedef FileRange + * @property {string} path + * @property {import("@/hook/jsdoc").Range} [range] + * + * @param {string | undefined} definition + * @returns {FileRange[]} + */ +function processDefinition(definition) { + if (typeof definition !== 'string') { + return []; + } + if (definition.includes('|')) { + const defs = []; + for (const def of definition.split('|')) { + defs.push(...processDefinition(def)); + } + return defs; + } + + if (definition.includes(':')) { + const [path, rangeString] = definition.split(':'); + const [startString, endString] = rangeString.split('-'); + const [startLine, startCharacter] = startString.split('.'); + const [endLine, endCharacter] = endString.split('.'); + const range = { + start: { + line: parseRangeInt(startLine), + character: parseRangeInt(startCharacter) + }, + end: { + line: parseRangeInt(endLine), + character: parseRangeInt(endCharacter) + } + }; + + return [ + { path, range } + ]; + } + + return [ + { + path: definition, + range: undefined + } + ]; +} + +function parseRangeInt(s) { + const i = parseInt(s); + if (i > 0) { + // 因为 yosys 是 one index 的,但是 vscode 内部跳转都是 zero index + return i - 1; + } + return i; +} \ No newline at end of file diff --git a/src/api/index.js b/src/api/index.js index 9edbcb6..b547af1 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -5,7 +5,7 @@ import { pinkLog } from "@/hook/utils"; import axios from 'axios'; import pako from 'pako'; -const mode = window.acquireVsCodeApi === undefined ? 'debug' : 'release'; +export const mode = window.acquireVsCodeApi === undefined ? 'debug' : 'release'; pinkLog('digital-netlist-render mode: ' + mode); let vscode = window.acquireVsCodeApi === undefined ? undefined : acquireVsCodeApi(); diff --git a/src/components/about/index.vue b/src/components/about/index.vue index 810bee8..a345e76 100644 --- a/src/components/about/index.vue +++ b/src/components/about/index.vue @@ -1,5 +1,5 @@