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

Added support for titles in framed views #36

Closed
wants to merge 2 commits into from

Conversation

conejoninja
Copy link

This PR add a new attribute "Title" to the views, if it's set to a non-empty string and the view has Frame = true, then the title is shown on the top border (replacing the long dashes).

IT has a 2 spaces margin, and titles are shortened automatically to fit the space available.

Screenshot:

screenshot from 2016-02-02 16-03-07

Usage:

    if v, err := g.SetView("example", 2, 2, 30, 30); err != nil {
        if err != gocui.ErrUnknownView {
            return err
        }
        v.Frame = true
        v.Title = "This is a title"
        fmt.Fprintln(v, "Some content here ...")
    }

This commit add a new attribute "Title" to views, if the title is set to a non-empty value and the view is framed, then it's shown on the top frame with a 2 spaced margin.
Title is shortened to fit the space available
@jroimartin
Copy link
Owner

First of all, thanks for the contribution! :) Now, take into account that I plan to release v0.2 next Friday if no bug shows up, so, in case of merging the PR it would be for v0.3.

On the other hand, some time ago we discussed exactly about this very same feature (Issue #30) and my first thought was that we should keep views as simple as possible and handle title as views without frame, etc. However, I must admit that after seeing the screenshot, I'm seriously thinking about adding the feature :p Let me review the PR and we can consider merging it for v0.3.

@conejoninja
Copy link
Author

I totally understood. This was a quick hack I did on the train. Didn't test it much.

I first tried the two views approach, but it gets messy fast if you have a few views (because position/size), plus you need to act on two views instead of one when updating/deleting.

But titles could be more complicated (align, colors, margins, ...), so I understand you don't want to include them in gocui.

@dcu
Copy link

dcu commented Feb 6, 2016

nice!

@jroimartin jroimartin mentioned this pull request Feb 6, 2016
@jroimartin
Copy link
Owner

I've just added the feature. For more details, please, follow the discussion on issue #30.

@jroimartin jroimartin closed this Feb 6, 2016
cswank pushed a commit to cswank/gocui that referenced this pull request Oct 27, 2019
Pad syscall correctly in getTermWindowSize
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.

3 participants