-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
API mouse support #2336
Comments
It seems we will end up with a browser and a common part for mouse related stuff. While the browser part is yet to come the common part already took shape in #2323. In general I see two interesting use cases for public API regarding the mouse:
API Proposal: // mouse event types we offer
enum MouseEventType {
// no mouse events
NONE = 0,
// mousedown gets reported in viewport
DOWN = 1,
// mouseup gets reported in viewport
// + globally if DOWN is also registered
UP = 2,
// reports mousemove events if a button is held
DRAG = 4,
// reports mousemove if no button is held
MOVE = 8,
// any wheel events (up/down only)
WHEEL = 16
}
// for button and action we could either go with synthetized types
// or an enum (const enum would not work for pure JS)
interface IMouseEvent {
col: number;
row: number;
button: 'left' | 'middle' | ... ;
action: 'up' | 'down' | ... ;
}
// fired by the browser mouse service
onMouseEvent((e: IMouseEvent) => boolean): IDisposable;
// tell the browser mouse service to install needed listener
requestMouseEventType(type: MouseEventType): void;
// to create a mouse report to the pty
triggerMouseEvent(e: IMouseEvent): boolean; This kinda resembles what currently Example: A local REPL wants to catch simple button clicks within the terminal viewport. // request down events to be enabled
term.requestMouseEventType(MouseEventType.DOWN);
// register some click handler
term.onMouseEvent(e => console.log(`xy: [${e.col}, ${e.row}], button: ${e.button}`));
...
// when done reset listeners
term.requestMouseEventType(MouseEventType.NONE); Example: Some app at the pty registered some mouse protocol and waits for mouse input. // fake a click - sends automatically the correct report to the backend
term.triggerMouseEvent({col: 10, row: 5, button: 'left', action: 'down'}); Thats just a rough outline atm, questions like correct lifecycling and multiple handlers at once are not covered yet. |
I don't think we should go in this direction as it feels like we're just implementing puppeteer or something. Consumers can already built their own helpers for doing this provided they have the cell dimensions (which we should expose #702), this is the case for a regular renderer and a monaco-based one. |
There are several ideas floating around how mouse support in the API could be utilized - #2323 (comment) and #2323 (comment).
So lets discuss whether we want mouse primitives in the public API and how it could look like.
The text was updated successfully, but these errors were encountered: