@theia/memory-inspector 1.45.0 → 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.
Files changed (102) hide show
  1. package/README.md +71 -71
  2. package/lib/browser/diff-widget/memory-diff-options-widget.d.ts +36 -36
  3. package/lib/browser/diff-widget/memory-diff-options-widget.js +132 -132
  4. package/lib/browser/diff-widget/memory-diff-select-widget.d.ts +50 -50
  5. package/lib/browser/diff-widget/memory-diff-select-widget.js +137 -137
  6. package/lib/browser/diff-widget/memory-diff-table-widget.d.ts +77 -77
  7. package/lib/browser/diff-widget/memory-diff-table-widget.js +314 -314
  8. package/lib/browser/diff-widget/memory-diff-widget-types.d.ts +41 -41
  9. package/lib/browser/diff-widget/memory-diff-widget-types.js +23 -23
  10. package/lib/browser/editable-widget/memory-editable-table-widget.d.ts +64 -64
  11. package/lib/browser/editable-widget/memory-editable-table-widget.js +324 -324
  12. package/lib/browser/memory-inspector-frontend-contribution.d.ts +46 -46
  13. package/lib/browser/memory-inspector-frontend-contribution.js +291 -291
  14. package/lib/browser/memory-inspector-frontend-module.d.ts +21 -21
  15. package/lib/browser/memory-inspector-frontend-module.js +87 -87
  16. package/lib/browser/memory-provider/cdt-gdb-memory-provider.d.ts +35 -35
  17. package/lib/browser/memory-provider/cdt-gdb-memory-provider.js +136 -136
  18. package/lib/browser/memory-provider/memory-provider-service.d.ts +36 -36
  19. package/lib/browser/memory-provider/memory-provider-service.js +101 -101
  20. package/lib/browser/memory-provider/memory-provider.d.ts +65 -65
  21. package/lib/browser/memory-provider/memory-provider.js +96 -96
  22. package/lib/browser/memory-provider/memory-provider.spec.d.ts +16 -16
  23. package/lib/browser/memory-provider/memory-provider.spec.js +23 -23
  24. package/lib/browser/memory-widget/memory-options-widget.d.ts +136 -136
  25. package/lib/browser/memory-widget/memory-options-widget.js +564 -564
  26. package/lib/browser/memory-widget/memory-table-widget.d.ts +146 -146
  27. package/lib/browser/memory-widget/memory-table-widget.js +487 -487
  28. package/lib/browser/memory-widget/memory-widget.d.ts +33 -33
  29. package/lib/browser/memory-widget/memory-widget.js +112 -112
  30. package/lib/browser/register-widget/register-filter-service.d.ts +42 -42
  31. package/lib/browser/register-widget/register-filter-service.js +81 -81
  32. package/lib/browser/register-widget/register-options-widget.d.ts +81 -81
  33. package/lib/browser/register-widget/register-options-widget.js +338 -338
  34. package/lib/browser/register-widget/register-table-widget.d.ts +77 -77
  35. package/lib/browser/register-widget/register-table-widget.js +230 -230
  36. package/lib/browser/register-widget/register-widget-types.d.ts +29 -29
  37. package/lib/browser/register-widget/register-widget-types.js +35 -35
  38. package/lib/browser/utils/memory-commands.d.ts +27 -27
  39. package/lib/browser/utils/memory-commands.js +67 -67
  40. package/lib/browser/utils/memory-hover-renderer.d.ts +33 -33
  41. package/lib/browser/utils/memory-hover-renderer.js +111 -111
  42. package/lib/browser/utils/memory-recents.d.ts +27 -27
  43. package/lib/browser/utils/memory-recents.js +52 -52
  44. package/lib/browser/utils/memory-widget-components.d.ts +58 -58
  45. package/lib/browser/utils/memory-widget-components.js +69 -69
  46. package/lib/browser/utils/memory-widget-manager.d.ts +50 -50
  47. package/lib/browser/utils/memory-widget-manager.js +182 -182
  48. package/lib/browser/utils/memory-widget-utils.d.ts +113 -113
  49. package/lib/browser/utils/memory-widget-utils.js +42 -42
  50. package/lib/browser/utils/memory-widget-variable-utils.d.ts +57 -57
  51. package/lib/browser/utils/memory-widget-variable-utils.js +143 -143
  52. package/lib/browser/utils/multi-select-bar.d.ts +31 -31
  53. package/lib/browser/utils/multi-select-bar.js +34 -34
  54. package/lib/browser/wrapper-widgets/memory-dock-panel.d.ts +24 -24
  55. package/lib/browser/wrapper-widgets/memory-dock-panel.js +48 -48
  56. package/lib/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.d.ts +23 -23
  57. package/lib/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.js +57 -57
  58. package/lib/browser/wrapper-widgets/memory-layout-widget.d.ts +51 -51
  59. package/lib/browser/wrapper-widgets/memory-layout-widget.js +191 -191
  60. package/lib/common/util.d.ts +21 -21
  61. package/lib/common/util.js +30 -30
  62. package/lib/common/utils.spec.d.ts +16 -16
  63. package/lib/common/utils.spec.js +45 -45
  64. package/package.json +4 -4
  65. package/src/browser/diff-widget/memory-diff-options-widget.tsx +152 -152
  66. package/src/browser/diff-widget/memory-diff-select-widget.tsx +163 -163
  67. package/src/browser/diff-widget/memory-diff-table-widget.tsx +366 -366
  68. package/src/browser/diff-widget/memory-diff-widget-types.ts +45 -45
  69. package/src/browser/editable-widget/memory-editable-table-widget.tsx +359 -359
  70. package/src/browser/memory-inspector-frontend-contribution.ts +301 -301
  71. package/src/browser/memory-inspector-frontend-module.ts +118 -118
  72. package/src/browser/memory-provider/cdt-gdb-memory-provider.ts +132 -132
  73. package/src/browser/memory-provider/memory-provider-service.ts +86 -86
  74. package/src/browser/memory-provider/memory-provider.spec.ts +23 -23
  75. package/src/browser/memory-provider/memory-provider.ts +119 -119
  76. package/src/browser/memory-widget/memory-options-widget.tsx +738 -738
  77. package/src/browser/memory-widget/memory-table-widget.tsx +625 -625
  78. package/src/browser/memory-widget/memory-widget.ts +114 -114
  79. package/src/browser/register-widget/register-filter-service.ts +76 -76
  80. package/src/browser/register-widget/register-options-widget.tsx +393 -393
  81. package/src/browser/register-widget/register-table-widget.tsx +276 -276
  82. package/src/browser/register-widget/register-widget-types.ts +45 -45
  83. package/src/browser/register-widget/register-widget.css +34 -34
  84. package/src/browser/style/index.css +746 -746
  85. package/src/browser/style/memory-lock.svg +21 -21
  86. package/src/browser/style/memory-view.svg +20 -20
  87. package/src/browser/style/register-lock.svg +29 -29
  88. package/src/browser/style/register-view.svg +28 -28
  89. package/src/browser/utils/memory-commands.ts +76 -76
  90. package/src/browser/utils/memory-hover-renderer.ts +113 -113
  91. package/src/browser/utils/memory-recents.ts +58 -58
  92. package/src/browser/utils/memory-widget-components.tsx +193 -193
  93. package/src/browser/utils/memory-widget-manager.ts +179 -179
  94. package/src/browser/utils/memory-widget-utils.tsx +132 -132
  95. package/src/browser/utils/memory-widget-variable-utils.ts +170 -170
  96. package/src/browser/utils/multi-select-bar.css +61 -61
  97. package/src/browser/utils/multi-select-bar.tsx +75 -75
  98. package/src/browser/wrapper-widgets/memory-dock-panel.ts +51 -51
  99. package/src/browser/wrapper-widgets/memory-dockpanel-placeholder-widget.tsx +38 -38
  100. package/src/browser/wrapper-widgets/memory-layout-widget.tsx +167 -167
  101. package/src/common/util.ts +28 -28
  102. package/src/common/utils.spec.ts +52 -52
