Skip to content

Commit

Permalink
feat: use path for base view
Browse files Browse the repository at this point in the history
  • Loading branch information
qarlosalberto committed Sep 29, 2024
1 parent 476d3b2 commit f1314cf
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 30 deletions.
2 changes: 1 addition & 1 deletion auto_package/templates/info.nj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"displayName": "TerosHDL",
"publisher": "teros-technology",
"description": "Powerful toolbox for ASIC/FPGA: state machine viewer, linter, documentation, snippets... and more! ",
"version": "6.0.8",
"version": "6.0.9",
"engines": {
"vscode": "^1.74.0"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "TerosHDL",
"publisher": "teros-technology",
"description": "Powerful toolbox for ASIC/FPGA: state machine viewer, linter, documentation, snippets... and more! ",
"version": "6.0.8",
"version": "6.0.9",
"engines": {
"vscode": "^1.74.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/colibri/config/config_web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ export const WEB_CONFIG = `
<div class="mb-3">
<label for="schematic-general-extra" class="form-label">
Extra options passed before to run yowasp-yosys. Eg: conda activate base &
Extra options passed before to run yowasp-yosys or yosys. Eg: 'conda activate base & ' or 'C:/OSS-CAD-SUITE/oss-cad-suite/start.bat & '
<span class="markConfig badge bg-secondary" id="mark_schematic-general-extra"></span>
</label>
<input class="form-control" id="schematic-general-extra" rows="3" value=""></input>
Expand Down
2 changes: 1 addition & 1 deletion src/colibri/config/helpers/configs/schematic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ backend:
value: "yowasp"

extra:
description: "Extra options passed before to run yowasp-yosys. Eg: conda activate base & "
description: "Extra options passed before to run yowasp-yosys or yosys. Eg: 'conda activate base & ' or 'C:/OSS-CAD-SUITE/oss-cad-suite/start.bat & '"
type: string
value: ""

Expand Down
2 changes: 1 addition & 1 deletion src/colibri/config/web_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ <h6 class="card-subtitle mb-2 text-muted"></h6>

<div class="mb-3">
<label for="schematic-general-extra" class="form-label">
Extra options passed before to run yowasp-yosys. Eg: conda activate base &
Extra options passed before to run yowasp-yosys or yosys. Eg: 'conda activate base & ' or 'C:/OSS-CAD-SUITE/oss-cad-suite/start.bat & '
<span class="markConfig badge bg-secondary" id="mark_schematic-general-extra"></span>
</label>
<input class="form-control" id="schematic-general-extra" rows="3" value=""></input>
Expand Down
6 changes: 3 additions & 3 deletions src/teroshdl/features/base_webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export abstract class Base_webview {
context.subscriptions.push(
vscode.commands.registerCommand(
activation_command,
async () => {
await this.create_webview();
async (documentUri: vscode.Uri) => {
await this.create_webview(documentUri.fsPath);
}
),
vscode.workspace.onDidOpenTextDocument((e) => this.update_open_document(e)),
Expand All @@ -59,7 +59,7 @@ export abstract class Base_webview {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Abstract
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
abstract create_webview(): void;
abstract create_webview(documentPath: string): void;
abstract update(vscode_document : utils.t_vscode_document): void;
abstract get_webview_content(webview: vscode.Webview): string;

Expand Down
17 changes: 10 additions & 7 deletions src/teroshdl/features/documenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { globalLogger } from '../logger';
import { Documenter } from 'colibri/documenter/documenter';
import { doc_output_type } from 'colibri/documenter/common';
import { t_documenter_options } from 'colibri/config/auxiliar_config';
import { check_if_hdl_file } from 'colibri/utils/hdl_utils';
import { get_language_from_filepath, read_file_sync } from 'colibri/utils/file_utils';

export class Documenter_manager extends Base_webview {

Expand Down Expand Up @@ -69,13 +71,14 @@ export class Documenter_manager extends Base_webview {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Webview creator
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
async create_webview() {
// Get active editor file language. Return if no active editor
const document = utils.get_vscode_active_document();
if (document === undefined) {
return;
}

async create_webview(documentPath: string) {
const document: utils.t_vscode_document = {
filename: documentPath,
is_hdl: check_if_hdl_file(documentPath),
lang: get_language_from_filepath(documentPath),
code: read_file_sync(documentPath)
};

if (this.panel === undefined) {
this.panel = vscode.window.createWebviewPanel(
'catCoding',
Expand Down
18 changes: 10 additions & 8 deletions src/teroshdl/features/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import * as os from 'os';
import * as fs from 'fs';
import * as nunjucks from 'nunjucks';
import { globalLogger } from '../logger';
import { check_if_path_exist, get_default_version_for_filepath, get_language_from_filepath } from 'colibri/utils/file_utils';
import { check_if_path_exist, get_default_version_for_filepath, get_language_from_filepath, read_file_sync } from 'colibri/utils/file_utils';
import { e_source_type, t_file } from 'colibri/project_manager/common';
import { get_toplevel_from_path } from 'colibri/utils/hdl_utils';
import { check_if_hdl_file, get_toplevel_from_path } from 'colibri/utils/hdl_utils';
import { e_schematic_result, getSchematic } from 'colibri/yosys/yosys';
import { e_schematic_general_backend } from 'colibri/config/config_declaration';

Expand Down Expand Up @@ -94,7 +94,7 @@ export class Schematic_manager extends Base_webview {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Webview creator
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
async create_webview(mode_project = false) {
async create_webview(documentPath: string) {
// Create panel
this.panel = vscode.window.createWebviewPanel(
'netlist_viewer',
Expand Down Expand Up @@ -129,11 +129,13 @@ export class Schematic_manager extends Base_webview {

this.panel.webview.html = this.get_webview_content(this.panel.webview);

if (mode_project === false) {
const document = utils.get_vscode_active_document();
if (document === undefined) {
return;
}
if (documentPath != "") {
const document: utils.t_vscode_document = {
filename: documentPath,
is_hdl: check_if_hdl_file(documentPath),
lang: get_language_from_filepath(documentPath),
code: read_file_sync(documentPath)
};
await this.update(document);
}
else {
Expand Down
16 changes: 10 additions & 6 deletions src/teroshdl/features/state_machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { Base_webview } from './base_webview';
import { globalLogger } from '../logger';
import { Multi_project_manager } from 'colibri/project_manager/multi_project_manager';
import { t_documenter_options } from 'colibri/config/auxiliar_config';
import { check_if_hdl_file } from 'colibri/utils/hdl_utils';
import {get_language_from_filepath, read_file_sync} from 'colibri/utils/file_utils';
import { Documenter } from 'colibri/documenter/documenter';

export class State_machine_manager extends Base_webview {
Expand Down Expand Up @@ -79,12 +81,14 @@ export class State_machine_manager extends Base_webview {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Webview creator
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
async create_webview() {
// Get active editor file language. Return if no active editor
const document = utils.get_vscode_active_document();
if (document === undefined) {
return;
}
async create_webview(documentPath: string) {

const document: utils.t_vscode_document = {
filename: documentPath,
is_hdl: check_if_hdl_file(documentPath),
lang: get_language_from_filepath(documentPath),
code: read_file_sync(documentPath)
};

this.panel = vscode.window.createWebviewPanel(
'state_machine_viewer',
Expand Down
2 changes: 1 addition & 1 deletion src/teroshdl/features/tree_views/dependency/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class TreeDependencyManager extends BaseView{
}

open_schematic_viewer(){
this.schematic_manager.create_webview(true);
this.schematic_manager.create_webview("");
}

open_dependencies_viewer(){
Expand Down

0 comments on commit f1314cf

Please sign in to comment.