@theia/memory-inspector 1.53.0-next.4 → 1.53.0-next.55

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.
Files changed (40) hide show
  1. package/README.md +71 -71
  2. package/package.json +4 -4
  3. package/src/browser/diff-widget/memory-diff-options-widget.tsx +152 -152
  4. package/src/browser/diff-widget/memory-diff-select-widget.tsx +163 -163
  5. package/src/browser/diff-widget/memory-diff-table-widget.tsx +366 -366
  6. package/src/browser/diff-widget/memory-diff-widget-types.ts +45 -45
  7. package/src/browser/editable-widget/memory-editable-table-widget.tsx +359 -359
  8. package/src/browser/memory-inspector-frontend-contribution.ts +301 -301
  9. package/src/browser/memory-inspector-frontend-module.ts +118 -118
  10. package/src/browser/memory-provider/cdt-gdb-memory-provider.ts +132 -132
  11. package/src/browser/memory-provider/memory-provider-service.ts +86 -86
  12. package/src/browser/memory-provider/memory-provider.spec.ts +23 -23
  13. package/src/browser/memory-provider/memory-provider.ts +119 -119
  14. package/src/browser/memory-widget/memory-options-widget.tsx +738 -738
  15. package/src/browser/memory-widget/memory-table-widget.tsx +625 -625
  16. package/src/browser/memory-widget/memory-widget.ts +114 -114
  17. package/src/browser/register-widget/register-filter-service.ts +76 -76
  18. package/src/browser/register-widget/register-options-widget.tsx +393 -393
  19. package/src/browser/register-widget/register-table-widget.tsx +276 -276
  20. package/src/browser/register-widget/register-widget-types.ts +45 -45
  21. package/src/browser/register-widget/register-widget.css +34 -34
  22. package/src/browser/style/index.css +746 -746
  23. package/src/browser/style/memory-lock.svg +21 -21
  24. package/src/browser/style/memory-view.svg +20 -20
  25. package/src/browser/style/register-lock.svg +29 -29
  26. package/src/browser/style/register-view.svg +28 -28
  27. package/src/browser/utils/memory-commands.ts +76 -76
  28. package/src/browser/utils/memory-hover-renderer.ts +113 -113
  29. package/src/browser/utils/memory-recents.ts +58 -58
  30. package/src/browser/utils/memory-widget-components.tsx +193 -193
  31. package/src/browser/utils/memory-widget-manager.ts +179 -179
  32. package/src/browser/utils/memory-widget-utils.tsx +132 -132
  33. package/src/browser/utils/memory-widget-variable-utils.ts +170 -170
  34. package/src/browser/utils/multi-select-bar.css +61 -61
  35. package/src/browser/utils/multi-select-bar.tsx +75 -75
  36. package/src/browser/wrapper-widgets/memory-dock-panel.ts +51 -51
  37. package/src/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.tsx +38 -38
  38. package/src/browser/wrapper-widgets/memory-layout-widget.tsx +167 -167
  39. package/src/common/util.ts +28 -28
  40. package/src/common/utils.spec.ts +52 -52