@@ -1,58 +1,58 @@
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
- /*
18
- * Utility for storing and sorting an array of most recently visited memory locations
19
- */
20
- interface RecentsOptions {
21
- maxValues?: number;
22
- }
23
-
24
- export class Recents {
25
- protected maxValues: number;
26
- protected _values: string[] = [];
27
- get values(): string[] {
28
- return this._values;
29
- }
30
-
31
- constructor(initialValues?: string[], opts?: RecentsOptions) {
32
- this.maxValues = opts?.maxValues ?? 10;
33
- if (initialValues) {
34
- if (initialValues.length <= this.maxValues) {
35
- this._values = initialValues;
36
- return;
37
- }
38
- console.error('Initial values length is greater than allowed length, resetting to empty array');
39
- }
40
- this._values = [];
41
- }
42
-
43
- add(locationString: string): void {
44
- const indexOf = this.has(locationString);
45
- if (indexOf > -1) {
46
- this._values.splice(indexOf, 1);
47
- } else {
48
- if (this._values.length === this.maxValues) {
49
- this._values.shift();
50
- }
51
- }
52
- this._values.push(locationString);
53
- }
54
-
55
- has(locationString: string): number {
56
- return this._values.indexOf(locationString);
57
- }
58
- }
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
+ /*
18
+ * Utility for storing and sorting an array of most recently visited memory locations
19
+ */
20
+ interface RecentsOptions {
21
+ maxValues?: number;
22
+ }
23
+
24
+ export class Recents {
25
+ protected maxValues: number;
26
+ protected _values: string[] = [];
27
+ get values(): string[] {
28
+ return this._values;
29
+ }
30
+
31
+ constructor(initialValues?: string[], opts?: RecentsOptions) {
32
+ this.maxValues = opts?.maxValues ?? 10;
33
+ if (initialValues) {
34
+ if (initialValues.length <= this.maxValues) {
35
+ this._values = initialValues;
36
+ return;
37
+ }
38
+ console.error('Initial values length is greater than allowed length, resetting to empty array');
39
+ }
40
+ this._values = [];
41
+ }
42
+
43
+ add(locationString: string): void {
44
+ const indexOf = this.has(locationString);
45
+ if (indexOf > -1) {
46
+ this._values.splice(indexOf, 1);
47
+ } else {
48
+ if (this._values.length === this.maxValues) {
49
+ this._values.shift();
50
+ }
51
+ }
52
+ this._values.push(locationString);
53
+ }
54
+
55
+ has(locationString: string): number {
56
+ return this._values.indexOf(locationString);
57
+ }
58
+ }
@@ -1,193 +1,193 @@
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 * as React from '@theia/core/shared/react';
19
- import { Interfaces } from './memory-widget-utils';
20
-
21
- export interface MWLabelProps { id: string; label: string; disabled?: boolean; classNames?: string[] }
22
-
23
- export const MWLabel: React.FC<MWLabelProps> = ({ id, label, disabled, classNames }) => {
24
- const additionalClassNames = classNames ? classNames.join(' ') : '';
25
- return <label htmlFor={id} className={`t-mv-label theia-header no-select ${additionalClassNames}${disabled ? ' disabled' : ''}`}>{label}</label>;
26
- };
27
-
28
- export interface InputProps<T extends HTMLElement = HTMLElement> {
29
- id: string;
30
- label: string;
31
- defaultValue?: string;
32
- value?: string;
33
- onChange?: React.EventHandler<React.ChangeEvent>;
34
- onKeyDown?: React.EventHandler<React.KeyboardEvent<HTMLInputElement>>;
35
- passRef?: React.ClassAttributes<T>['ref'];
36
- title?: string;
37
- disabled?: boolean;
38
- placeholder?: string;
39
- }
40
-
41
- export const MWInput: React.FC<InputProps<HTMLInputElement>> = ({ id, label, passRef, defaultValue, onChange, title, onKeyDown, disabled }) => (
42
- <>
43
- <MWLabel id={id} label={label} disabled={disabled} />
44
- <input
45
- tabIndex={0}
46
- type='text'
47
- ref={passRef}
48
- id={id}
49
- className='theia-input t-mv-input'
50
- defaultValue={defaultValue}
51
- onChange={onChange}
52
- onKeyDown={onKeyDown}
53
- title={title}
54
- spellCheck={false}
55
- disabled={disabled}
56
- />
57
- </>
58
- );
59
-
60
- export interface LabelAndSelectProps extends InputProps<HTMLSelectElement> {
61
- options: string[];
62
- }
63
-
64
- export const MWSelect: React.FC<LabelAndSelectProps> = ({ id, label, options, passRef, onChange, title, value, disabled }) => (
65
- <>
66
- <MWLabel id={id} label={label} disabled={disabled} />
67
- <select
68
- tabIndex={0}
69
- ref={passRef}
70
- id={id}
71
- className='theia-select t-mv-select'
72
- value={value}
73
- onChange={onChange}
74
- title={title}
75
- disabled={disabled}
76
- >
77
- {options.map(option => <option value={option} key={option}>{option}</option>)}
78
- </select>
79
- </>
80
- );
81
-
82
- export interface LabelAndSelectWithNameProps extends InputProps<HTMLSelectElement> {
83
- options: Array<[string, string]>;
84
- }
85
-
86
- export const MWSelectWithName: React.FC<LabelAndSelectWithNameProps> = ({ id, label, options, passRef, onChange, title, value, disabled }) => (
87
- <>
88
- <MWLabel id={id} label={label} disabled={disabled} />
89
- <select
90
- tabIndex={0}
91
- ref={passRef}
92
- id={id}
93
- className='theia-select'
94
- value={value}
95
- onChange={onChange}
96
- title={title}
97
- disabled={disabled}
98
- >
99
- {options.map(option => <option value={option[0]} key={option[0]}>{option[1]}</option>)}
100
- </select>
101
- </>
102
- );
103
-
104
- export interface InputWithSelectProps<T extends HTMLElement> extends InputProps<T> {
105
- options: string[];
106
- onSelectChange?(e: React.ChangeEvent): void;
107
- onInputChange?(e: React.ChangeEvent<HTMLInputElement>): void;
108
- }
109
- export const MWInputWithSelect: React.FC<InputWithSelectProps<HTMLInputElement>> = (
110
- { id, label, passRef, onKeyDown, title, options, onSelectChange, defaultValue, disabled, placeholder },
111
- ) => (
112
- <>
113
- <MWLabel id={id} label={label} disabled={disabled} />
114
- <div className='mw-input-select'>
115
- <input
116
- tabIndex={0}
117
- type='text'
118
- ref={passRef}
119
- id={id}
120
- className='theia-input t-mv-input'
121
- defaultValue={defaultValue}
122
- onKeyDown={onKeyDown}
123
- title={title}
124
- spellCheck={false}
125
- disabled={disabled}
126
- placeholder={placeholder}
127
- />
128
- <select
129
- className='theia-select t-mv-select'
130
- onChange={onSelectChange}
131
- disabled={disabled || (options.length === 0)}
132
- >
133
- {options.reverse().map(option => <option key={`'mw-input-select'-${id}-${option}`} value={option}>{option}</option>)}
134
- </select>
135
- </div>
136
- </>
137
- );
138
-
139
- export interface MoreMemoryProps {
140
- options: number[];
141
- direction: 'above' | 'below';
142
- handler(opts: Interfaces.MoreMemoryOptions): void;
143
- }
144
-
145
- export const MWMoreMemorySelect: React.FC<MoreMemoryProps> = ({ options, handler, direction }) => {
146
- const [numBytes, setNumBytes] = React.useState<number>(options[0]);
147
- const containerRef = React.createRef<HTMLDivElement>();
148
- const onSelectChange = (e: React.ChangeEvent<HTMLSelectElement>): void => {
149
- e.stopPropagation();
150
- const { value } = e.currentTarget;
151
- setNumBytes(parseInt(value));
152
- };
153
-
154
- const loadMoreMemory = (e: React.MouseEvent | React.KeyboardEvent): void => {
155
- containerRef.current?.blur();
156
- const doHandle = !('key' in e) || KeyCode.createKeyCode(e.nativeEvent).key?.keyCode === Key.ENTER.keyCode;
157
- if (doHandle) {
158
- handler({
159
- numBytes,
160
- direction,
161
- });
162
- }
163
- };
164
-
165
- return (
166
- <div
167
- className='mw-more-memory-select'
168
- tabIndex={0}
169
- role='button'
170
- onClick={loadMoreMemory}
171
- onKeyDown={loadMoreMemory}
172
- ref={containerRef}
173
- >
174
- <div className='mw-more-memory-select-top no-select'>
175
- Load
176
- <select
177
- className='theia-select'
178
- onChange={onSelectChange}
179
- tabIndex={0}
180
- >
181
- {options.map(option => (
182
- <option
183
- key={`mw-more-memory-select-${option}`}
184
- value={option}
185
- >
186
- {option}
187
- </option>))}
188
- </select>
189
- {`more bytes ${direction}`}
190
- </div>
191
- </div>
192
- );
193
- };
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 * as React from '@theia/core/shared/react';
19
+ import { Interfaces } from './memory-widget-utils';
20
+
21
+ export interface MWLabelProps { id: string; label: string; disabled?: boolean; classNames?: string[] }
22
+
23
+ export const MWLabel: React.FC<MWLabelProps> = ({ id, label, disabled, classNames }) => {
24
+ const additionalClassNames = classNames ? classNames.join(' ') : '';
25
+ return <label htmlFor={id} className={`t-mv-label theia-header no-select ${additionalClassNames}${disabled ? ' disabled' : ''}`}>{label}</label>;
26
+ };
27
+
28
+ export interface InputProps<T extends HTMLElement = HTMLElement> {
29
+ id: string;
30
+ label: string;
31
+ defaultValue?: string;
32
+ value?: string;
33
+ onChange?: React.EventHandler<React.ChangeEvent>;
34
+ onKeyDown?: React.EventHandler<React.KeyboardEvent<HTMLInputElement>>;
35
+ passRef?: React.ClassAttributes<T>['ref'];
36
+ title?: string;
37
+ disabled?: boolean;
38
+ placeholder?: string;
39
+ }
40
+
41
+ export const MWInput: React.FC<InputProps<HTMLInputElement>> = ({ id, label, passRef, defaultValue, onChange, title, onKeyDown, disabled }) => (
42
+ <>
43
+ <MWLabel id={id} label={label} disabled={disabled} />
44
+ <input
45
+ tabIndex={0}
46
+ type='text'
47
+ ref={passRef}
48
+ id={id}
49
+ className='theia-input t-mv-input'
50
+ defaultValue={defaultValue}
51
+ onChange={onChange}
52
+ onKeyDown={onKeyDown}
53
+ title={title}
54
+ spellCheck={false}
55
+ disabled={disabled}
56
+ />
57
+ </>
58
+ );
59
+
60
+ export interface LabelAndSelectProps extends InputProps<HTMLSelectElement> {
61
+ options: string[];
62
+ }
63
+
64
+ export const MWSelect: React.FC<LabelAndSelectProps> = ({ id, label, options, passRef, onChange, title, value, disabled }) => (
65
+ <>
66
+ <MWLabel id={id} label={label} disabled={disabled} />
67
+ <select
68
+ tabIndex={0}
69
+ ref={passRef}
70
+ id={id}
71
+ className='theia-select t-mv-select'
72
+ value={value}
73
+ onChange={onChange}
74
+ title={title}
75
+ disabled={disabled}
76
+ >
77
+ {options.map(option => <option value={option} key={option}>{option}</option>)}
78
+ </select>
79
+ </>
80
+ );
81
+
82
+ export interface LabelAndSelectWithNameProps extends InputProps<HTMLSelectElement> {
83
+ options: Array<[string, string]>;
84
+ }
85
+
86
+ export const MWSelectWithName: React.FC<LabelAndSelectWithNameProps> = ({ id, label, options, passRef, onChange, title, value, disabled }) => (
87
+ <>
88
+ <MWLabel id={id} label={label} disabled={disabled} />
89
+ <select
90
+ tabIndex={0}
91
+ ref={passRef}
92
+ id={id}
93
+ className='theia-select'
94
+ value={value}
95
+ onChange={onChange}
96
+ title={title}
97
+ disabled={disabled}
98
+ >
99
+ {options.map(option => <option value={option[0]} key={option[0]}>{option[1]}</option>)}
100
+ </select>
101
+ </>
102
+ );
103
+
104
+ export interface InputWithSelectProps<T extends HTMLElement> extends InputProps<T> {
105
+ options: string[];
106
+ onSelectChange?(e: React.ChangeEvent): void;
107
+ onInputChange?(e: React.ChangeEvent<HTMLInputElement>): void;
108
+ }
109
+ export const MWInputWithSelect: React.FC<InputWithSelectProps<HTMLInputElement>> = (
110
+ { id, label, passRef, onKeyDown, title, options, onSelectChange, defaultValue, disabled, placeholder },
111
+ ) => (
112
+ <>
113
+ <MWLabel id={id} label={label} disabled={disabled} />
114
+ <div className='mw-input-select'>
115
+ <input
116
+ tabIndex={0}
117
+ type='text'
118
+ ref={passRef}
119
+ id={id}
120
+ className='theia-input t-mv-input'
121
+ defaultValue={defaultValue}
122
+ onKeyDown={onKeyDown}
123
+ title={title}
124
+ spellCheck={false}
125
+ disabled={disabled}
126
+ placeholder={placeholder}
127
+ />
128
+ <select
129
+ className='theia-select t-mv-select'
130
+ onChange={onSelectChange}
131
+ disabled={disabled || (options.length === 0)}
132
+ >
133
+ {options.reverse().map(option => <option key={`'mw-input-select'-${id}-${option}`} value={option}>{option}</option>)}
134
+ </select>
135
+ </div>
136
+ </>
137
+ );
138
+
139
+ export interface MoreMemoryProps {
140
+ options: number[];
141
+ direction: 'above' | 'below';
142
+ handler(opts: Interfaces.MoreMemoryOptions): void;
143
+ }
144
+
145
+ export const MWMoreMemorySelect: React.FC<MoreMemoryProps> = ({ options, handler, direction }) => {
146
+ const [numBytes, setNumBytes] = React.useState<number>(options[0]);
147
+ const containerRef = React.createRef<HTMLDivElement>();
148
+ const onSelectChange = (e: React.ChangeEvent<HTMLSelectElement>): void => {
149
+ e.stopPropagation();
150
+ const { value } = e.currentTarget;
151
+ setNumBytes(parseInt(value));
152
+ };
153
+
154
+ const loadMoreMemory = (e: React.MouseEvent | React.KeyboardEvent): void => {
155
+ containerRef.current?.blur();
156
+ const doHandle = !('key' in e) || KeyCode.createKeyCode(e.nativeEvent).key?.keyCode === Key.ENTER.keyCode;
157
+ if (doHandle) {
158
+ handler({
159
+ numBytes,
160
+ direction,
161
+ });
162
+ }
163
+ };
164
+
165
+ return (
166
+ <div
167
+ className='mw-more-memory-select'
168
+ tabIndex={0}
169
+ role='button'
170
+ onClick={loadMoreMemory}
171
+ onKeyDown={loadMoreMemory}
172
+ ref={containerRef}
173
+ >
174
+ <div className='mw-more-memory-select-top no-select'>
175
+ Load
176
+ <select
177
+ className='theia-select'
178
+ onChange={onSelectChange}
179
+ tabIndex={0}
180
+ >
181
+ {options.map(option => (
182
+ <option
183
+ key={`mw-more-memory-select-${option}`}
184
+ value={option}
185
+ >
186
+ {option}
187
+ </option>))}
188
+ </select>
189
+ {`more bytes ${direction}`}
190
+ </div>
191
+ </div>
192
+ );
193
+ };