2 * Copyright (c) 2017 The xterm.js authors. All rights reserved.
6 import { IEvent } from 'common/EventEmitter';
7 import { IDisposable } from 'common/Types';
9 export interface IColorManager {
13 export interface IColor {
15 rgba: number; // 32-bit int with rgba in each byte
18 export interface IColorSet {
27 export interface IPartialColorSet {
31 cursorAccent?: IColor;
36 export interface IViewport extends IDisposable {
37 scrollBarWidth: number;
38 syncScrollArea(immediate?: boolean): void;
39 getLinesScrolled(ev: WheelEvent): number;
40 onWheel(ev: WheelEvent): boolean;
41 onTouchStart(ev: TouchEvent): void;
42 onTouchMove(ev: TouchEvent): boolean;
43 onThemeChange(colors: IColorSet): void;
46 export interface IViewportRange {
47 start: IViewportRangePosition;
48 end: IViewportRangePosition;
51 export interface IViewportRangePosition {
56 export type LinkMatcherHandler = (event: MouseEvent, uri: string) => void;
57 export type LinkMatcherHoverTooltipCallback = (event: MouseEvent, uri: string, position: IViewportRange) => void;
58 export type LinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void;
60 export interface ILinkMatcher {
63 handler: LinkMatcherHandler;
64 hoverTooltipCallback?: LinkMatcherHoverTooltipCallback;
65 hoverLeaveCallback?: () => void;
67 validationCallback?: LinkMatcherValidationCallback;
69 willLinkActivate?: (event: MouseEvent, uri: string) => boolean;
72 export interface IRegisteredLinkMatcher extends ILinkMatcher {
76 export interface ILinkifierEvent {
82 fg: number | undefined;
85 export interface ILinkifier {
86 onLinkHover: IEvent<ILinkifierEvent>;
87 onLinkLeave: IEvent<ILinkifierEvent>;
88 onLinkTooltip: IEvent<ILinkifierEvent>;
90 attachToDom(element: HTMLElement, mouseZoneManager: IMouseZoneManager): void;
91 linkifyRows(start: number, end: number): void;
92 registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number;
93 deregisterLinkMatcher(matcherId: number): boolean;
96 export interface ILinkMatcherOptions {
98 * The index of the link from the regex.match(text) call. This defaults to 0
99 * (for regular expressions without capture groups).
103 * A callback that validates an individual link, returning true if valid and
106 validationCallback?: LinkMatcherValidationCallback;
108 * A callback that fires when the mouse hovers over a link.
110 tooltipCallback?: LinkMatcherHoverTooltipCallback;
112 * A callback that fires when the mouse leaves a link that was hovered.
114 leaveCallback?: () => void;
116 * The priority of the link matcher, this defines the order in which the link
117 * matcher is evaluated relative to others, from highest to lowest. The
118 * default value is 0.
122 * A callback that fires when the mousedown and click events occur that
123 * determines whether a link will be activated upon click. This enables
124 * only activating a link when a certain modifier is held down, if not the
125 * mouse event will continue propagation (eg. double click to select word).
127 willLinkActivate?: (event: MouseEvent, uri: string) => boolean;
130 export interface IMouseZoneManager extends IDisposable {
131 add(zone: IMouseZone): void;
132 clearAll(start?: number, end?: number): void;
135 export interface IMouseZone {
140 clickCallback: (e: MouseEvent) => any;
141 hoverCallback: (e: MouseEvent) => any | undefined;
142 tooltipCallback: (e: MouseEvent) => any | undefined;
143 leaveCallback: () => any | undefined;
144 willLinkActivate: (e: MouseEvent) => boolean;