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

Support for column/box selection #1538

Merged
merged 8 commits into from
Jun 30, 2018
Merged

Conversation

vsinha
Copy link
Contributor

@vsinha vsinha commented Jun 28, 2018

closes #1300

@vsinha
Copy link
Contributor Author

vsinha commented Jun 28, 2018

The final test in SelectionManager.test.ts is failing, would love some guidance on how to set that up. I left a comment in there which explains that the behavior in browser actually works as intended, but the test does not reflect that

@Tyriar Tyriar self-assigned this Jun 29, 2018
Copy link
Member

@Tyriar Tyriar left a 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

@@ -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[];
Copy link
Member

Choose a reason for hiding this comment

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

This can be removed

protected _activeSelectionMode: SelectionMode;

/**
* The modifier keys required to trigger block select mode with left click + drag
Copy link
Member

Choose a reason for hiding this comment

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

block -> column

}

/**
* Begin a block selection
Copy link
Member

Choose a reason for hiding this comment

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

block -> column

}

/**
* Checks if all required key modifiers are pressed in order to enable block
Copy link
Member

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 */
Copy link
Member

Choose a reason for hiding this comment

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

block -> column


if (this._activeSelectionMode === SelectionMode.COLUMN) {
// Ignore zero width selections
if (start[0] !== end[0]) {
Copy link
Member

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 ''

@@ -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 });
Copy link
Member

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.

* select mode
* @param event the mouse click event
*/
public isColumnSelectMode(event: KeyboardEvent | MouseEvent): boolean {
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 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.

@Tyriar
Copy link
Member

Tyriar commented Jun 29, 2018

I fixed the emoji test, it was just using the wrong test helper; stringToRow iterates over the characters in the string (of which the emoji has 2), stringArrayToRow allows you to have characters where length > 1.

@vsinha
Copy link
Contributor Author

vsinha commented Jun 30, 2018

@Tyriar Updated :)

@Tyriar Tyriar added this to the 3.5.0 milestone Jun 30, 2018
Copy link
Member

@Tyriar Tyriar left a 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 🎉

@Tyriar Tyriar merged commit 38debf7 into xtermjs:master Jun 30, 2018
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.

Support for column/box selection
2 participants