Repository navigation
run_screen: opt-in mouse, reported chords and notices (0.8.1) - #28
Merged
Merged
Conversation
Screen gains default methods a view opts into: takes_mouse and mouse for clicks and the wheel, reports_chords for keys held with Shift, Alt or Ctrl told apart from the bare key, and take_notice for a bell and a desktop notification. run_screen asks the terminal for these only for a screen that wants them, takes them back while its screen is up, and takes events already queued before drawing again. Existing screens are unchanged. Also clears lints raised by the current clippy.
The mouse is asked for buttons and the wheel, not every move of the pointer, and every mouse event goes to the screen, which says whether it changed. Ticks keep time while events come, so a stream of them cannot keep a view from its background work. run_screen_with hands keys to a caller's function rather than handle_key, for a caller with key rules of its own. Notices go through notify, which drops control characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Screengains default methods that a view opts into. Existing screens keep compiling and behave as before.takes_mouse/mouse: the terminal is asked only for mouse buttons and the wheel (modes 1000 and 1006), not every movement of the pointer, and only when a screen takes the mouse, since capturing it stops text from being selected. Every mouse event goes tomouse, which returns whether the screen changed.reports_chords: asks the terminal (kitty keyboard protocol) to report keys held with Shift, Alt or Ctrl separately from the plain key, so Shift+Enter isn't mistaken for Enter.take_notice: rings the bell and sends a desktop notification (OSC 9, throughnotify, which strips control characters) once, for whoever is away.run_screen:tickon schedule even while events keep arriving, so a stream of them can't stall a view's background work.run_screen_with(screen, on_key)passes each key (except Ctrl-C) to the caller's function instead ofhandle_key, for a caller with its own key rules.Also fixes lints raised by the current clippy (needless borrows in format arguments,
sort_by_key, a match guard). Version 0.8.1.