Skip to content

Commit

Permalink
Merge branch 'CircuitVerse:main' into applythemes.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatDeparted2061 authored Feb 10, 2025
2 parents 1dae747 + 1ea73f2 commit 67a4326
Show file tree
Hide file tree
Showing 15 changed files with 548 additions and 445 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
## Community
We would love to hear from you! We communicate on Slack:

[![Slack](https://img.shields.io/badge/chat-on_slack-purple.svg?style=for-the-badge&logo=slack)](https://join.slack.com/t/circuitverse-team/shared_invite/zt-p6bgler9-~8vWvsKmL9lZeYg4pP9hwQ)
[![Slack](https://circuitverse.org/slack)

## Installation
To set up the project on your local machine, follow these steps:
Expand Down
11 changes: 6 additions & 5 deletions src/simulator/src/app.js → src/simulator/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { setup } from './setup'
import { setup } from './setup';
import { JsConfig } from './types/app.types'

document.addEventListener('DOMContentLoaded', () => {
setup()
var js = {
setup();
const js: JsConfig = {
devices: {
dev0: {
type: 'Input',
Expand Down Expand Up @@ -206,5 +207,5 @@ document.addEventListener('DOMContentLoaded', () => {
},
],
subcircuits: {},
}
})
};
});
51 changes: 0 additions & 51 deletions src/simulator/src/data/undo.js

This file was deleted.

82 changes: 82 additions & 0 deletions src/simulator/src/data/undo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* eslint-disable import/no-cycle */
import { layoutModeGet } from '../layoutMode'
import Scope, { scopeList } from '../circuit'
import { loadScope } from './load'
import { updateRestrictedElementsInScope } from '../restrictedElementDiv'
import { forceResetNodesSet } from '../engine'

// Declare global variables
declare let globalScope: Scope
declare let loading: boolean

/**
* Function to restore copy from backup
* @param scope - The circuit on which undo is called
* @category data
*/
export default function undo(scope: Scope = globalScope): void {
if (layoutModeGet() || scope.backups.length < 2) return

const { ox, oy, scale } = saveGlobalScopePosition()
resetGlobalScopePosition()

loading = true
const undoData = popLastBackup(scope)
if (!undoData) return

scope.history.push(undoData)

const tempScope = createTempScope(scope)
if (!tempScope) return

updateGlobalScope(tempScope, ox, oy, scale)
forceResetNodesSet(true)
updateRestrictedElementsInScope()
}

function saveGlobalScopePosition() {
return {
ox: globalScope.ox,
oy: globalScope.oy,
scale: globalScope.scale,
}
}

function resetGlobalScopePosition() {
globalScope.ox = 0
globalScope.oy = 0
}

function popLastBackup(scope: Scope): string | undefined {
return scope.backups.pop()
}

function createTempScope(scope: Scope): Scope | undefined {
const tempScope = new Scope(scope.name)
if (scope.backups.length === 0) return tempScope

try {
loadScope(tempScope, JSON.parse(scope.backups[scope.backups.length - 1]))
} catch (error) {
console.error('Failed to parse backup data:', error)
loading = false
return undefined
}

tempScope.backups = scope.backups
tempScope.history = scope.history
tempScope.id = scope.id
tempScope.name = scope.name
tempScope.testbenchData = scope.testbenchData

return tempScope
}

function updateGlobalScope(tempScope: Scope, ox: number, oy: number, scale: number) {
scopeList[tempScope.id] = tempScope
globalScope = tempScope
globalScope.ox = ox
globalScope.oy = oy
globalScope.scale = scale
loading = false
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/**Add more elements here, along with a valid value for key
* Elements keys must have the same name as their ID
**/
export interface DefaultKeysType {
[key: string]: string;
}

export const defaultKeys = {
export const defaultKeys: DefaultKeysType = {
'New Circuit': 'Shift + N',
'Save Online': 'Ctrl + S',
'Save Offline': 'Ctrl + Alt + S',
Expand Down
2 changes: 1 addition & 1 deletion src/simulator/src/hotkey_binder/model/addShortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { saveOffline, openOffline } from '../../data/project'
import createSaveAsImgPrompt from '../../data/saveImage'
import { createSubCircuitPrompt } from '../../subcircuit'
import { createCombinationalAnalysisPrompt } from '../../combinationalAnalysis'
import { shortcut } from './shortcuts.plugin.js'
import { shortcut } from './shortcuts.plugin'
import logixFunction from '../../data'

export const addShortcut = (keys, action) => {
Expand Down
154 changes: 0 additions & 154 deletions src/simulator/src/themer/customThemer.js

This file was deleted.

Loading

0 comments on commit 67a4326

Please sign in to comment.