Skip to content

Add BorderLabels to Border widget - #214

Merged
rockorager merged 6 commits into
rockorager:mainfrom
CosmicPredator:main
Jul 23, 2025
Merged

rockorager merged 6 commits into
rockorager:mainfrom
CosmicPredator:main

Conversation

@CosmicPredator

Copy link
Copy Markdown
Contributor

Added BorderLabels to Border Widget to show text inline along the borders. Currently, it has the following alignment options,

  • Top Left
  • Top Center
  • Top Right
  • Bottom Left
  • Bottom Center
  • Bottom Right

Here is a screenshot,
image

Example code snippet,

self.border.labels = &[_]vxfw.Border.BorderLabel {
    .{ .text = "TopLeft", .alignment = .TopLeft },
    .{ .text = "TopCenter", .alignment = .TopCenter },
    .{ .text = "TopRight", .alignment = .TopRight },
    .{ .text = "BottomLeft", .alignment = .BottomLeft },
    .{ .text = "BottomCenter", .alignment = .BottomCenter },
    .{ .text = "BottomRight", .alignment = .BottomRight },
};

@rockorager rockorager left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good feature to add. Approach is good but you just need to make sure you are working on graphemes vs bytes.

Comment thread src/vxfw/Border.zig Resolved
Comment thread src/vxfw/Border.zig Resolved
Comment thread src/vxfw/Border.zig Resolved
- used Grapheme Iterator instead of old range based loop.
- used `ctx.stringWidth()` instead of `text.len`.
- added empty label guard.
@CosmicPredator

Copy link
Copy Markdown
Contributor Author

@rockorager I have made the changes requested.
Btw, thanks for the helper snippets, really appreciate it 😃.

Comment thread src/vxfw/Border.zig Resolved

@rockorager rockorager left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One remaining issue on the loop.

@CosmicPredator

Copy link
Copy Markdown
Contributor Author

@rockorager Done. (I think I need to get a good grasp on grapheme iterator)

@CosmicPredator

Copy link
Copy Markdown
Contributor Author

@rockorager I have made requested changes. Is there anything needed to be done?

Comment thread src/vxfw/Border.zig Resolved
Comment thread src/vxfw/Border.zig Resolved
@rockorager

Copy link
Copy Markdown
Owner

One change and one nit left! I was going to ignore the nit but since there is another change to make I added it.

Thanks!

…ition.

- Changed from `.width=1` to `.width=width`
@CosmicPredator

Copy link
Copy Markdown
Contributor Author

@rockorager I have made the requested changes!

@CosmicPredator

Copy link
Copy Markdown
Contributor Author

@rockorager I think I need to intcast it

@rockorager

Copy link
Copy Markdown
Owner

@rockorager I think I need to intcast it

Yep!

@CosmicPredator

Copy link
Copy Markdown
Contributor Author

@rockorager Done! I ran tests in my local and verified!

@rockorager

Copy link
Copy Markdown
Owner

Can you run zig fmt to fix the check-fmt test?

@CosmicPredator

Copy link
Copy Markdown
Contributor Author

@rockorager Literally just 2 spaces lmao. Anyways, fixed it!

@rockorager
rockorager merged commit f8d4d03 into rockorager:main Jul 23, 2025
rockorager pushed a commit that referenced this pull request Sep 20, 2025
* vxfw(Border): add BorderLabels to Border widget

* - changed enum names to snake_case.
- used Grapheme Iterator instead of old range based loop.
- used `ctx.stringWidth()` instead of `text.len`.
- added empty label guard.

* modified loop to use stringWidth instead of i range

* - Added trailing comma at the end of BorderLabel alignment enum definition.
- Changed from `.width=1` to `.width=width`

* - Added @intcast for width

* fix zig fmt errors
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.

2 participants