Skip to content

Feat: add AddBlock method for adding block rows to Panels#630

Open
ccubed wants to merge 1 commit into
GoMudEngine:masterfrom
ccubed:AddBlock
Open

Feat: add AddBlock method for adding block rows to Panels#630
ccubed wants to merge 1 commit into
GoMudEngine:masterfrom
ccubed:AddBlock

Conversation

@ccubed

@ccubed ccubed commented Jun 16, 2026

Copy link
Copy Markdown

Description

This is my implementation of the requested Block rows in #624 for the panel system. This allows you to display a block of text without a label. This allows you to do something like this:

layout := templates.NewPanelLayout("open", "single", 1, 1)

slot := layout.AddSlot()
layout.AddPanelsToSlot(slot, "x")

layout.Panel("x").
   SetWidth(40).
   SetTitle(`<ansi fg="cyan">X</ansi>`).
   AddBlock(`Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since 1966, when designers at Letraset and James Mosley, the librarian at St Bride Printing Library in London, took a 1914 Cicero translation and scrambled it to make dummy text for Letraset's Body Type sheets.`, 80)

layout.Render()

And produce a panel that looks like this:

┌─ X ──────────────────────────────────┐
│ Lorem Ipsum is simply dummy text of  │
│ the printing and typesetting         │
│ industry. Lorem Ipsum has been the   │
│ industry's standard dummy text ever  │
│ since 1966, when designers at        │
│ Letraset and James Mosley, the       │
│ librarian at St Bride Printing       │
│ Library in London, took a 1914       │
│ Cicero translation and scrambled it  │
│ to make dummy text for Letraset's    │
│ Body Type sheets.                    │
└──────────────────────────────────────┘

Changes

Provide a bullet point list of noteworthy changes in this Pull Request:

  • Added Block boolean to PanelRow Struct
  • Added AddBlock function to add a Block Row
  • Added renderSingleBlockColumnLines function to render block content correctly
  • Modified panelInnerWidth to calculate block widths correctly
  • Modified renderCellContent to render block cells correctly
  • Modified renderSingleColumnLines to redirect Block Rows to a new function (It doesn't need to be a new function, but I thought it was eaiser to read this way)
  • Added a test case TestRenderPanel_BlockRow that ensures we render blocks correctly and within visible width constraints. It also ensures we ignore labels even if provided.

Small Note

This does not contain the fixes for #628 because I wanted to separate the new feature from the bug fix, but I've tested they can both be merged automatically.

@ccubed ccubed requested a review from Volte6 as a code owner June 16, 2026 16:48
@ccubed

ccubed commented Jun 16, 2026

Copy link
Copy Markdown
Author
image

Just wanted to show an example of it in action. This is it in use on my test instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant