Sprites.Media.Binary.Tool.Select

The binary editor's Select tool window: a readout of the marked range and its length, and a Clear button. It mirrors the map and text editors' Select windows, reusing the shared Sprites.Media.Sprite window parts, and owns its live rect. The tool selector and the Tools window live in Sprites.Media.Binary.Tool.

Sprites.Media.Binary.Tool.Select

Sprites.Media.Binary.Tool.Select.Window Void

Sprites.Media.Binary.Tool.Select.Window(visible, selStart, selEnd, clearSelection)

The Select window: a readout of the marked range and its length, and a Clear button. It is shown while the Select tool is active and has no close button. With no range marked it shows a hint to drag over the bytes.

InputTypeDescription
visibleValueThe show flag, true while the Select tool is active.
selStartValueThe range's first address, or undefined with no range.
selEndValueThe range's last address.
clearSelectionValueThe command the Clear button runs to drop the range.

Returns nothing.

const selStart = Sprites.Reactive.Value(16);
const selEnd = Sprites.Reactive.Value(31);
const clearSelection = Sprites.Reactive.Reverse(() => {
  Sprites.Reactive.Set(selStart, undefined);
});
Sprites.Ui.Content.Area(() => {
  const hasSelection = Sprites.Logic.Not(Sprites.Logic.Equals(selStart, undefined));
  Sprites.Reactive.If(hasSelection, () => {
    const lo = Sprites.Maths.Min(selStart, selEnd);
    const hi = Sprites.Maths.Max(selStart, selEnd);
    const span = Sprites.Maths.Subtract(hi, lo);
    const count = Sprites.Maths.Add(span, 1);
    const from = Sprites.Text.Hex(lo, Sprites.Media.Binary.AddressDigits);
    const to = Sprites.Text.Hex(hi, Sprites.Media.Binary.AddressDigits);
    Sprites.Ui.Dom.Tag('p', () => {
      Sprites.Ui.Dom.Class('binary-readout');
      Sprites.Ui.Dom.Text(from, ' to ', to, ' · ', count, ' bytes');
    });
  });
  Sprites.Reactive.Else(hasSelection, () => {
    Sprites.Ui.Content.Text('Drag over the bytes to mark a range.');
  });
  Sprites.Ui.Button.Group.Column(() => {
    Sprites.Ui.Button.Act(clearSelection, () => {
      Sprites.Ui.Button.Secondary();
      Sprites.Ui.Dom.Text('Clear');
    });
  });
});
The marked range and its length, with a Clear button.