xterm.pp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. {
  2. Xterm.js package, autogenerated from typescript description.
  3. This is still incomplete (some event handlers need to be correctly typed)
  4. }
  5. Unit xterm;
  6. {$MODE ObjFPC}
  7. {$H+}
  8. {$modeswitch externalclass}
  9. interface
  10. uses SysUtils, JS, Types, Web;
  11. Type
  12. // Forward class definitions
  13. Txterm = Class;
  14. // Modules
  15. HTMLELement = TJSHTMLElement;
  16. MouseEvent = TJSMouseEvent;
  17. Txterm = class external name 'window' (TJSObject)
  18. Public
  19. Type
  20. // Forward class definitions
  21. TITerminalOptions = Class;
  22. TITheme = Class;
  23. TILinkMatcherOptions = Class;
  24. TIDisposable = Class;
  25. TIEvent = Class;
  26. TIMarker = Class;
  27. TILocalizableStrings = Class;
  28. TIWindowOptions = Class;
  29. TITerminalAddon = Class;
  30. TISelectionPosition = Class;
  31. TIViewportRange = Class;
  32. TIViewportRangePosition = Class;
  33. TILinkProvider = Class;
  34. TILink = Class;
  35. TILinkDecorations = Class;
  36. TIBufferRange = Class;
  37. TIBufferCellPosition = Class;
  38. TIBuffer = Class;
  39. TIBufferNamespace = Class;
  40. TIBufferLine = Class;
  41. TIBufferCell = Class;
  42. TIFunctionIdentifier = Class;
  43. TIParser = Class;
  44. TIUnicodeVersionProvider = Class;
  45. TIUnicodeHandling = Class;
  46. TIModes = Class;
  47. // Forward class definitions
  48. TTerminal = Class;
  49. TFontWeight = jsvalue; // number
  50. TLogLevel = jsvalue; //
  51. TRendererType = jsvalue; //
  52. TattachCustomKeyEventHandler_customKeyEventHandler = reference to function (event: TJSKeyboardEvent): boolean;
  53. TCallBack = reference to procedure;
  54. TMarkersType = specialize TArray<TIMarker>;
  55. TOnDataCallback = reference to function (data : String) : Boolean;
  56. TOnRenderCallbackDataType = class external name 'Object' (TJSObject)
  57. start : integer;
  58. end_ : integer; external name 'end';
  59. end;
  60. TOnKeyCallbackDataType = class external name 'Object' (TJSObject)
  61. key : string;
  62. domEvent : TJSKeyBoardEvent;
  63. end;
  64. TOnResizeCallbackDataType = class external name 'Object' (TJSObject)
  65. cols : integer;
  66. rows : integer;
  67. end;
  68. TOnKeyCallback = reference to function(data : TOnKeyCallbackDataType) : Boolean;
  69. TOnRenderCallBack = reference to function(data : TOnRenderCallBackDataType) : Boolean;
  70. TOnResizeCallBack = reference to function(data : TOnResizeCallBackDataType) : Boolean;
  71. TOnScrollCallBack = reference to function(data : double) : Boolean;
  72. TTerminal = class external name 'Terminal' (TJSObject)
  73. Private
  74. Felement : jsvalue; external name 'element';
  75. Ftextarea : jsvalue; external name 'textarea';
  76. Frows : Double; external name 'rows';
  77. Fcols : Double; external name 'cols';
  78. Fbuffer : TIBufferNamespace; external name 'buffer';
  79. Fmarkers : TMarkersType; external name 'markers';
  80. Fparser : TIParser; external name 'parser';
  81. Funicode : TIUnicodeHandling; external name 'unicode';
  82. Fmodes : TIModes; external name 'modes';
  83. Public
  84. Function addMarker(cursorYOffset : Double): jsvalue;
  85. Procedure attachCustomKeyEventHandler(customKeyEventHandler : TattachCustomKeyEventHandler_customKeyEventHandler);
  86. Procedure blur;
  87. Procedure clear;
  88. Procedure clearSelection;
  89. Procedure clearTextureAtlas;
  90. constructor new(options : TITerminalOptions); overload;
  91. constructor new; overload;
  92. Procedure deregisterCharacterJoiner(joinerId : Double);
  93. Procedure deregisterLinkMatcher(matcherId : Double);
  94. Procedure dispose;
  95. Procedure focus;
  96. Function getOption(key : jsvalue): string; overload;
  97. Function getOption(key : string): string; overload;
  98. Function getSelection: string;
  99. Function getSelectionPosition: jsvalue;
  100. Function hasSelection: boolean;
  101. Procedure loadAddon(addon : TITerminalAddon);
  102. Procedure open(parent : HTMLElement);
  103. Procedure paste(data : string);
  104. Procedure refresh(start : Double; &end : Double);
  105. // Function registerCharacterJoiner(handler : procedure): Double;
  106. // Function registerLinkMatcher(regex : RegExp; handler : procedure; options : TILinkMatcherOptions): Double; overload;
  107. // Function registerLinkMatcher(regex : RegExp; handler : procedure): Double; overload;
  108. Function registerLinkProvider(linkProvider : TILinkProvider): TIDisposable;
  109. Function registerMarker(cursorYOffset : Double): jsvalue;
  110. Procedure reset;
  111. Procedure resize(columns : Double; rows : Double);
  112. Procedure scrollLines(amount : Double);
  113. Procedure scrollPages(pageCount : Double);
  114. Procedure scrollToBottom;
  115. Procedure scrollToLine(line : Double);
  116. Procedure scrollToTop;
  117. Procedure select(column : Double; row : Double; &length : Double);
  118. Procedure selectAll;
  119. Procedure selectLines(start : Double; &end : Double);
  120. Procedure setOption(key : jsvalue; value : string); overload;
  121. Procedure setOption(key : jsvalue; value : jsvalue); overload;
  122. Procedure setOption(key : String; value : TLogLevel); overload;
  123. Procedure setOption(key : jsvalue; value : boolean); overload;
  124. Procedure setOption(key : jsvalue; value : Double); overload;
  125. Procedure setOption(key : String; value : TITheme); overload;
  126. Procedure write(data : jsvalue; callback : TCallback); overload;
  127. Procedure write(data : jsvalue); overload;
  128. Procedure writeln(data : jsvalue; callback : TCallBack); overload;
  129. Procedure writeln(data : jsvalue); overload;
  130. Procedure writeUtf8(data : TJSUint8Array; callback : TCallback); overload;
  131. Procedure writeUtf8(data : TJSUint8Array); overload;
  132. Property element : jsvalue Read Felement;
  133. Property textarea : jsvalue Read Ftextarea;
  134. Property rows : Double Read Frows;
  135. Property cols : Double Read Fcols;
  136. Property buffer : TIBufferNamespace Read Fbuffer;
  137. Property markers : TMarkersType Read Fmarkers;
  138. Property parser : TIParser Read Fparser;
  139. Property unicode : TIUnicodeHandling Read Funicode;
  140. Property modes : TIModes Read Fmodes;
  141. options : TITerminalOptions;
  142. strings : TILocalizableStrings;
  143. function onBell(listener: TCallBack) : TIDisposable;
  144. function onBinary(listener : TOnDataCallBack) : TIDisposable;
  145. Function onCursorMove(listener: TCallBack) : TIDisposable;
  146. function onData (listener : TOnDataCallback) : TIDisposable;
  147. function onKey(listener: TOnKeyCallback) : TIDisposable;
  148. function onLineFeed (listener: TCallBack) : TIDisposable;
  149. function onRender(listener : TOnRenderCallBack) : TIDisposable;
  150. function onResize(listener : TOnResizeCallBack) : TIDisposable;
  151. function onScroll(listener : TOnScrollCallBack) : TIDisposable;
  152. function onSelectionChange(listener : TCallBack) : TIDisposable;
  153. function onTitleChange(listener : TOnDataCallback) : TIDisposable;
  154. end;
  155. TITerminalOptions = class external name 'Object' (TJSObject)
  156. allowProposedApi : boolean;
  157. allowTransparency : boolean;
  158. altClickMovesCursor : boolean;
  159. bellSound : string;
  160. bellStyle : jsvalue;
  161. convertEol : boolean;
  162. cols : Double;
  163. cursorBlink : boolean;
  164. cursorStyle : jsvalue;
  165. cursorWidth : Double;
  166. customGlyphs : boolean;
  167. disableStdin : boolean;
  168. drawBoldTextInBrightColors : boolean;
  169. fastScrollModifier : jsvalue;
  170. fastScrollSensitivity : Double;
  171. fontSize : Double;
  172. fontFamily : string;
  173. fontWeight : TFontWeight;
  174. fontWeightBold : TFontWeight;
  175. letterSpacing : Double;
  176. lineHeight : Double;
  177. linkTooltipHoverDuration : Double;
  178. logLevel : TLogLevel;
  179. macOptionIsMeta : boolean;
  180. macOptionClickForcesSelection : boolean;
  181. minimumContrastRatio : Double;
  182. rendererType : TRendererType;
  183. rightClickSelectsWord : boolean;
  184. rows : Double;
  185. screenReaderMode : boolean;
  186. scrollback : Double;
  187. scrollSensitivity : Double;
  188. tabStopWidth : Double;
  189. theme : TITheme;
  190. windowsMode : boolean;
  191. wordSeparator : string;
  192. windowOptions : TIWindowOptions;
  193. end;
  194. TITheme = class external name 'Object' (TJSObject)
  195. foreground : string;
  196. background : string;
  197. cursor : string;
  198. cursorAccent : string;
  199. selection : string;
  200. black : string;
  201. red : string;
  202. green : string;
  203. yellow : string;
  204. blue : string;
  205. magenta : string;
  206. cyan : string;
  207. white : string;
  208. brightBlack : string;
  209. brightRed : string;
  210. brightGreen : string;
  211. brightYellow : string;
  212. brightBlue : string;
  213. brightMagenta : string;
  214. brightCyan : string;
  215. brightWhite : string;
  216. end;
  217. TILinkMatcherOptions = class external name 'Object' (TJSObject)
  218. matchIndex : Double;
  219. validationCallback : TCallBack;
  220. tooltipCallback : TCallBack;
  221. leaveCallback : TCallback;
  222. priority : Double;
  223. willLinkActivate : TCallBack;
  224. end;
  225. TIDisposable = class external name 'Object' (TJSObject)
  226. Procedure dispose;
  227. end;
  228. TIEvent = class external name 'Object' (TJSObject)
  229. constructor new(listener : TCallback);
  230. end;
  231. TIMarker = class external name 'Object' (TJSObject)
  232. Fid : Double; external name 'id';
  233. FisDisposed : boolean; external name 'isDisposed';
  234. Fline : Double; external name 'line';
  235. Property id : Double Read Fid;
  236. Property isDisposed : boolean Read FisDisposed;
  237. Property line : Double Read Fline;
  238. onDispose : TIEvent;
  239. end;
  240. TILocalizableStrings = class external name 'Object' (TJSObject)
  241. promptLabel : string;
  242. tooMuchOutput : string;
  243. end;
  244. TIWindowOptions = class external name 'Object' (TJSObject)
  245. restoreWin : boolean;
  246. minimizeWin : boolean;
  247. setWinPosition : boolean;
  248. setWinSizePixels : boolean;
  249. raiseWin : boolean;
  250. lowerWin : boolean;
  251. refreshWin : boolean;
  252. setWinSizeChars : boolean;
  253. maximizeWin : boolean;
  254. fullscreenWin : boolean;
  255. getWinState : boolean;
  256. getWinPosition : boolean;
  257. getWinSizePixels : boolean;
  258. getScreenSizePixels : boolean;
  259. getCellSizePixels : boolean;
  260. getWinSizeChars : boolean;
  261. getScreenSizeChars : boolean;
  262. getIconTitle : boolean;
  263. getWinTitle : boolean;
  264. pushTitle : boolean;
  265. popTitle : boolean;
  266. setWinLines : boolean;
  267. end;
  268. TITerminalAddon = class external name 'Object' (TJSObject)
  269. Procedure activate(terminal : TTerminal);
  270. end;
  271. TISelectionPosition = class external name 'Object' (TJSObject)
  272. startColumn : Double;
  273. startRow : Double;
  274. endColumn : Double;
  275. endRow : Double;
  276. end;
  277. TIViewportRange = class external name 'Object' (TJSObject)
  278. start : TIViewportRangePosition;
  279. &end : TIViewportRangePosition;external name 'end';
  280. end;
  281. TIViewportRangePosition = class external name 'Object' (TJSObject)
  282. x : Double;
  283. y : Double;
  284. end;
  285. TILinkProvider = class external name 'Object' (TJSObject)
  286. Procedure provideLinks(bufferLineNumber : Double; callback : TCallback);
  287. end;
  288. TILink = class external name 'Object' (TJSObject)
  289. Procedure activate(event : MouseEvent; text : string);
  290. Procedure dispose;
  291. Procedure hover(event : MouseEvent; text : string);
  292. Procedure leave(event : MouseEvent; text : string);
  293. range : TIBufferRange;
  294. text : string;
  295. decorations : TILinkDecorations;
  296. end;
  297. TILinkDecorations = class external name 'Object' (TJSObject)
  298. pointerCursor : boolean;
  299. underline : boolean;
  300. end;
  301. TIBufferRange = class external name 'Object' (TJSObject)
  302. start : TIBufferCellPosition;
  303. &end : TIBufferCellPosition;external name 'end';
  304. end;
  305. TIBufferCellPosition = class external name 'Object' (TJSObject)
  306. x : Double;
  307. y : Double;
  308. end;
  309. TIBuffer = class external name 'Object' (TJSObject)
  310. Ftype : jsvalue; external name 'type';
  311. FcursorY : Double; external name 'cursorY';
  312. FcursorX : Double; external name 'cursorX';
  313. FviewportY : Double; external name 'viewportY';
  314. FbaseY : Double; external name 'baseY';
  315. Flength : Double; external name 'length';
  316. Function getLine(y : Double): jsvalue;
  317. Function getNullCell: TIBufferCell;
  318. Property &type : jsvalue Read Ftype;
  319. Property cursorY : Double Read FcursorY;
  320. Property cursorX : Double Read FcursorX;
  321. Property viewportY : Double Read FviewportY;
  322. Property baseY : Double Read FbaseY;
  323. Property &length : Double Read Flength;
  324. end;
  325. TIBufferNamespace = class external name 'Object' (TJSObject)
  326. Factive : TIBuffer; external name 'active';
  327. Fnormal : TIBuffer; external name 'normal';
  328. Falternate : TIBuffer; external name 'alternate';
  329. Property active : TIBuffer Read Factive;
  330. Property normal : TIBuffer Read Fnormal;
  331. Property alternate : TIBuffer Read Falternate;
  332. onBufferChange : TIEvent;
  333. end;
  334. TIBufferLine = class external name 'Object' (TJSObject)
  335. FisWrapped : boolean; external name 'isWrapped';
  336. Flength : Double; external name 'length';
  337. Function getCell(x : Double; cell : TIBufferCell): jsvalue; overload;
  338. Function getCell(x : Double): jsvalue; overload;
  339. Function translateToString(trimRight : boolean; startColumn : Double; endColumn : Double): string; overload;
  340. Function translateToString: string; overload;
  341. Function translateToString(trimRight : boolean): string; overload;
  342. Function translateToString(trimRight : boolean; startColumn : Double): string; overload;
  343. Property isWrapped : boolean Read FisWrapped;
  344. Property &length : Double Read Flength;
  345. end;
  346. TIBufferCell = class external name 'Object' (TJSObject)
  347. Function getBgColor: Double;
  348. Function getBgColorMode: Double;
  349. Function getChars: string;
  350. Function getCode: Double;
  351. Function getFgColor: Double;
  352. Function getFgColorMode: Double;
  353. Function getWidth: Double;
  354. Function isAttributeDefault: boolean;
  355. Function isBgDefault: boolean;
  356. Function isBgPalette: boolean;
  357. Function isBgRGB: boolean;
  358. Function isBlink: Double;
  359. Function isBold: Double;
  360. Function isDim: Double;
  361. Function isFgDefault: boolean;
  362. Function isFgPalette: boolean;
  363. Function isFgRGB: boolean;
  364. Function isInverse: Double;
  365. Function isInvisible: Double;
  366. Function isItalic: Double;
  367. Function isStrikethrough: Double;
  368. Function isUnderline: Double;
  369. end;
  370. TIFunctionIdentifier = class external name 'Object' (TJSObject)
  371. prefix : string;
  372. intermediates : string;
  373. final : string;
  374. end;
  375. TIParser = class external name 'Object' (TJSObject)
  376. Function registerCsiHandler(id : TIFunctionIdentifier; callback : TCallBack): TIDisposable;
  377. Function registerDcsHandler(id : TIFunctionIdentifier; callback : TCallBack): TIDisposable;
  378. Function registerEscHandler(id : TIFunctionIdentifier; handler : TCallBack): TIDisposable;
  379. Function registerOscHandler(ident : Double; callback : TCallBack): TIDisposable;
  380. end;
  381. TIUnicodeVersionProvider = class external name 'Object' (TJSObject)
  382. Fversion : string; external name 'version';
  383. Function wcwidth(codepoint : Double): jsvalue;
  384. Property version : string Read Fversion;
  385. end;
  386. TIUnicodeHandling = class external name 'Object' (TJSObject)
  387. Fversions : TStringDynArray; external name 'versions';
  388. Procedure register(provider : TIUnicodeVersionProvider);
  389. Property versions : TStringDynArray Read Fversions;
  390. activeVersion : string;
  391. end;
  392. TIModes = class external name 'Object' (TJSObject)
  393. FapplicationCursorKeysMode : boolean; external name 'applicationCursorKeysMode';
  394. FapplicationKeypadMode : boolean; external name 'applicationKeypadMode';
  395. FbracketedPasteMode : boolean; external name 'bracketedPasteMode';
  396. FinsertMode : boolean; external name 'insertMode';
  397. FmouseTrackingMode : jsvalue; external name 'mouseTrackingMode';
  398. ForiginMode : boolean; external name 'originMode';
  399. FreverseWraparoundMode : boolean; external name 'reverseWraparoundMode';
  400. FsendFocusMode : boolean; external name 'sendFocusMode';
  401. FwraparoundMode : boolean; external name 'wraparoundMode';
  402. Property applicationCursorKeysMode : boolean Read FapplicationCursorKeysMode;
  403. Property applicationKeypadMode : boolean Read FapplicationKeypadMode;
  404. Property bracketedPasteMode : boolean Read FbracketedPasteMode;
  405. Property insertMode : boolean Read FinsertMode;
  406. Property mouseTrackingMode : jsvalue Read FmouseTrackingMode;
  407. Property originMode : boolean Read ForiginMode;
  408. Property reverseWraparoundMode : boolean Read FreverseWraparoundMode;
  409. Property sendFocusMode : boolean Read FsendFocusMode;
  410. Property wraparoundMode : boolean Read FwraparoundMode;
  411. end;
  412. end;
  413. implementation
  414. end.