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

Add Screen.ChannelEvents v2 #465

Merged
merged 3 commits into from Jun 12, 2021
Merged

Add Screen.ChannelEvents v2 #465

merged 3 commits into from Jun 12, 2021

Conversation

@eNV25
Copy link
Contributor

@eNV25 eNV25 commented Jun 6, 2021

This PR proposes an alternative API for getting Events. Version 2. The following method is added:

type Screen interface {
	...
	// ChannelEvents is an infinite loop that waits for an event and
	// channels it into the user provided channel. When Fini() is called
	// or quit is closed, the function returns. This function should be
	// used as a goroutine.
	ChannelEvents(ch chan<- Event, quit <-chan struct{})
	...
}

Previous version: #461.

@codecov
Copy link

@codecov codecov bot commented Jun 6, 2021

Codecov Report

Merging #465 (6224fe8) into master (da8f206) will decrease coverage by 0.65%.
The diff coverage is 25.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #465      +/-   ##
==========================================
- Coverage   16.10%   15.44%   -0.66%     
==========================================
  Files          21       22       +1     
  Lines        1472     1580     +108     
==========================================
+ Hits          237      244       +7     
- Misses       1221     1322     +101     
  Partials       14       14              
Impacted Files Coverage Δ
screen.go 0.00% <ø> (ø)
tscreen.go 0.00% <0.00%> (ø)
simulation.go 53.84% <53.84%> (ø)
tty_unix.go 0.00% <0.00%> (ø)
nonblock_unix.go 0.00% <0.00%> (ø)
stdin_unix.go 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da8f206...6224fe8. Read the comment docs.

@eNV25
Copy link
Contributor Author

@eNV25 eNV25 commented Jun 6, 2021

I have simplified the implementation from before, and I have added tests too.

Now the only potential problem is what happens when you call PollEvent while ChannelEvents is running.

@gdamore
Copy link
Owner

@gdamore gdamore commented Jun 6, 2021

I wouldn't worry about that problem. We should just document that two are incompatible.

screen.go Outdated Show resolved Hide resolved
@eNV25
Copy link
Contributor Author

@eNV25 eNV25 commented Jun 11, 2021

I don't understand how just changing a doc comment reduces test coverage.
https://app.codecov.io/gh/gdamore/tcell/compare/465/commits

@gdamore gdamore merged commit b60a903 into gdamore:master Jun 12, 2021
2 of 3 checks passed
@gdamore
Copy link
Owner

@gdamore gdamore commented Jun 12, 2021

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants