Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view titles #30

Closed
dcu opened this issue May 29, 2015 · 5 comments
Closed

view titles #30

dcu opened this issue May 29, 2015 · 5 comments
Assignees
Milestone

Comments

@dcu
Copy link

dcu commented May 29, 2015

hi,

is there a way to add a title to the view?
If not, that'd be nice to have, it can be in the same level as the frame like https://github.com/gizak/termui does.

The syntax could be something like this:

if v, err := g.SetView(...); err != nil {
    v.Title = "Title"
    v.TitleAlign = "left|right|center"
}
@jroimartin
Copy link
Owner

I'd prefer to keep views as simple as possible, think on them just as buffers. In the case of needing a title, I would add another view above just with the title (one line height, you can disable borders, etc.)

@jroimartin jroimartin added this to the GoCUI 0.3 milestone Feb 6, 2016
@jroimartin jroimartin self-assigned this Feb 6, 2016
@jroimartin jroimartin reopened this Feb 6, 2016
@jroimartin
Copy link
Owner

I've implemented this feature based on the PR #36 from @conejoninja. You can check it on branch view-title commit bb01d13. The main difference between my patch and the original PR is that I iterate over the title string, avoiding unnecessary iterations during the draw loop.

I've also added an example with all the test cases under _examples/title.go to test long titles, overlap between views, small views with title, etc.

Could you please check if it works as expected? :)

@jroimartin
Copy link
Owner

This is the output of _examples/title.go:

image

@jroimartin jroimartin added the wip label Feb 6, 2016
@conejoninja
Copy link

Looks good to me, no problems so far

@jroimartin
Copy link
Owner

Great. I've just merged it!

@jroimartin jroimartin removed the wip label Feb 7, 2016
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

No branches or pull requests

3 participants