Skip to content

Commit c8ec3ef

Browse files
committed
More clean-up in editorCommon
1 parent b3097df commit c8ec3ef

47 files changed

Lines changed: 1185 additions & 1245 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/vs/editor/browser/config/configuration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserve
1515
import { FastDomNode } from 'vs/base/browser/fastDomNode';
1616
import { CharWidthRequest, CharWidthRequestType, readCharWidths } from 'vs/editor/browser/config/charWidthReader';
1717
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
18+
import { IEditorOptions } from "vs/editor/common/config/editorOptions";
1819

1920
class CSSBasedConfigurationCache {
2021

@@ -308,7 +309,7 @@ export class Configuration extends CommonEditorConfiguration {
308309
domNode.setLineHeight(fontInfo.lineHeight);
309310
}
310311

311-
constructor(options: any, referenceDomElement: HTMLElement = null) {
312+
constructor(options: IEditorOptions, referenceDomElement: HTMLElement = null) {
312313
super(options, new ElementSizeObserver(referenceDomElement, () => this._onReferenceDomElementSizeChanged()));
313314

314315
this._register(CSSBasedConfiguration.INSTANCE.onDidChange(() => this._onCSSBasedConfigurationChanged()));

src/vs/editor/browser/controller/mouseHandler.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { StandardMouseWheelEvent } from 'vs/base/browser/mouseEvent';
2222
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
2323
import { IViewCursorRenderData } from 'vs/editor/browser/viewParts/viewCursors/viewCursor';
2424
import * as viewEvents from 'vs/editor/common/view/viewEvents';
25+
import { IViewWhitespaceViewportData } from "vs/editor/common/viewModel/viewModel";
2526

2627
/**
2728
* Merges mouse events when mouse move events are throttled
@@ -93,7 +94,7 @@ export interface IPointerHandlerHelper {
9394
isAfterLines(verticalOffset: number): boolean;
9495
getLineNumberAtVerticalOffset(verticalOffset: number): number;
9596
getVerticalOffsetForLineNumber(lineNumber: number): number;
96-
getWhitespaceAtVerticalOffset(verticalOffset: number): editorCommon.IViewWhitespaceViewportData;
97+
getWhitespaceAtVerticalOffset(verticalOffset: number): IViewWhitespaceViewportData;
9798

9899
/**
99100
* Get the last rendered information of the cursors.
@@ -274,12 +275,12 @@ export class MouseHandler extends ViewEventHandler implements IDisposable {
274275
public _onMouseDown(e: EditorMouseEvent): void {
275276
let t = this._createMouseTarget(e, true);
276277

277-
let targetIsContent = (t.type === editorCommon.MouseTargetType.CONTENT_TEXT || t.type === editorCommon.MouseTargetType.CONTENT_EMPTY);
278-
let targetIsGutter = (t.type === editorCommon.MouseTargetType.GUTTER_GLYPH_MARGIN || t.type === editorCommon.MouseTargetType.GUTTER_LINE_NUMBERS || t.type === editorCommon.MouseTargetType.GUTTER_LINE_DECORATIONS);
279-
let targetIsLineNumbers = (t.type === editorCommon.MouseTargetType.GUTTER_LINE_NUMBERS);
278+
let targetIsContent = (t.type === editorBrowser.MouseTargetType.CONTENT_TEXT || t.type === editorBrowser.MouseTargetType.CONTENT_EMPTY);
279+
let targetIsGutter = (t.type === editorBrowser.MouseTargetType.GUTTER_GLYPH_MARGIN || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_DECORATIONS);
280+
let targetIsLineNumbers = (t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS);
280281
let selectOnLineNumbers = this._context.configuration.editor.viewInfo.selectOnLineNumbers;
281-
let targetIsViewZone = (t.type === editorCommon.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorCommon.MouseTargetType.GUTTER_VIEW_ZONE);
282-
let targetIsWidget = (t.type === editorCommon.MouseTargetType.CONTENT_WIDGET);
282+
let targetIsViewZone = (t.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE);
283+
let targetIsWidget = (t.type === editorBrowser.MouseTargetType.CONTENT_WIDGET);
283284

284285
let shouldHandle = e.leftButton;
285286
if (platform.isMacintosh && e.ctrlKey) {
@@ -402,10 +403,10 @@ class MouseDownOperation extends Disposable {
402403
}
403404
}
404405

405-
public start(targetType: editorCommon.MouseTargetType, e: EditorMouseEvent): void {
406+
public start(targetType: editorBrowser.MouseTargetType, e: EditorMouseEvent): void {
406407
this._lastMouseEvent = e;
407408

408-
this._mouseState.setStartedOnLineNumbers(targetType === editorCommon.MouseTargetType.GUTTER_LINE_NUMBERS);
409+
this._mouseState.setStartedOnLineNumbers(targetType === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS);
409410
this._mouseState.setModifiers(e);
410411
let position = this._findMousePosition(e, true);
411412
if (!position) {
@@ -494,22 +495,22 @@ class MouseDownOperation extends Disposable {
494495

495496
if (e.posy < editorContent.y) {
496497
let aboveLineNumber = this._viewHelper.getLineNumberAtVerticalOffset(Math.max(this._viewHelper.getScrollTop() - (editorContent.y - e.posy), 0));
497-
return new MouseTarget(null, editorCommon.MouseTargetType.OUTSIDE_EDITOR, mouseColumn, new Position(aboveLineNumber, 1));
498+
return new MouseTarget(null, editorBrowser.MouseTargetType.OUTSIDE_EDITOR, mouseColumn, new Position(aboveLineNumber, 1));
498499
}
499500

500501
if (e.posy > editorContent.y + editorContent.height) {
501502
let belowLineNumber = this._viewHelper.getLineNumberAtVerticalOffset(this._viewHelper.getScrollTop() + (e.posy - editorContent.y));
502-
return new MouseTarget(null, editorCommon.MouseTargetType.OUTSIDE_EDITOR, mouseColumn, new Position(belowLineNumber, this._context.model.getLineMaxColumn(belowLineNumber)));
503+
return new MouseTarget(null, editorBrowser.MouseTargetType.OUTSIDE_EDITOR, mouseColumn, new Position(belowLineNumber, this._context.model.getLineMaxColumn(belowLineNumber)));
503504
}
504505

505506
let possibleLineNumber = this._viewHelper.getLineNumberAtVerticalOffset(this._viewHelper.getScrollTop() + (e.posy - editorContent.y));
506507

507508
if (e.posx < editorContent.x) {
508-
return new MouseTarget(null, editorCommon.MouseTargetType.OUTSIDE_EDITOR, mouseColumn, new Position(possibleLineNumber, 1));
509+
return new MouseTarget(null, editorBrowser.MouseTargetType.OUTSIDE_EDITOR, mouseColumn, new Position(possibleLineNumber, 1));
509510
}
510511

511512
if (e.posx > editorContent.x + editorContent.width) {
512-
return new MouseTarget(null, editorCommon.MouseTargetType.OUTSIDE_EDITOR, mouseColumn, new Position(possibleLineNumber, this._context.model.getLineMaxColumn(possibleLineNumber)));
513+
return new MouseTarget(null, editorBrowser.MouseTargetType.OUTSIDE_EDITOR, mouseColumn, new Position(possibleLineNumber, this._context.model.getLineMaxColumn(possibleLineNumber)));
513514
}
514515

515516
return null;
@@ -527,7 +528,7 @@ class MouseDownOperation extends Disposable {
527528
return null;
528529
}
529530

530-
if (t.type === editorCommon.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorCommon.MouseTargetType.GUTTER_VIEW_ZONE) {
531+
if (t.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE) {
531532
// Force position on view zones to go above or below depending on where selection started from
532533
let selectionStart = new Position(this._currentSelection.selectionStartLineNumber, this._currentSelection.selectionStartColumn);
533534
let viewZoneData = <editorBrowser.IViewZoneData>t.detail;

src/vs/editor/browser/controller/mouseTarget.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
import { Position } from 'vs/editor/common/core/position';
88
import { Range as EditorRange } from 'vs/editor/common/core/range';
9-
import { MouseTargetType } from 'vs/editor/common/editorCommon';
10-
import { ClassNames, IMouseTarget, IViewZoneData } from 'vs/editor/browser/editorBrowser';
9+
import { MouseTargetType, ClassNames, IMouseTarget, IViewZoneData } from 'vs/editor/browser/editorBrowser';
1110
import { ViewContext } from 'vs/editor/common/view/viewContext';
1211
import { IPointerHandlerHelper } from 'vs/editor/browser/controller/mouseHandler';
1312
import { EditorMouseEvent, PageCoordinates, ClientCoordinates, EditorPagePosition } from 'vs/editor/browser/editorDom';

src/vs/editor/browser/editorBrowser.ts

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import { Range, IRange } from 'vs/editor/common/core/range';
1414
import { FastDomNode } from 'vs/base/browser/fastDomNode';
1515
import { ViewOutgoingEvents } from 'vs/editor/browser/view/viewOutgoingEvents';
1616
import * as editorOptions from "vs/editor/common/config/editorOptions";
17+
import { OverviewRulerZone } from "vs/editor/common/view/overviewZoneManager";
1718

1819
/**
1920
* @internal
21+
* TODO@editorBrowser: MOVE
2022
*/
2123
export interface IContentWidgetData {
2224
widget: IContentWidget;
@@ -25,6 +27,7 @@ export interface IContentWidgetData {
2527

2628
/**
2729
* @internal
30+
* TODO@editorBrowser: MOVE
2831
*/
2932
export interface IOverlayWidgetData {
3033
widget: IOverlayWidget;
@@ -33,6 +36,7 @@ export interface IOverlayWidgetData {
3336

3437
/**
3538
* @internal
39+
* TODO@editorBrowser: MOVE
3640
*/
3741
export interface ICodeEditorHelper {
3842
getScrollWidth(): number;
@@ -53,6 +57,7 @@ export interface ICodeEditorHelper {
5357

5458
/**
5559
* @internal
60+
* TODO@editorBrowser: MOVE
5661
*/
5762
export interface IView extends IDisposable {
5863
domNode: FastDomNode<HTMLElement>;
@@ -85,6 +90,7 @@ export interface IView extends IDisposable {
8590

8691
/**
8792
* @internal
93+
* TODO@editorBrowser: MOVE
8894
*/
8995
export interface IViewZoneData {
9096
viewZoneId: number;
@@ -115,6 +121,7 @@ export interface IMouseDispatchData {
115121

116122
/**
117123
* @internal
124+
* TODO@editorBrowser: MOVE
118125
*/
119126
export interface IViewController {
120127
dispatchMouse(data: IMouseDispatchData);
@@ -141,6 +148,7 @@ export interface IViewController {
141148

142149
/**
143150
* @internal
151+
* TODO@editorBrowser: MOVE
144152
*/
145153
export const ClassNames = {
146154
TEXTAREA_COVER: 'textAreaCover',
@@ -164,6 +172,7 @@ export const ClassNames = {
164172

165173
/**
166174
* @internal
175+
* TODO@editorBrowser: MOVE
167176
*/
168177
export interface IViewportInfo {
169178
visibleRange: Range;
@@ -350,6 +359,68 @@ export interface IOverlayWidget {
350359
getPosition(): IOverlayWidgetPosition;
351360
}
352361

362+
/**
363+
* Type of hit element with the mouse in the editor.
364+
*/
365+
export enum MouseTargetType {
366+
/**
367+
* Mouse is on top of an unknown element.
368+
*/
369+
UNKNOWN,
370+
/**
371+
* Mouse is on top of the textarea used for input.
372+
*/
373+
TEXTAREA,
374+
/**
375+
* Mouse is on top of the glyph margin
376+
*/
377+
GUTTER_GLYPH_MARGIN,
378+
/**
379+
* Mouse is on top of the line numbers
380+
*/
381+
GUTTER_LINE_NUMBERS,
382+
/**
383+
* Mouse is on top of the line decorations
384+
*/
385+
GUTTER_LINE_DECORATIONS,
386+
/**
387+
* Mouse is on top of the whitespace left in the gutter by a view zone.
388+
*/
389+
GUTTER_VIEW_ZONE,
390+
/**
391+
* Mouse is on top of text in the content.
392+
*/
393+
CONTENT_TEXT,
394+
/**
395+
* Mouse is on top of empty space in the content (e.g. after line text or below last line)
396+
*/
397+
CONTENT_EMPTY,
398+
/**
399+
* Mouse is on top of a view zone in the content.
400+
*/
401+
CONTENT_VIEW_ZONE,
402+
/**
403+
* Mouse is on top of a content widget.
404+
*/
405+
CONTENT_WIDGET,
406+
/**
407+
* Mouse is on top of the decorations overview ruler.
408+
*/
409+
OVERVIEW_RULER,
410+
/**
411+
* Mouse is on top of a scrollbar.
412+
*/
413+
SCROLLBAR,
414+
/**
415+
* Mouse is on top of an overlay widget.
416+
*/
417+
OVERLAY_WIDGET,
418+
/**
419+
* Mouse is outside of the editor.
420+
*/
421+
OUTSIDE_EDITOR,
422+
}
423+
353424
/**
354425
* Target hit with the mouse in the editor.
355426
*/
@@ -361,7 +432,7 @@ export interface IMouseTarget {
361432
/**
362433
* The target type
363434
*/
364-
readonly type: editorCommon.MouseTargetType;
435+
readonly type: MouseTargetType;
365436
/**
366437
* The 'approximate' editor position
367438
*/
@@ -399,7 +470,7 @@ export type IEditorContributionCtor = IConstructorSignature1<ICodeEditor, editor
399470
export interface IOverviewRuler {
400471
getDomNode(): HTMLElement;
401472
dispose(): void;
402-
setZones(zones: editorCommon.OverviewRulerZone[]): void;
473+
setZones(zones: OverviewRulerZone[]): void;
403474
setLayout(position: editorOptions.OverviewRulerPosition): void;
404475
}
405476
/**

src/vs/editor/browser/standalone/standaloneCodeEditor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
1212
import { CommandsRegistry, ICommandService, ICommandHandler } from 'vs/platform/commands/common/commands';
1313
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
1414
import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
15-
import { IActionDescriptor, ICodeEditorWidgetCreationOptions, IModel, IModelChangedEvent } from 'vs/editor/common/editorCommon';
15+
import { IActionDescriptor, IModel, IModelChangedEvent } from 'vs/editor/common/editorCommon';
1616
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
1717
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
1818
import { StandaloneKeybindingService } from 'vs/editor/browser/standalone/simpleServices';
@@ -29,7 +29,11 @@ import { IThemeService } from "vs/platform/theme/common/themeService";
2929
/**
3030
* The options to create an editor.
3131
*/
32-
export interface IEditorConstructionOptions extends ICodeEditorWidgetCreationOptions {
32+
export interface IEditorConstructionOptions extends IEditorOptions {
33+
/**
34+
* The initial model associated with this code editor.
35+
*/
36+
model?: IModel;
3337
/**
3438
* The initial value of the auto created model in the editor.
3539
* To not create automatically a model, use `model: null`.

src/vs/editor/browser/standalone/standaloneEditor.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import 'vs/css!./media/standalone-tokens';
88
import * as editorCommon from 'vs/editor/common/editorCommon';
9-
import { ICodeEditor, ContentWidgetPositionPreference, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
9+
import { ICodeEditor, ContentWidgetPositionPreference, OverlayWidgetPositionPreference, MouseTargetType } from 'vs/editor/browser/editorBrowser';
1010
import { StandaloneEditor, IStandaloneCodeEditor, StandaloneDiffEditor, IStandaloneDiffEditor, IEditorConstructionOptions, IDiffEditorConstructionOptions } from 'vs/editor/browser/standalone/standaloneCodeEditor';
1111
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
1212
import { IEditorOverrideServices, DynamicStandaloneServices, StaticServices } from 'vs/editor/browser/standalone/standaloneServices';
@@ -345,7 +345,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
345345
EndOfLineSequence: editorCommon.EndOfLineSequence,
346346
TrackedRangeStickiness: editorCommon.TrackedRangeStickiness,
347347
CursorChangeReason: editorCommon.CursorChangeReason,
348-
MouseTargetType: editorCommon.MouseTargetType,
348+
MouseTargetType: MouseTargetType,
349349
TextEditorCursorStyle: editorOptions.TextEditorCursorStyle,
350350
TextEditorCursorBlinkingStyle: editorOptions.TextEditorCursorBlinkingStyle,
351351
ContentWidgetPositionPreference: ContentWidgetPositionPreference,
@@ -368,11 +368,6 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
368368

369369
// vars
370370
EditorType: editorCommon.EditorType,
371-
CursorMoveByUnit: editorCommon.CursorMoveByUnit,
372-
CursorMovePosition: editorCommon.CursorMovePosition,
373-
EditorScrollDirection: editorCommon.EditorScrollDirection,
374-
EditorScrollByUnit: editorCommon.EditorScrollByUnit,
375-
RevealLineAtArgument: editorCommon.RevealLineAtArgument,
376371
Handler: editorCommon.Handler,
377372
};
378373
}

src/vs/editor/browser/view/viewImpl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'
5050
import { EditorScrollbar } from 'vs/editor/browser/viewParts/editorScrollbar/editorScrollbar';
5151
import { Minimap } from 'vs/editor/browser/viewParts/minimap/minimap';
5252
import * as viewEvents from 'vs/editor/common/view/viewEvents';
53+
import { CursorMovePosition } from "vs/editor/common/controller/oneCursor";
5354

5455
export class View extends ViewEventHandler implements editorBrowser.IView, IDisposable {
5556

@@ -524,7 +525,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
524525
return e.revealCursor ? this.revealCursor() : false;
525526
}
526527
private revealCursor(): boolean {
527-
this.triggerCursorHandler('revealCursor', editorCommon.Handler.CursorMove, { to: editorCommon.CursorMovePosition.ViewPortIfOutside });
528+
this.triggerCursorHandler('revealCursor', editorCommon.Handler.CursorMove, { to: CursorMovePosition.ViewPortIfOutside });
528529
return false;
529530
}
530531

src/vs/editor/browser/view/viewOutgoingEvents.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
99
import { Position } from 'vs/editor/common/core/position';
1010
import { Range } from 'vs/editor/common/core/range';
1111
import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
12-
import { IScrollEvent, MouseTargetType } from 'vs/editor/common/editorCommon';
13-
import { IEditorMouseEvent, IMouseTarget } from 'vs/editor/browser/editorBrowser';
12+
import { IScrollEvent } from 'vs/editor/common/editorCommon';
13+
import { IEditorMouseEvent, IMouseTarget, MouseTargetType } from 'vs/editor/browser/editorBrowser';
1414
import { MouseTarget } from 'vs/editor/browser/controller/mouseTarget';
1515
import * as viewEvents from 'vs/editor/common/view/viewEvents';
1616
import Event, { Emitter } from 'vs/base/common/event';

0 commit comments

Comments
 (0)