From 4d8eafd6b25365f754b911a09d296aa0b4c2eb6d Mon Sep 17 00:00:00 2001 From: Martin Fleck Date: Tue, 30 Apr 2024 16:04:38 +0200 Subject: [PATCH] Avoid line break when editing a value while Auto Fit is enabled - Ensure that editing takes as much space as display - Use CSS to set styles on elements - Avoid large number of updates by guarding auto-fit group calculation Fixes #112 --- media/memory-table.css | 37 +++++++++++++++++++++++++ src/webview/columns/data-column.tsx | 19 +++---------- src/webview/components/memory-table.tsx | 6 +++- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/media/memory-table.css b/media/memory-table.css index 124340f..647b9cf 100644 --- a/media/memory-table.css +++ b/media/memory-table.css @@ -102,6 +102,8 @@ width: 2px; } +/* == Hover == */ + .hoverable:hover { border-bottom: 1px dotted var(--vscode-editorHoverWidget-border); } @@ -157,3 +159,38 @@ .memory-hover .variable-hover .value.type { color: var(--vscode-debugTokenExpression-name); } + +/* == Data Edit == */ + +.byte-group { + font-family: var(--vscode-editor-font-family); + margin-right: 2px; + padding: 0 1px; /* we use this padding to balance out the 2px that are needed for the editing */ +} + +.byte-group:last-child { + margin-right: 0px; +} + +.byte-group:has(> .data-edit) { + outline: 1px solid var(--vscode-inputOption-activeBorder); + outline-offset: 1px; + padding: 0px; /* editing takes two more pixels cause the input field will cut off the characters otherwise. */ +} + +.data-edit { + padding: 0; + outline: 0; + border: none; + text-indent: 1px; + min-height: unset; + height: 2ex; + background: unset; + margin: 0; +} + +.data-edit:enabled:focus { + outline: none; + border: none; + text-indent: 1px; +} diff --git a/src/webview/columns/data-column.tsx b/src/webview/columns/data-column.tsx index b84dc5e..25c3aab 100644 --- a/src/webview/columns/data-column.tsx +++ b/src/webview/columns/data-column.tsx @@ -70,9 +70,7 @@ export class EditableDataColumnRow extends React.Component= range.endAddress; - const style: React.CSSProperties | undefined = isLast ? undefined : DataColumn.Styles.byteGroupStyle; - groups.push(this.renderGroup(maus, groupStartAddress, next, style)); + groups.push(this.renderGroup(maus, groupStartAddress, next)); groupStartAddress = next; maus = []; } @@ -82,12 +80,11 @@ export class EditableDataColumnRow extends React.Component @@ -138,21 +135,16 @@ export class EditableDataColumnRow extends React.Component ({ ...prev, selection: null })); } - this.ensureGroupsPerRowToRenderIsSet(); + const hasDisplayChanged = prevProps.bytesPerMau !== this.props.bytesPerMau || prevProps.mausPerGroup !== this.props.mausPerGroup || + (prevProps.groupsPerRow !== 'Autofit' && this.props.groupsPerRow === 'Autofit'); + if (hasDisplayChanged) { + this.ensureGroupsPerRowToRenderIsSet(); + } if (this.props.memory !== undefined && this.props.scrollingBehavior === 'Auto-Append') { this.ensureSufficientVisibleRowsForScrollbar();