提交 cab36275 编写于 作者: A Alexandru Dima

Merge pull request #961 from edm-opensource/master

Implementation of issue #950
...@@ -168,6 +168,7 @@ registerCoreCommand(H.CursorDownSelect, { ...@@ -168,6 +168,7 @@ registerCoreCommand(H.CursorDownSelect, {
mac: { primary: KeyMod.Shift | KeyCode.DownArrow }, mac: { primary: KeyMod.Shift | KeyCode.DownArrow },
linux: { primary: KeyMod.Shift | KeyCode.DownArrow } linux: { primary: KeyMod.Shift | KeyCode.DownArrow }
}); });
registerCoreCommand(H.CursorPageUp, { registerCoreCommand(H.CursorPageUp, {
primary: KeyCode.PageUp primary: KeyCode.PageUp
}); });
...@@ -196,6 +197,10 @@ registerCoreCommand(H.CursorEndSelect, { ...@@ -196,6 +197,10 @@ registerCoreCommand(H.CursorEndSelect, {
primary: KeyMod.Shift | KeyCode.End, primary: KeyMod.Shift | KeyCode.End,
mac: { primary: KeyMod.Shift | KeyCode.End, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow] } mac: { primary: KeyMod.Shift | KeyCode.End, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow] }
}); });
registerCoreCommand(H.ExpandLineSelection, {
primary: KeyMod.CtrlCmd | KeyCode.KEY_I,
mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_I}
});
registerCoreCommand(H.Tab, { registerCoreCommand(H.Tab, {
primary: KeyCode.Tab primary: KeyCode.Tab
......
...@@ -966,6 +966,8 @@ export class Cursor extends EventEmitter { ...@@ -966,6 +966,8 @@ export class Cursor extends EventEmitter {
handlersMap[H.DeleteAllRight] = (ctx:IMultipleCursorOperationContext) => this._deleteAllRight(ctx); handlersMap[H.DeleteAllRight] = (ctx:IMultipleCursorOperationContext) => this._deleteAllRight(ctx);
handlersMap[H.Cut] = (ctx:IMultipleCursorOperationContext) => this._cut(ctx); handlersMap[H.Cut] = (ctx:IMultipleCursorOperationContext) => this._cut(ctx);
handlersMap[H.ExpandLineSelection] = (ctx:IMultipleCursorOperationContext) => this._expandLineSelection(ctx);
handlersMap[H.Undo] = (ctx:IMultipleCursorOperationContext) => this._undo(ctx); handlersMap[H.Undo] = (ctx:IMultipleCursorOperationContext) => this._undo(ctx);
handlersMap[H.CursorUndo] = (ctx:IMultipleCursorOperationContext) => this._cursorUndo(ctx); handlersMap[H.CursorUndo] = (ctx:IMultipleCursorOperationContext) => this._cursorUndo(ctx);
handlersMap[H.Redo] = (ctx:IMultipleCursorOperationContext) => this._redo(ctx); handlersMap[H.Redo] = (ctx:IMultipleCursorOperationContext) => this._redo(ctx);
...@@ -1187,6 +1189,10 @@ export class Cursor extends EventEmitter { ...@@ -1187,6 +1189,10 @@ export class Cursor extends EventEmitter {
return true; return true;
} }
private _expandLineSelection(ctx: IMultipleCursorOperationContext): boolean {
return this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => OneCursorOp.expandLineSelection(oneCursor, oneCtx));
}
private _lineInsertBefore(ctx: IMultipleCursorOperationContext): boolean { private _lineInsertBefore(ctx: IMultipleCursorOperationContext): boolean {
return this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => OneCursorOp.lineInsertBefore(oneCursor, oneCtx)); return this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => OneCursorOp.lineInsertBefore(oneCursor, oneCtx));
} }
......
...@@ -737,6 +737,21 @@ export class OneCursorOp { ...@@ -737,6 +737,21 @@ export class OneCursorOp {
return true; return true;
} }
public static expandLineSelection(cursor:OneCursor, ctx: IOneCursorOperationContext): boolean {
ctx.cursorPositionChangeReason = 'explicit';
var currentSelection = cursor.getSelection();
var lastColumn = cursor.getColumnAtEndOfViewLine(currentSelection.endLineNumber, currentSelection.endColumn);
var expandedSelection = new Selection(currentSelection.startLineNumber,1,currentSelection.endLineNumber,lastColumn);
if (currentSelection.equalsSelection(expandedSelection)){
lastColumn = cursor.getColumnAtEndOfViewLine(currentSelection.endLineNumber+1, currentSelection.endColumn+1);
expandedSelection = new Selection(currentSelection.startLineNumber,1,currentSelection.endLineNumber+1,lastColumn);
cursor.setSelection(expandedSelection);
} else {
cursor.setSelection(expandedSelection);
}
return true;
}
public static moveToBeginningOfBuffer(cursor:OneCursor, inSelectionMode: boolean, ctx: IOneCursorOperationContext): boolean { public static moveToBeginningOfBuffer(cursor:OneCursor, inSelectionMode: boolean, ctx: IOneCursorOperationContext): boolean {
ctx.cursorPositionChangeReason = 'explicit'; ctx.cursorPositionChangeReason = 'explicit';
cursor.moveModelPosition(inSelectionMode, 1, 1, 0, true); cursor.moveModelPosition(inSelectionMode, 1, 1, 0, true);
......
...@@ -3283,6 +3283,8 @@ export var Handler = { ...@@ -3283,6 +3283,8 @@ export var Handler = {
CursorEnd: 'cursorEnd', CursorEnd: 'cursorEnd',
CursorEndSelect: 'cursorEndSelect', CursorEndSelect: 'cursorEndSelect',
ExpandLineSelection: 'expandLineSelection',
CursorTop: 'cursorTop', CursorTop: 'cursorTop',
CursorTopSelect: 'cursorTopSelect', CursorTopSelect: 'cursorTopSelect',
CursorBottom: 'cursorBottom', CursorBottom: 'cursorBottom',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册