diff --git a/canvas/src/blocks/machine/components/MemoryViewer.tsx b/canvas/src/blocks/machine/components/MemoryViewer.tsx
index fb1bf171..99411a5e 100644
--- a/canvas/src/blocks/machine/components/MemoryViewer.tsx
+++ b/canvas/src/blocks/machine/components/MemoryViewer.tsx
@@ -17,6 +17,7 @@ interface Props {
config?: ViewerConfig
onHover?: (address: number | null) => void
+ onConfirm?: (start: number, end: number) => void
}
const HOLD_MS = 100
@@ -57,6 +58,14 @@ export const MemoryViewer = memo((props: Props) => {
const show = (n: number) => n.toString(base).padStart(pad, "0").toUpperCase()
+ function confirm() {
+ setSelecting(false)
+
+ if (props.onConfirm && start !== null && end !== null) {
+ props.onConfirm(start, end)
+ }
+ }
+
return (
{showAddress && (
@@ -76,7 +85,7 @@ export const MemoryViewer = memo((props: Props) => {
className={cn("px-1 grid nodrag", full && "w-full")}
style={{ gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }}
onMouseLeave={() => {
- if (selecting) setSelecting(false)
+ if (selecting) confirm()
if (props.onHover) props.onHover(null)
}}
>
@@ -102,7 +111,7 @@ export const MemoryViewer = memo((props: Props) => {
}
}}
onMouseUp={() => {
- setSelecting(false)
+ confirm()
aborted.current = true
}}
className={cn(
diff --git a/canvas/src/blocks/machine/components/PaginatedMemoryViewer.tsx b/canvas/src/blocks/machine/components/PaginatedMemoryViewer.tsx
index c128a160..835e50e0 100644
--- a/canvas/src/blocks/machine/components/PaginatedMemoryViewer.tsx
+++ b/canvas/src/blocks/machine/components/PaginatedMemoryViewer.tsx
@@ -2,8 +2,10 @@ import { Icon } from "@iconify/react"
import { useStore } from "@nanostores/react"
import cn from "classnames"
import { useState } from "react"
+import { useReactFlow } from "reactflow"
import { MemoryViewer } from "@/blocks/machine/components/MemoryViewer"
+import { engine } from "@/engine"
import {
$memoryPageConfig,
$memoryPages,
@@ -14,6 +16,9 @@ import {
prevMemPage,
setMemPage,
} from "@/store/memory"
+import { $nodes } from "@/store/nodes"
+import { updateValueViewers } from "@/store/remote-values"
+import { updateMemoryViewer } from "@/store/results"
interface Props {
id: number
@@ -44,11 +49,33 @@ export const PaginatedMemoryViewer = (props: Props) => {
const show = (n: number) =>
`${hex ? "0x" : ""}${n.toString(base).padStart(pad, "0").toUpperCase()}`
+ function onConfirm(start: number, end: number) {
+ const viewer = $nodes
+ .get()
+ .find((n) => n.selected && n.type === "ValueView")
+
+ // Update remote value viewer if it is selected
+ if (viewer) {
+ engine.updateBlockData(viewer.data.id, "ValueView", {
+ target: id,
+ size: end - start + 1,
+ offset: start,
+ })
+
+ updateValueViewers()
+ }
+ }
+
if (!memory || memory.length === 0) return null
return (
-
+