Skip to content

Commit

Permalink
Merge pull request #57 from dls-controls/fix_bob_wordwrap
Browse files Browse the repository at this point in the history
Handle BOB file default word-wrap property
  • Loading branch information
rjwills28 authored Jun 10, 2024
2 parents c29ff72 + 6f8752a commit 3547c21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ui/widgets/EmbeddedDisplay/bobParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe("opi widget parser", (): void => {
<x>10</x>
<y>20</y>
<not_a_property>hello</not_a_property>
<wrap_words>false</wrap_words>
</widget>
</display>`;

Expand All @@ -56,6 +57,7 @@ describe("opi widget parser", (): void => {
expect(widget.foregroundColor).toEqual(Color.RED);
// Unrecognised property not passed on.
expect(widget.not_a_property).toEqual(undefined);
expect(widget.wrapWords).toEqual(false);
});

const readbackString = `
Expand Down Expand Up @@ -113,6 +115,7 @@ describe("opi widget parser", (): void => {
.children?.[0] as WidgetDescription;
expect(widget.precisionFromPv).toEqual(true);
expect(widget.showUnits).toEqual(true);
expect(widget.wrapWords).toEqual(true);
});

const readbackPrecisionUnits = `
Expand Down
5 changes: 5 additions & 0 deletions src/ui/widgets/EmbeddedDisplay/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ export function parseWidget(
if (widgetDescription.showUnits === undefined) {
widgetDescription.showUnits = true;
}
// Default to true if wrapWords is not defined.
// Applicable to BOB files.
if (widgetDescription.wrapWords === undefined) {
widgetDescription.wrapWords = true;
}

return widgetDescription;
}

0 comments on commit 3547c21

Please sign in to comment.