Compare commits

...
309 Commits
Author SHA1 Message Date
Paris Kasidiaris ef407ae93a Bump version to 2.2.3
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-12-15 21:56:32 +00:00
Paris Kasidiaris 9032ce99d3 Merge pull request #416 from sourcelair/issue-#414-css-files-in-npm
Include appropriate files in npm.
2016-12-15 21:53:19 +00:00
Paris Kasidiaris adaaeb6f36 Include appropriate files in npm.
Fix #414
2016-12-15 23:49:43 +02:00
Paris Kasidiaris 8a146b5401 Bump version to 2.2.2
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-12-15 17:16:04 +00:00
Paris Kasidiaris 3a6368ba6c Merge pull request #411 from sourcelair/issue-#408-tslint
Add tslint
2016-12-15 12:13:23 +00:00
Paris Kasidiaris fbc314a74b Parallelise build 2016-12-15 14:05:37 +02:00
Paris Kasidiaris 850a238ca2 Include lint test into travis 2016-12-15 14:02:38 +02:00
Paris Kasidiaris 20b6f20908 Make linter happy 2016-12-15 13:57:25 +02:00
Paris Kasidiaris 33f7d7649a Add tslint
Fix #408
2016-12-15 13:53:26 +02:00
Paris Kasidiaris fb4d263211 Merge pull request #409 from sourcelair/issue-#405-firefox-paste
Fix linux firefox paste
2016-12-14 10:38:30 +00:00
Paris Kasidiaris ab87dece0b Fix weird paste issue: #405
Fix #405
2016-12-14 01:45:53 +02:00
Paris Kasidiaris 69e027394d 😱 Fix wrong event type and remove useless interface 2016-12-14 01:43:32 +02:00
Paris Kasidiaris 6639b2c731 Merge pull request #407 from sourcelair/build-ts-into-lib
Always build TypeScript in `lib/`
2016-12-13 23:32:49 +00:00
Paris Kasidiaris e23956cd77 Do not publish test files to npm 2016-12-13 23:28:33 +00:00
Paris Kasidiaris 56ca7743a8 Always build TypeScript in lib/ 2016-12-14 01:10:03 +02:00
Paris Kasidiaris fb17d57549 Merge pull request #398 from budde377/feat-npm
Add prepublish script and change main
2016-12-13 22:59:58 +00:00
Christian Budde Christensen e7045f2b8a Add prepublish script and change main
Building TS before publish and pointing the main entry to the builded files.
2016-12-13 20:34:19 +01:00
Paris Kasidiaris 852f587bd2 Merge pull request #400 from arcanis/patch-1
Use a fixed size to account for the scrollbar
2016-12-11 10:25:35 +00:00
Maël Nison e0e6f5e302 Use a fixed size to account for the scrollbar 2016-12-10 14:46:01 +01:00
Paris Kasidiaris 06a5ffdd1a Merge pull request #399 from bottleofwater/patch-1
Don't apply the 32 delta when in sgr mode - fix #394
2016-12-09 10:12:42 +00:00
bottleofwater a75bafc4ba Don't apply the 32 delta when in sgr mode - fix #394 2016-12-09 10:52:09 +01:00
Paris Kasidiaris 60a59be4d3 Bump version to 2.2.1
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-12-07 18:43:03 +00:00
Paris Kasidiaris b76b2d01eb Checkout add-ons 2016-12-07 18:42:40 +00:00
Paris Kasidiaris cd70d298fc Bump version to 2.2.0
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-12-07 18:41:37 +00:00
Paris Kasidiaris 70d0ed3ebf Merge pull request #393 from sourcelair/migrate-clipboard-to-typescript
Migrate Clipboard handler to TypeScript
2016-12-07 18:37:00 +00:00
Paris Kasidiaris 5a5c6ab621 Merge pull request #392 from sourcelair/fix-readme-addon-path
Update path to addons in README.md
2016-12-06 22:08:30 +00:00
Paris Kasidiaris a34bb9724f Improve interfaces in Clipboard.ts 2016-12-07 00:07:50 +02:00
Paris Kasidiaris 824a9c6dbf Migrate Clipboard handler to TypeScript
Also apply JavaScript rules in `.editorconfig` in TypeScript files as well.

Part of #335
2016-12-06 10:01:06 +00:00
Paris Kasidiaris c9eaae6bd5 Update path to addons in README.md 2016-12-06 10:55:40 +02:00
Daniel Imms 9f5790fcaf Merge pull request #391 from Tyriar/357_textarea_top_zero
Position the textarea at top:0
2016-12-05 11:47:55 -08:00
Paris Kasidiaris 6aeb0435ce Merge pull request #390 from sourcelair/issue-#375-bring-build-dir-back
Bring back the `build` directory for temporary builds
2016-12-05 19:35:08 +00:00
Paris Kasidiaris 70ec2496db Remove export from build script 2016-12-05 21:29:50 +02:00
Daniel Imms 55314e0fc7 Position the textarea at top:0
This prevents the browser from scrolling to the top of the page if the terminal
can be scrolled out of view.

