Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cursorless-talon/src/modifiers/scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"short paint": "boundedNonWhitespaceSequence",
"link": "url",
"cell": "notebookCell",
"visible": "visible",
Copy link
Member

Choose a reason for hiding this comment

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

visible is being added next to document in other places. The same should be done here for consistency.

}


Expand Down
1 change: 1 addition & 0 deletions docs/user/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ We have experimental support for prefixing a command with `"from <target>"` to n

- `"from funk take every instance air"`: selects all instances of the token with a hat over the letter `a` in the current function
- `"from air take next instance bat"`: selects the next instance of the token with a hat over the letter `b` starting from the token with a hat over the letter `a`
- `"from visible take every instance drum"`: selects all instances of the token with a hat over the letter `d` that are currently visible in the editor

Note that the `"from"` modifier is not enabled by default; you must remove the `-` at the start of the line starting with `-from` in your `experimental/experimental_actions.csv` [settings csv](./customization.md). Note also that this feature is considered experimental and may change in the future.

Expand Down
1 change: 1 addition & 0 deletions docs/user/experimental/keyboard/modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ To bind keys that do not have modifiers (eg just pressing `a`), add entries like
"ss": "boundedNonWhitespaceSequence",
"sa": "argumentOrParameter",
"sl": "url",
"vz": "visible",
Copy link
Member

Choose a reason for hiding this comment

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

The v key is already used for the curve shape below, so this will need to use a different key sequence.

},
"cursorless.experimental.keyboard.modal.keybindings.actions": {
"t": "setSelection",
Expand Down
10 changes: 10 additions & 0 deletions packages/cheatsheet/src/lib/sampleSpokenFormInfos/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,16 @@
}
]
},
{
"id": "visible",
"type": "scopeType",
"variations": [
{
"spokenForm": "visible",
"description": "Visible content in editor"
}
]
},
{
"id": "word",
"type": "scopeType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export type SimpleScopeTypeType =
| "nonWhitespaceSequence"
| "boundedNonWhitespaceSequence"
| "url"
| "notebookCell";
| "notebookCell"
| "visible";

export interface SimpleScopeType {
type: SimpleScopeTypeType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CharacterScopeHandler,
CustomRegexScopeHandler,
DocumentScopeHandler,
VisibleScopeHandler,
IdentifierScopeHandler,
LineScopeHandler,
NonWhitespaceSequenceScopeHandler,
Expand Down Expand Up @@ -60,6 +61,8 @@ export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory {
return new ParagraphScopeHandler(scopeType, languageId);
case "document":
return new DocumentScopeHandler(scopeType, languageId);
case "visible":
return new VisibleScopeHandler(scopeType, languageId);
case "oneOf":
return OneOfScopeHandler.create(this, scopeType, languageId);
case "nonWhitespaceSequence":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { TextEditor, Position } from "@cursorless/common";
import { Direction, ScopeType } from "@cursorless/common";
import { PlainTarget } from "../../targets";
import BaseScopeHandler from "./BaseScopeHandler";
import { TargetScope } from "./scope.types";

export default class VisibleScopeHandler extends BaseScopeHandler {
public readonly scopeType = { type: "visible" } as const;
public readonly iterationScopeType = { type: "document" } as const;
protected readonly isHierarchical = false;

constructor(_scopeType: ScopeType, _languageId: string) {
super();
}

protected *generateScopeCandidates(
editor: TextEditor,
_position: Position,
_direction: Direction,
): Iterable<TargetScope> {
yield {
editor,
domain: editor.document.range,
getTargets: (isReversed) =>
editor.visibleRanges.map(
(range) =>
new PlainTarget({
editor,
isReversed,
contentRange: range,
}),
),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export * from "./ParagraphScopeHandler";
export { default as ParagraphScopeHandler } from "./ParagraphScopeHandler";
export * from "./SentenceScopeHandler/SentenceScopeHandler";
export { default as SentenceScopeHandler } from "./SentenceScopeHandler/SentenceScopeHandler";
export { default as VisibleScopeHandler } from "./VisibleScopeHandler";
export * from "./RegexScopeHandler";
export * from "./ScopeHandlerFactory";
export * from "./ScopeHandlerFactoryImpl";
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
languageId: plaintext
command:
version: 6
spokenForm: change visible
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: visible}
usePrePhraseSnapshot: true
initialState:
documentContents: abc
selections:
- anchor: {line: 0, character: 3}
active: {line: 0, character: 3}
marks: {}
finalState:
documentContents: ""
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
1 change: 1 addition & 0 deletions packages/cursorless-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@
"notebookCell",
"paragraph",
"document",
"visible",
"character",
"word",
"boundedNonWhitespaceSequence",
Expand Down
1 change: 1 addition & 0 deletions schemas/cursorless-snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"notebookCell",
"paragraph",
"document",
"visible",
"character",
"word",
"nonWhitespaceSequence",
Expand Down