Moving towards a "custom" parser for NextReg 0xF0
This commit is contained in:
@@ -12,13 +12,14 @@ interface RegisterBrowserProps {
|
||||
/**
|
||||
* Renders the access details for a register, including its description, operations, and notes.
|
||||
* @param access The register access data to render.
|
||||
* @param extraNotes Non access footnotes to include in the tooltip.
|
||||
* @returns A React component that displays the register access details.
|
||||
*/
|
||||
export function renderAccess(access: RegisterAccess) {
|
||||
export function renderAccess(access: RegisterAccess, extraNotes: Note[] = []) {
|
||||
const renderTooltip = (notes: Note[]) => (
|
||||
<Tooltip id="tooltip">
|
||||
{notes.map((note, index) => (
|
||||
<div key={index}>{note.text}</div>
|
||||
<div key={index}><code>{note.ref}</code> {note.text}</div>
|
||||
))}
|
||||
</Tooltip>
|
||||
);
|
||||
@@ -36,7 +37,11 @@ export function renderAccess(access: RegisterAccess) {
|
||||
</thead>
|
||||
<tbody>
|
||||
{access.operations.map((op, index) => {
|
||||
const notes = access.notes.filter(note => note.ref === op.footnoteRef);
|
||||
const access_notes = access.notes.filter(note => note.ref === op.footnoteRef);
|
||||
const extra_notes = extraNotes.filter(note => note.ref === op.footnoteRef);
|
||||
|
||||
const notes = [...access_notes, ...extra_notes].filter(note => note.text.length > 0);
|
||||
|
||||
return (
|
||||
<tr key={index}>
|
||||
<td>{op.bits}</td>
|
||||
@@ -44,7 +49,7 @@ export function renderAccess(access: RegisterAccess) {
|
||||
{op.description}
|
||||
{op.footnoteRef && notes.length > 0 && (
|
||||
<OverlayTrigger placement="top" overlay={renderTooltip(notes)}>
|
||||
<span className="footnote-ref">{op.footnoteRef}</span>
|
||||
<span className="footnote-ref">{op.footnoteRef}</span>
|
||||
</OverlayTrigger>
|
||||
)}
|
||||
</td>
|
||||
|
||||
@@ -19,6 +19,8 @@ export default function RegisterDetail({
|
||||
}) {
|
||||
const [showSource, setShowSource] = useState(false);
|
||||
|
||||
console.log("RENDERING: ", register.name, "FROM", register);
|
||||
|
||||
return (
|
||||
<Col key={register.hex_address} xs={12} className="mb-4">
|
||||
<Card>
|
||||
@@ -41,26 +43,34 @@ export default function RegisterDetail({
|
||||
</Card.Header>
|
||||
<Card.Body>
|
||||
{ register.modes.map((mode, idx) => (
|
||||
<div key={idx} className={idx > 0 ? 'mt-4' : ''}>
|
||||
{register.modes.length > 1 && (
|
||||
<h5 className="mb-3">Mode {idx + 1}</h5>
|
||||
)}
|
||||
<Tabs id={`register-tabs-${register.hex_address}-${idx}`}>
|
||||
{mode.common && <Tab eventKey="common" title="Read/Write">{renderAccess(mode.common)}</Tab>}
|
||||
{mode.read && <Tab eventKey="read" title="Read">{renderAccess(mode.read)}</Tab>}
|
||||
{mode.write && <Tab eventKey="write" title="Write">{renderAccess(mode.write)}</Tab>}
|
||||
</Tabs>
|
||||
{mode.notes && mode.notes.map((note, index) => (
|
||||
<p key={index} className="small text-muted">{note.ref} {note.text}</p>
|
||||
))}
|
||||
{mode.text && mode.text.length > 0 && (
|
||||
<div className="mt-3">
|
||||
<h6>Notes:</h6>
|
||||
<pre>{mode.text}</pre>
|
||||
<div key={idx} className={idx > 0 ? 'mt-4' : ''}>
|
||||
<div>
|
||||
{mode.modeName?.length && (
|
||||
<h5 className="mb-3">{mode.modeName}</h5>
|
||||
)}
|
||||
<Tabs id={`register-tabs-${register.hex_address}-${idx}`}>
|
||||
{mode.common && <Tab eventKey="common" title="Read/Write">{renderAccess(mode.common, register.notes)}</Tab>}
|
||||
{mode.read && <Tab eventKey="read" title="Read">{renderAccess(mode.read, register.notes)}</Tab>}
|
||||
{mode.write && <Tab eventKey="write" title="Write">{renderAccess(mode.write, register.notes)}</Tab>}
|
||||
</Tabs>
|
||||
</div>
|
||||
{mode.text && mode.text.length > 0 && (
|
||||
<div className="mt-3">
|
||||
<h6>Mode Notes:</h6>
|
||||
<pre>{mode.text}</pre>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
{register.notes && register.notes.map((note, index) => (
|
||||
<p key={index} className="small text-muted">{note.ref}: {note.text}</p>
|
||||
))}
|
||||
{register.text && register.text.length > 0 && (
|
||||
<div className="mt-3">
|
||||
<h6>Notes:</h6>
|
||||
<pre>{register.text}</pre>
|
||||
</div>
|
||||
)}
|
||||
</Card.Body>
|
||||
</Card>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Pulse 5.3.8
|
||||
// Bootswatch
|
||||
@use 'sass:color';
|
||||
|
||||
$theme: "pulse" !default;
|
||||
|
||||
@@ -86,7 +87,7 @@ $progress-bar-bg: $primary !default;
|
||||
|
||||
$list-group-bg: $gray-900 !default;
|
||||
$list-group-border-color: transparent !default;
|
||||
$list-group-hover-bg: lighten($list-group-bg, 10%) !default;
|
||||
$list-group-hover-bg: color.scale($list-group-bg, $lightness:10%) !default;
|
||||
$list-group-active-color: $white !default;
|
||||
$list-group-active-bg: $list-group-bg !default;
|
||||
$list-group-disabled-color: lighten($list-group-bg, 30%) !default;
|
||||
$list-group-disabled-color: color.scale($list-group-bg, $lightness:30%) !default;
|
||||
|
||||
@@ -11,10 +11,10 @@ let registers: Register[] = [];
|
||||
* @returns A promise that resolves to an array of Register objects.
|
||||
*/
|
||||
export async function getRegisters(): Promise<Register[]> {
|
||||
if (registers.length === 0) {
|
||||
// if (registers.length === 0) {
|
||||
const filePath = path.join(process.cwd(), 'data', 'nextreg.txt');
|
||||
const fileContent = await fs.readFile(filePath, 'utf8');
|
||||
registers = await parseNextReg(fileContent);
|
||||
}
|
||||
// }
|
||||
return registers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user