@@ -1,276 +1,276 @@
1
- /********************************************************************************
2
- * Copyright (C) 2021 Ericsson and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
-
17
- import { Key, KeyCode } from '@theia/core/lib/browser';
18
- import { inject } from '@theia/core/shared/inversify';
19
- import * as React from '@theia/core/shared/react';
20
- import { DebugVariable } from '@theia/debug/lib/browser/console/debug-console-items';
21
- import { EMPTY_MEMORY } from '../memory-widget/memory-options-widget';
22
- import { MemoryTable, MemoryTableWidget } from '../memory-widget/memory-table-widget';
23
- import { Interfaces } from '../utils/memory-widget-utils';
24
- import { RegisterReadResult } from '../utils/memory-widget-variable-utils';
25
- import { RegisterOptions, RegisterOptionsWidget } from './register-options-widget';
26
-
27
- export namespace RegisterTable {
28
-
29
- export const ROW_CLASS = 't-mv-view-row';
30
- export const ROW_DIVIDER_CLASS = 't-mv-view-row-highlight';
31
- export const REGISTER_NAME_CLASS = 't-mv-view-address';
32
- export const REGISTER_DATA_CLASS = 't-mv-view-data';
33
- export const EXTRA_COLUMN_DATA_CLASS = 't-mv-view-code';
34
- export const HEADER_ROW_CLASS = 't-mv-header';
35
-
36
- export interface RowOptions {
37
- regName: string;
38
- regVal: string;
39
- hexadecimal?: string;
40
- decimal?: string;
41
- octal?: string;
42
- binary?: string;
43
- doShowDivider?: boolean;
44
- isChanged?: boolean;
45
- }
46
-
47
- export interface StylableNodeAttributes {
48
- className?: string;
49
- style?: React.CSSProperties;
50
- title?: string;
51
- isChanged?: boolean;
52
- }
53
-
54
- export interface RowDecorator {
55
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
- (...args: any[]): Partial<StylableNodeAttributes>;
57
- }
58
- }
59
-
60
- export class RegisterTableWidget extends MemoryTableWidget {
61
- static override CONTEXT_MENU = ['register.view.context.menu'];
62
- static override ID = 'register-table-widget';
63
-
64
- @inject(RegisterOptionsWidget) override readonly optionsWidget: RegisterOptionsWidget;
65
-
66
- protected readonly registerNotSaved = '<not saved>';
67
- protected registers: RegisterReadResult;
68
- protected previousRegisters: RegisterReadResult | undefined;
69
- protected override options: RegisterOptions;
70
- protected override memory: Interfaces.WidgetMemoryState = { ...EMPTY_MEMORY, variables: [] };
71
-
72
- protected override async doInit(): Promise<void> {
73
- this.id = RegisterTableWidget.ID;
74
- this.addClass(RegisterTableWidget.ID);
75
- this.scrollOptions = { ...this.scrollOptions, suppressScrollX: false };
76
- this.toDispose.push(this.optionsWidget.onOptionsChanged(optionId => this.handleOptionChange(optionId)));
77
- this.toDispose.push(this.optionsWidget.onRegisterChanged(e => this.handleRegisterChange(e)));
78
- this.toDispose.push(this.themeService.onDidColorThemeChange(e => this.handleThemeChange(e)));
79
-
80
- this.getStateAndUpdate();
81
- }
82
-
83
- handleSetValue(dVar: DebugVariable | undefined): void {
84
- if (dVar) {
85
- dVar.open();
86
- }
87
- }
88
-
89
- protected handleRegisterChange(newRegister: [RegisterReadResult, boolean]): void {
90
- const regResult = newRegister[0];
91
- const updatePrevRegs = !newRegister[1];
92
- if (this.registers.threadId !== regResult.threadId) {
93
- // if not same thread Id, dont highlighting register changes
94
- this.previousRegisters = undefined;
95
- } else {
96
- if (updatePrevRegs) {
97
- this.previousRegisters = this.registers;
98
- }
99
- }
100
- this.getStateAndUpdate();
101
- }
102
-
103
- protected override getState(): void {
104
- this.options = this.optionsWidget.options;
105
- this.registers = this.optionsWidget.registers;
106
- }
107
-
108
- protected override getTableRows(): React.ReactNode {
109
- return [...this.renderRegRows()];
110
- }
111
-
112
- protected *renderRegRows(result: RegisterReadResult = this.registers): IterableIterator<React.ReactNode> {
113
- let rowsYielded = 0;
114
- // For each row...
115
- for (const reg of result.registers) {
116
- if (this.optionsWidget.displayReg(reg.name)) {
117
- const notSaved = reg.value === this.registerNotSaved;
118
- const isChanged = this.previousRegisters && reg.value !== this.getPrevRegVal(reg.name, this.previousRegisters);
119
- const options: RegisterTable.RowOptions = {
120
- regName: reg.name,
121
- regVal: reg.value,
122
- hexadecimal: notSaved ? reg.value : this.optionsWidget.handleRadixRendering(reg.value, 16, reg.name),
123
- decimal: notSaved ? reg.value : this.optionsWidget.handleRadixRendering(reg.value, 10),
124
- octal: notSaved ? reg.value : this.optionsWidget.handleRadixRendering(reg.value, 8),
125
- binary: notSaved ? reg.value : this.optionsWidget.handleRadixRendering(reg.value, 2, reg.name),
126
- doShowDivider: (rowsYielded % 4) === 3,
127
- isChanged,
128
- };
129
- yield this.renderRegRow(options);
130
- rowsYielded += 1;
131
- }
132
- }
133
- }
134
-
135
- protected getPrevRegVal(regName: string, inRegs: RegisterReadResult): string | undefined {
136
- return inRegs.registers.find(element => element.name === regName)?.value;
137
- }
138
-
139
- protected renderRegRow(
140
- options: RegisterTable.RowOptions,
141
- getRowAttributes: RegisterTable.RowDecorator = this.getRowAttributes.bind(this),
142
- ): React.ReactNode {
143
- const { regName } = options;
144
- const { className, style, title } = getRowAttributes(options);
145
- return (
146
- <tr
147
- // Add a marker to help visual navigation when scrolling
148
- className={className}
149
- style={style}
150
- title={title}
151
- key={regName}
152
- data-id={regName}
153
- data-value={options.decimal ?? 'none'}
154
- tabIndex={0}
155
- onKeyDown={this.handleRowKeyDown}
156
- onContextMenu={this.options.isFrozen ? undefined : this.handleTableRightClick}
157
- onDoubleClick={this.options.isFrozen ? undefined : this.openDebugVariableByCurrentTarget}
158
- >
159
- <td className={RegisterTable.REGISTER_NAME_CLASS}>{regName}</td>
160
- {this.getExtraRegColumn(options)}
161
- </tr>
162
- );
163
- }
164
-
165
- protected override getRowAttributes(options: Partial<RegisterTable.RowOptions>): Partial<RegisterTable.StylableNodeAttributes> {
166
- let className = RegisterTable.ROW_CLASS;
167
- if (options.doShowDivider) {
168
- className += ` ${RegisterTable.ROW_DIVIDER_CLASS}`;
169
- }
170
- if (options.isChanged) {
171
- // use the eight-bits change CSS class
172
- className += ' eight-bits changed';
173
- }
174
- return { className };
175
- }
176
-
177
- protected getExtraRegColumn(options: Pick<RegisterTable.RowOptions, 'hexadecimal' | 'decimal' | 'octal' | 'binary'>): React.ReactNode[] {
178
- const additionalColumns = [];
179
- if (this.options.columnsDisplayed.hexadecimal.doRender) {
180
- additionalColumns.push(<td className={RegisterTable.EXTRA_COLUMN_DATA_CLASS} key='hexadecimal'>{options.hexadecimal}</td>);
181
- }
182
- if (this.options.columnsDisplayed.decimal.doRender) {
183
- additionalColumns.push(<td className={RegisterTable.EXTRA_COLUMN_DATA_CLASS} key='decimal'>{options.decimal}</td>);
184
- }
185
- if (this.options.columnsDisplayed.octal.doRender) {
186
- additionalColumns.push(<td className={RegisterTable.EXTRA_COLUMN_DATA_CLASS} key='octal'>{options.octal}</td>);
187
- }
188
- if (this.options.columnsDisplayed.binary.doRender) {
189
- additionalColumns.push(<td className={RegisterTable.EXTRA_COLUMN_DATA_CLASS} key='binary'>{options.binary}</td>);
190
- }
191
-
192
- return additionalColumns;
193
- }
194
-
195
- protected override getWrapperHandlers(): MemoryTable.WrapperHandlers {
196
- return this.options.isFrozen || this.options.noRadixColumnDisplayed
197
- ? super.getWrapperHandlers()
198
- : {
199
- onMouseMove: this.handleTableMouseMove,
200
- onContextMenu: this.handleTableRightClick,
201
- };
202
- }
203
-
204
- protected override doHandleTableMouseMove(targetElement: React.MouseEvent['target']): void {
205
- const tempTarget = targetElement as HTMLElement;
206
- const target = tempTarget.parentElement?.tagName === 'TR' ? tempTarget.parentElement : tempTarget;
207
- if (target.tagName === 'TR') {
208
- const { x, y } = target.getBoundingClientRect();
209
- const anchor = { x: Math.round(x), y: Math.round(y + target.clientHeight) };
210
- const value = Number(target.getAttribute('data-value'));
211
- if (!isNaN(value)) {
212
- const register = target.getAttribute('data-id') as string;
213
- const properties = {
214
- register,
215
- hex: `0x${value.toString(16)}`,
216
- binary: `0b${value.toString(2)}`,
217
- decimal: value.toString(10),
218
- octal: `0o${value.toString(8)}`,
219
- };
220
- return this.hoverRenderer.render(this.node, anchor, properties);
221
- }
222
- }
223
- return this.hoverRenderer.hide();
224
- }
225
-
226
- protected handleRowKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {
227
- const keyCode = KeyCode.createKeyCode(event.nativeEvent).key?.keyCode;
228
- switch (keyCode) {
229
- case Key.ENTER.keyCode:
230
- this.openDebugVariableByCurrentTarget(event);
231
- break;
232
- default:
233
- break;
234
- }
235
- };
236
-
237
- protected openDebugVariableByCurrentTarget = (event: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement>): void => {
238
- this.openDebugVariableByDataId(event.currentTarget);
239
- };
240
-
241
- protected openDebugVariableByDataId(element: HTMLElement): void {
242
- const registerName = element.getAttribute('data-id');
243
- if (registerName) {
244
- this.openDebugVariableByName(registerName);
245
- }
246
- }
247
-
248
- protected openDebugVariableByName(registerName: string): void {
249
- const debugVariable = this.registers.registers.find(element => element.name === registerName);
250
- this.handleSetValue(debugVariable);
251
- }
252
-
253
- protected override doHandleTableRightClick(event: React.MouseEvent): void {
254
- event.preventDefault();
255
- const curTarget = event.currentTarget as HTMLElement;
256
- if (curTarget.tagName === 'TR') {
257
- this.update();
258
- event.stopPropagation();
259
- this.contextMenuRenderer.render({
260
- menuPath: RegisterTableWidget.CONTEXT_MENU,
261
- anchor: event.nativeEvent,
262
- args: this.getContextMenuArgs(event),
263
- });
264
- }
265
- }
266
-
267
- protected override getContextMenuArgs(event: React.MouseEvent): unknown[] {
268
- const args: unknown[] = [this];
269
- const regName = (event.currentTarget as HTMLElement).getAttribute('data-id');
270
- if (regName) {
271
- const dVar = this.registers.registers.find(element => element.name === regName);
272
- args.push(dVar);
273
- }
274
- return args;
275
- }
276
- }
1
+ /********************************************************************************
2
+ * Copyright (C) 2021 Ericsson and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import { Key, KeyCode } from '@theia/core/lib/browser';
18
+ import { inject } from '@theia/core/shared/inversify';
19
+ import * as React from '@theia/core/shared/react';
20
+ import { DebugVariable } from '@theia/debug/lib/browser/console/debug-console-items';
21
+ import { EMPTY_MEMORY } from '../memory-widget/memory-options-widget';
22
+ import { MemoryTable, MemoryTableWidget } from '../memory-widget/memory-table-widget';
23
+ import { Interfaces } from '../utils/memory-widget-utils';
24
+ import { RegisterReadResult } from '../utils/memory-widget-variable-utils';
25
+ import { RegisterOptions, RegisterOptionsWidget } from './register-options-widget';
26
+
27
+ export namespace RegisterTable {
28
+
29
+ export const ROW_CLASS = 't-mv-view-row';
30
+ export const ROW_DIVIDER_CLASS = 't-mv-view-row-highlight';
31
+ export const REGISTER_NAME_CLASS = 't-mv-view-address';
32
+ export const REGISTER_DATA_CLASS = 't-mv-view-data';
33
+ export const EXTRA_COLUMN_DATA_CLASS = 't-mv-view-code';
34
+ export const HEADER_ROW_CLASS = 't-mv-header';
35
+
36
+ export interface RowOptions {
37
+ regName: string;
38
+ regVal: string;
39
+ hexadecimal?: string;
40
+ decimal?: string;
41
+ octal?: string;
42
+ binary?: string;
43
+ doShowDivider?: boolean;
44
+ isChanged?: boolean;
45
+ }
46
+
47
+ export interface StylableNodeAttributes {
48
+ className?: string;
49
+ style?: React.CSSProperties;
50
+ title?: string;
51
+ isChanged?: boolean;
52
+ }
53
+
54
+ export interface RowDecorator {
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ (...args: any[]): Partial<StylableNodeAttributes>;
57
+ }
58
+ }
59
+
60
+ export class RegisterTableWidget extends MemoryTableWidget {
61
+ static override CONTEXT_MENU = ['register.view.context.menu'];
62
+ static override ID = 'register-table-widget';
63
+
64
+ @inject(RegisterOptionsWidget) override readonly optionsWidget: RegisterOptionsWidget;
65
+
66
+ protected readonly registerNotSaved = '<not saved>';
67
+ protected registers: RegisterReadResult;
68
+ protected previousRegisters: RegisterReadResult | undefined;
69
+ protected override options: RegisterOptions;
70
+ protected override memory: Interfaces.WidgetMemoryState = { ...EMPTY_MEMORY, variables: [] };
71
+
72
+ protected override async doInit(): Promise<void> {
73
+ this.id = RegisterTableWidget.ID;
74
+ this.addClass(RegisterTableWidget.ID);
75
+ this.scrollOptions = { ...this.scrollOptions, suppressScrollX: false };
76
+ this.toDispose.push(this.optionsWidget.onOptionsChanged(optionId => this.handleOptionChange(optionId)));
77
+ this.toDispose.push(this.optionsWidget.onRegisterChanged(e => this.handleRegisterChange(e)));
78
+ this.toDispose.push(this.themeService.onDidColorThemeChange(e => this.handleThemeChange(e)));
79
+
80
+ this.getStateAndUpdate();
81
+ }
82
+
83
+ handleSetValue(dVar: DebugVariable | undefined): void {
84
+ if (dVar) {
85
+ dVar.open();
86
+ }
87
+ }
88
+
89
+ protected handleRegisterChange(newRegister: [RegisterReadResult, boolean]): void {
90
+ const regResult = newRegister[0];
91
+ const updatePrevRegs = !newRegister[1];
92
+ if (this.registers.threadId !== regResult.threadId) {
93
+ // if not same thread Id, dont highlighting register changes
94
+ this.previousRegisters = undefined;
95
+ } else {
96
+ if (updatePrevRegs) {
97
+ this.previousRegisters = this.registers;
98
+ }
99
+ }
100
+ this.getStateAndUpdate();
101
+ }
102
+
103
+ protected override getState(): void {
104
+ this.options = this.optionsWidget.options;
105
+ this.registers = this.optionsWidget.registers;
106
+ }
107
+
108
+ protected override getTableRows(): React.ReactNode {
109
+ return [...this.renderRegRows()];
110
+ }
111
+
112
+ protected *renderRegRows(result: RegisterReadResult = this.registers): IterableIterator<React.ReactNode> {
113
+ let rowsYielded = 0;
114
+ // For each row...
115
+ for (const reg of result.registers) {
116
+ if (this.optionsWidget.displayReg(reg.name)) {
117
+ const notSaved = reg.value === this.registerNotSaved;
118
+ const isChanged = this.previousRegisters && reg.value !== this.getPrevRegVal(reg.name, this.previousRegisters);
119
+ const options: RegisterTable.RowOptions = {
120
+ regName: reg.name,
121
+ regVal: reg.value,
122
+ hexadecimal: notSaved ? reg.value : this.optionsWidget.handleRadixRendering(reg.value, 16, reg.name),
123
+ decimal: notSaved ? reg.value : this.optionsWidget.handleRadixRendering(reg.value, 10),
124
+ octal: notSaved ? reg.value : this.optionsWidget.handleRadixRendering(reg.value, 8),
125
+ binary: notSaved ? reg.value : this.optionsWidget.handleRadixRendering(reg.value, 2, reg.name),
126
+ doShowDivider: (rowsYielded % 4) === 3,
127
+ isChanged,
128
+ };
129
+ yield this.renderRegRow(options);
130
+ rowsYielded += 1;
131
+ }
132
+ }
133
+ }
134
+
135
+ protected getPrevRegVal(regName: string, inRegs: RegisterReadResult): string | undefined {
136
+ return inRegs.registers.find(element => element.name === regName)?.value;
137
+ }
138
+
139
+ protected renderRegRow(
140
+ options: RegisterTable.RowOptions,
141
+ getRowAttributes: RegisterTable.RowDecorator = this.getRowAttributes.bind(this),
142
+ ): React.ReactNode {
143
+ const { regName } = options;
144
+ const { className, style, title } = getRowAttributes(options);
145
+ return (
146
+ <tr
147
+ // Add a marker to help visual navigation when scrolling
148
+ className={className}
149
+ style={style}
150
+ title={title}
151
+ key={regName}
152
+ data-id={regName}
153
+ data-value={options.decimal ?? 'none'}
154
+ tabIndex={0}
155
+ onKeyDown={this.handleRowKeyDown}
156
+ onContextMenu={this.options.isFrozen ? undefined : this.handleTableRightClick}
157
+ onDoubleClick={this.options.isFrozen ? undefined : this.openDebugVariableByCurrentTarget}
158
+ >
159
+ <td className={RegisterTable.REGISTER_NAME_CLASS}>{regName}</td>
160
+ {this.getExtraRegColumn(options)}
161
+ </tr>
162
+ );
163
+ }
164
+
165
+ protected override getRowAttributes(options: Partial<RegisterTable.RowOptions>): Partial<RegisterTable.StylableNodeAttributes> {
166
+ let className = RegisterTable.ROW_CLASS;
167
+ if (options.doShowDivider) {
168
+ className += ` ${RegisterTable.ROW_DIVIDER_CLASS}`;
169
+ }
170
+ if (options.isChanged) {
171
+ // use the eight-bits change CSS class
172
+ className += ' eight-bits changed';
173
+ }
174
+ return { className };
175
+ }
176
+
177
+ protected getExtraRegColumn(options: Pick<RegisterTable.RowOptions, 'hexadecimal' | 'decimal' | 'octal' | 'binary'>): React.ReactNode[] {
178
+ const additionalColumns = [];
179
+ if (this.options.columnsDisplayed.hexadecimal.doRender) {
180
+ additionalColumns.push(<td className={RegisterTable.EXTRA_COLUMN_DATA_CLASS} key='hexadecimal'>{options.hexadecimal}</td>);
181
+ }
182
+ if (this.options.columnsDisplayed.decimal.doRender) {
183
+ additionalColumns.push(<td className={RegisterTable.EXTRA_COLUMN_DATA_CLASS} key='decimal'>{options.decimal}</td>);
184
+ }
185
+ if (this.options.columnsDisplayed.octal.doRender) {
186
+ additionalColumns.push(<td className={RegisterTable.EXTRA_COLUMN_DATA_CLASS} key='octal'>{options.octal}</td>);
187
+ }
188
+ if (this.options.columnsDisplayed.binary.doRender) {
189
+ additionalColumns.push(<td className={RegisterTable.EXTRA_COLUMN_DATA_CLASS} key='binary'>{options.binary}</td>);
190
+ }
191
+
192
+ return additionalColumns;
193
+ }
194
+
195
+ protected override getWrapperHandlers(): MemoryTable.WrapperHandlers {
196
+ return this.options.isFrozen || this.options.noRadixColumnDisplayed
197
+ ? super.getWrapperHandlers()
198
+ : {
199
+ onMouseMove: this.handleTableMouseMove,
200
+ onContextMenu: this.handleTableRightClick,
201
+ };
202
+ }
203
+
204
+ protected override doHandleTableMouseMove(targetElement: React.MouseEvent['target']): void {
205
+ const tempTarget = targetElement as HTMLElement;
206
+ const target = tempTarget.parentElement?.tagName === 'TR' ? tempTarget.parentElement : tempTarget;
207
+ if (target.tagName === 'TR') {
208
+ const { x, y } = target.getBoundingClientRect();
209
+ const anchor = { x: Math.round(x), y: Math.round(y + target.clientHeight) };
210
+ const value = Number(target.getAttribute('data-value'));
211
+ if (!isNaN(value)) {
212
+ const register = target.getAttribute('data-id') as string;
213
+ const properties = {
214
+ register,
215
+ hex: `0x${value.toString(16)}`,
216
+ binary: `0b${value.toString(2)}`,
217
+ decimal: value.toString(10),
218
+ octal: `0o${value.toString(8)}`,
219
+ };
220
+ return this.hoverRenderer.render(this.node, anchor, properties);
221
+ }
222
+ }
223
+ return this.hoverRenderer.hide();
224
+ }
225
+
226
+ protected handleRowKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {
227
+ const keyCode = KeyCode.createKeyCode(event.nativeEvent).key?.keyCode;
228
+ switch (keyCode) {
229
+ case Key.ENTER.keyCode:
230
+ this.openDebugVariableByCurrentTarget(event);
231
+ break;
232
+ default:
233
+ break;
234
+ }
235
+ };
236
+
237
+ protected openDebugVariableByCurrentTarget = (event: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement>): void => {
238
+ this.openDebugVariableByDataId(event.currentTarget);
239
+ };
240
+
241
+ protected openDebugVariableByDataId(element: HTMLElement): void {
242
+ const registerName = element.getAttribute('data-id');
243
+ if (registerName) {
244
+ this.openDebugVariableByName(registerName);
245
+ }
246
+ }
247
+
248
+ protected openDebugVariableByName(registerName: string): void {
249
+ const debugVariable = this.registers.registers.find(element => element.name === registerName);
250
+ this.handleSetValue(debugVariable);
251
+ }
252
+
253
+ protected override doHandleTableRightClick(event: React.MouseEvent): void {
254
+ event.preventDefault();
255
+ const curTarget = event.currentTarget as HTMLElement;
256
+ if (curTarget.tagName === 'TR') {
257
+ this.update();
258
+ event.stopPropagation();
259
+ this.contextMenuRenderer.render({
260
+ menuPath: RegisterTableWidget.CONTEXT_MENU,
261
+ anchor: event.nativeEvent,
262
+ args: this.getContextMenuArgs(event),
263
+ });
264
+ }
265
+ }
266
+
267
+ protected override getContextMenuArgs(event: React.MouseEvent): unknown[] {
268
+ const args: unknown[] = [this];
269
+ const regName = (event.currentTarget as HTMLElement).getAttribute('data-id');
270
+ if (regName) {
271
+ const dVar = this.registers.registers.find(element => element.name === regName);
272
+ args.push(dVar);
273
+ }
274
+ return args;
275
+ }
276
+ }
@@ -1,45 +1,45 @@
1
- /********************************************************************************
2
- * Copyright (C) 2021 Ericsson and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
-
17
- import { nls } from '@theia/core';
18
- import { interfaces } from '@theia/core/shared/inversify';
19
- import { MemoryOptionsWidget } from '../memory-widget/memory-options-widget';
20
- import { MemoryTableWidget } from '../memory-widget/memory-table-widget';
21
- import { MemoryWidget } from '../memory-widget/memory-widget';
22
- import { MemoryWidgetOptions } from '../utils/memory-widget-utils';
23
- import { RegisterFilterService, RegisterFilterServiceImpl, RegisterFilterServiceOptions } from './register-filter-service';
24
- import { RegisterOptionsWidget } from './register-options-widget';
25
- import { RegisterTableWidget } from './register-table-widget';
26
-
27
- export type RegisterWidget = MemoryWidget<RegisterOptionsWidget, RegisterTableWidget>;
28
- export namespace RegisterWidget {
29
- export const ID = 'register-view-options-widget';
30
- export const LABEL = nls.localize('theia/memory-inspector/register', 'Register');
31
- export const is = (widget: MemoryWidget): boolean => widget.optionsWidget instanceof RegisterOptionsWidget;
32
-
33
- export const createContainer = (
34
- parent: interfaces.Container,
35
- optionsWidget: interfaces.ServiceIdentifier<MemoryOptionsWidget>,
36
- tableWidget: interfaces.ServiceIdentifier<MemoryTableWidget>,
37
- optionSymbol: interfaces.ServiceIdentifier<MemoryWidgetOptions | undefined> = MemoryWidgetOptions,
38
- options?: MemoryWidgetOptions,
39
- ): interfaces.Container => {
40
- const child = MemoryWidget.createContainer(parent, optionsWidget, tableWidget, optionSymbol, options);
41
- child.bind(RegisterFilterService).to(RegisterFilterServiceImpl).inSingletonScope();
42
- child.bind(RegisterFilterServiceOptions).toConstantValue({});
43
- return child;
44
- };
45
- }
1
+ /********************************************************************************
2
+ * Copyright (C) 2021 Ericsson and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import { nls } from '@theia/core';
18
+ import { interfaces } from '@theia/core/shared/inversify';
19
+ import { MemoryOptionsWidget } from '../memory-widget/memory-options-widget';
20
+ import { MemoryTableWidget } from '../memory-widget/memory-table-widget';
21
+ import { MemoryWidget } from '../memory-widget/memory-widget';
22
+ import { MemoryWidgetOptions } from '../utils/memory-widget-utils';
23
+ import { RegisterFilterService, RegisterFilterServiceImpl, RegisterFilterServiceOptions } from './register-filter-service';
24
+ import { RegisterOptionsWidget } from './register-options-widget';
25
+ import { RegisterTableWidget } from './register-table-widget';
26
+
27
+ export type RegisterWidget = MemoryWidget<RegisterOptionsWidget, RegisterTableWidget>;
28
+ export namespace RegisterWidget {
29
+ export const ID = 'register-view-options-widget';
30
+ export const LABEL = nls.localize('theia/memory-inspector/register', 'Register');
31
+ export const is = (widget: MemoryWidget): boolean => widget.optionsWidget instanceof RegisterOptionsWidget;
32
+
33
+ export const createContainer = (
34
+ parent: interfaces.Container,
35
+ optionsWidget: interfaces.ServiceIdentifier<MemoryOptionsWidget>,
36
+ tableWidget: interfaces.ServiceIdentifier<MemoryTableWidget>,
37
+ optionSymbol: interfaces.ServiceIdentifier<MemoryWidgetOptions | undefined> = MemoryWidgetOptions,
38
+ options?: MemoryWidgetOptions,
39
+ ): interfaces.Container => {
40
+ const child = MemoryWidget.createContainer(parent, optionsWidget, tableWidget, optionSymbol, options);
41
+ child.bind(RegisterFilterService).to(RegisterFilterServiceImpl).inSingletonScope();
42
+ child.bind(RegisterFilterServiceOptions).toConstantValue({});
43
+ return child;
44
+ };
45
+ }