Fixes #357
2016-12-05 11:19:36 -08:00
Paris Kasidiaris 243d76617b Create the build directory if it does not exist already 2016-12-05 13:34:10 +02:00
Paris Kasidiaris 6cc66a0b20 Bring back the build directory for temporary builds
Fix #375
2016-12-05 13:17:13 +02:00
Paris Kasidiaris 1e928df531 Merge pull request #388 from sourcelair/issue-#366
Update documentation with cleaner license declaration
2016-12-01 19:41:58 +02:00
Daniel Imms db9bec02f5 Merge pull request #382 from sourcelair/Tyriar-patch-1
Add link to TravisCI badge
2016-12-01 09:19:06 -08:00
Daniel Imms 0dc033692f Merge pull request #383 from Tyriar/381_clean_out_on_build
Clean out/* on build in case src/* files were deleted
2016-12-01 09:18:56 -08:00
Paris Kasidiaris 1d30091188 Update documentation with cleaner license declaration
Fix #366
2016-12-01 13:37:20 +00:00
Daniel Imms 64f80f8623 Merge pull request #380 from Tyriar/378_handle_keypress_scroll
Scroll to bottom whenever handler is called
2016-11-28 15:55:27 -08:00
Daniel Imms 83b06c6bb0 Clean out/* on build in case src/* files were deleted
If files in src/ were compiled and then deleted they will hang around in out/
until deleted. This can potentially cause difficult to diagnose build/test
errors. This commit removes all files from out/ but keeps the folder to
prevent editor file watchers from seeing the folder was deleted and shifting
the file explorer around.

Fixed #381
2016-11-28 10:52:03 -08:00
Daniel Imms 5cbc2f0ea5 Add link to TravisCI badge 2016-11-28 10:46:19 -08:00
Daniel Imms 2bc8adee8c Scroll to bottom whenever handler is called
This catches all current and future cases for correctly scrolling to the bottom
on input by handling it in the handler immediately before emitting the data
event.

Fixes #378
2016-11-28 10:41:05 -08:00
Daniel Imms c6eb7f136c Merge pull request #371 from Tyriar/335_CompositionHelper_ts
Convert CompositionHelper to TypeScript
2016-11-28 08:21:12 -08:00
Daniel Imms 48b87c2f40 Merge remote-tracking branch 'upstream/master' into 335_CompositionHelper_ts 2016-11-28 08:16:38 -08:00
Daniel Imms ca818fbf04 Merge pull request #379 from Tyriar/378_cannot_scroll_up_1plus_pages
Only scroll to bottom during composition or result.key is evaluated
2016-11-28 08:07:00 -08:00
Daniel Imms 264fe4edc7 Merge pull request #372 from Tyriar/335_viewport_tidy
Clean up viewport more after TS conversion
2016-11-28 08:06:50 -08:00
Daniel Imms 317c0ec2de Merge pull request #377 from Tyriar/376_ctrl_backslash_sigquit
Implement ^\ String Terminator
2016-11-28 08:06:42 -08:00
Daniel Imms 3b2e89d878 Only scroll to bottom during composition or result.key is evaluated
Fixes #378
2016-11-27 01:49:45 -08:00
Daniel Imms 15a94240eb Implement ^\ String Terminator
Fixes #376
2016-11-26 14:59:53 -08:00
Daniel Imms f75b7db90e Move CompositionHelper header comment to class 2016-11-22 11:54:42 -08:00
Daniel Imms 81dc48ef00 Clean up viewport more after TS conversion
Part of #335
2016-11-22 11:53:45 -08:00
Daniel Imms 3638ef808b tsify CompositionHelper test 2016-11-22 11:50:08 -08:00
Daniel Imms f24cba722a Rename composition-helper-test.js -> CompositionHelper.test.ts 2016-11-22 11:48:16 -08:00
Daniel Imms 30fcdd6ccb tsify CompositionHelper 2016-11-22 11:47:18 -08:00
Daniel Imms b0df236dea Rename CompositionHelper.js -> CompositionHelper.ts 2016-11-22 11:36:34 -08:00
Daniel Imms d91e33ff39 Merge pull request #369 from Tyriar/368_custom_handler_before_scroll
Evaluate the custom keydown event handler before scrolling down
2016-11-22 10:29:43 -08:00
Daniel Imms 1ee316ca83 Merge remote-tracking branch 'upstream/master' into 368_custom_handler_before_scroll 2016-11-22 10:23:04 -08:00
Daniel Imms dcbf014402 Merge pull request #367 from Tyriar/363_modifier_keys_no_scroll
Prevent keyboard modifier events from scrolling down
2016-11-22 08:00:23 -08:00
Daniel Imms 20b0d4fdcc Merge pull request #370 from Tyriar/335_Viewport_ts
Convert Viewport to TypeScript
2016-11-22 07:59:46 -08:00
Daniel Imms 2da1255c26 Merge pull request #355 from Tyriar/354_fix_sourcemaps
Set up source maps
2016-11-21 15:27:38 -08:00
Daniel Imms 5bddb93745 Adopt more TS syntax in Viewport.test.ts 2016-11-21 14:44:10 -08:00
Daniel Imms 51932161af Move viewport-test.js to Viewport.test.ts 2016-11-21 14:39:58 -08:00
Daniel Imms e0d9871195 Convert Viewport to a TS class 2016-11-21 14:39:08 -08:00
Daniel Imms 634d4af4dd Rename Viewport.js -> Viewport.ts
Part of #335
2016-11-21 14:27:41 -08:00
Daniel Imms a507e4f002 Add test for not scrolling on custom handler 2016-11-21 14:23:28 -08:00
Daniel Imms c15fed382d Evaluate the custom keydown event handler before scrolling down
Fixes #368
2016-11-21 14:04:13 -08:00
Daniel Imms 9937d54410 Prevent keyboard modifier events from scrolling down
Fixes #363
2016-11-21 14:01:20 -08:00
Daniel Imms 64f6610f11 Merge pull request #353 from Tyriar/352_fix_demo_after_ts
Point to correct assets after TS build
2016-11-16 09:56:35 -08:00
Daniel Imms e6f21f0bfc Make all dist/ references in index.html absolute 2016-11-14 10:35:20 -08:00
Daniel Imms c63732ef5f Set up source maps
Fixes #354
2016-11-12 14:24:57 -08:00
Daniel Imms 99496de242 Point to correct assets after TS build 2016-11-12 14:01:38 -08:00
Daniel Imms 29cb576737 Merge pull request #296 from Tyriar/typescript_build_2
Move to TypeScript build
2016-11-12 13:51:12 -08:00
Daniel Imms bf4ef599ad Merge remote-tracking branch 'upstream/master' into typescript_build_2 2016-11-12 13:46:59 -08:00
Daniel Imms 5ddb33419e Merge pull request #1 from Tyriar/typescript_build_3
Refactor TS build and fix testing
2016-11-12 11:39:24 -08:00
Paris Kasidiaris bc10fbdfae Merge pull request #351 from yuvipanda/docsome
Add doc comments for *some* events
2016-11-12 12:53:02 +02:00
YuviPanda 6dcf7267a5 Add doc comment for scroll event 2016-11-11 16:28:25 -08:00
YuviPanda 5712365cac Add docstring for the open event 2016-11-11 16:27:10 -08:00
YuviPanda 1fc5a9aada Add docstring for the title event 2016-11-11 16:27:01 -08:00
Daniel Imms 38cd1bd6d7 Merge pull request #350 from sourcelair/Tyriar-patch-1
Make ttyd link bold like the others
2016-11-11 08:31:44 -08:00
Daniel Imms 771642d17d Make ttyd link bold like the others 2016-11-09 19:34:36 -08:00
Paris Kasidiaris bb19b2040b Merge pull request #347 from tsl0922/update-readme
Add ttyd to the real-world uses section of README
2016-11-09 14:52:56 +02:00
Shuanglei Tao 12840dae6c Add ttyd to the real-world uses section of README 2016-11-09 20:23:36 +08:00
Paris Kasidiaris 521d7dbdaa Bump version to 2.1.0
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-11-08 22:51:33 +00:00
Paris Kasidiaris 2cba2ff3d4 Merge pull request #345 from hiro-su/fix-ie11-right-click-paste
Fix the right click paste in IE11
2016-11-08 13:21:12 +02:00
hiro-su 547db92693 Fix the right click paste in IE11 2016-11-08 14:56:57 +09:00
Paris Kasidiaris bf334238b7 Merge pull request #339 from hiro-su/fix-ie11-copy-event
Fixed copy event in IE11
2016-11-05 15:27:50 +00:00
hiro-su 5808de648b Fixed copy event in IE11 2016-11-05 23:55:34 +09:00
Paris Kasidiaris 9ab0455b05 Merge pull request #342 from sourcelair/issue-#310-cross-browser-right-click
Make right-click work on all browsers
2016-11-04 20:40:53 +00:00
Paris Kasidiaris 55ab36662a Merge pull request #336 from sourcelair/issue-#216-no-auto-scroll-on-output
Stop auto scrolling to bottom on output
2016-11-04 19:55:07 +00:00
Paris Kasidiaris b1ad564b0d Actually fix tests 2016-11-04 21:48:53 +02:00
Paris Kasidiaris bc70b3b37d Fix tests 2016-11-04 19:36:30 +02:00
Paris Kasidiaris d426c99866 Move all browser/platform detecting in utils/Browser.js 2016-11-04 18:41:00 +02:00
Paris Kasidiaris 356377975b Fix right-click for Firefox and IE
Fix #310
2016-11-04 18:33:04 +02:00
Paris Kasidiaris 0de3d839e6 Improve experience and add test
- Scroll to bottom on keydown (when scrolled up)
- Add test to ensure above behavior
2016-11-04 12:29:17 +00:00
Paris Kasidiaris 0fcd6b1d22 Merge pull request #337 from IanLewis/master
Add main property to bower.json
2016-11-04 09:35:24 +00:00
Ian Lewis 99b5464392 Add main property to bower.json
This patch adds the main property to the project's bower.json for better
interoperability with tools like wiredep etc.
2016-11-03 17:56:58 +05:30
Paris Kasidiaris 70965a8fd6 Merge pull request #334 from hiro-su/fix-ie11-paste-key
Fixed paste key in IE11
2016-11-02 09:19:18 +00:00
hiro-su 77ca15497c Fixed paste key in IE11 2016-11-02 11:17:37 +09:00
Daniel Imms 56ecc77dfc Refactor TS build and fix testing
This change is largely just moving files with minor tweaks to them to fix,
the rest of the commit is build process changes:

- The addons/ and test/ dirs have been moved to src/
- The build directory has been removed
- TypeScript builds are output in out/, this is where tests are run
- The demo now relies on the dist/ build which is performed as part of ./bin/build
- Addons are now shipped under the ./build directory
2016-10-31 21:22:21 -07:00
Daniel Imms a995b610cf Remove typings (not needed in TS 2+) 2016-10-31 19:30:35 -07:00
Daniel Imms 332bc6be76 Merge remote-tracking branch 'upstream/master' into typescript_build_2 2016-10-31 19:29:36 -07:00
Paris Kasidiaris 26de9fe4c5 Merge pull request #332 from sourcelair/issue-#331-fix-no-selection-range
Consider click not on selection, when s.rangeCount is 0
2016-10-31 18:52:48 +00:00
Paris Kasidiaris 00dcb4f6e3 Consider click not on selection, when s.rangeCount is 0 2016-10-31 15:06:00 +02:00
Daniel Imms 996c641a79 Merge pull request #328 from Tyriar/327_fix_random_line_wrap
Force nowrap on each line
2016-10-27 07:52:48 -07:00
Daniel Imms a077860464 Force nowrap on each line
Fixes #327
2016-10-26 18:07:55 -07:00
Mikko Karvonen 5e68acfc76 Quick fix to prevent terminal scrolling when user is looking into scrollback. 2016-10-25 13:54:57 +03:00
Daniel Imms 269540bfed Merge pull request #323 from Tyriar/322_ime_bad_position
Fix the textarea in the composition view's pos when composing
2016-10-24 14:58:41 -07:00
Daniel Imms 868f15173d Fix the textarea in the composition view's pos when composing
Fixes #322
2016-10-24 11:06:25 -07:00
Paris Kasidiaris 06a93344bb Merge pull request #321 from sourcelair/issue-#313-document-terminal-constructor
Issue #313 document terminal constructor
2016-10-24 19:01:37 +03:00
Paris Kasidiaris e8e7870be2 Remove geometry option from terminal consttructor 2016-10-23 17:55:37 +03:00
Paris Kasidiaris a9417c6878 Fix term.geometry and document it in constructor options
Set `term.geometry` on terminal creation and on resize
2016-10-23 14:22:00 +00:00
Paris Kasidiaris 605d61b64f Ignore .env files that set the environment 2016-10-23 14:22:00 +00:00
Daniel Imms 8feaacf57e Merge pull request #320 from Tyriar/299_keep_textarea_in_viewport
Correctly size and position the composition view
2016-10-23 07:16:28 -07:00
Daniel Imms 553c651166 Correctly size and position the composition view 2016-10-22 16:27:17 -07:00
Daniel Imms 1ec0bac9c6 Keep composition textarea within viewport
Part of #299
2016-10-22 15:41:55 -07:00
Paris Kasidiaris b1c6ae8a06 Merge pull request #303 from staticfloat/sf/terminado
Add `Terminado` example
2016-10-17 21:03:49 +03:00
Daniel Imms 8a124d0b35 Merge pull request #308 from Tyriar/294_scroll
Implement scrollPages, scrollToTop, scrollToBottom and add scroll tests
2016-10-10 08:33:09 -07:00
Daniel Imms 0ad02a4afa Add note that negative scrolls up on scrollPages 2016-10-10 08:25:01 -07:00
Daniel Imms 9389f899d7 Merge pull request #309 from Tyriar/fix_indentation
Fix jsdoc indentation
2016-10-10 08:20:56 -07:00
Paris Kasidiaris 050a34921b Merge pull request #304 from sourcelair/update-addons-paths
Make add-ons load Terminal from dist
2016-10-10 10:12:50 +03:00
Daniel Imms 32e878db81 Fix jsdoc indentation 2016-10-09 13:23:22 -07:00
Daniel Imms 0bf7bf56a5 Add jsdoc to scrollTo functions 2016-10-09 13:20:33 -07:00
Daniel Imms e5d130b698 Add scrollToBottom 2016-10-09 13:19:11 -07:00
Daniel Imms 941e57a218 Add tests for scrollPages 2016-10-09 13:10:18 -07:00
Daniel Imms c02eea6ad3 Add tests for scrollDisp 2016-10-09 13:08:08 -07:00
Daniel Imms fe0d878b23 Implement scrollPages 2016-10-09 12:51:58 -07:00
Paris Kasidiaris 763f148fa1 Remove __dirname usage from loadAddon 2016-10-09 13:17:17 +03:00
Elliot Saba 8f0ada708f Make naming a little more self-consistent 2016-10-08 20:09:34 -07:00
Paris Kasidiaris 8117999ab3 Fix tests 2016-10-08 12:22:18 +03:00
Elliot Saba 10dd22a3d4 Rename Terminado attach and detach functions 2016-10-08 00:36:08 -07:00
Daniel Imms 738f37e86c Set travis to node 6 2016-10-07 23:01:20 -07:00
Daniel Imms 729c0abf04 Explicitly indicate test locations 2016-10-07 22:56:02 -07:00
Elliot Saba fe54da34f8 Add terminado.js, an addon for connecting to Terminado backends 2016-10-07 13:33:10 -07:00
Daniel Imms 09de0f31fa Merge pull request #301 from Tyriar/300_top_textarea_helper
Add top to textarea helper
2016-10-05 09:33:08 -07:00
Paris Kasidiaris 6ee524864e Make add-ons load the latest built version 2016-10-05 13:23:45 +03:00
Elliot Saba 8fd350f0fc Add Terminado example 2016-10-05 00:32:39 -07:00
Daniel Imms ebbeeefd86 Add top to textarea helper
Fixes #300
2016-10-04 19:03:15 -07:00
Paris Kasidiaris 76a890aa74 Bump version to 2.0.1
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-10-03 12:39:39 +00:00
Paris Kasidiaris 5ce522a401 Add built files 2016-10-03 12:39:14 +00:00
Paris Kasidiaris 68906b5def Bump version to 2.0.0
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-10-03 12:37:00 +00:00
Paris Kasidiaris dddaa16573 Merge pull request #298 from sourcelair/fix-release-scripts
Fix release scripts
2016-10-03 15:33:20 +03:00
Paris Kasidiaris d581559dd4 Fix release scripts 2016-10-03 15:32:14 +03:00
Paris Kasidiaris 3e77db8149 Merge pull request #269 from Tyriar/set_package_main
Set package.json main to build/xterm.js
2016-10-03 14:11:34 +03:00
Daniel Imms bd994f9e57 Install typings on build and add to git ignore 2016-10-01 12:22:57 -07:00
Paris Kasidiaris 9115846017 Merge pull request #293 from sourcelair/issue-#202-fix-paste
Allow right-click paste (again)
2016-10-01 10:39:46 +03:00
Daniel Imms 441009d359 Move to TypeScript build 2016-10-01 00:29:33 -07:00
Paris Kasidiaris ab7d63a8c8 Merge pull request #295 from sourcelair/update-copyright-text
Update copyright text in all files
2016-09-30 14:06:34 +03:00
Paris Kasidiaris a7acee726d Update copyright text in all files
sourceLair Limited → SourceLair Private Company
2016-09-30 13:52:55 +03:00
Paris Kasidiaris a6f047331f Add forgotten line to keep copied text 😅 2016-09-29 10:59:24 +03:00
Paris Kasidiaris a224acb50b Document new Clipboard module 2016-09-29 07:51:31 +00:00
Paris Kasidiaris 42a1e4ef9b Move clipboard into its own module 2016-09-29 07:51:07 +00:00
Paris Kasidiaris dff867b8a7 Fix right-click paste
Fix #202
2016-09-29 10:50:21 +03:00
Daniel Imms 8bf8147028 Merge pull request #289 from Tyriar/151_allow_wheel_in_application_mode
Allow wheel events in application mode
2016-09-25 04:44:53 -07:00
Daniel Imms ccf6d8f87d Merge pull request #287 from Tyriar/286_fix_scroll_in_app_mode
Sync scroll bar instead of disabling on enter app mode
2016-09-25 04:44:44 -07:00
Daniel Imms ac817ccc66 Merge pull request #288 from Tyriar/278_sync_scrollbar_after_reset
Sync scroll bar after reset
2016-09-25 02:44:56 -07:00
Daniel Imms 37c07eaaf9 Allow wheel events in application mode
This change allows wheel events in application mode which fixes mouse wheel
scrolling in oh-my-zsh and powershell for Linux (among others). Along with #287
a functional scroll bar will also be usable in those shells.

Fixes #151
2016-09-25 02:42:46 -07:00
Daniel Imms 71e20801f0 Fix tests 2016-09-25 02:07:53 -07:00
Daniel Imms bae1bd6a42 Fix tests 2016-09-25 02:02:05 -07:00
Daniel Imms c8b194931f Sync scroll bar after reset
Fixes #278
2016-09-25 01:56:03 -07:00
Daniel Imms c7a4881552 Sync scroll bar instead of disabling on enter app mode
Fixes #286
2016-09-25 01:50:49 -07:00
Paris Kasidiaris 26fd963fbd Merge pull request #283 from iMoses/master
Workaround a known bug in Babel JS
2016-09-22 14:46:02 +01:00
imoses 122a34b40e Merge branch 'master' of https://github.com/sourcelair/xterm.js 2016-09-22 16:28:20 +03:00
imoses 33abd69e85 Tests were failing locally due to a babel js bug - https://github.com/babel/babel/issues/3826
Fixed the tests to work around the problem and added /.idea/ to .gitignore for the benefit of contributors who uses intellij
2016-09-22 16:26:03 +03:00
Paris Kasidiaris 76a686beb2 Merge pull request #282 from sourcelair/get-option
Add `getOption` API
2016-09-21 17:14:39 +01:00
Paris Kasidiaris 53e8ac9b0c Stricter check for option existence 2016-09-21 19:09:55 +03:00
Paris Kasidiaris 4b459fe0fd Implement term.getOption 2016-09-21 13:56:03 +03:00
Daniel Imms be4c8341ba Merge pull request #275 from Tyriar/move_comments_inside_case
Move key handler comments inside case blocks
2016-09-18 13:49:52 -07:00
Daniel Imms a33bc027f1 Merge pull request #274 from Tyriar/205_cancel_shift_pg_up_down_event
Cancel keydown event on shift+page up/down
2016-09-18 13:49:38 -07:00
Daniel Imms 3c9d8b0d84 Merge pull request #276 from Tyriar/173_clear_api
Expose API to clear the terminal
2016-09-17 04:11:20 -07:00
Daniel Imms 26fc53990b Fix clear function when buffer is <= rows 2016-09-17 04:07:36 -07:00
Daniel Imms 852dac4d62 Don't clear prompt on clear if it already is 2016-09-17 03:59:42 -07:00
Daniel Imms 76719413f9 Expose API to clear the terminal
Fixes #173
2016-09-17 02:39:22 -07:00
Daniel Imms fca673d653 Move key handler comments inside case blocks
Improves readability
2016-09-17 01:11:43 -07:00
Daniel Imms 446c3958df Cancel keydown even on shift+page up/down
Fixes #205
2016-09-17 01:09:08 -07:00
Daniel Imms 59e72b8b07 Merge pull request #272 from Tyriar/271_setOption
Add setOption API
2016-09-16 02:17:28 -07:00
Daniel Imms 15e56bd809 Add @param to setOption 2016-09-16 02:03:31 -07:00
Daniel Imms ab5cc0ad05 Add setOption API
Fixes #271
2016-09-16 01:46:02 -07:00
Daniel Imms b89bce17ad Merge pull request #268 from Tyriar/267_fix_mouseup_focus
Fix focus on mouseup when mousedown was in another element
2016-09-16 01:23:57 -07:00
Daniel Imms 7fcbddac04 Set package.json main to build/xterm.js
build/xterm.js should be used when require is used when installed via npm.
2016-09-15 16:25:22 -07:00
Daniel Imms 4e1bbee67e Fix focus on mouseup when mousedown was in another element
Fixes #267
2016-09-15 13:50:39 -07:00
Paris Kasidiaris ecfa44b0e8 Merge pull request #263 from sourcelair/fix-indentation
Fix indentation of `src/xterm.js`
2016-09-05 13:18:49 +03:00
Paris Kasidiaris db76868c26 Fix indentation of src/xterm.js 2016-09-04 16:47:21 +03:00
Paris Kasidiaris b4c7989566 Merge pull request #252 from ayapi/modifier-keys
add modifier+delete, modifier+F1-F12 keys
2016-09-04 16:23:29 +03:00
Paris Kasidiaris 7b38b9ed57 Merge pull request #261 from yurovant/patch-1
Update README.md
2016-09-02 11:54:25 +03:00
Anton Yurovskykh c2fccc0350 Update README.md
Fix typo: is => if
2016-09-02 09:28:57 +03:00
Daniel Imms b56ad5e8fe Merge pull request #243 from Tyriar/242_enable_scroll_on_soft_reset
Disable application mode in viewport on soft reset
2016-08-31 10:40:54 -07:00
Daniel Imms abfcf27962 Merge pull request #256 from Tyriar/254_compositionhelper_module
Pull CompositionHelper into a module
2016-08-31 10:34:14 -07:00
Daniel Imms 6a04614549 Merge remote-tracking branch 'upstream/master' into 254_compositionhelper_module 2016-08-29 16:50:35 -07:00
Daniel Imms 89f981836f Merge pull request #255 from Tyriar/253_viewport_module
Pull Viewport into a module
2016-08-29 16:49:03 -07:00
Paris Kasidiaris 33d4d400f0 Merge pull request #257 from Tyriar/improve_copyright_line
Improve copyright line
2016-08-30 02:38:41 +03:00
Daniel Imms 749ed6372a Improve copyright line 2016-08-29 16:21:00 -07:00
Daniel Imms 81fccee906 Add copyright line 2016-08-29 16:20:11 -07:00
Daniel Imms 4caac78241 Improve copyright line 2016-08-29 16:19:27 -07:00
Daniel Imms 7ff03bb475 Pull Viewport into a module
Fixes #253
2016-08-29 16:17:59 -07:00
Daniel Imms 28c3a2026c Pull CompositionHelper into a module
Fixes #254
2016-08-29 16:15:28 -07:00
Paris Kasidiaris a9c85fe825 Merge pull request #251 from sourcelair/issue-#158-es2015
Introduce Babel as the build system, convert src/xterm.js to ES2015 and export EventEmitter
2016-08-30 01:59:17 +03:00
Paris Kasidiaris c46e799dd0 Update README.md to include xterm.js from new directory 2016-08-29 22:57:19 +03:00
Paris Kasidiaris ed1a31d1cf Make src/xterm.js ES2015 and export EventEmitter into its own file
Fix #158
2016-08-29 19:51:40 +00:00
ayapi 7f7156bafa add modifier+F1-F12 keys 2016-08-27 01:13:01 +09:00
ayapi 62ce64f97d add modifier+delete keys 2016-08-27 01:03:35 +09:00
Paris Kasidiaris 04a226f813 Merge pull request #249 from sourcelair/Tyriar-patch-3
Improve grammar
2016-08-26 03:40:16 +03:00
Daniel Imms 68b012ca06 Improve grammar 2016-08-25 14:46:20 -07:00
Paris Kasidiaris 220828f7db Bump version to 1.1.3
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-08-23 22:44:55 +00:00
Paris Kasidiaris 7df7f8f598 Merge pull request #246 from sourcelair/bin-release
Improve "prepare-release" and introduce "release" scripts
2016-08-24 01:47:17 +03:00
Paris Kasidiaris 05aff199b2 Improve "prepare-release" and introduce "release" scripts
Has to do with #244.
2016-08-24 01:43:37 +03:00
Daniel Imms fc22fc39e2 Disable application mode in viewport on soft reset
Fixes #242
2016-08-23 09:11:02 -07:00
Paris Kasidiaris 01c20807c2 Bump version to 1.1.2
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-08-22 14:26:27 +00:00
Paris Kasidiaris 243ce59806 Merge pull request #240 from sourcelair/issue/239
Fix alt + arrow key movement
2016-08-22 17:28:23 +03:00
Paris Kasidiaris 5d6e0356b3 Add tests for arrow key movements 2016-08-22 17:21:58 +03:00
Paris Kasidiaris 8324b43cc2 Fix Alt + Arrow movement
Fix #239
2016-08-22 17:17:58 +03:00
Paris Kasidiaris 4c3ccc264c Bump version to 1.1.1
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2016-08-22 13:11:54 +00:00
Paris Kasidiaris 197c83d993 Merge pull request #234 from Tyriar/233_fix_cursor_on_top_of_ime
Ensure composition view is on top of cursor
2016-08-22 16:14:15 +03:00
Paris Kasidiaris aaded29855 Merge pull request #238 from sourcelair/gitter-badge
Add "Chat on Gitter" badge
2016-08-22 14:47:21 +03:00
Paris Kasidiaris e5656b9982 Add "Chat on Gitter" badge 2016-08-22 14:40:34 +03:00
Paris c06b08df5b Bump version to 1.1.0
Signed-off-by: Paris <paris@sourcelair.com>
2016-08-22 11:22:21 +00:00
Daniel Imms fc16752cec Merge pull request #236 from Tyriar/235_fix_scroll_to_top_on_app_mode
Disable onScroll event during application mode
2016-08-21 00:58:47 -07:00
Daniel Imms 588d3b12e0 Disable onScroll event during application mode
Fixes #235
2016-08-19 12:52:13 -07:00
Daniel Imms 7de7bdac71 Ensure composition view is on top of cursor
Fixes #233
2016-08-18 11:28:10 -07:00
Paris Kasidiaris 6e8e78db57 Merge pull request #230 from ayapi/refresh-viewport-height
Refresh the height of the viewport when the line-height changed
2016-08-18 20:35:39 +03:00
ayapi dcc991bd5c refresh the height of the viewport when the line-height changed 2016-08-18 19:37:16 +09:00
Daniel Imms 04cb9f33ff Merge pull request #226 from Tyriar/208_fix_ime_popup_pos
Reposition textview after composition view
2016-08-17 08:50:41 -07:00
Paris Kasidiaris 9bd167c10d Merge pull request #231 from meefik/patch-1
Fix incorrect mouse position
2016-08-17 11:57:16 +03:00
Anton Skshidlevsky dc6aab88b0 Fix incorrect mouse position
Incorrect mouse position in Midnight Commander
2016-08-17 10:38:12 +03:00
Paris Kasidiaris 43fc6f1fa3 Merge pull request #228 from ayapi/restore-customkeydownhandler
restore customKeydownHandler on reset(RIS)
2016-08-16 17:20:40 +03:00
ayapi c2aa0d75ec restore customKeydownHandler on reset(RIS) 2016-08-13 22:44:56 +09:00
Daniel Imms c24ae84b00 Fix tests 2016-08-12 10:27:49 -07:00
Daniel Imms 92605a9734 Reposition textview after composition view
Call the function again via setTimeout to allow changes after composition
events. This prevents the IME windows jumping sometimes on thesecond key
press.

Fixes #208
2016-08-12 10:21:41 -07:00
Daniel Imms b32a34b97c Merge pull request #224 from sourcelair/Tyriar-patch-2
Sync scroll bar height if the viewport height changes
2016-08-09 09:03:16 -07:00
Daniel Imms 12923a6649 Sync scroll bar height if the viewport height changes 2016-08-08 14:41:39 -07:00
Daniel Imms e7c7160f85 Merge pull request #218 from Tyriar/77_scroll_bar
Implement scroll bar
2016-08-08 12:52:12 -07:00
Paris Kasidiaris 2a0962183e Merge pull request #223 from sourcelair/Tyriar-patch-1
By more explicit in security warning
2016-08-08 20:14:14 +01:00
Daniel Imms 95d9ad46cf By more explicit in security warning
Calling out that the insecurity is due to the barebones implementation
of the demo will prevent people thinking that the library is inherently
insecure.
2016-08-08 10:38:01 -07:00
Daniel Imms e60513f554 Fix outline showing up when clicking terminal 2016-08-08 10:22:34 -07:00
Daniel Imms a557a82b40 Fix scrollbar being transparent on OS X 2016-08-08 10:22:19 -07:00
Paris Kasidiaris 3dd6f368d6 Merge pull request #220 from sourcelair/improve-demo
Introduce resizing option in demo
2016-08-08 14:35:02 +01:00
Paris 5ce012bdac Add notice about security risks 2016-08-08 16:28:29 +03:00
Paris Kasidiaris a2338c49b9 Merge pull request #222 from sourcelair/signed-releases
Require release commits to be signed
2016-08-05 14:56:00 +01:00
Paris Kasidiaris dd6886f358 Merge pull request #221 from odino/patch-1
Update pty.js
2016-08-05 14:55:14 +01:00
Paris 5ddf6301c2 Add Sign-Off flag as well 2016-08-05 16:49:04 +03:00
Paris 14dd2c0afb Require release commits to be signed 2016-08-05 11:21:27 +00:00
Alessandro Nadalin fc2a0d3e65 Update pty.js 2016-08-05 13:59:21 +04:00
Paris 0f8fc63a5e First functional resizing demo
Fix #211
2016-08-05 12:28:22 +03:00
Paris f57a40eeb3 First batch of improvements to demo
- Used fetch tentatively
- Implemented resize endpoint
- Create terminals with the appropriate size
2016-08-05 08:46:49 +00:00
Daniel Imms 2c9c95f531 Add another test 2016-08-04 18:56:33 -07:00
Daniel Imms 7048f6edf7 Add some tests, fix app keypad mode bug 2016-08-04 18:34:04 -07:00
Paris Kasidiaris c333cfa073 Merge pull request #214 from mentos1386/mentos1386-linkify
Make linkify links open in new tab/window
2016-08-04 14:31:29 +01:00
Tine Jozelj 64d77d2491 Making it more human readable 2016-08-04 15:22:45 +02:00
Tine Jozelj 9604674c65 Default without target atribute 2016-08-04 15:05:09 +02:00
Tine Jozelj d9294779a6 Add target as option
You can now provide target argument if you want to modify target attribute on links. It defaults to `_self` to keep current behavior.
2016-08-04 14:58:42 +02:00
Paris Kasidiaris 3117fe9465 Merge pull request #219 from sourcelair/issue/198
Update README and remove screenshot
2016-08-04 11:07:20 +01:00
Paris 0a74b9aa3b Fix typos 2016-08-04 13:00:47 +03:00
Paris 7e90576391 Update README and remove screenshot 2016-08-04 12:01:37 +03:00
Daniel Imms 0a34885fbc Fix line-height after rowContainer moved out of viewport 2016-08-03 18:27:43 -07:00
Daniel Imms 61201525a8 Remaining jsdoc 2016-08-03 18:27:19 -07:00
Daniel Imms 1b886a4420 Disable the scroll bar when in application keypad mode 2016-08-03 18:12:44 -07:00
Daniel Imms 6f70984ab6 Drop support for old mouse wheel APIs
All browsers have supported the WheelEvent (onwheel) for sometime now, since
Firefox does not support onmousewheel which is also non-standard but works with
the standard interface, it makes sense to drop support now.
2016-08-03 13:41:55 -07:00
Daniel Imms 38fa2d78da Support DOMMouseScroll event (Firefox) 2016-08-03 13:00:07 -07:00
Daniel Imms fe905bace5 Prevent the page from scrolling when the terminal scrolls 2016-08-03 12:49:12 -07:00
Daniel Imms e7e1434293 Clean up, refresh sizes when font-size changes 2016-08-03 12:47:36 -07:00
Daniel Imms 363c647a5f Sync scroll bar on more sensible events 2016-08-03 11:27:16 -07:00
Daniel Imms aac60eb029 Add support for WheelEvent.deltaMode 2016-08-03 10:16:08 -07:00
Daniel Imms 06ca03ae9c Get it working 2016-08-02 18:36:24 -07:00
Daniel Imms ff927b8e79 Implement basic scroll bar 2016-08-02 16:59:50 -07:00
Daniel Imms 670b0d58c7 Add base viewport, set line height
Fixes #149
2016-08-02 12:42:13 -07:00
Tine Jozelj 3113cdf0ea Make linkify links open in new tab/window
I believe this behavior is more appropriate.
2016-08-02 15:57:15 +02:00
Paris Kasidiaris d2cef6f29d Merge pull request #210 from Tyriar/209_hide_textarea_when_not_composing
Hide textarea off-screen when not composing
2016-08-01 11:35:06 +03:00
Daniel Imms d62bd5f748 Get rid of rogue whitespace 2016-07-28 11:15:20 -07:00
Daniel Imms e6fd1381ce Hide textarea off-screen when not composing
Fixes #209
2016-07-28 11:13:24 -07:00
Daniel Imms 65b2be7831 Merge pull request #186 from Tyriar/118_support_custom_keydown_handler
Allow custom keydown handler to be attached
2016-07-22 05:21:28 -07:00
Daniel Imms e2d0de2686 Fix test 2016-07-22 05:18:28 -07:00
Daniel Imms 495b2d7fbb Merge remote-tracking branch 'upstream/master' into 118_support_custom_keydown_handler 2016-07-22 05:12:52 -07:00
Paris Kasidiaris 5e662d0eb7 Merge pull request #203 from Tyriar/124_fix_focus_blur
Correct blur/focus delegation
2016-07-22 14:26:48 +03:00
Daniel Imms 892db98c96 Correct blur/focus delegation
Focus and blur events on the Terminal object are delegated to the textarea
which handles everything.
2016-07-22 04:14:05 -07:00
Paris Kasidiaris 10fbf0dccc Merge pull request #175 from Tyriar/124_add_textarea_back
Add textarea back and support IMEs
2016-07-22 11:50:23 +03:00
Daniel Imms 4595a18197 Tidy up blur/focus handlers 2016-07-21 10:51:43 -07:00
Daniel Imms 577a3d81e5 Use explicit boolean comparison 2016-07-21 10:32:20 -07:00
Paris Kasidiaris 55fb5dbcb5 Merge pull request #200 from jerch/fix_193
fixing arrow key sequences
2016-07-21 15:00:17 +03:00
Jörg Breitbart 8e7eeff45c fixing test cases 2016-07-21 12:47:19 +02:00
Jörg Breitbart ec7130b46f fixing arrow key sequences 2016-07-21 12:39:36 +02:00
Daniel Imms 0010a5a109 Explicitly return from keydown 2016-07-15 16:33:30 -07:00
Daniel Imms 9cb5b005bb Add tests 2016-07-15 16:31:57 -07:00
Daniel Imms 06a3aa6cf8 Merge remote-tracking branch 'upstream/master' into 118_support_custom_keydown_handler 2016-07-15 16:21:06 -07:00
Daniel Imms d4e9d34d2d Allow custom keydown handler to be attached
Fixes #118
2016-07-15 16:16:37 -07:00
Daniel Imms a3a7017f6b Fix tests 2016-07-15 10:22:31 -07:00
Daniel Imms fedc1fd325 Fix keydown conditional 2016-07-15 10:17:29 -07:00
Daniel Imms 11d5f51e67 Merge remote-tracking branch 'upstream/master' into 124_add_textarea_back 2016-07-15 10:13:56 -07:00
Daniel Imms 534a9e7f5a Big clean up
Move keydown event to CompositionHelper
Move call in refresh to be handled with an event
2016-07-13 21:50:00 -07:00
Daniel Imms 14a62c0f8b Add test cases for Japanese 2016-07-13 21:22:27 -07:00
Daniel Imms 89d29bbc10 Fix non-composition char input after composition char + test 2016-07-13 21:02:43 -07:00
Daniel Imms ac8db6e8ec jsdoc handleAnyTextareaChanges 2016-07-13 20:52:55 -07:00
Daniel Imms 0a7c1bfd98 Position the textarea below the cursor during a composition
This will position any IME helper in the correct position
2016-07-13 20:46:43 -07:00
Daniel Imms 4efb8d24ac Don't wrap multi-character compositions 2016-07-13 20:34:55 -07:00
Daniel Imms 38d08873bc Don't finalize composition on modifier key presses 2016-07-13 20:34:43 -07:00
Daniel Imms 8074d754d3 Only position composition view if a cursor is visible 2016-07-13 20:12:49 -07:00
Daniel Imms e1c1b07a0b Add test cases for Korean 2016-07-13 08:37:24 -07:00
Daniel Imms c18794f202 Merge remote-tracking branch 'upstream/master' into 124_add_textarea_back 2016-07-13 07:14:14 -07:00
Daniel Imms 8b46e84263 Use correct .terminal-cursor for composition view 2016-07-12 21:42:10 -07:00
Daniel Imms 237e6819bf Fix tests 2016-07-12 20:55:24 -07:00
Daniel Imms 8faea59e31 Handle non-composition input when IME is active 2016-07-12 20:51:55 -07:00
Daniel Imms cab79c473f jsdoc and tidy up 2016-07-12 20:26:18 -07:00
Daniel Imms c656ed04b0 Use handler not write, fix other edge cases 2016-07-12 20:19:26 -07:00
Daniel Imms 29000fb79e Refactor into CompositionHelper object 2016-07-12 19:14:56 -07:00
Daniel Imms 03fa017d4a Re-hide the textarea 2016-07-12 18:49:37 -07:00
Daniel Imms 26af6ffd4d Get IMEs working 2016-07-12 18:48:08 -07:00
Daniel Imms 7d8e28a7dd Merge remote-tracking branch 'upstream/master' into 124_add_textarea_back 2016-07-12 17:02:11 -07:00
Daniel Imms a52b7e7a4e Add starting point for IME support 2016-07-12 16:50:07 -07:00
Daniel Imms aaedcfc700 Support focus class on the .xterm element 2016-07-12 16:18:05 -07:00
Daniel Imms fc7b22dc48 Manually revert textarea changes 2016-07-12 16:03:31 -07:00
206 changed files with 14849 additions and 5150 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.js]
[*.{j,t}s]
max_line_length = 100
[*.css]
+4 -2
View File
@@ -1,8 +1,7 @@
node_modules/
*.swp
build/*
.lock-wscript
out/
lib/
Makefile.gyp
*.Makefile
*.target.gyp.mk
@@ -10,3 +9,6 @@ Makefile.gyp
example/*.log
docs/
npm-debug.log
/.idea/
.env
build/
+16
View File
@@ -0,0 +1,16 @@
node_modules/
*.swp
.lock-wscript
lib/*.test.js
lib/*.test.js.map
lib/test/
Makefile.gyp
*.Makefile
*.target.gyp.mk
*.node
example/*.log
docs/
npm-debug.log
/.idea/
.env
build/
+7 -2
View File
@@ -1,8 +1,12 @@
language: node_js
node_js:
- 4
- 6
env:
- CXX=g++-4.8
global:
- CXX=g++-4.8
matrix:
- NPM_COMMAND=lint
- NPM_COMMAND=test
addons:
apt:
sources:
@@ -11,3 +15,4 @@ addons:
- g++-4.8
notifications:
email: false
script: npm run $NPM_COMMAND
+15
View File
@@ -1,19 +1,34 @@
List of xterm.js contributors. Updated before every release.
Alessandro Nadalin <alessandro.nadalin@gmail.com>
Alexander Olsson <noseglid@gmail.com>
Antonis Kalipetis <akalipetis@sourcelair.com>
Anton Skshidlevsky <meefik@gmail.com>
Anton Yurovskykh <anton.yurovskykh@gmail.com>
Austin Robertson <austinrobertson@gmail.com>
ayapi <colors.aya@gmail.com>
Benjamin Fischer <benjamin.fischer@rwth-aachen.de>
bottleofwater <nison.mael+bottleofwater@gmail.com>
Carson Anderson <carson@betterservers.com>
Christian Budde Christensen <budde377@gmail.com>
Christopher Jeffrey <chjjeffrey@gmail.com>
Daniel Imms <daimms@microsoft.com>
Daniel Risacher <drisacher@gmail.com>
Dan Kaplun <dbkaplun@twitch.tv>
Darin Morrison <freebroccolo@users.noreply.github.com>
Elliot Saba <staticfloat@gmail.com>
hiro-su <h.sugipon@gmail.com>
Ian Lewis <ianlewis@google.com>
imoses <ido@twiggle.com>
Jean Bruenn <himself@jeanbruenn.info>
Jörg Breitbart <jerch@rockborn.de>
Maël Nison <nison.mael@gmail.com>
Mikko Karvonen <mikko.karvonen@arm.com>
Paris Kasidiaris <pariskasidiaris@gmail.com>
Paris Kasidiaris <paris@sourcelair.com>
runarberg <runar@greenqloud.com>
Shuanglei Tao <tsl0922@gmail.com>
Steven Silvester <steven.silvester@ieee.org>
Thanasis Daglis <thanasis@sourcelair.com>
Tine Jozelj <tine.jozelj@outlook.com>
YuviPanda <yuvipanda@gmail.com>
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2014, sourceLair Limited (https://github.com/sourcelair/)
Copyright (c) 2014-2016, SourceLair Private Company (https://www.sourcelair.com)
Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/)
Permission is hereby granted, free of charge, to any person obtaining a copy
+37 -11
View File
@@ -1,18 +1,36 @@
# xterm.js
![xterm.js build status](https://api.travis-ci.org/sourcelair/xterm.js.svg)
[![xterm.js build status](https://api.travis-ci.org/sourcelair/xterm.js.svg)](https://travis-ci.org/sourcelair/xterm.js) [![Gitter](https://badges.gitter.im/sourcelair/xterm.js.svg)](https://gitter.im/sourcelair/xterm.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
Xterm.js is a full xterm clone, written in JavaScript.
Xterm.js is a terminal front-end component written in JavaScript that works in the browser.
It is used at [SourceLair](https://www.sourcelair.com/home) to help people develop their applications in their browsers.
It enables applications to provide fully featured terminals to their users and create great development experiences.
Xterm.js supplies a modular, event-based interface that lets developers build addons and themes on top of it.
## Features
- **Text-based application support**: Use xterm.js to work with applications like `bash`, `git` etc.
- **Curses-based application support**: Use xterm.js to work with applications like `vim`, `tmux` etc.
- **Mouse events support**: Xterm.js captures mouse events like click and scroll and passes them to the terminal's back-end controlling process
- **CJK (Chinese, Japanese, Korean) character support**: Xterm.js renders CJK characters seamlessly
- **IME support**: Insert international (including CJK) characters using IME input with your keyboard
- **Self-contained library**: Xterm.js works on its own. It does not require any external libraries like jQuery or React to work
- **Modular, event-based API**: Lets you build addons and themes with ease
![xterm.js screenshot](xtermjs.png)
## What xterm.js is not
- Xterm.js is not a terminal application that you can download and use on your computer
- Xterm.js is not `bash`. Xterm.js can be connected to processes like `bash` and let you interact with them (provide input, receive output)
## Real-world uses
Xterm.js is used in several world-class applications to provide great terminal experiences.
- [**SourceLair**](https://www.sourcelair.com/): In-browser IDE that provides its users with fully-featured Linux terminals based on xterm.js
- [**Microsoft Visual Studio Code**](http://code.visualstudio.com/): Modern, versatile and powerful open source code editor that provides an integrated terminal based on xterm.js
- [**ttyd**](https://github.com/tsl0922/ttyd): A command-line tool for sharing terminal over the web, with fully-featured terminal emulation based on xterm.js
Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list.
## Browser Support
Since xterm.js is typically implemented as a developer tool, only modern browsers are supported officially. Here is a list of the versions we aim to support:
Since xterm.js is typically implemented as a developer tool, only modern browsers are supported officially. Here is a list of the versions we aim to support:
- Chrome 48+
- Edge 13+
@@ -21,7 +39,7 @@ Since xterm.js is typically implemented as a developer tool, only modern browser
- Opera 35+
- Safari 8+
xterm.js may work on earlier versions of the browsers but these are the browsers we strive to keep working.
Xterm.js works seamlessly in Electron apps and may even work on earlier versions of the browsers but these are the browsers we strive to keep working.
## Demo
@@ -32,17 +50,17 @@ npm install
npm start
```
Then open http://0.0.0.0:3000 in a web browser (use http://127.0.0.1:3000 is running under Windows).
Then open http://0.0.0.0:3000 in a web browser (use http://127.0.0.1:3000 if running under Windows).
## Addons
Addons are JavaScript modules that attach functions to the `Terminal` prototype to extend its functionality. There are a handful available in the main repository in the `addons` directory, you can even write your own (though they may break when the internals of xterm.js change across versions).
Addons are JavaScript modules that attach functions to the `Terminal` prototype to extend its functionality. There are a handful available in the main repository in the `dist/addons` directory, you can even write your own (though they may break when the internals of xterm.js change across versions).
To use an addon, just include the JavaScript file after xterm.js and before the `Terminal` object has been instantiated. The function should then be exposed on the `Terminal` object:
```html
<script src="node_modules/src/xterm.js"></script>
<script src="node_modules/addons/fit/fit.js"></script>
<script src="node_modules/dist/xterm.js"></script>
<script src="node_modules/dist/addons/fit/fit.js"></script>
```
```js
@@ -51,8 +69,16 @@ var xterm = new Terminal();
xterm.fit();
```
## Releases
Xterm.js follows a monthly release cycle roughly.
The existing releases are available at this GitHub repo's [Releases](https://github.com/sourcelair/xterm.js/releases), while the roadmap is available as [Milestones](https://github.com/sourcelair/xterm.js/milestones).
## Development and Contribution
Xterm.js is maintained by [SourceLair](https://www.sourcelair.com/) and a few external contributors, but we would love to receive contributions from everyone!
To contribute either code, documentation or issues to xterm.js please read the [Contributing document](CONTRIBUTING.md) before.
The development of xterm.js does not require any special tool. All you need is an editor that supports JavaScript and a browser (if you would like to run the demo you will need Node.js to get all features).
Executable
+36
View File
@@ -0,0 +1,36 @@
#! /usr/bin/env bash
set -e
# $BUILD_DIR should default to "build"
BUILD_DIR=${BUILD_DIR:=build}
# Create the build directory
mkdir -p $BUILD_DIR
# Clean lib/* to prevent confusion if files were deleted in src/
rm -rf lib/*
# Build all TypeScript files (including tests) to lib/
tsc
# Concat all xterm.js files into a single file and output as a UMD to $BUILD_DIR/xterm.js
browserify ./lib/xterm.js --standalone Terminal --debug --outfile ./$BUILD_DIR/xterm.js
cat ./$BUILD_DIR/xterm.js | exorcist ./$BUILD_DIR/xterm.js.map -b ./$BUILD_DIR > ./$BUILD_DIR/xterm.temp.js
rm ./$BUILD_DIR/xterm.js
mv ./$BUILD_DIR/xterm.temp.js ./$BUILD_DIR/xterm.js
# Resolve the chain of sourcemaps so that ./$BUILD_DIR/xterm.js.map points at ./src
sorcery -i $BUILD_DIR/xterm.js
# Copy all CSS files from src/ to $BUILD_DIR/ and lib/
cd src
find . -name '*.css' | cpio -pdm ../$BUILD_DIR
find . -name '*.css' | cpio -pdm ../lib
cd ..
# Copy addons from lib/ to $BUILD_DIR/
cd lib/addons
find . -name '*.js' | cpio -pdm ../../$BUILD_DIR/addons
cd ../..
+11 -4
View File
@@ -3,6 +3,8 @@
# Usage: ./bin/prepare-release x.y.z
# x.y.z should be semver (e.g. 1.0.0)
set -e
NEW_VERSION=$1
CURRENT_PACKAGE_JSON_VERSION=$(cat package.json \
| grep version \
@@ -17,11 +19,16 @@ CURRENT_BOWER_JSON_VERSION=$(cat bower.json \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
# Update version in package.json and bower.json
sed -i "s/\"version\": \"$CURRENT_PACKAGE_JSON_VERSION\"/\"version\": \"$NEW_VERSION\"/g" package.json
sed -i "s/\"version\": \"$CURRENT_BOWER_JSON_VERSION\"/\"version\": \"$NEW_VERSION\"/g" bower.json
# Build xterm.js into `dist`
export BUILD_DIR=dist
./bin/build
# Update AUTHORS file
sh bin/generate-authors
git commit -a -m "Bump version to $NEW_VERSION"
# Update version in package.json and bower.json
sed -i "s/\"version\": \"$CURRENT_PACKAGE_JSON_VERSION\"/\"version\": \"$NEW_VERSION\"/g" package.json
sed -i "s/\"version\": \"$CURRENT_BOWER_JSON_VERSION\"/\"version\": \"$NEW_VERSION\"/g" bower.json
git commit -S -s -a -m "Bump version to $NEW_VERSION"
git tag $NEW_VERSION
Executable
+22
View File
@@ -0,0 +1,22 @@
#! /usr/bin/env sh
# Usage: ./bin/release x.y.z
# x.y.z should be semver (e.g. 1.0.0)
set -e
if [ -z "$1" ];
then
echo "No version supplied. Please a version argument\n"
echo "Usage: $0 VERSION\n"
echo "Example: $0 1.0.0"
exit
fi
NEW_VERSION=$1
./bin/prepare-release $NEW_VERSION
git push && \
git push --tags && \
npm publish
+6 -2
View File
@@ -1,5 +1,9 @@
{
"name": "xterm.js",
"version": "1.0.0",
"ignore": ["demo", "test", ".gitignore"]
"version": "2.2.3",
"ignore": ["demo", "test", ".gitignore"],
"main": [
"dist/xterm.js",
"dist/xterm.css"
]
}
+44 -13
View File
@@ -4,8 +4,10 @@ var expressWs = require('express-ws')(app);
var os = require('os');
var pty = require('pty.js');
app.use('/src', express.static(__dirname + '/../src'));
app.use('/addons', express.static(__dirname + '/../addons'));
var terminals = {},
logs = {};
app.use('/build', express.static(__dirname + '/../build'));
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
@@ -19,17 +21,43 @@ app.get('/main.js', function(req, res){
res.sendFile(__dirname + '/main.js');
});
app.ws('/bash', function(ws, req) {
/**
* Open bash terminal and attach it
*/
var term = pty.spawn(process.platform === 'win32' ? 'cmd.exe' : 'bash', [], {
name: 'xterm-color',
cols: 80,
rows: 24,
cwd: process.env.PWD,
env: process.env
app.post('/terminals', function (req, res) {
var cols = parseInt(req.query.cols),
rows = parseInt(req.query.rows),
term = pty.spawn(process.platform === 'win32' ? 'cmd.exe' : 'bash', [], {
name: 'xterm-color',
cols: cols || 80,
rows: rows || 24,
cwd: process.env.PWD,
env: process.env
});
console.log('Created terminal with PID: ' + term.pid);
terminals[term.pid] = term;
logs[term.pid] = '';
term.on('data', function(data) {
logs[term.pid] += data;
});
res.send(term.pid.toString());
res.end();
});
app.post('/terminals/:pid/size', function (req, res) {
var pid = parseInt(req.params.pid),
cols = parseInt(req.query.cols),
rows = parseInt(req.query.rows),
term = terminals[pid];
term.resize(cols, rows);
console.log('Resized terminal ' + pid + ' to ' + cols + ' cols and ' + rows + ' rows.');
res.end();
});
app.ws('/terminals/:pid', function (ws, req) {
var term = terminals[parseInt(req.params.pid)];
console.log('Connected to terminal ' + term.pid);
ws.send(logs[term.pid]);
term.on('data', function(data) {
try {
ws.send(data);
@@ -41,8 +69,11 @@ app.ws('/bash', function(ws, req) {
term.write(msg);
});
ws.on('close', function () {
console.log('close');
process.kill(term.pid);
console.log('Closed terminal ' + term.pid);
// Clean things up
delete terminals[term.pid];
delete logs[term.pid];
});
});
+22 -9
View File
@@ -2,23 +2,36 @@
<html>
<head>
<title>xterm.js demo</title>
<link rel="stylesheet" href="../src/xterm.css" />
<link rel="stylesheet" href="../addons/fullscreen/fullscreen.css" />
<link rel="stylesheet" href="/build/xterm.css" />
<link rel="stylesheet" href="/build/addons/fullscreen/fullscreen.css" />
<link rel="stylesheet" href="style.css" />
<script src="../src/xterm.js" ></script>
<script src="../addons/attach/attach.js" ></script>
<script src="../addons/fit/fit.js" ></script>
<script src="../addons/fullscreen/fullscreen.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
<script src="/build/xterm.js" ></script>
<script src="/build/addons/attach/attach.js" ></script>
<script src="/build/addons/fit/fit.js" ></script>
<script src="/build/addons/fullscreen/fullscreen.js" ></script>
</head>
<body>
<h1>
xterm.js: xterm, in the browser
</h1>
<h1>xterm.js: xterm, in the browser</h1>
<div id="terminal-container"></div>
<div>
<h2>Options</h2>
<label><input type="checkbox" id="option-cursor-blink"> cursorBlink</label>
<div>
<h3>Size</h3>
<div>
<div style="display: inline-block; margin-right: 16px;">
<label for="cols">Columns</label>
<input type="number" id="cols" />
</div>
<div style="display: inline-block; margin-right: 16px;">
<label for="rows">Rows</label>
<input type="number" id="rows" />
</div>
</div>
</div>
</div>
<p><strong>Attention:</strong> The demo is a barebones implementation and is designed for xterm.js evaluation purposes only. Exposing the demo to the public as is would introduce security risks for the host.</p>
<script src="main.js" defer ></script>
</body>
</html>
+58 -13
View File
@@ -1,34 +1,81 @@
var term,
protocol,
socketURL,
socket;
socket,
pid,
charWidth,
charHeight;
var terminalContainer = document.getElementById('terminal-container');
var optionElements = {
cursorBlink: document.querySelector('#option-cursor-blink')
};
var terminalContainer = document.getElementById('terminal-container'),
optionElements = {
cursorBlink: document.querySelector('#option-cursor-blink')
},
colsElement = document.getElementById('cols'),
rowsElement = document.getElementById('rows');
function setTerminalSize () {
var cols = parseInt(colsElement.value),
rows = parseInt(rowsElement.value),
width = (cols * charWidth).toString() + 'px',
height = (rows * charHeight).toString() + 'px';
terminalContainer.style.width = width;
terminalContainer.style.height = height;
term.resize(cols, rows);
}
colsElement.addEventListener('change', setTerminalSize);
rowsElement.addEventListener('change', setTerminalSize);
optionElements.cursorBlink.addEventListener('change', createTerminal);
createTerminal();
function createTerminal() {
// Clean terminal
while (terminalContainer.children.length) {
terminalContainer.removeChild(terminalContainer.children[0]);
}
term = new Terminal({
cursorBlink: optionElements.cursorBlink.checked
});
term.on('resize', function (size) {
if (!pid) {
return;
}
var cols = size.cols,
rows = size.rows,
url = '/terminals/' + pid + '/size?cols=' + cols + '&rows=' + rows;
fetch(url, {method: 'POST'});
});
protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://';
socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/bash';
socket = new WebSocket(socketURL);
socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/terminals/';
term.open(terminalContainer);
term.fit();
socket.onopen = runRealTerminal;
socket.onclose = runFakeTerminal;
socket.onerror = runFakeTerminal;
var initialGeometry = term.proposeGeometry(),
cols = initialGeometry.cols,
rows = initialGeometry.rows;
colsElement.value = cols;
rowsElement.value = rows;
fetch('/terminals?cols=' + cols + '&rows=' + rows, {method: 'POST'}).then(function (res) {
charWidth = Math.ceil(term.element.offsetWidth / cols);
charHeight = Math.ceil(term.element.offsetHeight / rows);
res.text().then(function (pid) {
window.pid = pid;
socketURL += pid;
socket = new WebSocket(socketURL);
socket.onopen = runRealTerminal;
socket.onclose = runFakeTerminal;
socket.onerror = runFakeTerminal;
});
});
}
@@ -64,9 +111,7 @@ function runFakeTerminal() {
if (ev.keyCode == 13) {
term.prompt();
} else if (ev.keyCode == 8) {
/*
* Do not delete the prompt
*/
// Do not delete the prompt
if (term.x > 2) {
term.write('\b \b');
}
+2 -2
View File
@@ -9,8 +9,8 @@ h1 {
}
#terminal-container {
width: 960px;
height: 600px;
width: 800px;
height: 450px;
margin: 0 auto;
padding: 2px;
}
+114
View File
@@ -0,0 +1,114 @@
/**
* Implements the attach method, that attaches the terminal to a WebSocket stream.
* @module xterm/addons/attach/attach
* @license MIT
*/
(function (attach) {
if (typeof exports === 'object' && typeof module === 'object') {
/*
* CommonJS environment
*/
module.exports = attach(require('../../xterm'));
}
else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../xterm'], attach);
}
else {
/*
* Plain browser environment
*/
attach(window.Terminal);
}
})(function (Xterm) {
'use strict';
var exports = {};
/**
* Attaches the given terminal to the given socket.
*
* @param {Xterm} term - The terminal to be attached to the given socket.
* @param {WebSocket} socket - The socket to attach the current terminal.
* @param {boolean} bidirectional - Whether the terminal should send data
* to the socket as well.
* @param {boolean} buffered - Whether the rendering of incoming data
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
exports.attach = function (term, socket, bidirectional, buffered) {
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
term.socket = socket;
term._flushBuffer = function () {
term.write(term._attachSocketBuffer);
term._attachSocketBuffer = null;
clearTimeout(term._attachSocketBufferTimer);
term._attachSocketBufferTimer = null;
};
term._pushToBuffer = function (data) {
if (term._attachSocketBuffer) {
term._attachSocketBuffer += data;
}
else {
term._attachSocketBuffer = data;
setTimeout(term._flushBuffer, 10);
}
};
term._getMessage = function (ev) {
if (buffered) {
term._pushToBuffer(ev.data);
}
else {
term.write(ev.data);
}
};
term._sendData = function (data) {
socket.send(data);
};
socket.addEventListener('message', term._getMessage);
if (bidirectional) {
term.on('data', term._sendData);
}
socket.addEventListener('close', term.detach.bind(term, socket));
socket.addEventListener('error', term.detach.bind(term, socket));
};
/**
* Detaches the given terminal from the given socket
*
* @param {Xterm} term - The terminal to be detached from the given socket.
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
exports.detach = function (term, socket) {
term.off('data', term._sendData);
socket = (typeof socket == 'undefined') ? term.socket : socket;
if (socket) {
socket.removeEventListener('message', term._getMessage);
}
delete term.socket;
};
/**
* Attaches the current terminal to the given socket
*
* @param {WebSocket} socket - The socket to attach the current terminal.
* @param {boolean} bidirectional - Whether the terminal should send data
* to the socket as well.
* @param {boolean} buffered - Whether the rendering of incoming data
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
Xterm.prototype.attach = function (socket, bidirectional, buffered) {
return exports.attach(this, socket, bidirectional, buffered);
};
/**
* Detaches the current terminal from the given socket.
*
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
Xterm.prototype.detach = function (socket) {
return exports.detach(this, socket);
};
return exports;
});
//# sourceMappingURL=attach.js.map
+59
View File
@@ -0,0 +1,59 @@
/**
* Fit terminal columns and rows to the dimensions of its DOM element.
*
* ## Approach
* - Rows: Truncate the division of the terminal parent element height by the terminal row height.
*
* - Columns: Truncate the division of the terminal parent element width by the terminal character
* width (apply display: inline at the terminal row and truncate its width with the current
* number of columns).
* @module xterm/addons/fit/fit
* @license MIT
*/
(function (fit) {
if (typeof exports === 'object' && typeof module === 'object') {
/*
* CommonJS environment
*/
module.exports = fit(require('../../xterm'));
}
else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../xterm'], fit);
}
else {
/*
* Plain browser environment
*/
fit(window.Terminal);
}
})(function (Xterm) {
var exports = {};
exports.proposeGeometry = function (term) {
var parentElementStyle = window.getComputedStyle(term.element.parentElement), parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')), parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17), elementStyle = window.getComputedStyle(term.element), elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')), elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left')), availableHeight = parentElementHeight - elementPaddingVer, availableWidth = parentElementWidth - elementPaddingHor, container = term.rowContainer, subjectRow = term.rowContainer.firstElementChild, contentBuffer = subjectRow.innerHTML, characterHeight, rows, characterWidth, cols, geometry;
subjectRow.style.display = 'inline';
subjectRow.innerHTML = 'W'; // Common character for measuring width, although on monospace
characterWidth = subjectRow.getBoundingClientRect().width;
subjectRow.style.display = ''; // Revert style before calculating height, since they differ.
characterHeight = parseInt(subjectRow.offsetHeight);
subjectRow.innerHTML = contentBuffer;
rows = parseInt(availableHeight / characterHeight);
cols = parseInt(availableWidth / characterWidth);
geometry = { cols: cols, rows: rows };
return geometry;
};
exports.fit = function (term) {
var geometry = exports.proposeGeometry(term);
term.resize(geometry.cols, geometry.rows);
};
Xterm.prototype.proposeGeometry = function () {
return exports.proposeGeometry(this);
};
Xterm.prototype.fit = function () {
return exports.fit(this);
};
return exports;
});
//# sourceMappingURL=fit.js.map
+50
View File
@@ -0,0 +1,50 @@
/**
* Fullscreen addon for xterm.js
* @module xterm/addons/fullscreen/fullscreen
* @license MIT
*/
(function (fullscreen) {
if (typeof exports === 'object' && typeof module === 'object') {
/*
* CommonJS environment
*/
module.exports = fullscreen(require('../../xterm'));
}
else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../xterm'], fullscreen);
}
else {
/*
* Plain browser environment
*/
fullscreen(window.Terminal);
}
})(function (Xterm) {
var exports = {};
/**
* Toggle the given terminal's fullscreen mode.
* @param {Xterm} term - The terminal to toggle full screen mode
* @param {boolean} fullscreen - Toggle fullscreen on (true) or off (false)
*/
exports.toggleFullScreen = function (term, fullscreen) {
var fn;
if (typeof fullscreen == 'undefined') {
fn = (term.element.classList.contains('fullscreen')) ? 'remove' : 'add';
}
else if (!fullscreen) {
fn = 'remove';
}
else {
fn = 'add';
}
term.element.classList[fn]('fullscreen');
};
Xterm.prototype.toggleFullscreen = function (fullscreen) {
exports.toggleFullScreen(this, fullscreen);
};
return exports;
});
//# sourceMappingURL=fullscreen.js.map
+165
View File
@@ -0,0 +1,165 @@
/**
* Methods for turning URL subscrings in the terminal's content into links (`a` DOM elements).
* @module xterm/addons/linkify/linkify
* @license MIT
*/
(function (linkify) {
if (typeof exports === 'object' && typeof module === 'object') {
/*
* CommonJS environment
*/
module.exports = linkify(require('../../xterm'));
}
else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../xterm'], linkify);
}
else {
/*
* Plain browser environment
*/
linkify(window.Terminal);
}
})(function (Xterm) {
'use strict';
var exports = {}, protocolClause = '(https?:\\/\\/)', domainCharacterSet = '[\\da-z\\.-]+', negatedDomainCharacterSet = '[^\\da-z\\.-]+', domainBodyClause = '(' + domainCharacterSet + ')', tldClause = '([a-z\\.]{2,6})', ipClause = '((\\d{1,3}\\.){3}\\d{1,3})', portClause = '(:\\d{1,5})', hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + ')' + portClause + '?', pathClause = '(\\/[\\/\\w\\.-]*)*', negatedPathCharacterSet = '[^\\/\\w\\.-]+', bodyClause = hostClause + pathClause, start = '(?:^|' + negatedDomainCharacterSet + ')(', end = ')($|' + negatedPathCharacterSet + ')', lenientUrlClause = start + protocolClause + '?' + bodyClause + end, strictUrlClause = start + protocolClause + bodyClause + end, lenientUrlRegex = new RegExp(lenientUrlClause), strictUrlRegex = new RegExp(strictUrlClause);
/**
* Converts all valid URLs found in the given terminal line into
* hyperlinks. The terminal line can be either the HTML element itself
* or the index of the termina line in the children of the terminal
* rows container.
*
* @param {Xterm} terminal - The terminal that owns the given line.
* @param {number|HTMLDivElement} line - The terminal line that should get
* "linkified".
* @param {boolean} lenient - The regex type that will be used to identify links. If lenient is
* false, the regex requires a protocol clause. Defaults to true.
* @param {string} target - Sets target="" attribute with value provided to links.
* Default doesn't set target attribute
* @emits linkify
* @emits linkify:line
*/
exports.linkifyTerminalLine = function (terminal, line, lenient, target) {
if (typeof line == 'number') {
line = terminal.rowContainer.children[line];
}
else if (!(line instanceof HTMLDivElement)) {
var message = 'The "line" argument should be either a number';
message += ' or an HTMLDivElement';
throw new TypeError(message);
}
if (typeof target === 'undefined') {
target = '';
}
else {
target = 'target="' + target + '"';
}
var buffer = document.createElement('span'), nodes = line.childNodes;
for (var j = 0; j < nodes.length; j++) {
var node = nodes[j], match;
/**
* Since we cannot access the TextNode's HTML representation
* from the instance itself, we assign its data as textContent
* to a dummy buffer span, in order to retrieve the TextNode's
* HTML representation from the buffer's innerHTML.
*/
buffer.textContent = node.data;
var nodeHTML = buffer.innerHTML;
/**
* Apply function only on TextNodes
*/
if (node.nodeType != node.TEXT_NODE) {
continue;
}
var url = exports.findLinkMatch(node.data, lenient);
if (!url) {
continue;
}
var startsWithProtocol = new RegExp('^' + protocolClause), urlHasProtocol = url.match(startsWithProtocol), href = (urlHasProtocol) ? url : 'http://' + url, link = '<a href="' + href + '" ' + target + '>' + url + '</a>', newHTML = nodeHTML.replace(url, link);
line.innerHTML = line.innerHTML.replace(nodeHTML, newHTML);
}
/**
* This event gets emitted when conversion of all URL susbtrings
* to HTML anchor elements (links) has finished, for a specific
* line of the current Xterm instance.
*
* @event linkify:line
*/
terminal.emit('linkify:line', line);
};
/**
* Finds a link within a block of text.
*
* @param {string} text - The text to search .
* @param {boolean} lenient - Whether to use the lenient search.
* @return {string} A URL.
*/
exports.findLinkMatch = function (text, lenient) {
var match = text.match(lenient ? lenientUrlRegex : strictUrlRegex);
if (!match || match.length === 0) {
return null;
}
return match[1];
};
/**
* Converts all valid URLs found in the terminal view into hyperlinks.
*
* @param {Xterm} terminal - The terminal that should get "linkified".
* @param {boolean} lenient - The regex type that will be used to identify links. If lenient is
* false, the regex requires a protocol clause. Defaults to true.
* @param {string} target - Sets target="" attribute with value provided to links.
* Default doesn't set target attribute
* @emits linkify
* @emits linkify:line
*/
exports.linkify = function (terminal, lenient, target) {
var rows = terminal.rowContainer.children;
lenient = (typeof lenient == "boolean") ? lenient : true;
for (var i = 0; i < rows.length; i++) {
var line = rows[i];
exports.linkifyTerminalLine(terminal, line, lenient, target);
}
/**
* This event gets emitted when conversion of all URL substrings to
* HTML anchor elements (links) has finished for the current Xterm
* instance's view.
*
* @event linkify
*/
terminal.emit('linkify');
};
/**
* Extend Xterm prototype.
*/
/**
* Converts all valid URLs found in the current terminal linte into
* hyperlinks.
*
* @memberof Xterm
* @param {number|HTMLDivElement} line - The terminal line that should get
* "linkified".
* @param {boolean} lenient - The regex type that will be used to identify links. If lenient is
* false, the regex requires a protocol clause. Defaults to true.
* @param {string} target - Sets target="" attribute with value provided to links.
* Default doesn't set target attribute
*/
Xterm.prototype.linkifyTerminalLine = function (line, lenient, target) {
return exports.linkifyTerminalLine(this, line, lenient, target);
};
/**
* Converts all valid URLs found in the current terminal into hyperlinks.
*
* @memberof Xterm
* @param {boolean} lenient - The regex type that will be used to identify links. If lenient is
* false, the regex requires a protocol clause. Defaults to true.
* @param {string} target - Sets target="" attribute with value provided to links.
* Default doesn't set target attribute
*/
Xterm.prototype.linkify = function (lenient, target) {
return exports.linkify(this, lenient, target);
};
return exports;
});
//# sourceMappingURL=linkify.js.map
+122
View File
@@ -0,0 +1,122 @@
/**
* This module provides methods for attaching a terminal to a terminado WebSocket stream.
*
* @module xterm/addons/terminado/terminado
* @license MIT
*/
(function (attach) {
if (typeof exports === 'object' && typeof module === 'object') {
/*
* CommonJS environment
*/
module.exports = attach(require('../../xterm'));
}
else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../xterm'], attach);
}
else {
/*
* Plain browser environment
*/
attach(window.Terminal);
}
})(function (Xterm) {
'use strict';
var exports = {};
/**
* Attaches the given terminal to the given socket.
*
* @param {Xterm} term - The terminal to be attached to the given socket.
* @param {WebSocket} socket - The socket to attach the current terminal.
* @param {boolean} bidirectional - Whether the terminal should send data
* to the socket as well.
* @param {boolean} buffered - Whether the rendering of incoming data
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
exports.terminadoAttach = function (term, socket, bidirectional, buffered) {
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
term.socket = socket;
term._flushBuffer = function () {
term.write(term._attachSocketBuffer);
term._attachSocketBuffer = null;
clearTimeout(term._attachSocketBufferTimer);
term._attachSocketBufferTimer = null;
};
term._pushToBuffer = function (data) {
if (term._attachSocketBuffer) {
term._attachSocketBuffer += data;
}
else {
term._attachSocketBuffer = data;
setTimeout(term._flushBuffer, 10);
}
};
term._getMessage = function (ev) {
var data = JSON.parse(ev.data);
if (data[0] == "stdout") {
if (buffered) {
term._pushToBuffer(data[1]);
}
else {
term.write(data[1]);
}
}
};
term._sendData = function (data) {
socket.send(JSON.stringify(['stdin', data]));
};
term._setSize = function (size) {
socket.send(JSON.stringify(['set_size', size.rows, size.cols]));
};
socket.addEventListener('message', term._getMessage);
if (bidirectional) {
term.on('data', term._sendData);
}
term.on('resize', term._setSize);
socket.addEventListener('close', term.terminadoDetach.bind(term, socket));
socket.addEventListener('error', term.terminadoDetach.bind(term, socket));
};
/**
* Detaches the given terminal from the given socket
*
* @param {Xterm} term - The terminal to be detached from the given socket.
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
exports.terminadoDetach = function (term, socket) {
term.off('data', term._sendData);
socket = (typeof socket == 'undefined') ? term.socket : socket;
if (socket) {
socket.removeEventListener('message', term._getMessage);
}
delete term.socket;
};
/**
* Attaches the current terminal to the given socket
*
* @param {WebSocket} socket - The socket to attach the current terminal.
* @param {boolean} bidirectional - Whether the terminal should send data
* to the socket as well.
* @param {boolean} buffered - Whether the rendering of incoming data
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
Xterm.prototype.terminadoAttach = function (socket, bidirectional, buffered) {
return exports.terminadoAttach(this, socket, bidirectional, buffered);
};
/**
* Detaches the current terminal from the given socket.
*
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
Xterm.prototype.terminadoDetach = function (socket) {
return exports.terminadoDetach(this, socket);
};
return exports;
});
//# sourceMappingURL=terminado.js.map
+2206
View File
File diff suppressed because it is too large Load Diff
+5160
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+6 -6
View File
@@ -1,12 +1,12 @@
{
"source": {
"include": [
"src/xterm.js",
"addons/attach/attach.js",
"addons/fit/fit.js",
"addons/fullscreen/fullscreen.js",
"addons/linkify/linkify.js"
]
"src/"
],
"exclude": [
"src/test/"
],
"excludePattern": "src/.+\\.test\\.(js|ts)$"
},
"opts": {
"readme": "README.md",
+42 -8
View File
@@ -1,28 +1,62 @@
{
"name": "xterm",
"version": "1.0.0",
"version": "2.2.3",
"ignore": [
"demo",
"test",
".gitignore"
],
"main": "src/xterm.js",
"main": "lib/xterm.js",
"repository": "https://github.com/sourcelair/xterm.js",
"license": "MIT",
"files": [
"dist/*.css",
"dist/**/*.css",
"dist/*.js",
"dist/*.js.map",
"dist/**/*.js",
"dist/**/*.js.map",
"lib/*.css",
"lib/**/*.css",
"lib/*.js",
"lib/*.js.map",
"lib/**/*.js",
"lib/**/*.js.map",
"src/*.css",
"src/**/*.css",
"src/*.js",
"src/*.js.map",
"src/*.ts",
"src/**/*.js",
"src/**/*.js.map",
"src/**/*.ts"
],
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/mocha": "^2.2.33",
"@types/node": "^6.0.41",
"browserify": "^13.1.0",
"chai": "3.5.0",
"docdash": "0.4.0",
"exorcist": "^0.4.0",
"express": "4.13.4",
"express-ws": "2.0.0-rc.1",
"glob": "^7.0.5",
"jsdoc": "3.4.0",
"jsdoc": "3.4.3",
"mocha": "2.5.3",
"pty.js": "0.3.0",
"sleep": "^3.0.1"
"nodemon": "1.10.2",
"pty.js": "0.3.1",
"sleep": "^3.0.1",
"sorcery": "^0.10.0",
"tslint": "^4.0.2",
"typescript": "^2.0.3"
},
"scripts": {
"start": "node demo/app",
"test": "mocha --recursive",
"build:docs": "node_modules/.bin/jsdoc -c jsdoc.json"
"start": "nodemon --watch src --watch addons --watch demo --exec bash -c './bin/build && node demo/app'",
"lint": "tslint src/**/*.ts",
"test": "mocha --recursive ./lib",
"build:docs": "jsdoc -c jsdoc.json",
"build": "./bin/build",
"prepublish": "tsc"
}
}
+236
View File
@@ -0,0 +1,236 @@
import { assert } from 'chai';
import { CompositionHelper } from './CompositionHelper';
describe('CompositionHelper', () => {
var terminal;
var compositionHelper;
var compositionView;
var textarea;
var handledText;
beforeEach(() => {
compositionView = {
classList: {
add: () => {},
remove: () => {},
},
getBoundingClientRect: () => {
return { width: 0 };
},
style: {
left: 0,
top: 0
},
textContent: ''
};
textarea = {
value: '',
style: {
left: 0,
top: 0
}
};
terminal = {
element: {
querySelector: () => {
return { offsetLeft: 0, offsetTop: 0 };
}
},
handler: function (text) {
handledText += text;
}
};
handledText = '';
compositionHelper = new CompositionHelper(textarea, compositionView, terminal);
});
describe('Input', () => {
it('Should insert simple characters', function (done) {
// First character 'ㅇ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
textarea.value = 'ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
setTimeout(() => { // wait for any textarea updates
assert.equal(handledText, 'ㅇ');
// Second character 'ㅇ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
textarea.value = 'ㅇㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
setTimeout(() => { // wait for any textarea updates
assert.equal(handledText, 'ㅇㅇ');
done();
}, 0);
}, 0);
}, 0);
}, 0);
});
it('Should insert complex characters', function (done) {
// First character '앙'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
textarea.value = 'ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '아' });
textarea.value = '아';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '앙' });
textarea.value = '앙';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
setTimeout(() => { // wait for any textarea updates
assert.equal(handledText, '앙');
// Second character '앙'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
textarea.value = '앙ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '아' });
textarea.value = '앙아';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '앙' });
textarea.value = '앙앙';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
setTimeout(() => { // wait for any textarea updates
assert.equal(handledText, '앙앙');
done();
}, 0);
}, 0);
}, 0);
}, 0);
}, 0);
}, 0);
}, 0);
}, 0);
});
it('Should insert complex characters that change with following character', function (done) {
// First character '아'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
textarea.value = 'ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '아' });
textarea.value = '아';
setTimeout(() => { // wait for any textarea updates
// Start second character '아' in first character
compositionHelper.compositionupdate({ data: '앙' });
textarea.value = '앙';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: '아' });
textarea.value = '아아'
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
setTimeout(() => { // wait for any textarea updates
assert.equal(handledText, '아아');
done();
}, 0);
}, 0);
}, 0);
}, 0);
}, 0);
});
it('Should insert multi-characters compositions', function (done) {
// First character 'だ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'd' });
textarea.value = 'd';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: 'だ' });
textarea.value = 'だ';
setTimeout(() => { // wait for any textarea updates
// Second character 'あ'
compositionHelper.compositionupdate({ data: 'だあ' });
textarea.value = 'だあ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
setTimeout(() => { // wait for any textarea updates
assert.equal(handledText, 'だあ');
done();
}, 0);
}, 0);
}, 0);
}, 0);
});
it('Should insert multi-character compositions that are converted to other characters with the same length', function (done) {
// First character 'だ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'd' });
textarea.value = 'd';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: 'だ' });
textarea.value = 'だ';
setTimeout(() => { // wait for any textarea updates
// Second character 'ー'
compositionHelper.compositionupdate({ data: 'だー' });
textarea.value = 'だー';
setTimeout(() => { // wait for any textarea updates
// Convert to katakana 'ダー'
compositionHelper.compositionupdate({ data: 'ダー' });
textarea.value = 'ダー';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
setTimeout(() => { // wait for any textarea updates
assert.equal(handledText, 'ダー');
done();
}, 0);
}, 0);
}, 0);
}, 0);
}, 0);
})
it('Should insert multi-character compositions that are converted to other characters with different lengths', function (done) {
// First character 'い'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'い' });
textarea.value = 'い';
setTimeout(() => { // wait for any textarea updates
// Second character 'ま'
compositionHelper.compositionupdate({ data: 'いm' });
textarea.value = 'いm';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: 'いま' });
textarea.value = 'いま';
setTimeout(() => { // wait for any textarea updates
// Convert to kanji '今'
compositionHelper.compositionupdate({ data: '今' });
textarea.value = '今';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
setTimeout(() => { // wait for any textarea updates
assert.equal(handledText, '今');
done();
}, 0);
}, 0);
}, 0);
}, 0);
}, 0);
});
it('Should insert non-composition characters input immediately after composition characters', function (done) {
// First character 'ㅇ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
textarea.value = 'ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
// Second character '1' (a non-composition character)
textarea.value = 'ㅇ1';
setTimeout(() => { // wait for any textarea updates
assert.equal(handledText, 'ㅇ1');
done();
}, 0);
}, 0);
});
});
});
+232
View File
@@ -0,0 +1,232 @@
/**
* @license MIT
*/
import { ITerminal } from './Interfaces';
interface IPosition {
start: number;
end: number;
}
/**
* Encapsulates the logic for handling compositionstart, compositionupdate and compositionend
* events, displaying the in-progress composition to the UI and forwarding the final composition
* to the handler.
*/
export class CompositionHelper {
/**
* Whether input composition is currently happening, eg. via a mobile keyboard, speech input or
* IME. This variable determines whether the compositionText should be displayed on the UI.
*/
private isComposing: boolean;
/**
* The position within the input textarea's value of the current composition.
*/
private compositionPosition: IPosition;;
/**
* Whether a composition is in the process of being sent, setting this to false will cancel any
* in-progress composition.
*/
private isSendingComposition: boolean;
/**
* Creates a new CompositionHelper.
* @param textarea The textarea that xterm uses for input.
* @param compositionView The element to display the in-progress composition in.
* @param terminal The Terminal to forward the finished composition to.
*/
constructor(
private textarea: HTMLTextAreaElement,
private compositionView: HTMLElement,
private terminal: ITerminal
) {
this.isComposing = false;
this.isSendingComposition = false;
this.compositionPosition = { start: null, end: null };
}
/**
* Handles the compositionstart event, activating the composition view.
*/
public compositionstart() {
this.isComposing = true;
this.compositionPosition.start = this.textarea.value.length;
this.compositionView.textContent = '';
this.compositionView.classList.add('active');
}
/**
* Handles the compositionupdate event, updating the composition view.
* @param {CompositionEvent} ev The event.
*/
public compositionupdate(ev: CompositionEvent) {
this.compositionView.textContent = ev.data;
this.updateCompositionElements();
var self = this;
setTimeout(function() {
self.compositionPosition.end = self.textarea.value.length;
}, 0);
}
/**
* Handles the compositionend event, hiding the composition view and sending the composition to
* the handler.
*/
public compositionend() {
this.finalizeComposition(true);
}
/**
* Handles the keydown event, routing any necessary events to the CompositionHelper functions.
* @param ev The keydown event.
* @return Whether the Terminal should continue processing the keydown event.
*/
public keydown(ev: KeyboardEvent) {
if (this.isComposing || this.isSendingComposition) {
if (ev.keyCode === 229) {
// Continue composing if the keyCode is the "composition character"
return false;
} else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) {
// Continue composing if the keyCode is a modifier key
return false;
} else {
// Finish composition immediately. This is mainly here for the case where enter is
// pressed and the handler needs to be triggered before the command is executed.
this.finalizeComposition(false);
}
}
if (ev.keyCode === 229) {
// If the "composition character" is used but gets to this point it means a non-composition
// character (eg. numbers and punctuation) was pressed when the IME was active.
this.handleAnyTextareaChanges();
return false;
}
return true;
}
/**
* Finalizes the composition, resuming regular input actions. This is called when a composition
* is ending.
* @param waitForPropogation Whether to wait for events to propogate before sending
* the input. This should be false if a non-composition keystroke is entered before the
* compositionend event is triggered, such as enter, so that the composition is send before
* the command is executed.
*/
private finalizeComposition(waitForPropogation: boolean) {
this.compositionView.classList.remove('active');
this.isComposing = false;
this.clearTextareaPosition();
if (!waitForPropogation) {
// Cancel any delayed composition send requests and send the input immediately.
this.isSendingComposition = false;
var input = this.textarea.value.substring(this.compositionPosition.start, this.compositionPosition.end);
this.terminal.handler(input);
} else {
// Make a deep copy of the composition position here as a new compositionstart event may
// fire before the setTimeout executes.
var currentCompositionPosition = {
start: this.compositionPosition.start,
end: this.compositionPosition.end,
}
// Since composition* events happen before the changes take place in the textarea on most
// browsers, use a setTimeout with 0ms time to allow the native compositionend event to
// complete. This ensures the correct character is retrieved, this solution was used
// because:
// - The compositionend event's data property is unreliable, at least on Chromium
// - The last compositionupdate event's data property does not always accurately describe
// the character, a counter example being Korean where an ending consonsant can move to
// the following character if the following input is a vowel.
var self = this;
this.isSendingComposition = true;
setTimeout(function () {
// Ensure that the input has not already been sent
if (self.isSendingComposition) {
self.isSendingComposition = false;
var input;
if (self.isComposing) {
// Use the end position to get the string if a new composition has started.
input = self.textarea.value.substring(currentCompositionPosition.start, currentCompositionPosition.end);
} else {
// Don't use the end position here in order to pick up any characters after the
// composition has finished, for example when typing a non-composition character
// (eg. 2) after a composition character.
input = self.textarea.value.substring(currentCompositionPosition.start);
}
self.terminal.handler(input);
}
}, 0);
}
}
/**
* Apply any changes made to the textarea after the current event chain is allowed to complete.
* This should be called when not currently composing but a keydown event with the "composition
* character" (229) is triggered, in order to allow non-composition text to be entered when an
* IME is active.
*/
private handleAnyTextareaChanges() {
var oldValue = this.textarea.value;
var self = this;
setTimeout(function() {
// Ignore if a composition has started since the timeout
if (!self.isComposing) {
var newValue = self.textarea.value;
var diff = newValue.replace(oldValue, '');
if (diff.length > 0) {
self.terminal.handler(diff);
}
}
}, 0);
}
/**
* Positions the composition view on top of the cursor and the textarea just below it (so the
* IME helper dialog is positioned correctly).
* @param dontRecurse Whether to use setTimeout to recursively trigger another update, this is
* necessary as the IME events across browsers are not consistently triggered.
*/
public updateCompositionElements(dontRecurse?: boolean) {
if (!this.isComposing) {
return;
}
var cursor = <HTMLElement>this.terminal.element.querySelector('.terminal-cursor');
if (cursor) {
// Take .xterm-rows offsetTop into account as well in case it's positioned absolutely within
// the .xterm element.
var xtermRows = <HTMLElement>this.terminal.element.querySelector('.xterm-rows');
var cursorTop = xtermRows.offsetTop + cursor.offsetTop;
this.compositionView.style.left = cursor.offsetLeft + 'px';
this.compositionView.style.top = cursorTop + 'px';
this.compositionView.style.height = cursor.offsetHeight + 'px';
this.compositionView.style.lineHeight = cursor.offsetHeight + 'px';
// Sync the textarea to the exact position of the composition view so the IME knows where the
// text is.
var compositionViewBounds = this.compositionView.getBoundingClientRect();
this.textarea.style.left = cursor.offsetLeft + 'px';
this.textarea.style.top = cursorTop + 'px';
this.textarea.style.width = compositionViewBounds.width + 'px';
this.textarea.style.height = compositionViewBounds.height + 'px';
this.textarea.style.lineHeight = compositionViewBounds.height + 'px';
}
if (!dontRecurse) {
setTimeout(this.updateCompositionElements.bind(this, true), 0);
}
};
/**
* Clears the textarea's position so that the cursor does not blink on IE.
* @private
*/
private clearTextareaPosition() {
this.textarea.style.left = '';
this.textarea.style.top = '';
};
}
+64
View File
@@ -0,0 +1,64 @@
/**
* @license MIT
*/
function EventEmitter() {
this._events = this._events || {};
}
EventEmitter.prototype.addListener = function(type, listener) {
this._events[type] = this._events[type] || [];
this._events[type].push(listener);
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.removeListener = function(type, listener) {
if (!this._events[type]) return;
var obj = this._events[type]
, i = obj.length;
while (i--) {
if (obj[i] === listener || obj[i].listener === listener) {
obj.splice(i, 1);
return;
}
}
};
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.removeAllListeners = function(type) {
if (this._events[type]) delete this._events[type];
};
EventEmitter.prototype.once = function(type, listener) {
var self = this;
function on() {
var args = Array.prototype.slice.call(arguments);
this.removeListener(type, on);
return listener.apply(this, args);
}
on.listener = listener;
return this.on(type, on);
};
EventEmitter.prototype.emit = function(type) {
if (!this._events[type]) return;
var args = Array.prototype.slice.call(arguments, 1)
, obj = this._events[type]
, l = obj.length
, i = 0;
for (; i < l; i++) {
obj[i].apply(this, args);
}
};
EventEmitter.prototype.listeners = function(type) {
return this._events[type] = this._events[type] || [];
};
export { EventEmitter };
+34
View File
@@ -0,0 +1,34 @@
/**
* @license MIT
*/
export interface IBrowser {
isNode: boolean;
userAgent: string;
platform: string;
isFirefox: boolean;
isMSIE: boolean;
isMac: boolean;
isIpad: boolean;
isIphone: boolean;
isMSWindows: boolean;
}
export interface ITerminal {
element: HTMLElement;
rowContainer: HTMLElement;
textarea: HTMLTextAreaElement;
ydisp: number;
lines: string[];
rows: number;
browser: IBrowser;
/**
* Emit the 'data' event and populate the given data.
* @param data The data to populate in the event.
*/
handler(data: string);
on(event: string, callback: () => void);
scrollDisp(disp: number, suppressScrollEvent: boolean);
cancel(ev: Event, force?: boolean);
}
+84
View File
@@ -0,0 +1,84 @@
import { assert } from 'chai';
import { Viewport } from './Viewport';
describe('Viewport', () => {
var terminal;
var viewportElement;
var charMeasureElement;
var viewport;
var scrollAreaElement;
const CHARACTER_HEIGHT = 10;
beforeEach(() => {
terminal = {
lines: [],
rows: 0,
ydisp: 0,
on: () => {},
rowContainer: {
style: {
lineHeight: 0
}
}
};
viewportElement = {
addEventListener: () => {},
style: {
height: 0,
lineHeight: 0
}
};
scrollAreaElement = {
style: {
height: 0
}
};
charMeasureElement = {
getBoundingClientRect: () => {
return { width: null, height: CHARACTER_HEIGHT };
}
};
viewport = new Viewport(terminal, viewportElement, scrollAreaElement, charMeasureElement);
});
describe('refresh', () => {
it('should set the line-height of the terminal', () => {
assert.equal(viewportElement.style.lineHeight, CHARACTER_HEIGHT + 'px');
assert.equal(terminal.rowContainer.style.lineHeight, CHARACTER_HEIGHT + 'px');
charMeasureElement.getBoundingClientRect = () => {
return { width: null, height: 1 };
};
viewport.refresh();
assert.equal(viewportElement.style.lineHeight, '1px');
assert.equal(terminal.rowContainer.style.lineHeight, '1px');
});
it('should set the height of the viewport when the line-height changed', () => {
terminal.lines.push('');
terminal.lines.push('');
terminal.rows = 1;
viewport.refresh();
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
charMeasureElement.getBoundingClientRect = () => {
return { width: null, height: 20 };
};
viewport.refresh();
assert.equal(viewportElement.style.height, 20 + 'px');
});
});
describe('syncScrollArea', () => {
it('should sync the scroll area', () => {
terminal.lines.push('');
terminal.rows = 1;
assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
viewport.syncScrollArea();
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
terminal.lines.push('');
viewport.syncScrollArea();
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');
});
});
});
+123
View File
@@ -0,0 +1,123 @@
/**
* @license MIT
*/
import { ITerminal } from './Interfaces';
/**
* Represents the viewport of a terminal, the visible area within the larger buffer of output.
* Logic for the virtual scroll bar is included in this object.
*/
export class Viewport {
private currentRowHeight: number;
private lastRecordedBufferLength: number;
private lastRecordedViewportHeight: number;
/**
* Creates a new Viewport.
* @param terminal The terminal this viewport belongs to.
* @param viewportElement The DOM element acting as the viewport.
* @param scrollArea The DOM element acting as the scroll area.
* @param charMeasureElement A DOM element used to measure the character size of. the terminal.
*/
constructor(
private terminal: ITerminal,
private viewportElement: HTMLElement,
private scrollArea: HTMLElement,
private charMeasureElement: HTMLElement
) {
this.currentRowHeight = 0;
this.lastRecordedBufferLength = 0;
this.lastRecordedViewportHeight = 0;
this.terminal.on('scroll', this.syncScrollArea.bind(this));
this.terminal.on('resize', this.syncScrollArea.bind(this));
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
this.syncScrollArea();
}
/**
* Refreshes row height, setting line-height, viewport height and scroll area height if
* necessary.
* @param charSize A character size measurement bounding rect object, if it doesn't exist it will
* be created.
*/
private refresh(charSize?: ClientRect): void {
var size = charSize || this.charMeasureElement.getBoundingClientRect();
if (size.height > 0) {
var rowHeightChanged = size.height !== this.currentRowHeight;
if (rowHeightChanged) {
this.currentRowHeight = size.height;
this.viewportElement.style.lineHeight = size.height + 'px';
this.terminal.rowContainer.style.lineHeight = size.height + 'px';
}
var viewportHeightChanged = this.lastRecordedViewportHeight !== this.terminal.rows;
if (rowHeightChanged || viewportHeightChanged) {
this.lastRecordedViewportHeight = this.terminal.rows;
this.viewportElement.style.height = size.height * this.terminal.rows + 'px';
}
this.scrollArea.style.height = (size.height * this.lastRecordedBufferLength) + 'px';
}
}
/**
* Updates dimensions and synchronizes the scroll area if necessary.
*/
public syncScrollArea(): void {
if (this.lastRecordedBufferLength !== this.terminal.lines.length) {
// If buffer height changed
this.lastRecordedBufferLength = this.terminal.lines.length;
this.refresh();
} else if (this.lastRecordedViewportHeight !== this.terminal.rows) {
// If viewport height changed
this.refresh();
} else {
// If size has changed, refresh viewport
var size = this.charMeasureElement.getBoundingClientRect();
if (size.height !== this.currentRowHeight) {
this.refresh(size);
}
}
// Sync scrollTop
var scrollTop = this.terminal.ydisp * this.currentRowHeight;
if (this.viewportElement.scrollTop !== scrollTop) {
this.viewportElement.scrollTop = scrollTop;
}
}
/**
* Handles scroll events on the viewport, calculating the new viewport and requesting the
* terminal to scroll to it.
* @param ev The scroll event.
*/
private onScroll(ev: Event) {
var newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
var diff = newRow - this.terminal.ydisp;
this.terminal.scrollDisp(diff, true);
}
/**
* Handles mouse wheel events by adjusting the viewport's scrollTop and delegating the actual
* scrolling to `onScroll`, this event needs to be attached manually by the consumer of
* `Viewport`.
* @param ev The mouse wheel event.
*/
public onWheel(ev: WheelEvent) {
if (ev.deltaY === 0) {
// Do nothing if it's not a vertical scroll event
return;
}
// Fallback to WheelEvent.DOM_DELTA_PIXEL
var multiplier = 1;
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
multiplier = this.currentRowHeight;
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
multiplier = this.currentRowHeight * this.terminal.rows;
}
this.viewportElement.scrollTop += ev.deltaY * multiplier;
// Prevent the page from scrolling when the terminal scrolls
ev.preventDefault();
};
}
@@ -1,9 +1,7 @@
/*
* Implements the attach method, that
* attaches the terminal to a WebSocket stream.
*
* The bidirectional argument indicates, whether the terminal should
* send data to the socket as well and is true, by default.
/**
* Implements the attach method, that attaches the terminal to a WebSocket stream.
* @module xterm/addons/attach/attach
* @license MIT
*/
(function (attach) {
@@ -11,27 +9,21 @@
/*
* CommonJS environment
*/
module.exports = attach(require('../../src/xterm'));
module.exports = attach(require('../../xterm'));
} else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], attach);
define(['../../xterm'], attach);
} else {
/*
* Plain browser environment
*/
attach(this.Xterm);
attach(window.Terminal);
}
})(function (Xterm) {
'use strict';
/**
* This module provides methods for attaching a terminal to a WebSocket
* stream.
*
* @module xterm/addons/attach/attach
*/
var exports = {};
/**
+15 -20
View File
@@ -1,45 +1,40 @@
/*
* Fit terminal columns and rows to the dimensions of its
* DOM element.
/**
* Fit terminal columns and rows to the dimensions of its DOM element.
*
* Approach:
* - Rows: Truncate the division of the terminal parent element height
* by the terminal row height
* ## Approach
* - Rows: Truncate the division of the terminal parent element height by the terminal row height.
*
* - Columns: Truncate the division of the terminal parent element width by
* the terminal character width (apply display: inline at the
* terminal row and truncate its width with the current number
* of columns)
* - Columns: Truncate the division of the terminal parent element width by the terminal character
* width (apply display: inline at the terminal row and truncate its width with the current
* number of columns).
* @module xterm/addons/fit/fit
* @license MIT
*/
(function (fit) {
if (typeof exports === 'object' && typeof module === 'object') {
/*
* CommonJS environment
*/
module.exports = fit(require('../../src/xterm'));
module.exports = fit(require('../../xterm'));
} else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], fit);
define(['../../xterm'], fit);
} else {
/*
* Plain browser environment
*/
fit(this.Xterm);
fit(window.Terminal);
}
})(function (Xterm) {
/**
* This module provides methods for fitting a terminal's size to a parent container.
*
* @module xterm/addons/fit/fit
*/
var exports = {};
exports.proposeGeometry = function (term) {
var parentElementStyle = window.getComputedStyle(term.element.parentElement),
parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
parentElementWidth = parseInt(parentElementStyle.getPropertyValue('width')),
parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17),
elementStyle = window.getComputedStyle(term.element),
elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')),
elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left')),
@@ -62,7 +57,7 @@
subjectRow.innerHTML = contentBuffer;
rows = parseInt(availableHeight / characterHeight);
cols = parseInt(availableWidth / characterWidth) - 1;
cols = parseInt(availableWidth / characterWidth);
geometry = {cols: cols, rows: rows};
return geometry;
+10
View File
@@ -0,0 +1,10 @@
.xterm.fullscreen {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: auto;
height: auto;
z-index: 255;
}
@@ -1,35 +1,33 @@
/*
/**
* Fullscreen addon for xterm.js
*
* Implements the toggleFullscreen function.
*
* If the `fullscreen` argument has been supplied, then
* if it is true, the fullscreen mode gets turned on,
* if it is false or null, the fullscreen mode gets turned off.
*
* If the `fullscreen` argument has not been supplied, the
* fullscreen mode is being toggled.
* @module xterm/addons/fullscreen/fullscreen
* @license MIT
*/
(function (fullscreen) {
if (typeof exports === 'object' && typeof module === 'object') {
/*
* CommonJS environment
*/
module.exports = fullscreen(require('../../src/xterm'));
module.exports = fullscreen(require('../../xterm'));
} else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], fullscreen);
define(['../../xterm'], fullscreen);
} else {
/*
* Plain browser environment
*/
fullscreen(this.Xterm);
fullscreen(window.Terminal);
}
})(function (Xterm) {
var exports = {};
/**
* Toggle the given terminal's fullscreen mode.
* @param {Xterm} term - The terminal to toggle full screen mode
* @param {boolean} fullscreen - Toggle fullscreen on (true) or off (false)
*/
exports.toggleFullScreen = function (term, fullscreen) {
var fn;
@@ -1,29 +1,29 @@
/**
* Methods for turning URL subscrings in the terminal's content into links (`a` DOM elements).
* @module xterm/addons/linkify/linkify
* @license MIT
*/
(function (linkify) {
if (typeof exports === 'object' && typeof module === 'object') {
/*
* CommonJS environment
*/
module.exports = linkify(require('../../src/xterm'));
module.exports = linkify(require('../../xterm'));
} else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../src/xterm'], linkify);
define(['../../xterm'], linkify);
} else {
/*
* Plain browser environment
*/
linkify(this.Xterm);
linkify(window.Terminal);
}
})(function (Xterm) {
'use strict';
/**
* This module provides methods for convertings valid URL substrings
* into HTML anchor elements (links), inside a terminal view.
*
* @module xterm/addons/linkify/linkify
*/
var exports = {},
protocolClause = '(https?:\\/\\/)',
domainCharacterSet = '[\\da-z\\.-]+',
@@ -54,10 +54,12 @@
* "linkified".
* @param {boolean} lenient - The regex type that will be used to identify links. If lenient is
* false, the regex requires a protocol clause. Defaults to true.
* @param {string} target - Sets target="" attribute with value provided to links.
* Default doesn't set target attribute
* @emits linkify
* @emits linkify:line
*/
exports.linkifyTerminalLine = function (terminal, line, lenient) {
exports.linkifyTerminalLine = function (terminal, line, lenient, target) {
if (typeof line == 'number') {
line = terminal.rowContainer.children[line];
} else if (! (line instanceof HTMLDivElement)) {
@@ -67,6 +69,12 @@
throw new TypeError(message);
}
if (typeof target === 'undefined') {
target = '';
} else {
target = 'target="' + target + '"';
}
var buffer = document.createElement('span'),
nodes = line.childNodes;
@@ -100,7 +108,7 @@
var startsWithProtocol = new RegExp('^' + protocolClause),
urlHasProtocol = url.match(startsWithProtocol),
href = (urlHasProtocol) ? url : 'http://' + url,
link = '<a href="' + href + '" >' + url + '</a>',
link = '<a href="' + href + '" ' + target + '>' + url + '</a>',
newHTML = nodeHTML.replace(url, link);
line.innerHTML = line.innerHTML.replace(nodeHTML, newHTML);
@@ -137,17 +145,19 @@
* @param {Xterm} terminal - The terminal that should get "linkified".
* @param {boolean} lenient - The regex type that will be used to identify links. If lenient is
* false, the regex requires a protocol clause. Defaults to true.
* @param {string} target - Sets target="" attribute with value provided to links.
* Default doesn't set target attribute
* @emits linkify
* @emits linkify:line
*/
exports.linkify = function (terminal, lenient) {
exports.linkify = function (terminal, lenient, target) {
var rows = terminal.rowContainer.children;
lenient = (typeof lenient == "boolean") ? lenient : true;
for (var i=0; i<rows.length; i++) {
var line = rows[i];
exports.linkifyTerminalLine(terminal, line, lenient);
exports.linkifyTerminalLine(terminal, line, lenient, target);
}
/**
@@ -173,9 +183,11 @@
* "linkified".
* @param {boolean} lenient - The regex type that will be used to identify links. If lenient is
* false, the regex requires a protocol clause. Defaults to true.
* @param {string} target - Sets target="" attribute with value provided to links.
* Default doesn't set target attribute
*/
Xterm.prototype.linkifyTerminalLine = function (line, lenient) {
return exports.linkifyTerminalLine(this, line, lenient);
Xterm.prototype.linkifyTerminalLine = function (line, lenient, target) {
return exports.linkifyTerminalLine(this, line, lenient, target);
};
/**
@@ -184,9 +196,11 @@
* @memberof Xterm
* @param {boolean} lenient - The regex type that will be used to identify links. If lenient is
* false, the regex requires a protocol clause. Defaults to true.
* @param {string} target - Sets target="" attribute with value provided to links.
* Default doesn't set target attribute
*/
Xterm.prototype.linkify = function (lenient) {
return exports.linkify(this, lenient);
Xterm.prototype.linkify = function (lenient, target) {
return exports.linkify(this, lenient, target);
};
return exports;
+5
View File
@@ -0,0 +1,5 @@
{
"name": "xterm.terminado",
"main": "terminado.js",
"private": true
}
+135
View File
@@ -0,0 +1,135 @@
/**
* This module provides methods for attaching a terminal to a terminado WebSocket stream.
*
* @module xterm/addons/terminado/terminado
* @license MIT
*/
(function (attach) {
if (typeof exports === 'object' && typeof module === 'object') {
/*
* CommonJS environment
*/
module.exports = attach(require('../../xterm'));
} else if (typeof define == 'function') {
/*
* Require.js is available
*/
define(['../../xterm'], attach);
} else {
/*
* Plain browser environment
*/
attach(window.Terminal);
}
})(function (Xterm) {
'use strict';
var exports = {};
/**
* Attaches the given terminal to the given socket.
*
* @param {Xterm} term - The terminal to be attached to the given socket.
* @param {WebSocket} socket - The socket to attach the current terminal.
* @param {boolean} bidirectional - Whether the terminal should send data
* to the socket as well.
* @param {boolean} buffered - Whether the rendering of incoming data
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
exports.terminadoAttach = function (term, socket, bidirectional, buffered) {
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
term.socket = socket;
term._flushBuffer = function () {
term.write(term._attachSocketBuffer);
term._attachSocketBuffer = null;
clearTimeout(term._attachSocketBufferTimer);
term._attachSocketBufferTimer = null;
};
term._pushToBuffer = function (data) {
if (term._attachSocketBuffer) {
term._attachSocketBuffer += data;
} else {
term._attachSocketBuffer = data;
setTimeout(term._flushBuffer, 10);
}
};
term._getMessage = function (ev) {
var data = JSON.parse(ev.data)
if( data[0] == "stdout" ) {
if (buffered) {
term._pushToBuffer(data[1]);
} else {
term.write(data[1]);
}
}
};
term._sendData = function (data) {
socket.send(JSON.stringify(['stdin', data]));
};
term._setSize = function (size) {
socket.send(JSON.stringify(['set_size', size.rows, size.cols]));
};
socket.addEventListener('message', term._getMessage);
if (bidirectional) {
term.on('data', term._sendData);
}
term.on('resize', term._setSize);
socket.addEventListener('close', term.terminadoDetach.bind(term, socket));
socket.addEventListener('error', term.terminadoDetach.bind(term, socket));
};
/**
* Detaches the given terminal from the given socket
*
* @param {Xterm} term - The terminal to be detached from the given socket.
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
exports.terminadoDetach = function (term, socket) {
term.off('data', term._sendData);
socket = (typeof socket == 'undefined') ? term.socket : socket;
if (socket) {
socket.removeEventListener('message', term._getMessage);
}
delete term.socket;
};
/**
* Attaches the current terminal to the given socket
*
* @param {WebSocket} socket - The socket to attach the current terminal.
* @param {boolean} bidirectional - Whether the terminal should send data
* to the socket as well.
* @param {boolean} buffered - Whether the rendering of incoming data
* should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
Xterm.prototype.terminadoAttach = function (socket, bidirectional, buffered) {
return exports.terminadoAttach(this, socket, bidirectional, buffered);
};
/**
* Detaches the current terminal from the given socket.
*
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
*/
Xterm.prototype.terminadoDetach = function (socket) {
return exports.terminadoDetach(this, socket);
};
return exports;
});
+18
View File
@@ -0,0 +1,18 @@
import { assert } from 'chai';
import * as Terminal from '../xterm';
import * as Clipboard from './Clipboard';
describe('evaluateCopiedTextProcessing', function () {
it('should strip trailing whitespaces and replace nbsps with spaces', function () {
let nonBreakingSpace = String.fromCharCode(160),
copiedText = 'echo' + nonBreakingSpace + 'hello' + nonBreakingSpace,
processedText = Clipboard.prepareTextForClipboard(copiedText);
// No trailing spaces
assert.equal(processedText.match(/\s+$/), null);
// No non-breaking space
assert.equal(processedText.indexOf(nonBreakingSpace), -1);
});
});
+154
View File
@@ -0,0 +1,154 @@
/**
* Clipboard handler module: exports methods for handling all clipboard-related events in the
* terminal.
* @module xterm/handlers/Clipboard
* @license MIT
*/
import { ITerminal } from '../Interfaces';
interface IWindow extends Window {
clipboardData?: {
getData(format: string): string;
setData(format: string, data: string);
};
}
declare var window: IWindow;
/**
* Prepares text copied from terminal selection, to be saved in the clipboard by:
* 1. stripping all trailing white spaces
* 2. converting all non-breaking spaces to regular spaces
* @param {string} text The copied text that needs processing for storing in clipboard
* @returns {string}
*/
export function prepareTextForClipboard(text: string): string {
let space = String.fromCharCode(32),
nonBreakingSpace = String.fromCharCode(160),
allNonBreakingSpaces = new RegExp(nonBreakingSpace, 'g'),
processedText = text.split('\n').map(function (line) {
// Strip all trailing white spaces and convert all non-breaking spaces
// to regular spaces.
let processedLine = line.replace(/\s+$/g, '').replace(allNonBreakingSpaces, space);
return processedLine;
}).join('\n');
return processedText;
}
/**
* Binds copy functionality to the given terminal.
* @param {ClipboardEvent} ev The original copy event to be handled
*/
export function copyHandler(ev: ClipboardEvent, term: ITerminal) {
// We cast `window` to `any` type, because TypeScript has not declared the `clipboardData`
// property that we use below for Internet Explorer.
let copiedText = window.getSelection().toString(),
text = prepareTextForClipboard(copiedText);
if (term.browser.isMSIE) {
window.clipboardData.setData('Text', text);
} else {
ev.clipboardData.setData('text/plain', text);
}
ev.preventDefault(); // Prevent or the original text will be copied.
}
/**
* Redirect the clipboard's data to the terminal's input handler.
* @param {ClipboardEvent} ev The original paste event to be handled
* @param {Terminal} term The terminal on which to apply the handled paste event
*/
export function pasteHandler(ev: ClipboardEvent, term: ITerminal) {
ev.stopPropagation();
let text: string;
let dispatchPaste = function(text) {
term.handler(text);
term.textarea.value = '';
return term.cancel(ev);
};
if (term.browser.isMSIE) {
if (window.clipboardData) {
text = window.clipboardData.getData('Text');
dispatchPaste(text);
}
} else {
if (ev.clipboardData) {
text = ev.clipboardData.getData('text/plain');
dispatchPaste(text);
}
}
}
/**
* Bind to right-click event and allow right-click copy and paste.
*
* **Logic**
* If text is selected and right-click happens on selected text, then
* do nothing to allow seamless copying.
* If no text is selected or right-click is outside of the selection
* area, then bring the terminal's input below the cursor, in order to
* trigger the event on the textarea and allow-right click paste, without
* caring about disappearing selection.
* @param {MouseEvent} ev The original right click event to be handled
* @param {Terminal} term The terminal on which to apply the handled paste event
*/
export function rightClickHandler(ev: MouseEvent, term: ITerminal) {
let s = document.getSelection(),
selectedText = prepareTextForClipboard(s.toString()),
clickIsOnSelection = false,
x = ev.clientX,
y = ev.clientY;
if (s.rangeCount) {
let r = s.getRangeAt(0),
cr = r.getClientRects();
for (let i = 0; i < cr.length; i++) {
let rect = cr[i];
clickIsOnSelection = (
(x > rect.left) && (x < rect.right) &&
(y > rect.top) && (y < rect.bottom)
);
if (clickIsOnSelection) {
break;
}
}
// If we clicked on selection and selection is not a single space,
// then mark the right click as copy-only. We check for the single
// space selection, as this can happen when clicking on an &nbsp;
// and there is not much pointing in copying a single space.
if (selectedText.match(/^\s$/) || !selectedText.length) {
clickIsOnSelection = false;
}
}
// Bring textarea at the cursor position
if (!clickIsOnSelection) {
term.textarea.style.position = 'fixed';
term.textarea.style.width = '20px';
term.textarea.style.height = '20px';
term.textarea.style.left = (x - 10) + 'px';
term.textarea.style.top = (y - 10) + 'px';
term.textarea.style.zIndex = '1000';
term.textarea.focus();
// Reset the terminal textarea's styling
setTimeout(function () {
term.textarea.style.position = null;
term.textarea.style.width = null;
term.textarea.style.height = null;
term.textarea.style.left = null;
term.textarea.style.top = null;
term.textarea.style.zIndex = null;
}, 4);
}
}
@@ -1,5 +1,5 @@
var assert = require('chai').assert;
var Terminal = require('../../src/xterm');
var Terminal = require('../../xterm');
var linkify = require('../../addons/linkify/linkify');
describe('linkify addon', function () {
@@ -1,10 +1,10 @@
var assert = require('chai').assert;
var Terminal = require('../../src/xterm');
var Terminal = require('../../xterm');
describe('xterm.js addons', function() {
it('should load addons with Terminal.loadAddon', function () {
Terminal.loadAddon('attach');
// Test that function was loaded successfully
// Test that addon was loaded successfully
assert.equal(typeof Terminal.prototype.attach, 'function');
});
});
@@ -2,7 +2,7 @@ var glob = require('glob');
var fs = require('fs');
var pty = require('pty.js');
var sleep = require('sleep');
var Terminal = require('../src/xterm');
var Terminal = require('../xterm');
var CONSOLE_LOG = console.log;
@@ -27,7 +27,7 @@ function pty_write_read(s) {
return b.toString('utf8', 0, bytes);
}
// make sure raw pty is at x=0 and has no pending data
// make sure raw pty is at x=0 and has no pending data
function pty_reset() {
pty_write_read('\r\n');
}
@@ -80,9 +80,10 @@ describe('xterm output comparison', function() {
// omit stack trace for escape sequence files
Error.stackTraceLimit = 0;
var files = glob.sync('test/escape_sequence_files/*.in');
var files = glob.sync('**/escape_sequence_files/*.in');
// only successful tests for now
var successful = [0, 2, 6, 12, 13, 18, 20, 22, 27, 28];
console.log(files);
for (var a in successful) {
var i = successful[a];
(function(filename){

Some files were not shown because too many files have changed in this diff Show More