Skip to content

Commit

Permalink
merging old search LUT w/ bitwise LUT
Browse files Browse the repository at this point in the history
  • Loading branch information
stricklandrbls committed Oct 16, 2023
1 parent 6243cb2 commit 56ad7d2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ limitations under the License.
searchResultsUpdated,
viewportByteIndicatorsLUT,
CATEGORY_ONE_MASK,
CATEGORY_TWO_MASK,
} from '../../../utilities/highlights'
import { bytesPerRow } from '../../../stores'
export let awaitViewportSeek: boolean
Expand Down Expand Up @@ -170,7 +171,7 @@ limitations under the License.
bytes: Array<ByteValue>
highlight: 'even' | 'odd'
}
enum ViewportScrollDirection {
DECREMENT = -1,
NONE = 0,
Expand All @@ -190,7 +191,6 @@ limitations under the License.
$: {
makingSelection =
$selectionDataStore.startOffset >= 0 && $selectionDataStore.active === false
console.log(`makingSelection: ${makingSelection} | Selection Data: {${$selectionDataStore.active},${$selectionDataStore.startOffset},${$selectionDataStore.originalEndOffset}, ${$selectionDataStore.endOffset}`)
}
onMount(() => {
viewportDataContainer = document.getElementById(
Expand Down Expand Up @@ -583,12 +583,11 @@ limitations under the License.
<DataValue
{byte}
id={'physical'}
categoryOneIndicator={$viewportByteIndicatorsLUT[byte.offset] &
CATEGORY_ONE_MASK}
radix={dataRadix}
indicators={{
cat1: $viewportByteIndicatorsLUT[byte.offset] & CATEGORY_ONE_MASK,
cat2: $viewportByteIndicatorsLUT[byte.offset] & CATEGORY_TWO_MASK }}
width={byteElementWidth}
disabled={byte.value === -1}
bind:selectionData={$selectionDataStore}
/>
{/each}
</div>
Expand All @@ -601,13 +600,12 @@ limitations under the License.
{#each viewportLine.bytes as byte}
<DataValue
{byte}
categoryOneIndicator={$viewportByteIndicatorsLUT[byte.offset] &
CATEGORY_ONE_MASK}
indicators={{
cat1: $viewportByteIndicatorsLUT[byte.offset] & CATEGORY_ONE_MASK,
cat2: $viewportByteIndicatorsLUT[byte.offset] & CATEGORY_TWO_MASK }}
id={'logical'}
radix={dataRadix}
width={byteElementWidth}
disabled={byte.value === -1}
bind:selectionData={$selectionDataStore}
/>
{/each}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,22 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<script lang="ts">
import { createEventDispatcher } from 'svelte'
import {
latin1Undefined,
type ByteSelectionEvent,
type ByteValue,
type ViewportDataType,
} from './BinaryData'
import type { SelectionData_t } from '../../../stores'
import type { ByteDivWidth } from '../../../utilities/display'
import type { RadixValues } from '../../../stores/configuration'
import { CategoryOneIndicators } from '../../../utilities/highlights'
import { CategoryOneIndicators, CategoryTwoIndicators } from '../../../utilities/highlights'
export let categoryOneIndicator: number
export let id: ViewportDataType
export let byte: ByteValue
export let selectionData: SelectionData_t
export let radix: RadixValues
export let disabled = false
export let width: ByteDivWidth = '20px'
export let isSelected = false
export let possibleSelection = false
export let isSearchResult = 0
const eventDispatcher = createEventDispatcher()
export let indicators: {
cat1: number,
cat2: number
}
</script>

Expand All @@ -48,7 +40,7 @@ limitations under the License.
{:else if id === 'physical'}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
class={'byte ' + CategoryOneIndicators[categoryOneIndicator]}
class={'byte ' + CategoryOneIndicators[indicators.cat1] + " " + CategoryTwoIndicators[indicators.cat2]}
id={id + '-' + byte.offset.toString()}
style:width
offset={byte.offset}
Expand All @@ -58,7 +50,7 @@ limitations under the License.
{:else}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
class={'byte ' + CategoryOneIndicators[categoryOneIndicator]}
class={'byte ' + CategoryOneIndicators[indicators.cat1] + " " + CategoryTwoIndicators[indicators.cat2]}
id={id + '-' + byte.offset.toString()}
style:width={'20px'}
class:latin1Undefined={latin1Undefined(byte.value)}
Expand All @@ -76,7 +68,6 @@ limitations under the License.
align-items: center;
flex-direction: row;
font-family: var(--monospace-font);
/* border-radius: 5px; */
border-style: solid;
border-width: 2px;
border-color: transparent;
Expand All @@ -94,11 +85,10 @@ limitations under the License.
color: var(--color-secondary-darkest);
}
div.byte.isSearchResult {
background-color: var(--color-tertiary-light);
color: var(--color-secondary-darkest);
border-color: var(--color-search-result);
}
div.byte.possibleSelection {
border-color: var(--color-secondary-light);
div.byte.isReplaceResult {
border-color: var(--color-replace-result);
}
div.byte:hover {
border-color: var(--color-secondary-mid);
Expand Down
2 changes: 2 additions & 0 deletions src/svelte/src/components/globalStyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ html {
--color-tertiary-dark: #5f816b;
--color-tertiary-darkest: #232f27;
--color-alternate-grey: #bbb5bd;
--color-search-result: #69a0a7;
--color-replace-result: #5f816b;
}

/* Global LEGEND Styles */
Expand Down
63 changes: 29 additions & 34 deletions src/svelte/src/utilities/highlights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,29 @@ import { derived, get, readable, readonly, writable } from 'svelte/store'
import { selectionDataStore } from '../stores'
import { VIEWPORT_CAPACITY_MAX } from '../stores/configuration'

let searchResultsHighlightLUT = new Uint8Array(1024).fill(0)
export const CATEGORY_ONE_MASK = 0x0f
export const CATEGORY_TWO_MASK = 0xf0

export enum IndicatorCategoryShift {
CategoryOne = 0,
CategoryTwo = 4,
}

export enum HightlightCategoryMasks {
enum CategoryOneIndications {
None = 0,
ActiveSelection = 1,
ConsideredForSelection = 2,
SearchResult = 4,
Selected = 1,
}
export const CategoryOneIndicators = ['', 'selected']
enum CategoryTwoIndications {
None = 0,
IsSearchResult = 1,
IsReplaceResult = 2,
}
export const CategoryTwoIndicators = ['', 'isSearchResult', 'isReplaceResult']

let searchResultsHighlightLUT = new Uint8Array(1024).fill(0)

let ViewportByteIndicatorsLUT = new Uint8Array(VIEWPORT_CAPACITY_MAX)

export const searchResultsHighlights = readable(searchResultsHighlightLUT)
export const searchResultsUpdated = writable(false)
Expand All @@ -42,44 +57,24 @@ export function updateSearchResultsHighlights(
criteriaEnd >= 0 ? criteriaEnd : data.length
)

searchResultsHighlightLUT.fill(0)
clearSearchResultsHighlights()

searchCriteria.forEach((offset) => {
for (let i = 0; i < byteWidth; i++)
searchResultsHighlightLUT[offset - viewportFileOffset + i] = 1
// searchResultsHighlightLUT[offset - viewportFileOffset + i] = 1
ViewportByteIndicatorsLUT[offset - viewportFileOffset + i] |=
CategoryTwoIndications.IsReplaceResult <<
IndicatorCategoryShift.CategoryTwo
})
searchResultsUpdated.set(true)
}
export function clearSearchResultsHighlights() {
searchResultsHighlightLUT.fill(0)
}

export const CATEGORY_ONE_MASK = 0x0f
export const CATEGORY_TWO_MASK = 0xf0
export enum IndicatorCategoryShift {
CategoryOne = 0,
CategoryTwo = 4,
}

enum CategoryOneIndications {
None = 0,
MakingSelection = 1,
Selected = 2,
}
export const CategoryOneIndicators = [
'cat1_none',
'possibleSelection',
'selected',
]

enum CategoryTwoIndications {
None = 0,
IsSearchResult = 1,
IsReplaceResult = 2,
ViewportByteIndicatorsLUT.forEach((byte) => {
byte = byte & ~CATEGORY_TWO_MASK
})
// searchResultsHighlightLUT.fill(0)
}

let ViewportByteIndicatorsLUT = new Uint8Array(VIEWPORT_CAPACITY_MAX)

export const viewportByteIndicatorsLUT = derived(
selectionDataStore,
($selectionData) => {
Expand Down

0 comments on commit 56ad7d2

Please sign in to comment.