You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sh...@apache.org on 2023/03/28 17:48:08 UTC

[daffodil-vscode] branch main updated: Data View offset displays in correct radix

This is an automated email from the ASF dual-hosted git repository.

shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git


The following commit(s) were added to refs/heads/main by this push:
     new 56352db  Data View offset displays in correct radix
56352db is described below

commit 56352dbfc231be1b58df9deb2bb956ad90e688fe
Author: Robert Strickland <st...@gmail.com>
AuthorDate: Mon Mar 27 10:27:29 2023 -0500

    Data View offset displays in correct radix
    
    - Created Svelte store convert data view offset display text to
      selected address display radix.
    
    Closes #530
---
 src/svelte/src/components/dataEditor.svelte |  5 +++--
 src/svelte/src/stores/index.ts              | 15 +++++++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/svelte/src/components/dataEditor.svelte b/src/svelte/src/components/dataEditor.svelte
index b04d693..f737548 100644
--- a/src/svelte/src/components/dataEditor.svelte
+++ b/src/svelte/src/components/dataEditor.svelte
@@ -77,6 +77,7 @@ limitations under the License.
     originalDataSegment,
     editedByteIsOriginalByte,
     selectionActive,
+    dataViewOffsetText,
   } from '../stores'
   import {
     radixOpt,
@@ -1249,7 +1250,7 @@ limitations under the License.
                 <label for="offset_dv"
                   >&nbsp;Offset: <text-field
                     id="offset_dv"
-                  />{$selectionStartOffset + $byteOffsetPos}</label
+                  />{$dataViewOffsetText}</label
                 >
                 <span id="b8_dv">
                   <br /><label for="int8_dv"
@@ -1348,7 +1349,7 @@ limitations under the License.
                 <label for="offset_dv"
                   >&nbsp;Offset: <text-field
                     id="offset_dv"
-                  />{$selectionStartOffset + $byteOffsetPos}</label
+                  />{$dataViewOffsetText}</label
                 >
                 <span id="b8_dv">
                   <br /><label for="int8_dv"
diff --git a/src/svelte/src/stores/index.ts b/src/svelte/src/stores/index.ts
index c7fb196..e3e2513 100644
--- a/src/svelte/src/stores/index.ts
+++ b/src/svelte/src/stores/index.ts
@@ -264,10 +264,6 @@ export const gotoable = derived(
   }
 )
 
-export const dataView = derived(editedDataSegment, ($selectedFileData) => {
-  return new DataView($selectedFileData.buffer)
-})
-
 export const byteOffsetPos = derived(
   [cursorPos, editorEncoding],
   ([$cursorPos, $editorEncoding]) => {
@@ -282,6 +278,17 @@ export const byteOffsetPos = derived(
   }
 )
 
+export const dataView = derived(editedDataSegment, ($selectedFileData) => {
+  return new DataView($selectedFileData.buffer)
+})
+
+export const dataViewOffsetText = derived(
+  [selectionStartOffset, byteOffsetPos, addressValue],
+  ([$selectionStartOffset, $byteOffsetPos, $addressValue]) => {
+    return ($selectionStartOffset + $byteOffsetPos).toString($addressValue)
+  }
+)
+
 export const dataViewLookAhead = derived(
   [editMode, dataView, byteOffsetPos, disableDataView],
   ([$editMode, $dataView, $byteOffsetPos]) => {