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 tree helpers #12

Merged
merged 4 commits into from
Apr 4, 2021
Merged

Added tree helpers #12

merged 4 commits into from
Apr 4, 2021

Conversation

ivanmilov
Copy link
Contributor

As we discussed in #11
there are a few helpers to extend the tree API.
Please take a look, maybe it is OK with the current project philosophy.

Copy link
Member

@stapelberg stapelberg left a comment

Choose a reason for hiding this comment

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

Sorry for the late reply. I think these are okay overall, and thanks for adding tests, too!

tree_utils.go Outdated

import "strings"

func (n *Node) FindFocusedLeaf() *Node {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be easier to understand if we introduced only the func(n *Node) bool { return n.Focused } predicate. Can you do that and remove the FindFocusedLeaf function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean something like this?:

// implementation
package i3
func IsFocused(n *Node)  bool { 
    return n.Focused 
}

....

// usage
package main
var n Node
...
n = GetBlahBlahNode()
n.FindFocused(i3.IsFocused())

Copy link
Member

Choose a reason for hiding this comment

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

Yes, though now that I see it written out, it would merely be an accessor for the Focused field.

Maybe it would be better to not introduce this one after all. It’s just one line to write out, and fairly straight-forward.

Can you remove please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

tree_utils.go Show resolved Hide resolved
tree_utils.go Outdated
}

func (n *Node) IsFloating() bool {
if len(n.Floating) < 4 {
Copy link
Member

Choose a reason for hiding this comment

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

Is this conditional necessary? strings.HasSuffix should be safe to call regardless the length of the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@stapelberg stapelberg merged commit d0fbc26 into i3:master Apr 4, 2021
@ivanmilov ivanmilov deleted the milov/tree_utils branch April 4, 2021 17:37
@ivanmilov
Copy link
Contributor Author

Hi @stapelberg, thanks for approving :)
What is the next step to use this module? Importing 'go.i3wm.org/i3/v4' does not provide the latest changes

@stapelberg
Copy link
Member

It should: https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies

You can try explicitly specifying the @latest suffix.

Or you can try GOPROXY=direct to circumvent any possibly stale proxy servers.

@ivanmilov
Copy link
Contributor Author

ivanmilov commented Apr 4, 2021

Ok, this works

import "i3"

@ivanmilov
Copy link
Contributor Author

just to correct myself:

go get go.i3wm.org/i3/v4@master
import "go.i3wm.org/i3/v4"

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