mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 11:10:48 +00:00
Work towards hover tooltips
This commit is contained in:
parent
1347d2a357
commit
7ae8cd13d1
7 changed files with 46 additions and 51 deletions
2
npm-shrinkwrap.json
generated
2
npm-shrinkwrap.json
generated
|
@ -432,7 +432,7 @@
|
|||
"xterm": {
|
||||
"version": "2.4.0",
|
||||
"from": "Tyriar/xterm.js#vscode-release/1.11",
|
||||
"resolved": "git+https://github.com/Tyriar/xterm.js.git#0704179005c64b5e359ab440eebb46f656146442"
|
||||
"resolved": "git+https://github.com/Tyriar/xterm.js.git#f9378fe3c635f4dfdee011a140ddb8cd744426eb"
|
||||
},
|
||||
"yauzl": {
|
||||
"version": "2.3.1",
|
||||
|
|
|
@ -85,14 +85,11 @@ class MessageWidget {
|
|||
this._domNode.style.bottom = `${_container.offsetHeight - _top}px`;
|
||||
this._domNode.classList.add('terminal-message-widget');
|
||||
|
||||
const message = document.createElement('div');
|
||||
message.classList.add('message');
|
||||
message.textContent = _text;
|
||||
this._domNode.appendChild(message);
|
||||
|
||||
const anchor = document.createElement('div');
|
||||
anchor.classList.add('anchor');
|
||||
this._domNode.appendChild(anchor);
|
||||
this._domNode.textContent = _text;
|
||||
// const message = document.createElement('div');
|
||||
// message.classList.add('message');
|
||||
// message.textContent = _text;
|
||||
// this._domNode.appendChild(message);
|
||||
|
||||
this._container.appendChild(this._domNode);
|
||||
this._domNode.classList.add('fadeIn');
|
||||
|
|
|
@ -180,7 +180,7 @@ export interface ITerminalInstance {
|
|||
* added to the DOM.
|
||||
* @return The ID of the new matcher, this can be used to deregister.
|
||||
*/
|
||||
registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number, validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void): number;
|
||||
registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number, validationCallback?: (uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => void): number;
|
||||
|
||||
/**
|
||||
* Deregisters a link matcher if it has been registered.
|
||||
|
|
|
@ -11,42 +11,20 @@
|
|||
pointer-events: none;
|
||||
}
|
||||
|
||||
.monaco-workbench .panel.integrated-terminal .terminal-message-widget {
|
||||
.monaco-workbench .terminal-message-widget {
|
||||
/* This font list is sourced from a .monaco-shell style */
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "HelveticaNeue-Light", "Ubuntu", "Droid Sans", sans-serif;
|
||||
font-size: 13px;
|
||||
padding-bottom: 8px;
|
||||
font-size: 14px;
|
||||
line-height: 19px;
|
||||
padding: 4px 5px;
|
||||
animation: fadein 100ms linear;
|
||||
background-color: #F3F3F3;
|
||||
border: 1px solid #CCC;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
.monaco-workbench .panel.integrated-terminal .terminal-message-widget.fadeIn {
|
||||
animation: fadeIn 150ms ease-out;
|
||||
}
|
||||
|
||||
@keyframes fadeOut {
|
||||
from { opacity: 1; }
|
||||
to { opacity: 0; }
|
||||
}
|
||||
.monaco-workbench .panel.integrated-terminal .terminal-message-widget.fadeOut {
|
||||
animation: fadeOut 100ms ease-out;
|
||||
}
|
||||
|
||||
.monaco-workbench .panel.integrated-terminal .terminal-message-widget .message {
|
||||
padding: 1px 4px;
|
||||
background: #1382CE;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.monaco-workbench .panel.integrated-terminal .terminal-message-widget .anchor {
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
border-color: transparent;
|
||||
border-style: solid;
|
||||
z-index: 1000;
|
||||
border-width: 8px;
|
||||
border-top-color: #1382CE;
|
||||
position: absolute;
|
||||
.vs-dark .monaco-workbench .terminal-message-widget {
|
||||
background-color: #2D2D30;
|
||||
border-color: #555;
|
||||
}
|
||||
.hc-black .monaco-workbench .terminal-message-widget {
|
||||
background-color: #0C141F;
|
||||
}
|
|
@ -283,7 +283,7 @@ export class TerminalInstance implements ITerminalInstance {
|
|||
this.updateConfig();
|
||||
}
|
||||
|
||||
public registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number, validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void): number {
|
||||
public registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number, validationCallback?: (uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => void): number {
|
||||
return this._linkHandler.registerCustomLinkHandler(regex, handler, matchIndex, validationCallback);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ const CUSTOM_LINK_PRIORITY = -1;
|
|||
const LOCAL_LINK_PRIORITY = -2;
|
||||
|
||||
export type XtermLinkMatcherHandler = (event: MouseEvent, uri: string) => boolean | void;
|
||||
export type XtermLinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void;
|
||||
export type XtermLinkMatcherValidationCallback = (uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => void;
|
||||
|
||||
export class TerminalLinkHandler {
|
||||
constructor(
|
||||
|
@ -42,7 +42,10 @@ export class TerminalLinkHandler {
|
|||
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
|
||||
@IWorkspaceContextService private _contextService: IWorkspaceContextService
|
||||
) {
|
||||
this._xterm.attachHypertextLinkHandler(this._wrapLinkHandler(() => true));
|
||||
this._xterm.setHypertextLinkHandler(this._wrapLinkHandler(() => true));
|
||||
this._xterm.setHypertextValidationCallback((uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => {
|
||||
this._validateWebLink(uri, element, callback);
|
||||
});
|
||||
}
|
||||
|
||||
public registerCustomLinkHandler(regex: RegExp, handler: (uri: string) => void, matchIndex?: number, validationCallback?: XtermLinkMatcherValidationCallback): number {
|
||||
|
@ -60,7 +63,7 @@ export class TerminalLinkHandler {
|
|||
});
|
||||
return this._xterm.registerLinkMatcher(this._localLinkRegex, wrappedHandler, {
|
||||
matchIndex: 1,
|
||||
validationCallback: (link: string, callback: (isValid: boolean) => void) => this._validateLocalLink(link, callback),
|
||||
validationCallback: (link: string, element: HTMLElement, callback: (isValid: boolean) => void) => this._validateLocalLink(link, element, callback),
|
||||
priority: LOCAL_LINK_PRIORITY
|
||||
});
|
||||
}
|
||||
|
@ -101,12 +104,29 @@ export class TerminalLinkHandler {
|
|||
});
|
||||
}
|
||||
|
||||
private _validateLocalLink(link: string, callback: (isValid: boolean) => void): void {
|
||||
private _validateLocalLink(link: string, element: HTMLElement, callback: (isValid: boolean) => void): void {
|
||||
this._resolvePath(link).then(resolvedLink => {
|
||||
if (resolvedLink) {
|
||||
this._addTooltipEventListeners(element);
|
||||
}
|
||||
callback(!!resolvedLink);
|
||||
});
|
||||
}
|
||||
|
||||
private _validateWebLink(link: string, element: HTMLElement, callback: (isValid: boolean) => void): void {
|
||||
this._addTooltipEventListeners(element);
|
||||
callback(true);
|
||||
}
|
||||
|
||||
private _addTooltipEventListeners(element: HTMLElement) {
|
||||
element.addEventListener('mouseenter', () => {
|
||||
console.log('enter');
|
||||
});
|
||||
element.addEventListener('mouseleave', () => {
|
||||
console.log('leave');
|
||||
});
|
||||
}
|
||||
|
||||
private _resolvePath(link: string): TPromise<string> {
|
||||
if (this._platform === platform.Platform.Windows) {
|
||||
// Resolve ~ -> %HOMEDRIVE%\%HOMEPATH%
|
||||
|
|
|
@ -16,7 +16,7 @@ class TestTerminalLinkHandler extends TerminalLinkHandler {
|
|||
}
|
||||
|
||||
class TestXterm {
|
||||
public attachHypertextLinkHandler() { }
|
||||
public setHypertextLinkHandler() { }
|
||||
}
|
||||
|
||||
suite('Workbench - TerminalLinkHandler', () => {
|
||||
|
|
Loading…
Reference in a new issue