/
memory-widget.tsx
109 lines (102 loc) · 4.88 KB
/
memory-widget.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/********************************************************************************
* Copyright (C) 2022 Ericsson, Arm and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import React from 'react';
import { ColumnStatus } from '../columns/column-contribution-service';
import { Decoration, Endianness, MemoryDisplayConfiguration, MemoryState } from '../utils/view-types';
import { MemoryTable } from './memory-table';
import { OptionsWidget } from './options-widget';
import { MemoryOptions, ReadMemoryArguments, SessionContext } from '../../common/messaging';
import { Memory } from '../../common/memory';
interface MemoryWidgetProps extends MemoryDisplayConfiguration {
sessionContext: SessionContext;
configuredReadArguments: Required<ReadMemoryArguments>;
activeReadArguments: Required<ReadMemoryArguments>;
memory?: Memory;
title: string;
decorations: Decoration[];
columns: ColumnStatus[];
effectiveAddressLength: number;
isMemoryFetching: boolean;
updateMemoryState: (state: Partial<MemoryState>) => void;
toggleColumn(id: string, active: boolean): void;
isFrozen: boolean;
toggleFrozen: () => void;
updateMemoryDisplayConfiguration: (memoryArguments: Partial<MemoryDisplayConfiguration>) => void;
resetMemoryDisplayConfiguration: () => void;
updateTitle: (title: string) => void;
fetchMemory(partialOptions?: MemoryOptions): Promise<void>;
storeMemory(): void;
applyMemory(): void;
}
interface MemoryWidgetState {
endianness: Endianness;
}
const defaultOptions: MemoryWidgetState = {
endianness: Endianness.Little,
};
export class MemoryWidget extends React.Component<MemoryWidgetProps, MemoryWidgetState> {
constructor(props: MemoryWidgetProps) {
super(props);
this.state = { ...defaultOptions };
}
override render(): React.ReactNode {
return (<div className='flex flex-column h-full'>
<OptionsWidget
sessionContext={this.props.sessionContext}
title={this.props.title}
updateTitle={this.props.updateTitle}
columnOptions={this.props.columns}
configuredReadArguments={this.props.configuredReadArguments}
activeReadArguments={this.props.activeReadArguments}
endianness={this.state.endianness}
bytesPerWord={this.props.bytesPerWord}
wordsPerGroup={this.props.wordsPerGroup}
groupsPerRow={this.props.groupsPerRow}
updateMemoryState={this.props.updateMemoryState}
updateRenderOptions={this.props.updateMemoryDisplayConfiguration}
resetRenderOptions={this.props.resetMemoryDisplayConfiguration}
addressPadding={this.props.addressPadding}
addressRadix={this.props.addressRadix}
showRadixPrefix={this.props.showRadixPrefix}
fetchMemory={this.props.fetchMemory}
toggleColumn={this.props.toggleColumn}
toggleFrozen={this.props.toggleFrozen}
isFrozen={this.props.isFrozen}
storeMemory={this.props.storeMemory}
applyMemory={this.props.applyMemory}
/>
<MemoryTable
configuredReadArguments={this.props.configuredReadArguments}
activeReadArguments={this.props.activeReadArguments}
decorations={this.props.decorations}
columnOptions={this.props.columns.filter(candidate => candidate.active)}
memory={this.props.memory}
endianness={this.state.endianness}
bytesPerWord={this.props.bytesPerWord}
wordsPerGroup={this.props.wordsPerGroup}
groupsPerRow={this.props.groupsPerRow}
effectiveAddressLength={this.props.effectiveAddressLength}
fetchMemory={this.props.fetchMemory}
isMemoryFetching={this.props.isMemoryFetching}
scrollingBehavior={this.props.scrollingBehavior}
addressPadding={this.props.addressPadding}
addressRadix={this.props.addressRadix}
showRadixPrefix={this.props.showRadixPrefix}
isFrozen={this.props.isFrozen}
/>
</div>);
}
}