Skip to content

Commit 09a4c6f

Browse files
committed
Extract the custom mouse cursor to vs/base to get it also in the standalone editor
1 parent 54aeb00 commit 09a4c6f

10 files changed

Lines changed: 40 additions & 20 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
.monaco-mouse-cursor-text {
7+
cursor: text;
8+
}
9+
10+
/* The following selector looks a bit funny, but that is needed to cover all the workbench and the editor!! */
11+
.vs-dark .mac .monaco-mouse-cursor-text, .hc-black .mac .monaco-mouse-cursor-text,
12+
.vs-dark.mac .monaco-mouse-cursor-text, .hc-black.mac .monaco-mouse-cursor-text {
13+
cursor: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAL0lEQVQoz2NgCD3x//9/BhBYBWdhgFVAiVW4JBFKGIa4AqD0//9D3pt4I4tAdAMAHTQ/j5Zom30AAAAASUVORK5CYII=') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAz0lEQVRIx2NgYGBY/R8I/vx5eelX3n82IJ9FxGf6tksvf/8FiTMQAcAGQMDvSwu09abffY8QYSAScNk45G198eX//yev73/4///701eh//kZSARckrNBRvz//+8+6ZohwCzjGNjdgQxkAg7B9WADeBjIBqtJCbhRA0YNoIkBSNmaPEMoNmA0FkYNoFKhapJ6FGyAH3nauaSmPfwI0v/3OukVi0CIZ+F25KrtYcx/CTIy0e+rC7R1Z4KMICVTQQ14feVXIbR695u14+Ir4gwAAD49E54wc1kWAAAAAElFTkSuQmCC') 2x) 5 8, text;
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import 'vs/css!./mouseCursor';
7+
8+
export const MOUSE_CURSOR_TEXT_CSS_CLASS_NAME = `monaco-mouse-cursor-text`;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
3030
import * as viewEvents from 'vs/editor/common/view/viewEvents';
3131
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
3232
import { IEditorAriaOptions } from 'vs/editor/browser/editorBrowser';
33+
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
3334

3435
export interface ITextAreaHandlerHelper {
3536
visibleRangeForPositionRelativeToEditor(lineNumber: number, column: number): HorizontalPosition | null;
@@ -117,7 +118,7 @@ export class TextAreaHandler extends ViewPart {
117118
// Text Area (The focus will always be in the textarea when the cursor is blinking)
118119
this.textArea = createFastDomNode(document.createElement('textarea'));
119120
PartFingerprints.write(this.textArea, PartFingerprint.TextArea);
120-
this.textArea.setClassName('inputarea mouse-text');
121+
this.textArea.setClassName(`inputarea ${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`);
121122
this.textArea.setAttribute('wrap', 'off');
122123
this.textArea.setAttribute('autocorrect', 'off');
123124
this.textArea.setAttribute('autocapitalize', 'off');
@@ -279,7 +280,7 @@ export class TextAreaHandler extends ViewPart {
279280
}
280281

281282
// Show the textarea
282-
this.textArea.setClassName('inputarea mouse-text ime-input');
283+
this.textArea.setClassName(`inputarea ${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME} ime-input`);
283284

284285
this._viewController.compositionStart('keyboard');
285286
}));
@@ -301,7 +302,7 @@ export class TextAreaHandler extends ViewPart {
301302
this._visibleTextArea = null;
302303
this._render();
303304

304-
this.textArea.setClassName('inputarea mouse-text');
305+
this.textArea.setClassName(`inputarea ${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`);
305306
this._viewController.compositionEnd('keyboard');
306307
}));
307308

src/vs/editor/browser/viewParts/lines/viewLines.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'
2222
import { Viewport } from 'vs/editor/common/viewModel/viewModel';
2323
import { EditorOption } from 'vs/editor/common/config/editorOptions';
2424
import { Constants } from 'vs/base/common/uint';
25+
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
2526

2627
class LastRenderedData {
2728

@@ -134,7 +135,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
134135
this._viewLineOptions = new ViewLineOptions(conf, this._context.theme.type);
135136

136137
PartFingerprints.write(this.domNode, PartFingerprint.ViewLines);
137-
this.domNode.setClassName('view-lines mouse-text');
138+
this.domNode.setClassName(`view-lines ${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`);
138139
Configuration.applyFontInfo(this.domNode, fontInfo);
139140

140141
// --- width & height

src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Range } from 'vs/editor/common/core/range';
1313
import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
1414
import { ViewContext } from 'vs/editor/common/view/viewContext';
1515
import * as viewEvents from 'vs/editor/common/view/viewEvents';
16+
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
1617

