-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Support for column/box selection #1538
Conversation
The final test in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the first round of comments. Also I fixed the build as a file changed folders in the merge. There are a bunch of failing tests in Terminal.test.ts
now
typings/xterm.d.ts
Outdated
@@ -562,7 +571,7 @@ declare module 'xterm' { | |||
* Retrieves an option's value from the terminal. | |||
* @param key The option key. | |||
*/ | |||
getOption(key: 'colors'): string[]; | |||
getOption(key: 'columnSelectModifiers' | 'colors'): string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed
src/SelectionManager.ts
Outdated
protected _activeSelectionMode: SelectionMode; | ||
|
||
/** | ||
* The modifier keys required to trigger block select mode with left click + drag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block -> column
src/SelectionManager.ts
Outdated
} | ||
|
||
/** | ||
* Begin a block selection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block -> column
src/SelectionManager.ts
Outdated
} | ||
|
||
/** | ||
* Checks if all required key modifiers are pressed in order to enable block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block -> column
src/xterm.css
Outdated
@@ -139,6 +139,11 @@ | |||
cursor: pointer; | |||
} | |||
|
|||
.xterm.xterm-cursor-crosshair { | |||
/* Block selection mode */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block -> column
src/SelectionManager.ts
Outdated
|
||
if (this._activeSelectionMode === SelectionMode.COLUMN) { | ||
// Ignore zero width selections | ||
if (start[0] !== end[0]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can exit early here and return ''
src/SelectionManager.ts
Outdated
@@ -254,7 +272,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager | |||
*/ | |||
private _refresh(): void { | |||
this._refreshAnimationFrame = null; | |||
this.emit('refresh', { start: this._model.finalSelectionStart, end: this._model.finalSelectionEnd }); | |||
this.emit('refresh', { start: this._model.finalSelectionStart, end: this._model.finalSelectionEnd, columnSelectMode: this._activeSelectionMode === SelectionMode.COLUMN }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's break this into a separate line for each property now since it's getting a bit long.
src/SelectionManager.ts
Outdated
* select mode | ||
* @param event the mouse click event | ||
*/ | ||
public isColumnSelectMode(event: KeyboardEvent | MouseEvent): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be simplified by following the pattern of shouldForceSelection
and not adding the code that enables customization. That will also let us get rid of <any>
.
Also let's include macOptionClickForcesSelection
in the condition just to make our intent explicit.
I fixed the emoji test, it was just using the wrong test helper; |
@Tyriar Updated :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Made some minor polish tweaks and created #1541 to follow up after this. Will merge when CI passes 🎉
closes #1300