Skip to content
Merged
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
28 changes: 27 additions & 1 deletion src/actions/ws_movement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,22 @@ export class WorkspaceMovement {
callback: (workspace) => this.moveWSCursor(workspace, 0, -1),
keyCodes: [createSerializedKey(KeyCodes.W, [KeyCodes.SHIFT])],
},

/** Move the cursor on the workspace down. */
{
name: Constants.SHORTCUT_NAMES.MOVE_WS_CURSOR_DOWN,
preconditionFn: (workspace) => this.canCurrentlyEdit(workspace),
callback: (workspace) => this.moveWSCursor(workspace, 0, 1),
keyCodes: [createSerializedKey(KeyCodes.S, [KeyCodes.SHIFT])],
},

/** Move the cursor to the workspace. */
{
name: Constants.SHORTCUT_NAMES.CREATE_WS_CURSOR,
preconditionFn: (workspace) => this.canCurrentlyEdit(workspace),
callback: (workspace) => this.createWSCursor(workspace),
keyCodes: [KeyCodes.W],
},
];

/**
Expand Down Expand Up @@ -114,4 +122,22 @@ export class WorkspaceMovement {
);
return true;
}

/**
* Moves the cursor to the workspace near the origin.
*
* @param workspace The workspace the cursor is on.
*/
createWSCursor(workspace: WorkspaceSvg) {
const workspaceNode = ASTNode.createWorkspaceNode(
workspace,
new BlocklyUtils.Coordinate(10, 10),
);
const cursor = workspace.getCursor();

if (!cursor || !workspaceNode) return false;

cursor.setCurNode(workspaceNode);
return true;
}
}
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export enum SHORTCUT_NAMES {
MOVE_WS_CURSOR_DOWN = 'workspace_down',
MOVE_WS_CURSOR_LEFT = 'workspace_left',
MOVE_WS_CURSOR_RIGHT = 'workspace_right',
CREATE_WS_CURSOR = 'to_workspace',
/* eslint-enable @typescript-eslint/naming-convention */
LIST_SHORTCUTS = 'list_shortcuts',
CLEAN_UP = 'clean_up_workspace',
Expand Down