Skip to content
This repository was archived by the owner on Jan 17, 2020. It is now read-only.
This repository was archived by the owner on Jan 17, 2020. It is now read-only.

Giving a maximum area for a Text #133

@Raveline

Description

@Raveline

Though text rendering is done through Pango, the current version of Helm doesn't allow us to leverage Pango line-wrapping abilities. Considering that linewrapping is typically not something one want to do manually, it looks like a good feature to add.

The ideal feature would be to set width and height, but current Pango bindings to not provide us with the setHeight function (I've just added an issue to the Gtk2hs repo that maintain Pango about this).

In the meantime, a possible fix is to:

  • Add an optional line width field (as a Maybe Double) to the Text datatype;
  • Add two calls on the SDL rendering engine for Text:
Pango.layoutSetWidth layout lineWidth
Pango.layoutSetWrap layout Pango.WrapWholeWords
  • This could be further improved by adding Pango alignment and justification features.

The beauty of it is that a call to setWidth with Nothing does... nothing, and wrapWholeWords has no effect without a set lineWidth.

I have a small proof of concept and would be happy to push a PR, but I'm troubled by two things:

  • I'm not sure how to mix the current available TextAlignment with this new system;
  • Other backends might now benefit from Pango and this would increase the workload of writing new backends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions