@theia/memory-inspector 1.45.1 → 1.46.0-next.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -71
- package/lib/browser/diff-widget/memory-diff-options-widget.d.ts +36 -36
- package/lib/browser/diff-widget/memory-diff-options-widget.js +132 -132
- package/lib/browser/diff-widget/memory-diff-select-widget.d.ts +50 -50
- package/lib/browser/diff-widget/memory-diff-select-widget.js +137 -137
- package/lib/browser/diff-widget/memory-diff-table-widget.d.ts +77 -77
- package/lib/browser/diff-widget/memory-diff-table-widget.js +314 -314
- package/lib/browser/diff-widget/memory-diff-widget-types.d.ts +41 -41
- package/lib/browser/diff-widget/memory-diff-widget-types.js +23 -23
- package/lib/browser/editable-widget/memory-editable-table-widget.d.ts +64 -64
- package/lib/browser/editable-widget/memory-editable-table-widget.js +324 -324
- package/lib/browser/memory-inspector-frontend-contribution.d.ts +46 -46
- package/lib/browser/memory-inspector-frontend-contribution.js +291 -291
- package/lib/browser/memory-inspector-frontend-module.d.ts +21 -21
- package/lib/browser/memory-inspector-frontend-module.js +87 -87
- package/lib/browser/memory-provider/cdt-gdb-memory-provider.d.ts +35 -35
- package/lib/browser/memory-provider/cdt-gdb-memory-provider.js +136 -136
- package/lib/browser/memory-provider/memory-provider-service.d.ts +36 -36
- package/lib/browser/memory-provider/memory-provider-service.js +101 -101
- package/lib/browser/memory-provider/memory-provider.d.ts +65 -65
- package/lib/browser/memory-provider/memory-provider.js +96 -96
- package/lib/browser/memory-provider/memory-provider.spec.d.ts +16 -16
- package/lib/browser/memory-provider/memory-provider.spec.js +23 -23
- package/lib/browser/memory-widget/memory-options-widget.d.ts +136 -136
- package/lib/browser/memory-widget/memory-options-widget.js +564 -564
- package/lib/browser/memory-widget/memory-table-widget.d.ts +146 -146
- package/lib/browser/memory-widget/memory-table-widget.js +487 -487
- package/lib/browser/memory-widget/memory-widget.d.ts +33 -33
- package/lib/browser/memory-widget/memory-widget.js +112 -112
- package/lib/browser/register-widget/register-filter-service.d.ts +42 -42
- package/lib/browser/register-widget/register-filter-service.js +81 -81
- package/lib/browser/register-widget/register-options-widget.d.ts +81 -81
- package/lib/browser/register-widget/register-options-widget.js +338 -338
- package/lib/browser/register-widget/register-table-widget.d.ts +77 -77
- package/lib/browser/register-widget/register-table-widget.js +230 -230
- package/lib/browser/register-widget/register-widget-types.d.ts +29 -29
- package/lib/browser/register-widget/register-widget-types.js +35 -35
- package/lib/browser/utils/memory-commands.d.ts +27 -27
- package/lib/browser/utils/memory-commands.js +67 -67
- package/lib/browser/utils/memory-hover-renderer.d.ts +33 -33
- package/lib/browser/utils/memory-hover-renderer.js +111 -111
- package/lib/browser/utils/memory-recents.d.ts +27 -27
- package/lib/browser/utils/memory-recents.js +52 -52
- package/lib/browser/utils/memory-widget-components.d.ts +58 -58
- package/lib/browser/utils/memory-widget-components.js +69 -69
- package/lib/browser/utils/memory-widget-manager.d.ts +50 -50
- package/lib/browser/utils/memory-widget-manager.js +182 -182
- package/lib/browser/utils/memory-widget-utils.d.ts +113 -113
- package/lib/browser/utils/memory-widget-utils.js +42 -42
- package/lib/browser/utils/memory-widget-variable-utils.d.ts +57 -57
- package/lib/browser/utils/memory-widget-variable-utils.js +143 -143
- package/lib/browser/utils/multi-select-bar.d.ts +31 -31
- package/lib/browser/utils/multi-select-bar.js +34 -34
- package/lib/browser/wrapper-widgets/memory-dock-panel.d.ts +24 -24
- package/lib/browser/wrapper-widgets/memory-dock-panel.js +48 -48
- package/lib/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.d.ts +23 -23
- package/lib/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.js +57 -57
- package/lib/browser/wrapper-widgets/memory-layout-widget.d.ts +51 -51
- package/lib/browser/wrapper-widgets/memory-layout-widget.js +191 -191
- package/lib/common/util.d.ts +21 -21
- package/lib/common/util.js +30 -30
- package/lib/common/utils.spec.d.ts +16 -16
- package/lib/common/utils.spec.js +45 -45
- package/package.json +4 -4
- package/src/browser/diff-widget/memory-diff-options-widget.tsx +152 -152
- package/src/browser/diff-widget/memory-diff-select-widget.tsx +163 -163
- package/src/browser/diff-widget/memory-diff-table-widget.tsx +366 -366
- package/src/browser/diff-widget/memory-diff-widget-types.ts +45 -45
- package/src/browser/editable-widget/memory-editable-table-widget.tsx +359 -359
- package/src/browser/memory-inspector-frontend-contribution.ts +301 -301
- package/src/browser/memory-inspector-frontend-module.ts +118 -118
- package/src/browser/memory-provider/cdt-gdb-memory-provider.ts +132 -132
- package/src/browser/memory-provider/memory-provider-service.ts +86 -86
- package/src/browser/memory-provider/memory-provider.spec.ts +23 -23
- package/src/browser/memory-provider/memory-provider.ts +119 -119
- package/src/browser/memory-widget/memory-options-widget.tsx +738 -738
- package/src/browser/memory-widget/memory-table-widget.tsx +625 -625
- package/src/browser/memory-widget/memory-widget.ts +114 -114
- package/src/browser/register-widget/register-filter-service.ts +76 -76
- package/src/browser/register-widget/register-options-widget.tsx +393 -393
- package/src/browser/register-widget/register-table-widget.tsx +276 -276
- package/src/browser/register-widget/register-widget-types.ts +45 -45
- package/src/browser/register-widget/register-widget.css +34 -34
- package/src/browser/style/index.css +746 -746
- package/src/browser/style/memory-lock.svg +21 -21
- package/src/browser/style/memory-view.svg +20 -20
- package/src/browser/style/register-lock.svg +29 -29
- package/src/browser/style/register-view.svg +28 -28
- package/src/browser/utils/memory-commands.ts +76 -76
- package/src/browser/utils/memory-hover-renderer.ts +113 -113
- package/src/browser/utils/memory-recents.ts +58 -58
- package/src/browser/utils/memory-widget-components.tsx +193 -193
- package/src/browser/utils/memory-widget-manager.ts +179 -179
- package/src/browser/utils/memory-widget-utils.tsx +132 -132
- package/src/browser/utils/memory-widget-variable-utils.ts +170 -170
- package/src/browser/utils/multi-select-bar.css +61 -61
- package/src/browser/utils/multi-select-bar.tsx +75 -75
- package/src/browser/wrapper-widgets/memory-dock-panel.ts +51 -51
- package/src/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.tsx +38 -38
- package/src/browser/wrapper-widgets/memory-layout-widget.tsx +167 -167
- package/src/common/util.ts +28 -28
- package/src/common/utils.spec.ts +52 -52
|
@@ -1,488 +1,488 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/********************************************************************************
|
|
3
|
-
* Copyright (C) 2021 Ericsson and others.
|
|
4
|
-
*
|
|
5
|
-
* This program and the accompanying materials are made available under the
|
|
6
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
*
|
|
9
|
-
* This Source Code may also be made available under the following Secondary
|
|
10
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
* with the GNU Classpath Exception which is available at
|
|
13
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
*
|
|
15
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
********************************************************************************/
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
var MemoryTableWidget_1;
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.MemoryTableWidget = exports.MemoryTable = void 0;
|
|
29
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
30
|
-
const theming_1 = require("@theia/core/lib/browser/theming");
|
|
31
|
-
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
32
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
33
|
-
const React = require("@theia/core/shared/react");
|
|
34
|
-
const util_1 = require("../../common/util");
|
|
35
|
-
const memory_provider_service_1 = require("../memory-provider/memory-provider-service");
|
|
36
|
-
const memory_hover_renderer_1 = require("../utils/memory-hover-renderer");
|
|
37
|
-
const memory_widget_components_1 = require("../utils/memory-widget-components");
|
|
38
|
-
const memory_widget_utils_1 = require("../utils/memory-widget-utils");
|
|
39
|
-
const memory_widget_variable_utils_1 = require("../utils/memory-widget-variable-utils");
|
|
40
|
-
const memory_options_widget_1 = require("./memory-options-widget");
|
|
41
|
-
const debounce = require("@theia/core/shared/lodash.debounce");
|
|
42
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
43
|
-
var MemoryTable;
|
|
44
|
-
(function (MemoryTable) {
|
|
45
|
-
MemoryTable.ROW_CLASS = 't-mv-view-row';
|
|
46
|
-
MemoryTable.ROW_DIVIDER_CLASS = 't-mv-view-row-highlight';
|
|
47
|
-
MemoryTable.ADDRESS_DATA_CLASS = 't-mv-view-address';
|
|
48
|
-
MemoryTable.MEMORY_DATA_CLASS = 't-mv-view-data';
|
|
49
|
-
MemoryTable.EXTRA_COLUMN_DATA_CLASS = 't-mv-view-code';
|
|
50
|
-
MemoryTable.GROUP_SPAN_CLASS = 'byte-group';
|
|
51
|
-
MemoryTable.BYTE_SPAN_CLASS = 'single-byte';
|
|
52
|
-
MemoryTable.EIGHT_BIT_SPAN_CLASS = 'eight-bits';
|
|
53
|
-
MemoryTable.HEADER_LABEL_CONTAINER_CLASS = 't-mv-header-label-container';
|
|
54
|
-
MemoryTable.HEADER_LABEL_CLASS = 't-mv-header-label';
|
|
55
|
-
MemoryTable.VARIABLE_LABEL_CLASS = 't-mv-variable-label';
|
|
56
|
-
MemoryTable.HEADER_ROW_CLASS = 't-mv-header';
|
|
57
|
-
})(MemoryTable = exports.MemoryTable || (exports.MemoryTable = {}));
|
|
58
|
-
let MemoryTableWidget = MemoryTableWidget_1 = class MemoryTableWidget extends browser_1.ReactWidget {
|
|
59
|
-
constructor() {
|
|
60
|
-
super(...arguments);
|
|
61
|
-
this.deferredScrollContainer = new promise_util_1.Deferred();
|
|
62
|
-
this.updateColumnWidths = debounce(this.doUpdateColumnWidths.bind(this), memory_widget_utils_1.Constants.DEBOUNCE_TIME);
|
|
63
|
-
this.assignScrollContainerRef = (element) => {
|
|
64
|
-
this.deferredScrollContainer.resolve(element);
|
|
65
|
-
};
|
|
66
|
-
this.loadMoreMemory = async (options) => {
|
|
67
|
-
const { direction, numBytes } = options;
|
|
68
|
-
const { address, offset, length } = this.optionsWidget.options;
|
|
69
|
-
let newOffset = 0;
|
|
70
|
-
const newLength = length + numBytes;
|
|
71
|
-
if (direction === 'above') {
|
|
72
|
-
newOffset = offset - numBytes;
|
|
73
|
-
}
|
|
74
|
-
await this.optionsWidget.setAddressAndGo(`${address}`, newOffset, newLength, direction);
|
|
75
|
-
};
|
|
76
|
-
this.handleTableMouseMove = (e) => {
|
|
77
|
-
const { target } = e; // react events can't be put into the debouncer
|
|
78
|
-
this.debounceHandleMouseTableMove(target);
|
|
79
|
-
};
|
|
80
|
-
this.debounceHandleMouseTableMove = debounce(this.doHandleTableMouseMove.bind(this), memory_widget_utils_1.Constants.DEBOUNCE_TIME, { trailing: true });
|
|
81
|
-
this.handleTableRightClick = (e) => this.doHandleTableRightClick(e);
|
|
82
|
-
}
|
|
83
|
-
init() {
|
|
84
|
-
this.doInit();
|
|
85
|
-
}
|
|
86
|
-
async doInit() {
|
|
87
|
-
this.id = MemoryTableWidget_1.ID;
|
|
88
|
-
this.addClass(MemoryTableWidget_1.ID);
|
|
89
|
-
this.scrollOptions = { ...this.scrollOptions, suppressScrollX: false };
|
|
90
|
-
this.toDispose.push(this.optionsWidget.onOptionsChanged(optionId => this.handleOptionChange(optionId)));
|
|
91
|
-
this.toDispose.push(this.optionsWidget.onMemoryChanged(e => this.handleMemoryChange(e)));
|
|
92
|
-
this.toDispose.push(this.themeService.onDidColorThemeChange(e => this.handleThemeChange(e)));
|
|
93
|
-
this.getStateAndUpdate();
|
|
94
|
-
}
|
|
95
|
-
handleOptionChange(_id) {
|
|
96
|
-
this.getStateAndUpdate();
|
|
97
|
-
return Promise.resolve();
|
|
98
|
-
}
|
|
99
|
-
update() {
|
|
100
|
-
super.update();
|
|
101
|
-
this.updateColumnWidths();
|
|
102
|
-
}
|
|
103
|
-
onResize(msg) {
|
|
104
|
-
this.updateColumnWidths();
|
|
105
|
-
super.onResize(msg);
|
|
106
|
-
}
|
|
107
|
-
doUpdateColumnWidths() {
|
|
108
|
-
setTimeout(() => {
|
|
109
|
-
const firstTR = this.node.querySelector('tr');
|
|
110
|
-
const header = this.node.querySelector(`.${MemoryTable.HEADER_ROW_CLASS}`);
|
|
111
|
-
if (firstTR && header) {
|
|
112
|
-
const allTDs = Array.from(firstTR.querySelectorAll('td'));
|
|
113
|
-
const allSizes = allTDs.map(td => `minmax(max-content, ${td.clientWidth}px)`);
|
|
114
|
-
header.style.gridTemplateColumns = allSizes.join(' ');
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
areSameRegion(a, b) {
|
|
119
|
-
return a.address.equals(b === null || b === void 0 ? void 0 : b.address) && a.bytes.length === (b === null || b === void 0 ? void 0 : b.bytes.length);
|
|
120
|
-
}
|
|
121
|
-
handleMemoryChange(newMemory) {
|
|
122
|
-
if (this.areSameRegion(this.memory, newMemory)) {
|
|
123
|
-
this.previousBytes = this.memory.bytes;
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
this.previousBytes = undefined;
|
|
127
|
-
}
|
|
128
|
-
this.getStateAndUpdate();
|
|
129
|
-
}
|
|
130
|
-
handleThemeChange(_themeChange) {
|
|
131
|
-
this.getStateAndUpdate();
|
|
132
|
-
}
|
|
133
|
-
getState() {
|
|
134
|
-
this.options = this.optionsWidget.options;
|
|
135
|
-
this.memory = this.optionsWidget.memory;
|
|
136
|
-
const isHighContrast = this.themeService.getCurrentTheme().type === 'hc';
|
|
137
|
-
this.variableFinder = this.optionsWidget.options.columnsDisplayed.variables.doRender
|
|
138
|
-
? new memory_widget_variable_utils_1.VariableFinder(this.memory.variables, isHighContrast)
|
|
139
|
-
: undefined;
|
|
140
|
-
}
|
|
141
|
-
getStateAndUpdate() {
|
|
142
|
-
this.getState();
|
|
143
|
-
this.update();
|
|
144
|
-
this.scrollIntoViewIfNecessary();
|
|
145
|
-
}
|
|
146
|
-
scrollIntoViewIfNecessary() {
|
|
147
|
-
return new Promise(resolve => setTimeout(() => {
|
|
148
|
-
this.deferredScrollContainer.promise.then(scrollContainer => {
|
|
149
|
-
var _a;
|
|
150
|
-
const table = scrollContainer.querySelector('table');
|
|
151
|
-
if (table && scrollContainer.scrollTop > table.clientHeight) {
|
|
152
|
-
const valueToGetInWindow = table.clientHeight - this.node.clientHeight;
|
|
153
|
-
const scrollHere = Math.max(valueToGetInWindow, 0);
|
|
154
|
-
scrollContainer.scrollTo(scrollContainer.scrollLeft, scrollHere);
|
|
155
|
-
}
|
|
156
|
-
(_a = this.scrollBar) === null || _a === void 0 ? void 0 : _a.update();
|
|
157
|
-
resolve();
|
|
158
|
-
});
|
|
159
|
-
}));
|
|
160
|
-
}
|
|
161
|
-
getWrapperHandlers() {
|
|
162
|
-
return { onMouseMove: this.handleTableMouseMove };
|
|
163
|
-
}
|
|
164
|
-
async getScrollContainer() {
|
|
165
|
-
return this.deferredScrollContainer.promise;
|
|
166
|
-
}
|
|
167
|
-
render() {
|
|
168
|
-
const rows = this.getTableRows();
|
|
169
|
-
const { onClick, onContextMenu, onFocus, onBlur, onKeyDown, onMouseMove } = this.getWrapperHandlers();
|
|
170
|
-
const headers = Object.entries(this.options.columnsDisplayed)
|
|
171
|
-
.filter(([, { doRender }]) => doRender)
|
|
172
|
-
.map(([id, { label }]) => ({ label, id }));
|
|
173
|
-
return (React.createElement("div", { className: this.getWrapperClass(), onClick: onClick, onContextMenu: onContextMenu, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onMouseMove: onMouseMove, role: 'textbox', tabIndex: 0 },
|
|
174
|
-
React.createElement("div", { className: this.getTableHeaderClass(), style: this.getTableHeaderStyle(headers.length) }, this.getTableHeaders(headers)),
|
|
175
|
-
React.createElement("div", { className: 't-mv-view-container', style: { position: 'relative' }, ref: this.assignScrollContainerRef },
|
|
176
|
-
this.getBeforeTableContent(),
|
|
177
|
-
React.createElement("table", { className: 't-mv-view' },
|
|
178
|
-
React.createElement("tbody", null, rows)),
|
|
179
|
-
this.getAfterTableContent()),
|
|
180
|
-
this.getTableFooter()));
|
|
181
|
-
}
|
|
182
|
-
getWrapperClass() {
|
|
183
|
-
return `t-mv-memory-container${this.options.isFrozen ? ' frozen' : ''}`;
|
|
184
|
-
}
|
|
185
|
-
getTableHeaderClass() {
|
|
186
|
-
return MemoryTable.HEADER_ROW_CLASS + ' no-select';
|
|
187
|
-
}
|
|
188
|
-
getTableHeaderStyle(numLabels) {
|
|
189
|
-
const safePercentage = Math.floor(100 / numLabels);
|
|
190
|
-
const gridTemplateColumns = ` ${safePercentage}% `.repeat(numLabels);
|
|
191
|
-
return { gridTemplateColumns };
|
|
192
|
-
}
|
|
193
|
-
getTableHeaders(labels) {
|
|
194
|
-
return labels.map(label => this.getTableHeader(label));
|
|
195
|
-
}
|
|
196
|
-
getTableHeader({ label, id }) {
|
|
197
|
-
return (React.createElement("div", { key: id, className: MemoryTable.HEADER_LABEL_CONTAINER_CLASS },
|
|
198
|
-
React.createElement("span", { className: 't-mv-header-label' }, label)));
|
|
199
|
-
}
|
|
200
|
-
getBeforeTableContent() {
|
|
201
|
-
return (!!this.memory.bytes.length && (React.createElement(memory_widget_components_1.MWMoreMemorySelect, { options: [128, 256, 512], direction: 'above', handler: this.loadMoreMemory })));
|
|
202
|
-
}
|
|
203
|
-
getAfterTableContent() {
|
|
204
|
-
return (!!this.memory.bytes.length && (React.createElement(memory_widget_components_1.MWMoreMemorySelect, { options: [128, 256, 512], direction: 'below', handler: this.loadMoreMemory })));
|
|
205
|
-
}
|
|
206
|
-
getTableFooter() {
|
|
207
|
-
return undefined;
|
|
208
|
-
}
|
|
209
|
-
getTableRows() {
|
|
210
|
-
return [...this.renderRows()];
|
|
211
|
-
}
|
|
212
|
-
*renderRows(iteratee = this.memory.bytes) {
|
|
213
|
-
const bytesPerRow = this.options.bytesPerGroup * this.options.groupsPerRow;
|
|
214
|
-
let rowsYielded = 0;
|
|
215
|
-
let groups = [];
|
|
216
|
-
let ascii = '';
|
|
217
|
-
let variables = [];
|
|
218
|
-
let isRowHighlighted = false;
|
|
219
|
-
for (const { node, index, ascii: groupAscii, variables: groupVariables, isHighlighted = false } of this.renderGroups(iteratee)) {
|
|
220
|
-
groups.push(node);
|
|
221
|
-
ascii += groupAscii;
|
|
222
|
-
variables.push(...groupVariables);
|
|
223
|
-
isRowHighlighted = isRowHighlighted || isHighlighted;
|
|
224
|
-
if (groups.length === this.options.groupsPerRow || index === iteratee.length - 1) {
|
|
225
|
-
const rowAddress = this.memory.address.add(bytesPerRow * rowsYielded);
|
|
226
|
-
const options = {
|
|
227
|
-
address: `0x${rowAddress.toString(16)}`,
|
|
228
|
-
doShowDivider: (rowsYielded % 4) === 3,
|
|
229
|
-
isHighlighted: isRowHighlighted,
|
|
230
|
-
ascii,
|
|
231
|
-
groups,
|
|
232
|
-
variables,
|
|
233
|
-
index,
|
|
234
|
-
};
|
|
235
|
-
yield this.renderRow(options);
|
|
236
|
-
ascii = '';
|
|
237
|
-
variables = [];
|
|
238
|
-
groups = [];
|
|
239
|
-
rowsYielded += 1;
|
|
240
|
-
isRowHighlighted = false;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
renderRow(options, getRowAttributes = this.getRowAttributes.bind(this)) {
|
|
245
|
-
const { address, groups } = options;
|
|
246
|
-
const { className, style, title } = getRowAttributes(options);
|
|
247
|
-
return (React.createElement("tr", {
|
|
248
|
-
// Add a marker to help visual navigation when scrolling
|
|
249
|
-
className: className, style: style, title: title, key: address },
|
|
250
|
-
React.createElement("td", { className: MemoryTable.ADDRESS_DATA_CLASS }, address),
|
|
251
|
-
React.createElement("td", { className: MemoryTable.MEMORY_DATA_CLASS }, groups),
|
|
252
|
-
this.getExtraColumn(options)));
|
|
253
|
-
}
|
|
254
|
-
getRowAttributes(options) {
|
|
255
|
-
let className = MemoryTable.ROW_CLASS;
|
|
256
|
-
if (options.doShowDivider) {
|
|
257
|
-
className += ` ${MemoryTable.ROW_DIVIDER_CLASS}`;
|
|
258
|
-
}
|
|
259
|
-
return { className };
|
|
260
|
-
}
|
|
261
|
-
getExtraColumn(options) {
|
|
262
|
-
const { variables } = options;
|
|
263
|
-
const additionalColumns = [];
|
|
264
|
-
if (this.options.columnsDisplayed.variables.doRender) {
|
|
265
|
-
additionalColumns.push(React.createElement("td", { className: MemoryTable.EXTRA_COLUMN_DATA_CLASS, key: 'variables' }, !!(variables === null || variables === void 0 ? void 0 : variables.length) && (React.createElement("span", { className: 'variable-container' }, variables.map(({ name, color }) => (React.createElement("span", { key: name, className: MemoryTable.VARIABLE_LABEL_CLASS, style: { color } }, name)))))));
|
|
266
|
-
}
|
|
267
|
-
if (this.options.columnsDisplayed.ascii.doRender) {
|
|
268
|
-
const asciiColumn = this.options.columnsDisplayed.ascii.doRender && React.createElement("td", { className: MemoryTable.EXTRA_COLUMN_DATA_CLASS, key: 'ascii' }, options.ascii);
|
|
269
|
-
additionalColumns.push(asciiColumn);
|
|
270
|
-
}
|
|
271
|
-
return additionalColumns;
|
|
272
|
-
}
|
|
273
|
-
*renderGroups(iteratee = this.memory.bytes) {
|
|
274
|
-
let bytesInGroup = [];
|
|
275
|
-
let ascii = '';
|
|
276
|
-
let variables = [];
|
|
277
|
-
let isGroupHighlighted = false;
|
|
278
|
-
for (const { node, index, ascii: byteAscii, variables: byteVariables, isHighlighted = false } of this.renderBytes(iteratee)) {
|
|
279
|
-
this.buildGroupByEndianness(bytesInGroup, node);
|
|
280
|
-
ascii += byteAscii;
|
|
281
|
-
variables.push(...byteVariables);
|
|
282
|
-
isGroupHighlighted = isGroupHighlighted || isHighlighted;
|
|
283
|
-
if (bytesInGroup.length === this.options.bytesPerGroup || index === iteratee.length - 1) {
|
|
284
|
-
const itemID = this.memory.address.add(index);
|
|
285
|
-
yield {
|
|
286
|
-
node: React.createElement("span", { className: 'byte-group', key: itemID.toString(16) }, bytesInGroup),
|
|
287
|
-
ascii,
|
|
288
|
-
index,
|
|
289
|
-
variables,
|
|
290
|
-
isHighlighted: isGroupHighlighted,
|
|
291
|
-
};
|
|
292
|
-
bytesInGroup = [];
|
|
293
|
-
ascii = '';
|
|
294
|
-
variables = [];
|
|
295
|
-
isGroupHighlighted = false;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
buildGroupByEndianness(oldBytes, newByte) {
|
|
300
|
-
if (this.options.endianness === memory_widget_utils_1.Interfaces.Endianness.Big) {
|
|
301
|
-
oldBytes.push(newByte);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
oldBytes.unshift(newByte);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
*renderBytes(iteratee = this.memory.bytes) {
|
|
308
|
-
const itemsPerByte = this.options.byteSize / 8;
|
|
309
|
-
let currentByte = 0;
|
|
310
|
-
let chunksInByte = [];
|
|
311
|
-
let variables = [];
|
|
312
|
-
let isByteHighlighted = false;
|
|
313
|
-
for (const { node, content, index, variable, isHighlighted = false } of this.renderArrayItems(iteratee)) {
|
|
314
|
-
chunksInByte.push(node);
|
|
315
|
-
const numericalValue = parseInt(content, 16);
|
|
316
|
-
currentByte = (currentByte << 8) + numericalValue;
|
|
317
|
-
isByteHighlighted = isByteHighlighted || isHighlighted;
|
|
318
|
-
if (variable === null || variable === void 0 ? void 0 : variable.firstAppearance) {
|
|
319
|
-
variables.push(variable);
|
|
320
|
-
}
|
|
321
|
-
if (chunksInByte.length === itemsPerByte || index === iteratee.length - 1) {
|
|
322
|
-
const itemID = this.memory.address.add(index);
|
|
323
|
-
const ascii = this.getASCIIForSingleByte(currentByte);
|
|
324
|
-
yield {
|
|
325
|
-
node: React.createElement("span", { className: 'single-byte', key: itemID.toString(16) }, chunksInByte),
|
|
326
|
-
ascii,
|
|
327
|
-
index,
|
|
328
|
-
variables,
|
|
329
|
-
isHighlighted: isByteHighlighted,
|
|
330
|
-
};
|
|
331
|
-
currentByte = 0;
|
|
332
|
-
chunksInByte = [];
|
|
333
|
-
variables = [];
|
|
334
|
-
isByteHighlighted = false;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
getASCIIForSingleByte(byte) {
|
|
339
|
-
return typeof byte === 'undefined'
|
|
340
|
-
? ' ' : memory_widget_utils_1.Utils.isPrintableAsAscii(byte) ? String.fromCharCode(byte) : '.';
|
|
341
|
-
}
|
|
342
|
-
*renderArrayItems(iteratee = this.memory.bytes, getBitAttributes = this.getBitAttributes.bind(this)) {
|
|
343
|
-
const { address } = this.memory;
|
|
344
|
-
for (let i = 0; i < iteratee.length; i += 1) {
|
|
345
|
-
const itemID = address.add(i).toString(16);
|
|
346
|
-
const { content = '', className, style, variable, title, isHighlighted } = getBitAttributes(i, iteratee);
|
|
347
|
-
const node = (React.createElement("span", { style: style, key: itemID, className: className, "data-id": itemID, title: title }, content));
|
|
348
|
-
yield {
|
|
349
|
-
node,
|
|
350
|
-
content,
|
|
351
|
-
index: i,
|
|
352
|
-
variable,
|
|
353
|
-
isHighlighted,
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
getBitAttributes(arrayOffset, iteratee) {
|
|
358
|
-
var _a;
|
|
359
|
-
const itemAddress = this.memory.address.add(arrayOffset * 8 / this.options.byteSize);
|
|
360
|
-
const classNames = [MemoryTable.EIGHT_BIT_SPAN_CLASS];
|
|
361
|
-
const isChanged = this.previousBytes && iteratee[arrayOffset] !== this.previousBytes[arrayOffset];
|
|
362
|
-
const variable = (_a = this.variableFinder) === null || _a === void 0 ? void 0 : _a.getVariableForAddress(itemAddress);
|
|
363
|
-
if (!this.options.isFrozen) {
|
|
364
|
-
if (isChanged) {
|
|
365
|
-
classNames.push('changed');
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return {
|
|
369
|
-
className: classNames.join(' '),
|
|
370
|
-
variable,
|
|
371
|
-
style: { color: variable === null || variable === void 0 ? void 0 : variable.color },
|
|
372
|
-
content: iteratee[arrayOffset].toString(16).padStart(2, '0')
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
doHandleTableMouseMove(targetSpan) {
|
|
376
|
-
const target = targetSpan instanceof HTMLElement && targetSpan;
|
|
377
|
-
if (target) {
|
|
378
|
-
const { x, y } = target.getBoundingClientRect();
|
|
379
|
-
const anchor = { x: Math.round(x), y: Math.round(y + target.clientHeight) };
|
|
380
|
-
if (target.classList.contains(MemoryTable.EIGHT_BIT_SPAN_CLASS)) {
|
|
381
|
-
const properties = this.getHoverForChunk(target);
|
|
382
|
-
this.hoverRenderer.render(this.node, anchor, properties);
|
|
383
|
-
}
|
|
384
|
-
else if (target.classList.contains(MemoryTable.VARIABLE_LABEL_CLASS)) {
|
|
385
|
-
const properties = this.getHoverForVariable(target);
|
|
386
|
-
this.hoverRenderer.render(this.node, anchor, properties);
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
this.hoverRenderer.hide();
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
this.hoverRenderer.hide();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
getHoverForChunk(span) {
|
|
397
|
-
var _a;
|
|
398
|
-
if (span.classList.contains(MemoryTable.EIGHT_BIT_SPAN_CLASS)) {
|
|
399
|
-
const parentByteContainer = span.parentElement;
|
|
400
|
-
if (parentByteContainer === null || parentByteContainer === void 0 ? void 0 : parentByteContainer.textContent) {
|
|
401
|
-
const hex = (_a = parentByteContainer.textContent) !== null && _a !== void 0 ? _a : '';
|
|
402
|
-
const decimal = parseInt(hex, 16);
|
|
403
|
-
const binary = this.getPaddedBinary(decimal);
|
|
404
|
-
const UTF8 = String.fromCodePoint(decimal);
|
|
405
|
-
return { hex, binary, decimal, UTF8 };
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return undefined;
|
|
409
|
-
}
|
|
410
|
-
getPaddedBinary(decimal) {
|
|
411
|
-
const paddedBinary = decimal.toString(2).padStart(this.options.byteSize, '0');
|
|
412
|
-
let paddedAndSpacedBinary = '';
|
|
413
|
-
for (let i = 8; i <= paddedBinary.length; i += 8) {
|
|
414
|
-
paddedAndSpacedBinary += ` ${paddedBinary.slice(i - 8, i)}`;
|
|
415
|
-
}
|
|
416
|
-
return paddedAndSpacedBinary.trim();
|
|
417
|
-
}
|
|
418
|
-
getHoverForVariable(span) {
|
|
419
|
-
var _a, _b;
|
|
420
|
-
const variable = (_a = this.variableFinder) === null || _a === void 0 ? void 0 : _a.searchForVariable((_b = span.textContent) !== null && _b !== void 0 ? _b : '');
|
|
421
|
-
if (variable === null || variable === void 0 ? void 0 : variable.type) {
|
|
422
|
-
return { type: variable.type };
|
|
423
|
-
}
|
|
424
|
-
return undefined;
|
|
425
|
-
}
|
|
426
|
-
doHandleTableRightClick(event) {
|
|
427
|
-
var _a;
|
|
428
|
-
event.preventDefault();
|
|
429
|
-
const target = event.target;
|
|
430
|
-
if ((_a = target.classList) === null || _a === void 0 ? void 0 : _a.contains('eight-bits')) {
|
|
431
|
-
const { right, top } = target.getBoundingClientRect();
|
|
432
|
-
this.update();
|
|
433
|
-
event.stopPropagation();
|
|
434
|
-
this.contextMenuRenderer.render({
|
|
435
|
-
menuPath: MemoryTableWidget_1.CONTEXT_MENU,
|
|
436
|
-
anchor: { x: right, y: top },
|
|
437
|
-
args: this.getContextMenuArgs(event),
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
getContextMenuArgs(event) {
|
|
442
|
-
var _a;
|
|
443
|
-
const args = [this];
|
|
444
|
-
const id = event.target.getAttribute('data-id');
|
|
445
|
-
if (id) {
|
|
446
|
-
const location = (0, util_1.hexStrToUnsignedLong)(id);
|
|
447
|
-
args.push(location);
|
|
448
|
-
const offset = this.memory.address.multiply(-1).add(location);
|
|
449
|
-
const cellAddress = this.memory.address.add(offset.multiply(8 / this.options.byteSize));
|
|
450
|
-
const variableAtLocation = (_a = this.variableFinder) === null || _a === void 0 ? void 0 : _a.searchForVariable(cellAddress);
|
|
451
|
-
args.push(variableAtLocation);
|
|
452
|
-
}
|
|
453
|
-
return args;
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
MemoryTableWidget.CONTEXT_MENU = ['memory.view.context.menu'];
|
|
457
|
-
MemoryTableWidget.ID = 'memory-table-widget';
|
|
458
|
-
__decorate([
|
|
459
|
-
(0, inversify_1.inject)(theming_1.ThemeService),
|
|
460
|
-
__metadata("design:type", theming_1.ThemeService)
|
|
461
|
-
], MemoryTableWidget.prototype, "themeService", void 0);
|
|
462
|
-
__decorate([
|
|
463
|
-
(0, inversify_1.inject)(memory_options_widget_1.MemoryOptionsWidget),
|
|
464
|
-
__metadata("design:type", memory_options_widget_1.MemoryOptionsWidget)
|
|
465
|
-
], MemoryTableWidget.prototype, "optionsWidget", void 0);
|
|
466
|
-
__decorate([
|
|
467
|
-
(0, inversify_1.inject)(memory_provider_service_1.MemoryProviderService),
|
|
468
|
-
__metadata("design:type", memory_provider_service_1.MemoryProviderService)
|
|
469
|
-
], MemoryTableWidget.prototype, "memoryProvider", void 0);
|
|
470
|
-
__decorate([
|
|
471
|
-
(0, inversify_1.inject)(memory_hover_renderer_1.MemoryHoverRendererService),
|
|
472
|
-
__metadata("design:type", memory_hover_renderer_1.MemoryHoverRendererService)
|
|
473
|
-
], MemoryTableWidget.prototype, "hoverRenderer", void 0);
|
|
474
|
-
__decorate([
|
|
475
|
-
(0, inversify_1.inject)(browser_1.ContextMenuRenderer),
|
|
476
|
-
__metadata("design:type", browser_1.ContextMenuRenderer)
|
|
477
|
-
], MemoryTableWidget.prototype, "contextMenuRenderer", void 0);
|
|
478
|
-
__decorate([
|
|
479
|
-
(0, inversify_1.postConstruct)(),
|
|
480
|
-
__metadata("design:type", Function),
|
|
481
|
-
__metadata("design:paramtypes", []),
|
|
482
|
-
__metadata("design:returntype", void 0)
|
|
483
|
-
], MemoryTableWidget.prototype, "init", null);
|
|
484
|
-
MemoryTableWidget = MemoryTableWidget_1 = __decorate([
|
|
485
|
-
(0, inversify_1.injectable)()
|
|
486
|
-
], MemoryTableWidget);
|
|
487
|
-
exports.MemoryTableWidget = MemoryTableWidget;
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (C) 2021 Ericsson and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
var MemoryTableWidget_1;
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.MemoryTableWidget = exports.MemoryTable = void 0;
|
|
29
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
30
|
+
const theming_1 = require("@theia/core/lib/browser/theming");
|
|
31
|
+
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
32
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
33
|
+
const React = require("@theia/core/shared/react");
|
|
34
|
+
const util_1 = require("../../common/util");
|
|
35
|
+
const memory_provider_service_1 = require("../memory-provider/memory-provider-service");
|
|
36
|
+
const memory_hover_renderer_1 = require("../utils/memory-hover-renderer");
|
|
37
|
+
const memory_widget_components_1 = require("../utils/memory-widget-components");
|
|
38
|
+
const memory_widget_utils_1 = require("../utils/memory-widget-utils");
|
|
39
|
+
const memory_widget_variable_utils_1 = require("../utils/memory-widget-variable-utils");
|
|
40
|
+
const memory_options_widget_1 = require("./memory-options-widget");
|
|
41
|
+
const debounce = require("@theia/core/shared/lodash.debounce");
|
|
42
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
43
|
+
var MemoryTable;
|
|
44
|
+
(function (MemoryTable) {
|
|
45
|
+
MemoryTable.ROW_CLASS = 't-mv-view-row';
|
|
46
|
+
MemoryTable.ROW_DIVIDER_CLASS = 't-mv-view-row-highlight';
|
|
47
|
+
MemoryTable.ADDRESS_DATA_CLASS = 't-mv-view-address';
|
|
48
|
+
MemoryTable.MEMORY_DATA_CLASS = 't-mv-view-data';
|
|
49
|
+
MemoryTable.EXTRA_COLUMN_DATA_CLASS = 't-mv-view-code';
|
|
50
|
+
MemoryTable.GROUP_SPAN_CLASS = 'byte-group';
|
|
51
|
+
MemoryTable.BYTE_SPAN_CLASS = 'single-byte';
|
|
52
|
+
MemoryTable.EIGHT_BIT_SPAN_CLASS = 'eight-bits';
|
|
53
|
+
MemoryTable.HEADER_LABEL_CONTAINER_CLASS = 't-mv-header-label-container';
|
|
54
|
+
MemoryTable.HEADER_LABEL_CLASS = 't-mv-header-label';
|
|
55
|
+
MemoryTable.VARIABLE_LABEL_CLASS = 't-mv-variable-label';
|
|
56
|
+
MemoryTable.HEADER_ROW_CLASS = 't-mv-header';
|
|
57
|
+
})(MemoryTable = exports.MemoryTable || (exports.MemoryTable = {}));
|
|
58
|
+
let MemoryTableWidget = MemoryTableWidget_1 = class MemoryTableWidget extends browser_1.ReactWidget {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
this.deferredScrollContainer = new promise_util_1.Deferred();
|
|
62
|
+
this.updateColumnWidths = debounce(this.doUpdateColumnWidths.bind(this), memory_widget_utils_1.Constants.DEBOUNCE_TIME);
|
|
63
|
+
this.assignScrollContainerRef = (element) => {
|
|
64
|
+
this.deferredScrollContainer.resolve(element);
|
|
65
|
+
};
|
|
66
|
+
this.loadMoreMemory = async (options) => {
|
|
67
|
+
const { direction, numBytes } = options;
|
|
68
|
+
const { address, offset, length } = this.optionsWidget.options;
|
|
69
|
+
let newOffset = 0;
|
|
70
|
+
const newLength = length + numBytes;
|
|
71
|
+
if (direction === 'above') {
|
|
72
|
+
newOffset = offset - numBytes;
|
|
73
|
+
}
|
|
74
|
+
await this.optionsWidget.setAddressAndGo(`${address}`, newOffset, newLength, direction);
|
|
75
|
+
};
|
|
76
|
+
this.handleTableMouseMove = (e) => {
|
|
77
|
+
const { target } = e; // react events can't be put into the debouncer
|
|
78
|
+
this.debounceHandleMouseTableMove(target);
|
|
79
|
+
};
|
|
80
|
+
this.debounceHandleMouseTableMove = debounce(this.doHandleTableMouseMove.bind(this), memory_widget_utils_1.Constants.DEBOUNCE_TIME, { trailing: true });
|
|
81
|
+
this.handleTableRightClick = (e) => this.doHandleTableRightClick(e);
|
|
82
|
+
}
|
|
83
|
+
init() {
|
|
84
|
+
this.doInit();
|
|
85
|
+
}
|
|
86
|
+
async doInit() {
|
|
87
|
+
this.id = MemoryTableWidget_1.ID;
|
|
88
|
+
this.addClass(MemoryTableWidget_1.ID);
|
|
89
|
+
this.scrollOptions = { ...this.scrollOptions, suppressScrollX: false };
|
|
90
|
+
this.toDispose.push(this.optionsWidget.onOptionsChanged(optionId => this.handleOptionChange(optionId)));
|
|
91
|
+
this.toDispose.push(this.optionsWidget.onMemoryChanged(e => this.handleMemoryChange(e)));
|
|
92
|
+
this.toDispose.push(this.themeService.onDidColorThemeChange(e => this.handleThemeChange(e)));
|
|
93
|
+
this.getStateAndUpdate();
|
|
94
|
+
}
|
|
95
|
+
handleOptionChange(_id) {
|
|
96
|
+
this.getStateAndUpdate();
|
|
97
|
+
return Promise.resolve();
|
|
98
|
+
}
|
|
99
|
+
update() {
|
|
100
|
+
super.update();
|
|
101
|
+
this.updateColumnWidths();
|
|
102
|
+
}
|
|
103
|
+
onResize(msg) {
|
|
104
|
+
this.updateColumnWidths();
|
|
105
|
+
super.onResize(msg);
|
|
106
|
+
}
|
|
107
|
+
doUpdateColumnWidths() {
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
const firstTR = this.node.querySelector('tr');
|
|
110
|
+
const header = this.node.querySelector(`.${MemoryTable.HEADER_ROW_CLASS}`);
|
|
111
|
+
if (firstTR && header) {
|
|
112
|
+
const allTDs = Array.from(firstTR.querySelectorAll('td'));
|
|
113
|
+
const allSizes = allTDs.map(td => `minmax(max-content, ${td.clientWidth}px)`);
|
|
114
|
+
header.style.gridTemplateColumns = allSizes.join(' ');
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
areSameRegion(a, b) {
|
|
119
|
+
return a.address.equals(b === null || b === void 0 ? void 0 : b.address) && a.bytes.length === (b === null || b === void 0 ? void 0 : b.bytes.length);
|
|
120
|
+
}
|
|
121
|
+
handleMemoryChange(newMemory) {
|
|
122
|
+
if (this.areSameRegion(this.memory, newMemory)) {
|
|
123
|
+
this.previousBytes = this.memory.bytes;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.previousBytes = undefined;
|
|
127
|
+
}
|
|
128
|
+
this.getStateAndUpdate();
|
|
129
|
+
}
|
|
130
|
+
handleThemeChange(_themeChange) {
|
|
131
|
+
this.getStateAndUpdate();
|
|
132
|
+
}
|
|
133
|
+
getState() {
|
|
134
|
+
this.options = this.optionsWidget.options;
|
|
135
|
+
this.memory = this.optionsWidget.memory;
|
|
136
|
+
const isHighContrast = this.themeService.getCurrentTheme().type === 'hc';
|
|
137
|
+
this.variableFinder = this.optionsWidget.options.columnsDisplayed.variables.doRender
|
|
138
|
+
? new memory_widget_variable_utils_1.VariableFinder(this.memory.variables, isHighContrast)
|
|
139
|
+
: undefined;
|
|
140
|
+
}
|
|
141
|
+
getStateAndUpdate() {
|
|
142
|
+
this.getState();
|
|
143
|
+
this.update();
|
|
144
|
+
this.scrollIntoViewIfNecessary();
|
|
145
|
+
}
|
|
146
|
+
scrollIntoViewIfNecessary() {
|
|
147
|
+
return new Promise(resolve => setTimeout(() => {
|
|
148
|
+
this.deferredScrollContainer.promise.then(scrollContainer => {
|
|
149
|
+
var _a;
|
|
150
|
+
const table = scrollContainer.querySelector('table');
|
|
151
|
+
if (table && scrollContainer.scrollTop > table.clientHeight) {
|
|
152
|
+
const valueToGetInWindow = table.clientHeight - this.node.clientHeight;
|
|
153
|
+
const scrollHere = Math.max(valueToGetInWindow, 0);
|
|
154
|
+
scrollContainer.scrollTo(scrollContainer.scrollLeft, scrollHere);
|
|
155
|
+
}
|
|
156
|
+
(_a = this.scrollBar) === null || _a === void 0 ? void 0 : _a.update();
|
|
157
|
+
resolve();
|
|
158
|
+
});
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
getWrapperHandlers() {
|
|
162
|
+
return { onMouseMove: this.handleTableMouseMove };
|
|
163
|
+
}
|
|
164
|
+
async getScrollContainer() {
|
|
165
|
+
return this.deferredScrollContainer.promise;
|
|
166
|
+
}
|
|
167
|
+
render() {
|
|
168
|
+
const rows = this.getTableRows();
|
|
169
|
+
const { onClick, onContextMenu, onFocus, onBlur, onKeyDown, onMouseMove } = this.getWrapperHandlers();
|
|
170
|
+
const headers = Object.entries(this.options.columnsDisplayed)
|
|
171
|
+
.filter(([, { doRender }]) => doRender)
|
|
172
|
+
.map(([id, { label }]) => ({ label, id }));
|
|
173
|
+
return (React.createElement("div", { className: this.getWrapperClass(), onClick: onClick, onContextMenu: onContextMenu, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onMouseMove: onMouseMove, role: 'textbox', tabIndex: 0 },
|
|
174
|
+
React.createElement("div", { className: this.getTableHeaderClass(), style: this.getTableHeaderStyle(headers.length) }, this.getTableHeaders(headers)),
|
|
175
|
+
React.createElement("div", { className: 't-mv-view-container', style: { position: 'relative' }, ref: this.assignScrollContainerRef },
|
|
176
|
+
this.getBeforeTableContent(),
|
|
177
|
+
React.createElement("table", { className: 't-mv-view' },
|
|
178
|
+
React.createElement("tbody", null, rows)),
|
|
179
|
+
this.getAfterTableContent()),
|
|
180
|
+
this.getTableFooter()));
|
|
181
|
+
}
|
|
182
|
+
getWrapperClass() {
|
|
183
|
+
return `t-mv-memory-container${this.options.isFrozen ? ' frozen' : ''}`;
|
|
184
|
+
}
|
|
185
|
+
getTableHeaderClass() {
|
|
186
|
+
return MemoryTable.HEADER_ROW_CLASS + ' no-select';
|
|
187
|
+
}
|
|
188
|
+
getTableHeaderStyle(numLabels) {
|
|
189
|
+
const safePercentage = Math.floor(100 / numLabels);
|
|
190
|
+
const gridTemplateColumns = ` ${safePercentage}% `.repeat(numLabels);
|
|
191
|
+
return { gridTemplateColumns };
|
|
192
|
+
}
|
|
193
|
+
getTableHeaders(labels) {
|
|
194
|
+
return labels.map(label => this.getTableHeader(label));
|
|
195
|
+
}
|
|
196
|
+
getTableHeader({ label, id }) {
|
|
197
|
+
return (React.createElement("div", { key: id, className: MemoryTable.HEADER_LABEL_CONTAINER_CLASS },
|
|
198
|
+
React.createElement("span", { className: 't-mv-header-label' }, label)));
|
|
199
|
+
}
|
|
200
|
+
getBeforeTableContent() {
|
|
201
|
+
return (!!this.memory.bytes.length && (React.createElement(memory_widget_components_1.MWMoreMemorySelect, { options: [128, 256, 512], direction: 'above', handler: this.loadMoreMemory })));
|
|
202
|
+
}
|
|
203
|
+
getAfterTableContent() {
|
|
204
|
+
return (!!this.memory.bytes.length && (React.createElement(memory_widget_components_1.MWMoreMemorySelect, { options: [128, 256, 512], direction: 'below', handler: this.loadMoreMemory })));
|
|
205
|
+
}
|
|
206
|
+
getTableFooter() {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
getTableRows() {
|
|
210
|
+
return [...this.renderRows()];
|
|
211
|
+
}
|
|
212
|
+
*renderRows(iteratee = this.memory.bytes) {
|
|
213
|
+
const bytesPerRow = this.options.bytesPerGroup * this.options.groupsPerRow;
|
|
214
|
+
let rowsYielded = 0;
|
|
215
|
+
let groups = [];
|
|
216
|
+
let ascii = '';
|
|
217
|
+
let variables = [];
|
|
218
|
+
let isRowHighlighted = false;
|
|
219
|
+
for (const { node, index, ascii: groupAscii, variables: groupVariables, isHighlighted = false } of this.renderGroups(iteratee)) {
|
|
220
|
+
groups.push(node);
|
|
221
|
+
ascii += groupAscii;
|
|
222
|
+
variables.push(...groupVariables);
|
|
223
|
+
isRowHighlighted = isRowHighlighted || isHighlighted;
|
|
224
|
+
if (groups.length === this.options.groupsPerRow || index === iteratee.length - 1) {
|
|
225
|
+
const rowAddress = this.memory.address.add(bytesPerRow * rowsYielded);
|
|
226
|
+
const options = {
|
|
227
|
+
address: `0x${rowAddress.toString(16)}`,
|
|
228
|
+
doShowDivider: (rowsYielded % 4) === 3,
|
|
229
|
+
isHighlighted: isRowHighlighted,
|
|
230
|
+
ascii,
|
|
231
|
+
groups,
|
|
232
|
+
variables,
|
|
233
|
+
index,
|
|
234
|
+
};
|
|
235
|
+
yield this.renderRow(options);
|
|
236
|
+
ascii = '';
|
|
237
|
+
variables = [];
|
|
238
|
+
groups = [];
|
|
239
|
+
rowsYielded += 1;
|
|
240
|
+
isRowHighlighted = false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
renderRow(options, getRowAttributes = this.getRowAttributes.bind(this)) {
|
|
245
|
+
const { address, groups } = options;
|
|
246
|
+
const { className, style, title } = getRowAttributes(options);
|
|
247
|
+
return (React.createElement("tr", {
|
|
248
|
+
// Add a marker to help visual navigation when scrolling
|
|
249
|
+
className: className, style: style, title: title, key: address },
|
|
250
|
+
React.createElement("td", { className: MemoryTable.ADDRESS_DATA_CLASS }, address),
|
|
251
|
+
React.createElement("td", { className: MemoryTable.MEMORY_DATA_CLASS }, groups),
|
|
252
|
+
this.getExtraColumn(options)));
|
|
253
|
+
}
|
|
254
|
+
getRowAttributes(options) {
|
|
255
|
+
let className = MemoryTable.ROW_CLASS;
|
|
256
|
+
if (options.doShowDivider) {
|
|
257
|
+
className += ` ${MemoryTable.ROW_DIVIDER_CLASS}`;
|
|
258
|
+
}
|
|
259
|
+
return { className };
|
|
260
|
+
}
|
|
261
|
+
getExtraColumn(options) {
|
|
262
|
+
const { variables } = options;
|
|
263
|
+
const additionalColumns = [];
|
|
264
|
+
if (this.options.columnsDisplayed.variables.doRender) {
|
|
265
|
+
additionalColumns.push(React.createElement("td", { className: MemoryTable.EXTRA_COLUMN_DATA_CLASS, key: 'variables' }, !!(variables === null || variables === void 0 ? void 0 : variables.length) && (React.createElement("span", { className: 'variable-container' }, variables.map(({ name, color }) => (React.createElement("span", { key: name, className: MemoryTable.VARIABLE_LABEL_CLASS, style: { color } }, name)))))));
|
|
266
|
+
}
|
|
267
|
+
if (this.options.columnsDisplayed.ascii.doRender) {
|
|
268
|
+
const asciiColumn = this.options.columnsDisplayed.ascii.doRender && React.createElement("td", { className: MemoryTable.EXTRA_COLUMN_DATA_CLASS, key: 'ascii' }, options.ascii);
|
|
269
|
+
additionalColumns.push(asciiColumn);
|
|
270
|
+
}
|
|
271
|
+
return additionalColumns;
|
|
272
|
+
}
|
|
273
|
+
*renderGroups(iteratee = this.memory.bytes) {
|
|
274
|
+
let bytesInGroup = [];
|
|
275
|
+
let ascii = '';
|
|
276
|
+
let variables = [];
|
|
277
|
+
let isGroupHighlighted = false;
|
|
278
|
+
for (const { node, index, ascii: byteAscii, variables: byteVariables, isHighlighted = false } of this.renderBytes(iteratee)) {
|
|
279
|
+
this.buildGroupByEndianness(bytesInGroup, node);
|
|
280
|
+
ascii += byteAscii;
|
|
281
|
+
variables.push(...byteVariables);
|
|
282
|
+
isGroupHighlighted = isGroupHighlighted || isHighlighted;
|
|
283
|
+
if (bytesInGroup.length === this.options.bytesPerGroup || index === iteratee.length - 1) {
|
|
284
|
+
const itemID = this.memory.address.add(index);
|
|
285
|
+
yield {
|
|
286
|
+
node: React.createElement("span", { className: 'byte-group', key: itemID.toString(16) }, bytesInGroup),
|
|
287
|
+
ascii,
|
|
288
|
+
index,
|
|
289
|
+
variables,
|
|
290
|
+
isHighlighted: isGroupHighlighted,
|
|
291
|
+
};
|
|
292
|
+
bytesInGroup = [];
|
|
293
|
+
ascii = '';
|
|
294
|
+
variables = [];
|
|
295
|
+
isGroupHighlighted = false;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
buildGroupByEndianness(oldBytes, newByte) {
|
|
300
|
+
if (this.options.endianness === memory_widget_utils_1.Interfaces.Endianness.Big) {
|
|
301
|
+
oldBytes.push(newByte);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
oldBytes.unshift(newByte);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
*renderBytes(iteratee = this.memory.bytes) {
|
|
308
|
+
const itemsPerByte = this.options.byteSize / 8;
|
|
309
|
+
let currentByte = 0;
|
|
310
|
+
let chunksInByte = [];
|
|
311
|
+
let variables = [];
|
|
312
|
+
let isByteHighlighted = false;
|
|
313
|
+
for (const { node, content, index, variable, isHighlighted = false } of this.renderArrayItems(iteratee)) {
|
|
314
|
+
chunksInByte.push(node);
|
|
315
|
+
const numericalValue = parseInt(content, 16);
|
|
316
|
+
currentByte = (currentByte << 8) + numericalValue;
|
|
317
|
+
isByteHighlighted = isByteHighlighted || isHighlighted;
|
|
318
|
+
if (variable === null || variable === void 0 ? void 0 : variable.firstAppearance) {
|
|
319
|
+
variables.push(variable);
|
|
320
|
+
}
|
|
321
|
+
if (chunksInByte.length === itemsPerByte || index === iteratee.length - 1) {
|
|
322
|
+
const itemID = this.memory.address.add(index);
|
|
323
|
+
const ascii = this.getASCIIForSingleByte(currentByte);
|
|
324
|
+
yield {
|
|
325
|
+
node: React.createElement("span", { className: 'single-byte', key: itemID.toString(16) }, chunksInByte),
|
|
326
|
+
ascii,
|
|
327
|
+
index,
|
|
328
|
+
variables,
|
|
329
|
+
isHighlighted: isByteHighlighted,
|
|
330
|
+
};
|
|
331
|
+
currentByte = 0;
|
|
332
|
+
chunksInByte = [];
|
|
333
|
+
variables = [];
|
|
334
|
+
isByteHighlighted = false;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
getASCIIForSingleByte(byte) {
|
|
339
|
+
return typeof byte === 'undefined'
|
|
340
|
+
? ' ' : memory_widget_utils_1.Utils.isPrintableAsAscii(byte) ? String.fromCharCode(byte) : '.';
|
|
341
|
+
}
|
|
342
|
+
*renderArrayItems(iteratee = this.memory.bytes, getBitAttributes = this.getBitAttributes.bind(this)) {
|
|
343
|
+
const { address } = this.memory;
|
|
344
|
+
for (let i = 0; i < iteratee.length; i += 1) {
|
|
345
|
+
const itemID = address.add(i).toString(16);
|
|
346
|
+
const { content = '', className, style, variable, title, isHighlighted } = getBitAttributes(i, iteratee);
|
|
347
|
+
const node = (React.createElement("span", { style: style, key: itemID, className: className, "data-id": itemID, title: title }, content));
|
|
348
|
+
yield {
|
|
349
|
+
node,
|
|
350
|
+
content,
|
|
351
|
+
index: i,
|
|
352
|
+
variable,
|
|
353
|
+
isHighlighted,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
getBitAttributes(arrayOffset, iteratee) {
|
|
358
|
+
var _a;
|
|
359
|
+
const itemAddress = this.memory.address.add(arrayOffset * 8 / this.options.byteSize);
|
|
360
|
+
const classNames = [MemoryTable.EIGHT_BIT_SPAN_CLASS];
|
|
361
|
+
const isChanged = this.previousBytes && iteratee[arrayOffset] !== this.previousBytes[arrayOffset];
|
|
362
|
+
const variable = (_a = this.variableFinder) === null || _a === void 0 ? void 0 : _a.getVariableForAddress(itemAddress);
|
|
363
|
+
if (!this.options.isFrozen) {
|
|
364
|
+
if (isChanged) {
|
|
365
|
+
classNames.push('changed');
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
className: classNames.join(' '),
|
|
370
|
+
variable,
|
|
371
|
+
style: { color: variable === null || variable === void 0 ? void 0 : variable.color },
|
|
372
|
+
content: iteratee[arrayOffset].toString(16).padStart(2, '0')
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
doHandleTableMouseMove(targetSpan) {
|
|
376
|
+
const target = targetSpan instanceof HTMLElement && targetSpan;
|
|
377
|
+
if (target) {
|
|
378
|
+
const { x, y } = target.getBoundingClientRect();
|
|
379
|
+
const anchor = { x: Math.round(x), y: Math.round(y + target.clientHeight) };
|
|
380
|
+
if (target.classList.contains(MemoryTable.EIGHT_BIT_SPAN_CLASS)) {
|
|
381
|
+
const properties = this.getHoverForChunk(target);
|
|
382
|
+
this.hoverRenderer.render(this.node, anchor, properties);
|
|
383
|
+
}
|
|
384
|
+
else if (target.classList.contains(MemoryTable.VARIABLE_LABEL_CLASS)) {
|
|
385
|
+
const properties = this.getHoverForVariable(target);
|
|
386
|
+
this.hoverRenderer.render(this.node, anchor, properties);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
this.hoverRenderer.hide();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
this.hoverRenderer.hide();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
getHoverForChunk(span) {
|
|
397
|
+
var _a;
|
|
398
|
+
if (span.classList.contains(MemoryTable.EIGHT_BIT_SPAN_CLASS)) {
|
|
399
|
+
const parentByteContainer = span.parentElement;
|
|
400
|
+
if (parentByteContainer === null || parentByteContainer === void 0 ? void 0 : parentByteContainer.textContent) {
|
|
401
|
+
const hex = (_a = parentByteContainer.textContent) !== null && _a !== void 0 ? _a : '';
|
|
402
|
+
const decimal = parseInt(hex, 16);
|
|
403
|
+
const binary = this.getPaddedBinary(decimal);
|
|
404
|
+
const UTF8 = String.fromCodePoint(decimal);
|
|
405
|
+
return { hex, binary, decimal, UTF8 };
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return undefined;
|
|
409
|
+
}
|
|
410
|
+
getPaddedBinary(decimal) {
|
|
411
|
+
const paddedBinary = decimal.toString(2).padStart(this.options.byteSize, '0');
|
|
412
|
+
let paddedAndSpacedBinary = '';
|
|
413
|
+
for (let i = 8; i <= paddedBinary.length; i += 8) {
|
|
414
|
+
paddedAndSpacedBinary += ` ${paddedBinary.slice(i - 8, i)}`;
|
|
415
|
+
}
|
|
416
|
+
return paddedAndSpacedBinary.trim();
|
|
417
|
+
}
|
|
418
|
+
getHoverForVariable(span) {
|
|
419
|
+
var _a, _b;
|
|
420
|
+
const variable = (_a = this.variableFinder) === null || _a === void 0 ? void 0 : _a.searchForVariable((_b = span.textContent) !== null && _b !== void 0 ? _b : '');
|
|
421
|
+
if (variable === null || variable === void 0 ? void 0 : variable.type) {
|
|
422
|
+
return { type: variable.type };
|
|
423
|
+
}
|
|
424
|
+
return undefined;
|
|
425
|
+
}
|
|
426
|
+
doHandleTableRightClick(event) {
|
|
427
|
+
var _a;
|
|
428
|
+
event.preventDefault();
|
|
429
|
+
const target = event.target;
|
|
430
|
+
if ((_a = target.classList) === null || _a === void 0 ? void 0 : _a.contains('eight-bits')) {
|
|
431
|
+
const { right, top } = target.getBoundingClientRect();
|
|
432
|
+
this.update();
|
|
433
|
+
event.stopPropagation();
|
|
434
|
+
this.contextMenuRenderer.render({
|
|
435
|
+
menuPath: MemoryTableWidget_1.CONTEXT_MENU,
|
|
436
|
+
anchor: { x: right, y: top },
|
|
437
|
+
args: this.getContextMenuArgs(event),
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
getContextMenuArgs(event) {
|
|
442
|
+
var _a;
|
|
443
|
+
const args = [this];
|
|
444
|
+
const id = event.target.getAttribute('data-id');
|
|
445
|
+
if (id) {
|
|
446
|
+
const location = (0, util_1.hexStrToUnsignedLong)(id);
|
|
447
|
+
args.push(location);
|
|
448
|
+
const offset = this.memory.address.multiply(-1).add(location);
|
|
449
|
+
const cellAddress = this.memory.address.add(offset.multiply(8 / this.options.byteSize));
|
|
450
|
+
const variableAtLocation = (_a = this.variableFinder) === null || _a === void 0 ? void 0 : _a.searchForVariable(cellAddress);
|
|
451
|
+
args.push(variableAtLocation);
|
|
452
|
+
}
|
|
453
|
+
return args;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
MemoryTableWidget.CONTEXT_MENU = ['memory.view.context.menu'];
|
|
457
|
+
MemoryTableWidget.ID = 'memory-table-widget';
|
|
458
|
+
__decorate([
|
|
459
|
+
(0, inversify_1.inject)(theming_1.ThemeService),
|
|
460
|
+
__metadata("design:type", theming_1.ThemeService)
|
|
461
|
+
], MemoryTableWidget.prototype, "themeService", void 0);
|
|
462
|
+
__decorate([
|
|
463
|
+
(0, inversify_1.inject)(memory_options_widget_1.MemoryOptionsWidget),
|
|
464
|
+
__metadata("design:type", memory_options_widget_1.MemoryOptionsWidget)
|
|
465
|
+
], MemoryTableWidget.prototype, "optionsWidget", void 0);
|
|
466
|
+
__decorate([
|
|
467
|
+
(0, inversify_1.inject)(memory_provider_service_1.MemoryProviderService),
|
|
468
|
+
__metadata("design:type", memory_provider_service_1.MemoryProviderService)
|
|
469
|
+
], MemoryTableWidget.prototype, "memoryProvider", void 0);
|
|
470
|
+
__decorate([
|
|
471
|
+
(0, inversify_1.inject)(memory_hover_renderer_1.MemoryHoverRendererService),
|
|
472
|
+
__metadata("design:type", memory_hover_renderer_1.MemoryHoverRendererService)
|
|
473
|
+
], MemoryTableWidget.prototype, "hoverRenderer", void 0);
|
|
474
|
+
__decorate([
|
|
475
|
+
(0, inversify_1.inject)(browser_1.ContextMenuRenderer),
|
|
476
|
+
__metadata("design:type", browser_1.ContextMenuRenderer)
|
|
477
|
+
], MemoryTableWidget.prototype, "contextMenuRenderer", void 0);
|
|
478
|
+
__decorate([
|
|
479
|
+
(0, inversify_1.postConstruct)(),
|
|
480
|
+
__metadata("design:type", Function),
|
|
481
|
+
__metadata("design:paramtypes", []),
|
|
482
|
+
__metadata("design:returntype", void 0)
|
|
483
|
+
], MemoryTableWidget.prototype, "init", null);
|
|
484
|
+
MemoryTableWidget = MemoryTableWidget_1 = __decorate([
|
|
485
|
+
(0, inversify_1.injectable)()
|
|
486
|
+
], MemoryTableWidget);
|
|
487
|
+
exports.MemoryTableWidget = MemoryTableWidget;
|
|
488
488
|
//# sourceMappingURL=memory-table-widget.js.map
|