1718
export interface IViewCursorRenderData {
1819
domNode: HTMLElement;
@@ -63,7 +64,7 @@ export class ViewCursor {
6364

6465
// Create the dom node
6566
this._domNode = createFastDomNode(document.createElement('div'));
66-
this._domNode.setClassName('cursor mouse-text');
67+
this._domNode.setClassName(`cursor ${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`);
6768
this._domNode.setHeight(this._lineHeight);
6869
this._domNode.setTop(0);
6970
this._domNode.setLeft(0);
@@ -200,7 +201,7 @@ export class ViewCursor {
200201
this._domNode.domNode.textContent = this._lastRenderedContent;
201202
}
202203

203-
this._domNode.setClassName('cursor mouse-text ' + this._renderData.textContentClassName);
204+
this._domNode.setClassName(`cursor ${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME} ${this._renderData.textContentClassName}`);
204205

205206
this._domNode.setDisplay('block');
206207
this._domNode.setTop(this._renderData.top);

src/vs/editor/browser/widget/diffEditorWidget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
4949
import { IEditorProgressService, IProgressRunner } from 'vs/platform/progress/common/progress';
5050
import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver';
5151
import { Codicon, registerIcon } from 'vs/base/common/codicons';
52+
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
5253

5354
interface IEditorDiffDecorations {
5455
decorations: IModelDeltaDecoration[];
@@ -2095,7 +2096,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
20952096
maxCharsPerLine += this.modifiedEditorOptions.get(EditorOption.scrollBeyondLastColumn);
20962097

20972098
let domNode = document.createElement('div');
2098-
domNode.className = 'view-lines line-delete mouse-text';
2099+
domNode.className = `view-lines line-delete ${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`;
20992100
domNode.innerHTML = sb.build();
21002101
Configuration.applyFontInfoSlow(domNode, fontInfo);
21012102

src/vs/workbench/browser/media/style.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,6 @@ body.web {
175175
cursor: default;
176176
}
177177

178-
.monaco-workbench .mouse-text {
179-
cursor: text;
180-
}
181-
182-
.vs-dark .monaco-workbench.mac .mouse-text,
183-
.hc-black .monaco-editor.mac .mouse-text {
184-
cursor: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAL0lEQVQoz2NgCD3x//9/BhBYBWdhgFVAiVW4JBFKGIa4AqD0//9D3pt4I4tAdAMAHTQ/j5Zom30AAAAASUVORK5CYII=') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAz0lEQVRIx2NgYGBY/R8I/vx5eelX3n82IJ9FxGf6tksvf/8FiTMQAcAGQMDvSwu09abffY8QYSAScNk45G198eX//yev73/4///701eh//kZSARckrNBRvz//+8+6ZohwCzjGNjdgQxkAg7B9WADeBjIBqtJCbhRA0YNoIkBSNmaPEMoNmA0FkYNoFKhapJ6FGyAH3nauaSmPfwI0v/3OukVi0CIZ+F25KrtYcx/CTIy0e+rC7R1Z4KMICVTQQ14feVXIbR695u14+Ir4gwAAD49E54wc1kWAAAAAElFTkSuQmCC') 2x) 5 8, text;
185-
}
186-
187178
/* Custom Dropdown (select) Arrows */
188179

189180
.monaco-workbench select {

src/vs/workbench/contrib/comments/browser/commentNode.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { ContextAwareMenuEntryActionViewItem } from 'vs/platform/actions/browser
3333
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3434
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
3535
import { CommentFormActions } from 'vs/workbench/contrib/comments/browser/commentFormActions';
36+
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
3637

3738
export class CommentNode extends Disposable {
3839
private _domNode: HTMLElement;
@@ -100,7 +101,7 @@ export class CommentNode extends Disposable {
100101

101102
this.createHeader(this._commentDetailsContainer);
102103

103-
this._body = dom.append(this._commentDetailsContainer, dom.$('div.comment-body.mouse-text'));
104+
this._body = dom.append(this._commentDetailsContainer, dom.$(`div.comment-body.${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`));
104105
this._md = this.markdownRenderer.render(comment.body).element;
105106
this._body.appendChild(this._md);
106107

@@ -120,7 +121,7 @@ export class CommentNode extends Disposable {
120121
}
121122

122123
private createHeader(commentDetailsContainer: HTMLElement): void {
123-
const header = dom.append(commentDetailsContainer, dom.$('div.comment-title.mouse-text'));
124+
const header = dom.append(commentDetailsContainer, dom.$(`div.comment-title.${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`));
124125
const author = dom.append(header, dom.$('strong.author'));
125126
author.innerText = this.comment.userName;
126127

src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { EditorOption } from 'vs/editor/common/config/editorOptions';
4848
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
4949
import { KeyCode } from 'vs/base/common/keyCodes';
5050
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
51+
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
5152

5253
export const COMMENTEDITOR_DECORATION_KEY = 'commenteditordecoration';
5354
const COLLAPSE_ACTION_CLASS = 'expand-review-action codicon-chevron-up';
@@ -720,7 +721,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
720721
}
721722

722723
private createReplyButton() {
723-
this._reviewThreadReplyButton = <HTMLButtonElement>dom.append(this._commentForm, dom.$('button.review-thread-reply-button.mouse-text'));
724+
this._reviewThreadReplyButton = <HTMLButtonElement>dom.append(this._commentForm, dom.$(`button.review-thread-reply-button.${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`));
724725
this._reviewThreadReplyButton.title = this._commentOptions?.prompt || nls.localize('reply', "Reply...");
725726

726727
this._reviewThreadReplyButton.textContent = this._commentOptions?.prompt || nls.localize('reply', "Reply...");

src/vs/workbench/contrib/debug/browser/repl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
6060
import { ReplGroup } from 'vs/workbench/contrib/debug/common/replModel';
6161
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
6262
import { EDITOR_FONT_DEFAULTS, EditorOption } from 'vs/editor/common/config/editorOptions';
63+
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
6364

6465
const $ = dom.$;
6566

@@ -508,7 +509,7 @@ export class Repl extends ViewPane implements IHistoryNavigationWidget {
508509
super.renderBody(parent);
509510

510511
this.container = dom.append(parent, $('.repl'));
511-
const treeContainer = dom.append(this.container, $('.repl-tree.mouse-text'));
512+
const treeContainer = dom.append(this.container, $(`.repl-tree.${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`));
512513
this.createReplInput(this.container);
513514

514515
this.replDelegate = new ReplDelegate(this.configurationService);

0 commit comments

Comments
 (0)