Compare commits

..
2154 Commits
Author SHA1 Message Date
Daniel Imms ebb21710c5 Merge pull request #2179 from Tyriar/release/3.14_2174
Fix NPE in open
2019-06-03 12:34:14 -07:00
Daniel Imms 367e23b64e v3.14.2 2019-06-03 12:29:25 -07:00
Daniel Imms 322ae131a1 Fix NPE in open
Fixes #2174
2019-06-03 12:28:44 -07:00
Daniel Imms 4f35c21355 v3.14.1 2019-05-31 09:30:49 -07:00
Daniel Imms 13133d699f Make sure xterm.css gets built to dist/ 2019-05-31 09:30:40 -07:00
Daniel Imms 0ed75dc100 Merge pull request #2145 from xtermjs/Tyriar-patch-1
v3.14.0
2019-05-30 16:37:12 -07:00
Daniel Imms b3a631750d v3.14.0 2019-05-30 16:26:37 -07:00
Daniel Imms 9643de4c01 Merge pull request #2141 from Tyriar/ts_3.5
typescript@3.5
2019-05-29 16:38:37 -07:00
Daniel Imms ab1263f669 typescript@3.5 2019-05-29 16:10:54 -07:00
Daniel Imms 9ebe094a2f Merge pull request #2140 from Tyriar/2136_fix_dom_renderer
Fix DOM renderer
2019-05-28 11:56:31 -07:00
Daniel Imms 0c3f2d7222 Revert "Revert "fix: don't use Math.floor in DomRenderer charWidth computation""
This reverts commit 1feb0a27e9.
2019-05-28 09:49:14 -07:00
Daniel Imms a39da0f0d5 Ensure DOM renderer has styles injected on ctor
Fixes #2136
2019-05-28 09:49:03 -07:00
Daniel Imms adac12eded Merge pull request #2134 from Tyriar/fix_underline
Draw underline over char glyph
2019-05-28 08:49:01 -07:00
Daniel Imms 030fb78712 Merge branch 'master' into fix_underline 2019-05-26 21:19:03 -07:00
Daniel Imms 96b3eb982b Draw underline over char glyph 2019-05-26 21:12:36 -07:00
Daniel Imms 5276ad8146 Merge pull request #2133 from Tyriar/remove_scripts
Remove release scripts
2019-05-26 13:17:19 -07:00
Daniel Imms 4c42393aa4 Remove release scripts
They're no longer used, azure-pipelines.yml does this now
2019-05-26 13:07:37 -07:00
Daniel Imms 1942b4ad51 Merge pull request #2130 from Tyriar/2117_J_tests
Tests for erase in display
2019-05-25 21:34:11 -07:00
Daniel Imms 05ca1cb7dc Up timeouts 2019-05-25 21:25:56 -07:00
Daniel Imms 2f4c5b93fa Merge pull request #2131 from Tyriar/72149_npe
Fix NPE in reflow
2019-05-25 21:23:19 -07:00
Daniel Imms de8d9a720a Fix NPE in reflow
See microsoft/vscode#72149
2019-05-25 21:17:36 -07:00
Daniel Imms 7c2bc70aac Tests for erase in display
Part of #2117
2019-05-25 21:13:47 -07:00
Daniel Imms 44e01ba006 Merge pull request #2128 from Tyriar/1965_optimize_a11y
Only update a11y announcements on animation frame
2019-05-25 19:03:22 -07:00
Daniel Imms 8ffdc14143 Only update a11y announcements on animation frame
Fixes #1965
2019-05-25 11:46:02 -07:00
Daniel Imms fda964b3ea Merge pull request #2127 from jerch/2126_fix
fix losing data after RIS command
2019-05-24 16:39:40 -07:00
Jörg Breitbart b748eca980 fix losing data behind RIS 2019-05-24 23:17:40 +02:00
jerch bbefedb6eb Merge pull request #2125 from jerch/2124_fix_colormode_switches
fix colormode switches
2019-05-24 21:13:59 +02:00
Jörg Breitbart c387180a47 add color mode transition tests 2019-05-24 21:09:11 +02:00
Jörg Breitbart 0e1704f563 cleanup 2019-05-24 20:50:25 +02:00
Daniel Imms b8f55f1c8f Merge pull request #2123 from Tyriar/revert_floor
Revert "fix: don't use Math.floor in DomRenderer charWidth computation"
2019-05-24 06:55:26 -07:00
Daniel Imms a428193424 Merge branch 'master' into revert_floor 2019-05-24 06:50:37 -07:00
Daniel Imms 1feb0a27e9 Revert "fix: don't use Math.floor in DomRenderer charWidth computation"
This reverts commit 23bdb2a6c2.
2019-05-24 06:48:48 -07:00
jerch a92e4adfe2 Merge pull request #2120 from jerch/2108_memory_exhaustion
trim processed chunks from write buffer
2019-05-22 22:28:01 +02:00
Jörg Breitbart 7716e9abda trim already processed chunks 2019-05-22 14:12:15 +02:00
Daniel Imms 6e196da59c Merge pull request #2118 from Tyriar/2117_csi_tests
Add tests for CSI @-I
2019-05-21 22:53:48 -07:00
Daniel Imms 69e8f62149 Make tests way faster by avoiding page reload 2019-05-21 22:43:02 -07:00
Daniel Imms b46757010f Boost timeout of xterm output tests 2019-05-21 22:34:04 -07:00
Daniel Imms a74173adf2 Add tests for CSI @-I
Part of #2117
2019-05-21 22:29:39 -07:00
Daniel Imms c10b18113e Merge pull request #2116 from Tyriar/2097_fix_addon_dispose
Fix new addon dispose
2019-05-21 16:35:28 -07:00
Daniel Imms 7786e59c77 Fix new addon dispose
Fixes #2097
2019-05-21 16:26:50 -07:00
Daniel Imms 9dfac7e674 Merge pull request #2114 from Tyriar/consolidate_api_test_timeout
Move API test timeout to top-level describe
2019-05-21 14:58:37 -07:00
Daniel Imms 922e594fcf Fix lint 2019-05-21 14:51:48 -07:00
Daniel Imms c73aa07135 Merge branch 'master' into consolidate_api_test_timeout 2019-05-21 14:48:22 -07:00
Daniel Imms acea979fe0 Move API test timeout to top-level describe
I learned a thing.
2019-05-21 14:48:03 -07:00
Daniel Imms e4f626e3b6 Merge pull request #2110 from Tyriar/split_out_integration
Split out integration tests into its own job
2019-05-21 14:39:35 -07:00
Daniel Imms 9a4f419820 Merge branch 'master' into split_out_integration 2019-05-21 14:33:27 -07:00
Daniel Imms 209c44898d Merge pull request #2113 from Tyriar/2111_automate_patch_release
Run release against builds on release/* branches
2019-05-21 14:32:12 -07:00
Daniel Imms d3ff32da72 Run release against builds on release/* branches
Fixes #2111
2019-05-21 14:26:28 -07:00
Daniel Imms f81d1cb1cf Increase integration test sleep 2019-05-21 14:20:58 -07:00
Daniel Imms 8f09f58119 Merge branch 'master' into split_out_integration 2019-05-21 12:39:22 -07:00
Daniel Imms ab0eedc513 Fix job name 2019-05-21 11:19:54 -07:00
Daniel Imms 8e460dfe55 Merge pull request #2109 from Tyriar/2107_cursor_report
Fix status reporting
2019-05-21 11:13:32 -07:00
Daniel Imms 37ed1e4796 Split out integration tests into its own job
This will make Linux finish faster and release trigger faster
2019-05-21 11:12:34 -07:00
Daniel Imms d0a3164e99 Fix lint 2019-05-21 11:01:40 -07:00
Daniel Imms 968dd93ba7 Fix status reporting
Fixes #2107
2019-05-21 10:57:26 -07:00
Daniel Imms 739723fe92 Merge pull request #2101 from Tyriar/bad_comment_
Remove old comment
2019-05-18 21:21:34 -07:00
Daniel Imms 2f08b87d95 Remove old comment 2019-05-18 21:21:02 -07:00
Daniel Imms eb70ddcba5 Merge pull request #2100 from Tyriar/2099_pausing
Support pausing in RenderCoordinator
2019-05-18 21:19:51 -07:00
Daniel Imms 43015f85f4 Move Renderer ownership to RenderCoordinator 2019-05-18 21:15:18 -07:00
Daniel Imms 87dca56dee Support pausing in RenderCoordinator
This actually removes the pause rendering functionality when the resize
and theme changes but simplifies it as a result, they also rarely happen
especially when off screen/hidden.

Fixes #2099
2019-05-18 20:20:46 -07:00
Daniel Imms 72e6863a7f Merge pull request #2098 from Tyriar/2093_logo_demo
Use logo in demo
2019-05-18 20:05:33 -07:00
Daniel Imms e83aa64794 Merge pull request #2096 from Tyriar/render_coordinator
Introduce RenderCoordinator
2019-05-18 20:03:20 -07:00
Daniel Imms c7416a6eaa Use logo in demo
Fixes #2093
2019-05-18 19:56:28 -07:00
Daniel Imms 9ed5920275 Add some basic fg/bg renderer tests 2019-05-18 19:51:44 -07:00
Daniel Imms 497d31bec3 onThemeChange -> setColors 2019-05-18 19:31:35 -07:00
Daniel Imms 24de302d2f onWindowResize -> onDevicePixelRatioChange 2019-05-18 19:27:06 -07:00
Daniel Imms 5f70b3f3be Move window resize listener to render coordinator 2019-05-18 19:22:51 -07:00
Daniel Imms b64cc0a9de Fix ui project build 2019-05-18 19:16:06 -07:00
Daniel Imms 3e4c1b5a21 Move ScreenDprMonitor to be owned by RenderCoordinator
(and a11y manager)
2019-05-18 19:12:37 -07:00
Daniel Imms f698cafccb Move the renderer events to RenderCoordinator 2019-05-18 19:02:42 -07:00
Daniel Imms 8792bb5f36 Introduce a RenderCoordinator that owns common Renderer logic
Part of #2005
2019-05-18 18:47:44 -07:00
Daniel Imms ac48ef977b Merge pull request #2094 from Tyriar/2005_colormanager
Move ColorManager to ui
2019-05-18 18:16:47 -07:00
Daniel Imms 4119c7d1d7 Move ColorManager ownership to Terminal 2019-05-18 18:10:04 -07:00
Daniel Imms 000fefdead Move ColorManager to ui
Part of #2005
Part of #1507
2019-05-18 17:49:48 -07:00
Daniel Imms 33955398e7 Merge pull request #2092 from Tyriar/layering
Move BufferReflow and Marker to core
2019-05-18 09:59:54 -07:00
Daniel Imms dbafc793da Move Marker to core 2019-05-17 23:41:26 -07:00
Daniel Imms 88c1ff6f11 Move BufferReflow to core 2019-05-17 23:37:44 -07:00
Daniel Imms 610c4c9726 Merge pull request #2088 from Tyriar/fix_coveralls
Fix what branch coverage is sent with
2019-05-16 10:47:34 -07:00
Daniel Imms e2214b0239 Fix what branch coverage is sent with 2019-05-16 10:39:53 -07:00
Daniel Imms 23d3a27a6f Merge pull request #2085 from Tyriar/a11y_fix
Add sanity check in AccessibilityManager
2019-05-16 09:58:02 -07:00
Daniel Imms d04016d51f Merge branch 'master' into a11y_fix 2019-05-16 09:52:54 -07:00
Daniel Imms fede301f5f Merge pull request #2081 from Tyriar/xterm-tests
Support debugging integration tests
2019-05-16 09:52:42 -07:00
Daniel Imms a62ec679bd Move readFileSync out of test 2019-05-15 12:49:13 -07:00
Daniel Imms da79fec5c2 Disable failing test on Linux 2019-05-15 11:57:32 -07:00
Daniel Imms 80025804b3 Add sanity check in AccessibilityManager
Fixes #2082
2019-05-15 11:47:15 -07:00
Daniel Imms 955c45906b Merge branch 'master' into xterm-tests 2019-05-13 21:30:33 -07:00
Daniel Imms f331269ef4 Support debugging integration tests 2019-05-13 21:11:56 -07:00
Daniel Imms 9cb6706e2d Merge pull request #2080 from jerch/demo_update
apply attach changes to demo
2019-05-13 21:07:48 -07:00
Daniel Imms b9cfbbea8f xterm-addon-attach@0.1.0-beta8 2019-05-13 20:34:14 -07:00
Jörg Breitbart 58d461bb90 optimize Buffer.concat 2019-05-13 15:33:54 +02:00
Jörg Breitbart 69411916cb make linter happy 2019-05-13 01:45:21 +02:00
Jörg Breitbart 1a596f9608 default to string transport 2019-05-13 01:41:51 +02:00
Jörg Breitbart 67be8c36e7 utf8 switch in server.js 2019-05-13 01:40:54 +02:00
Jörg Breitbart 0b50c06810 Merge branch 'master' into demo_update 2019-05-13 01:25:51 +02:00
Jörg Breitbart 53167df1a8 document utf8 switch in client.ts 2019-05-13 01:24:41 +02:00
jerch eef855601b Merge pull request #1904 from jerch/utf8_input
Support for raw UTF8 input
2019-05-13 01:23:39 +02:00
Jörg Breitbart 6fd5cdd8f1 apply attach changes to demo 2019-05-13 00:58:14 +02:00
Jörg Breitbart c0e9bbe87f Revert "change demo to utf8 input"
This reverts commit e6e5ecc0f2.
2019-05-12 22:17:06 +02:00
Jörg Breitbart 06c292c11d Merge branch 'master' into utf8_input 2019-05-12 22:16:59 +02:00
Jörg Breitbart bda068c5f0 docs 2019-05-12 22:07:14 +02:00
Daniel Imms 031a30b007 Merge pull request #2065 from Tyriar/1128_addons
New addon API
2019-05-12 12:54:45 -07:00
Daniel Imms 3475764946 Types/doc polish 2019-05-12 10:59:26 -07:00
Daniel Imms f90239377b Fix possible infinite loop if addon disposes terminal 2019-05-12 10:47:35 -07:00
Daniel Imms 1502fea431 Remove unused fullscreen addon from demo 2019-05-12 10:41:01 -07:00
Daniel Imms caf8f9d35e Update search addon 2019-05-12 10:39:39 -07:00
Daniel Imms d230f93bde Remove old search addon from demo 2019-05-12 10:25:41 -07:00
Daniel Imms bae125b789 Merge branch 'master' into utf8_input 2019-05-12 10:24:39 -07:00
Daniel Imms eda04bcb23 Add new search addon, move AddonManager to public
Because addons build on top of the API it needs to live in public, the main
reason for this is because the implementation of buffer differs on
public/Terminal and src/Terminal.
2019-05-12 10:22:29 -07:00
Jörg Breitbart 523d562f73 fix missing types 2019-05-12 18:49:23 +02:00
Daniel Imms 0c588a7333 Fix missed merge conflict 2019-05-12 09:45:09 -07:00
Daniel Imms f7612a49d2 Merge remote-tracking branch 'ups/master' into 1128_addons 2019-05-12 09:44:09 -07:00
Daniel Imms 34244248bf Merge pull request #2078 from Tyriar/1443_selection_api
select and getSelectionPosition APIs
2019-05-12 09:40:03 -07:00
Daniel Imms f654044e5e Fix search addon unit tests 2019-05-12 00:17:59 -07:00
Daniel Imms a7fa58cc60 Add API test for getSelectionPosition 2019-05-11 23:59:51 -07:00
Daniel Imms 9ca9f7296e Use new APIs in selection addon 2019-05-11 23:56:34 -07:00
Daniel Imms 5bbbbf7348 Expose getSelectionPosition and select APIs instead 2019-05-11 23:52:38 -07:00
Daniel Imms da7c39e526 Add API test 2019-05-11 23:37:42 -07:00
Daniel Imms 6674f05cc8 Implement setSelection API
Fixes #1443
2019-05-11 23:35:31 -07:00
Daniel Imms 161c7f9339 Use API clearSelection in search addon 2019-05-11 23:22:46 -07:00
Daniel Imms 780e924b21 Use stable API for buffer in search addon 2019-05-11 23:15:04 -07:00
Daniel Imms 1f000054c2 Merge remote-tracking branch 'ups/master' into 1128_addons 2019-05-11 22:48:49 -07:00
Daniel Imms c13d6e5eeb Make write and writeln consistent with writeUtf8 test 2019-05-11 22:29:01 -07:00
Daniel Imms e5dfc56030 Add api test for writeUtf8 2019-05-11 22:24:33 -07:00
Daniel Imms 00423407c1 Clean up 2019-05-11 22:18:18 -07:00
Daniel Imms 2340fcd071 Fix compile and update yarn.lock with utf8 2019-05-11 21:21:36 -07:00
Daniel Imms 59a1749d44 Merge branch 'master' into utf8_input 2019-05-11 21:16:05 -07:00
Daniel Imms 0fae9bb5a8 Merge pull request #2074 from Tyriar/1994_buffer_api
Buffer API
2019-05-11 21:15:55 -07:00
Daniel Imms 70ba349a85 Fix invalid index check, add api tests 2019-05-11 20:58:51 -07:00
Daniel Imms 49574be510 Add warnings to getCell and getLine 2019-05-11 20:49:48 -07:00
Daniel Imms f41e00ed97 Return undefined if cell or line doesn't exist 2019-05-11 20:46:55 -07:00
Jörg Breitbart ce079f399c fix docstring 2019-05-12 00:07:07 +02:00
Jörg Breitbart 7a567d2717 apply time-based limit 2019-05-11 23:10:18 +02:00
Daniel Imms cd3f2609d6 Make tests use buffer API over _core 2019-05-11 12:12:53 -07:00
Daniel Imms 8a929ed142 Add API tests for loadAddon 2019-05-11 11:02:15 -07:00
Daniel Imms 46995fdbc1 Add tests for buffer.getLine 2019-05-11 10:46:00 -07:00
Daniel Imms d694eae6b5 Add some buffer tests 2019-05-11 10:32:53 -07:00
Daniel Imms bce2eae66f Update yarn.lock 2019-05-11 10:15:29 -07:00
Daniel Imms 3554d3e075 Merge branch 'master' into 1128_addons 2019-05-11 10:14:48 -07:00
Daniel Imms eb6deb67f9 Fix build issues 2019-05-11 10:10:31 -07:00
Daniel Imms 7c55e1be9e Merge remote-tracking branch 'ups/master' into 1994_buffer_api 2019-05-11 10:05:31 -07:00
Daniel Imms 7549ca59be Merge branch 'master' into utf8_input 2019-05-11 10:02:14 -07:00
Daniel Imms af81acc50e Merge pull request #2068 from Tyriar/api_tests
API integration tests
2019-05-11 10:00:36 -07:00
Jörg Breitbart f033800554 fix imports 2019-05-11 17:56:26 +02:00
Daniel Imms 623dd56190 Merge pull request #2073 from jerch/2072_remove_instanceof
remove instanceof check
2019-05-11 08:46:22 -07:00
Jörg Breitbart 740604f035 remove instanceof check 2019-05-11 17:21:16 +02:00
Daniel Imms 3f68a60e73 Merge pull request #2067 from starpit/floor
fix: don't use Math.floor in DomRenderer charWidth computation
2019-05-11 00:50:20 -07:00
Daniel Imms 556c56ff94 Merge branch 'master' into api_tests 2019-05-11 00:10:33 -07:00
Daniel Imms dfb5d8e663 Add focus, blur test 2019-05-11 00:00:57 -07:00
Daniel Imms 7562948259 Add tests for all API events 2019-05-10 23:47:28 -07:00
Daniel Imms 34ac1bc502 Fix clearSelection not firing onSelectionChange
Fixes #2070
2019-05-10 23:38:45 -07:00
Daniel Imms 97b176e701 Add selection tests 2019-05-10 23:14:16 -07:00
Daniel Imms 8a5b6b0356 Move puppeteer to devDependencies 2019-05-10 22:58:23 -07:00
Daniel Imms 55d590348c API integration tests
Part of #1247
2019-05-10 22:57:27 -07:00
Nick Mitchell 23bdb2a6c2 fix: don't use Math.floor in DomRenderer charWidth computation
Fixes #2063
2019-05-11 00:59:59 -04:00
Daniel Imms 16aaf6c58c Fix build 2019-05-10 21:08:06 -07:00
Daniel Imms 22c9ad7145 Merge remote-tracking branch 'origin/master' into 1994_buffer_api 2019-05-10 21:04:26 -07:00
Daniel Imms 41a7cabbc2 Merge branch 'master' into 1128_addons 2019-05-10 21:02:55 -07:00
Daniel Imms 724baf22f9 Merge pull request #2066 from Tyriar/lib_import
Fix bad import from lib
2019-05-10 20:52:20 -07:00
Daniel Imms c04ebe974f Fix bad import from lib
Related #1996
2019-05-10 20:51:18 -07:00
Daniel Imms fcee890819 Merge branch 'master' into 1128_addons 2019-05-10 20:47:17 -07:00
Daniel Imms d696046921 Simplify and mark new addon API as experimental 2019-05-10 20:38:08 -07:00
Daniel Imms 518e2734ba Re-introduce original attach and webLinks addons back
We could release this in v3 if we don't break addons like this
2019-05-10 20:30:47 -07:00
Daniel Imms eedcbccb15 Merge remote-tracking branch 'origin/master' into 1128_addons 2019-05-10 20:24:43 -07:00
Daniel Imms d7e6cb17a5 Merge pull request #2062 from Tyriar/windowsMode_typings
Add typings for windowsMode
2019-05-10 19:41:49 -07:00
Daniel Imms b658baf921 Add typings for windowsMode 2019-05-10 16:26:53 -07:00
Daniel Imms 10c6e900ad Merge pull request #2059 from Tyriar/buffer_core
Move BufferLine into core
2019-05-10 15:17:14 -07:00
Daniel Imms b608c9d0ef Merge branch 'master' into buffer_core 2019-05-10 14:57:32 -07:00
Daniel Imms 0e0bcde957 Merge pull request #2061 from Tyriar/fix_beta_off_patch
Make sure beta builds are always on patch version 0
2019-05-10 07:57:33 -07:00
Daniel Imms d735196a30 Make sure beta builds are always on patch version 0 2019-05-10 07:39:42 -07:00
Daniel Imms 59aec69379 Add BufferLine into core and strict null check 2019-05-09 22:19:33 -07:00
Daniel Imms 228ec7b818 Move BufferLine into core 2019-05-09 22:15:32 -07:00
Daniel Imms 7b7fc53157 Move more BufferLine dependencies into core 2019-05-09 22:10:07 -07:00
Daniel Imms f381cdfc33 Move a bunch of types to core 2019-05-09 21:57:33 -07:00
Daniel Imms ac6bced6e7 Merge pull request #2056 from xtermjs/Tyriar-patch-1
Add missing space to typings
2019-05-09 10:12:29 -07:00
Daniel Imms 1a61401cbe Merge pull request #2057 from Tyriar/fix_cd_after_release
Fix beta CD for new major/minor beta versions
2019-05-09 10:12:11 -07:00
Daniel Imms 6d55ab23fd Fix beta CD for new major/minor beta versions 2019-05-09 10:11:25 -07:00
Daniel Imms 3abc090412 Add missing space to typings 2019-05-09 10:02:42 -07:00
Daniel Imms 21f1498977 Merge pull request #2053 from xtermjs/Tyriar-patch-1
Update year in README
2019-05-09 10:00:09 -07:00
Daniel Imms 16c0550d7c Merge pull request #2051 from Tyriar/2019_prepublish
Replace prepublish
2019-05-09 09:59:58 -07:00
Daniel Imms 517d5cfd0e Merge pull request #2050 from Tyriar/2048_demo_line_height
Update terminal dimensions after line height changes
2019-05-09 09:59:49 -07:00
Daniel Imms d363416fb4 Merge pull request #2046 from NizamLZ/fix/2045
Allow + char in URI path
2019-05-09 09:59:36 -07:00
Daniel Imms ffc868a4b8 Merge pull request #2055 from xtermjs/Tyriar-patch-2
v3.13.0
2019-05-09 09:42:56 -07:00
Daniel Imms e40f924913 v3.13.0 2019-05-09 09:37:07 -07:00
Daniel Imms ca1c647442 Merge pull request #2054 from Tyriar/fix_beta_cd
Actually fix beta CD
2019-05-09 08:20:58 -07:00
Daniel Imms 79e182d63f Actually fix beta CD
Part of #2044
2019-05-09 08:20:19 -07:00
Daniel Imms c1b56722d3 Merge pull request #2052 from jflatow/unit-separator
Send the unit separator for C-_, like some other keyboards
2019-05-09 07:56:30 -07:00
Daniel Imms b959fc8d6a Update year in README 2019-05-09 07:49:50 -07:00
Khaja Nizamuddin 48753625f3 Merge branch 'master' into fix/2045 2019-05-09 12:43:25 +05:30
Jared Flatow dc236aeb20 Send the unit separator for C-_, like some other keyboards 2019-05-09 00:06:32 -07:00
Daniel Imms 71886167be Replace prepublish
On prepublishOnly we want to do a full build, on prepare we want
to only build the ts projects so the .d.ts files are avilable.

Fixes #2019
2019-05-08 23:08:39 -07:00
Daniel Imms 4b1c54d634 Update terminal dimensions after line height changes
Fixes #2048
2019-05-08 20:53:24 -07:00
Daniel Imms 2d0937ac1d Merge pull request #2047 from Tyriar/2044_cd_fix
Base the next beta version on the correct current beta
2019-05-08 18:08:18 -07:00
Daniel Imms 0d5cd9582f Base the next beta version on the correct current beta
Fixes #2044
2019-05-08 18:03:06 -07:00
Khaja Nizamuddin e831bdf1ef Allow + char in URI path 2019-05-08 21:06:22 +05:30
Daniel Imms 4729bfaa2d Merge pull request #2043 from cubiclesoft/add_php_app_server
Added PHP App Server to Real-world uses section.
2019-05-07 18:30:04 -07:00
cubiclesoft a88469aac6 Added PHP App Server to Real-world uses section. 2019-05-07 12:07:00 -07:00
jerch d6da010c7e Merge pull request #2035 from jerch/2028_handle_joined_cells
cell representation for joined cells
2019-05-06 22:42:05 +02:00
Daniel Imms c6138edec2 Merge branch 'master' into 2028_handle_joined_cells 2019-05-05 18:55:53 -07:00
Daniel Imms 15a6c9846d Merge pull request #2040 from Tyriar/devcontainer
Add a dev container
2019-05-05 16:06:55 -07:00
Jörg Breitbart ca193ed00d Merge branch 'master' into 2028_handle_joined_cells 2019-05-05 21:54:16 +02:00
Jörg Breitbart ffcdba8d5b simplify JoinedCellData 2019-05-05 21:48:35 +02:00
Daniel Imms d68c441b86 Merge pull request #2038 from roottool/fix-that-webLinks-not-interpreted#1954
Fix that webLinks not interpreted
2019-05-03 21:13:00 -07:00
Daniel Imms 613f877954 Add a dev container
This lets users using VS Code/Docker avoid installing node and the C++
dependencies necessary for running xterm.js.
2019-05-03 21:08:25 -07:00
Daniel Imms a1353a8fb4 Merge pull request #2039 from roottool/refacter-the-css-code-of-cursor-blink
Refactored the CSS code of cursor blink
2019-05-03 12:59:04 -07:00
roottool 4269777f1c Fix: Refactored the css code of keyframes blink 2019-05-04 02:54:38 +09:00
roottool 23eed1b3ea Fix: Changed pathClause 2019-05-04 02:02:26 +09:00
Daniel Imms ebc0083531 Merge pull request #2036 from Tyriar/protect_markers
Make Terminal.markers readonly
2019-05-02 09:45:15 -07:00
Daniel Imms 7d3e2d7da4 Merge branch 'master' into protect_markers 2019-05-02 09:33:24 -07:00
Daniel Imms ea09c6af09 Fix build 2019-05-02 09:23:13 -07:00
Daniel Imms 267357c4de Merge pull request #2032 from Tyriar/task
Add build and test task
2019-05-02 07:54:42 -07:00
Daniel Imms f416bd155a Make compound task the default 2019-05-02 07:53:28 -07:00
Daniel Imms c6a3fb3b42 Merge branch 'master' into task 2019-05-02 07:47:29 -07:00
Daniel Imms cb33c897d2 Merge branch 'master' into protect_markers 2019-04-30 12:20:30 -07:00
Daniel Imms 469d5158a0 Make Terminal.markers readonly 2019-04-30 19:19:41 +00:00
Daniel Imms 766b1745d3 Merge pull request #2027 from Tyriar/auto_release
Automatically release stable builds
2019-04-29 22:50:16 -07:00
Daniel Imms 68182ed162 Merge branch 'master' into auto_release 2019-04-29 22:42:20 -07:00
Daniel Imms d261862ccb Merge pull request #2026 from Tyriar/ui_project
Create UI project, strict null check some more files
2019-04-29 22:41:54 -07:00
Daniel Imms 8d6682a2bc Merge branch 'master' into ui_project 2019-04-29 22:26:28 -07:00
Daniel Imms 63833b59ed Fix lint 2019-04-29 22:24:44 -07:00
Jörg Breitbart 4fd9b3f249 jix joined cell representation as overloaded CellData type 2019-04-30 00:58:18 +02:00
jerch 3f145b8a0c Merge pull request #2034 from jerch/2031_defaultcolor_handling
apply default fg color for uncached chars and underline in canvas renderer
2019-04-29 23:40:18 +02:00
Jörg Breitbart 1f42e7c06a fix fg color for underline 2019-04-29 23:19:16 +02:00
Jörg Breitbart 42b1dca7db add handling for default fg color 2019-04-29 22:33:01 +02:00
Daniel Imms f0c3bab156 Add build and test task 2019-04-29 11:35:42 -07:00
Daniel Imms 4453a1cbf7 Automatically release stable builds
Part of #1921
2019-04-28 03:52:43 +00:00
Daniel Imms 362152004b Move files not in ui project back to root 2019-04-28 02:28:20 +00:00
Daniel Imms 88d5cf46f8 Strict null check ScreenDprMonitor 2019-04-28 02:16:28 +00:00
Daniel Imms ebfa57b71c Strict null check RenderDebouncer 2019-04-28 02:03:41 +00:00
Daniel Imms 4c3082c924 Remove ITerminal dependency in RenderDebouncer 2019-04-28 01:59:40 +00:00
Daniel Imms 672db9437f Create ui project, add Lifecycle 2019-04-28 01:55:56 +00:00
Daniel Imms eb10652e46 Merge branch 'master' into utf8_input 2019-04-27 18:49:46 -07:00
Daniel Imms f4bbfc30f3 Merge pull request #1872 from Tyriar/cd
Setup continuous deployment beta builds
2019-04-27 18:33:46 -07:00
Daniel Imms 65eaea39d3 Base the beta build off of the next minor version 2019-04-28 00:45:51 +00:00
Daniel Imms 70db48b533 Add notice about beta builds in readme 2019-04-28 00:34:44 +00:00
Daniel Imms 779ebe87e5 Merge branch 'master' into cd 2019-04-27 16:52:09 -07:00
Daniel Imms 6237eaa86f Merge pull request #2025 from thebradbain/fix-terminal-resize
Clear line cache on terminal resize
2019-04-27 16:42:30 -07:00
Bradley Bain 736bd53e49 Clear line cache on terminal resize 2019-04-25 21:24:07 -07:00
Daniel Imms 69d43d4a40 Merge branch 'master' into cd 2019-04-14 16:04:49 -07:00
Daniel Imms 017a5b1218 Merge branch 'master' into utf8_input 2019-04-14 12:54:26 -07:00
Daniel Imms c6f785f51a Merge pull request #2014 from starpit/underline
feat: add underline support to DOM renderer
2019-04-14 11:24:25 -07:00
Nick Mitchell 8718d3a4ca feat: add underline support to DOM renderer
part of #1896
2019-04-14 13:47:58 -04:00
Daniel Imms 7aaa1ad0bb Merge pull request #2009 from Tyriar/single_quote
Add vscode setting for single quote style
2019-04-12 09:36:35 -07:00
Daniel Imms fa70aa0983 Merge pull request #2008 from Tyriar/event_emitter_2
Explicit event API
2019-04-11 09:08:15 -07:00
Daniel Imms 89a3931a68 Merge branch 'master' into event_emitter_2 2019-04-11 08:15:19 -07:00
Daniel Imms a0ee09a7bc Add vscode setting for single quote style
This will alwayts use single quotes when TS server does auto imports,
implement interface, etc.
2019-04-11 08:14:18 -07:00
Daniel Imms 94415a227d Merge pull request #1866 from ntchjb/master
Fix search addons: Fix problem of skipping some results and incorrect text selection after resize window
2019-04-10 03:45:58 -04:00
Daniel Imms 0b4ff4bb6b Merge branch 'master' into event_emitter_2 2019-04-10 03:34:37 -04:00
Daniel Imms 4be376d397 Merge branch 'master' into master 2019-04-10 03:31:40 -04:00
Daniel Imms 5362ea195c Add first API test 2019-04-10 00:24:50 -07:00
Daniel Imms b55bedc6af Add terminal API interface to Types.ts
This is needed since the API/public buffer now differs from the TerminalCore's
2019-04-09 21:29:08 -07:00
Daniel Imms cf4b59567b Add tests for new events 2019-04-09 21:01:55 -07:00
Daniel Imms b9bc219ecc Make events in d.ts alphabetical 2019-04-09 20:52:18 -07:00
Daniel Imms f4c7e3fd7d Remove extends EventEmitter from Linkifier 2019-04-09 20:43:42 -07:00
Daniel Imms 36567e60df Remove extends EventEmitter from more classes 2019-04-09 20:36:08 -07:00
Daniel Imms 2e0e24c382 Remove extends EventEmitter from SelectinoManager 2019-04-09 20:26:18 -07:00
Daniel Imms 290bde6163 Convert refresh to EventEmitter2 2019-04-09 20:16:26 -07:00
Daniel Imms db78b75e8b Convert selection to EventEmitter2 2019-04-09 20:05:13 -07:00
Daniel Imms 87328fe293 Convert data to EventEmitter2 2019-04-09 19:53:02 -07:00
Daniel Imms 2c96c262f4 Convert scroll to EventEmitter2 2019-04-09 19:42:53 -07:00
Daniel Imms f111aa27dc Convert linefeed to EventEmitter2 2019-04-09 19:35:41 -07:00
Daniel Imms 8e5d372b81 Convert cursormove to EventEmitter2 2019-04-09 19:31:59 -07:00
Daniel Imms 8b5b64605e Start find previous from the current viewport 2019-04-09 19:53:22 -04:00
Daniel Imms 0c388c69bc Merge branch 'master' into pr/jerch/1904 2019-04-09 19:38:39 -04:00
Daniel Imms 660466d244 Merge pull request #1923 from jerch/fix_1879
signal sequence was finally handled
2019-04-09 11:15:02 -04:00
Daniel Imms dee4429151 Remove unneeded interfaces 2019-04-09 11:11:16 -04:00
Daniel Imms c3d1b0703c Merge branch 'master' into fix_1879 2019-04-09 11:10:17 -04:00
Daniel Imms 71827f7981 Merge branch 'master' into master 2019-04-09 11:01:02 -04:00
Daniel Imms 2d80abe801 Merge branch 'master' into 1128_addons 2019-04-09 10:57:32 -04:00
Daniel Imms 6b0f2170ea Merge branch 'master' into 1994_buffer_api 2019-04-09 10:57:22 -04:00
Daniel Imms a86c2943b8 Merge branch 'master' into event_emitter_2 2019-04-09 10:57:11 -04:00
Daniel Imms cb591f212a Merge pull request #2006 from skavanagh/patch-1
Added Bastillion to Real-world uses
2019-04-09 10:53:08 -04:00
Sean Kavanagh e5f94391ae Update README.md 2019-04-09 09:10:29 -04:00
Daniel Imms 5476f4cb93 Merge pull request #2002 from Tyriar/1932_broken_reflow
Fix reflow case where wrapped line portions ended in \t
2019-04-08 18:59:21 -04:00
Daniel Imms aaf8b80292 Merge branch 'master' into 1932_broken_reflow 2019-04-08 18:51:02 -04:00
Daniel Imms 9ab3d319d1 Merge pull request #2004 from Tyriar/dim_dom_renderer_test
Add a test for dim flag in dom renderer
2019-04-08 10:56:15 -04:00
Daniel Imms efeca49705 Mostly implemented buffer API
Part of #1994
2019-04-07 15:29:37 -04:00
Daniel Imms 267071ead6 Add deprecation message to applyAddon 2019-04-07 15:00:27 -04:00
Daniel Imms 26a80d0d35 Convert to much simpler model 2019-04-07 14:53:09 -04:00
Daniel Imms 49f58f5d25 Merge branch 'master' into 1128_addons 2019-04-07 14:24:29 -04:00
Daniel Imms a0b4ee56f6 Add a test for dim flag in dom renderer 2019-04-07 14:17:38 -04:00
Daniel Imms 6ff81c43f6 Convert marker dispose, selection manager newselection 2019-04-07 14:09:31 -04:00
Daniel Imms 625e168e1b Convert title and resize events 2019-04-07 14:02:11 -04:00
Daniel Imms b2ab89ddaa Merge branch 'master' into event_emitter_2 2019-04-07 13:56:50 -04:00
Daniel Imms 4ace81d994 Merge branch 'master' into 1932_broken_reflow 2019-04-07 13:53:23 -04:00
Daniel Imms 25745777c6 Merge pull request #2003 from Tyriar/fix_merge_problem
Fix compile error from conflicting PRs
2019-04-07 13:53:09 -04:00
Daniel Imms 74b68ac1c7 Fix compile error from conflicting PRs 2019-04-07 13:49:56 -04:00
Daniel Imms 2a4208cf3e Merge branch 'master' into 1932_broken_reflow 2019-04-07 13:48:31 -04:00
Daniel Imms e58033bbac Merge pull request #1895 from jerch/true_color
True color support
2019-04-07 13:45:08 -04:00
Daniel Imms bd92aaf4dc Merge branch 'master' into 1932_broken_reflow 2019-04-07 13:44:29 -04:00
Daniel Imms 3ac313f8e1 Fix reflow larger case
Fixes #1932
2019-04-07 13:18:05 -04:00
Daniel Imms ab44650d87 Fix reflow smaller case related to ended \t chars
Part of #1932
2019-04-07 13:16:20 -04:00
Daniel Imms 11ab4dbd5b Merge pull request #2000 from starpit/dim
feat: add DIM support to DomRenderer
2019-04-07 09:47:51 -04:00
Daniel Imms 92c435a16d Use same dim opacity as canvas renderer 2019-04-07 09:45:54 -04:00
Nick Mitchell ddd02b4968 feat: add DIM support to DomRenderer
part of #1896
2019-04-06 16:04:50 -04:00
Daniel Imms 7e36bf47c6 Have undefined | true mean success 2019-04-06 15:21:20 -04:00
Daniel Imms d6daf40250 Merge branch 'master' into fix_1879 2019-04-06 15:08:58 -04:00
Daniel Imms 09a5fd4e61 Fix capitalization in color mode 2019-04-06 15:06:42 -04:00
Daniel Imms 171b9337cb Make BufferLine enums const 2019-04-06 14:56:15 -04:00
Daniel Imms bb324ba9c1 Move width shift back into enum 2019-04-06 14:55:43 -04:00
Daniel Imms 27283e45e9 Merge branch 'master' into true_color 2019-04-06 14:13:14 -04:00
Daniel Imms 23ce6ce19e Merge pull request #1999 from asadm/master
add CodeInterview.io in README
2019-04-05 11:12:03 -04:00
Asad Memon e8a9994583 add CodeInterview.io in README 2019-04-04 11:58:19 -07:00
Daniel Imms 46f3b3fa62 Merge branch 'master' into true_color 2019-04-04 01:06:26 -04:00
Daniel Imms 2f8d49c74d Convert internal key event usages 2019-04-04 00:45:57 -04:00
Daniel Imms 629238ae70 Use onResize in demo 2019-04-04 00:25:03 -04:00
Daniel Imms 3f9d90ecf6 Remove unnecessary paste listener from demo 2019-04-04 00:23:12 -04:00
Daniel Imms f35dfb496a Use onKey in demo 2019-04-04 00:22:34 -04:00
Daniel Imms 4e6f4be6cc Convert Listener to an interface 2019-04-04 00:14:04 -04:00
Daniel Imms 798cf8abc3 Merge branch 'master' into event_emitter_2 2019-04-04 00:12:07 -04:00
Daniel Imms b591db8c02 Merge pull request #1997 from Tyriar/1989_backspace_demo
Fix backspace on demo
2019-04-04 00:06:09 -04:00
Daniel Imms b18829963c Fix backspace on demo
buffer.x will probably be public API soon (#1994)

Fixes #1989
2019-04-04 00:01:43 -04:00
Daniel Imms e402dba635 Merge pull request #1995 from termius/fix_csi_scroll_down
Fix CSI scroll down handler
2019-04-03 23:57:01 -04:00
Daniel Imms 2023b5b677 Merge pull request #1992 from Tyriar/1990_layering_libs
Ensure DOM APIs cannot be used in common and core
2019-04-03 18:28:53 -04:00
Vadim Zakondyrin 68e3d7fa16 Fix CSI scroll down handler
The issue has been introduced in cd8477a942
2019-04-03 12:10:32 +06:00
Daniel Imms 3f993d675f Fix conflicts with new stuff 2019-04-02 20:17:33 -04:00
Daniel Imms 7ddcf1a2a2 Merge branch 'master' into 1128_addons 2019-04-02 20:16:09 -04:00
Daniel Imms e6333bde2d Merge branch 'master' into true_color 2019-04-02 17:13:21 -07:00
Daniel Imms 51c7337099 Merge branch 'master' into 1990_layering_libs 2019-04-02 17:10:49 -07:00
Daniel Imms 6476429077 Merge pull request #1993 from Tyriar/windows_mode
Replace winptyCompat addon with windowsMode option
2019-04-02 17:08:31 -07:00
Daniel Imms 7b9a718af0 Fix some imports to point at ts files, not lib/ 2019-04-02 16:45:43 -07:00
Daniel Imms 60113fa155 Replace EventEmitter usage in CharMeasure 2019-04-02 11:38:55 -07:00
Daniel Imms 60c2b20d68 Replace EventEmitter usage in BufferSet 2019-04-02 11:35:20 -07:00
Daniel Imms f8fb4da9f4 Replace EventEmitter with EventEmitter2 in CircularList 2019-04-02 11:30:47 -07:00
Daniel Imms 5f014be057 Add onCursorMove, replace .on usage in addons 2019-04-02 11:12:57 -07:00
Daniel Imms b12d2c218e Remove reference to winptyCompat tsconfig 2019-04-02 11:03:24 -07:00
Daniel Imms ba4662ac14 Introduce new onEvent APIs and deprecate on/off/etc.
Part of #1505
2019-04-02 11:01:16 -07:00
Daniel Imms ca1f7f1392 Add EventEmitter2 2019-04-02 10:11:59 -07:00
Daniel Imms fa505111a2 Replace winptyCompat addon with windowsMode option 2019-04-02 08:51:23 -07:00
Daniel Imms 2e10c8c25e Clean up 2019-04-02 08:04:39 -07:00
Daniel Imms 8d4da3c2ac Merge branch 'master' into pr/jerch/1895 2019-04-02 07:53:22 -07:00
Daniel Imms 81dda13218 Merge branch 'master' into 1990_layering_libs 2019-04-02 06:35:59 -07:00
Daniel Imms 0a8d57ce74 Merge pull request #1878 from jerch/utf32_buffer
Utf32 buffer
2019-04-01 17:50:09 -07:00
Daniel Imms 5c8c680dac Fix feedback 2019-04-01 00:01:41 -07:00
Daniel Imms 69f8700557 Merge branch 'master' into pr/jerch/1878 2019-03-31 23:34:46 -07:00
Daniel Imms 4a3609f805 Move platform to common and remove dom dependence in common
Because common/ imports 'xterm', it also imported dom accidentally.

Fixes #1990
2019-03-31 23:24:29 -07:00
Daniel Imms fa2cbb0aca Merge branch 'master' into fix_1879 2019-03-30 15:38:53 -07:00
Daniel Imms b05c66b132 Merge pull request #1987 from Tyriar/1986_localhost
Recommend 127.0.0.1:3000 on mac and linux too
2019-03-30 15:36:42 -07:00
Daniel Imms 75046235af Merge pull request #1984 from Tyriar/project_references
Build using TypeScript project references
2019-03-30 15:09:11 -07:00
Daniel Imms bab94ebbdc Merge pull request #1958 from nikonso/1947-weblinks-with-selection
WebLinks plugin don't follow link on selection
2019-03-30 15:07:34 -07:00
Daniel Imms 4d008c66f1 Recommend 127.0.0.1:3000 on mac and linux too
Fixes #1986
2019-03-30 15:06:25 -07:00
Daniel Imms bf9d879efa Fix typo 2019-03-30 14:59:31 -07:00
Daniel Imms 636afa11d6 Merge branch 'master' into 1947-weblinks-with-selection 2019-03-30 14:57:24 -07:00
Daniel Imms 1283123d4d Merge pull request #1985 from Tyriar/fix_demo_non_win
Fix demo on non-Windows
2019-03-30 14:55:00 -07:00
Daniel Imms e182e3d4e4 Fix demo on non-Windows
Broke in #1978
2019-03-30 14:52:48 -07:00
Daniel Imms 51033596ef Merge branch 'master' into 1947-weblinks-with-selection 2019-03-30 14:47:46 -07:00
Daniel Imms 0960a7ae14 Merge branch 'master' into project_references 2019-03-30 14:43:11 -07:00
Daniel Imms 84d5963e7e Merge pull request #1976 from Tyriar/1975_renderer_pause_fix
Fix renderer pausing to not full refresh every time
2019-03-30 14:42:38 -07:00
Daniel Imms 10b7b467b4 Merge pull request #1978 from Tyriar/move_windows_check
Let consumers decide whether winptyCompat should be active
2019-03-30 14:41:58 -07:00
Daniel Imms 2317a319d0 Merge pull request #1982 from Tyriar/1981_prevent_scroll_on_focus
Prevent scroll on focus
2019-03-30 14:40:26 -07:00
Daniel Imms f80924fb8d Remove zmodem demo 2019-03-30 14:12:15 -07:00
Daniel Imms 18f4dc6b3e Remove concurrently 2019-03-30 14:09:51 -07:00
Daniel Imms b400f9ca3b Don't clear terminal on yarn watch 2019-03-30 14:08:57 -07:00
Daniel Imms 0b78011fa3 Adopt project references
Recent versions of TypeScript has improved the performance of project
references so they are now viable to switch over to.
2019-03-30 14:05:24 -07:00
Daniel Imms 2be0a5819b Merge branch 'master' into 1981_prevent_scroll_on_focus 2019-03-29 19:57:33 -07:00
Daniel Imms e346f8bba3 Prevent scroll on focus
Fixes #1981
2019-03-29 19:46:24 -07:00
Daniel Imms 1451bcb6ae Merge pull request #1961 from nikonso:1773-take-drawBoldTextInBrightColors-into-account
Fix #1773 - drawBoldTextInBrightColors is not taken into account with DOM renderer
2019-03-29 12:59:20 -07:00
Daniel Imms f1ef9abc77 Merge pull request #1979 from JesseStolwijk:master
#1977 Add blinking cursor to DomRenderer
2019-03-29 12:51:49 -07:00
Jesse Stolwijk f9df863ee0 Add blinking cursor to DomRenderer 2019-03-25 22:17:16 +01:00
Daniel Imms e6ac5634bb Merge branch 'master' into move_windows_check 2019-03-23 11:38:19 -07:00
Daniel Imms 4dbe8ec1db Let consumers decide whether winptyCompat should be active 2019-03-23 10:58:26 -07:00
Daniel Imms 8b6d564598 Merge pull request #1968 from nikonso/new-feature
Use new vscode serverReadyAction
2019-03-23 09:37:15 -07:00
Daniel Imms 131e4f78bd Fix renderer pausing to not full refresh every time
Fixes #1975
2019-03-23 09:08:55 -07:00
Daniel Imms 99beeb2270 Merge pull request #1973 from zhaojh329/master
Modify uses
2019-03-19 10:46:23 -07:00
Jianhui Zhao 0d63cecc6b Modify uses
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
2019-03-19 14:04:16 +08:00
ntchjb 3c444ca39a Fixed coding format 2019-03-15 19:20:23 +07:00
ntchjb 03e648a0fb Fixed the case that, if findPrevious is run without any selection, then start scan at the last row 2019-03-15 19:15:41 +07:00
Max 48a98fa29f Merge pull request #1 from xtermjs/master
update branch
2019-03-15 17:26:55 +07:00
Bruno Ribeito 27ebe8c353 Use new vscode serverReadyAction 2019-03-11 20:58:42 +00:00
Bruno Ribeito 62cfa642cb Better aproach, check i a selection is being performed 2019-03-11 20:54:17 +00:00
Bruno Ribeito c16e3e54e8 Merge branch 'master' of https://github.com/xtermjs/xterm.js into 1947-weblinks-with-selection 2019-03-11 20:41:23 +00:00
Daniel Imms bc86a61a0c Merge pull request #1966 from turtle0x1/master
Add LxdMosaic to list of applications that use xterm.js
2019-03-11 10:29:22 -07:00
turtle0x1 19d36f9228 Update readme with link for lxdmosaic 2019-03-11 13:47:25 +00:00
Bruno Ribeito b4bef0986c Remove circular dependency 2019-03-10 22:03:38 +00:00
Daniel Imms f63bd3d218 Merge branch 'master' into master 2019-03-08 11:47:41 -08:00
Daniel Imms 5cf2a21ddd Merge branch 'master' into cd 2019-03-08 11:44:55 -08:00
Daniel Imms 7e1b5cc7e9 Merge pull request #1952 from NickShaffner/master
Fix for issue #812: Xterm.js's encoding of mouse coordinate
2019-03-08 09:50:24 -08:00
Daniel Imms 4046d682c9 v3.12.0 2019-03-08 09:21:01 -08:00
jerch 127a2ca27a Merge branch 'master' into master 2019-03-07 23:28:26 +01:00
Bruno Ribeito 525af9c36a Fix #1773 2019-03-07 21:30:32 +00:00
Bruno Ribeito 5878aa099d Cleaner aproach 2019-03-07 21:00:07 +00:00
Daniel Imms 9597ad20d3 Merge pull request #1950 from Tyriar/1943_winpty_compat_reflow
Disable reflow when winptyCompat is on
2019-03-07 12:38:30 -08:00
Daniel Imms 6deb3e13d2 Merge pull request #1938 from Tyriar/1937_uncached_char_top_fix
Align y draw coord with how cache draws it
2019-03-07 12:38:00 -08:00
Daniel Imms ecb7f429bc Merge branch 'master' into 1937_uncached_char_top_fix 2019-03-07 12:34:57 -08:00
Daniel Imms ce09ae4ff8 Merge pull request #1959 from nikonso/1908-leave-callback
Fix #1908 - leaveCallback does not fire when links are on the edge of the terminal
2019-03-07 11:17:49 -08:00
Bruno Ribeito bc41cc7d27 Fix #1908 2019-03-07 00:15:03 +00:00
Bruno Ribeito 51e2cdfafb WIP: First draft 2019-03-06 21:45:53 +00:00
Daniel Imms f41146fb40 Merge pull request #1934 from ahtshamraziq/fix-docker-compose-variable-substitution
Compose file: fix variable substitution
2019-03-05 08:31:59 -08:00
Daniel Imms 8fa7f177a6 Merge pull request #1956 from JesseStolwijk/master
Replace array shift with offset
2019-03-05 08:18:06 -08:00
Jesse Stolwijk 07430a4892 Replace array shift with offset (#1955) 2019-03-05 00:00:54 +01:00
Daniel Imms ce1c45fb18 Merge pull request #1818 from juancampa/perf3
Use a time-based limit in Terminal._innerWrite
2019-03-04 10:50:27 -08:00
Daniel Imms 55f3aeeff5 Merge branch 'master' into perf3 2019-03-04 10:39:00 -08:00
Daniel Imms a99364eae9 Merge branch 'master' into fix_1879 2019-03-04 10:37:51 -08:00
Daniel Imms 7b41b002c6 Merge branch 'master' into master 2019-03-04 10:05:18 -08:00
Daniel Imms 32e157bfaa Remove unnecessary else 2019-03-04 10:04:52 -08:00
Daniel Imms 655c595011 Merge pull request #1927 from pfitzseb/sp/mousehandlerfix
*actually* fix mouse handler before term attached
2019-03-04 10:01:42 -08:00
Daniel Imms 064a372c71 Merge branch 'master' into sp/mousehandlerfix 2019-03-04 10:00:38 -08:00
Daniel Imms c63f15a9b2 Fix lint 2019-03-04 10:00:04 -08:00
Daniel Imms 1aa40eb58b Merge branch 'master' into fix-docker-compose-variable-substitution 2019-03-04 09:57:33 -08:00
Daniel Imms d8b973b126 Merge pull request #1929 from coderaiser/patch-1
fix: Renderer: IntersectionObserver can produce more then 1 entry
2019-03-04 09:54:53 -08:00
Daniel Imms 05b162eefd Merge branch 'master' into patch-1 2019-03-04 09:53:12 -08:00
Daniel Imms 46aa6a40f9 Merge branch 'master' into fix-docker-compose-variable-substitution 2019-03-04 09:49:12 -08:00
Daniel Imms 9f2aec1944 Merge branch 'master' into 1937_uncached_char_top_fix 2019-03-04 09:47:33 -08:00
Daniel Imms 42b66d98b2 Merge branch 'master' into 1943_winpty_compat_reflow 2019-03-04 09:46:15 -08:00
Daniel Imms 1eee182860 Merge pull request #1930 from Tyriar/1926_reflow_larger_fix
Make sure the viewport is filled when reflowing a row change
2019-03-04 09:45:43 -08:00
Daniel Imms bd602fb078 Merge branch 'master' into 1926_reflow_larger_fix 2019-03-04 07:23:06 -08:00
Daniel Imms 8ea254bdc7 Merge pull request #1953 from cherouvim/patch-1
docs: style improvements
2019-03-01 11:26:06 -08:00
Ioannis Cherouvim 09754fddf8 xterm.js references to the library should not be backticked 2019-03-01 21:15:20 +02:00
Ioannis Cherouvim a8a0344d1a docs: style improvements
- Added a trailing dot at the end of each list line.
- Consistent usage of `xterm.js` in "Real-world uses".
2019-03-01 14:51:19 +02:00
Ioannis Cherouvim 4e479b455a docs: Consistent style on lists.
Added some missing dots, capitalized a couple of lines.
2019-03-01 14:40:21 +02:00
Nick Shaffner e178139907 Fix for issue #812: Xterm.js's encoding of mouse coordinate
See: https://github.com/xtermjs/xterm.js/issues/812
Changed the utf-8 mouse encoding to match iTerm
2019-02-27 22:37:22 -08:00
Sebastian Pfitzner 0854f84653 actually fix mouse handler before term attached 2019-02-26 11:31:22 +01:00
Daniel Imms a35cd43395 Merge branch 'master' into 1943_winpty_compat_reflow 2019-02-20 10:02:54 -08:00
Daniel Imms 3285374618 Disable reflow when winptyCompat is on
Fixes #1943
2019-02-20 07:03:40 -08:00
Daniel Imms 6ad6a01c3f Merge pull request #1949 from liuzheng/master
Update README.md
2019-02-20 06:21:08 -08:00
夏虫 e1c1c7a4f2 Update README.md
move it to the bottom
2019-02-20 14:57:16 +08:00
Daniel Imms 437a59d4cd Merge branch 'master' into 1937_uncached_char_top_fix 2019-02-19 07:19:33 -08:00
夏虫 9f29eeed23 Update README.md
(Jumpserver)[https://github.com/jumpserver/] use xterm.js
2019-02-19 17:19:19 +08:00
coderaiser b0f01beb0f Merge branch 'master' into patch-1 2019-02-15 16:57:58 +02:00
Daniel Imms 857ae4b702 Merge pull request #1936 from Tyriar/1935_remove_font_family
Remove font-family from .css file
2019-02-11 07:24:11 -08:00
Daniel Imms c934200c86 Also set font size 2019-02-11 06:07:31 -08:00
Daniel Imms 78426d8a12 Make the composition view use the same font as the terminal 2019-02-11 06:05:14 -08:00
Daniel Imms 817401bbcd Align y draw coord with how cache draws it
Fixes #1937
2019-02-11 05:32:47 -08:00
Daniel Imms 84d7bfeacc Remove font-family from .css file
Fixes #1935
2019-02-11 05:14:55 -08:00
Ahtsham Raziq 92be01dd81 Compose file: fix variable substitution 2019-02-09 23:24:32 +05:00
Daniel Imms d17dfbc73f Cover a case when resizing smaller making y go out of bounds 2019-02-08 12:13:00 -08:00
Daniel Imms ba9ed43acd Merge branch 'master' into utf32_buffer 2019-02-05 11:39:08 -08:00
Daniel Imms b88230db8b Make sure the viewport is filled when reflowing a row change
Fixes #1926
2019-02-05 08:20:16 -08:00
coderaiser 69d3a4667f fix: Renderer: IntersectionObserver can produce more then 1 entry 2019-02-04 13:28:14 +02:00
Daniel Imms abf6a9fa58 Merge pull request #1925 from xtermjs/Tyriar-patch-1
Add roadmap wiki link to README
2019-02-03 15:37:50 -08:00
Daniel Imms ea9d1d7ef0 Merge pull request #1928 from xtermjs/Tyriar-patch-2
Update license year
2019-02-03 15:37:40 -08:00
Daniel Imms f3aac10bbd Update license year 2019-02-03 10:46:20 -08:00
Daniel Imms f30012b985 Merge branch 'master' into fix_1879 2019-02-01 20:03:40 -08:00
Daniel Imms db9aa5c88b Merge pull request #1916 from skyway777:master
Clear selection state if selection doesn't exists
2019-02-01 19:39:25 -08:00
Daniel Imms 1829cb7609 Add roadmap wiki link to README 2019-02-01 19:28:07 -08:00
Daniel Imms 6d6be9bed8 Merge pull request #1924 from xtermjs/Tyriar-patch-1
v3.11.0
2019-02-01 18:29:09 -08:00
Daniel Imms 54a1319f57 v3.11.0 2019-02-01 18:23:10 -08:00
Jörg Breitbart 65dbf88460 apply bright shift for uncached draws 2019-02-01 21:44:51 +01:00
Jörg Breitbart 0c54b1a29e Merge branch 'master' into true_color 2019-02-01 20:59:31 +01:00
Jörg Breitbart 179e5d5892 Merge branch 'master' into utf32_buffer 2019-02-01 20:59:02 +01:00
Jörg Breitbart 6993daef15 Merge branch 'master' into fix_1879 2019-02-01 20:38:45 +01:00
Jörg Breitbart 801db3831d type add methods 2019-02-01 20:32:07 +01:00
Jörg Breitbart e813ae02fc return true from inputhandler methods to signal sequence was handled 2019-02-01 20:28:45 +01:00
Daniel Imms 73ec8a89a0 Merge pull request #1912 from mofux/contextmenu_fix
Make textarea positioning work with css transformations
2019-02-01 09:53:16 -08:00
Jörg Breitbart c2446df966 Merge branch 'utf32_buffer' into true_color 2019-02-01 01:30:29 +01:00
Jörg Breitbart 2de39024be Merge branch 'utf32_buffer' into utf8_input 2019-02-01 01:11:58 +01:00
Jörg Breitbart 079729f1b4 change property getter into methods 2019-02-01 01:10:20 +01:00
Jörg Breitbart ec3a95f727 Merge branch 'utf32_buffer' into utf8_input 2019-01-31 23:32:48 +01:00
Jörg Breitbart c4a5e0862c Merge branch 'utf32_buffer' into true_color 2019-01-31 23:16:23 +01:00
Jörg Breitbart 594797e05b Merge branch 'master' into utf32_buffer 2019-01-31 23:15:50 +01:00
jerch 682efc7206 Merge pull request #1887 from jerch/fix_linkifier_offset
account empty cells in stringIndexToBufferIndex
2019-01-31 23:07:24 +01:00
jerch 9791d8ab49 Merge branch 'master' into fix_linkifier_offset 2019-01-31 23:02:53 +01:00
Daniel Imms 8e88ce8da5 Merge pull request #1919 from xtermjs/Tyriar-patch-1
Improve docs on Terminal.resize
2019-01-31 14:02:12 -08:00
Daniel Imms 828f14f2ab Improve docs on Terminal.resize 2019-01-31 14:00:39 -08:00
Jörg Breitbart 7b7f85e3cf add test for correct tab handling, docs 2019-01-31 22:56:55 +01:00
Jörg Breitbart 7da40b9d56 Merge branch 'utf32_buffer' into true_color 2019-01-31 22:13:33 +01:00
Jörg Breitbart a1b61e05f9 Merge branch 'master' into utf32_buffer 2019-01-31 21:51:58 +01:00
jerch 21cb9872f3 Merge branch 'master' into fix_linkifier_offset 2019-01-31 20:33:26 +01:00
Daniel Imms 93d3842156 Merge pull request #1917 from Tyriar/vscode67364
Fix various problems with reflow
2019-01-31 09:07:51 -08:00
Daniel Imms db31a44da3 Fix tests 2019-01-30 22:14:47 -08:00
Daniel Imms 33e46682b1 Fix various problems with reflow
- No longer reflow lines where the full unwrapped line contains the cursor
- Add guards to prevent y and ybase becoming invalid values

Part of Microsoft/vscode#67364
Fixes #1910
2019-01-30 21:47:39 -08:00
Nikita Chuklinov fc1692b3eb clear state if selection doesn't exists 2019-01-30 20:34:16 +03:00
Daniel Imms d48982b60e Merge branch 'master' into cd 2019-01-28 07:25:55 -08:00
Daniel Imms 9c72254d3a Bump to 3.11.0 2019-01-28 07:23:58 -08:00
Daniel Imms af6544d6d9 Improve package.json modifications 2019-01-28 07:23:46 -08:00
Jörg Breitbart 39fd6c427d name polishing, docs 2019-01-28 10:42:44 +01:00
Jörg Breitbart ef3c0c0e72 Merge branch 'fix_linkifier_offset' of git+ssh://github.com/jerch/xterm.js into fix_linkifier_offset 2019-01-27 22:23:08 +01:00
Jörg Breitbart 13f0fd0503 Merge branch 'master' into fix_linkifier_offset 2019-01-27 22:22:52 +01:00
Jörg Breitbart c60f9b1468 code formatting 2019-01-27 20:06:58 +01:00
Jörg Breitbart e77e36cbb7 fix typo in HAS_CONTENT 2019-01-27 19:59:13 +01:00
Jörg Breitbart b20730ee4d add more docs 2019-01-27 19:40:28 +01:00
Jörg Breitbart acea73c8ac Merge branch 'master' into utf32_buffer 2019-01-27 19:02:09 +01:00
jerch cc531f1933 Merge pull request #1796 from jerch/typedarray_parser
support typed array in parser
2019-01-27 18:22:08 +01:00
Daniel Imms c1b0c9bbf1 Merge branch 'master' into fix_linkifier_offset 2019-01-27 08:45:57 -08:00
Jörg Breitbart 358d70d721 cleanup gitignore 2019-01-27 17:34:58 +01:00
Jörg Breitbart 975dfc4a5e Merge branch 'typedarray_parser' of git+ssh://github.com/jerch/xterm.js into typedarray_parser 2019-01-27 17:29:41 +01:00
Jörg Breitbart fdf784ea96 Merge branch 'master' into typedarray_parser 2019-01-27 17:29:12 +01:00
Jörg Breitbart e67bef69f4 cleanup types 2019-01-27 17:28:15 +01:00
Daniel Imms 8b6327b563 Merge branch 'master' into master 2019-01-27 08:18:40 -08:00
Daniel Imms 8e37883b90 Merge branch 'master' into typedarray_parser 2019-01-27 08:11:37 -08:00
Daniel Imms ace855d0fe Merge branch 'master' into contextmenu_fix 2019-01-27 07:49:03 -08:00
Daniel Imms 007cac22d2 Merge branch 'master' into cd 2019-01-27 07:29:34 -08:00
Daniel Imms b047045949 Replace hardcoded version 2019-01-27 07:28:04 -08:00
Daniel Imms c7cfca395c Merge pull request #1871 from Tyriar/1867_readonly_api_props
Make Terminal API properties readonly
2019-01-27 07:25:15 -08:00
Daniel Imms a7f2348c63 Merge branch 'master' into 1867_readonly_api_props 2019-01-27 07:17:07 -08:00
Daniel Imms 51a148508e Merge pull request #1900 from Tyriar/cleanup
Remove unused var and unneeded defensive check
2019-01-27 07:16:53 -08:00
Jörg Breitbart 90a41a113a review changes 2019-01-27 13:22:34 +01:00
Thomas Zilz 2a1f25e7dc Make textarea positioning work with css transformations on parent elements 2019-01-27 13:15:37 +01:00
Daniel Imms 7e3b315d91 Merge branch 'master' into perf3 2019-01-26 13:20:32 -08:00
Daniel Imms 3a32a5714c Merge branch 'master' into cleanup 2019-01-26 13:17:32 -08:00
Daniel Imms 273cc45357 Merge branch 'master' into cd 2019-01-26 13:12:40 -08:00
Daniel Imms 4dab31dbe0 Merge branch 'master' into 1867_readonly_api_props 2019-01-26 12:58:13 -08:00
Jörg Breitbart 87e9789748 more explicit docs for DCS parsers 2019-01-25 18:16:01 +01:00
Jörg Breitbart 4855b60ffe move utf32ToString to TextDecoder.ts 2019-01-25 17:35:12 +01:00
Jörg Breitbart 21165a4286 Merge branch 'master' into typedarray_parser 2019-01-25 16:53:06 +01:00
Daniel Imms c908da351b Merge pull request #1864 from Tyriar/622_reflow3
Reflow text on resize
2019-01-24 20:04:33 -08:00
Daniel Imms 52a429f584 Merge branch 'master' into 622_reflow3 2019-01-24 19:01:21 -08:00
Jörg Breitbart e6447bc91f Merge branch 'master' into true_color 2019-01-25 02:43:52 +01:00
Jörg Breitbart b587c2f30f Merge branch 'master' into utf8_input 2019-01-25 02:43:07 +01:00
Jörg Breitbart 4f531f8490 Merge branch 'master' into utf32_buffer 2019-01-25 02:42:40 +01:00
Jörg Breitbart 19931e75c0 Merge branch 'master' into typedarray_parser 2019-01-25 02:41:56 +01:00
Daniel Imms 2edf02e468 Merge pull request #1905 from pfitzseb/sp/mousehandler
fix mouse event listener change before term attached
2019-01-24 11:49:09 -08:00
Daniel Imms e1363e9fe7 Replace if/add/remove with a toggle 2019-01-24 11:32:09 -08:00
Daniel Imms 109e3a50e8 jsdoc 2019-01-24 10:20:18 -08:00
Daniel Imms 99ac78031c Remove out param from reflow large method 2019-01-24 09:11:16 -08:00
Daniel Imms d4bd8ae2be Pull more parts out of reflow larger 2019-01-23 23:58:38 -08:00
Daniel Imms dfff04cf3d Pull toRemove step into BufferReflow 2019-01-23 23:51:28 -08:00
Daniel Imms deb04ca162 Merge branch 'master' into 622_reflow3 2019-01-23 22:48:53 -08:00
Daniel Imms 178c513407 Clean up 2019-01-23 22:48:32 -08:00
Daniel Imms df7cd9c319 Get reflow smaller working for wide chars 2019-01-23 22:40:40 -08:00
Daniel Imms ce69dceee7 Progress on reflow smaller with wide chars 2019-01-23 21:46:35 -08:00
Daniel Imms 4843ca5bb8 Fix reflow larger with wide chars 2019-01-21 09:08:33 -08:00
Sebastian Pfitzner 8bdb606fd1 fix mouse event listener change before term attached 2019-01-21 11:09:00 +01:00
Jörg Breitbart e6e5ecc0f2 change demo to utf8 input 2019-01-20 23:06:51 +01:00
Jörg Breitbart 3a2076805c Merge branch 'master' into utf8_input 2019-01-20 22:44:15 +01:00
Jörg Breitbart d7ea0edfcf add utf8 input to terminal 2019-01-20 22:19:50 +01:00
Daniel Imms 50abb43e9c Remove request term info handler
We're not supporting it anyway, no point having it.
2019-01-20 12:56:49 -08:00
Jörg Breitbart 6bdd380890 add utf8 decoder 2019-01-20 21:54:58 +01:00
Daniel Imms 07d3407892 Remove unused var and unneeded defensive check
...items as an arg will always be an array
2019-01-17 09:48:18 -08:00
Daniel Imms 68197ed47b Merge branch 'master' into 622_reflow3 2019-01-16 19:41:46 -08:00
Jörg Breitbart b13b737a07 Merge branch 'master' into true_color 2019-01-17 02:09:44 +01:00
Jörg Breitbart 200f7bf33d Merge branch 'master' into utf32_buffer 2019-01-17 02:09:19 +01:00
Jörg Breitbart 9549896ea5 Merge branch 'master' into typedarray_parser 2019-01-17 02:08:58 +01:00
Jörg Breitbart 2370038523 always draw RGB uncached 2019-01-17 01:41:48 +01:00
Jörg Breitbart df739ab814 remove old color and flag shims 2019-01-17 01:31:59 +01:00
Jörg Breitbart 8d850d6c8b apply CellData to canvas renderer 2019-01-17 01:25:16 +01:00
Jörg Breitbart ae50d84c5a fix characterjoiner to support AttrData 2019-01-17 00:07:25 +01:00
Daniel Imms daaed5ac8f Merge pull request #1897 from juancampa/char-measure-fix
Prevent charsizechanged from firing unnecessarily
2019-01-16 13:07:54 -08:00
Juan Campa e02a9ff09e Prevent charsizechanged from firing unnecessarily 2019-01-15 11:00:34 -05:00
Jörg Breitbart 1536e79542 remove printf remnant 2019-01-15 03:24:47 +01:00
Jörg Breitbart 94c19fb92a preliminarly RGB support in canvas renderer 2019-01-15 03:13:44 +01:00
Jörg Breitbart 9cf479bcfa cleanup rgb channel conversion 2019-01-14 08:51:18 +01:00
Jörg Breitbart 0802582c9b test cases for DOM renderer style changes 2019-01-14 01:00:07 +01:00
Jörg Breitbart 3515c0b220 DOM renderer with RGB support 2019-01-14 00:46:44 +01:00
Jörg Breitbart 70ded42bee follow naming scheme 2019-01-13 23:50:58 +01:00
Jörg Breitbart c444eebd89 RGB support in buffer and attributes 2019-01-13 23:19:56 +01:00
Jörg Breitbart 7c6dad5805 test cases 2019-01-12 19:06:09 +01:00
Jörg Breitbart 40b231edd1 tests for CellData 2019-01-12 18:44:10 +01:00
Jörg Breitbart 35a6aa8326 some docs 2019-01-12 18:04:52 +01:00
Jörg Breitbart 711ae65947 remove get CharData from codebase and deprecate method 2019-01-12 17:50:19 +01:00
Jörg Breitbart ece7192db7 remove set with CharData from codebase and deprecate method 2019-01-12 16:15:24 +01:00
Jörg Breitbart 3e456971b1 change buffer line ctor to new interface 2019-01-12 15:47:50 +01:00
Jörg Breitbart 60a591e8c8 use getNullChar in InputHandler.print 2019-01-12 15:37:20 +01:00
Jörg Breitbart 56dec2849f change resize, fill to new interface, remove _cell on buffer line 2019-01-12 15:21:55 +01:00
Jörg Breitbart fe6919b52a change replaceCells to new interface 2019-01-12 15:05:52 +01:00
Jörg Breitbart 4bf7f3eb89 change deleteCells to new interface 2019-01-12 14:58:30 +01:00
Jörg Breitbart 523ff6e5fc add null and whitespace placeholder cells to buffer 2019-01-12 14:54:54 +01:00
Jörg Breitbart 88a037b309 change insertCells to new interface 2019-01-12 14:34:29 +01:00
Jörg Breitbart ad67f47acb Merge branch 'typedarray_parser' into utf32_buffer 2019-01-12 14:08:53 +01:00
Jörg Breitbart 329d40ab14 cleanup DCS handler 2019-01-12 13:53:43 +01:00
Jörg Breitbart a1f8749411 Merge branch 'typedarray_parser' of git+ssh://github.com/jerch/xterm.js into typedarray_parser 2019-01-12 13:43:55 +01:00
Jörg Breitbart e7e0f67ea8 Merge branch 'master' into typedarray_parser 2019-01-12 13:43:40 +01:00
Jörg Breitbart 907a6b9732 Merge branch 'master' into utf32_buffer 2019-01-12 13:43:11 +01:00
Daniel Imms 7fe3f0a4e3 Improve BufferLine test
Ensure combined is cleared when shrinking and enlarging
2019-01-11 12:58:41 -08:00
ntchjb 9236934586 _findInLine() function should not run multiple times on the same row 2019-01-09 07:01:34 +07:00
Daniel Imms 932d5c7c21 Merge branch 'master' into master 2019-01-08 10:19:38 -08:00
Daniel Imms 509ce5fa3a Merge pull request #1881 from Tyriar/1880_key_repeat
Don't print keys that print more than a single char
2019-01-07 14:43:20 -08:00
Jörg Breitbart fed430b78c Merge branch 'master' into fix_linkifier_offset 2019-01-07 11:39:52 +01:00
Jörg Breitbart 883ad01bd5 make linter happy 2019-01-07 11:39:16 +01:00
Jörg Breitbart 249f8800af account empty cells in stringIndexToBufferIndex 2019-01-07 11:30:26 +01:00
Daniel Imms 0b8c320579 Merge pull request #1886 from epicfaace/typos
Fix typos
2019-01-06 19:01:35 -08:00
Ashwin Ramaswami f04f2efc52 doc: fix more typos 2019-01-06 15:09:57 -08:00
Ashwin Ramaswami f090fa822d doc: fix typos 2019-01-06 15:07:36 -08:00
jerch 9bcf06f658 Merge branch 'master' into typedarray_parser 2019-01-05 05:04:42 +01:00
jerch 6581eb7d88 fix leftover BufferLineConstructor 2019-01-05 01:47:44 +01:00
jerch 90950e2b00 Merge branch 'master' into 622_reflow3 2019-01-05 01:24:28 +01:00
Jörg Breitbart 62dfa84d5d remove get CharData calls from codebase (beside tests) 2019-01-05 01:01:10 +01:00
Jörg Breitbart b93b774971 direct cell attrs getter 2019-01-04 19:14:56 +01:00
Jörg Breitbart 6552a023c1 remove get from linkifier 2019-01-04 18:46:45 +01:00
Jörg Breitbart 13ffed392d remove get calls from renderer 2019-01-04 18:36:07 +01:00
Jörg Breitbart d7e5977d9a remove leftover 2019-01-04 16:19:01 +01:00
Daniel Imms 7a416aa18f Don't print keys that print more than a single char
Fixes #1880
2019-01-03 22:49:03 -08:00
Daniel Imms 7ba17ca770 Convert web links and attach to modules 2019-01-03 22:19:30 -08:00
Daniel Imms 290394b401 New addon prototype
Part of #1128
2019-01-03 20:22:53 -08:00
Jörg Breitbart 802543f7cf replace set(CharData) with setCell 2019-01-04 02:58:15 +01:00
Jörg Breitbart f3619ab61c fix linter error 2019-01-04 01:33:49 +01:00
Jörg Breitbart 2f66efa49a first try to optimize read access 2019-01-04 01:32:56 +01:00
Jörg Breitbart 75fbda1fe6 further opt for InputHandler.print 2019-01-04 01:32:20 +01:00
Jörg Breitbart b0eecea45a partially apply fast data access in InputHandler.print 2019-01-03 21:40:34 +01:00
Jörg Breitbart f63223f8d8 Merge branch 'master' into utf32_buffer 2019-01-03 21:10:40 +01:00
Jörg Breitbart a2a8c3d47f extend buffer line with more direct access methods 2019-01-03 21:08:18 +01:00
jerch f98572cf71 Merge pull request #1877 from jerch/remove_jsarray_buffer
remove js array based buffer line
2019-01-03 20:55:09 +01:00
Jörg Breitbart ba1582cf3c apply utf32 buffer layout 2019-01-03 19:01:43 +01:00
Jörg Breitbart c668bb1243 remove js array based buffer line 2019-01-03 16:08:40 +01:00
Max b4b6bab000 Merge branch 'master' into master 2019-01-03 16:12:19 +07:00
ntchjb c784a012c7 Fix: update findingRow and cumulativeCols before running _findInLine
to be able to scan unwrapped line at the last row
2019-01-03 15:55:27 +07:00
ntchjb efe22d8cf3 Revert "Support wide characters and combined characters"
This reverts commit f961f90bc8.
2019-01-03 15:32:25 +07:00
Jörg Breitbart 27b91f6b00 speedup utf32ToString conversion 2019-01-03 02:55:11 +01:00
Jörg Breitbart 1fb1f556b1 Merge branch 'master' into typedarray_parser 2019-01-03 00:54:12 +01:00
Jörg Breitbart 8fc66a39e3 switch parse buffer to UTF32 2019-01-03 00:48:00 +01:00
Daniel Imms 740ca9ce6d v3.10.0 2019-01-02 14:23:09 -08:00
Jörg Breitbart 2918a6763f fix wrongly changed test case 2019-01-02 22:55:50 +01:00
Jörg Breitbart dfc853aef4 add TextDecoder for string to UTF32 2019-01-02 22:50:15 +01:00
Daniel Imms 4db95f253e Build to dist dir in release build 2019-01-02 13:40:06 -08:00
Daniel Imms 805c02fb18 Merge branch 'master' into cd 2019-01-02 12:56:07 -08:00
Daniel Imms d120ef5301 Re-enable condition and dependsOn 2019-01-02 12:55:44 -08:00
Daniel Imms 68fbb2f8c9 Tweak more 2019-01-02 11:53:51 -08:00
Daniel Imms 515cf7878e Tweak var 2019-01-02 11:49:20 -08:00
Daniel Imms a35ad6aa81 Inherit exit code from publish call 2019-01-02 11:39:44 -08:00
Daniel Imms aa2d28e619 Disable dependsOn 2019-01-02 11:37:34 -08:00
Daniel Imms a6c3f94860 Publish to npm as beta 2019-01-02 11:24:06 -08:00
Daniel Imms ff81ce078b Add a release pipelines job 2019-01-02 09:38:40 -08:00
Jörg Breitbart 5fd764a89d dont pullin everything from .vscode folder 2019-01-02 18:10:51 +01:00
Jörg Breitbart 83c734eae3 Merge branch 'typedarray_parser' of git+ssh://github.com/jerch/xterm.js into typedarray_parser 2019-01-02 18:00:31 +01:00
Jörg Breitbart 570cd786cb Merge branch 'master' into typedarray_parser 2019-01-02 18:00:05 +01:00
Daniel Imms 29ff74e069 Merge pull request #1859 from Tyriar/baseline
Fix text being top aligned in latest Chrome and Firefox
2019-01-01 18:58:32 -08:00
Daniel Imms c66a24fab4 Merge branch 'master' into baseline 2019-01-01 15:33:57 -08:00
jerch 7a579a374a Merge pull request #1853 from PerBothner/control-seq-handler
hooks for custom CSI/OSC control sequences
2019-01-01 21:25:52 +01:00
jerch f534758e29 Merge branch 'master' into control-seq-handler 2019-01-01 21:19:34 +01:00
Daniel Imms dbd9b2af37 Merge branch 'master' into baseline 2019-01-01 11:50:09 -08:00
Daniel Imms 68b2b79880 Merge pull request #1861 from Tyriar/1860_style_npe
Add sanity checks to dom renderer underline code
2019-01-01 11:47:17 -08:00
Per Bothner 8fbeadd5f9 Add missing deleteCount argument to Array.splice calls. 2019-01-01 09:45:23 -08:00
ntchjb f961f90bc8 Support wide characters and combined characters
- Convert buffer index to string index before searching
- Convert string index to buffer index after searching
- Fix bug when search selection skipped some result
2019-01-01 16:39:23 +07:00
Daniel Imms 338558d86c Make Terminal API properties readonly
Fixes #1867
2018-12-31 20:09:48 -08:00
Daniel Imms 8b3513f009 Merge branch 'master' into 1860_style_npe 2018-12-31 19:15:15 -08:00
Daniel Imms 9b0b323957 Merge branch 'master' into baseline 2018-12-31 19:14:53 -08:00
Daniel Imms 48c1d36d77 Merge branch 'master' into control-seq-handler 2018-12-31 19:07:58 -08:00
Daniel Imms 2ce67b89bc Remove unneeded MockTerminal member 2018-12-31 14:43:50 -08:00
Daniel Imms 6559931f34 Add lots of tests 2018-12-31 14:28:52 -08:00
Daniel Imms 840970eac7 Update markers after a reflow 2018-12-31 13:15:23 -08:00
Daniel Imms 40e8618cf5 Discard cut off combined data when resizing BufferLines 2018-12-31 10:26:10 -08:00
Daniel Imms db488ebcc9 Reflow combined chars 2018-12-31 10:18:38 -08:00
Daniel Imms 1612cec3e0 Fix reflow larger bug, add regression test 2018-12-31 09:54:24 -08:00
Daniel Imms 135e31f2ca Speed up reflow larger by batching removals 2018-12-31 08:58:04 -08:00
Daniel Imms b7081abfce Move loop into reflowLarger (adjust indent) 2018-12-31 07:54:16 -08:00
Daniel Imms c9f4a650c6 Clean up comments and todos 2018-12-31 07:26:08 -08:00
Daniel Imms 478742a22e Make reflow small crazy fast
This messy but this drops 100000 scrollback reflow from 87 cols to 40 cols
go from ~18 seconds to < 1 second, 10000 takes around 70ms
2018-12-30 12:14:48 -08:00
Per Bothner bbfe149397 Merge pull request #1 from Tyriar/hooks_changes
Move to array-based instead of linked list, simplify, add tests
2018-12-29 07:01:39 -08:00
ntchjb d94c897754 Fix search addons: be able to search wrapped lines from unwrapped line
by managing column range that is needed to be scanned.
2018-12-29 13:55:14 +07:00
Daniel Imms dde96187fa Keep track of cols/rows inside Buffer 2018-12-28 19:27:38 -08:00
Daniel Imms 4a9f10d062 Remove some of Buffer's dependency on Terminal 2018-12-28 19:22:05 -08:00
Daniel Imms 7435971c32 Merge remote-tracking branch 'origin/master' into 622_reflow3 2018-12-28 19:13:12 -08:00
Max 1b68682b79 Merge branch 'master' into master 2018-12-29 10:12:17 +07:00
ntchjb 565cba9c1a Fix search addons:
- Changed to use `this._terminal.cols` for buffer line length instead.
- Let `_findInLine` check on wrapped line
- Added conditions in `_findInLine`
  - For reverse search, if there is no  selection at given row, then start scan at the end of the string
2018-12-29 09:38:17 +07:00
Daniel Imms 4375b3cdb9 Merge pull request #1865 from ntchjb/master
Fix search addons: searchTerm should not be matched if the beginning of matching index < 0
2018-12-28 15:02:51 -08:00
Daniel Imms 72369e060e Only enable reflow on the normal buffer 2018-12-28 14:55:58 -08:00
Daniel Imms 2a0da173f2 Add a bunch of reflow tests 2018-12-28 14:55:15 -08:00
Daniel Imms a33e8a6af7 Properly shrink rows to cols every time 2018-12-28 12:57:10 -08:00
ntchjb 913150fe13 Fix search addons:
searchTerm should not be matched if the beginning of matching index < 0
2018-12-29 03:03:23 +07:00
Daniel Imms 358898daf9 Fix some tests 2018-12-28 11:02:08 -08:00
Daniel Imms 7684f93773 Fix ydisp/ybase after trimming buffer 2018-12-28 01:32:19 -08:00
Daniel Imms ae29dbb133 Fix scrollbar when wrapping beyond single viewport of data 2018-12-28 01:26:49 -08:00
Daniel Imms 3311ed509a Do shrink in reverse, fix up row remove count again 2018-12-28 00:40:30 -08:00
Daniel Imms 8bc04c2fa7 Tidy up 2018-12-27 23:58:57 -08:00
Daniel Imms fa47036982 Fix row removal in reflowLarger 2018-12-27 23:49:59 -08:00
Daniel Imms 314f98f2a6 Mostly working for reflowing to smaller 2018-12-27 23:35:52 -08:00
Daniel Imms 8a50729a98 Reflow wider 2018-12-27 21:58:54 -08:00
Daniel Imms c133c644a6 Merge pull request #1834 from Tyriar/debugging
Add VS Code debug targets for demo server, client and unit tests
2018-12-27 14:18:51 -08:00
Daniel Imms 951f281bb0 Merge branch 'master' into debugging 2018-12-27 14:09:48 -08:00
Daniel Imms d5cacbaf4a Merge pull request #1863 from vincentwoo/patch-2
Small indent fix
2018-12-27 14:02:53 -08:00
Vincent Woo bb198a980c Small indent fix 2018-12-27 13:54:11 -08:00
Daniel Imms 60bc1bb873 Merge branch 'master' into perf3 2018-12-27 13:53:01 -08:00
Daniel Imms d5bffb5395 Merge branch 'master' into typedarray_parser 2018-12-27 13:20:48 -08:00
Daniel Imms 2611a9b1d1 Merge pull request #1846 from linrock/no-end-quotes-in-weblinks
Weblinks should not allow quotes at end of urls enclosed in quotes
2018-12-27 11:32:40 -08:00
Daniel Imms 689ac3e073 Merge branch 'master' into no-end-quotes-in-weblinks 2018-12-27 11:29:33 -08:00
Daniel Imms 51e1f49bf3 Make dispose more resilient 2018-12-27 10:26:40 -08:00
Daniel Imms 838d727a89 Merge pull request #1849 from epicfaace/feature/hold-key
Allow holding key on mac to send multiple keys to terminal
2018-12-27 10:08:12 -08:00
Daniel Imms 9bcfb4d722 Tidy up wrapping style 2018-12-27 10:04:48 -08:00
Ashwin Ramaswami 0d9487c10f Merge branch 'master' into feature/hold-key 2018-12-26 20:36:53 -05:00
Daniel Imms b48f9108c8 Merge pull request #1763 from noamyogev84/issue_1654
Finding multiple instances on the same line
2018-12-26 16:13:24 -08:00
Daniel Imms d698faa183 Comment how the regex reverse search while works 2018-12-26 16:12:53 -08:00
Daniel Imms 1a1f7e984f Remove ISearchIndex object 2018-12-26 16:03:31 -08:00
Daniel Imms e0d535e0da Fix previous search, remove incremental previous search 2018-12-26 15:49:08 -08:00
Daniel Imms 76302e2146 Get multiple matches working after incremental changes 2018-12-26 15:32:34 -08:00
Daniel Imms 204e42a151 Fix incremental search 2018-12-26 15:15:12 -08:00
Daniel Imms bb9732599b Merge remote-tracking branch 'origin/master' into pr/noamyogev84/1763 2018-12-26 15:08:16 -08:00
Daniel Imms adbb929f78 Wrap .d.ts comments to 80 chars 2018-12-26 14:49:49 -08:00
Daniel Imms c045c803d6 Add tests for dispose 2018-12-26 14:48:35 -08:00
Daniel Imms 38796a0f74 Add tests, fix NPE 2018-12-26 14:40:23 -08:00
Daniel Imms d01efdda27 Use array instead of linkedlist, add typings 2018-12-26 14:08:53 -08:00
Daniel Imms 9e3e724f63 Add sanity checks to dom renderer underline code
Fixes #1860
2018-12-26 10:53:40 -08:00
Daniel Imms a80baa71e8 Merge branch 'master' into control-seq-handler 2018-12-23 22:24:26 -08:00
Daniel Imms 272cb08472 Merge pull request #1847 from linrock/update-natives
Fix npm scripts crashing when using node 10+
2018-12-23 22:19:12 -08:00
Per Bothner 48ff841d6a Be more paranoid about cleaning up escape sequence handlers. 2018-12-23 12:27:26 -08:00
Daniel Imms 0e8a102e17 Merge pull request #1856 from Tyriar/readme
Remove gitter and improve README
2018-12-23 10:57:49 -08:00
Daniel Imms c6e6c51929 Use textBaseline middle to draw instead of top
Chrome and Firefox behavior differs, see:
- https://bugzilla.mozilla.org/show_bug.cgi?id=737852
- https://bugs.chromium.org/p/chromium/issues/detail?id=607053

Fixes #1858
2018-12-23 10:51:41 -08:00
Daniel Imms 81ada39989 Remove Gitter link from issue template
Fixes #1838
2018-12-21 23:07:25 -08:00
Daniel Imms 78e7e39bb4 Improve the readme 2018-12-21 23:04:38 -08:00
Ashwin Ramaswami 548d8cd764 Merge branch 'feature/hold-key' of https://github.com/epicfaace/xterm.js into feature/hold-key 2018-12-21 07:38:19 -05:00
Ashwin Ramaswami a4b4d082fb Don't include num lock and scroll lock 2018-12-21 07:38:14 -05:00
Per Bothner 29cc0bf933 Merge remote-tracking branch 'upstream/master' into control-seq-handler 2018-12-20 18:12:53 -08:00
Daniel Imms 2896f56ebb Merge branch 'master' into feature/hold-key 2018-12-20 12:13:43 -08:00
Daniel Imms fcef4d5d28 Merge pull request #1851 from robins1212/bindfullscreen
bind classList function before calling in toggleFullScreen
2018-12-20 12:11:53 -08:00
robins1212 701f50f47b Merge branch 'master' into bindfullscreen 2018-12-20 12:03:43 -08:00
Daniel Imms 61d0e99ffd Merge pull request #1850 from Tyriar/vscode65485
Fix winptyCompat wrapped line heuristic
2018-12-20 11:58:55 -08:00
Robin Sturm 3eac446a85 bind function before calling 2018-12-20 11:54:26 -08:00
Daniel Imms 71d8a4d1ed Merge branch 'master' into vscode65485 2018-12-20 11:48:51 -08:00
Daniel Imms ff73f705ae Fix winptyCompat wrapped line heuristic
Part of Microsoft/vscode#65485
2018-12-20 11:47:51 -08:00
Ashwin Ramaswami 64dd9d46fb Change keyCode cutoff 2018-12-20 14:21:35 -05:00
Ashwin Ramaswami 0782fbb828 Fix check 2018-12-20 09:57:24 -05:00
Ashwin Ramaswami b820f23da6 Add additional test 2018-12-20 09:50:57 -05:00
Ashwin Ramaswami ec1060187d Add tests 2018-12-20 09:50:18 -05:00
Ashwin Ramaswami 1104bcbccb Allow holding key on mac to send multiple keys to terminal 2018-12-20 09:41:44 -05:00
Daniel Imms 90ec90746e Merge pull request #1848 from linrock/fix-addons-typo
Fix missing quotes in import statement in readme
2018-12-19 11:09:25 -08:00
Daniel Imms b39e8cfbb9 Merge pull request #1843 from Tyriar/endcol_null
Fix translateToString endCol default arg
2018-12-19 11:04:55 -08:00
Linmiao Xu 5ebd543b8b Fix missing quotes in import statement in readme 2018-12-19 14:32:15 +09:00
Linmiao Xu 86f194a6d3 Fix npm scripts when using node 10+ 2018-12-19 13:50:41 +09:00
Linmiao Xu 9cd7bf2af1 Weblinks should not allow quotes at end of urls enclosed in quotes 2018-12-19 13:28:16 +09:00
Daniel Imms c961175c03 Merge branch 'master' into debugging 2018-12-18 16:28:26 -08:00
Daniel Imms 04ac36fc16 Fix translateToString endCol default arg 2018-12-18 16:22:41 -08:00
Daniel Imms d27b43d515 Merge pull request #1841 from jerch/fix/1840
fix invalid string and buffer index in Linkifier
2018-12-18 10:57:00 -08:00
Jörg Breitbart 0da6300102 make linter happy 2018-12-18 10:50:30 +01:00
Jörg Breitbart e5ff04e798 Merge branch 'master' into fix/1840 2018-12-18 00:04:48 +01:00
Jörg Breitbart 5460068d52 fix invalid string and buffer index 2018-12-17 23:59:48 +01:00
Daniel Imms a53c6f1728 Merge pull request #1826 from nojvek/master
Fix #1660: Search as you type
2018-12-17 11:56:22 -08:00
Daniel Imms 6a5b5c23f8 Merge branch 'master' into master 2018-12-17 11:46:33 -08:00
Jörg Breitbart ef171bf29f Merge branch 'master' into typedarray_parser 2018-12-15 23:42:08 +01:00
Per Bothner 6b65ebd4aa Various typing and API fixes, doc comments, typing test etc. 2018-12-15 11:34:15 -08:00
Per Bothner 8a5a03238f New method _linkHandler used by both addCsiHandler and addOscHandler. 2018-12-15 09:42:19 -08:00
jerch 4feed2dabc Merge pull request #1775 from jerch/trim_behavior
explicit null char representation and fix for right side trimming
2018-12-15 00:11:41 +01:00
Jörg Breitbart 415e760a8a Merge branch 'trim_behavior' of git+ssh://github.com/jerch/xterm.js into trim_behavior 2018-12-15 00:04:15 +01:00
Jörg Breitbart 3927364f0e remove nonsense comments 2018-12-15 00:03:54 +01:00
Jörg Breitbart 62be3047d8 infer types fix 2018-12-15 00:01:18 +01:00
Jörg Breitbart d18c947854 Merge branch 'master' into trim_behavior 2018-12-14 23:59:40 +01:00
Per Bothner 5af4626ec7 Change addCsiHandler/addOscHandler to not use Object.assign. 2018-12-13 17:33:33 -08:00
Daniel Imms 4446fa34de Merge branch 'master' into master 2018-12-13 10:55:51 -08:00
Daniel Imms 4a7a19c368 Merge branch 'master' into trim_behavior 2018-12-13 10:19:58 -08:00
Daniel Imms 6351a5b748 Merge branch 'master' into master 2018-12-13 10:14:15 -08:00
Daniel Imms dc5c2381a8 Merge branch 'master' into perf3 2018-12-12 11:24:34 -08:00
Daniel Imms 551feb849e Merge pull request #1832 from Tyriar/remove_jsdoc
Remove jsdoc dependency
2018-12-12 09:44:40 -08:00
Daniel Imms 98285d3a84 Merge pull request #1831 from Tyriar/1830_addon_types_fix
Remove triple slash directive error in addon types
2018-12-12 09:30:34 -08:00
Daniel Imms 98ccc23934 Merge pull request #1827 from Tyriar/1605_remove_authors
Remove authors
2018-12-12 09:11:24 -08:00
Jörg Breitbart d0d94584ad Merge branch 'master' into trim_behavior 2018-12-12 18:10:24 +01:00
Noam Yogev e00c7d535d Merge branch 'master' into issue_1654 2018-12-12 11:59:48 +02:00
Per Bothner 8ceea112f7 hooks for custom control sequences
This re-implements addCsiHandler/addOscHandler to return an IDisposable.
2018-12-11 17:18:10 -08:00
Per Bothner 53fd04a886 Revert "hooks for custom control sequences"
This reverts commit 4d660deff3.
2018-12-11 16:50:40 -08:00
Per Bothner ffb2708a81 Revert "Cleanups required by tslink."
This reverts commit b68974517e.
2018-12-11 16:50:14 -08:00
Per Bothner 8ad2d1bf43 Merge remote-tracking branch 'upstream/master' 2018-12-11 16:30:18 -08:00
Daniel Imms a758f8c82f Merge pull request #1822 from PerBothner/optimize-osc-parse
Optimize parsing of OSC_STRING to minimize string concatenation.
2018-12-11 11:09:27 -08:00
Daniel Imms bbbfc04fa5 Merge branch 'master' into optimize-osc-parse 2018-12-11 11:07:12 -08:00
Daniel Imms d7f284c676 Add debug target for demo server, merge 2 start processes into one 2018-12-11 09:56:33 -08:00
Daniel Imms 943def1391 Add debug target for client, fix source maps in demo to point to ts 2018-12-11 09:37:20 -08:00
Daniel Imms a0a8003d60 Add unit tests debug target 2018-12-11 09:06:50 -08:00
Daniel Imms 6cc0a1447d Merge branch 'master' into remove_jsdoc 2018-12-11 08:58:28 -08:00
Daniel Imms 4d3345182f Remove jsdoc dependency 2018-12-11 08:57:44 -08:00
Daniel Imms 3a5d07a8f2 Merge branch 'master' into 1830_addon_types_fix 2018-12-11 07:21:34 -08:00
Daniel Imms 1e94fce545 Remove triple slash directive error in addon types
Fixes #1830
2018-12-11 07:19:37 -08:00
Daniel Imms da8546725f Merge branch 'master' into master 2018-12-11 06:28:08 -08:00
Daniel Imms 53f3b4e368 Merge pull request #1828 from Tyriar/1507_remove_layering
Remove utils/ folder
2018-12-11 06:27:49 -08:00
Noj Vek a0d583b075 handle non-cached scenario in tests land 2018-12-10 17:23:28 -08:00
Noj Vek 9005de1c42 adding a linesCache ttl and cursor move invalidation 2018-12-10 17:13:28 -08:00
Daniel Imms b9a22eb468 Remove utils/ folder
Part of #1507
2018-12-10 16:46:57 -08:00
Daniel Imms b51c07c408 Merge branch 'master' into 1605_remove_authors 2018-12-10 16:41:04 -08:00
Daniel Imms 3397ecf977 Remove authors
Fixes #1605
2018-12-10 16:40:04 -08:00
Noj Vek 801dcc3b75 Merge branch 'master' of github.com:xtermjs/xterm.js 2018-12-10 15:54:38 -08:00
Noj Vek 91ef7f24a6 Fixes #1660: Search as you type 2018-12-10 15:54:35 -08:00
Daniel Imms 65877d491e Merge pull request #1788 from gou4shi1/fix-get-mouse-coord
getCoordsRelativeToElement: use getBoundingClientRect and clientX/Y.
2018-12-10 14:46:33 -08:00
Daniel Imms f34c3d509d Merge pull request #1821 from Tyriar/dispose_atlas
Call dispose when atlas is no longer used in cache
2018-12-10 14:45:59 -08:00
Daniel Imms e1b3c7233a Merge pull request #1820 from Tyriar/add_missing_break
Add missing break in options code
2018-12-10 14:45:49 -08:00
Daniel Imms 08dc8a3e5f Merge pull request #1819 from Tyriar/fix_demo_line_height
Allow decimal line heights in demo
2018-12-10 14:45:41 -08:00
jerch 6a2e6a5edc Merge branch 'master' into optimize-osc-parse 2018-12-10 20:17:51 +01:00
Daniel Imms 1c62980d20 v3.9.0 2018-12-10 07:51:28 -08:00
jerch 2d8f420db8 fix default transition for 0xa0 2018-12-10 16:37:48 +01:00
Per Bothner 2cb293ceb2 Further tweaks to optimize parsing of OSC_STRING. 2018-12-09 19:03:58 -08:00
Juan Campa 3d2ae2b01e Removing redundant condition. Clearer variable name 2018-12-09 17:58:44 -05:00
Per Bothner 1c4a71f0df Optimize parsing of OSC_STRING to minimize string concatenation. 2018-12-09 13:29:09 -08:00
Per Bothner 30a667c3be Revert "Optimize parsing of OSC_STRING to minimize string concatenation."
This reverts commit 03115639a9.
2018-12-09 13:11:17 -08:00
Per Bothner 03115639a9 Optimize parsing of OSC_STRING to minimize string concatenation. 2018-12-09 10:56:34 -08:00
Daniel Imms 48629e7eb2 Merge remote-tracking branch 'origin/master' into pr/gou4shi1/1788 2018-12-09 10:02:55 -08:00
Daniel Imms 6b9fb48898 Fix tests/lint, use element instead of event.target 2018-12-09 09:59:33 -08:00
Daniel Imms fe9eb7d31e Call dispose when atlas is no longer used in cache
Only runtime change is that this clears the bitmap commit timeout
in DynamicCharAtlas
2018-12-09 09:19:56 -08:00
Daniel Imms 693e17a5cb Add missing break in options code
Atlas is reset as part of onResize, this should be safe
2018-12-09 09:13:30 -08:00
Daniel Imms b5b2bcd0c9 Allow decimal line heights in demo 2018-12-09 09:08:11 -08:00
Juan Campa fd34caee23 Use a time-based limit to Terminal._innerWrite
The idea is that it should run for a bit and then let the renderer draw
a frame so that the terminal look responsive. The existing approach
limits the work done using a fixed number elements from the write
buffer so the duration of a frame can vary widely.

This approach looks at the clock to determine when to stop, we basically
allocate an amount of time each frame to write, while the rest can be
used for rendering.

From my tests this change makes the terminal feel a lot smoother.
2018-12-08 00:44:05 -05:00
Noam 278d696709 remove reverseSearch from ISearchOptions
add isReverseSearch argument to findInLine
modify unit tests
2018-12-07 22:56:57 +02:00
gou4shi1 7f18199985 Fix build fail 2018-12-06 14:37:27 +08:00
Per Bothner b68974517e Cleanups required by tslink. 2018-12-05 14:45:57 -08:00
Per Bothner 4d660deff3 hooks for custom control sequences
This fixes (at least partially) issue #1176
"Add a way to plugin a custom control sequence handler".
2018-12-04 19:00:44 -08:00
jerch b5f1c3384a Merge pull request #1812 from jerch/default_buffer_to_typedarray
Deprecate JS array based terminal buffer
2018-12-04 20:40:47 +01:00
Jörg Breitbart 6f4a6ef308 deprecate experimentalBufferLineImpl 2018-12-04 20:33:12 +01:00
Jörg Breitbart 18902dd789 make linter happy 2018-12-04 19:11:39 +01:00
Jörg Breitbart 66ec57b431 cleanup 2018-12-04 19:02:27 +01:00
Jörg Breitbart 6ee9178302 make typed array buffer default 2018-12-04 18:55:11 +01:00
Daniel Imms 6e45d022ac Merge pull request #1806 from dividuum/patch-1
Added info-beamer hosted
2018-12-03 06:58:09 -08:00
Florian Wesch 4d270bf72c Added info-beamer hosted
Works pretty well. See https://community.infobeamer.com/t/174 for details. Wouldn't be able to add this feature without Xterm.js.
2018-12-02 15:38:50 +01:00
Noam Yogev 38adfcd81c Merge branch 'master' into issue_1654 2018-11-30 20:49:12 +02:00
Noam 376c790e1d implement find multiple matches in line.
start search from current selection.
add unit tests.
2018-11-30 20:46:47 +02:00
Daniel Imms 5f989929c3 Merge pull request #1799 from Tyriar/remove_shared_folder
Remove shared/ folder
2018-11-29 14:03:20 -08:00
Jörg Breitbart 9d4beb024a keep whitespace chars 2018-11-29 22:11:38 +01:00
Jörg Breitbart 99e4a9649f fix failing test cases 2018-11-29 21:48:48 +01:00
Jörg Breitbart eb27641928 Merge branch 'master' into trim_behavior 2018-11-29 21:26:45 +01:00
Jörg Breitbart 2483a98f63 use faster string conversion 2018-11-29 21:13:18 +01:00
Jörg Breitbart 5d3ef759b4 Merge branch 'master' into typedarray_parser 2018-11-29 21:11:07 +01:00
Daniel Imms 4beb3a9ecd Merge remote-tracking branch 'origin/master' into remove_shared_folder 2018-11-29 11:56:27 -08:00
Daniel Imms 9df56aba13 Merge pull request #1795 from Tyriar/clipboard_layering
Move Clipboard to ui/
2018-11-29 11:54:15 -08:00
Daniel Imms 8cf98ec546 Merge pull request #1800 from Tyriar/typescript_3_1
Upgrade to typescript 3.1
2018-11-29 11:53:50 -08:00
Jörg Breitbart a6ef64dcb6 always clear DCS buffer on HOOK 2018-11-29 16:39:17 +01:00
Jörg Breitbart a4e3646640 Merge branch 'master' into typedarray_parser 2018-11-29 16:35:12 +01:00
Jörg Breitbart 591dfd506d fix DCS handler 2018-11-29 16:33:56 +01:00
Daniel Imms 68d5ce947e Merge pull request #1772 from whydoubt/fix_1767
Only show cross-hairs when terminal has focus
2018-11-26 11:20:36 -08:00
Daniel Imms 13175976d0 Upgrade to typescript 3.1
Bunch of types needed changing in this version, also the
IOffscreenCanvas "support" in the canvas renderer was removed
as we're moving away from that.
2018-11-24 07:16:43 -08:00
Daniel Imms f4a522516c Remove shared/ folder
We changed plans from moving web worker compatible code to shared/
to enforcing layers using core/, common/, ui/ and public/. This
change moves files back from the shared/ dir to clean up the
codebase.

Part of #1507
2018-11-24 07:03:59 -08:00
Daniel Imms 1db17701df Merge pull request #1739 from Tyriar/1737_inverse_dynamic_cache
Allow inverse colors to be stored in glyph keys, fix inverted colors in DOM renderer
2018-11-24 05:32:21 -08:00
Daniel Imms c6f1de7970 Introduce is256Color helper 2018-11-24 05:24:15 -08:00
Jörg Breitbart 14d6960873 Merge remote-tracking branch 'upstream/master' into typedarray_parser 2018-11-23 23:33:56 +01:00
Daniel Imms 5fca73aa5a Merge branch 'master' into 1737_inverse_dynamic_cache 2018-11-23 14:31:16 -08:00
Jörg Breitbart 06e89549a8 typed array support for parser 2018-11-23 23:30:37 +01:00
Daniel Imms 929d722e0e Merge pull request #1794 from Tyriar/remove_unused_line_height
Remove unused lineHeight parameters
2018-11-23 14:30:08 -08:00
jerch 79a1194bea Merge pull request #1793 from Tyriar/improve_fill_fallback
Improve types of fill polyfill and test fallback
2018-11-23 19:25:22 +01:00
jerch 8a04431417 Merge branch 'master' into improve_fill_fallback 2018-11-23 19:18:21 +01:00
jerch 76e7057c94 Merge pull request #1764 from whydoubt/alt_buffer
Alternate buffer improvement
2018-11-23 19:15:27 +01:00
jerch 62b1aa5a67 Merge branch 'master' into alt_buffer 2018-11-23 19:09:08 +01:00
jerch 41ba20f749 remove not longer needed test cases
Removed the `loopFill` test method as it is not needed anymore with the separation of the looping variant in `fillFallback`.
2018-11-23 18:40:52 +01:00
Daniel Imms 32574a1a09 Move Clipboard to ui/
Belong here as it interacts with DOM

Part of #1507
2018-11-23 09:05:07 -08:00
Daniel Imms fc6f101e16 Remove unused lineHeight parameters 2018-11-23 08:59:30 -08:00
Daniel Imms 2e889852b0 Merge branch 'master' into 1737_inverse_dynamic_cache 2018-11-23 08:52:32 -08:00
Daniel Imms 1b5ef5d93a Move TypedArrayUtils to common
It belongs here since the renderers will use it
2018-11-23 08:08:30 -08:00
Daniel Imms 4f18717940 Improve handling of default values 2018-11-23 07:49:35 -08:00
Daniel Imms 266ea38d91 Improve types of fill polyfill and test fallback
The polyfill will now return the T instead of the TypedArray union
type. Tests now target the fallback only so engines that support fill
will run tests against the fallback code.
2018-11-23 07:36:01 -08:00
Daniel Imms c6c67587e1 Merge pull request #1792 from Tyriar/1609_dom_no_null_cells
DOM renderer: Don't output empty cells at end of a line
2018-11-23 07:06:00 -08:00
Daniel Imms f363872f1e Merge branch 'master' into 1609_dom_no_null_cells 2018-11-23 06:51:53 -08:00
Daniel Imms 478dfee6e2 Ensure wide chars don't overflow onto following row 2018-11-23 06:51:39 -08:00
Daniel Imms d9513ce50d Don't bother checking beyond cols 2018-11-23 06:48:37 -08:00
jerch a693eb8e9b Merge pull request #1789 from jerch/optimisation_wcwidth
Optimisation for wcwidth
2018-11-23 15:33:33 +01:00
Daniel Imms fe027a2e9d Merge branch 'master' into optimisation_wcwidth 2018-11-23 06:26:36 -08:00
Daniel Imms 65c5df92d9 Move import below copyright 2018-11-23 06:26:06 -08:00
Daniel Imms dc0ae4a815 Fix indentation 2018-11-23 06:24:27 -08:00
Daniel Imms 66272eb310 Get the line length by going backwards instead 2018-11-23 05:40:35 -08:00
Daniel Imms 913adf9ccc Merge branch 'master' into 1609_dom_no_null_cells 2018-11-22 12:46:00 -08:00
jerch b4faaef785 Merge pull request #1731 from jerch/reuse_bufferlines
Recycle buffer lines
2018-11-22 21:24:18 +01:00
jerch 2f453f968c Merge branch 'master' into reuse_bufferlines 2018-11-22 21:17:38 +01:00
Daniel Imms dc077a181e Fix tests and the colCount feature 2018-11-22 12:03:08 -08:00
Daniel Imms 692cdfa390 DOM renderer: Don't output empty cells at end
Fixes #1609
2018-11-22 11:38:00 -08:00
Daniel Imms 6b89ec9d8e Merge pull request #1754 from vladimirze/run-tests-and-tslint-for-addons-directory
Run tests & tslint for src/addons directory
2018-11-22 10:57:42 -08:00
Daniel Imms 53fe096455 Type fn strongly 2018-11-22 10:52:55 -08:00
Daniel Imms 549c28bfa4 Merge branch 'master' into run-tests-and-tslint-for-addons-directory 2018-11-22 10:51:55 -08:00
Daniel Imms 2687fd02b2 Merge branch 'master' into reuse_bufferlines 2018-11-22 10:48:47 -08:00
Daniel Imms 1ceecf3f14 Merge pull request #1791 from xtermjs/Tyriar-patch-1
Add help wanted/good first issue links
2018-11-22 09:44:40 -08:00
Daniel Imms 98a3892e52 Fix typo 2018-11-22 09:44:13 -08:00
Jörg Breitbart 8c33de395d fix linter errors 2018-11-21 00:15:04 +01:00
Jörg Breitbart ef6fb93a92 polyfill for TypedArray.fill 2018-11-21 00:07:28 +01:00
Jörg Breitbart 36db03e713 keep old impl in test as reference; minor changes 2018-11-20 22:35:51 +01:00
Jörg Breitbart 895d6fc479 Merge branch 'master' into reuse_bufferlines 2018-11-20 22:03:24 +01:00
Jörg Breitbart 15c4cc8a74 remove experimental flag for recycling, merge with TypedArray setting 2018-11-20 22:01:57 +01:00
Jörg Breitbart 3964bb28b5 throw error in recycle with buffer not full 2018-11-20 21:49:31 +01:00
Daniel Imms 006869704b Add help wanted/good first issue links 2018-11-20 09:44:10 -08:00
Jörg Breitbart 21f848d0ab regression test 2018-11-18 23:48:59 +01:00
Jörg Breitbart 9b762854eb faster wcwidth init and runtime; fix slightly wrong surrogate handling 2018-11-18 23:31:45 +01:00
Daniel Imms e4a84643b8 Merge pull request #1765 from jrkong/vscode-issue-60401
Updated webLinks regex accept colons, fix vscode issue#60401
2018-11-18 14:12:30 -08:00
jerch 02732d9272 Merge pull request #1787 from jerch/fix_audiocontext
hold single AudioContext instance for all terminal instances
2018-11-18 22:54:57 +01:00
Jörg Breitbart 9286ea3eaf make statix usage explicit 2018-11-18 17:50:29 +01:00
Jörg Breitbart 203ee0f644 remove ctx args from ctor 2018-11-18 17:47:49 +01:00
Jörg Breitbart 579ef28929 Merge branch 'master' into fix_audiocontext 2018-11-18 17:46:19 +01:00
Daniel Imms bcd3a4dc40 Merge pull request #1784 from xtermjs/Tyriar-patch-1
Fixing isClickInSelection to cover missing cases
2018-11-16 18:03:27 -08:00
Daniel Imms a480f483cd Add tests 2018-11-16 17:54:03 -08:00
Jeff Smith 2f90035243 Clear alt buffer with erase attributes upon entering 2018-11-16 14:33:37 -06:00
Jeff Smith a19d93851c Each buffer needs its own saved cursor attributes 2018-11-16 14:33:37 -06:00
Jeff Smith a5894ee234 Fix cursor movement when swapping buffers 2018-11-16 14:33:37 -06:00
gou4shi1 3ca0598279 fix EventTarget type 2018-11-15 11:56:41 +08:00
gou4shi1 3d2035e1a0 getCoordsRelativeToElement: use getBoundingClientRect and clientX/Y. 2018-11-15 11:43:38 +08:00
Jörg Breitbart ef6f0db0a0 Merge branch 'master' into reuse_bufferlines 2018-11-15 01:05:33 +01:00
Jörg Breitbart 0e3f9b72d1 allow to set audio context per argument 2018-11-15 00:48:31 +01:00
Jörg Breitbart e3146961be make linter happy 2018-11-15 00:25:23 +01:00
Jörg Breitbart 9faebaf5fe hold single AudioContext instance 2018-11-15 00:16:52 +01:00
jerch 19174dd836 Merge branch 'master' into fix_1767 2018-11-14 20:25:25 +01:00
jerch e4e5b966da Merge pull request #1780 from whydoubt/fix_1751
Make scrollbar draggable when using DOM renderer
2018-11-14 19:59:00 +01:00
Jeff Smith 8ea0bb55b4 Make scrollbar draggable when using DOM renderer
Fixes #1751
2018-11-12 21:08:51 -06:00
jerch cb97ab35cb Merge pull request #1783 from jerch/fix_1778
fix minor parser issues:
- dont expose ESC+\ (7bit ST)
- add missing executables FS, GS, RS and US
2018-11-09 13:39:50 +01:00
Daniel Imms 774793c7ca Fixing isClickInSelection to cover missing cases
The following cases weren't working:

- The first character on single line selections
- The first row on multi-line selection
2018-11-08 19:20:12 -08:00
Jörg Breitbart 4aa822e7a9 Merge branch 'master' into fix_1778 2018-11-09 01:07:11 +01:00
Jörg Breitbart de7d5e1eec swallow 7bit ST, add missing executables 2018-11-09 01:03:44 +01:00
jerch 3e233be54b Merge branch 'master' into fix_1767 2018-11-08 19:45:34 +01:00
jerch 70981c7a29 Merge pull request #1782 from astefanutti/pr-wheel
Use WheelEvent.deltaY instead of WheelEvent.wheelDeltaY for wheel event
2018-11-08 19:43:24 +01:00
Antonin Stefanutti 8acf137d14 Use WheelEvent.deltaY instead of WheelEvent.wheelDeltaY for wheel event
Fixes #1781
2018-11-08 14:44:18 +01:00
Jörg Breitbart a15b866013 test cases for getTrimLength and translateToString 2018-11-08 06:13:05 +01:00
Jörg Breitbart 2f9c04c3af cleanup test cases 2018-11-08 05:00:08 +01:00
Jörg Breitbart 67df9a5cdc cleanup 2018-11-08 04:03:48 +01:00
Jörg Breitbart 22e4a2dc97 Merge branch 'master' into reuse_bufferlines 2018-11-07 00:58:35 +01:00
Jörg Breitbart e9906f9b9e compromise between code safety and speed 2018-11-07 00:56:45 +01:00
Daniel Imms eca1170a45 Merge branch 'master' into fix_1767 2018-11-01 11:12:53 -07:00
Jörg Breitbart 5395503031 apply code and char replacement to renderer 2018-10-31 15:47:35 +01:00
Jörg Breitbart 200b59b47c fix canvas renderer 2018-10-31 15:35:30 +01:00
Jörg Breitbart cabd4a721c fix dom renderer 2018-10-31 15:30:29 +01:00
Jörg Breitbart 745e228e98 fix input handler and terminal tests 2018-10-31 15:26:40 +01:00
Jörg Breitbart 8ffcd65cff fix buffer tests 2018-10-31 15:11:18 +01:00
Jörg Breitbart 1c111d3e60 skip empty cells after fullwidth 2018-10-31 14:53:55 +01:00
Jörg Breitbart 62f1d64af4 fix trimmedLength for TypedArray 2018-10-31 14:26:54 +01:00
Jörg Breitbart ee6fa6ca00 change NULL_CHAR and trim 2018-10-31 12:42:56 +01:00
jrkong 5173bd6419 Merge branch 'master' into vscode-issue-60401 2018-10-30 19:33:05 -04:00
Daniel Imms 160b4a7d66 Revert "Remove request term info handler"
This reverts commit c2994b0ae1.
2018-10-30 11:04:32 -07:00
Jörg Breitbart fb64c527a5 revert to precheck pushWouldTrim 2018-10-30 17:40:11 +01:00
Jörg Breitbart aaffc2b2be Merge branch 'master' into reuse_bufferlines 2018-10-30 14:18:28 +01:00
Jeff Smith c7eb727220 Only show cross-hairs when terminal has focus
Fixes #1767
2018-10-29 16:18:35 -05:00
Daniel Imms f3cd652e74 Merge pull request #1733 from leomoty/line-height
Support for lineHeight in DOM Renderer
2018-10-28 10:54:52 -07:00
Daniel Imms 108438dbeb Use setRenderer instead of ctor
Just in case something hangs onto MouseHelper
2018-10-28 10:51:57 -07:00
Daniel Imms 41b1c929e0 Fix screen element remaining large if originally using canvas 2018-10-28 10:50:16 -07:00
leomoty 793516060f Recreate mouseHelper after renderer is disposed 2018-10-28 14:24:08 -03:00
leomoty 60468356db Merge branch 'master' into line-height 2018-10-27 13:26:50 -03:00
Daniel Imms e90f8611d5 Merge pull request #1752 from Tyriar/improve_dec
Improve types for listener args in .d.ts
2018-10-26 13:24:01 -07:00
Jörg Breitbart 93d7a3021d remove pushRecycling, test case for trimAndRecycle, docs 2018-10-26 16:11:47 +02:00
Jörg Breitbart 982006836b Merge branch 'master' into reuse_bufferlines 2018-10-26 15:23:43 +02:00
vladimirze d137880876 Merge branch 'master' into run-tests-and-tslint-for-addons-directory 2018-10-26 11:15:59 +03:00
Daniel Imms fc8640af1e Merge pull request #1768 from huashengdun/master
Added webssh to real-world uses
2018-10-25 09:05:15 -07:00
Shengdun Hua 213dadf1bd Update README.md 2018-10-25 23:01:03 +08:00
jrkong 2efd28ad4b updated webLinks regex to ignore colon at the end of a line and added the corresponding tests 2018-10-25 00:14:20 -04:00
Daniel Imms ba8d341416 Merge pull request #1748 from Tyriar/1747_npe
Fix NPE in DOM renderer underline
2018-10-24 16:28:57 -07:00
Daniel Imms 16614b7179 Merge pull request #1766 from whydoubt/has_focus 2018-10-24 16:10:01 -07:00
jerch c77af88010 Merge pull request #1706 from whydoubt/blank_line_attributes
Fill lines inserted from scrolling with erase attributes
2018-10-24 17:39:05 +02:00
jerch 50bc11b28b Merge branch 'master' into blank_line_attributes 2018-10-24 16:32:28 +02:00
Daniel Imms 565f46075c Merge pull request #1720 from alexr00/alexr00/ClearShouldClear
Cleared terminal lines should have isWrapped reset
2018-10-23 15:48:52 -07:00
Daniel Imms c2994b0ae1 Remove request term info handler
We're not supporting it anyway, no point having it.
2018-10-23 15:45:52 -07:00
Jeff Smith 4d556fcaf0 Check for focus on document as well as on textarea
When clicking outside of the browser document area, the cursor does not
appear to get 'blurred'. This can be confusing as it implies that the
cursor is still active. This is caused by Terminal's isFocused getter
only checking if the textarea is the active element of the document.

Expand isFocused to also check that the document itself has focus.
2018-10-23 11:57:20 -05:00
Alex Ross 083bc0f3d1 Merge branch 'master' into alexr00/ClearShouldClear 2018-10-23 10:17:26 +02:00
jrkong 1208fc9e10 updated webLinks regex to fix vscode issue#60401 2018-10-22 16:32:04 -04:00
Jörg Breitbart 1585aba5b5 slightly faster trimAndRecycle 2018-10-22 21:12:51 +02:00
Jörg Breitbart 82228ad891 trimAndRecycle with external check 2018-10-22 18:15:47 +02:00
Jörg Breitbart 6f6c7c20c0 Merge branch 'master' into reuse_bufferlines 2018-10-22 17:20:28 +02:00
Daniel Imms b9ab35dfe9 Merge pull request #1760 from skprabhanjan/fix-1749
Search from top of viewport when there is no selection
2018-10-20 13:56:53 -07:00
Daniel Imms 35db216f64 Fix indent 2018-10-20 13:55:13 -07:00
Daniel Imms 00c1211435 Merge pull request #1740 from jerch/bufferline_fixes
fix handling of length in BufferLine.resize
2018-10-20 12:57:47 -07:00
Jeff Smith 8bd49cba35 Fill inserted lines with background color
When scrolling occurs due to a LF or scroll code, fill the new line with
the currently-set background color.
2018-10-19 10:27:52 -05:00
Alex Ross 4a2189d140 Merge branch 'master' into alexr00/ClearShouldClear 2018-10-17 10:45:12 +02:00
Prabhanjan S Koushik f2fb46cc82 Merge branch 'master' into fix-1749 2018-10-17 10:51:27 +05:30
pkoushik 74664a9161 Fix-1749 2018-10-17 10:48:46 +05:30
Daniel Imms 5bc7fc4256 Merge pull request #1758 from Tyriar/1757_cjk_glyph_key
Move dynamic atlas canCache check higher
2018-10-16 11:23:22 -07:00
Daniel Imms af0ca6c2cb Merge pull request #1759 from stkvrs/fix-comment-typos
Fix typos
2018-10-16 11:22:49 -07:00
Vladimir Zeifman 3f3263cbb0 Fix tslint errors for all addons and un-exclude tests for search addon 2018-10-16 19:36:14 +03:00
Stathis Kavros 161dfa8d2d Fix typos 2018-10-16 14:23:58 +03:00
Alex Ross 8a6ed52e4e Merge branch 'master' into alexr00/ClearShouldClear 2018-10-16 12:21:00 +02:00
Daniel Imms 3edd2f2816 Merge branch 'master' into 1757_cjk_glyph_key 2018-10-15 11:44:51 -07:00
Daniel Imms 33ee08da47 Merge pull request #1756 from skprabhanjan/fix-1750
Fixes-1750
2018-10-15 11:43:58 -07:00
Daniel Imms a53aaa5f25 Move dynamic atlas canCache check higher
Fixes #1757
2018-10-15 11:35:21 -07:00
pkoushik f61ba9558b Fixes-1750 2018-10-15 23:44:30 +05:30
Alex Ross c6eb56670d Merge branch 'master' into alexr00/ClearShouldClear 2018-10-15 11:34:06 +02:00
Daniel Imms 19f6c0a940 Fix tests 2018-10-12 09:02:03 -07:00
Daniel Imms 37972aa5dd Merge pull request #1745 from xtermjs/Tyriar-patch-1
Update Azure data studio info
2018-10-12 08:58:06 -07:00
Daniel Imms a0250c5cea Improve types for listener args in .d.ts
Without this consumers need an undefined check with strictNullChecks
turned on.
2018-10-12 08:33:59 -07:00
Daniel Imms 9e1551e2f1 Fix NPE in DOM renderer underline
Fixes #1747
2018-10-11 09:37:19 -07:00
Jörg Breitbart d25e55ff45 Merge branch 'master' into bufferline_fixes 2018-10-11 18:33:21 +02:00
Daniel Imms b650db5b1a Merge pull request #1742 from AndrienkoAleksandr/fixDockerImageBuild
Fix docker image build.
2018-10-11 09:26:39 -07:00
Jörg Breitbart 4450dc9206 Merge branch 'master' into bufferline_fixes 2018-10-11 18:25:38 +02:00
jerch 69e6d7d9cc Merge pull request #1744 from jerch/demo_buffer
add buffer to server part in demo
2018-10-11 18:20:53 +02:00
Daniel Imms e66a10889f Merge branch 'master' into alexr00/ClearShouldClear 2018-10-11 09:02:54 -07:00
Daniel Imms 375b5c5b4f Fix indent 2018-10-11 09:02:36 -07:00
leomoty 2eec8f951f Merge branch 'master' into line-height 2018-10-11 11:55:12 -04:00
Alex Ross 64d6354983 Added testing and better erase left and above handling 2018-10-11 11:18:56 +02:00
Daniel Imms 8843b0cbc6 Update Azure data strudio info 2018-10-10 18:20:12 -07:00
Jörg Breitbart 588ed5e3af Merge branch 'demo_buffer' into reuse_bufferlines 2018-10-11 02:03:01 +02:00
Jörg Breitbart 05b68ee4ae Merge branch 'master' into demo_buffer 2018-10-11 01:59:03 +02:00
Daniel Imms 25e5795374 Merge branch 'master' into fixDockerImageBuild 2018-10-10 16:36:36 -07:00
Jörg Breitbart eb123ca787 add tiny buffer to server part in demo 2018-10-11 00:32:14 +02:00
Daniel Imms 58003d4e29 Merge pull request #1743 from alexr00/alexr00/nonWordChars
Remove underscore from non word characters list
2018-10-10 14:08:39 -07:00
Alex Ross c12aec3484 Merge branch 'alexr00/ClearShouldClear' of https://github.com/alexr00/xterm.js into alexr00/ClearShouldClear 2018-10-10 15:32:39 +02:00
Alex Ross f2ecd06e64 Additional isWrapped clearing 2018-10-10 15:31:49 +02:00
Jörg Breitbart 751e2efa75 better integration and experimentalPushRecycling option 2018-10-10 15:00:38 +02:00
Alex Ross c739d2fe87 Remove underscore from non word characters list
This is the upstream fix for Microsoft/vscode#59379
2018-10-10 14:05:23 +02:00
Oleksandr Andriienko 45e64a9167 Remove from package.json unused script command
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
2018-10-10 11:39:34 +03:00
Oleksandr Andriienko a63779ae7b Fix docker image build.
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
2018-10-10 10:26:32 +03:00
leomoty 6e350219aa Support for lineHeight in DOM Renderer 2018-10-09 18:58:25 -03:00
Jörg Breitbart 33a358033c new approach 2018-10-09 23:48:58 +02:00
Jörg Breitbart 0065682bd7 resize should not alter length if shrink=false 2018-10-09 21:17:33 +02:00
Daniel Imms 18035e239e Fix tests 2018-10-09 11:56:08 -07:00
Daniel Imms 91d04f2552 Merge branch 'master' into 1737_inverse_dynamic_cache 2018-10-09 11:43:26 -07:00
Daniel Imms bc16a8b7e7 Handle inverted default colors properly in DOM renderer
This uses the actual fg for bg and bg to fg, rather than the
black/white theme colors

Fixes #1738
2018-10-09 11:38:53 -07:00
Daniel Imms 1e9564788e Use constants for default colors 2018-10-09 11:12:35 -07:00
Daniel Imms 791c020a56 Allow inverse colors to be stored in glyph keys
Fixes #1737
2018-10-09 11:03:31 -07:00
jerch febc3ba2b8 Merge pull request #1736 from jerch/fix_bufferline_resize
fix BufferLine resize
2018-10-09 19:09:23 +02:00
Daniel Imms 1c5dfb5f34 Merge branch 'master' into fix_bufferline_resize 2018-10-09 09:58:00 -07:00
Jörg Breitbart 3877e96d7f fix BufferLine resize 2018-10-09 18:56:48 +02:00
Daniel Imms f2c7de8d53 Merge pull request #1735 from Tyriar/60291_infinite_loop
Fix infinite loop
2018-10-09 09:37:21 -07:00
Daniel Imms ed5467689a Fix infinite loop
See Microsoft/vscode#60291
2018-10-09 08:38:08 -07:00
jerch 8d16bb6ea2 Merge pull request #1641 from jerch/typedarray_BufferLine
buffer redesign - 2. Typedarray based BufferLine
2018-10-07 23:29:29 +02:00
Jörg Breitbart 2febd9b248 Merge branch 'typedarray_BufferLine' of git+ssh://github.com/jerch/xterm.js into typedarray_BufferLine 2018-10-07 22:10:10 +02:00
Jörg Breitbart 5b7aa68299 Merge branch 'master' into typedarray_BufferLine 2018-10-07 22:08:46 +02:00
Jörg Breitbart 3dbc6e604f move SIZE out of Cell enum 2018-10-07 22:07:55 +02:00
Daniel Imms 211cca8fda Merge branch 'master' into alexr00/ClearShouldClear 2018-10-06 10:36:18 -07:00
Daniel Imms e7ae4be394 Merge pull request #1728 from Tyriar/yarn_integrity
Commit yarn integrity checks
2018-10-05 10:14:28 -07:00
Daniel Imms b85b9bb3c3 Merge pull request #1699 from Tyriar/common_layering_strict
Enable strict null checks and no DOM access in common and core
2018-10-05 09:36:49 -07:00
Daniel Imms 77da89f5da Merge branch 'master' into alexr00/ClearShouldClear 2018-10-05 09:25:30 -07:00
Daniel Imms f5038bea3d Merge branch 'master' into common_layering_strict 2018-10-05 09:17:15 -07:00
Daniel Imms ae61292b10 Merge pull request #1729 from xtermjs/Tyriar-patch-1
Bump version to 3.8.0
2018-10-05 09:10:36 -07:00
Daniel Imms 8fd4bdd678 Bump version to 3.8.0 2018-10-05 09:04:20 -07:00
Daniel Imms 92b5c902de Commit yarn integrity checks 2018-10-05 08:59:54 -07:00
Daniel Imms a7b051c52f Merge pull request #1717 from Tyriar/charatlas_npe
Prevent NPE when disposing terminal shortly after creation
2018-10-04 12:02:09 -07:00
Daniel Imms b92bbf578b Merge branch 'master' into charatlas_npe 2018-10-04 10:30:04 -07:00
Alex Ross 18871f0d3c Cleared terminal lines should have isWrapped reset
Fixes #1710
2018-10-01 13:34:13 -07:00
Daniel Imms efe007b89b Merge branch 'master' into typedarray_BufferLine 2018-10-01 07:34:40 -07:00
Daniel Imms da027b2e11 Merge branch 'master' into common_layering_strict 2018-10-01 07:32:09 -07:00
Daniel Imms d4ec50e7de Merge pull request #1718 from zwhitchcox/patch-2
Don't delete fake terminal
2018-10-01 07:31:45 -07:00
Zane Hitchcox 5a1c71c1d5 Don't delete fake terminal 2018-10-01 10:16:59 -04:00
Daniel Imms bbf36fe091 Prevent NPE when disposing terminal shortly after creation 2018-10-01 06:38:24 -07:00
Daniel Imms 990bf5c973 Merge pull request #1711 from pfitzseb/patch-1
Add new use case: Juno
2018-09-27 09:23:02 -07:00
Sebastian Pfitzner b28bba56df Add new use case: Juno 2018-09-27 15:46:33 +02:00
jerch 21f3534668 Merge pull request #1693 from jerch/fix_1691
fix overscan issue at viewborders and enable linkifier on partial shown matches
2018-09-26 22:14:57 +02:00
Jörg Breitbart fefc6c6a34 fix typo 2018-09-26 22:07:02 +02:00
Jörg Breitbart 00bf16f610 Merge branch 'master' into typedarray_BufferLine 2018-09-25 01:02:14 +02:00
Jörg Breitbart 57a6fe5b87 Merge branch 'master' into fix_1691 2018-09-25 00:47:48 +02:00
Daniel Imms 9e446a9a0e Merge pull request #1692 from Tyriar/1677_perf_improve
Dynamic atlas: Reduce unnecessary objects generated and draw from ImageBitmap
2018-09-23 10:41:40 -07:00
Daniel Imms 16c0ad858a Make a new empty array instead of shift 2018-09-22 13:23:22 -07:00
Daniel Imms 750ec3870c Resolve feedback 2018-09-22 13:20:29 -07:00
Daniel Imms e9d54bf011 Merge branch 'master' into 1677_perf_improve 2018-09-22 13:04:05 -07:00
Jörg Breitbart 408403e2a0 Merge branch 'master' into fix_1691 2018-09-22 15:21:32 +02:00
Jörg Breitbart a30bb22c7a fix comments to <80 2018-09-22 15:20:31 +02:00
Daniel Imms a531b4dd9b Merge pull request #1695 from Tyriar/coveralls_fix
Fix coveralls integration
2018-09-21 12:40:03 -07:00
Daniel Imms 4cd591cb21 Merge branch 'master' into common_layering_strict 2018-09-21 11:50:22 -07:00
Jörg Breitbart 10687b138d range checks for buffer iterator 2018-09-21 20:23:41 +02:00
Jörg Breitbart 1108d0746e Merge branch 'master' into fix_1691 2018-09-21 19:23:49 +02:00
Daniel Imms 005785b84d Merge pull request #1705 from agurodriguez/xterm-1704
Support link underlines in the DOM renderer
2018-09-21 10:02:30 -07:00
Daniel Imms 2e8e64eb4d Merge pull request #1703 from Tyriar/1702_isWrapped_fix
Speculative fix for NPE in linkifier
2018-09-21 09:58:38 -07:00
Daniel Imms f44d57b2e8 Merge branch 'master' into coveralls_fix 2018-09-21 07:33:10 -07:00
Daniel Imms 36c53a5f8c Merge branch 'master' into common_layering_strict 2018-09-21 07:31:18 -07:00
Daniel Imms 995e384980 Fix search addon build 2018-09-21 07:31:06 -07:00
Daniel Imms 4941d5a19e Simplify loop, pass lint 2018-09-21 07:08:17 -07:00
Agustín Rodríguez 1f2d223e64 remove line in xterm.d.ts that says link underlines are not supported 2018-09-21 01:42:20 -03:00
Agustín Rodríguez d1991396e7 generalized loops to handle both single and multi line links 2018-09-21 01:38:37 -03:00
Agustín Rodríguez 478d824fa7 fix underline don't appearing when using the fallback DOM renderer 2018-09-21 01:38:37 -03:00
Daniel Imms 39a7b18065 Keep track of glyphs using cache values, not keys 2018-09-20 10:09:39 -07:00
Daniel Imms 2c62c3a8c3 Fix tests 2018-09-19 20:06:09 -07:00
Daniel Imms 4463f8d810 Speculative fix for NPE
Fixes #1702
2018-09-19 19:47:16 -07:00
Daniel Imms c05b6bd885 Merge branch 'master' into 1677_perf_improve 2018-09-19 08:03:09 -07:00
Daniel Imms 290c95ad71 Merge pull request #1698 from Tyriar/1697_scrolltop
Fix scroll APIs not affecting scroll bar
2018-09-19 07:58:53 -07:00
Daniel Imms 57bbc817bb Reduce addon lib usage 2018-09-18 10:25:49 -07:00
Daniel Imms fb0b73ab83 Enforce core layering and enable strict
Part of #1507
Part of #1319
2018-09-18 10:21:59 -07:00
Daniel Imms d1deca2330 Merge branch 'master' into common_layering_strict 2018-09-18 09:49:38 -07:00
Daniel Imms 33915f3ae0 Improve structure of addon tsconfigs 2018-09-18 09:49:07 -07:00
Daniel Imms e736f1223f Merge pull request #1696 from Tyriar/posttest
Remove npm-run-all
2018-09-18 09:29:45 -07:00
Daniel Imms a7a58aa055 Enable strict null checks and restrict DOM access in common
Part of #1507
Part of #1319
2018-09-17 13:44:31 -07:00
Daniel Imms cbe7b21090 Don't unlink node when updating inBitmap and verify undefined 2018-09-17 07:52:37 -07:00
Daniel Imms d9ec47ab7a Clear bitmap timeout on dispose 2018-09-17 07:48:05 -07:00
Daniel Imms 94b20d40bf Reuse object for glyph identifier 2018-09-17 07:43:31 -07:00
Daniel Imms 202734f10c Fix typo which broke dynamic atlas 2018-09-17 07:43:10 -07:00
Daniel Imms 4656bd433c Revert "Remove IGlyphIdentifier in-between object"
This reverts commit 04f2d52f26.
2018-09-17 07:37:04 -07:00
Daniel Imms f6d5abf7b3 Fix scroll APIs not affecting scroll bar
Fixes #1697
2018-09-17 06:52:22 -07:00
Daniel Imms 6ea56cd85e Remove npm-run-all
We can just use posttest
2018-09-16 11:42:09 -07:00
Daniel Imms 4d7ce4da46 Set coveralls branch name 2018-09-15 11:02:53 -07:00
Daniel Imms 39047767e4 Move coverage to mac agent as it's much faster 2018-09-15 10:40:54 -07:00
Daniel Imms 8d4b5cdc55 Run yarn coveralls after generating report 2018-09-15 10:38:06 -07:00
Daniel Imms 00af63b271 Expand glyph when needed 2018-09-15 10:10:50 -07:00
Daniel Imms 608d78b6ac Add fallback for window.createImageBitmap 2018-09-15 09:46:19 -07:00
Daniel Imms ac3595e8b4 Generate and use a bitmap instead of canvas 2018-09-15 09:44:01 -07:00
Jörg Breitbart 5284a5a742 fix spelling 2018-09-15 00:41:55 +02:00
Jörg Breitbart 842ee6c164 change overscan limit to 2k chars 2018-09-15 00:22:00 +02:00
Jörg Breitbart d0dc387921 fix overscan issue and enable linkify of partial shown matches 2018-09-14 23:16:24 +02:00
Daniel Imms 7762ab96a5 Exit draw early for the space character 2018-09-14 12:06:14 -07:00
Jörg Breitbart 84e9ad2adc Merge branch 'master' into typedarray_BufferLine 2018-09-14 19:19:41 +02:00
Daniel Imms 6528ba84ff Avoid creation of array converting index to coordinates 2018-09-14 10:12:43 -07:00
Daniel Imms 0bcf30a21b Merge remote-tracking branch 'origin/master' into 1677_perf_improve 2018-09-14 10:10:03 -07:00
Daniel Imms 86c78e726d Merge pull request #1675 from Tyriar/1674_watch_addons
Split addon watch into watch-addons
2018-09-14 10:09:34 -07:00
Daniel Imms cf9cb80cb4 Use a number as the dynamic cache key
This prevents string creation on every draw
2018-09-14 10:08:26 -07:00
Daniel Imms 04f2d52f26 Remove IGlyphIdentifier in-between object
This was being constructed for every character draw
2018-09-14 09:58:49 -07:00
Daniel Imms 192f751862 Merge branch 'master' into 1674_watch_addons 2018-09-14 09:35:20 -07:00
Daniel Imms de143b552d Merge pull request #1676 from Tyriar/1671_dom_renderer_stable
Make the DOM renderer stable
2018-09-14 09:35:02 -07:00
jerch d37a8ce539 Merge pull request #1678 from jerch/fix_linkifier
Improve unicode string handling in linkifier
2018-09-14 18:28:46 +02:00
Daniel Imms 2f66ec452c 💄 2018-09-14 08:35:14 -07:00
Jörg Breitbart 4b68976dfb hide regex error behind debug flag 2018-09-14 15:43:29 +02:00
Jörg Breitbart 3143ad7f02 Merge branch 'master' into fix_linkifier 2018-09-14 14:52:35 +02:00
Jörg Breitbart 631e331077 fix test cases 2018-09-14 14:48:41 +02:00
Jörg Breitbart 70be55df75 test cases for getStringCellWidth 2018-09-14 14:46:57 +02:00
Jörg Breitbart 14c20c5f32 simplify stringIndexToBufferIndex, fix docs 2018-09-14 14:19:25 +02:00
Jörg Breitbart 57bbbda7e8 rename stringWidth; add some comments 2018-09-14 14:15:27 +02:00
Jörg Breitbart 8664f54a76 rename contents to iterator 2018-09-14 13:22:02 +02:00
Jörg Breitbart 9514bfd31c cleanup BufferStringIterator 2018-09-14 13:15:35 +02:00
Jörg Breitbart 9ce2894353 remove toArray; interface type for iterator result 2018-09-14 12:59:56 +02:00
Daniel Imms 5c873c1ce2 Merge pull request #1664 from alexr00/alexr00/searchWord
Added search support for 'match whole word'
2018-09-13 20:38:22 -07:00
Daniel Imms 4d4d9914a8 Merge branch 'master' into alexr00/searchWord 2018-09-13 20:32:05 -07:00
Daniel Imms a19673d835 Merge branch 'master' into 1671_dom_renderer_stable 2018-09-13 20:31:55 -07:00
Daniel Imms f7dbadc79b Merge branch 'master' into 1674_watch_addons 2018-09-13 20:31:53 -07:00
Daniel Imms 50d600877c Use common TestTerminal for writeSync across Buffer/Linkifier test 2018-09-13 19:54:53 -07:00
Daniel Imms cd2ac929c3 💄 2018-09-13 19:44:02 -07:00
Daniel Imms 7401567856 Remove unsafe cast in Buffer.test.ts 2018-09-13 19:34:44 -07:00
Jörg Breitbart 69ab27004e Merge branch 'typedarray_BufferLine' of git+ssh://github.com/jerch/xterm.js into typedarray_BufferLine 2018-09-13 19:30:50 +02:00
Jörg Breitbart 65a528c18b Merge branch 'master' into typedarray_BufferLine 2018-09-13 19:18:37 +02:00
Jörg Breitbart a8d9c92ae1 make linter happy 2018-09-13 19:03:57 +02:00
Jörg Breitbart bd68853575 Merge branch 'master' into fix_linkifier 2018-09-13 19:01:31 +02:00
Daniel Imms 69a6c04620 Merge pull request #1687 from xtermjs/Tyriar-patch-1
Use new domain for azure pipelines
2018-09-13 08:50:49 -07:00
Daniel Imms 68766d540f Use new domain for azure pipelines 2018-09-13 08:19:59 -07:00
Daniel Imms a09e6a6238 Merge pull request #1681 from xtermjs/azure-pipelines
Set up CI with Azure Pipelines
2018-09-13 08:07:40 -07:00
Jörg Breitbart 30f74bf5f3 cover & comment right border trim behavior to be fixed 2018-09-13 16:20:37 +02:00
Jörg Breitbart 2708a76501 fix next() invocation; handle wild matches 2018-09-13 15:44:26 +02:00
Jörg Breitbart c8c22e3ddf docs 2018-09-13 14:30:11 +02:00
Alex Ross 7fc1fd947f Added search support for 'match whole word' 2018-09-12 09:30:34 -07:00
Jörg Breitbart 7e69c5d0db apply linkifier only to rows in viewport 2018-09-12 15:37:05 +02:00
Jörg Breitbart 0068c477b9 Merge branch 'master' into fix_linkifier 2018-09-12 15:05:12 +02:00
Daniel Imms 74474da7f3 Merge pull request #1663 from alexr00/alexr00/caseSearch
Added optional case sensitive searching
2018-09-11 22:35:12 -07:00
Daniel Imms e6e079bfa1 Merge branch 'master' into alexr00/caseSearch 2018-09-11 22:29:01 -07:00
Daniel Imms 7dc8118367 Merge pull request #1682 from alexr00/alexr00/spaceTrimming
Fixed translateBufferLineToStringWithWrap to correctly not remove spaces in the middle of a multiline wrapped string
2018-09-11 22:25:52 -07:00
Alex Ross 5aa6656971 Added test and fixed uncovered buy 2018-09-11 16:29:11 -07:00
Alex Ross 8979eea810 Fixed translateBufferLineToStringWithWrap to correctly not remove spaces in the middle of a multiline wrapped string 2018-09-11 16:12:53 -07:00
Alex Ross 7d2bdacf77 Added test case for when regex and case sensitive are both selected 2018-09-11 15:48:24 -07:00
Daniel Imms 1edc732c55 Use new Azure Pipelines badge 2018-09-11 11:34:47 -07:00
Daniel Imms e03c93fb81 Install yarn using installer task 2018-09-11 00:19:42 -07:00
Daniel Imms d23c65d1db Symlink yarn to /usr/bin 2018-09-11 00:09:36 -07:00
Daniel Imms 07b5bd0b64 Echo path 2018-09-11 00:04:27 -07:00
Daniel Imms 35483b3bf4 Source bashrc after yarn install 2018-09-11 00:00:33 -07:00
Daniel Imms 6ebf17bf04 Export yarn path 2018-09-10 23:53:45 -07:00
Daniel Imms 5d37a17383 Install latest yarn with install script
Avoids dpkg lock flakes
2018-09-10 23:49:52 -07:00
Daniel Imms dade9ba050 Simplify steps 2018-09-10 23:17:03 -07:00
Daniel Imms 5909885d43 Download and install yarn directly from deb 2018-09-10 23:10:42 -07:00
Daniel Imms 0446cf3aee Install yarn manually on Linux 2018-09-10 23:04:33 -07:00
Daniel Imms 3a97dbecde Add more platforms, build out script 2018-09-10 23:01:18 -07:00
azure-pipelines[bot] c88bc62ff9 Set up CI with Azure Pipelines 2018-09-11 05:53:14 +00:00
Jörg Breitbart a2bfbeaa74 Merge branch 'master' into fix_linkifier 2018-09-10 23:54:44 +02:00
Alex Ross ade3e0943c Fixed a merge mistake 2018-09-10 13:54:29 -07:00
Alex Ross 16de86f5ea Fixed an unintentionally capitalized i 2018-09-10 13:50:35 -07:00
Alex Ross fed579238a Added optional case sensitive searching 2018-09-10 13:45:29 -07:00
Daniel Imms 11426bb0d0 Merge pull request #1662 from alexr00/alexr00/searchWrapped
Added support for searching accross wrapped lines
2018-09-10 12:26:52 -07:00
Daniel Imms 5e004b21a3 Disallow the empty string from being selected by find 2018-09-10 12:17:17 -07:00
Daniel Imms b2ba281916 Fix references in demo to addons 2018-09-10 12:09:26 -07:00
Alex Ross bcf223e235 Fixed merge errors 2018-09-10 10:43:03 -07:00
Alex Ross d5c17a0cc9 Added one more test case 2018-09-10 10:25:23 -07:00
Alex Ross 54ed988fd1 Fixed issues around searching lines twice and considering a wrapped line both it's own line and part of the previous line. 2018-09-10 10:25:23 -07:00
Alex Ross 1460a34796 Added another test case and fixed the multi-line issue that uncovered 2018-09-10 10:22:12 -07:00
Alex Ross bc156294aa Udated comment 2018-09-10 10:20:32 -07:00
Alex Ross 09028d4d86 Added support for searching accross wrapped lines 2018-09-10 10:20:31 -07:00
Jörg Breitbart c35306aaa6 handle unicode within a match; test cases 2018-09-10 17:47:29 +02:00
Jörg Breitbart 3289eed2a2 merge master 2018-09-10 16:17:41 +02:00
Jörg Breitbart a76d4a6055 fix multiple row linkifier attempts; tests for unicode before a match 2018-09-10 16:10:41 +02:00
Daniel Imms 12e38404a2 Merge pull request #1672 from Tyriar/demo_lint
Fix lint in demo
2018-09-09 16:38:14 -07:00
Jörg Breitbart 08af72be1a linter errors 2018-09-10 01:13:21 +02:00
Jörg Breitbart daa6fa0a66 change Linkifier._doLinkifyRow 2018-09-10 00:40:29 +02:00
Jörg Breitbart 4aa8e402a4 fix MockBuffer 2018-09-09 22:21:00 +02:00
Jörg Breitbart a494e80a9f BufferStringIterator 2018-09-09 22:17:49 +02:00
Jörg Breitbart a8fe4107a3 Buffer.stringIndexToBufferIndex method 2018-09-09 21:18:33 +02:00
Daniel Imms 6c2acd6e34 Fix reference to new setting 2018-09-09 08:00:05 -07:00
Daniel Imms f2049694c8 Make the DOM renderer stable
Also updated the list of features which are not supported now. Note
that this may be moved to an addon eventually, this can be part of a
major release rather than included in the comment.

Fixes #1671
2018-09-09 07:38:38 -07:00
Daniel Imms e59fef87cc Split addon watch into watch-addons
Fixes #1674
2018-09-09 07:33:13 -07:00
Daniel Imms d943a5c890 Run tslint on the demo
Fixes #1673
2018-09-09 07:28:22 -07:00
Daniel Imms 715c078b6d Fix lint in demo 2018-09-09 07:22:18 -07:00
Daniel Imms 7447a8d08d Rename setting to experimentalBufferLineImpl, expose in d.ts 2018-09-09 07:20:13 -07:00
Daniel Imms f9717bc635 Merge pull request #1670 from Tyriar/1669_linkifier_exception
Fallback on default color when linkifier can't find the character
2018-09-09 07:00:45 -07:00
Daniel Imms 7ef18cca1e Merge pull request #1646 from peacefullatom/add-tests-for-events
#900 Add tests for events on Terminal
2018-09-08 14:15:56 -07:00
Daniel Imms c291ab1058 Remove failing refresh test 2018-09-08 14:04:04 -07:00
Daniel Imms d4d1426bff Merge branch 'master' into typedarray_BufferLine 2018-09-08 13:47:06 -07:00
Daniel Imms 25e0e97ef2 Merge branch 'master' into add-tests-for-events 2018-09-08 13:44:57 -07:00
jerch 0f28ccb093 Merge pull request #1668 from jerch/fix_demo
add explicit type to demo/client.ts
2018-09-08 22:10:51 +02:00
Daniel Imms f4bb4a22d4 Fallback on default color when linkifier can't find the character
This probably doesn't fix the underlying problem, but it will make it
obvious by using the white background color and more easily help identify
the problem case.

Fixes #1669
2018-09-08 13:01:59 -07:00
Jörg Breitbart a754f37209 fix conditions in Buffer.setBufferLineFactory 2018-09-08 18:02:59 +02:00
Jörg Breitbart d4f7c6bcf5 rename to copyFrom; use _push for JSArray based bufferline 2018-09-08 17:51:22 +02:00
Jörg Breitbart 4eede85ef6 fixes #1667 2018-09-08 17:26:19 +02:00
Jörg Breitbart bc943b7b57 merge with 3.7 2018-09-08 16:54:10 +02:00
Daniel Imms bdb6647ae0 Merge pull request #1652 from Tyriar/1337_project_refs_prep
Preparation for project references
2018-09-08 02:59:26 -07:00
Daniel Imms 0d89fcdeeb Merge pull request #1648 from Tyriar/webpack_demo
Improve demo build task
2018-09-08 02:58:58 -07:00
Daniel Imms 4ffc076f84 Merge pull request #1661 from Hindol/fix/1640
Add support for block and underline style cursor in DOM rendering mode
2018-09-08 02:53:51 -07:00
Daniel Imms 2ed3997aaa Merge pull request #1651 from xtermjs/Tyriar-patch-1
Move tslint prefer-const with the other core rules
2018-09-08 02:52:05 -07:00
Daniel Imms a0f9768fe8 Merge remote-tracking branch 'ups/master' into webpack_demo 2018-09-08 02:51:07 -07:00
Daniel Imms 8b334b01a6 Merge branch 'master' into 1337_project_refs_prep 2018-09-08 02:50:45 -07:00
Daniel Imms c6029765a4 Merge branch 'master' into Tyriar-patch-1 2018-09-08 02:50:39 -07:00
Daniel Imms 520dacac27 Merge pull request #1666 from alexr00/alexr00/searchRegex
Added support for searching by regular expression
2018-09-08 02:50:18 -07:00
Daniel Imms dcc1b7a3e3 Merge branch 'master' into webpack_demo 2018-09-08 02:49:36 -07:00
Daniel Imms 27c3663470 Bump version to 3.7.0 2018-09-08 02:38:05 -07:00
Daniel Imms 599271bde4 Make search option props optional, test optional typings 2018-09-08 02:10:02 -07:00
Hindol Adhya 2716413e66 Updates as per code review comments
Getting rid of the ICursorOptions interface to improve performance
2018-09-08 13:20:31 +05:30
Alex Ross e5465841f8 Responded to feedback and fixed the returned found term 2018-09-07 15:29:51 -07:00
Alex Ross 03e54cce7d Added regex search test 2018-09-07 11:01:08 -07:00
Alex Ross 88205511e6 Added support for searching by regular expression 2018-09-07 09:47:15 -07:00
Hindol Adhya 374a8b70eb Add support for block and underline style cursor in DOM rendering mode 2018-09-06 21:27:35 +05:30
Jörg Breitbart c8b8e39dde move blankLine to Buffer 2018-09-04 22:19:10 +02:00
peacefullatom 48cf73c152 rewrote to async 2018-09-05 01:11:23 +05:00
peacefullatom 1dc88d2e29 Merge remote-tracking branch 'upstream/master' into add-tests-for-events 2018-09-05 01:08:57 +05:00
Jörg Breitbart 7873598a41 rename BufferLineJsArray as BufferLine 2018-09-04 21:41:00 +02:00
Daniel Imms 7c1b1e2eb8 Fix strict null checks in ./common
Part of #1319
2018-09-04 09:56:29 -07:00
Jörg Breitbart 2877c0da80 switch for BufferLineJsArray vs BufferLineTypedArray 2018-09-04 18:20:01 +02:00
Daniel Imms fb72f25067 Merge branch 'master' into 1337_project_refs_prep 2018-09-04 08:04:39 -07:00
Daniel Imms 3618c6495b typescript@3.0 2018-09-04 08:02:47 -07:00
Daniel Imms 443b2dbc28 Have common only reference within common
Part of #1337
2018-09-04 08:01:04 -07:00
Daniel Imms 53e995a2d8 Add dom lib to typings-test 2018-09-04 07:38:52 -07:00
Daniel Imms 53193d0a47 Use es6 in typings test 2018-09-04 07:34:13 -07:00
Jörg Breitbart 165c8d4522 convenient methods fill, makeCopyOf and clone for BufferLine 2018-09-04 16:30:17 +02:00
Daniel Imms 92341c3e7b Merge branch 'master' into webpack_demo 2018-09-04 06:56:06 -07:00
Jörg Breitbart 02672dc22e Merge branch 'master' into typedarray_BufferLine 2018-09-04 15:05:13 +02:00
Daniel Imms 57b8e064a8 Move tslint prefer-const with the other core rules
The ones at the bottom are separated as they're part of tslint-consistent-codestyle
2018-09-02 13:43:37 -07:00
jerch 3a310f1597 Merge pull request #1649 from jerch/fix_search_addon
Fix broken search addon
2018-09-02 22:00:25 +02:00
Jörg Breitbart 4d0217f816 Merge branch 'fix_search_addon' of https://github.com/jerch/xterm.js into fix_search_addon 2018-09-02 21:46:44 +02:00
Jörg Breitbart 559e932a2e remove comment and setTimeout 2018-09-02 21:46:20 +02:00
Jörg Breitbart aa427010e1 Merge branch 'master' into fix_search_addon 2018-09-02 21:38:42 +02:00
jerch 1aec57e8c0 Merge pull request #1645 from jerch/fix_convertEol
fix convertEol option
2018-09-02 21:19:19 +02:00
peacefullatom cbbf6bd654 Merge branch 'master' into add-tests-for-events 2018-09-02 22:50:45 +05:00
Daniel Imms 33b65bbfaa Merge branch 'master' into fix_convertEol 2018-09-02 10:42:02 -07:00
Daniel Imms 8e39650b5f Merge branch 'master' into fix_search_addon 2018-09-02 10:34:22 -07:00
Daniel Imms f148238117 Merge pull request #1638 from Tyriar/duplicate_tslint
Remove duplicate triple-equals rule
2018-09-02 10:32:23 -07:00
Jörg Breitbart 6057586ff3 fixes #1647 2018-09-02 17:52:56 +02:00
Daniel Imms e2267fce92 Remove old webpack.config.js 2018-09-01 19:57:51 -07:00
Daniel Imms 784a142dac Remove old gulp tasks 2018-09-01 19:50:45 -07:00
Daniel Imms 71aa7027bd Use new script for yarn start 2018-09-01 19:48:06 -07:00
Daniel Imms ca76ebc396 Remove todo 2018-09-01 17:34:52 -07:00
Daniel Imms 54187b3597 Fix build by adding es6 lib
Targets are still es5, es6 is needed for @types/webpack to parse
2018-09-01 17:03:02 -07:00
Daniel Imms d58f5cac01 Type Terminal 2018-09-01 16:48:55 -07:00
Daniel Imms b3e8980270 Convert demo client to TS 2018-09-01 16:34:07 -07:00
Daniel Imms 4d14e00034 Add webpack dependencies, update to webpack 4 2018-09-01 16:22:56 -07:00
Daniel Imms e75578440e Improve demo webpack build 2018-09-01 16:22:27 -07:00
peacefullatom 70afb13c9b #900 Add tests for events on Terminal 2018-09-02 02:31:26 +05:00
Daniel Imms 6a2c4b9823 Merge branch 'master' into duplicate_tslint 2018-09-01 09:58:58 -07:00
Daniel Imms e2cfd94005 Merge pull request #1607 from Tyriar/444_viewport_sync
Only sync viewport in an animation frame
2018-09-01 09:58:34 -07:00
Daniel Imms 9fe8ea8de2 Merge branch 'master' into duplicate_tslint 2018-09-01 09:50:57 -07:00
Daniel Imms 46311b87a2 Merge pull request #1602 from xtermjs/Tyriar-patch-1
Add link to running the demo from CONTRIBUTING.md
2018-09-01 09:48:31 -07:00
Daniel Imms 692ca1c9a3 Merge branch 'master' into duplicate_tslint 2018-09-01 09:47:26 -07:00
Daniel Imms bf5c1f0f78 Merge branch 'master' into 444_viewport_sync 2018-09-01 09:47:09 -07:00
Daniel Imms 467a93c8d9 Fix typo/grammar/line width 2018-09-01 09:34:01 -07:00
Daniel Imms 3841edadb5 Merge pull request #1644 from Tyriar/1642-disposable-jsdoc
Document addDisposableListener
2018-08-31 21:19:41 -07:00
Jörg Breitbart 76edd8a3bb fix error in resize 2018-09-01 05:31:32 +02:00
Jörg Breitbart 284b083274 note on copy on data access 2018-09-01 02:10:11 +02:00
Jörg Breitbart f9453ef4fa rename fill to fillCharData 2018-09-01 00:50:40 +02:00
Jörg Breitbart 024404f548 make cols mandatory in BufferLine ctor 2018-09-01 00:18:52 +02:00
Jörg Breitbart dc332480cc fix convertEol option 2018-08-31 23:02:05 +02:00
Daniel Imms a194263183 Document addDisposableListener
Part of #1642
2018-08-31 12:02:54 -07:00
Jörg Breitbart f3561fad30 cleanup 2018-08-31 17:51:47 +02:00
Jörg Breitbart 3f2605f35c typed array based BufferLine 2018-08-31 17:45:32 +02:00
Jörg Breitbart d1f6798e75 Merge branch 'buffer_preparations' into buffer_preparations_part2 2018-08-31 04:41:57 +02:00
Jörg Breitbart 841a33be28 remove push/pop/splice calls to BufferLine 2018-08-31 04:40:08 +02:00
jerch dd7081f948 Merge pull request #1632 from jerch/buffer_preparations
buffer redesign - `BufferLine` implementation and cleanups
2018-08-31 01:49:05 +02:00
Daniel Imms 999fce4e52 Remove test only functions from InputHandler.s 2018-08-30 16:22:30 -07:00
Jörg Breitbart 0d49d1f64d set DEFAULT_CELL explicit in ctor and remove the global const value 2018-08-30 21:12:55 +02:00
Jörg Breitbart 11df1e1d80 make sure DEFAULT_CELL gets not overwritten by accident 2018-08-30 21:03:30 +02:00
Jörg Breitbart a74ca25b09 cleanup spaces and comments in InputHandler 2018-08-30 20:29:23 +02:00
Jörg Breitbart 32231dcd41 remove static DefaultCell 2018-08-30 20:27:52 +02:00
Jörg Breitbart 04a847f0e2 merge with master 2018-08-30 18:12:48 +02:00
Jörg Breitbart 276e65fa0b move erase methods to InputHandler 2018-08-30 18:10:18 +02:00
Jörg Breitbart a1421b151e cleanup BufferLine.ts 2018-08-30 17:58:37 +02:00
Jörg Breitbart 71f5965f8e move to BufferLine.ts 2018-08-30 17:55:04 +02:00
Jörg Breitbart 59fc4af9a0 IBufferLine interface 2018-08-30 17:52:45 +02:00
Daniel Imms 381e6c1740 Move defaultCell to an exported member 2018-08-30 07:57:03 -07:00
Jörg Breitbart 9a54cf639b Merge branch 'master' into buffer_preparations 2018-08-29 23:19:14 +02:00
Jörg Breitbart 01a4ec21da make linter happy 2018-08-29 22:41:24 +02:00
Jörg Breitbart a65bd1a77c Merge branch 'buffer_preparations' of https://github.com/jerch/xterm.js into buffer_preparations 2018-08-29 22:37:19 +02:00
Jörg Breitbart 6439f6e856 regression tests for changes in InputHandler 2018-08-29 22:37:01 +02:00
Daniel Imms d24caf14a4 Merge branch 'master' into 444_viewport_sync 2018-08-29 10:27:20 -07:00
Daniel Imms 52f132a570 Clean up buffer tests 2018-08-28 14:29:18 -07:00
Jörg Breitbart 424d3257d1 set conditional blocks in brackets 2018-08-28 02:34:46 +02:00
Daniel Imms f47f095b89 Merge pull request #1636 from peacefullatom/fix-crosshair
Fix crosshair
2018-08-27 10:22:53 -07:00
Jörg Breitbart de26be56c1 change type of IPartialLineData 2018-08-27 17:11:40 +02:00
Jörg Breitbart f964a34b34 explicit member visibility 2018-08-27 17:01:30 +02:00
Jörg Breitbart 6576d513b0 fix index access to cell in winptyCompat 2018-08-27 16:53:58 +02:00
Daniel Imms 4af2d1ed41 Remove duplicate triple-equals rule 2018-08-27 07:26:00 -07:00
peacefullatom 9e27c231e5 Merge branch 'master' into fix-crosshair 2018-08-27 12:04:23 +05:00
Daniel Imms ae3684c897 Merge pull request #1634 from angersson/master
Add shellvault.io to README.md
2018-08-26 17:52:19 -07:00
Jörg Breitbart d4c621a182 more TerminalLine tests 2018-08-26 19:59:16 +02:00
Jörg Breitbart 9c68eb3b11 move line content functions to TerminalLine 2018-08-26 19:24:49 +02:00
Jörg Breitbart 77cb697990 remove <any> casts for .isWrapped 2018-08-26 16:04:52 +02:00
Jörg Breitbart cee432a66a TerminalLine ctor parameters; tests 2018-08-26 15:50:00 +02:00
Jörg Breitbart a553415216 remove blankLine from Terminal 2018-08-26 14:35:28 +02:00
Jörg Breitbart cd8477a942 move blankLine to TerminalLine 2018-08-26 14:27:38 +02:00
Austin Anderson 811b3cc326 Add Shellvault to readme 2018-08-25 21:36:58 -07:00
Jörg Breitbart a99cac45f7 fix import errors 2018-08-25 22:56:15 +02:00
Jörg Breitbart 3d34881c4e rebase to master 2018-08-25 22:43:15 +02:00
Jörg Breitbart 0340d91150 first step to buffer redesign: class TerminalLine; discourage low level index access to cells 2018-08-25 22:41:42 +02:00
Jörg Breitbart 5c3315251b first step to buffer redesign: class TerminalLine; discourage low level index access to cells 2018-08-25 20:58:50 +02:00
Daniel Imms e769e787a8 Merge pull request #1626 from peacefullatom/fix-underline-color
#957 Link underline should be the same as FG color
2018-08-24 14:49:40 -07:00
peacefullatom 96ed32698b fix 1629 Crosshair cursor doesn't go away after hitting alt+tab 2018-08-25 00:06:44 +05:00
peacefullatom e66928da20 Merge branch 'fix-underline-color' of https://github.com/peacefullatom/xterm.js into fix-underline-color 2018-08-24 22:48:50 +05:00
peacefullatom c762885c4b Merge branch 'master' of https://github.com/xtermjs/xterm.js into fix-underline-color 2018-08-24 22:36:12 +05:00
Yuriy Markov 63ced6f302 Merge branch 'master' into fix-underline-color 2018-08-24 22:35:39 +05:00
Daniel Imms 82f6547f10 Merge pull request #1628 from princjef/triple-equals
Enforce strict equality through tslint
2018-08-24 07:49:30 -07:00
Jeff Principe 841a0e010d Merge branch 'master' into triple-equals 2018-08-23 20:59:30 -07:00
Yuriy Markov 85f25e77f5 Merge branch 'master' into fix-underline-color 2018-08-24 01:46:30 +05:00
Daniel Imms 2adaed87d1 Merge pull request #1624 from princjef/first-line-render
Only render first line when requested
2018-08-23 09:53:33 -07:00
peacefullatom 4c93d8ddaa Merge branch 'master' into fix-underline-color 2018-08-23 16:25:32 +05:00
Jeff Principe b35fa9576e Enforce strict equality through tslint 2018-08-22 19:36:40 -07:00
Jeff Principe 091c42f7e6 only render first line when requested 2018-08-22 19:10:56 -07:00
peacefullatom 6601133912 #957 Link underline should be the same as FG color 2018-08-23 04:24:10 +05:00
Daniel Imms 9273e8175e Merge pull request #1621 from xtermjs/Tyriar-patch-2
Fix license
2018-08-21 15:59:27 -07:00
Daniel Imms cd75d6fb68 Merge pull request #1622 from Tyriar/1620_row_render
Prevent whole viewport from refreshing
2018-08-21 15:59:13 -07:00
Daniel Imms 01bfa1df4b Merge pull request #1619 from meefik/patch-1
Bug with receive the result from FileReader
2018-08-21 15:34:40 -07:00
Daniel Imms 123e074c16 Merge branch 'master' into 1620_row_render 2018-08-21 15:15:42 -07:00
Daniel Imms 929150a8e1 Prevent whole viewport from refreshing
Fixes #1620
2018-08-21 15:13:27 -07:00
Daniel Imms e3eb1b81b3 Fix license 2018-08-21 12:29:46 -07:00
Anton Skshidlevsky 04c4448f97 Bug with receive the result from FileReader
Incorrect variable "this" must be replace to fileReader.
2018-08-18 15:36:51 +03:00
Daniel Imms 0e45909c7e Merge pull request #1613 from shroudedcode/support-not-italic
Add support for the "Not italic" escape code
2018-08-14 11:33:39 -07:00
Niklas Higi 44366ffd3c Add support for the "Not italic" escape code 2018-08-14 12:29:12 +02:00
Daniel Imms 49cf1a2cea Merge pull request #1610 from princjef/typings-no-emit
Stop typescript from emitting output files in typings test
2018-08-10 19:47:18 -07:00
Daniel Imms 86800d2d71 Bump version to 3.6.0 2018-08-10 19:28:06 -07:00
Daniel Imms 41fdc9071a Update AUTHORS 2018-08-10 19:27:16 -07:00
Jeff Principe 14d75364eb Stop typescript from emitting output files in typings test 2018-08-09 19:44:25 -07:00
Daniel Imms 2127128ef5 Only sync viewport in an animation frame
Fixes #444
2018-08-09 12:19:37 -07:00
Daniel Imms 95ebba6fdb Add link to running the demo from CONTRIBUTING.md 2018-08-07 19:32:30 -07:00
Daniel Imms ff63d3eb23 Merge pull request #1601 from segevfiner/source-map-loader
Add source-map-loader to webpack config
2018-08-07 14:11:08 -07:00
Daniel Imms 05b8ef1727 Merge pull request #1599 from 7PH/master
#1591: Fix bold inverted text displayed with wrong color
2018-08-07 14:07:32 -07:00
Segev Finer 458f2d8bf1 Add source-map-loader to webpack config
This makes source maps work in the demo
2018-08-07 22:39:09 +03:00
PowerHat 87a84b608c #1591: Fix bold inverted text displayed with wrong color 2018-08-06 22:41:57 +02:00
Daniel Imms dd7a9c3b7a Merge pull request #1594 from Tyriar/1593_column_select
Fix bug in column selection rendering
2018-08-06 12:32:35 -07:00
Daniel Imms d1ca0d7839 Merge branch 'master' into 1593_column_select 2018-08-06 11:33:59 -07:00
Daniel Imms 3419480b98 Merge pull request #1586 from Tyriar/1579_emit_pos_directly
Report device status directly via emit
2018-08-06 11:26:15 -07:00
Daniel Imms a003a0c585 Merge remote-tracking branch 'origin/master' into 1579_emit_pos_directly 2018-08-06 11:21:35 -07:00
Daniel Imms e3dfe4bc32 Merge branch 'master' into 1593_column_select 2018-08-06 11:17:52 -07:00
Daniel Imms c9ec7aa215 Fix flickering when dragging below viewport 2018-08-06 11:17:28 -07:00
Daniel Imms 7675be7da3 Fix dragging when in column selection mode 2018-08-06 11:13:56 -07:00
Daniel Imms 1a03b703f1 Merge pull request #1578 from Tyriar/1567_npe
Fix NPE in InputHandler.parse
2018-08-06 07:31:28 -07:00
Daniel Imms 9165581266 Merge branch 'master' into 1593_column_select 2018-08-06 07:24:46 -07:00
Daniel Imms 6a770296f9 Add tests for Dispoable 2018-08-06 07:22:32 -07:00
Daniel Imms cbfb99a5cf Move _isDisposed to Disposable class 2018-08-06 07:16:51 -07:00
Daniel Imms bae3f64c10 Merge branch 'master' into 1567_npe 2018-08-06 07:14:33 -07:00
Daniel Imms 7c7102d8a6 Merge pull request #1556 from xtermjs/Tyriar-patch-1
Add pointer to .d.ts and mention addon CSS
2018-08-06 07:13:21 -07:00
Daniel Imms 8e9ba23227 Merge pull request #1598 from xtermjs/remove_travis
Remove Travis CI badge
2018-08-06 07:12:35 -07:00
Daniel Imms 1d91e3c5bf Merge pull request #1597 from Tyriar/1596_a11y_npe
Fix NPE in AccessibilityManager
2018-08-06 07:12:23 -07:00
Daniel Imms 45d4622920 Merge pull request #1590 from Tyriar/1589_swap_renderer
Allow renderer to be swapped in and out at runtime
2018-08-06 07:08:40 -07:00
Daniel Imms b7da4b6bfe Merge pull request #1588 from Tyriar/1584_use_const
Use const for null cell
2018-08-06 07:08:21 -07:00
Daniel Imms fdf51c119b Merge pull request #1585 from Tyriar/1571_dbl_click_wrapped
Make double click select word aware of wrapped lines
2018-08-06 07:06:45 -07:00
Daniel Imms 6de8c91059 Merge pull request #1583 from Tyriar/remove_jsdoc_types
Remove jsdoc types
2018-08-06 07:06:29 -07:00
Daniel Imms 490f0ad329 Remove Travis CI badge 2018-08-03 19:20:21 -07:00
Daniel Imms 882aea357f Fix NPE in AccessibilityManager
Fixes #1596
2018-08-03 11:10:51 -07:00
Daniel Imms d8eedfa1c7 Fix bug in column selection rendering
Fixes #1593
2018-07-31 10:56:37 -07:00
Daniel Imms 90e57c9b3c Merge branch 'master' into 1571_dbl_click_wrapped 2018-07-29 19:12:07 -07:00
Daniel Imms a269e7f5d9 Merge pull request #1569 from Tyriar/1505_deprecate_emit
Deprecate Terminal.emit
2018-07-29 19:11:15 -07:00
Daniel Imms 4a3c1a4cc6 Store theme in right place 2018-07-29 14:25:55 -07:00
Daniel Imms 804cb36adc Retain theme when renderers are swapped 2018-07-29 14:17:25 -07:00
Daniel Imms 5aaf9ef11b Allow renderer to be swapped in and out at runtime
Fixes #1589
2018-07-29 13:50:45 -07:00
Daniel Imms c65dd1f476 Use const for null cell
Fixes #1584
2018-07-29 13:05:27 -07:00
Daniel Imms 05f136b3da Add link to GitHub dependents to real world uses 2018-07-28 12:42:11 -07:00
Daniel Imms 1c4cb8c620 Reinstate IInputHandlingTerminal
Fixes #1587
2018-07-27 11:46:09 -07:00
Daniel Imms fec66c7dac Remove Terminal.send 2018-07-27 11:32:11 -07:00
Daniel Imms e82f78fc84 Merge branch 'master' into 1571_dbl_click_wrapped 2018-07-26 12:28:37 -07:00
Daniel Imms 67d6ad57c3 Add tests 2018-07-26 12:23:34 -07:00
Daniel Imms 48f1c4667a Fix select to word upwards 2018-07-26 11:30:49 -07:00
Daniel Imms 6a9da97163 Cover select to word downwards 2018-07-26 11:15:34 -07:00
Daniel Imms 7b68cb9fe7 Support double click select word over wrapped lines
Part of #1571
2018-07-26 11:09:29 -07:00
Daniel Imms 6691f80906 Merge pull request #1581 from Tyriar/exp_api
Add note in readme about API/experimental API
2018-07-25 17:53:22 -07:00
Daniel Imms bdfe877c8f Remove jsdoc types
They're redundant in TS/tsdoc
2018-07-24 08:59:20 -07:00
Daniel Imms ee3668eb03 Report device status directly via emit
Fixes #1579
2018-07-24 08:40:51 -07:00
Daniel Imms 4a443c4a45 Move API section to getting started, above addons 2018-07-24 06:30:18 -07:00
Daniel Imms d964c23c43 Add note in readme about API/experimental API 2018-07-24 06:27:05 -07:00
Daniel Imms 20d4c64ffe Make write/_innerWrite aware of terminal disposal 2018-07-23 15:37:04 -07:00
Daniel Imms bf3709f4c5 Fix NPE in InputHandler.parse
Fixes #1567
2018-07-23 15:29:45 -07:00
Daniel Imms 8f22d8dda4 Merge pull request #1574 from vincentwoo/patch-1
refreshRowElements argument order was flipped
2018-07-19 08:14:08 -07:00
Vincent Woo 0f6a8d3991 refreshRowElements argument order was flipped
This is potentially a fix for #1573 but I have not tested.
2018-07-18 17:55:59 -07:00
Daniel Imms 5b8da8c89a Merge pull request #1570 from nikonso/fix-1509
Prevent Uncaught TypeError  - Cannot read property 'isWrapped' on Linkifier
2018-07-17 08:43:08 -07:00
Bruno Ribeito f2e5ea5783 Remove unnecessary get line 2018-07-16 21:11:35 +01:00
Bruno Ribeito cb888c343e break instead of returning 2018-07-15 19:48:16 +01:00
Bruno Ribeito 18f37440dc Prevent Uncaught TypeError
- Cannot read property 'isWrapped' on Linkifier
2018-07-15 19:36:49 +01:00
Daniel Imms 3582f8733d Deprecate emit
Part of #1505
2018-07-14 10:46:55 -07:00
Daniel Imms b84dba2e8d Merge pull request #1566 from Tyriar/1565_charset_fix
Fix charset drawing
2018-07-12 08:45:21 -07:00
Daniel Imms 61fc4ca8a6 Fix charset drawing
Fixes #1565
2018-07-12 08:27:57 -07:00
Daniel Imms bbd234b951 Merge branch 'master' into Tyriar-patch-1 2018-07-10 18:26:31 -07:00
Daniel Imms 0545cfa121 Merge pull request #1563 from Tyriar/1562_yarn
Use yarn
2018-07-10 18:26:12 -07:00
Daniel Imms 26969b725e Merge branch 'master' into 1562_yarn 2018-07-10 17:47:23 -07:00
Daniel Imms eb31732af0 Merge pull request #1564 from Tyriar/remove_travis
Remove TravisCI
2018-07-10 17:47:05 -07:00
Daniel Imms 9c08f78017 Remove TravisCI 2018-07-10 17:33:37 -07:00
Daniel Imms 54dcbeb6cf Use yarn. 2018-07-10 17:25:39 -07:00
Daniel Imms a52aab4618 Merge pull request #1460 from princjef/character-joiner
Add optional character joiner
2018-07-10 17:01:20 -07:00
Daniel Imms 5f5a49995a Merge pull request #1555 from jerch/fix_out_of_bound_deopt
fix out of bound deopt in EscapeSequenceParser.parse
2018-07-10 17:00:58 -07:00
Daniel Imms ac7239732d Merge pull request #1558 from xtermjs/Tyriar-patch-2
Move developer documentation to the wiki
2018-07-10 17:00:25 -07:00
Daniel Imms 68d537fb28 Merge pull request #1561 from roke22/master
Add project that use xterm to the README file
2018-07-10 17:00:14 -07:00
Paris Kasidiaris 7c3bf3a130 Bump version to 3.5.0
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2018-07-10 16:01:25 +00:00
Daniel Imms 7ce071c575 Remove extra list item 2018-07-10 08:24:59 -07:00
Jose Anton 42f1aba00c Add project that use xterm to the README file 2018-07-10 16:20:58 +02:00
Daniel Imms dfb1b4db95 Move third party deps note to wiki 2018-07-09 09:25:35 -07:00
Daniel Imms 6900bbc07a Move developer documentation to the wiki 2018-07-09 09:24:07 -07:00
Daniel Imms d4b507ddb1 Inline private member to ctor 2018-07-09 07:05:12 -07:00
Daniel Imms 1bad71f13a Merge branch 'master' into character-joiner 2018-07-09 06:18:03 -07:00
Jeff Principe 63b3a6f323 Factor logic into registry, make matches cell-based and document 2018-07-08 11:30:54 -07:00
Jörg Breitbart ba7976f3b1 do while loop 2018-07-07 21:20:03 +02:00
Daniel Imms b5b350fdcf Add pointer to .d.ts and mention addon CSS
Part of #1554
2018-07-07 11:12:29 -07:00
Jörg Breitbart 87e292414d fix out of bound deopt in EscapeSequenceParser.parse 2018-07-07 12:46:51 +02:00
Daniel Imms 5620da49d8 Merge pull request #1553 from Tyriar/1552_selection_state
Include ydisp in selection state
2018-07-06 10:18:06 -07:00
Daniel Imms 3c8f336689 Include ydisp in selection state
Fixes #1552
2018-07-06 09:53:45 -07:00
Daniel Imms f1c9d37c83 Merge pull request #1547 from Tyriar/remove_parser
Remove the old parser
2018-07-05 07:40:15 -07:00
Daniel Imms 08603c7975 Merge branch 'master' into remove_parser 2018-07-05 07:40:06 -07:00
Daniel Imms 318dc6fcf6 Merge pull request #1537 from Tyriar/fix_typo
Fix typo
2018-07-05 07:39:48 -07:00
Daniel Imms 68adadf3f4 Remove the old parser 2018-07-04 10:34:53 -07:00
Daniel Imms 5e3ebbde5e Merge branch 'master' into character-joiner 2018-07-03 11:50:27 -07:00
Daniel Imms 6d9d2a3304 Merge remote-tracking branch 'origin/master' into pr/princjef/1460 2018-07-03 11:50:07 -07:00
Daniel Imms 73bc1c577a Merge pull request #1503 from Tyriar/998_mouse_off
Nullify and remove mouse handlers when mouse move it exited
2018-07-02 13:25:36 -07:00
Daniel Imms aec4c908d3 Merge remote-tracking branch 'origin/master' into 998_mouse_off 2018-07-02 13:22:28 -07:00
Daniel Imms 9aad2f7ca5 Merge pull request #1543 from nikonso/fix-SelectionRenderLayer-state
Fix SelectionRenderLayer._state
2018-07-02 09:23:01 -07:00
Daniel Imms af9d17760d Make columnSelectMode mandatory 2018-07-02 09:22:38 -07:00
Daniel Imms 4557f857f7 Merge pull request #1542 from nikonso/recreate-terminal
Add recreate terminal after disposing to the demo
2018-07-02 09:13:16 -07:00
Bruno Ribeito ed58c42513 Fix actions and styles 2018-07-01 22:50:08 +01:00
Bruno Ribeito 7e393dfa8c Move logic to helper function 2018-07-01 22:24:51 +01:00
Bruno Ribeiro 0a70b182a7 Merge branch 'master' into recreate-terminal 2018-07-01 20:35:15 +01:00
Bruno Ribeito 932a8d5028 Fix SelectionRenderLayer._state 2018-07-01 19:26:50 +01:00
Bruno Ribeito 054592520e Add recreate terminal after disposing to the demo 2018-07-01 18:56:58 +01:00
Daniel Imms 38debf77f8 Merge pull request #1538 from vsinha/column-select
Support for column/box selection
2018-06-30 10:20:38 -07:00
Daniel Imms 117c79e4e7 Polish 2018-06-30 10:11:48 -07:00
Viraj Sinha 3a4ad37177 Added mac platform check before we try to use mac specific config var 2018-06-29 20:19:18 -07:00
Viraj Sinha ace612e575 Fixes for merging column select 2018-06-29 20:15:17 -07:00
Daniel Imms e628a9be76 Fix emoji test 2018-06-29 11:25:17 -07:00
Daniel Imms 835d5a16ea Fix build after merge 2018-06-29 11:17:45 -07:00
Viraj Sinha 169cbb3fca Merge branch 'master' into column-select 2018-06-28 15:59:27 -07:00
Viraj Sinha 2669576b6c Adds a toggle to disable column selections on mac 2018-06-28 15:56:25 -07:00
Viraj Sinha 3202ddc96d Adds support for column selections if holding alt on mac and shift on windows/linux 2018-06-28 15:55:44 -07:00
Daniel Imms 35ee3610f7 Add missing new line back 2018-06-28 13:25:54 -07:00
Daniel Imms 45f5a710d6 Merge branch 'master' into fix_typo 2018-06-28 13:25:12 -07:00
Daniel Imms 1395b0f03c Merge pull request #1525 from Tyriar/1518_memory
Ensure all references are released when Terminal.dispose is called
2018-06-28 13:21:27 -07:00
Daniel Imms 38efb1a02d Merge branch 'master' into fix_typo 2018-06-28 13:00:34 -07:00
Daniel Imms 22308fb37c Fix typo 2018-06-28 12:59:53 -07:00
Daniel Imms 100143bd02 Merge branch 'master' into 1518_memory 2018-06-28 10:29:07 -07:00
Daniel Imms 8c20a2e26b Merge pull request #1535 from 7PH/master
#1532: 'Reset to Initial State' (RIS) escape sequence no longer makes the cursor disappear
2018-06-27 07:09:49 -07:00
Daniel Imms e24dca3e29 Send mousemove events when x10Mouse is true 2018-06-26 07:26:14 -07:00
7PH 218a4014c7 #1532: Add test to ensure terminal reset does not display cursor if hidden before 2018-06-26 10:42:08 +02:00
7PH 0ad7b8e27b #1532: Add test to ensure terminal reset does not affect cursorState 2018-06-26 10:36:11 +02:00
7PH f1504e5c0f #1532: Terminal reset does not affect cursorState anymore 2018-06-26 10:33:46 +02:00
Daniel Imms f0d872f7fe Merge pull request #1531 from Tyriar/pin_notepty
Pin node-pty to 0.7.6
2018-06-25 11:38:34 -07:00
Daniel Imms ff18b193eb Pin node-pty to 0.7.6 2018-06-25 11:28:09 -07:00
Daniel Imms 8ae8705ae6 Fix typo 2018-06-25 11:21:00 -07:00
Daniel Imms d585515de1 Move RenderDebouncer and ScreenDprMonitor into ui 2018-06-23 17:34:01 +10:00
Daniel Imms 8dda3e68f8 MOve CharMeasure into ui/ 2018-06-23 17:32:32 +10:00
Daniel Imms 4c7e5d2201 Move CircularList to common (tests in ui/ need) 2018-06-23 17:27:34 +10:00
Daniel Imms cc41fefe31 Move MouseZoneManager into ui/ 2018-06-23 17:25:07 +10:00
Daniel Imms 9a3751d7fb Merge pull request #1522 from 7PH/master
#1521: VT100 escape codes DECSC and DECRC now handle character attributes
2018-06-22 07:36:42 +10:00
PowerHat 64b0a9482c Merge branch 'master' into master 2018-06-21 11:35:01 +02:00
Daniel Imms 221a4353a4 Merge pull request #1524 from Tyriar/tyriar/1523
Make sure DOM renderer doesn't render cells beyond cols
2018-06-21 19:22:39 +10:00
Daniel Imms 989c24cbc3 Merge pull request #1513 from Tyriar/ensure_setting_redraws
Ensure drawBoldTextInBrightColors redraws screen
2018-06-21 19:06:00 +10:00
7PH 654f4bd5ae Merge branch 'master' of https://github.com/7PH/xterm.js 2018-06-21 09:22:41 +02:00
7PH 43ffa957ab #1521: fixed default value of 'Terminal.curAttr' when restoring a not previously saved cursor state 2018-06-21 09:22:17 +02:00
Daniel Imms a9a506f7db Merge branch 'master' into 998_mouse_off 2018-06-21 14:35:09 +10:00
Daniel Imms 6e71fb0fb8 Merge branch 'master' into ensure_setting_redraws 2018-06-21 14:33:42 +10:00
Daniel Imms 4d52cd3c66 Clean reference to custom key event handler on dispose 2018-06-21 14:14:36 +10:00
Daniel Imms 27b1c89f43 More cleaning up of references 2018-06-21 11:48:53 +10:00
Daniel Imms 867ce262e8 Fix test 2018-06-21 11:15:10 +10:00
Daniel Imms 45e4486bf5 Remove on, off, globalOn 2018-06-21 11:10:55 +10:00
Daniel Imms 545d0782c9 Properly register and dispose of majority of remaining listeners 2018-06-21 11:07:29 +10:00
Daniel Imms ede1d5f7c8 Correctly dispose of Renderer and ScreenDprMonitor 2018-06-21 10:49:03 +10:00
Daniel Imms 5adf962eb5 Dispose of attach addon event listeners 2018-06-21 10:39:52 +10:00
Daniel Imms 9293616f02 Add dispose terminal button to demo 2018-06-21 10:32:58 +10:00
Daniel Imms 7e779cd195 Replace _disposables with Disposable, add jsdoc 2018-06-21 10:29:02 +10:00
Daniel Imms dfd17be8bb Introduce Disposable abstract class 2018-06-21 10:24:37 +10:00
Daniel Imms a44f496ec7 Rename dom listener function for better clarity 2018-06-21 10:05:40 +10:00
Daniel Imms c0f4a8eb7c Move Dom listener helper to ui/
Part of #1518
2018-06-21 10:03:53 +10:00
Daniel Imms 086b2c04e0 Make sure DOM renderer doesn't render cells beyond cols
Fixes #1523
2018-06-20 23:02:05 +10:00
PowerHat 4809b04f26 Merge branch 'master' into master 2018-06-20 14:51:52 +02:00
7PH 4fecf05dab #1521: added unit tests for saving & restoring cursor attributes 2018-06-20 14:31:12 +02:00
7PH 285b0b6702 #1521: added 'savedCurAttr' attribute to 'MockInputHandlingTerminal' class 2018-06-20 14:23:05 +02:00
Benjamin Raymond a1b8f96d50 #1521: added default behavior of 'ESC 8' escape sequence (DECRC) when cursor state was never saved before using 'ESC 7' (DECSC) 2018-06-20 14:04:13 +02:00
Benjamin Raymond c345dba591 #1521: added 'savedCurAttr' property in 'Terminal' class which holds the saved state of the character attributes ('ESC 7' escape sequence code) 2018-06-20 13:58:53 +02:00
Benjamin Raymond 8dcb4698d3 #1521: now saving and restoring characters attributes when using ANSI escape sequences 'ESC 7' (DECSC) and 'ESC 8' (DECRC) 2018-06-20 13:57:42 +02:00
Daniel Imms f9bc3c511b Merge pull request #1508 from Tyriar/layering
Start of improved layering
2018-06-20 21:35:51 +10:00
Daniel Imms 0d0f4b048c Merge branch 'master' into layering 2018-06-20 21:25:58 +10:00
Daniel Imms 91cf9e1ba8 Move .strings to public/ 2018-06-20 19:46:04 +10:00
Daniel Imms 5d05c3a5f3 Merge pull request #1517 from JonKohler/patch-1
Sort asending for companies in readme and add Nutanix
2018-06-20 07:40:13 +10:00
Jon Kohler 628e648b57 Update README.md
Update readme and add note for future adders to append to the bottom of list
2018-06-18 22:28:25 -04:00
Jon Kohler 72bb1b030a Sort asending for companies in readme and add Nutanix
Sorted the company list in the readme asending and added Nutanix to the list of users
2018-06-18 10:05:40 -04:00
Daniel Imms 6c6d90a698 Merge branch 'master' into layering 2018-06-13 12:52:43 +02:00
Daniel Imms 356959e338 Merge pull request #1512 from Tyriar/1511_npe_beginFrame
Add a null check to charatlas beginFrame call
2018-06-12 18:02:21 +02:00
Daniel Imms 6c3b6b4655 Ensure drawBoldTextInBrightColors redraws screen 2018-06-12 17:54:26 +02:00
Daniel Imms ee935cc68c Add a null check to charatlas beginFrame call
Fixes #1511
2018-06-12 17:27:36 +02:00
Daniel Imms 57959249d8 Resolve todos 2018-06-12 17:17:21 +02:00
Daniel Imms bb4db71958 Rename base/ to common/ 2018-06-12 17:07:43 +02:00
Daniel Imms 8c3376911f Fix winptyCompat compile 2018-06-12 17:05:13 +02:00
Daniel Imms 1487b8d02d Merge pull request #1510 from FGasper/cpanel_whm_real_world
Add cPanel & WHM to the Real-World Uses list.
2018-06-12 10:25:10 +02:00
Felipe Gasper 3705d8159d Add cPanel & WHM to the Real-World Uses list. 2018-06-11 16:51:07 -04:00
Daniel Imms 6a3ed43ad2 Move EscapeSequences into base 2018-06-10 16:56:29 +01:00
Daniel Imms 12e7f80037 Move Charsets to core 2018-06-10 16:53:28 +01:00
Daniel Imms 410d506f34 Fix applyAddon test 2018-06-10 16:44:50 +01:00
Daniel Imms d29a527724 Introduce the public module 2018-06-10 16:40:36 +01:00
Daniel Imms 20307ef637 Add tests for mobile key events 2018-06-10 12:43:22 +02:00
Daniel Imms 95217ca931 Remove core/input/Keyboard's dep on Terminal 2018-06-10 12:33:50 +02:00
Daniel Imms b4ccbe042b Pull keyboard event translation into core 2018-06-10 11:52:25 +02:00
Daniel Imms e167686b6d Remove conversion step, KeyboardEvent implements IKeyboardEvent 2018-06-10 11:45:50 +02:00
Daniel Imms b6481f120b Introduce IKeyEvent 2018-06-10 11:03:37 +02:00
Daniel Imms fb63b3475b Merge pull request #1501 from Tyriar/issue_template
Add more granular github issue templates
2018-06-09 17:02:36 +02:00
Daniel Imms 2f1c1cd172 Remove old issue template 2018-06-09 17:01:37 +02:00
Daniel Imms 03e31571a9 Merge pull request #1497 from xtermjs/Tyriar-patch-1
Fix copyright line breaks
2018-06-09 17:00:24 +02:00
Daniel Imms c6370ba0cf Merge pull request #1472 from Tyriar/fix_tsconfig
Fix valid lib values in tsconfig
2018-06-09 17:00:05 +02:00
Daniel Imms 432c2cc369 Nullify and remove mouse handlers when mouse move it exited
Fixes #998
2018-06-08 17:36:04 +02:00
Daniel Imms 3637b83bbb Add more granular github issue templates 2018-06-08 09:04:37 +02:00
Daniel Imms ddc9466916 Merge pull request #1500 from Tyriar/coc
Add a code of conduct
2018-06-08 08:55:21 +02:00
Daniel Imms df9d20bfdc Add a code of conduct 2018-06-08 08:54:29 +02:00
Daniel Imms e9af4d0e80 Fix copyright line breaks 2018-06-07 09:22:14 +02:00
Daniel Imms f38a34c6da Merge pull request #1495 from nikonso/passive-events
Explicitly  mark Event Listeners as not passive
2018-06-06 10:04:39 +02:00
Daniel Imms 41b5fd8ddf Merge branch 'master' into passive-events 2018-06-06 09:57:42 +02:00
Daniel Imms 22ef5661eb Merge pull request #1388 from Tyriar/script_improvements
Improved test related npm scripts
2018-06-06 09:23:20 +02:00
Daniel Imms 4e2c30c81d Pin @types/jsdom 2018-06-06 09:09:40 +02:00
Bruno Ribeito 8f91e3bcde Fix #829 2018-06-06 08:02:26 +01:00
Daniel Imms 5aff7c2c1e Update @types/jsdom 2018-06-06 08:47:08 +02:00
Daniel Imms b4bb433c1b Add coveralls 2018-06-06 07:44:09 +02:00
Daniel Imms c405b58456 Merge branch 'master' into script_improvements 2018-06-06 05:45:16 +02:00
Daniel Imms 445689c679 Merge pull request #1494 from svenstaro/patch-1
Add genact
2018-06-06 04:23:48 +02:00
Sven-Hendrik Haase 1c0d7771d7 Add genact
genact uses xterm.js!
2018-06-05 20:58:39 +02:00
Daniel Imms a8964a15dd Merge pull request #1491 from pro-src/master
Fix typo in README.md
2018-06-05 08:36:42 +02:00
pro-src bdfdcf3508 Fix typo in README.md 2018-06-04 14:39:47 -05:00
Daniel Imms 0276ab4f85 Merge pull request #1489 from nikonso/master
Fix npm start on windows
2018-06-03 19:10:16 -07:00
Daniel Imms f83394b0ab Merge pull request #1490 from nikonso/fix-demo-string-options
Fix Demo String Options
2018-06-03 19:09:23 -07:00
Bruno Ribeito 13d5ad6506 Fix Demo String Options 2018-06-03 19:53:51 +01:00
Bruno Ribeito 7751933c8c Fix npm start on windows 2018-06-03 19:37:49 +01:00
Daniel Imms 42d7d3aefc Merge pull request #1488 from Tyriar/all_options
Add all options to demo in a way that makes it easy to maintain
2018-06-03 07:51:14 -07:00
Daniel Imms 0f488e59d7 Merge branch 'master' into all_options 2018-06-03 07:43:27 -07:00
Daniel Imms 1066816142 Merge pull request #1474 from Tyriar/1473_slow_build
Use incremental tsc builds
2018-06-03 07:42:27 -07:00
Daniel Imms 6e3c16a2c2 Merge branch 'master' into 1473_slow_build 2018-06-03 07:39:19 -07:00
Daniel Imms 3d56b152f3 Merge pull request #1421 from Tyriar/more_naming_conventions
Add remaining naming conventions into tslint
2018-06-03 07:39:03 -07:00
Daniel Imms 24fad1126c Add missing renames 2018-06-03 16:34:12 +02:00
Daniel Imms 53463681de Fix lint 2018-06-03 16:25:32 +02:00
Daniel Imms 2aff2eb710 Merge branch 'master' into more_naming_conventions 2018-06-03 07:23:14 -07:00
Daniel Imms c748b02111 Add rendererType 2018-06-03 16:21:23 +02:00
Daniel Imms 73e35b9293 Merge branch 'master' into all_options 2018-06-03 07:19:51 -07:00
Daniel Imms 1cccec6398 Merge pull request #1432 from Tyriar/1360_dom_renderer
Implement a fallback DOM renderer
2018-06-03 07:19:33 -07:00
Daniel Imms 1ca6e51564 Fix lint 2018-06-03 16:06:45 +02:00
Daniel Imms 52be55852e Merge branch 'master' into 1360_dom_renderer 2018-06-03 06:58:08 -07:00
Daniel Imms 824a03e0af Merge branch 'master' into 1473_slow_build 2018-06-03 06:43:42 -07:00
Daniel Imms 3c02c9ce66 Merge pull request #1457 from Tyriar/vsts
Add VSTS build badge
2018-06-03 06:41:50 -07:00
Daniel Imms adb0cf41ab Improve display of options 2018-06-03 15:37:01 +02:00
Daniel Imms de683b35b2 Merge pull request #1485 from Tyriar/664_fit_readme
Add basic fit readme
2018-06-03 06:13:30 -07:00
Daniel Imms 767e3570ac Merge pull request #1486 from Tyriar/1456_triple_click_wrapped
Select entire wrapped line on triple click
2018-06-03 06:10:22 -07:00
Daniel Imms 75a45808c3 Merge branch 'master' into 1456_triple_click_wrapped 2018-06-03 06:04:41 -07:00
Daniel Imms 7ca6873a5e Merge pull request #1487 from Tyriar/no_implicit_any
Enable noImplicitAny compiler option
2018-06-03 06:03:37 -07:00
Daniel Imms 908b06cfa7 Some polish 2018-06-03 11:18:34 +01:00
Daniel Imms 2d786910c8 Correctly set cols/rows 2018-06-03 11:10:11 +01:00
Daniel Imms 5b04451b05 console error on setting ctor only option via setOption 2018-06-03 11:02:39 +01:00
Daniel Imms 4d5e305a25 Generate inputs for all options in demo 2018-06-03 10:37:20 +01:00
Daniel Imms 4dff828374 Add @types/glob 2018-06-03 07:15:45 +01:00
Daniel Imms fea8ba03b8 Finish removing all implicit anys 2018-06-02 19:02:54 -07:00
Daniel Imms 918ee16f86 Don't set options on terminaol object itself 2018-06-02 18:47:04 -07:00
Daniel Imms b79ab7212c Remove a bunch of implicit anys 2018-06-02 18:39:05 -07:00
Daniel Imms 956b773421 Add more tests, fix boundary bug 2018-06-02 18:07:49 -07:00
Daniel Imms cd3418517e Select the whole wrapped line when triple clicking
Fixes #1456
2018-06-02 17:56:44 -07:00
Daniel Imms 285911cd98 Implement IBuffer.getWrappedRangeForLine
Part of #1456
2018-06-02 17:53:35 -07:00
Daniel Imms 5acc45f08b Add basic fit readme
Fixes #664
2018-06-02 12:22:05 -07:00
Jeff Principe eabb25c796 add ability to register/deregister character joiner 2018-06-02 10:24:52 -07:00
Daniel Imms c192a27d93 Merge pull request #1483 from AndrienkoAleksandr/littleFix
Minor: clean up build logs for source code without tests.
2018-06-01 09:12:05 -07:00
Daniel Imms d5af79fc5f Include typings in addons as well 2018-06-01 08:55:22 -07:00
Oleksandr Andriienko 90b9a487cd Minor: clean up build logs for source code without tests.
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
2018-06-01 13:41:35 +03:00
Daniel Imms 4617bab3a0 Merge pull request #1477 from lgeiger/let-const
Prefer const vs let for variables that are only declared once
2018-05-30 11:31:24 -07:00
Lukas Geiger 8989a09853 Prefer const vs let for variables that are only declared once
Requires that variable declarations use `const` instead of `let` and `var` if possible.

This is mostly for code readability, performance wins are debatable.
2018-05-30 19:47:28 +02:00
Daniel Imms 4a4a17966a Merge pull request #1475 from cathy-zhao/master
add a project to real-world uses list
2018-05-29 06:24:24 -07:00
赵雪珂 7db0b181bc add a project to real-world uses list 2018-05-29 13:03:48 +08:00
Daniel Imms 3ce71b7f8f Add css copy tasks 2018-05-28 05:49:47 -07:00
Daniel Imms c2568a6857 Fix Windows build 2018-05-28 05:44:15 -07:00
Daniel Imms 834b266b7f Move demo build into npm start 2018-05-27 07:59:44 -07:00
Daniel Imms 5d9b761f33 Merge branch 'master' into 1473_slow_build 2018-05-27 07:57:48 -07:00
Daniel Imms 35fc10b0e6 Kill watch/prebuild tasks when one fails 2018-05-27 07:42:34 -07:00
Daniel Imms ffd7d5513b Rebuild demo when demo files change 2018-05-27 07:38:04 -07:00
Daniel Imms 656567aed0 Use incremental tsc builds 2018-05-27 07:30:37 -07:00
Daniel Imms 82fdcc0771 Get DomRendererRowFactory test coverage to 100% 2018-05-26 08:43:55 -07:00
Daniel Imms c2b5a243f2 Refactor and add some tests to dom renderer 2018-05-26 08:15:40 -07:00
Daniel Imms 6e9cd35176 Remove coverage files from git 2018-05-26 07:34:32 -07:00
Daniel Imms 9890a8b20f Fix valid lib values in tsconfig
Mixed case is not valid
2018-05-26 07:32:46 -07:00
Daniel Imms 20975278c5 Merge remote-tracking branch 'ups/master' into 1360_dom_renderer 2018-05-26 07:25:08 -07:00
Daniel Imms b43ee08dd2 Merge pull request #1469 from tmpfs/safari-create-image-bitmap-patch
Suppress Safari promise rejections.
2018-05-23 20:28:06 -07:00
muji 3ae96a2266 Improve isSafari test. 2018-05-24 10:18:43 +08:00
muji 87fee8d024 Suppress Safari promise rejections.
Currently Webkit implements createImageBitmap() but returns a promise
rejection.

Note that once Webkit implements createImageBitmap() correctly these
changes should be removed.
2018-05-24 10:11:03 +08:00
Daniel Imms 09e42af730 Merge pull request #1466 from jerch/cleanup_print
cleanup and performance optimizations for InputHandler.print
2018-05-22 06:45:11 -07:00
Daniel Imms 44fde26f04 Remove types when they're inferred 2018-05-22 06:44:50 -07:00
Jörg Breitbart ac9b71549a add missing type decl 2018-05-21 22:39:00 +02:00
Jörg Breitbart 328086f206 declare types in InputHandler.print 2018-05-21 22:29:05 +02:00
Jörg Breitbart b3e8197111 changes in InputHandler.print:
- call updateRange only at start and end
- make all repeated terminal accesses local
- set full charCode (codepoint) in terminal buffer
2018-05-21 20:58:23 +02:00
Daniel Imms 099c7d8f04 Merge pull request #1399 from jerch/new_parser
new parser
2018-05-21 10:48:03 -07:00
Daniel Imms 507c4dc5d2 Use nyc for coverage report
Fixes #1464
2018-05-21 10:42:28 -07:00
Daniel Imms 6bc6ea56a5 Merge branch 'master' into new_parser 2018-05-21 10:04:15 -07:00
Jörg Breitbart e97882e5ad use string templates in DCS responses 2018-05-21 18:52:27 +02:00
Daniel Imms 85dada2eed Merge remote-tracking branch 'origin/master' into 1360_dom_renderer 2018-05-21 09:41:21 -07:00
Jörg Breitbart 8386ec1c19 Merge branch 'new_parser' of https://github.com/jerch/xterm.js into new_parser 2018-05-21 18:34:51 +02:00
Jörg Breitbart ceb1432f75 remove deprecated FIXME 2018-05-21 18:33:59 +02:00
Daniel Imms 8d722d20e2 Merge pull request #1463 from Tyriar/1424_fix_static_cache_ghost
Save and restore correctly when drawing from static cache
2018-05-21 09:21:58 -07:00
Daniel Imms 054abd15ea Save and restore correctly when drawing from static cache
Fixes #1424
2018-05-21 09:11:41 -07:00
Daniel Imms 724aa9d6c7 Fix compile and lint 2018-05-21 08:17:07 -07:00
Daniel Imms ab5fc98627 Merge branch 'master' into more_naming_conventions 2018-05-21 08:06:52 -07:00
Daniel Imms 0dfc9b2118 Merge branch 'master' into vsts 2018-05-21 07:54:50 -07:00
Daniel Imms 8bbc1fa287 Merge branch 'master' into script_improvements 2018-05-21 07:54:07 -07:00
Daniel Imms c1f8225c4f Merge branch 'master' into new_parser 2018-05-21 07:30:35 -07:00
Paris Kasidiaris 0ad1080133 Bump version to 3.4.0
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2018-05-19 08:31:27 +00:00
Daniel Imms 1736c1e12d Prevent outside line-height styles from affecting cursor
See Microsoft/vscode#50125
2018-05-18 12:17:39 -07:00
Benjamin Woodruff 4717619f76 Merge pull request #1327 from bgw/dynamic-char-atlas
Modularize the character atlas system, add a LRU-cache based dynamic character atlas
2018-05-17 22:59:03 -07:00
Benjamin Woodruff 7f761b5b9e Merge branch 'master' into dynamic-char-atlas
I did a bunch of testing of various ansi escape codes (including
italics) with all three char atlas implementations (none, static,
dynamic), with and without `drawBoldTextInBrightColors`, and with and
without `enableBold` to test all of the edge cases that I could.
2018-05-17 22:42:52 -07:00
Daniel Imms c00a3726f3 Merge branch 'master' into vsts 2018-05-16 13:46:06 -07:00
Daniel Imms 5ef399df6f Add VSTS build badge 2018-05-16 13:44:46 -07:00
Daniel Imms f8e9d02566 Merge branch 'master' into more_naming_conventions 2018-05-16 09:45:42 -07:00
Daniel Imms d8afdb1b6b Merge branch 'master' into new_parser 2018-05-15 13:21:33 -07:00
Daniel Imms 2b4c5adb3c Set font family and size 2018-05-15 11:29:51 -07:00
Daniel Imms 7334e6ab19 Merge pull request #1452 from Tyriar/coveralls
Update coveralls
2018-05-15 11:03:22 -07:00
Daniel Imms 137b499538 Merge pull request #1450 from Tyriar/tagline
Update tagline
2018-05-15 11:03:08 -07:00
Daniel Imms 6024e7c5fe Size row container so scroll bar shows 2018-05-15 10:52:01 -07:00
Daniel Imms aa1e1c5d94 Scope styles per terminal 2018-05-15 10:18:43 -07:00
Daniel Imms f055e0ef03 Throw exception for unrecognized renderer type 2018-05-15 10:10:34 -07:00
Daniel Imms 2f618b37c1 Merge branch 'master' into 1360_dom_renderer 2018-05-15 10:08:09 -07:00
Daniel Imms 3acd1eaecc Update coveralls
This broke after we moved the organization

Fixes #1451
2018-05-14 11:48:13 -07:00
Daniel Imms 435cf91ec7 Merge pull request #1433 from Tyriar/fix_lint
Run tslint on all of src/ (for good this time)
2018-05-14 11:33:30 -07:00
Daniel Imms 6e451f58b8 Update tagline 2018-05-14 11:13:01 -07:00
Daniel Imms 7a9f291df9 Merge pull request #1446 from Tyriar/1437_fix_link_pointer
Fix link cursor CSS
2018-05-12 07:45:20 -07:00
Daniel Imms 9dfce63e55 Simplify cursor styles 2018-05-12 07:44:30 -07:00
Daniel Imms 139a246436 Merge pull request #1401 from npezza93/alt-click-map-bug
Handle if getCoords returns null in the AltClickHandler
2018-05-11 15:56:14 -07:00
Daniel Imms 343cc2b7b2 Merge branch 'master' into alt-click-map-bug 2018-05-11 15:50:40 -07:00
Daniel Imms 0375e0064b Fix link cursor CSS
Ensure pointer overrides the default mouse events mode cursor.

Fixes #1437
2018-05-11 10:03:43 -07:00
Daniel Imms 57e35f836e Merge pull request #1438 from diag/master
Add diag.ai to list of real-world uses
2018-05-11 09:16:30 -07:00
Daniel Imms 685757b04b Merge pull request #1417 from pro-src/packaging
Stop publishing test files to npm - closes #1361
2018-05-11 07:51:46 -07:00
Daniel Imms 210a312fbf Remove ignore key from package.json 2018-05-11 07:49:37 -07:00
Daniel Imms c366ee20b8 Merge branch 'master' into packaging 2018-05-11 07:48:34 -07:00
Daniel Imms b9baacac3a Merge pull request #1444 from pengx17/patch-1
Update how to use addons with Typescript
2018-05-11 07:20:17 -07:00
Peng Xiao 45fea0e790 Merge branch 'master' into patch-1 2018-05-11 21:57:40 +08:00
Benjamin Woodruff cded6f80f6 Merge pull request #1445 from pro-src/master
Fix tsc
2018-05-10 23:57:24 -07:00
pro-src 9c1bee300d Fix tsc 2018-05-11 01:51:49 -05:00
Peng Xiao ef4cda2cc6 revise importing addons in ts 2018-05-11 11:20:02 +08:00
Peng Xiao d315dd6684 Merge branch 'master' into patch-1 2018-05-11 11:12:02 +08:00
Benjamin Woodruff 8a5891ede2 Merge pull request #1442 from bgw/dim-save-restore
Save and restore the ctx for cached characters
2018-05-10 09:38:46 -07:00
Peng Xiao bce81f304e Update how to use addons with Typescript 2018-05-10 16:11:25 +08:00
Benjamin Woodruff 3971fc9b4e Save and restore the ctx for cached characters
Drawing dim colors sets the globalAlpha to 0.5, so we need to
save/restore the ctx state. Otherwise, every time we draw some dim
content, our display will get progressively dimmer.

I tested this by running `echo '\u001b[2mfoo'` a few times in zsh.

Fixes #1424
2018-05-09 20:34:55 -07:00
npezza93 4edbd507e5 Check if endCol and endRow are present before handling an alt click 2018-05-09 19:35:02 -04:00
npezza93 b162582e66 Handle if getCoords returns null in the AltClickHandler
Fixes #1397
2018-05-09 19:31:19 -04:00
Benjamin Woodruff be32695e16 Merge pull request #1391 from LinusU/bright-vs-bold
Separate bright and bold
2018-05-08 18:43:41 -07:00
Benjamin Woodruff 9893338020 Add drawBoldTextInBrightColors to DEFAULT_OPTIONS
This lets term.setOption() work for drawBoldTextInBrightColors.
2018-05-08 18:34:23 -07:00
Ledion Bitincka cfdec9ff90 add diag.ai 2018-05-08 16:27:54 -07:00
Jörg Breitbart 02893dcbb8 fix some docs 2018-05-07 23:28:40 +02:00
Linus Unnebäck ce6139e604 Add drawBoldTextInBrightColors option 2018-05-07 22:23:04 +02:00
Linus Unnebäck a23354f018 Fully use char atlas for bright & bold colors 2018-05-07 22:23:01 +02:00
Linus Unnebäck 41fd563144 Separate bright and bold 2018-05-07 22:19:01 +02:00
Jörg Breitbart a37449a8cd some docs cleanup 2018-05-06 23:33:52 +02:00
Jörg Breitbart 551ccc0f2f explicit arguments for fallback handlers 2018-05-06 23:02:54 +02:00
Jörg Breitbart 108aa5ab31 test Uint8Array and Array; fix Uint8Array type 2018-05-06 22:42:07 +02:00
Daniel Imms 362d7698f7 Some polish 2018-05-05 08:12:52 -07:00
Daniel Imms edb06c6b2a Add copyright header 2018-05-05 07:54:38 -07:00
Jörg Breitbart 6cefb4c634 more test cases 2018-05-05 16:26:07 +02:00
Daniel Imms cd3eea5b48 Improve typings 2018-05-04 11:34:24 -07:00
Daniel Imms 5b5eb48867 Polish 2018-05-04 10:55:41 -07:00
Daniel Imms 09624c18e0 Move standard width to style element 2018-05-04 10:43:54 -07:00
Daniel Imms 9bcecd4e2e Run tslint on all of source (for good this time) 2018-05-04 10:20:09 -07:00
Daniel Imms 52e71a2530 Support italic 2018-05-04 10:13:21 -07:00
Daniel Imms 6cadd7c4a8 Fill in documentation on new option 2018-05-04 10:02:01 -07:00
Daniel Imms b14308f2c4 Resolve a bunch of TODOs 2018-05-04 09:38:24 -07:00
Daniel Imms 2c3949375e Update after a options change 2018-05-04 08:37:41 -07:00
Daniel Imms e3e4dcb5d1 Support selection 2018-05-04 08:32:03 -07:00
Daniel Imms e9f4d39f2b Start on selection 2018-05-04 06:27:40 -07:00
Daniel Imms d777513b87 Handle focus, emit refresh 2018-05-03 11:58:46 -07:00
Daniel Imms 1d2f356cfd Add a bunch of constants 2018-05-03 11:44:46 -07:00
Daniel Imms 418f2c6cdf Fix row height, add cursor 2018-05-03 11:35:04 -07:00
Daniel Imms 3cab8bede1 Merge branch 'oncharsizechanged' into 1360_dom_renderer 2018-05-02 15:05:42 -07:00
Daniel Imms 58ce5e2110 Only update dimensions when char size changes 2018-05-02 15:05:37 -07:00
Daniel Imms 20ff107768 Call IRenderer.onCharSizeChanged at right time
Even though Renderer just defers this to onResize, future IRenderer
implementations may take advantage of onCharSizeChanged specifically.
2018-05-02 15:00:42 -07:00
Daniel Imms 16393b228d Initial DOM renderer implementation 2018-05-02 13:32:22 -07:00
Jörg Breitbart 0f8d22547e fix identation 2018-05-02 01:23:46 +02:00
Jörg Breitbart c069e94a4c Merge branch 'master' into new_parser 2018-05-02 00:42:23 +02:00
Jörg Breitbart a1a4cac113 dcs handler implementations 2018-05-02 00:22:35 +02:00
Jörg Breitbart 25ff77af03 fix transition definitions 2018-05-01 22:22:40 +02:00
Jörg Breitbart 536b3a8def fix member scope and tests 2018-05-01 22:17:26 +02:00
Jörg Breitbart d090cbe4b9 some docs 2018-05-01 21:54:15 +02:00
Jörg Breitbart 9a32852e61 single arg for DCS and ESC handler registration 2018-05-01 21:07:13 +02:00
Daniel Imms e48b15e859 Merge pull request #1422 from flybayer/italic
Add support for italic rendering
2018-05-01 11:56:21 -07:00
Jörg Breitbart 89cf45c514 save func pointer in local var 2018-05-01 20:51:36 +02:00
Daniel Imms a732952677 Rearrange italic/bold to get _ctx.font validating 2018-05-01 11:50:06 -07:00
Jörg Breitbart 0c200f2feb remove collect from args where not needed 2018-05-01 20:41:41 +02:00
Jörg Breitbart 728eeebcc7 set member through ctor argument 2018-05-01 20:33:48 +02:00
Daniel Imms b60ab119b2 Merge branch 'master' into italic 2018-05-01 11:30:03 -07:00
Jörg Breitbart c7fdff2f40 several changes:
- missing escape sequence related methods in InputHandler implemented
- created namespace for C1 control codes
2018-05-01 17:50:41 +02:00
Jörg Breitbart 2eeb7b8ea5 ESC and OSC method entries for InputHandler 2018-05-01 16:36:12 +02:00
Jörg Breitbart 0535f5d1b3 unified method signature in InputHandler, moved some CSI condition into methods (FIXME: needs intermediate handler) 2018-05-01 14:58:16 +02:00
Jörg Breitbart aeae688b4c multiple changes in InputHandler:
- remove prefix/postfix
- optional collect arg where needed
- tempPrefix handler removed
- replaced .bind with () => notation
- moved callback registering to ctor again
2018-05-01 14:32:08 +02:00
Jörg Breitbart af392a6305 cleanup, some docs, temp fix for InputHandler tests 2018-04-30 23:35:54 +02:00
Jörg Breitbart ba6fcddc43 real merge of InputHandler and ParserTerminal 2018-04-30 17:04:29 +02:00
Jörg Breitbart dbc6b12ec2 missing whitespace 2018-04-30 15:44:21 +02:00
Jörg Breitbart 645cd2eb2c fix test cases 2018-04-30 15:38:17 +02:00
Jörg Breitbart b158176862 local .buffer in parse 2018-04-30 14:25:29 +02:00
Jörg Breitbart a1035269d5 add array fallback for TransitionTable 2018-04-30 11:27:10 +02:00
Jörg Breitbart f5375c3a99 fix error in esc handler call 2018-04-30 02:06:57 +02:00
Jörg Breitbart a55a7f3695 some cleanup 2018-04-30 01:49:29 +02:00
Jörg Breitbart 826cca7088 fix import issue 2018-04-30 01:32:49 +02:00
Jörg Breitbart 0f3d82a2a5 faster print action 2018-04-29 23:48:30 +02:00
Jörg Breitbart dc14f5226d fix InputHandler 2018-04-29 19:34:43 +02:00
Jörg Breitbart 27a3347c3f Merge branch 'master' into new_parser 2018-04-29 19:30:35 +02:00
Jörg Breitbart 2d77fcf2fb merge ParserTerminal with InputHandler
- quick'n dirty merge of classes - ParserTerminal is subclass of InputHandler
- basic fallback handlers implemented
- test regressions due to multiple changes in EscapeSequenceParser
- runtime down to 2.3s
- TODO: fix tests, implement DCS functions, full merge of classes
2018-04-29 19:10:47 +02:00
Jörg Breitbart 9d2bbd199c remove term from EscapeSequenceParser 2018-04-29 17:23:38 +02:00
Jörg Breitbart b72cdadd11 move switches to jump tables 2018-04-29 15:48:19 +02:00
Benjamin Woodruff 381d3e1444 Merge pull request #1413 from bgw/batch-background
Batch background draws together to reduce draws
2018-04-27 20:53:32 -07:00
Benjamin Woodruff b97eaf2c52 Merge branch 'master' into batch-background 2018-04-27 20:49:03 -07:00
Benjamin Woodruff 513847fd80 Make BaseRenderLayer's _alpha private again
This was accidentally left over from some earlier changes I was playing
with.
2018-04-27 20:47:55 -07:00
Daniel Imms 7b2500bfd6 Merge pull request #1420 from pro-src/patch-1
Update README.md
2018-04-27 09:44:47 -07:00
pro-src 882d5a86d3 Update README.md - prefer hex escapes over octal 2018-04-27 02:19:48 -05:00
Brandon Bayer 235982362c Add support for italic rendering 2018-04-26 17:34:01 -04:00
Daniel Imms aaaec75d73 Add remaining naming conventions into tslint 2018-04-26 13:54:20 -07:00
pro-src 30b88113a8 explicitly exclude demo 2018-04-26 12:09:21 -05:00
pro-src 994895af6d Update README.md
Replace the deprecated octal escapes with Unicode escapes.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal
2018-04-26 11:53:20 -05:00
pro-src a61ba2e140 closes #1361 2018-04-26 09:18:18 -05:00
Benjamin Woodruff a5a03c40f2 Batch background draws together to reduce draws
Adjacent cells on the same row sharing the same background color will be
drawn using the same `fillCells` call. This should make drawing an
application with a solid or mostly solid background color (e.g. vim)
faster.

I set vim to draw the background color for a file, and started scrolling
through it. Before, _drawBackground was taking around 6ms per frame.
After this commit, it was taking around 0.5ms per frame.

Based on prior experience, I'd expect these results to be more drastic
for larger terminal windows. The demo's window is pretty small.
2018-04-24 23:52:13 -07:00
Daniel Imms 83fe87d012 Merge pull request #1407 from Tyriar/enum_names
Enforce upper case for public const/enum members and const
2018-04-24 11:00:58 -07:00
Daniel Imms 3713d282d8 Fix conflicts 2018-04-24 10:55:53 -07:00
Daniel Imms 8aa65d06f5 Merge pull request #1404 from Tyriar/no_else_return
Add no else return tslint rule
2018-04-24 10:50:27 -07:00
Daniel Imms fd97fead60 Merge branch 'master' into no_else_return 2018-04-24 10:44:54 -07:00
Jörg Breitbart 9eb107a6e9 first handler API changes 2018-04-24 18:53:19 +02:00
Jörg Breitbart c0ab2b9a7c rename enums 2018-04-24 13:06:03 +02:00
Jörg Breitbart a058395014 move addChar to ParserTerminal 2018-04-24 12:27:43 +02:00
Benjamin Woodruff 453da35f51 Merge branch 'master' into dynamic-char-atlas 2018-04-23 22:43:43 -07:00
Benjamin Woodruff d254d69ee2 Fix fontWeight options with DynamicCharAtlas
The atlas wasn't using these values when setting the font.
2018-04-23 22:15:45 -07:00
Benjamin Woodruff ff19ba8e33 Merge pull request #1393 from bgw/text-render-layer
Separate foreground & background rendering passes
2018-04-23 21:48:09 -07:00
Daniel Imms fcde7be62a Enforce const enums
Fixes #1408
2018-04-23 17:35:41 -07:00
Daniel Imms 45b4429712 Merge branch 'master' into enum_names 2018-04-23 17:18:40 -07:00
Daniel Imms 9942dc384d Enforce upper case for public const/enum members
Fixes #1406
2018-04-23 17:17:21 -07:00
Jörg Breitbart 55993ada9b merge with remote 2018-04-24 00:35:55 +02:00
Jörg Breitbart c8910cc5fe utilize more typescript features 2018-04-24 00:23:46 +02:00
Jörg Breitbart f9767073ba new parser 2018-04-24 00:21:27 +02:00
Daniel Imms 56f9d423fe Merge branch 'master' into text-render-layer 2018-04-23 14:15:45 -07:00
Daniel Imms 716a8d5926 Merge pull request #1403 from jerch/performance_optimizations
performance optimizations
2018-04-23 13:49:03 -07:00
Jörg Breitbart 9593cb0cc8 readonly lines; fix for MockBuffer 2018-04-23 22:40:24 +02:00
Jörg Breitbart 7ed7505ce4 change _lines to lines in Buffer 2018-04-23 22:18:05 +02:00
Jörg Breitbart 6ff4ae7194 revert to local const buffer 2018-04-23 22:06:24 +02:00
Daniel Imms 9e863d0377 Add no else return tslint rule 2018-04-23 11:52:42 -07:00
Jörg Breitbart 13d4ab6f8d remove remnant 2018-04-23 18:32:32 +02:00
Jörg Breitbart 0d7ecd9129 prefetch row in addChar 2018-04-23 18:26:06 +02:00
Jörg Breitbart dd096c2e8b const buffer 2018-04-23 17:19:42 +02:00
Jörg Breitbart 0decd77253 map Buffer.lines directly to Buffer._lines 2018-04-23 16:59:55 +02:00
Jörg Breitbart 2bfe74490a make .buffer local where appropriate 2018-04-23 16:29:19 +02:00
Jörg Breitbart 20760d09e4 utilize more typescript features 2018-04-22 04:34:42 +02:00
Jörg Breitbart 73f40ef7d2 merge with master 2018-04-21 16:04:17 +02:00
Jörg Breitbart 9b085d2bdd new parser 2018-04-21 16:02:46 +02:00
Jörg Breitbart fb7e5d590c new parser 2018-04-21 05:12:24 +02:00
Benjamin Woodruff 0fe59df2e9 Rename startRow/endRow in TextRenderLayer
Renaming these to firstRow/lastRow makes the inclusivity of the range
clearer.

Addresses this comment:
https://github.com/xtermjs/xterm.js/pull/1393#discussion_r182471582
2018-04-18 20:22:55 -07:00
Daniel Imms a3ce881897 Merge pull request #1372 from Tyriar/1341_memory_leak
Remove terminal references on dispose
2018-04-18 08:10:20 -07:00
Daniel Imms 58c50f08db Break when the terminal reference is removed 2018-04-18 08:10:05 -07:00
Daniel Imms 984e027c87 Merge branch 'master' into 1341_memory_leak 2018-04-18 08:02:55 -07:00
Benjamin Woodruff b853aa4929 Separate foreground & background rendering passes
I'm primarily interested in doing this because it'll allow me to
optimize the background rendering in later diffs, but this may also make
it possible to fix some minor rendering issues.

Right now, if we draw a single-width character that overflows its cell's
bounds, and the character to the right of it has a background, that
background may cover up the first character's foreground. By drawing the
background in a separate pass, we can avoid those cases.

There's still some issues with how dirty regions are computed that makes
rendering stuff like that flaky, but this at least gets us closer to
"correct" rendering.

Other terminal emulators (e.g. alacritty) render the foreground and
background in separate passes:
https://github.com/jwilm/alacritty/blob/1b7ffea/src/renderer/mod.rs#L766
2018-04-17 21:44:17 -07:00
Benjamin Woodruff 4fd630ec5c Add code to IGlyphIdentifer, use it
It turns out that `glyph.char.charCodeAt(0)` isn't equivalent to the
character's actual code because of utf-16 garbage, so this adds
`glyph.code` to the `glyph` object so that we can use the `code` value,
and don't need to regenerate it.
2018-04-16 09:49:32 -07:00
Benjamin Woodruff ec96c40fde Re-add colors.ansi slicing in generateConfig
- We need to make a clone of this array, because ColorManager mutates
  it.
- We only want to compare the first 16 colors instead of all 256, since
  only the first 16 will ever change. In DynamicCharAtlas, we can pull
  the additional colors from DEFAULT_ANSI_COLORS.

I tested this out by loading the demo and changing the theme a few
times.
2018-04-16 09:41:00 -07:00
Daniel Imms cf8fa10205 Merge pull request #1299 from jonaustin/patch-1
Add Hyper to list of apps
2018-04-16 09:40:07 -07:00
Daniel Imms d8d9d904b5 Merge branch 'master' into patch-1 2018-04-16 09:39:02 -07:00
Benjamin Woodruff 4a13813941 Rename DRAW_TO_CACHE_LIMIT to FRAME_CACHE_DRAW_LIMIT 2018-04-16 08:56:54 -07:00
Daniel Imms cd7911a3d4 Merge pull request #1390 from Tyriar/third_party_addons
Add xterm-webfont addon to readme
2018-04-16 06:55:35 -07:00
Daniel Imms 3625a2278d Merge pull request #1365 from Tyriar/1364_addon_lint
Lint addon files
2018-04-16 06:46:42 -07:00
Daniel Imms 7d108999ff Fix lint 2018-04-16 06:42:16 -07:00
Daniel Imms e3dc36c123 Add xterm-webfont addon to readme 2018-04-16 06:28:45 -07:00
Daniel Imms 11541be4ae Merge branch 'master' into 1364_addon_lint 2018-04-16 06:25:48 -07:00
Daniel Imms ceffb35445 Merge pull request #1369 from Tyriar/897_dead_options
Remove unused options
2018-04-16 06:25:18 -07:00
Daniel Imms e1957ae6aa Merge remote-tracking branch 'origin/master' into 1364_addon_lint 2018-04-16 06:24:37 -07:00
Benjamin Woodruff 5a05db727c Add a per-frame limit on dynamic atlas writes
This limits the amount of damage a pathological program can cause in
thrashing the LRU cache.

I ran the script described here:
https://github.com/xtermjs/xterm.js/pull/1327#issuecomment-374003960

Without this patch, the entire output would get drawn in one frame that
took about 140 ms to draw. With this patch, it takes about 60 ms. It's
still nowhere as good as the static or none atlas implementations, but
it's not terrible, like it was.

This should have minimal impact on real-world applications: it'll just
take a little longer for the atlas to warm up.

The implementation is a little hacky, since it involves throwing some
code into TextRenderLayer that violates the separation of concerns, but
we can clean this up later.
2018-04-15 20:02:39 -07:00
Benjamin Woodruff 1f692ed047 Use a single tmpCtx, avoid parsing color values
Pros:
- The code is simpler.
- AA rendering is consistent between cached and uncached characters.
- No long requires parsing color values to determine the alpha, which
  means that we no longer depend on #rrggbbaa color value support.

Cons:
- We're drawing without SPAA in some cases where we could be.

Addresses this comment:
https://github.com/xtermjs/xterm.js/pull/1327#discussion_r176109332
2018-04-15 19:59:36 -07:00
Benjamin Woodruff c3eea02855 Add a LRUMap test, fix a bug in LRUMap
Bug: When appending a node, we weren't setting the tail's `next` value
correctly.
2018-04-15 19:48:37 -07:00
Benjamin Woodruff c6d66d7b0d Fix subpixel antialising in DynamicCharAtlas
Drawing to a ctx with `{alpha: true}` causes the canvas API (on chrome
at least) to switch to grayscale AA, instead of RGB subpixel AA.

This fixes it by drawing to a ctx that's using `{alpha: false}` when
posisble, and switching to a ctx that's using `{alpha: true}` only when
we have to.
2018-04-15 19:48:37 -07:00
Benjamin Woodruff 9c0ce1d742 Fix DynamicCharAtlas with transparency
There were two bugs:
- We need to clear the background of _tmpCtx instead of just drawing on
  top if the background color is transparent.
- We should set the background to fully transparent if it's partially
  transparent, to avoid drawing the transparent background twice.
2018-04-15 19:43:23 -07:00
Benjamin Woodruff ac7db87fd0 Remove use of Promises in {Base,Static}CharAtlas
Nothing actually cares about the return value, so we can avoid depending
on `Promise` by not returning a promise.

This should make this work for IE11 (though I haven't tested that).

I tried this in Chrome and Firefox to test both codepaths (ImageBitmap
and HTMLCanvasElement).
2018-04-15 18:52:06 -07:00
Benjamin Woodruff 8b3b7535c6 Add a new LRUMap class, remove uses of Map
LRUMap implements the parts of an ordered map that we need to
efficiently implement DynamicCharAtlas. It's more code, but there's a
few advantages of this approach:

- Map isn't available on some older browsers, so this removes the need
  for a polyfill.

- Moving an item to the end of the map's iteration order now only
  requires unlinking and linking a linked-list node, whereas before we
  had to delete and re-insert our value.

- Peeking at the oldest entry in the map no longer requires allocating
  and destroying an iterator.

- We can preallocate the linked-list nodes we want to improve cache
  locality. Similarly, we can recycle linked-list nodes to reduce
  allocations and the GC pauses those allocations may cause.

- LRUMap seems to give slightly better results in Chrome's profiler than
  Map did. We now spend about 5% of our time on map operations instead
  of about 10%.

- In my (limited) testing, it doesn't look like LRUMap is slowing down
  over time. Map appeared to get slightly slower the longer I ran the
  terminal for, either due to memory fragmentation or some sort of leak.

I still need to write some tests for LRUMap, but I've been using this
implementation for the last hour without problems.
2018-04-15 18:52:06 -07:00
Benjamin Woodruff c8b500c182 Skip drawing whitespace from DynamicCharAtlas
When we remove the background from a glyph, we can keep track of if we
made all the pixels fully transparent. If we did, we can just skip
future calls to _drawFromCache, since it would be a noop anyways.
2018-04-15 18:52:06 -07:00
Benjamin Woodruff 24feaabd9a Add a basic dynamic character atlas implementation
This adds a very minimal implementation of DynamicCharAtlas using a LRU
cache.

I've got some optimizations that I'll add on top of this, but this
proves the concept.
2018-04-15 18:49:07 -07:00
Benjamin Woodruff 8c980bc30d Add a dummy NoneCharAtlas implementation
This adds the logic needed to switch between multiple char atlas
implementations, and an example second implementation to test it out
with.

This also offers an escape hatch if something goes wrong with the char
atlas implementation(s).
2018-04-15 18:03:55 -07:00
Benjamin Woodruff 6f21385cd8 Add BaseCharAtlas and implement StaticCharAtlas
The API defined by BaseCharAtlas will let us support multiple char atlas
implementations at once.

I tested this by running the demo with Chrome's profiler, which shows
that calls are going to StaticCharAtlas/drawImage instead of
_drawUncachedChar. Applications using 256 colors also still work fine,
via _drawUncachedChar.
2018-04-15 18:03:55 -07:00
Daniel Imms 83f9d59d91 Merge pull request #1384 from Tyriar/1383_setoption_exception
Guard usages of DOM attached vars in setOption
2018-04-15 13:30:33 -07:00
Daniel Imms 3010760352 Remove vscode settings
No longer required as all the folders are in gitignore
2018-04-13 11:37:52 -07:00
Daniel Imms 82c16dee73 Rename coverage to test-coverage and document 2018-04-13 10:53:45 -07:00
Daniel Imms 7e8dd9647f Add testing section to README 2018-04-13 10:49:02 -07:00
Daniel Imms b594641b26 Run coverage on travis ci 2018-04-13 10:41:27 -07:00
Daniel Imms 5df9808d4c Remove launch.json in favor of auto attach debugging 2018-04-13 10:41:12 -07:00
Daniel Imms 2cee66909b Merge pull request #1374 from Tyriar/1353_run_lint_with_tests
Run lint with tests
2018-04-13 06:20:11 -07:00
Daniel Imms da8151b1b5 Merge pull request #1375 from Tyriar/remove-package-lock
Remove package-lock.json
2018-04-12 10:03:44 -07:00
Daniel Imms a3cb34fbf1 Merge pull request #1385 from johnpoth/headless-mode
Check if charMeasure is defined in headless mode
2018-04-12 07:29:48 -07:00
jpoth 9a1162d7f2 Check if charMeasure is defined in headless mode 2018-04-12 15:43:09 +02:00
Daniel Imms 591b09a62b Merge pull request #1377 from Tyriar/remove_jsdoc
Remove docdash
2018-04-11 09:39:12 -07:00
Daniel Imms f6f3e78e2c Merge pull request #1376 from Tyriar/1324_move_zmodem_demo
Move zmodem demo to demo/
2018-04-11 09:38:56 -07:00
Paris Kasidiaris 048b10ebf6 Bump version to 3.3.0
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2018-04-11 16:19:48 +00:00
Daniel Imms c882dcc353 Merge pull request #1381 from Tyriar/1379_viewport_throw
Fix exception when reset is called before open
2018-04-11 07:20:48 -07:00
Daniel Imms 82897ed56c Guard usages of DOM attached vars in setOption
Fixes #1383
2018-04-10 19:54:49 -07:00
Daniel Imms cd06786d16 Fix exception when reset is called before open
Fixes #1379
2018-04-09 06:13:32 -07:00
Daniel Imms 74d91a6bdd Remove docdash 2018-04-07 11:42:36 -07:00
Daniel Imms 4a1ebbfb56 Add .npmrc 2018-04-07 11:40:54 -07:00
Felipe Gasper 86c9b3f92c Fix zmodem demo. 2018-04-05 07:03:09 -07:00
Daniel Imms 4fbd1adaa9 Move zmodem demo to demo/
Fixes #1324
2018-04-04 14:31:25 -07:00
Daniel Imms 004ea61b83 Remove package-lock.json
We don't have any dependencies so this isn't as important to us, it's also ugly
to keep seeing these in PRs.
2018-04-04 14:11:46 -07:00
Daniel Imms 9be57f72f0 Run lint with tests
Fixes #1353
2018-04-04 14:10:03 -07:00
Daniel Imms e5ee76ded4 Remove terminal references on dispose
Part of #1341
Fixes #1370
2018-04-04 11:51:50 -07:00
Daniel Imms 87f21f14a1 Remove unused options
Fixes #897
2018-04-04 11:20:25 -07:00
Daniel Imms ef16811268 Merge branch 'master' into 1364_addon_lint 2018-04-04 11:11:05 -07:00
Daniel Imms 989f5873f5 Merge pull request #1366 from Tyriar/1363_fix_demo
Prevent falsy write values
2018-04-02 08:23:53 -07:00
Daniel Imms 307744be66 Prevent falsy write values
Fixes #1363
2018-04-02 08:22:22 -07:00
Daniel Imms 768539a57c Fix lint errors in attach 2018-04-02 08:17:44 -07:00
Daniel Imms 22c4197a1d Lint addons 2018-04-02 08:16:39 -07:00
Daniel Imms d4b75e4909 Merge pull request #1346 from bgw/color-parsing
Allow theming with arbitrary CSS color strings
2018-03-30 07:57:19 -07:00
Daniel Imms 4b5de031ea Merge branch 'master' into color-parsing 2018-03-30 07:50:39 -07:00
Benjamin Woodruff b66b0aae18 Block transparent colors without allowTransparency
Fixes xterm/xterm.js#1357.
2018-03-29 22:04:24 -07:00
Paris Kasidiaris 36a1c5b922 Merge pull request #1355 from AlexandrePetit-Pas/patch-5
Handle blob in attach Addon
2018-03-28 11:09:29 +03:00
Paris Kasidiaris 63f711e634 Fix styling and make string messages to work again 2018-03-28 10:57:21 +03:00
Alexandre Petit-Pas 516903e29e Handle blob in attach Addon
I have added blob handler for the attach Addon.
This allows to handle Docker with ws (works on Docker API v1.35)
I have also added a callback to handle asynchronous FileReader.
2018-03-28 07:37:02 +00:00
Paris Kasidiaris 5cf9423699 Merge pull request #1356 from xtermjs/fix-linter
Make linter blissful again
2018-03-28 10:31:29 +03:00
Paris Kasidiaris dbb2320e83 Fix linting errors 2018-03-28 10:22:42 +03:00
Benjamin Woodruff 0cb6138cd0 Allow theming with arbitrary CSS color strings
This mostly worked before, but clearColor made the assumption that the
colors were always in #RRBBGG format. See the discussion here:
https://github.com/xtermjs/xterm.js/pull/1327#issuecomment-374812842

This changes the internal representation of a color so that we hold onto
into an object containing the original css string along with an RGBA
value encoded as a 32-bit uint. clearColor can then use that RGBA
representation.

Additionally, this deduplicates some code between ColorManager and
Terminal. Terminal was generating the 256 ansi colors the same way
ColorManager was, so this just makes Terminal use the same constant.
2018-03-26 09:47:25 -07:00
Daniel Imms bf21097430 Merge pull request #1326 from LucianBuzzo/1322-options-clone
Do not mutate options object used in constructor
2018-03-24 14:07:59 -07:00
Lucian Buzzo 55d6daf8ee Do not mutate options object used in constructor
Connects to #1322

change-type: patch
2018-03-24 16:25:02 +00:00
Daniel Imms 6e1e63e666 Merge pull request #1350 from FGasper/issue_1330_rtl_layout
Force LTR for the terminal element
2018-03-23 16:19:02 -07:00
Daniel Imms b27d5bb08d Use single quote to make tslint happy 2018-03-23 16:18:41 -07:00
Felipe Gasper e63831febc Force LTR for the terminal element
Issue #1330: This prevents RTL layouts from mishandlin the
intended layout of the terminal container and children.
2018-03-23 19:16:02 -04:00
Daniel Imms 4ab79c908a Merge pull request #1329 from Tyriar/1319_bang_operator
Use bang operator for array methods
2018-03-21 07:34:18 -07:00
Daniel Imms b85083c3e8 Merge pull request #1303 from Tyriar/24_multi_line_links
Get multi-line links working
2018-03-21 07:33:43 -07:00
Daniel Imms 97f592ce8b Merge remote-tracking branch 'origin/master' into 24_multi_line_links 2018-03-21 07:32:32 -07:00
Daniel Imms 70da707569 Merge pull request #1338 from Tyriar/1325_marker_api
Implement Markers API
2018-03-20 19:14:10 -07:00
Daniel Imms 63f24be2b9 Merge branch 'master' into 1325_marker_api 2018-03-20 19:02:52 -07:00
Daniel Imms 0d6be9e03e Merge pull request #1344 from Tyriar/trailing_comma
Disallow trailing commas
2018-03-20 19:01:04 -07:00
Daniel Imms 3cbb21a966 Merge pull request #1340 from Tyriar/unused_func
Remove unused function
2018-03-20 19:00:35 -07:00
Daniel Imms 1fd7348938 Merge branch 'master' into unused_func 2018-03-20 19:00:24 -07:00
Daniel Imms ae32893732 Disallow trailing commas 2018-03-20 09:10:48 -07:00
Daniel Imms 4f82cf26f0 Merge pull request #1336 from mareklibra/removeStyle
Replace inline-styles by external CSS
2018-03-20 09:07:06 -07:00
Marek Libra b67b65cd1e Replace inline-styles by external CSS
Selected inline-styles were externalized to xterm.css.

The `Terminal._charSizeStyleElement` is removed since it
was not used anymore.

Fixes: https://github.com/xtermjs/xterm.js/issues/1335
2018-03-20 13:45:08 +01:00
Daniel Imms 0eeec13653 Clean up 2018-03-19 11:01:26 -07:00
Daniel Imms 5d1f744282 Remove unused function 2018-03-19 08:20:28 -07:00
Daniel Imms 387d5b056d Add Terminal.scrollToLine tests 2018-03-17 11:46:37 -07:00
Daniel Imms cbf7419601 Flag markers and addMarker as experimental 2018-03-16 17:24:04 -07:00
Daniel Imms 5c1a4a7d01 Add tests for Buffer.addMarker 2018-03-16 17:23:17 -07:00
Daniel Imms cbc6d7ce32 Add selectLines test 2018-03-16 15:56:48 -07:00
Daniel Imms b80832ac4c Initial marker API implementation
Part of #1325
2018-03-16 12:53:55 -07:00
Daniel Imms 3716aad202 Backtrack row to be linkified if the first row is wrapped 2018-03-16 07:21:14 -07:00
Daniel Imms efbd542964 Merge branch 'master' into 24_multi_line_links 2018-03-16 07:14:20 -07:00
Daniel Imms 888070830d Merge pull request #1332 from xtermjs/Tyriar-patch-1
Add note about third party dependencies
2018-03-13 12:44:51 -07:00
Daniel Imms 9905e2aa1d Add note about third party dependencies
Fixes #1328
2018-03-13 11:19:51 -07:00
Daniel Imms a59af6606b Use bang operator for array methods
Part of #1319
2018-03-12 14:14:37 -07:00
Daniel Imms d1213e5656 Merge pull request #1320 from Tyriar/1319/AccessibilityManager
Fix strictNullChecks errors in AccessibilityManager
2018-03-12 08:51:32 -07:00
Daniel Imms 0e14798d69 Merge pull request #1321 from felixse/patch-1
Add Fluent Terminal to the list of real-world uses
2018-03-11 13:44:16 -07:00
Daniel Imms c8ab687fa0 Add tests 2018-03-11 12:34:27 -07:00
Daniel Imms e5f5c2baf2 Fix links that start on wrapped lines 2018-03-10 16:08:50 -08:00
Felix 2f861602c8 Add Fluent Terminal to the list of real-world uses 2018-03-10 23:27:59 +01:00
Daniel Imms 4f0cc01485 Fix strictNullChecks errors in AccessibilityManager
Part of #1319
2018-03-09 11:27:10 -08:00
Daniel Imms dd41ab38bb Fix imports after noUnusedLocals was merged in 2018-03-09 10:58:57 -08:00
Daniel Imms 255cb5de3a Merge branch 'master' into 24_multi_line_links 2018-03-09 10:57:04 -08:00
Daniel Imms b44a11c42e Remove TODOs, polish 2018-03-09 10:56:54 -08:00
Daniel Imms 90b2f0e6a1 Merge pull request #1316 from Tyriar/noUnusedLocals
Add noUnusedLocals tsconfig flag, fix issues
2018-03-09 08:43:40 -08:00
Daniel Imms 811aa9c413 Merge remote-tracking branch 'origin/master' into noUnusedLocals 2018-03-09 08:43:21 -08:00
Daniel Imms 842c7132ec Merge pull request #1318 from Tyriar/remove_unused_css
Remove unused CSS rule
2018-03-09 08:41:41 -08:00
Daniel Imms efb67edc36 Remove unused CSS rule
With #1316, this will resolve Microsoft/vscode#45145
2018-03-09 07:11:53 -08:00
Daniel Imms ed7741e006 Merge pull request #1317 from bgw/rm-char-atlas-request
Merge ICharAtlasRequest with ICharAtlasConfig
2018-03-09 06:11:05 -08:00
Benjamin Woodruff cfe936a0b4 Merge ICharAtlasRequest with ICharAtlasConfig
ICharAtlasRequest and ICharAtlasConfig need almost exactly the same set
of information, so it's simpler if we just merge the two types.

As an added bonus, this also adds devicePixelRatio to the config, which
helps guarantee that we won't ever accidentally end up with an atlas
using a different pixel ratio than we need.
2018-03-08 23:23:33 -08:00
Daniel Imms 4ddf91dbbe Fix tests 2018-03-08 11:20:42 -08:00
Daniel Imms 59be054ca1 Fix exception for links on bottom line 2018-03-08 11:12:59 -08:00
Daniel Imms b794dc017d Fix test 2018-03-08 11:08:51 -08:00
Daniel Imms 4443ed69c7 Add noUnusedLocals tsconfig flag, fix issues
Two parts were commented out:
- _writeStopped: This is because _xoffSentToCatchUp references this variable
  and the feature is sort of half implemented/disabled.
- _clearChar: This is because some comments still reference this, it's part
  of the work needed to do better line redrawing.
2018-03-08 10:56:10 -08:00
Daniel Imms ab9b84898e Merge remote-tracking branch 'origin/master' into 24_multi_line_links 2018-03-08 10:23:05 -08:00
Daniel Imms a41e183b88 Merge pull request #1310 from Tyriar/426_alt_scroll
Send arrow events on mouse wheel in alt buffer
2018-03-08 09:53:36 -08:00
Daniel Imms 949239dbdc Merge remote-tracking branch 'origin/master' into 426_alt_scroll 2018-03-08 09:28:02 -08:00
Daniel Imms 421ccc5695 Join lines that wrap over more than 2 lines 2018-03-08 09:25:08 -08:00
Daniel Imms 5d68ed6e5e Merge pull request #1315 from Tyriar/underscore_private
Rename all remaining private variables to use underscores
2018-03-08 09:01:33 -08:00
Daniel Imms 021f8c1ba0 Draw and clear link cells 2018-03-08 07:00:37 -08:00
Daniel Imms f456b14b3f Get multi-line link hover working 2018-03-08 06:42:40 -08:00
Daniel Imms 7a1ef19146 Merge remote-tracking branch 'origin/master' into 24_multi_line_links 2018-03-08 06:23:29 -08:00
Daniel Imms b9cbdf6a0d Fix tests 2018-03-08 06:19:17 -08:00
Daniel Imms 7639131c12 Ensure underscore is used for private vars
Variables changed based on regex: "private [^(_|get)]"
2018-03-08 06:09:46 -08:00
Daniel Imms 289b4eeb23 Merge branch 'master' into 426_alt_scroll 2018-03-08 05:37:16 -08:00
Daniel Imms 404a285eaf Merge pull request #1307 from bgw/split-char-atlas-files
Split CharAtlas types and utility functions off
2018-03-08 05:16:44 -08:00
Daniel Imms b20fe80f9b Merge pull request #1308 from bgw/rm-did-char-size-change
Remove didCharSizeChange logic from renderer
2018-03-08 05:10:53 -08:00
Daniel Imms ff9814a40d Merge pull request #1293 from nikonso/allow-named-theme-colors-1195
Validate colors
2018-03-08 05:02:50 -08:00
Daniel Imms 855964fbe1 Merge pull request #1296 from olsonpm/fix-paste-newline
Paste newlines as \r
2018-03-08 05:02:31 -08:00
Paris Kasidiaris 606c68dd0c Bump version to 3.2.0
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2018-03-08 08:59:46 +00:00
Benjamin Woodruff 735dfb4710 Add copyright header to shared/atlas/Types.ts 2018-03-07 23:19:38 -08:00
Benjamin Woodruff ab69bfbb32 Move rest of atlas implementations to atlas dirs
Moves CharAtlas into src/renderer/atlas/ and CharAtlasGenerator into
src/shared/atlas/.
2018-03-07 22:23:19 -08:00
Benjamin Woodruff 70771430b5 Clean up char atlas constant imports/exports
- Ensures that everything is only defined in one place, and everything
  imports from that place.
- Moves CHAR_ATLAS_CELL_SPACING into a subdirectory of shared/ so that
  CharAtlasGenerator can pull from it.

This addresses the comments on
https://github.com/xtermjs/xterm.js/pull/1307/files/454fd4bfb1ab5c9ece
2018-03-07 22:13:41 -08:00
Paris Kasidiaris 6741e92cc6 Merge pull request #1313 from xtermjs/docker-image
Add xterm.js Docker image to documentation
2018-03-07 23:00:04 +02:00
Paris Kasidiaris 31ce5c1826 Run the webpack build in the docker image too 2018-03-07 12:38:29 +02:00
Paris Kasidiaris 1f113b1d29 Add xterm.js Docker image to documentation
Closes #1295
2018-03-07 12:28:44 +02:00
Bruno Ribeiro 41f6ee4f6d Merge branch 'master' into allow-named-theme-colors-1195 2018-03-06 20:15:32 +00:00
Daniel Imms 6e546c0f30 Merge pull request #1298 from Tyriar/1297_webLinks_addon
Pull web link support into an addon
2018-03-06 09:29:33 -08:00
Daniel Imms 7cae8e51ca Merge pull request #1290 from Tyriar/1287_double_click_exception
Check for valid coords before getting word at coords
2018-03-06 09:28:55 -08:00
Daniel Imms bf4dd7de60 Merge branch 'master' into 1287_double_click_exception 2018-03-06 09:28:47 -08:00
Thomas Zilz ff6ef1b63a Initialise _wheelPartialScroll to 0 to prevent NaN 2018-03-06 11:39:14 +01:00
Bruno Ribeiro 34034b849f Merge branch 'master' into allow-named-theme-colors-1195 2018-03-05 23:22:12 +00:00
Daniel Imms f2d8709dd8 Merge pull request #1309 from Tyriar/1305_alt_horizontal_only
Only move horizontally on alt click in normal buffer
2018-03-05 14:25:45 -08:00
Daniel Imms e137530581 Scroll by exact line amount in alt buffer, unify scroll logic
Fixes #1304
2018-03-05 14:22:20 -08:00
Daniel Imms be7788dda6 Merge remote-tracking branch 'origin/master' into 426_alt_scroll 2018-03-05 11:48:40 -08:00
Daniel Imms 7c471f5389 Fix test compile 2018-03-05 11:32:05 -08:00
Daniel Imms 9e62c8692f Only move horizontally on alt click in normal buffer
Fixes #1305
2018-03-05 11:11:54 -08:00
Benjamin Woodruff 18fb134910 Remove didCharSizeChange logic from renderer
The only thing `didCharSizeChange` was used for was to figure out if we
need to refresh the character atlas or not. However, `acquireCharAtlas`
already inspects the atlas owned by this terminal, and if it matches, it
avoids generating a new atlas.

So if `didCharSizeChange` is true and it's not needed, it quickly bails
out as a no-op. But if `didCharSizeChange` is false, and it was needed
(possible given the complexity of testing all of these edge cases), it
could introduce a bug.

I think it makes sense to just get rid of `didCharSizeChange`, and just
always call `acquireCharAtlas`.
2018-03-04 20:55:42 -08:00
Benjamin Woodruff 454fd4bfb1 Split CharAtlas types and utility functions off
I'm starting to pull some changes off of my large WIP branch/commit that
adds an alternative dynamic character atlas. We're going to need to
support multiple CharAtlas implementations, and this should make that
easier.
2018-03-04 18:50:46 -08:00
Daniel Imms 131e6ff949 Merge pull request #1302 from nikonso/Enforce-option-value-via-types
Enforce option value via types
2018-02-28 07:47:25 -08:00
Bruno Ribeito c51fa238ff Readd any overloads 2018-02-27 23:18:33 +00:00
Daniel Imms 2e3f9e7094 Multi-line links prototype
Part of #24
2018-02-27 08:37:16 -08:00
Bruno Ribeito 76a3dbf883 Enforce option value via types 2018-02-26 23:27:53 +00:00
Jon Austin 07cf029497 Merge branch 'master' into patch-1 2018-02-24 13:12:30 -08:00
Daniel Imms c8017345f1 Merge pull request #1288 from dgriffen/dev/dgriffen/fix-scrollbar
fix terminal width calculation
2018-02-24 11:56:35 -08:00
Daniel Imms 0d2cc7489e Fix tests, add webLinks addon test 2018-02-24 10:36:34 -08:00
Jon Austin f3a37a9522 Add Hyper to list of apps
https://github.com/zeit/hyper/blob/82c7afbeecf5a0c455075868cd23585fce95cf68/package.json#L197
2018-02-24 10:14:51 -08:00
Daniel Imms 6a71717751 Allow customization of the web links handler and options 2018-02-23 11:28:14 -08:00
Daniel Imms dc822787d0 Move http links to the new webLinks addon
Fixes #1297
2018-02-23 11:11:23 -08:00
Daniel Imms 5011e629b1 Build addons by scanning addon dir 2018-02-23 11:08:11 -08:00
Philip Olson bc35f28f51 Paste newlines as \r
Fix issue where non-windows OS terminals don't paste newlines correctly
into misbehaving programs.  As noted in JetBrains/jediterm#136, the
most practical solution is for terminals to handle this in their paste
logic.  In a perfect world, all terminal programs would implement
bracketed paste mode properly, but that's a lot to ask.

- translate newlines to \r which is what terminal programs expect
2018-02-22 23:52:45 -06:00
Bruno Ribeiro 97feb64e94 Merge branch 'master' into allow-named-theme-colors-1195 2018-02-21 23:51:36 +00:00
Daniel Imms 94bbc4e09d Merge pull request #1200 from nikonso/1181
WIP: Use web audio api
2018-02-21 15:36:19 -08:00
Daniel Imms ad7d2262ec Undo package-lock changes 2018-02-21 15:35:53 -08:00
Bruno Ribeito 1114977a21 Fix tests 2018-02-21 23:35:37 +00:00
Bruno Ribeiro a8c5b159a9 Merge branch 'master' into allow-named-theme-colors-1195 2018-02-21 23:17:00 +00:00
Daniel Imms a91e0e234a Use const everywhere 2018-02-21 14:44:48 -08:00
Daniel Imms af5b3f704e Fix lint 2018-02-21 14:42:04 -08:00
Daniel Imms 45c9763092 Fix indentation 2018-02-21 14:40:22 -08:00
Daniel Imms db8ba17147 Check audio context ctor before constructing 2018-02-21 14:39:43 -08:00
Daniel Imms 1972bf4bb3 Merge remote-tracking branch 'ups/master' into 1181 2018-02-21 14:36:11 -08:00
Daniel Imms 62cf0936dc Merge pull request #1231 from saamalik/ctrl-alt-sequences
Additional alt and control sequences
2018-02-21 14:08:31 -08:00
Bruno Ribeito a9d6686e14 Regex is not needed for color validation 2018-02-20 20:38:12 +00:00
Bruno Ribeito 99aa142cef Fix test -> wrong Regex flag 2018-02-19 23:55:25 +00:00
Bruno Ribeito f8f1355155 Validate colors 2018-02-19 22:54:09 +00:00
Daniel Imms ae28814041 Check for valid coords before getting word at coords
Fixes #1287
2018-02-16 21:34:57 -08:00
Daniel Griffen 183fd2fe79 fix terminal width calculation 2018-02-16 10:18:03 -08:00
Saad Malik 8324462b32 Merge branch 'master' into ctrl-alt-sequences 2018-02-15 09:49:16 -08:00
Daniel Imms 93e5996422 Merge pull request #1182 from Tyriar/731_screen_reader
Screen reader support
2018-02-15 06:20:14 -08:00
Daniel Imms f089b997c0 Merge branch 'master' into 731_screen_reader 2018-02-14 09:03:31 -08:00
Saad Malik 51d2064061 Merge branch 'master' into ctrl-alt-sequences 2018-02-13 14:59:46 -08:00
Daniel Imms 712b91a971 Merge pull request #1282 from matthew-matvei/add-freeman
Added FreeMAN to list of real-world uses
2018-02-13 06:37:55 -08:00
Daniel Imms cbe6c64a92 Merge pull request #1280 from AndrienkoAleksandr/fixHeadlessMode
Fix xterm.js in headless mode yields TypeError on resize
2018-02-12 12:42:14 -08:00
Matthew James 64ed8309a1 Added FreeMAN to list of real-world uses 2018-02-12 20:26:09 +00:00
Oleksandr Andriienko b5ba9ae771 Fix xterm.js in headless mode yields TypeError on resize
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
2018-02-12 12:30:26 +02:00
Saad Malik 18f6556061 Merge branch 'master' into ctrl-alt-sequences 2018-02-09 14:00:24 -08:00
Paris Kasidiaris 1dbe7b3a8c Bump version to 3.1.0
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2018-02-09 08:42:39 +00:00
Saad Malik 6dc49b7d01 Merge branch 'master' into ctrl-alt-sequences 2018-02-08 12:03:38 -08:00
Daniel Imms 987be07a70 Merge pull request #1276 from Tyriar/enableBold_deprecated
Mark enableBold setting as deprecated
2018-02-07 07:46:50 -08:00
Daniel Imms 760837e5cb Mark enableBold setting as deprecated 2018-02-06 07:25:54 -08:00
Thomas Zilz dc759a93bc Support setting padding on the .xterm element (#1208)
* Support padding on the .xterm element
2018-02-06 12:31:17 +01:00
Daniel Imms 1ec7b91a98 Merge pull request #1264 from Tyriar/1021_support_modifiers
Allow support of modifiers with links
2018-02-06 02:32:00 -08:00
Daniel Imms c218eebb24 Merge pull request #1266 from Tyriar/1265_sync_when_attached
Ensure viewport is attached before syncing scrollbar
2018-02-06 02:24:59 -08:00
Daniel Imms 8040e3de4a Merge pull request #1275 from xtermjs/Tyriar-patch-1
Update readme copyright statement
2018-02-06 02:23:39 -08:00
Paris Kasidiaris ff400bfcdc Merge pull request #1273 from xtermjs/webpack-watch
Add `watch` gulp task and npm script
2018-02-06 12:20:36 +02:00
Daniel Imms 35ea593806 Update readme copyright statement 2018-02-06 02:07:56 -08:00
Paris Kasidiaris f02903a6df Update README.md and Docker files 2018-02-06 09:22:16 +00:00
Paris Kasidiaris 182426dd0f Rename gulp task: webpack:watch → watch` and also monitor subdirectories 2018-02-06 10:28:34 +02:00
Paris Kasidiaris d0f45fee25 Fix #1232: Add webpack:watch gulp task 2018-02-05 15:49:37 +00:00
Daniel Imms 1462b30c88 Merge pull request #1271 from krasimir/patch-1
Update README.md
2018-02-05 07:41:23 -08:00
Krasimir Tsonev c302bc9f17 Update README.md
In `Getting Started` section we read `npm install` only. Shouldn't be `npm install xterm`?
2018-02-05 09:32:34 +02:00
Daniel Imms 01d841fec6 Merge pull request #1246 from Tyriar/1245_revert_page_change
Revert "Add support for modifiers for PageUp / PageDown keys."
2018-02-02 09:51:28 -08:00
Daniel Imms 1124f1fc7f Merge pull request #1114 from nikonso/feature-778
Select the word underneath the cursor on contextmenu
2018-02-01 17:35:52 -08:00
Daniel Imms cab097c09c Clean up condition for readability 2018-02-01 17:28:08 -08:00
Daniel Imms 43adf0ef70 Merge branch 'master' into feature-778 2018-02-01 17:21:04 -08:00
Daniel Imms 3c6cab1491 Clear selectionEnd when selecting word at cursor 2018-02-01 17:20:33 -08:00
Bruno Ribeito 5550bfd90b Fix is click in selection 2018-02-01 21:37:06 +00:00
Daniel Imms 04ccb638b4 Fix lint 2018-02-01 11:28:56 -08:00
Daniel Imms 5c05471993 Merge branch 'master' into 1021_support_modifiers 2018-02-01 11:28:05 -08:00
Daniel Imms 1e32d26a85 Merge branch 'master' into 1265_sync_when_attached 2018-02-01 10:28:41 -08:00
Daniel Imms 6105975308 Ensure viewport is attached before syncing scrollbar
Fixes #1265
2018-02-01 10:24:17 -08:00
Daniel Imms cd24f7a26c Merge pull request #1263 from Tyriar/ts_2.7
typescript@2.7
2018-02-01 08:16:42 -08:00
Daniel Imms 2ac5a8da49 Allow support of modifiers with links
Fixes #1021
2018-01-31 17:42:33 -08:00
Daniel Imms e849629533 typescript@2.7
Tuples using a fixed length by default will be helpful for CharData
2018-01-31 11:32:19 -08:00
Bruno Ribeito 983af8fac2 Use _selectWordA 2018-01-31 00:01:46 +00:00
Daniel Imms 74a6dfb197 Send arrow events on mouse wheel in alt buffer
Fixes #426
2018-01-29 11:28:48 -08:00
Saad Malik 73e0db1912 Merge branch 'master' into ctrl-alt-sequences 2018-01-29 10:21:36 -08:00
Daniel Imms 62d6c242fc Merge pull request #1249 from Tyriar/1248_tslint_curly
Add curly to tslint, fix errors
2018-01-29 07:54:09 -08:00
Daniel Imms e7b4e002f4 Merge remote-tracking branch 'origin/master' into 1248_tslint_curly 2018-01-29 07:45:31 -08:00
Daniel Imms d190bc0531 Merge pull request #1250 from xtermjs/Tyriar-patch-1
Add SQL Operations Studio to real world uses
2018-01-29 07:44:36 -08:00
Daniel Imms fb1d902804 Merge pull request #1258 from Tyriar/travis_tsc
Run tsc as a travis job
2018-01-29 07:44:26 -08:00
Daniel Imms 12cd6ea0e4 Merge pull request #1260 from Tyriar/typo
Fix recent typo in comment
2018-01-29 07:43:56 -08:00
Daniel Imms 69ebb3e53e Fix recent typo in comment 2018-01-29 07:42:59 -08:00
Paris Kasidiaris f2fe8ca08b Merge pull request #896 from npezza93/alt-click
Alt+click will move the prompt cursor to that position
2018-01-29 11:58:46 +02:00
Daniel Imms bbac1801e5 Small clean up 2018-01-28 17:33:51 -08:00
Daniel Imms a6a4bf0817 Merge remote-tracking branch 'ups/master' into feature-778 2018-01-28 17:25:46 -08:00
Saad Malik 9ade1f0a5d Add mapping for backward slash
* Add mapping for backward slash
* Fix mapping for single/double quote
2018-01-28 17:11:13 -08:00
Saad Malik f8fbdf31fa Merge branch 'master' into ctrl-alt-sequences 2018-01-28 16:54:55 -08:00
Daniel Imms e8666cafc9 Small clean up 2018-01-28 14:44:33 -08:00
Daniel Imms db95442af6 Merge pull request #1236 from chabou/pr/1148
Add allowTransparency option
2018-01-28 14:19:20 -08:00
Daniel Imms fc2af1d806 Fix lint, reduce duplication, don't scale ctx
Scaling ctx was breaking the scale when setOption was called, not sure
it was doing anything.
2018-01-28 14:13:25 -08:00
Daniel Imms 106704b5d8 Merge remote-tracking branch 'ups/master' into pr/1148 2018-01-28 13:39:07 -08:00
Daniel Imms a0f390ef54 Expose strings through the API 2018-01-28 13:10:11 -08:00
Daniel Imms af375eadb4 Run tsc as a travis job
This will hard fail when there are semantic errors. Currently building does
not do this and we will merge these in as a result.
2018-01-28 12:27:01 -08:00
Daniel Imms 098a3d0804 Merge pull request #1253 from sitzmar/right_click_timeout
adjust timeout to ensure right-click event has fired
2018-01-28 10:35:44 -08:00
npezza93 3bdc069f19 Set copyright header to 2018 2018-01-28 13:16:20 -05:00
npezza93 3313716c87 Add new lines back in types 2018-01-28 13:15:42 -05:00
npezza93 735ffdd2ce Merge remote-tracking branch 'upstream/master' into alt-click 2018-01-28 13:13:37 -05:00
Daniel Imms 8588199fdb Merge pull request #1256 from Tyriar/1255_id_class
Change render layer id to a class
2018-01-28 10:13:13 -08:00
npezza93 f726c1fd0d Allow selection and alt click to live conflict free 2018-01-28 13:06:54 -05:00
npezza93 e60704255f Fix lints 2018-01-28 13:00:11 -05:00
npezza93 aeae40e110 Use the terminal and circular list interface 2018-01-28 12:38:20 -05:00
npezza93 08af2ebeea Utilize enum to simplify sequence generation 2018-01-28 12:29:52 -05:00
npezza93 0202659c38 Set terminal and mouseevent inside constructor args 2018-01-28 10:48:08 -05:00
npezza93 edadb6e0f1 Update the copyright header 2018-01-28 10:44:01 -05:00
Daniel Imms 39abf8aecf Change render layer id to a class
It's only used to identify them in DOM explorer currently

Fixes #1255
2018-01-27 22:26:00 -08:00
Daniel Imms 65b6901170 Fix compile error 2018-01-27 21:51:13 -08:00
npezza93 14725d0b0d Merge remote-tracking branch 'upstream/master' into alt-click 2018-01-27 22:38:12 -05:00
npezza93 c41a4b5168 Move repeat import 2018-01-27 22:37:57 -05:00
npezza93 d61aa6e470 Fix lints 2018-01-27 22:37:31 -05:00
npezza93 544fa67851 Move repeat out of generic 2018-01-27 22:36:53 -05:00
npezza93 6a48022a45 Don't reset starting position if the row is not moved.
Mainly due to the normal buffer
2018-01-27 22:28:41 -05:00
npezza93 a4ee723665 Fix backward row/col definition 2018-01-27 22:06:58 -05:00
npezza93 dc59f33ccf Fix translateBufferToString bug 2018-01-27 22:06:31 -05:00
Daniel Imms ec156f62e1 Only update a11y manager dimensions after a renderer resize 2018-01-27 18:38:28 -08:00
npezza93 833d814499 Refactor alt-click to work independently of which buffer is being used 2018-01-27 21:30:53 -05:00
npezza93 327b16ac2e Add repeat polyfill for repeating a string 2018-01-27 21:30:24 -05:00
Daniel Imms a3958a1cba Merge branch 'master' into 731_screen_reader 2018-01-27 18:15:31 -08:00
Daniel Imms 7c8b64aaf1 Revert "Hook up scroll APIs to scroll and focus when navigating"
This reverts commit b13826441c.
2018-01-27 18:14:58 -08:00
Daniel Imms b13826441c Hook up scroll APIs to scroll and focus when navigating 2018-01-27 18:14:52 -08:00
Daniel Imms 0bdf1e8265 Remove unused function 2018-01-27 17:51:43 -08:00
Daniel Imms 5506af5322 Clean up a11y manager 2018-01-27 16:47:23 -08:00
Daniel Imms 6439aca1d8 Refresh dimensions of only a single row 2018-01-27 15:00:19 -08:00
Daniel Imms 65850c1c20 Reduce duplication 2018-01-27 14:53:46 -08:00
Daniel Imms 963db4d2fd Remove navigation mode/more rows element 2018-01-27 14:48:45 -08:00
Daniel Imms 5c061195c0 Get navigation right/down working with nav mode 2018-01-27 14:45:22 -08:00
Saad Malik 0104e4214e Reimplement using map
* Reimplemented reg + shift alt digits and characters using a map
* Add test cases for digits
2018-01-26 18:33:37 -08:00
Saad Malik baaf61b3a3 Merge branch 'master' into ctrl-alt-sequences 2018-01-26 13:38:48 -08:00
Daniel Imms 9feb10efc5 Merge pull request #1244 from Tyriar/remove_legacy_gitignore
Remove legacy .gitignore rules
2018-01-26 10:34:43 -08:00
Daniel Imms 58f3793cd4 Merge branch 'master' into remove_legacy_gitignore 2018-01-26 10:27:44 -08:00
Daniel Imms 93715c455d Add dist/ back 2018-01-26 10:26:31 -08:00
Daniel Imms b9976c3d17 Merge remote-tracking branch 'origin/master' into 731_screen_reader 2018-01-26 10:24:09 -08:00
sitzmar 069b489fb6 adjust timeout to ensure right-click event has fired 2018-01-26 08:04:59 -08:00
CHaBou fe53e1a091 Change canvas transparency when option is updated 2018-01-25 23:20:20 +01:00
Bruno Ribeito e6c6e0766a Fix usage of allowWhitespaceOnlySelection variable 2018-01-25 21:00:10 +00:00
Daniel Imms 2c065b66be Add SQL Operations Studio to real world uses 2018-01-25 12:31:48 -08:00
Daniel Imms 1dce76dbbb Add curly to tslint, fix errors
Fixes #1248
2018-01-25 12:17:59 -08:00
Daniel Imms 9c62a817d0 Fix build after merge 2018-01-25 12:08:50 -08:00
Daniel Imms 3a3f3db56e Merge remote-tracking branch 'ups/master' into feature-778 2018-01-25 11:58:46 -08:00
Daniel Imms bd55ce841e Merge branch 'master' into 1245_revert_page_change 2018-01-25 11:28:29 -08:00
Daniel Imms 6c54c6cded Merge pull request #1224 from Tyriar/1221_iterminal_typings
Move ITerminal and all its dependents into typings/
2018-01-25 11:25:02 -08:00
Daniel Imms c12394a687 Don't export contains 2018-01-25 11:09:20 -08:00
Daniel Imms 2e23dd34e0 Move xterm-internal types back into Types.ts files 2018-01-25 11:06:52 -08:00
Daniel Imms 8225b94d34 Types.d.ts -> .ts 2018-01-25 10:24:17 -08:00
Daniel Imms 4db4fcb40a Remove declaration file generation, we have explicit types 2018-01-25 10:23:14 -08:00
Daniel Imms 177edfa66e Merge interfaces and types files 2018-01-25 10:03:28 -08:00
Daniel Imms d454a50a84 Move FontWeight type to xterm.d.ts 2018-01-25 09:48:12 -08:00
Daniel Imms 7358890a31 Merge remote-tracking branch 'ups/master' into 1221_iterminal_typings 2018-01-25 09:45:13 -08:00
Daniel Imms 4c6f18c36f Revert "Add support for modifiers for PageUp / PageDown keys."
This reverts commit 83921c0b26.

Fixes #1245
2018-01-25 09:20:19 -08:00
Daniel Imms 70747e84a1 Merge remote-tracking branch 'ups/master' into pr/1148 2018-01-25 08:15:42 -08:00
Daniel Imms 8f1a629b48 Merge pull request #1198 from Tyriar/955_worker_refactor
Refactor char atlas to enable generation with worker
2018-01-25 07:22:15 -08:00
Daniel Imms b87fe53b94 Remove legacy .gitignore rules 2018-01-25 07:20:41 -08:00
Daniel Imms a22b5c0faa Merge remote-tracking branch 'ups/master' into 955_worker_refactor 2018-01-25 07:16:00 -08:00
Daniel Imms 92e85e0ce5 Merge pull request #1228 from Tyriar/missing_typings
Add missing macOptionIsMeta typings
2018-01-25 07:00:08 -08:00
Daniel Imms 038260b92a Merge pull request #1235 from Tyriar/1151_clamp_saved_cursor
Resize saved cursor position on buffer resize
2018-01-25 06:55:02 -08:00
Daniel Imms d17c08a32f Merge pull request #1238 from Tyriar/1117_reenable_enableBold
Add enableBold back, add fontWeight types to xterm.d.ts
2018-01-25 06:54:45 -08:00
Daniel Imms c1f18c33cc Merge pull request #1192 from Tyriar/master_version
Set version to 3.1.0-master
2018-01-25 06:54:25 -08:00
Daniel Imms 1cceda6052 Change navigation mode to work using focus instead of activedescendant 2018-01-24 16:34:39 -08:00
Daniel Imms 3e734fab79 Support i18n 2018-01-24 11:15:56 -08:00
Daniel Imms c41b35ae9c Add message about entering navigation mode 2018-01-24 11:04:41 -08:00
Saad Malik e478918ea7 Merge branch 'master' into ctrl-alt-sequences 2018-01-24 09:00:26 -08:00
Daniel Imms 3798b28aa2 Merge pull request #1211 from Tyriar/1103_search_wide_emoji
Fix search addon for lines with emojis and wide chars
2018-01-24 07:52:29 -08:00
Daniel Imms e539a59e26 Merge branch 'master' into 1103_search_wide_emoji 2018-01-24 07:33:08 -08:00
npezza93 027bc9535e Pass false for isSelection so the right half of the cell wont select the next element 2018-01-23 20:57:31 -05:00
npezza93 8d41c4c603 Fix lints 2018-01-23 20:12:39 -05:00
npezza93 7e0a484000 Handle going back and up in the alt buffer from a long line to a short line 2018-01-23 20:12:39 -05:00
npezza93 14498104fc Alt+click will move the prompt cursor to that position
Fixes #890
2018-01-23 20:12:39 -05:00
Saad Malik e1c99b28f0 Merge branch 'master' into ctrl-alt-sequences 2018-01-23 11:16:47 -08:00
Daniel Imms 45c6008b27 Rotate terminal rows after removing focus 2018-01-23 11:11:29 -08:00
Daniel Imms a74f7ba196 Merge branch 'master' into 1151_clamp_saved_cursor 2018-01-23 10:48:54 -08:00
Daniel Imms fba4f5f261 Ensure active item is removed before scroll 2018-01-23 10:39:21 -08:00
Daniel Imms bce0cce74d Ensure a11y tree is located above the prompt 2018-01-23 09:50:47 -08:00
Daniel Imms c2d78e57d0 Fix screenReadeMode disable in demo 2018-01-23 09:49:43 -08:00
Daniel Imms 46f35064e3 Merge pull request #1227 from Tyriar/typo_intefaces
Fix Intefaces typo
2018-01-23 09:07:05 -08:00
Daniel Imms 8f263fb987 Merge branch 'master' into typo_intefaces 2018-01-23 09:06:47 -08:00
Daniel Imms f56f4520d0 Merge branch 'master' into 1103_search_wide_emoji 2018-01-23 09:06:06 -08:00
Daniel Imms a13562bf45 Remove relative font weight as valid values 2018-01-23 08:58:33 -08:00
Daniel Imms 067acd8803 Merge branch 'master' into pr/1148 2018-01-23 08:33:55 -08:00
Daniel Imms df02dacdc4 Add enableBold back
Part of #1117
2018-01-23 08:28:01 -08:00
Daniel Imms 4e6b089216 Merge pull request #1119 from nikonso/1117
Support setting font weight
2018-01-23 08:11:27 -08:00
Daniel Imms 01c95168f2 Make font weight types in ITerminalOption more strict 2018-01-23 08:02:48 -08:00
Daniel Imms f3ecbea3e8 Fix tests 2018-01-23 07:55:18 -08:00
Daniel Imms 11aa193074 Merge branch 'master' into 1117 2018-01-23 07:51:25 -08:00
Daniel Imms 2ebc5d904d Resize saved cursor position on buffer resize
Saved cursor coordinates were not being resized as well which could
lead to crashes when resizing down while the alt buffer is active.

Fixes #1151
2018-01-23 06:51:22 -08:00
Saad Malik bb8e06592c Merge branch 'master' into ctrl-alt-sequences 2018-01-22 12:53:45 -08:00
Daniel Imms d85d353772 Merge pull request #1234 from Tyriar/1233_link_activation
Use explicit null check to ensure start/end row is valid
2018-01-22 12:53:00 -08:00
Daniel Imms a9d3e61794 Fix tests 2018-01-22 12:43:42 -08:00
Daniel Imms 16abf71b78 Use explicit null check to ensure start/end row is valid
It looks like this could have caused the inconsistent behavior with
links not activating and then working again after scrolling

Fixes #1233
2018-01-22 11:51:09 -08:00
Daniel Imms 421a885acd Merge remote-tracking branch 'origin/master' into 731_screen_reader 2018-01-22 06:32:38 -08:00
Saad Malik d62e4e25b7 Cleaup whitespace 2018-01-21 16:56:58 -08:00
Saad Malik ec9f2702eb Additional alt and control sequences
* Add punctuation alt sequences
* Add support for ctrl+alt sequences
2018-01-21 16:40:38 -08:00
Daniel Imms f554f53bda Merge pull request #1229 from ColdGrub1384/patch-1
Include Pisth in applications
2018-01-21 10:22:42 -08:00
Daniel Imms 49565c2fcf Merge branch 'master' into patch-1 2018-01-21 10:22:19 -08:00
Daniel Imms a338def801 Merge pull request #1230 from jkuri/abstruse-readme
Add AbstruseCI as real-world example
2018-01-21 10:16:16 -08:00
Jan Kuri a9a1d37a1e Add AbstruseCI as real-world example 2018-01-21 18:49:10 +01:00
Adrian Labbé e55a234b53 Include Pisth in applications 2018-01-20 16:07:31 -03:00
Daniel Imms 4e20b48aa0 Add missing macOptionIsMeta typings
Follow up from #1225
2018-01-20 11:06:53 -08:00
Daniel Imms 616958e2c6 Merge pull request #1225 from saamalik/altIsMeta
Mac OSX: altIsMeta support
2018-01-20 10:15:03 -08:00
Daniel Imms e4726192f1 Various fixes
- altIsMeta -> macOptionIsMeta
- Moved isThirdLevelShift into Terminal class
- Moved option check into isThirdLevelShift so it doesn't affect the Windows
  case and also includes the keypress case
- Add public API and typings test
- Add option checkbox to demo
2018-01-20 09:06:05 -08:00
Daniel Imms 4f59363331 Fix Intefaces typo 2018-01-20 08:22:12 -08:00
Saad Malik 73686e66c6 Remove package-lock changes 2018-01-19 16:51:57 -08:00
Daniel Imms b97cedcf5b Merge remote-tracking branch 'origin/master' into 731_screen_reader 2018-01-19 14:01:37 -08:00
Saad Malik d981a9fe6c Merge branch 'master' into altIsMeta 2018-01-19 12:49:07 -08:00
Daniel Imms 903ec3c910 Merge pull request #1206 from amejia1/master
Fix issue with resizing terminal.
2018-01-19 12:40:18 -08:00
Daniel Imms eb6ff003da Merge branch 'master' into master 2018-01-19 12:34:43 -08:00
Daniel Imms 6e3cd2cb23 Fix indentation 2018-01-19 12:34:32 -08:00
Saad Malik ec8593fe46 Merge branch 'master' into altIsMeta 2018-01-19 12:32:06 -08:00
Saad Malik 891fbd6b80 Mac OSX: altIsMeta support
* Support for altIsMeta option
* Instead of providing third-level shift characters
* Sample demo application using new altIsMeta option
2018-01-19 12:10:39 -08:00
Daniel Imms 39fcbe61c0 Improve announcement on focus 2018-01-19 10:52:03 -08:00
Daniel Imms e4abd4dd8a Move Shared interfaces into a new typings file
This will enable sharing the internal interface with addons (and catching
breakages early)
2018-01-19 09:48:33 -08:00
Daniel Imms 78a63d4860 Simplify interfaces, reduce duplication 2018-01-19 09:48:33 -08:00
Daniel Imms 47df04976c Base ITerminal on interface in .d.ts
Part of #1221
2018-01-19 09:48:33 -08:00
Daniel Imms d33c340de5 Merge pull request #1222 from Tyriar/1220_addon_types
Use Terminal types from xterm.d.ts in Addons
2018-01-19 09:34:44 -08:00
Daniel Imms 57a9948e8d Use Terminal typings in remaining addons
Fixes #1220
2018-01-19 09:30:24 -08:00
Daniel Imms ec17fb9179 Use Terminal type in attach, fit and fullscreen 2018-01-19 09:30:24 -08:00
Daniel Imms 682eb2f861 Use Terminal public API type in search addon
Part of #1220
2018-01-19 09:30:24 -08:00
Daniel Imms a9f69965fe Merge pull request #1223 from zhaojh329/master
Add rtty to the real-world uses section of README
2018-01-18 21:40:55 -08:00
Jianhui Zhao 1f79860aaf Add rtty to the real-world uses section of README
A reverse proxy WebTTY. It is composed of the client and the server.

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
2018-01-19 10:57:51 +08:00
Andres Mejia 5133f25fb7 Fix issue with resetting terminal.
Ensure new BufferSet is used and clear selection manager on reset.
2018-01-18 17:48:29 -05:00
Daniel Imms cfd00529eb Various fixes
- Add buffers being retained on full reset (CIS)
- Remove setup event, simplify
- Only have one trim listener active at once
- Disallow activate events if nothing changed (just in case)
2018-01-18 17:48:29 -05:00
Andres Mejia a9b7ef5dc3 Clear selection manager when the terminal switches its buffer set or buffer. 2018-01-18 17:48:29 -05:00
Andres Mejia 90c8c85c09 Fix issue with resizing terminal.
Need to ensure the active buffer is always being used.
Fixes https://github.com/xtermjs/xterm.js/issues/824 .
2018-01-18 17:48:28 -05:00
Bruno Ribeiro 9f8098c55b Merge branch 'master' into feature-778 2018-01-18 21:10:50 +00:00
Bruno Ribeiro b8f2832ed4 Merge branch 'master' into 1117 2018-01-18 21:10:09 +00:00
Daniel Imms 2f5029205d Merge pull request #1214 from Tyriar/fix_lint
Fix lint, update tslint and add more tslint rules
2018-01-18 12:28:02 -08:00
Daniel Imms 0645fe582f Fix missing space 2018-01-18 12:27:07 -08:00
Daniel Imms 9c4ef2fd86 Merge remote-tracking branch 'origin/master' into fix_lint 2018-01-18 12:11:21 -08:00
Daniel Imms 8d5ed6fc75 Merge pull request #1197 from blink1073/fix-typings
Ship the declaration files
2018-01-18 12:03:33 -08:00
Daniel Imms 1b48f2cd6d Merge branch 'master' into fix-typings 2018-01-18 11:56:10 -08:00
Daniel Imms 15dd1e6bec Merge pull request #1217 from Tyriar/1216_invalidate_cursor
Fix cursor lagging behind when blink is on
2018-01-18 10:54:26 -08:00
Daniel Imms b4b4456225 Merge branch 'master' into 1216_invalidate_cursor 2018-01-18 10:54:18 -08:00
Daniel Imms b89f9666e6 Merge pull request #1218 from Tyriar/travis_osx
Remove OSX from travis
2018-01-18 10:54:02 -08:00
Daniel Imms 2253e666e7 Remove OSX from travis
Builds take too long on free tier
2018-01-18 09:39:32 -08:00
Daniel Imms 777603b5cd Merge branch 'master' into 1216_invalidate_cursor 2018-01-18 09:01:27 -08:00
Daniel Imms 0379ef7bc7 Merge pull request #1215 from markus-oberhumer/ctrl-pageup-pagedown
Add support for modifiers for PageUp / PageDown keys.
2018-01-18 07:58:31 -08:00
Daniel Imms b1beee3595 Fix cursor lagging behind when blink is on
Fixes #1216
2018-01-18 07:54:45 -08:00
Markus F.X.J. Oberhumer 83921c0b26 Add support for modifiers for PageUp / PageDown keys.
This allows using Ctrl-PageUp/Down and Alt-PageUp/Down.
2018-01-18 09:23:05 +01:00
Daniel Imms 0f04f9fbb4 Rotate rows to ensure an item will be read in nav mode when scrolling 2018-01-17 14:10:03 -08:00
Daniel Imms abfa58fca9 Keep track of nav mode focused element 2018-01-17 10:52:12 -08:00
Daniel Imms 4588d15738 Add more tslint rules, fix attach addon 2018-01-17 10:40:42 -08:00
Daniel Imms 307dd0fd68 Add several tslint rules 2018-01-17 10:32:35 -08:00
Daniel Imms 53e1f83bb5 Update tslint, fix lint 2018-01-17 10:23:27 -08:00
Daniel Imms 70236f6818 Fix addon lint 2018-01-17 10:20:04 -08:00
Daniel Imms 78d734117b Support aria posinset and setsize 2018-01-17 09:56:57 -08:00
Daniel Imms f48da12c16 Prevent event propagation when handled by nav mode 2018-01-16 11:24:19 -08:00
Daniel Imms 3fa4b4941f Support nav mode pgup/pgdown/end/home, check boundaries 2018-01-16 11:01:45 -08:00
Daniel Imms 222c42f7ea Expose screen reader and navigation mode on demo/API 2018-01-16 10:29:40 -08:00
Daniel Imms 34eb08952c Fix RenderDebouncer not refreshing whole viewport when asked 2018-01-16 10:26:09 -08:00
Daniel Imms e9b55930d8 Fix test mocks 2018-01-16 10:12:37 -08:00
Daniel Imms 1e9fb8696a Merge remote-tracking branch 'origin/master' into 731_screen_reader 2018-01-16 09:56:19 -08:00
Daniel Imms 5888cd7938 Merge pull request #1210 from Tyriar/1194_initial_cursorBlink
Ensure renderer uses latest options at open
2018-01-16 09:21:39 -08:00
Daniel Imms 0e870d106f Fix search for emojis
Fixes #1103
2018-01-16 07:26:03 -08:00
Daniel Imms 8d3bdad7e4 Fix search for wide unicode
Part of #1103
2018-01-16 07:06:10 -08:00
Daniel Imms f02ead309b Merge branch 'master' into 1194_initial_cursorBlink 2018-01-16 06:45:58 -08:00
Daniel Imms 80f13792a3 Ensure renderer uses latest options at open
Fixes #1194
2018-01-16 06:34:22 -08:00
Paris Kasidiaris 691f8a7567 Merge pull request #1199 from ficristo/umd-addons
Make addons UMD compatible
2018-01-15 22:11:21 +02:00
Daniel Imms 81b4d8fe9c Dispose of NavigationMode when AccessibilityManager is 2018-01-14 13:42:36 -08:00
Daniel Imms 23bd60a733 Properly dispose of disposables 2018-01-14 13:28:43 -08:00
Daniel Imms 85c02f10bf Improve dispoable listener functions 2018-01-14 13:18:00 -08:00
Daniel Imms 70489e5035 Move navigation mode stuff into its own class 2018-01-14 12:59:57 -08:00
ficristo 46f684621c Merge branch 'master' into umd-addons 2018-01-14 20:24:52 +01:00
Daniel Imms adcbb1ae3f Merge pull request #1207 from amejia1/new-use-case
Add use case for atom-xterm.
2018-01-13 20:55:41 -08:00
Andres Mejia a7101b5bcb Add use case for atom-xterm. 2018-01-13 15:34:05 -05:00
Daniel Imms 1e41b11319 Remove logs 2018-01-12 21:15:53 -08:00
Daniel Imms cc80114748 Merge pull request #1205 from jluk/patch-1
Include cloud shell in xterm applications
2018-01-12 17:41:08 -08:00
Justin Luk 5a147f201f Include cloud shell in xterm applications 2018-01-12 15:13:19 -08:00
Daniel Imms 2a187a26e0 Update a11y rows on scroll 2018-01-11 23:15:02 -08:00
Daniel Imms 2311d7d66b Add basic navigation mode support for current viewport 2018-01-11 22:56:19 -08:00
Daniel Imms bbc9a010b9 Listen to dpr change in a11y manager 2018-01-11 09:27:37 -08:00
Bruno Ribeito b75f52734d Use Web audio API 2018-01-08 20:53:26 +00:00
Daniel Imms a19b05f813 Fix bad type check that caused rows to not refresh 2018-01-08 09:53:06 -08:00
ficristo b7c0ca11fe Make addons UMD compatible 2018-01-07 09:02:41 +01:00
Daniel Imms e49d844284 Add note in README about code structure 2018-01-06 13:46:27 -08:00
Daniel Imms d0ef868215 Refactor char atlas to enable generation with worker
This doesn't actually add workers but it separates the code nicely
such that the minimal amount of relevant code can be pulled in by
worker code.

Part of #955
2018-01-06 13:43:34 -08:00
Steven Silvester a36a17928d Ship the declaration files 2018-01-06 07:18:07 -06:00
Daniel Imms 50ed83ca64 Set version to 3.1.0-master
This will make it clear in bug reports etc. when someone is running off
master and not 3.0.
2018-01-05 14:40:41 -08:00
Daniel Imms c46304c716 Merge remote-tracking branch 'origin/master' into 731_screen_reader 2018-01-05 14:28:08 -08:00
Daniel Imms be18507df6 Merge pull request #1172 from Tyriar/1118_dpi_change
Update charatlas when monitor DPI changes
2018-01-05 14:24:12 -08:00
Daniel Imms f6da87f3b4 Merge remote-tracking branch 'origin/master' into 1118_dpi_change 2018-01-05 14:19:21 -08:00
Daniel Imms 248fbccfd9 Remove console.log 2018-01-05 14:18:16 -08:00
Daniel Imms eac14a149f Merge pull request #1144 from Tyriar/880_renderer_pause
Use IntersectionObserver to turn off renderer when hidden
2018-01-05 14:16:10 -08:00
Daniel Imms d90f48b210 Merge branch 'master' into 880_renderer_pause 2018-01-05 14:15:26 -08:00
Daniel Imms eb1110e3f5 Merge pull request #1191 from astefanutti/kubebox
Add Kubebox to real-world uses
2018-01-05 13:35:59 -08:00
Antonin Stefanutti 82e7fe5a1b Add Kubebox to real-world uses 2018-01-05 22:12:32 +01:00
Daniel Imms 1bf084921e Merge branch 'master' into 1117 2018-01-05 11:03:50 -08:00
Daniel Imms 25972d1e06 Merge branch 'master' into feature-778 2018-01-05 11:03:33 -08:00
Daniel Imms b3c8923709 Merge branch 'master' into 1117 2018-01-05 11:03:24 -08:00
Daniel Imms 13d1020308 Merge pull request #1137 from damz/pr/parser-escape-state
Fix parser not resetting state for some escape sequences
2018-01-05 11:02:24 -08:00
Daniel Imms b98f10625f Merge branch 'master' into pr/parser-escape-state 2018-01-05 11:02:14 -08:00
Daniel Imms 09605dba16 Merge pull request #1142 from Tyriar/1067_fix_cursor_on_right
Fix cursor on scroll bar
2018-01-05 11:01:30 -08:00
Daniel Imms 1509f88dbf Merge branch 'master' into 1067_fix_cursor_on_right 2018-01-05 11:01:21 -08:00
Daniel Imms 884c7c631d Merge branch 'master' into 880_renderer_pause 2018-01-05 11:01:06 -08:00
Daniel Imms b66578a4ca Merge branch 'master' into 880_renderer_pause 2018-01-05 11:00:11 -08:00
Daniel Imms b0b6c8d878 Merge branch 'master' into transparency 2018-01-05 10:58:59 -08:00
Daniel Imms 9f1f86c316 Merge pull request #1168 from Tyriar/1152_npe_selection_manager_2
Prevent dragging from setting selection y over bounds
2018-01-05 10:58:40 -08:00
Daniel Imms 80a1c2bd50 Merge branch 'master' into 1152_npe_selection_manager_2 2018-01-05 10:58:22 -08:00
Daniel Imms 09139cc350 Merge pull request #1177 from electerm/add-electerm-use-case
add Real-world use: electerm
2018-01-05 10:56:08 -08:00
Daniel Imms 019eb30b68 Merge pull request #1180 from Tyriar/1179_alt_backspace
Allow alt+backspace to delete a word
2018-01-05 10:55:57 -08:00
Daniel Imms 58f80c404f Merge branch 'master' into add-electerm-use-case 2018-01-05 09:14:37 -08:00
Daniel Imms 22f860536d Merge branch 'master' into add-electerm-use-case 2018-01-05 09:13:55 -08:00
Daniel Imms e9ec1bda3d Merge branch 'master' into 1179_alt_backspace 2018-01-05 09:13:32 -08:00
Daniel Imms 9a743ef301 Merge pull request #1188 from xtermjs/Tyriar-patch-1
Remove repo redirect from package.json
2018-01-05 09:12:44 -08:00
Daniel Imms 0de2d3846a Merge branch 'master' into Tyriar-patch-1 2018-01-05 09:12:30 -08:00
Daniel Imms a490051dda Merge pull request #1190 from Tyriar/fix_typings
Publish typings dir to npm
2018-01-05 08:38:00 -08:00
Daniel Imms edc80acd4d Publish typings dir to npm 2018-01-05 08:32:07 -08:00
Daniel Imms 0dd9b8d025 Remove repo redirect from package.json 2018-01-05 08:20:40 -08:00
Daniel Imms e20d2caa0e Use consistent refresh/render method names 2018-01-05 08:19:30 -08:00
Daniel Imms a846e8c08d Pull render animation frame logic into a helper class 2018-01-05 08:15:21 -08:00
Daniel Imms c332aeb51f Remove obsolete code and resolved TODOs 2018-01-05 07:51:22 -08:00
Daniel Imms bb830eb1ae Rate limit row refresh, tweak live region 2018-01-05 07:39:45 -08:00
Daniel Imms 6d1064fc01 Set height of a11y rows on creation 2018-01-03 10:08:24 -08:00
Daniel Imms 5ca15cfe3b Fix linefeed event
This was causing new lines to join words together
2018-01-03 09:54:06 -08:00
Daniel Imms 17964a517c Add screenReaderMode to typings 2018-01-03 09:28:24 -08:00
Daniel Imms 8cb7a9dabe Merge remote-tracking branch 'origin/v3' into 731_screen_reader 2018-01-03 09:09:42 -08:00
Daniel Imms 0819759814 Allow alt+backspace to delete a word
Fixes #1179
2018-01-02 10:33:17 -08:00
Daniel Imms ecc1055c10 Listen to resolution media query 2018-01-02 10:11:24 -08:00
ZHAO Xudong ac1023dac6 add Real-world use: electerm 2018-01-02 14:45:43 +08:00
Daniel Imms 72d946e089 Use a more robust solution to changing devicePixelRatio 2017-12-29 13:54:01 -08:00
Daniel Imms ef5beb6706 Update charatlas when monitor DPI changes
Fixes #1118
2017-12-29 08:30:13 -08:00
Daniel Imms cf2116ff6a Prevent dragging from setting selection y over bounds
Fixes #1152
2017-12-27 08:08:28 -08:00
Daniel Imms 5dc57a1305 Add detach logic back for mac only 2017-12-20 11:06:32 -08:00
Daniel Imms 0d65cb3f69 Add max rows to read to handle spam case 2017-12-19 16:27:03 -08:00
Daniel Imms ae957ecb3e Get output reading working on Windows, refresh on window resize 2017-12-19 15:48:58 -08:00
Daniel Imms d03f5b0c2a Range of improvements for macOS VoiceOver 2017-12-19 15:16:28 -08:00
Daniel Imms e5d57b08c8 Merge remote-tracking branch 'ups/v3' into 731_screen_reader 2017-12-19 13:28:31 -08:00
Daniel Imms 399779692d Initial prototype 2017-12-19 12:57:58 -08:00
CHaBou 9c5aaed441 Fix some function parameters 2017-12-15 00:02:37 +01:00
CHaBou 9f85790ad1 Add allowTransparency option
Fixes #1004
2017-12-14 22:55:01 +01:00
Daniel Imms 47a50acc55 Use IntersectionObserver to turn off renderer when hidden
Fixes #880
2017-12-11 15:16:13 -08:00
Daniel Imms 616f0f9d36 Fix cursor on scroll bar
Fixes #1067
2017-12-11 10:13:17 -08:00
Damien Tournoud 981da3d9e6 Fix parser not resetting state for some escape sequences 2017-12-02 20:45:23 -08:00
Bruno Ribeito 6822070222 Fix typo + Cleanup logic 2017-11-12 23:15:09 +00:00
Bruno Ribeito 51de968fde Fix non-white colors not being drawn as bold 2017-11-12 23:05:27 +00:00
Bruno Ribeito f12eb5367b Adress feedback 2017-11-12 22:04:10 +00:00
Bruno Ribeito 007410995a Fix#1117 2017-11-12 22:04:10 +00:00
Bruno Ribeito 18b86a1cbc Do the selection even if there is already a selection 2017-11-08 23:27:00 +00:00
Bruno Ribeito 2865d935b6 Adress feedback 2017-11-07 21:21:44 +00:00
Bruno Ribeito 1877e7019d Implement #778 2017-11-06 23:20:57 +00:00
198 changed files with 29193 additions and 19871 deletions
+22
View File
@@ -0,0 +1,22 @@
FROM node:10
# Configure apt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1
# Verify git and process tools are installed
RUN apt-get install -y git procps
# Install yarn
RUN apt-get install -y curl apt-transport-https lsb-release \
&& curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - 2>/dev/null \
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get -y install --no-install-recommends yarn
# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=dialog
+9
View File
@@ -0,0 +1,9 @@
{
"name": "xterm.js",
"dockerFile": "Dockerfile",
"appPort": 3000,
"extensions": [
"editorconfig.editorconfig",
"ms-vscode.vscode-typescript-tslint-plugin"
]
}
-11
View File
@@ -1,11 +0,0 @@
<!-- Enter your issue description here -->
## Details
- Browser and browser version:
- OS version:
- xterm.js version:
### Steps to reproduce
1.
2.
+17
View File
@@ -0,0 +1,17 @@
---
name: Bug report
about: Create a bug report
---
<!-- ⚠️ Please search existing issues to avoid creating duplicates. ⚠️ -->
<!-- Describe the bug here. -->
## Details
- Browser and browser version:
- OS version:
- xterm.js version:
### Steps to reproduce
1.
2.
@@ -0,0 +1,7 @@
---
name: Feature request
about: Suggest a feature or enhancement
---
<!-- ⚠️ Please search existing issues to avoid creating duplicates. ⚠️ -->
<!-- Describe the enhancement here. -->
+8
View File
@@ -0,0 +1,8 @@
---
name: Question
about: The issue tracker is not for questions. Please ask questions on https://stackoverflow.com/questions/tagged/xtermjs
---
🛑 The issue tracker is not for questions 🛑
If you have a question, please ask it on https://stackoverflow.com/questions/tagged/xtermjs.
+4 -7
View File
@@ -12,17 +12,14 @@ npm-debug.log
/.idea/
.env
build/
.vscode/
.DS_Store
fixtures/typings-test/*.js
package-lock.json
# Directories needed for code coverage
/coverage/
coverage/
.nyc_output/
# Keep legacy files out of the repo, this can be removed when we merge v3 into master
# Keep bundled code out of Git
dist/
src/utils/TestUtils.ts
src/xterm.js
# Keep the demo builds out of Git
demo/dist/
+45 -12
View File
@@ -1,16 +1,49 @@
node_modules/
*.swp
.lock-wscript
lib/*.test.js
lib/*.test.js.map
# Blacklist - exclude everything except npm defaults such as LICENSE, etc
*
!*/
# Whitelist - entries to be included must be negated with "!"
!*.js
!*.json
# Whitelist - dist/
!dist/**/*.js
!dist/**/*.js.map
!dist/**/*.css
# Whitelist - lib/
!lib/**/*.d.ts
!lib/**/*.js
!lib/**/*.js.map
!lib/**/*.css
# Whitelist - src/
!src/**/*.ts
!src/**/*.d.ts
!src/**/*.js
!src/**/*.js.map
!src/**/*.css
# Whitelist - typings/
!typings/*.d.ts
# Blacklist - (normal behavior) these will override any whitelist
*.test.ts
*.test.d.ts
*.test.js
*.test.js.map
lib/test/
Makefile.gyp
*.Makefile
*.target.gyp.mk
*.node
example/*.log
docs/
npm-debug.log
/.idea/
.env
.vscode/
bin/
build/
fixtures/
coverage/
demo/
+1
View File
@@ -0,0 +1 @@
package-lock=false
-20
View File
@@ -1,20 +0,0 @@
language: node_js
os:
- linux
- osx
node_js:
- 6
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq update ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq install g++-4.8 ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CXX=g++-4.8 ; fi
- npm install -g npm@5.1.0
env:
matrix:
- NPM_COMMAND=lint
- NPM_COMMAND=test
notifications:
email: false
script: npm run $NPM_COMMAND
after_success: npm run coveralls
+42 -2
View File
@@ -4,7 +4,7 @@
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"name": "Unit Tests",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/mocha",
"windows": {
@@ -13,11 +13,51 @@
"runtimeArgs": [
"--colors",
"--recursive",
"${workspaceRoot}/lib"
"${workspaceRoot}/lib/**/*.test.js"
],
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/lib/**/*.js" ],
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "node",
"request": "launch",
"name": "Integration Tests",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/mocha",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/mocha.cmd"
},
"runtimeArgs": [
"--colors",
"--recursive",
"${workspaceRoot}/lib/**/*.api.js"
],
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/lib/**/*.js" ],
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "chrome",
"request": "launch",
"name": "Demo Client",
"url": "http://127.0.0.1:3000",
"webRoot": "${workspaceFolder}/"
},
{
"type": "node",
"request": "launch",
"name": "Demo Server",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"start-debug"
],
"port": 9229,
"serverReadyAction": {
"action": "openExternally",
"pattern": "App listening to (http://.*?:[0-9]+)"
}
}
]
}
+1 -6
View File
@@ -1,8 +1,3 @@
{
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/build": true,
"**/lib": true
}
"typescript.preferences.quoteStyle": "single"
}
+51
View File
@@ -0,0 +1,51 @@
{
"version": "2.0.0",
"presentation": {
"echo": false,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true
},
"tasks": [
{
"type": "npm",
"script": "test",
"group": "test",
"problemMatcher": []
},
{
"type": "npm",
"script": "watch",
"group": "build",
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "vscode"
}
},
{
"type": "npm",
"script": "start",
"group": "build",
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "vscode"
}
},
{
"label": "Start demo",
"dependsOn": ["npm: watch", "npm: start"],
"group": {
"kind": "build",
"isDefault": true
},
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "vscode"
}
}
]
}
-92
View File
@@ -1,92 +0,0 @@
List of xterm.js contributors. Updated before every release.
Aleksandr Andrienko <aandrienko@codenvy.com>
Aleksandr Andriienko <oandriie@redhat.com>
Alessandro Nadalin <alessandro.nadalin@gmail.com>
Alexander Olsson <noseglid@gmail.com>
Alexey Kontsevoy <alexey@gravitational.com>
Anish Athalye <me@anishathalye.com>
Anthony Lapenna <lapenna.anthony@gmail.com>
Antonis Kalipetis <akalipetis@sourcelair.com>
Anton Skshidlevsky <meefik@gmail.com>
Anton Yurovskykh <anton.yurovskykh@gmail.com>
Artem Arbatskiy <artyom.arbatskiy@gmail.com>
Austin Robertson <austinrobertson@gmail.com>
ayapi <colors.aya@gmail.com>
Ben Hall <ben@benhall.me.uk>
Benjamin Fischer <benjamin.fischer@rwth-aachen.de>
Bill Church <billchurch@users.noreply.github.com>
Bob Reid <bobreid@Bobs-MacBook-Pro.local>
bottleofwater <nison.mael+bottleofwater@gmail.com>
Brian Mock <brian@mockbrian.com>
Bruno Ribeito <b.m.fernandes.ribeiro@gmail.com>
Carson Anderson <carson@betterservers.com>
CHaBou <chabup@delean.fr>
Christian Budde Christensen <budde377@gmail.com>
Christof Marti <chrmarti@microsoft.com>
Christopher Jeffrey <chjjeffrey@gmail.com>
coderaiser <mnemonic.enemy@gmail.com>
Dan Brown <jdanbrown@gmail.com>
Daniel Griffen <daniel@griffen.io>
Daniel Imms <daimms@microsoft.com>
Daniel Risacher <drisacher@gmail.com>
Dan Kaplun <dbkaplun@twitch.tv>
Darin Morrison <freebroccolo@users.noreply.github.com>
dcylabs <dcylabs@gmail.com>
Dominik Csapak <d.csapak@proxmox.com>
Edgar Andrés Margffoy Tuay <andfoy@gmail.com>
Elliot Saba <staticfloat@gmail.com>
Exile <exile@chamber.ee>
Felipe Gasper <felipe@felipegasper.com>
ficristo <ficristo.work@gmail.com>
Gary Ritchie <gary@rstudio.com>
hiro-su <h.sugipon@gmail.com>
Ian Lewis <ianlewis@google.com>
imoses <ido@twiggle.com>
InDieTasten <indietasten@gmail.com>
irokas <akasidiari@inf.uth.gr>
Jakob Gillich <jakob@gillich.me>
Jean Bruenn <himself@jeanbruenn.info>
Jeremy Danyow <jedanyow@microsoft.com>
Joao Moreno <jomo@microsoft.com>
Joao Moreno <mail@joaomoreno.com>
Johannes Zellner <johannes@nebulon.de>
Jon Masters <jon.masters@sky.com>
Jörg Breitbart <jerch@rockborn.de>
Justin Mecham <justin@mecham.me>
Kirill Merkushev <lanwen@yandex.ru>
Luca <LucaT1@users.noreply.github.com>
Lucian Buzzo <lucian.buzzo@gmail.com>
Lukas Drgon <lukas.drgon@gmail.com>
Maël Nison <nison.mael@gmail.com>
Marc Dumais <marc.dumais@ericsson.com>
Martin Chloride <i@martincl2.me>
Martin Koppehel <martin.koppehel@st.ovgu.de>
Martin Wang <jiahaow@ca.ibm.com>
Matt Bierner <matb@microsoft.com>
Michael Irwin <mikesir87@gmail.com>
Mikko Karvonen <mikko.karvonen@arm.com>
mofux <t.zilz@mofux.org>
Nicolas Ramz <nicolas.ramz@gmail.com>
npezza93 <npezza93@gmail.com>
Oleksandr Andriienko <oandriie@redhat.com>
Paris Kasidiaris <pariskasidiaris@gmail.com>
Paris Kasidiaris <paris@sourcelair.com>
Peter Baumgarten <me@peterbaumgarten.com>
Rick Baker <rick@ricktbaker.com>
runarberg <runar@greenqloud.com>
Samuel Williams <samuel.williams@oriontransfer.co.nz>
Saswat Das <saswatds@users.noreply.github.com>
Saul Costa <saul@codevolve.com>
Shuanglei Tao <tsl0922@gmail.com>
Steven Silvester <steven.silvester@ieee.org>
stuicey <stuicey@users.noreply.github.com>
t-amqi <umberos@gmail.com>
Thanasis Daglis <thanasis@sourcelair.com>
thomas <thomas@kreativkonzentrat.de>
Thomas Zilz <t.zilz@mofux.org>
Tine Jozelj <tine.jozelj@outlook.com>
Tyler Jewell <tjewell@codenvy.com>
Vincent Woo <me@vincentwoo.com>
yutaka <shigure@refy.net>
YuviPanda <yuvipanda@gmail.com>
+73
View File
@@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting [@Tyriar](https://twitter.com/Tyriar) or [@pariskasid](https://twitter.com/pariskasid) on Twitter. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
+9 -7
View File
@@ -23,29 +23,31 @@ opening an issue, read these pointers.
- Mention precisely what went wrong. What did you expect to happen? What happened instead? Describe the
exact steps a maintainer has to take to make the problem occur.
- If the problem can not be reproduced in the [demo of xterm.js](README.md#demo), please provide an HTML document that demonstrates the problem.
- If the problem can not be reproduced in the [demo of xterm.js](https://github.com/xtermjs/xterm.js/wiki/Contributing#running-the-demo), please provide an HTML document that demonstrates the problem.
- Be polite. Issues with an indignant or belligerent tone tend to be moved to the
bottom of the pile.
## Contributing code
- Make sure you have a [GitHub account](https://github.com/join)
You can find issues to work on by looking at the [help wanted](https://github.com/xtermjs/xterm.js/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) or [good first issue](https://github.com/xtermjs/xterm.js/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) issues. It's a good idea to comment on the issue saying that you're taking it, just in case someone else comes along and you duplicate work. Once you have your issue, here are the steps to contribute:
- Fork [xterm.js](https://github.com/sourcelair/xterm.js/)
([how to fork a repo](https://help.github.com/articles/fork-a-repo))
- Make your changes
([how to fork a repo](https://help.github.com/articles/fork-a-repo)).
- Get the [xterm.js demo](https://github.com/xtermjs/xterm.js/wiki/Contributing#running-the-demo) running.
- Make your changes.
- If your changes are easy to test or likely to regress, add tests. Tests go into `test`, directory.
- Follow the general code style of the rest of the project (see below).
- Submit a pull request
([how to create a pull request](https://help.github.com/articles/fork-a-repo)).
Don't put more than one feature/fix in a single pull request.
By contributing code to xterm.js you
By contributing code to xterm.js you:
- agree to license the contributed code under xterm.js' [MIT
- Agree to license the contributed code under xterm.js' [MIT
license](LICENSE).
- confirm that you have the right to contribute and license the code
- Confirm that you have the right to contribute and license the code
in question. (Either you hold all rights on the code, or the rights
holder has explicitly granted the right to use it like this,
through a compatible open source license or through a direct
+1 -1
View File
@@ -1,4 +1,4 @@
FROM node:6
FROM node:8
MAINTAINER Paris Kasidiaris <paris@sourcelair.com>
# Set the working directory
+1
View File
@@ -1,3 +1,4 @@
Copyright (c) 2017-2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
Copyright (c) 2014-2016, SourceLair Private Company (https://www.sourcelair.com)
Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/)
+1
View File
@@ -1 +1,2 @@
web: npm start
webpack: npm run watch
+91 -67
View File
@@ -1,33 +1,33 @@
# [![xterm.js logo](logo-full.png)](https://xtermjs.org)
[![xterm.js build status](https://api.travis-ci.org/xtermjs/xterm.js.svg)](https://travis-ci.org/xtermjs/xterm.js) [![Coverage Status](https://coveralls.io/repos/github/sourcelair/xterm.js/badge.svg)](https://coveralls.io/github/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) [![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/xterm/badge?style=rounded)](https://www.jsdelivr.com/package/npm/xterm)
[![Build Status](https://dev.azure.com/xtermjs/xterm.js/_apis/build/status/xtermjs.xterm.js)](https://dev.azure.com/xtermjs/xterm.js/_build/latest?definitionId=3)
[![Coverage Status](https://coveralls.io/repos/github/xtermjs/xterm.js/badge.svg?branch=master)](https://coveralls.io/github/xtermjs/xterm.js?branch=master)
Xterm.js is a terminal front-end component written in JavaScript that works in the browser.
It enables applications to provide fully featured terminals to their users and create great development experiences.
Xterm.js is a front-end component written in TypeScript that lets applications bring fully-featured terminals to their users in the browser. It's used by popular projects such as VS Code, Hyper and Theia.
## 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
- **Terminal apps just work**: Xterm.js works with most terminal apps such as `bash`, `vim` and `tmux`, this includes support for curses-based apps and mouse event support.
- **Perfomant**: Xterm.js is *really* fast, it even includes a GPU-accelerated renderer.
- **Rich unicode support**: Supports CJK, emojis and IMEs.
- **Self-contained**: Requires zero dependencies to work.
- **Accessible**: Screen reader support can be turned on using the `screenReaderMode` option.
- **And much more**: Links, theming, addons, well documented API, etc.
## 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)
- 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).
## Getting Started
First you need to install the module, we ship exclusively through [npm](https://www.npmjs.com/) so you need that installed and then add xterm.js as a dependency by running:
```
npm install
npm install xterm
```
To start using xterm.js on your browser, add the `xterm.js` and `xterm.css` to the head of your html page. Then create a `<div id="terminal"></div>` onto which xterm can attach itself.
To start using xterm.js on your browser, add the `xterm.js` and `xterm.css` to the head of your html page. Then create a `<div id="terminal"></div>` onto which xterm can attach itself. Finally instantiate the `Terminal` object and then call the `open` function with the DOM object of the `div`.
```html
<!doctype html>
@@ -39,43 +39,52 @@ To start using xterm.js on your browser, add the `xterm.js` and `xterm.css` to t
<body>
<div id="terminal"></div>
<script>
var term = new Terminal();
var term = new Terminal();
term.open(document.getElementById('terminal'));
term.write('Hello from \033[1;3;31mxterm.js\033[0m $ ')
term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ')
</script>
</body>
</html>
```
Finally instantiate the `Terminal` object and then call the `open` function with the DOM object of the `div`.
### Importing
The proposed way to load xterm.js is via the ES6 module syntax.
The recommended way to load xterm.js is via the ES6 module syntax:
```javascript
import { Terminal } from 'xterm';
```
*Note: There are currently no typings for addons so you will need to upcast if using TypeScript, eg. `(<any>xterm).fit()`.*
### Addons
Addons are JavaScript modules that extend the `Terminal` prototype with new methods and attributes to provide additional functionality. There are a handful available in the main repository in the `src/addons` directory and you can even write your own, by using xterm.js' public API.
Addons are JavaScript modules that extend the `Terminal` prototype with new methods and attributes to provide additional functionality. There are a handful available in the main repository in the `src/addons` directory and you can even write your own by using the [public API](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts).
To use an addon, just import the JavaScript module and pass it to `Terminal`'s `applyAddon` method:
```javascript
import { Terminal } from xterm;
import { Terminal } from 'xterm';
import * as fit from 'xterm/lib/addons/fit/fit';
Terminal.applyAddon(fit);
var xterm = new Terminal(); // Instantiate the terminal
xterm.fit(); // Use the `fit` method, provided by the `fit` addon
```
You will also need to include the addon's CSS file if it has one in the folder.
#### Importing Addons in TypeScript
There are currently no typings for addons if they are accessed via extending Terminal prototype, so you will need to upcast if using TypeScript, eg. `(xterm as any).fit()`. Alternatively, you can import the addon function and enhance the terminal on demand. This has better typing support and is friendly to treeshaking.
```typescript
import { Terminal } from 'xterm';
import { fit } from 'xterm/lib/addons/fit/fit';
const xterm = new Terminal();
fit(xterm); // Fit the terminal when necessary
```
## 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:
@@ -86,22 +95,28 @@ Since xterm.js is typically implemented as a developer tool, only modern browser
- Safari latest
- IE11
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.
Xterm.js works seamlessly in [Electron](https://electronjs.org/) apps and may even work on earlier versions of the browsers, these are the versions we strive to keep working.
## API
The full API for xterm.js is contained within the [TypeScript declaration file](https://github.com/xtermjs/xterm.js/blob/master/typings/xterm.d.ts), use the branch/tag picker in GitHub (`w`) to navigate to the correct version of the API.
Note that some APIs are marked *experimental*, these are added to enable experimentation with new ideas without committing to support it like a normal [semver](https://semver.org/) API. Note that these APIs can change radically between versions so be sure to read release notes if you plan on using experimental APIs.
## 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
- [**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.
- [**Katacoda**](https://www.katacoda.com/): Katacoda is an Interactive Learning Platform for software developers, covering the latest Cloud Native technologies.
- [**Eclipse Che**](http://www.eclipse.org/che): Developer workspace server, cloud IDE, and Eclipse next-generation IDE.
- [**Codenvy**](http://www.codenvy.com): Cloud workspaces for development teams.
- [**CoderPad**](https://coderpad.io): Online interviewing platform for programmers. Run code in many programming languages, with results displayed by `xterm.js`.
- [**WebSSH2**](https://github.com/billchurch/WebSSH2): A web based SSH2 client using `xterm.js`, socket.io, and ssh2.
- [**CoderPad**](https://coderpad.io): Online interviewing platform for programmers. Run code in many programming languages, with results displayed by xterm.js.
- [**WebSSH2**](https://github.com/billchurch/WebSSH2): A web based SSH2 client using xterm.js, socket.io, and ssh2.
- [**Spyder Terminal**](https://github.com/spyder-ide/spyder-terminal): A full fledged system terminal embedded on Spyder IDE.
- [**Cloud Commander**](https://cloudcmd.io "Cloud Commander"): Orthodox web file manager with console and editor.
- [**Codevolve**](https://www.codevolve.com "Codevolve"): Online platform for interactive coding and web development courses. Live container-backed terminal uses `xterm.js`.
- [**Codevolve**](https://www.codevolve.com "Codevolve"): Online platform for interactive coding and web development courses. Live container-backed terminal uses xterm.js.
- [**RStudio**](https://www.rstudio.com/products/RStudio "RStudio"): RStudio is an integrated development environment (IDE) for R.
- [**Terminal for Atom**](https://github.com/jsmecham/atom-terminal-tab): A simple terminal for the Atom text editor.
- [**Eclipse Orion**](https://orionhub.org): A modern, open source software development environment that runs in the cloud. Code, deploy and run in the cloud.
@@ -109,60 +124,69 @@ Xterm.js is used in several world-class applications to provide great terminal e
- [**Hexlet**](https://en.hexlet.io): Practical programming courses (JavaScript, PHP, Unix, databases, functional programming). A steady path from the first line of code to the first job.
- [**Selenoid UI**](https://github.com/aerokube/selenoid-ui): Simple UI for the scallable golang implementation of Selenium Hub named Selenoid. We use XTerm for streaming logs over websockets from docker containers.
- [**Portainer**](https://portainer.io): Simple management UI for Docker.
- [**SSHy**](https://github.com/stuicey/SSHy): HTML5 Based SSHv2 Web Client with E2E encryption utilising `xterm.js`, SJCL & websockets.
- [**JupyterLab**](https://github.com/jupyterlab/jupyterlab): An extensible
computational environment for Jupyter, supporting interactive data science and scientific computing across all programming languages.
- [**SSHy**](https://github.com/stuicey/SSHy): HTML5 Based SSHv2 Web Client with E2E encryption utilising xterm.js, SJCL & websockets.
- [**JupyterLab**](https://github.com/jupyterlab/jupyterlab): An extensible computational environment for Jupyter, supporting interactive data science and scientific computing across all programming languages.
- [**Theia**](https://github.com/theia-ide/theia): Theia is a cloud & desktop IDE framework implemented in TypeScript.
- [**Opshell**](https://github.com/ricktbaker/opshell) Ops Helper tool to make life easier working with AWS instances across multiple organizations.
- [**Proxmox VE**](https://www.proxmox.com/en/proxmox-ve): Proxmox VE is a complete open-source platform for enterprise virtualization. It uses xterm.js for container terminals and the host shell.
- [**Script Runner**](https://github.com/ioquatix/script-runner): Run scripts (or a shell) in Atom.
- [**Whack Whack Terminal**](https://github.com/Microsoft/WhackWhackTerminal): Terminal emulator for Visual Studio 2017.
- [**VTerm**](https://github.com/vterm/vterm): Extensible terminal emulator based on Electron and React.
- [**electerm**](http://electerm.html5beta.com): electerm is a terminal/ssh/sftp client(mac, win, linux) based on electron/node-pty/xterm.
- [**Kubebox**](https://github.com/astefanutti/kubebox): Terminal console for Kubernetes clusters.
- [**Azure Cloud Shell**](https://shell.azure.com): Azure Cloud Shell is a Microsoft-managed admin machine built on Azure, for Azure.
- [**atom-xterm**](https://atom.io/packages/atom-xterm): Atom plugin for providing terminals inside your Atom workspace.
- [**rtty**](https://github.com/zhaojh329/rtty): Access your terminals from anywhere via the web.
- [**Pisth**](https://github.com/ColdGrub1384/Pisth): An SFTP and SSH client for iOS.
- [**abstruse**](https://github.com/bleenco/abstruse): Abstruse CI is a continuous integration platform based on Node.JS and Docker.
- [**Azure Data Studio**](https://github.com/Microsoft/azuredatastudio): A data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.
- [**FreeMAN**](https://github.com/matthew-matvei/freeman): A free, cross-platform file manager for power users.
- [**Fluent Terminal**](https://github.com/felixse/FluentTerminal): A terminal emulator based on UWP and web technologies.
- [**Hyper**](https://hyper.is): A terminal built on web technologies.
- [**Diag**](https://diag.ai): A better way to troubleshoot problems faster. Capture, share and reapply troubleshooting knowledge so you can focus on solving problems that matter.
- [**GoTTY**](https://github.com/yudai/gotty): A simple command line tool that shares your terminal as a web application based on xterm.js.
- [**genact**](https://github.com/svenstaro/genact): A nonsense activity generator.
- [**cPanel & WHM**](https://cpanel.com): The hosting platform of choice.
- [**Nutanix**](https://github.com/nutanix): Nutanix Enterprise Cloud uses xterm in the webssh functionality within Nutanix Calm, and is also looking to move our old noserial (termjs) functionality to xterm.js.
- [**SSH Web Client**](https://github.com/roke22/PHP-SSH2-Web-Client): SSH Web Client with PHP.
- [**Shellvault**](https://www.shellvault.io): The cloud-based SSH terminal you can access from anywhere.
- [**Juno**](http://junolab.org/): A flexible Julia IDE, based on Atom.
- [**webssh**](https://github.com/huashengdun/webssh): Web based ssh client.
- [**info-beamer hosted**](https://info-beamer.com): Uses xterm.js to manage digital signage devices from the web dashboard.
- [**Jumpserver**](https://github.com/jumpserver/luna): Jumpserver Luna project, Jumpserver is a bastion server project, Luna use xterm.js for web terminal emulation.
- [**LxdMosaic**](https://github.com/turtle0x1/LxdMosaic): Uses xterm.js to give terminal access to containers through LXD
- [**CodeInterview.io**](https://codeinterview.io): A coding interview platform in 25+ languages and many web frameworks. Uses xterm.js to provide shell access.
- [**Bastillion**](https://www.bastillion.io): Bastillion is an open-source web-based SSH console that centrally manages administrative access to systems.
- [**PHP App Server**](https://github.com/cubiclesoft/php-app-server/): Create lightweight, installable almost-native applications for desktop OSes. ExecTerminal (nicely wraps the xterm.js Terminal), TerminalManager, and RunProcessSDK are self-contained, reusable ES5+ compliant Javascript components.
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.
[And much more...](https://github.com/xtermjs/xterm.js/network/dependents)
## Demo
### Linux or macOS
First, be sure that a C++ compiler such as GCC-C++ or Clang is installed, then run these commands:
```
npm install
npm start
```
Then open http://0.0.0.0:3000 in a web browser.
### Windows
First, ensure [node-gyp](https://github.com/nodejs/node-gyp) is installed and configured correctly, then run these commands.
```
npm install
npm start
```
Then open http://127.0.0.1:3000 in a web browser.
*Note: Do not use ConEmu, as it seems to break the demo for some reason.*
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. Note: Please add any new contributions to the end of the list only.
## 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).
All current and past releases are available on this repo's [Releases page](https://github.com/sourcelair/xterm.js/releases), you can view the [high-level roadmap on the wiki](https://github.com/xtermjs/xterm.js/wiki/Roadmap) and see what we're working on now by looking through [Milestones](https://github.com/sourcelair/xterm.js/milestones).
## Development and Contribution
### Beta builds
Xterm.js is maintained by [SourceLair](https://www.sourcelair.com/) and a few external contributors, but we would love to receive contributions from everyone!
Our CI releases beta builds to npm for every change that goes into master, install the latest beta build with:
To contribute either code, documentation or issues to xterm.js please read the [Contributing document](CONTRIBUTING.md) beforehand. The development of xterm.js does not require any special tool. All you need is an editor that supports JavaScript/TypeScript and a browser. You will need Node.js installed locally to get all the features working in the demo.
```
npm install -S xterm@beta
```
These should generally be stable but some bugs may slip in, we recommend using the beta build primarily to test out new features and for verifying bug fixes.
## Contributing
You can read the [guide on the wiki](https://github.com/xtermjs/xterm.js/wiki/Contributing) to learn how to contribute and setup xterm.js for development.
## License Agreement
If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work.
Copyright (c) 2014-2017, SourceLair, Private Company ([www.sourcelair.com](https://www.sourcelair.com/home)) (MIT License)
Copyright (c) 2017-2019, [The xterm.js authors](https://github.com/xtermjs/xterm.js/graphs/contributors) (MIT License)<br>
Copyright (c) 2014-2017, SourceLair, Private Company ([www.sourcelair.com](https://www.sourcelair.com/home)) (MIT License)<br>
Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
+115
View File
@@ -0,0 +1,115 @@
# Node.js
# Build a general Node.js application with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/vsts/pipelines/languages/javascript
jobs:
- job: Linux
pool:
vmImage: 'ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs:
versionSpec: "1.9.4"
displayName: 'Install Yarn'
- script: |
yarn
displayName: 'Install dependencies and build'
- script: |
yarn mocha
displayName: 'Unit tests'
- script: |
yarn lint
displayName: 'Lint'
- job: macOS
pool:
vmImage: 'xcode9-macos10.13'
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
- script: |
yarn
displayName: 'Install dependencies and build'
- script: |
yarn mocha
displayName: 'Unit tests'
- script: |
yarn lint
displayName: 'Lint'
- script: |
yarn test-coverage
export COVERALLS_GIT_BRANCH=$BUILD_SOURCEBRANCHNAME
yarn coveralls
displayName: 'Generate and publish coverage'
- job: Windows
pool:
vmImage: 'vs2017-win2016'
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
- script: |
yarn
displayName: 'Install dependencies and build'
- script: |
yarn mocha
displayName: 'Unit tests'
- script: |
yarn lint
displayName: 'Lint'
- job: IntegrationTests
pool:
vmImage: 'ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs:
versionSpec: "1.9.4"
displayName: 'Install Yarn'
- script: |
yarn
displayName: 'Install dependencies and build'
- script: |
yarn start &
sleep 10
yarn test-api --headless
displayName: 'Integration tests'
- job: Release
dependsOn:
- Linux
- macOS
- Windows
- IntegrationTests
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/release/*')))
pool:
vmImage: 'ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs:
versionSpec: "1.9.4"
displayName: 'Install Yarn'
- script: |
yarn
BUILD_DIR=dist npm run build
displayName: 'Install dependencies and build'
- script: |
NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./bin/publish.js
displayName: 'Publish to npm'
-7
View File
@@ -1,7 +0,0 @@
#! /usr/bin/env sh
tail --lines=+3 AUTHORS > AUTHORS.tmp
git log --format='%aN <%aE>' >> AUTHORS.tmp
echo "List of xterm.js contributors. Updated before every release.\n" > AUTHORS
sort -u AUTHORS.tmp >> AUTHORS
rm -f AUTHORS.tmp
-27
View File
@@ -1,27 +0,0 @@
#! /usr/bin/env sh
# 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 \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
# Build xterm.js into `dist`
export BUILD_DIR=dist
npm run build
# Update AUTHORS file
sh bin/generate-authors
# Update version in package.json
sed -i "s/\"version\": \"$CURRENT_PACKAGE_JSON_VERSION\"/\"version\": \"$NEW_VERSION\"/g" package.json
git commit -S -s -a -m "Bump version to $NEW_VERSION"
git tag $NEW_VERSION
+63
View File
@@ -0,0 +1,63 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const packageJson = require('../package.json');
// Setup auth
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);
// Determine if this is a stable or beta release
const publishedVersions = getPublishedVersions();
const isStableRelease = publishedVersions.indexOf(packageJson.version) === -1;
// Get the next version
let nextVersion = isStableRelease ? packageJson.version : getNextBetaVersion();
console.log(`Publishing version: ${nextVersion}`);
// Set the version in package.json
const packageJsonFile = path.resolve(__dirname, '..', 'package.json');
packageJson.version = nextVersion;
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
// Publish
const args = ['publish'];
if (!isStableRelease) {
args.push('--tag', 'beta');
}
const result = cp.spawn('npm', args, { stdio: 'inherit' });
result.on('exit', code => process.exit(code));
function getNextBetaVersion() {
if (!/^[0-9]+\.[0-9]+\.[0-9]+$/.exec(packageJson.version)) {
console.error('The package.json version must be of the form x.y.z');
process.exit(1);
}
const tag = 'beta';
const stableVersion = packageJson.version.split('.');
const nextStableVersion = `${stableVersion[0]}.${parseInt(stableVersion[1]) + 1}.0`;
const publishedVersions = getPublishedVersions(nextStableVersion, tag);
if (publishedVersions.length === 0) {
return `${nextStableVersion}-${tag}1`;
}
const latestPublishedVersion = publishedVersions.sort((a, b) => {
const aVersion = parseInt(a.substr(a.search(/[0-9]+$/)));
const bVersion = parseInt(b.substr(b.search(/[0-9]+$/)));
return aVersion > bVersion ? -1 : 1;
})[0];
const latestTagVersion = parseInt(latestPublishedVersion.substr(latestPublishedVersion.search(/[0-9]+$/)), 10);
return `${nextStableVersion}-${tag}${latestTagVersion + 1}`;
}
function getPublishedVersions(version, tag) {
const versionsProcess = cp.spawnSync('npm', ['view', packageJson.name, 'versions', '--json']);
const versionsJson = JSON.parse(versionsProcess.stdout);
if (tag) {
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}[0-9]+`)));
}
return versionsJson;
}
-22
View File
@@ -1,22 +0,0 @@
#! /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
-88
View File
@@ -1,88 +0,0 @@
var express = require('express');
var app = express();
var expressWs = require('express-ws')(app);
var os = require('os');
var pty = require('node-pty');
var terminals = {},
logs = {};
app.use('/build', express.static(__dirname + '/../build'));
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
app.get('/style.css', function(req, res){
res.sendFile(__dirname + '/style.css');
});
app.get('/dist/bundle.js', function(req, res){
res.sendFile(__dirname + '/dist/bundle.js');
});
app.get('/dist/bundle.js.map', function(req, res){
res.sendFile(__dirname + '/dist/bundle.js.map');
});
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);
} catch (ex) {
// The WebSocket is not open, ignore
}
});
ws.on('message', function(msg) {
term.write(msg);
});
ws.on('close', function () {
term.kill();
console.log('Closed terminal ' + term.pid);
// Clean things up
delete terminals[term.pid];
delete logs[term.pid];
});
});
var port = process.env.PORT || 3000,
host = os.platform() === 'win32' ? '127.0.0.1' : '0.0.0.0';
console.log('App listening to http://' + host + ':' + port);
app.listen(port, host);
+304
View File
@@ -0,0 +1,304 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*
* This file is the entry point for browserify.
*/
/// <reference path="../typings/xterm.d.ts"/>
import { Terminal } from '../lib/public/Terminal';
import { AttachAddon } from 'xterm-addon-attach';
import { SearchAddon, ISearchOptions } from 'xterm-addon-search';
import { WebLinksAddon } from 'xterm-addon-web-links';
import * as fit from '../lib/addons/fit/fit';
// Pulling in the module's types relies on the <reference> above, it's looks a
// little weird here as we're importing "this" module
import { Terminal as TerminalType, ITerminalOptions } from 'xterm';
export interface IWindowWithTerminal extends Window {
term: TerminalType;
Terminal?: typeof TerminalType;
}
declare let window: IWindowWithTerminal;
Terminal.applyAddon(fit);
let term;
let searchAddon: SearchAddon;
let protocol;
let socketURL;
let socket;
let pid;
const terminalContainer = document.getElementById('terminal-container');
const actionElements = {
findNext: <HTMLInputElement>document.querySelector('#find-next'),
findPrevious: <HTMLInputElement>document.querySelector('#find-previous')
};
const paddingElement = <HTMLInputElement>document.getElementById('padding');
function setPadding(): void {
term.element.style.padding = parseInt(paddingElement.value, 10).toString() + 'px';
term.fit();
}
function getSearchOptions(): ISearchOptions {
return {
regex: (document.getElementById('regex') as HTMLInputElement).checked,
wholeWord: (document.getElementById('whole-word') as HTMLInputElement).checked,
caseSensitive: (document.getElementById('case-sensitive') as HTMLInputElement).checked
};
}
const disposeRecreateButtonHandler = () => {
// If the terminal exists dispose of it, otherwise recreate it
if (term) {
term.dispose();
term = null;
window.term = null;
socket = null;
document.getElementById('dispose').innerHTML = 'Recreate Terminal';
}
else {
createTerminal();
document.getElementById('dispose').innerHTML = 'Dispose terminal';
}
};
if (document.location.pathname === '/test') {
window.Terminal = Terminal;
} else {
createTerminal();
document.getElementById('dispose').addEventListener('click', disposeRecreateButtonHandler);
}
function createTerminal(): void {
// Clean terminal
while (terminalContainer.children.length) {
terminalContainer.removeChild(terminalContainer.children[0]);
}
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].indexOf(navigator.platform) >= 0;
term = new Terminal({
windowsMode: isWindows
} as ITerminalOptions);
// Load addons
const typedTerm = term as TerminalType;
typedTerm.loadAddon(new WebLinksAddon());
searchAddon = new SearchAddon();
typedTerm.loadAddon(searchAddon);
window.term = term; // Expose `term` to window for debugging purposes
term.onResize((size: { cols: number, rows: number }) => {
if (!pid) {
return;
}
const cols = size.cols;
const rows = size.rows;
const 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) : '') + '/terminals/';
term.open(terminalContainer);
term.fit();
term.focus();
addDomListener(paddingElement, 'change', setPadding);
addDomListener(actionElements.findNext, 'keyup', (e) => {
const searchOptions = getSearchOptions();
searchOptions.incremental = e.key !== `Enter`;
searchAddon.findNext(actionElements.findNext.value, searchOptions);
});
addDomListener(actionElements.findPrevious, 'keyup', (e) => {
if (e.key === `Enter`) {
searchAddon.findPrevious(actionElements.findPrevious.value, getSearchOptions());
}
});
// fit is called within a setTimeout, cols and rows need this.
setTimeout(() => {
initOptions(term);
// TODO: Clean this up, opt-cols/rows doesn't exist anymore
(<HTMLInputElement>document.getElementById(`opt-cols`)).value = term.cols;
(<HTMLInputElement>document.getElementById(`opt-rows`)).value = term.rows;
paddingElement.value = '0';
// Set terminal size again to set the specific dimensions on the demo
updateTerminalSize();
fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => {
res.text().then((processId) => {
pid = processId;
socketURL += processId;
socket = new WebSocket(socketURL);
socket.onopen = runRealTerminal;
socket.onclose = runFakeTerminal;
socket.onerror = runFakeTerminal;
});
});
}, 0);
}
function runRealTerminal(): void {
/**
* The demo defaults to string transport by default.
* To run it with UTF8 binary transport, swap comment on
* the lines below. (Must also be switched in server.js)
*/
term.loadAddon(new AttachAddon(socket));
// term.loadAddon(new AttachAddon(socket, {inputUtf8: true}));
term._initialized = true;
}
function runFakeTerminal(): void {
if (term._initialized) {
return;
}
term._initialized = true;
term.prompt = () => {
term.write('\r\n$ ');
};
term.writeln('Welcome to xterm.js');
term.writeln('This is a local terminal emulation, without a real terminal in the back-end.');
term.writeln('Type some keys and commands to play around.');
term.writeln('');
term.prompt();
term.onKey((e: { key: string, domEvent: KeyboardEvent }) => {
const ev = e.domEvent;
const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey;
if (ev.keyCode === 13) {
term.prompt();
} else if (ev.keyCode === 8) {
// Do not delete the prompt
if (term._core.buffer.x > 2) {
term.write('\b \b');
}
} else if (printable) {
term.write(e.key);
}
});
}
function initOptions(term: TerminalType): void {
const blacklistedOptions = [
// Internal only options
'cancelEvents',
'convertEol',
'debug',
'handler',
'screenKeys',
'termName',
'useFlowControl',
// Complex option
'theme'
];
const stringOptions = {
bellSound: null,
bellStyle: ['none', 'sound'],
cursorStyle: ['block', 'underline', 'bar'],
experimentalCharAtlas: ['none', 'static', 'dynamic'],
fontFamily: null,
fontWeight: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
fontWeightBold: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
rendererType: ['dom', 'canvas']
};
const options = Object.keys((<any>term)._core.options);
const booleanOptions = [];
const numberOptions = [];
options.filter(o => blacklistedOptions.indexOf(o) === -1).forEach(o => {
switch (typeof term.getOption(o)) {
case 'boolean':
booleanOptions.push(o);
break;
case 'number':
numberOptions.push(o);
break;
default:
if (Object.keys(stringOptions).indexOf(o) === -1) {
console.warn(`Unrecognized option: "${o}"`);
}
}
});
let html = '';
html += '<div class="option-group">';
booleanOptions.forEach(o => {
html += `<div class="option"><label><input id="opt-${o}" type="checkbox" ${term.getOption(o) ? 'checked' : ''}/> ${o}</label></div>`;
});
html += '</div><div class="option-group">';
numberOptions.forEach(o => {
html += `<div class="option"><label>${o} <input id="opt-${o}" type="number" value="${term.getOption(o)}" step="${o === 'lineHeight' ? '0.1' : '1'}"/></label></div>`;
});
html += '</div><div class="option-group">';
Object.keys(stringOptions).forEach(o => {
if (stringOptions[o]) {
html += `<div class="option"><label>${o} <select id="opt-${o}">${stringOptions[o].map(v => `<option ${term.getOption(o) === v ? 'selected' : ''}>${v}</option>`).join('')}</select></label></div>`;
} else {
html += `<div class="option"><label>${o} <input id="opt-${o}" type="text" value="${term.getOption(o)}"/></label></div>`;
}
});
html += '</div>';
const container = document.getElementById('options-container');
container.innerHTML = html;
// Attach listeners
booleanOptions.forEach(o => {
const input = <HTMLInputElement>document.getElementById(`opt-${o}`);
addDomListener(input, 'change', () => {
console.log('change', o, input.checked);
term.setOption(o, input.checked);
});
});
numberOptions.forEach(o => {
const input = <HTMLInputElement>document.getElementById(`opt-${o}`);
addDomListener(input, 'change', () => {
console.log('change', o, input.value);
if (o === 'cols' || o === 'rows') {
updateTerminalSize();
} else if (o === 'lineHeight') {
term.setOption(o, parseFloat(input.value));
updateTerminalSize();
} else {
term.setOption(o, parseInt(input.value));
}
});
});
Object.keys(stringOptions).forEach(o => {
const input = <HTMLInputElement>document.getElementById(`opt-${o}`);
addDomListener(input, 'change', () => {
console.log('change', o, input.value);
term.setOption(o, input.value);
});
});
}
function addDomListener(element: HTMLElement, type: string, handler: (...args: any[]) => any): void {
element.addEventListener(type, handler);
term._core.register({ dispose: () => element.removeEventListener(type, handler) });
}
function updateTerminalSize(): void {
const cols = parseInt((<HTMLInputElement>document.getElementById(`opt-cols`)).value, 10);
const rows = parseInt((<HTMLInputElement>document.getElementById(`opt-rows`)).value, 10);
const width = (cols * term._core._renderCoordinator.dimensions.actualCellWidth + term._core.viewport.scrollBarWidth).toString() + 'px';
const height = (rows * term._core._renderCoordinator.dimensions.actualCellHeight).toString() + 'px';
terminalContainer.style.width = width;
terminalContainer.style.height = height;
term.fit();
}
+38 -67
View File
@@ -1,70 +1,41 @@
<!doctype html>
<html>
<head>
<title>xterm.js demo</title>
<link rel="stylesheet" href="/build/xterm.css" />
<link rel="stylesheet" href="/build/addons/fullscreen/fullscreen.css" />
<link rel="stylesheet" href="style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.1.1/es6-promise.auto.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
</head>
<body>
<h1>xterm.js: xterm, in the browser</h1>
<div id="terminal-container"></div>
<div>
<h2>Actions</h2>
<p>
<label>Find next <input id="find-next"/></label>
<label>Find previous <input id="find-previous"/></label>
</p>
</div>
<div>
<h2>Options</h2>
<p>
<label><input type="checkbox" id="option-cursor-blink"> cursorBlink</label>
</p>
<p>
<label>
cursorStyle
<select id="option-cursor-style">
<option value="block">block</option>
<option value="underline">underline</option>
<option value="bar">bar</option>
</select>
</label>
</p>
<p>
<label>
bellStyle
<select id="option-bell-style">
<option value="">none</option>
<option value="sound">sound</option>
<option value="visual">visual</option>
<option value="both">both</option>
</select>
</label>
</p>
<p>
<label>scrollback <input type="number" id="option-scrollback" value="1000" /></label>
</p>
<p>
<label>tabStopWidth <input type="number" id="option-tabstopwidth" value="8" /></label>
</p>
<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="dist/bundle.js" defer ></script>
</body>
<head>
<title>xterm.js demo</title>
<link rel="shortcut icon" type="image/png" href="/logo.png">
<link rel="stylesheet" href="/src/xterm.css" />
<link rel="stylesheet" href="style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.1.1/es6-promise.auto.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
</head>
<body>
<h1 style="color: #2D2E2C">xterm.js: A terminal for the <em style="color: #5DA5D5">web</em></h1>
<div id="terminal-container"></div>
<div>
<h3>Actions</h3>
<p>
<label>Find next <input id="find-next"/></label>
<label>Find previous <input id="find-previous"/></label>
<label>Use regex<input type="checkbox" id="regex"/></label>
<label>Case sensitive<input type="checkbox" id="case-sensitive"/></label>
<label>Whole word<input type="checkbox" id="whole-word"/></label>
</p>
</div>
<div>
<h3>Options</h3>
<p>These options can be set in the <code>Terminal</code> constructor or using the <code>Terminal.setOption</code> function.</p>
<div id="options-container"></div>
</div>
<div>
<h3>Style</h3>
<div style="display: inline-block; margin-right: 16px;">
<label for="padding">Padding</label>
<input type="number" id="padding" />
</div>
</div>
<hr/>
<p><strong>Attention:</strong> The demo is a barebones implementation and is designed for the development and evaluation of xterm.js only. Exposing the demo to the public as is would introduce security risks for the host.</p>
<button id="dispose" title="This is used to testing memory leaks">Dispose terminal</button>
<script src="dist/client-bundle.js" defer ></script>
</body>
</html>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

-179
View File
@@ -1,179 +0,0 @@
import * as Terminal from '../build/xterm';
import * as attach from '../build/addons/attach/attach';
import * as fit from '../build/addons/fit/fit';
import * as fullscreen from '../build/addons/fullscreen/fullscreen';
import * as search from '../build/addons/search/search';
import * as winptyCompat from '../build/addons/winptyCompat/winptyCompat';
Terminal.applyAddon(attach);
Terminal.applyAddon(fit);
Terminal.applyAddon(fullscreen);
Terminal.applyAddon(search);
Terminal.applyAddon(winptyCompat);
var term,
protocol,
socketURL,
socket,
pid;
var terminalContainer = document.getElementById('terminal-container'),
actionElements = {
findNext: document.querySelector('#find-next'),
findPrevious: document.querySelector('#find-previous')
},
optionElements = {
cursorBlink: document.querySelector('#option-cursor-blink'),
cursorStyle: document.querySelector('#option-cursor-style'),
scrollback: document.querySelector('#option-scrollback'),
tabstopwidth: document.querySelector('#option-tabstopwidth'),
bellStyle: document.querySelector('#option-bell-style')
},
colsElement = document.getElementById('cols'),
rowsElement = document.getElementById('rows');
function setTerminalSize() {
var cols = parseInt(colsElement.value, 10);
var rows = parseInt(rowsElement.value, 10);
var viewportElement = document.querySelector('.xterm-viewport');
var scrollBarWidth = viewportElement.offsetWidth - viewportElement.clientWidth;
var width = (cols * term.renderer.dimensions.actualCellWidth + 20 /*room for scrollbar*/).toString() + 'px';
var height = (rows * term.renderer.dimensions.actualCellHeight).toString() + 'px';
terminalContainer.style.width = width;
terminalContainer.style.height = height;
term.resize(cols, rows);
}
colsElement.addEventListener('change', setTerminalSize);
rowsElement.addEventListener('change', setTerminalSize);
actionElements.findNext.addEventListener('keypress', function (e) {
if (e.key === "Enter") {
e.preventDefault();
term.findNext(actionElements.findNext.value);
}
});
actionElements.findPrevious.addEventListener('keypress', function (e) {
if (e.key === "Enter") {
e.preventDefault();
term.findPrevious(actionElements.findPrevious.value);
}
});
optionElements.cursorBlink.addEventListener('change', function () {
term.setOption('cursorBlink', optionElements.cursorBlink.checked);
});
optionElements.cursorStyle.addEventListener('change', function () {
term.setOption('cursorStyle', optionElements.cursorStyle.value);
});
optionElements.bellStyle.addEventListener('change', function () {
term.setOption('bellStyle', optionElements.bellStyle.value);
});
optionElements.scrollback.addEventListener('change', function () {
term.setOption('scrollback', parseInt(optionElements.scrollback.value, 10));
});
optionElements.tabstopwidth.addEventListener('change', function () {
term.setOption('tabStopWidth', parseInt(optionElements.tabstopwidth.value, 10));
});
createTerminal();
function createTerminal() {
// Clean terminal
while (terminalContainer.children.length) {
terminalContainer.removeChild(terminalContainer.children[0]);
}
term = new Terminal({
cursorBlink: optionElements.cursorBlink.checked,
scrollback: parseInt(optionElements.scrollback.value, 10),
tabStopWidth: parseInt(optionElements.tabstopwidth.value, 10)
});
window.term = term; // Expose `term` to window for debugging purposes
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) : '') + '/terminals/';
term.open(terminalContainer);
term.winptyCompatInit();
term.fit();
term.focus();
// fit is called within a setTimeout, cols and rows need this.
setTimeout(function () {
colsElement.value = term.cols;
rowsElement.value = term.rows;
// Set terminal size again to set the specific dimensions on the demo
setTerminalSize();
fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then(function (res) {
res.text().then(function (processId) {
pid = processId;
socketURL += processId;
socket = new WebSocket(socketURL);
socket.onopen = runRealTerminal;
socket.onclose = runFakeTerminal;
socket.onerror = runFakeTerminal;
});
});
}, 0);
}
function runRealTerminal() {
term.attach(socket);
term._initialized = true;
}
function runFakeTerminal() {
if (term._initialized) {
return;
}
term._initialized = true;
var shellprompt = '$ ';
term.prompt = function () {
term.write('\r\n' + shellprompt);
};
term.writeln('Welcome to xterm.js');
term.writeln('This is a local terminal emulation, without a real terminal in the back-end.');
term.writeln('Type some keys and commands to play around.');
term.writeln('');
term.prompt();
term.on('key', function (key, ev) {
var printable = (
!ev.altKey && !ev.altGraphKey && !ev.ctrlKey && !ev.metaKey
);
if (ev.keyCode == 13) {
term.prompt();
} else if (ev.keyCode == 8) {
// Do not delete the prompt
if (term.x > 2) {
term.write('\b \b');
}
} else if (printable) {
term.write(key);
}
});
term.on('paste', function (data, ev) {
term.write(data);
});
}
+138
View File
@@ -0,0 +1,138 @@
var express = require('express');
var expressWs = require('express-ws');
var os = require('os');
var pty = require('node-pty');
/**
* Whether to use UTF8 binary transport.
* (Must also be switched in client.ts)
*/
const USE_BINARY_UTF8 = false;
function startServer() {
var app = express();
expressWs(app);
var terminals = {},
logs = {};
app.use('/src', express.static(__dirname + '/../src'));
app.get('/logo.png', (req, res) => res.sendFile(__dirname + '/logo.png'));
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
app.get('/test', function(req, res){
res.sendFile(__dirname + '/test.html');
});
app.get('/style.css', function(req, res){
res.sendFile(__dirname + '/style.css');
});
app.get('/dist/client-bundle.js', function(req, res){
res.sendFile(__dirname + '/dist/client-bundle.js');
});
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,
encoding: USE_BINARY_UTF8 ? null : 'utf8'
});
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]);
// string message buffering
function buffer(socket, timeout) {
let s = '';
let sender = null;
return (data) => {
s += data;
if (!sender) {
sender = setTimeout(() => {
socket.send(s);
s = '';
sender = null;
}, timeout);
}
};
}
// binary message buffering
function bufferUtf8(socket, timeout) {
let buffer = [];
let sender = null;
let length = 0;
return (data) => {
buffer.push(data);
length += data.length;
if (!sender) {
sender = setTimeout(() => {
socket.send(Buffer.concat(buffer, length));
buffer = [];
sender = null;
length = 0;
}, timeout);
}
};
}
const send = USE_BINARY_UTF8 ? bufferUtf8(ws, 5) : buffer(ws, 5);
term.on('data', function(data) {
try {
send(data);
} catch (ex) {
// The WebSocket is not open, ignore
}
});
ws.on('message', function(msg) {
term.write(msg);
});
ws.on('close', function () {
term.kill();
console.log('Closed terminal ' + term.pid);
// Clean things up
delete terminals[term.pid];
delete logs[term.pid];
});
});
var port = process.env.PORT || 3000,
host = os.platform() === 'win32' ? '127.0.0.1' : '0.0.0.0';
console.log('App listening to http://127.0.0.1:' + port);
app.listen(port, host);
}
module.exports = startServer;
+55
View File
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*
* This file is the entry point for browserify.
*/
const path = require('path');
const webpack = require('webpack');
const startServer = require('./server.js');
startServer();
// Build/watch client source
const clientConfig = {
entry: path.resolve(__dirname, 'client.ts'),
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre",
exclude: /node_modules/
}
]
},
resolve: {
modules: [path.resolve(__dirname, '..'), 'node_modules'],
extensions: [ '.tsx', '.ts', '.js' ]
},
output: {
filename: 'client-bundle.js',
path: path.resolve(__dirname, 'dist')
},
mode: 'development',
watch: true
};
const compiler = webpack(clientConfig);
compiler.watch({
// Example watchOptions
aggregateTimeout: 300,
poll: undefined
}, (err, stats) => {
// Print watch/build result here...
console.log(stats.toString({
colors: true
}));
});
+16
View File
@@ -14,3 +14,19 @@ h1 {
margin: 0 auto;
padding: 2px;
}
p {
font-size: 0.9em;
font-style: italic
}
#option-container {
display: flex;
justify-content: center;
}
.option-group {
display: inline-block;
padding-left: 20px;
vertical-align: top;
}
+12
View File
@@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<title>xterm.js integration test fixture</title>
<link rel="stylesheet" href="/src/xterm.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="terminal-container"></div>
<script src="dist/client-bundle.js" defer ></script>
</body>
</html>
+12
View File
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"rootDir": ".",
"sourceMap": true
},
"include": [
"client.ts",
"../typings/xterm.d.ts"
]
}
+9 -1
View File
@@ -2,8 +2,16 @@ version: "3"
services:
web:
image: xtermjs/xterm.js:latest
build: .
volumes:
- ./:/usr/src/app
ports:
- ${XTERMJS_PORT:3000}:3000
- ${XTERMJS_PORT:-3000}:3000
command: ["npm", "start"]
watch:
build: .
volumes:
- ./:/usr/src/app
command: ["npm", "run", "watch"]
+6 -1
View File
@@ -4,6 +4,11 @@
],
"compilerOptions": {
"module": "commonjs",
"target": "es5"
"target": "es5",
"lib": [
"dom",
"es6"
],
"noEmit": true
}
}
+22 -2
View File
@@ -4,7 +4,7 @@
/// <reference path="../../typings/xterm.d.ts" />
import { Terminal } from 'xterm';
import { Terminal, IDisposable } from 'xterm';
namespace constructor {
{
@@ -21,7 +21,7 @@ namespace constructor {
'disableStdin': false,
'rows': 1,
'scrollback': 10,
'tabStopWidth': 2,
'tabStopWidth': 2
});
}
}
@@ -119,6 +119,12 @@ namespace methods_core {
const t: Terminal = new Terminal();
t.attachCustomKeyEventHandler((e: KeyboardEvent) => true);
t.attachCustomKeyEventHandler((e: KeyboardEvent) => false);
const d1: IDisposable = t.addCsiHandler('x',
(params: number[], collect: string): boolean => params[0] === 1);
d1.dispose();
const d2: IDisposable = t.addOscHandler(199,
(data: string): boolean => true);
d2.dispose();
}
namespace options {
{
@@ -144,6 +150,12 @@ namespace methods_core {
const r20: string = t.getOption('bellStyle');
const r21: boolean = t.getOption('enableBold');
const r22: number = t.getOption('letterSpacing');
const r23: boolean = t.getOption('macOptionIsMeta');
const r24: string = t.getOption('fontWeight');
const r25: string = t.getOption('fontWeightBold');
const r26: boolean = t.getOption('allowTransparency');
const r27: boolean = t.getOption('rightClickSelectsWord');
const r28: boolean = t.getOption('windowsMode');
}
{
const t: Terminal = new Terminal();
@@ -157,10 +169,16 @@ namespace methods_core {
t.setOption('debug', true);
t.setOption('disableStdin', true);
t.setOption('enableBold', true);
t.setOption('fontWeight', 'normal');
t.setOption('fontWeight', 'bold');
t.setOption('fontWeightBold', 'normal');
t.setOption('fontWeightBold', 'bold');
t.setOption('popOnBell', true);
t.setOption('screenKeys', true);
t.setOption('useFlowControl', true);
t.setOption('allowTransparency', true);
t.setOption('visualBell', true);
t.setOption('windowsMode', true);
t.setOption('colors', ['a', 'b']);
t.setOption('letterSpacing', 1);
t.setOption('cols', 1);
@@ -177,6 +195,8 @@ namespace methods_core {
t.setOption('lineHeight', 1);
t.setOption('fontFamily', 'foo');
t.setOption('theme', {background: '#ff0000'});
t.setOption('macOptionIsMeta', true);
t.setOption('rightClickSelectsWord', false);
}
}
namespace scrolling {
+57 -125
View File
@@ -4,11 +4,9 @@
const browserify = require('browserify');
const buffer = require('vinyl-buffer');
const coveralls = require('gulp-coveralls');
const fs = require('fs-extra');
const gulp = require('gulp');
const path = require('path');
const istanbul = require('gulp-istanbul');
const merge = require('merge-stream');
const mocha = require('gulp-mocha');
const sorcery = require('sorcery');
@@ -16,12 +14,20 @@ const source = require('vinyl-source-stream');
const sourcemaps = require('gulp-sourcemaps');
const ts = require('gulp-typescript');
const util = require('gulp-util');
const webpack = require('webpack-stream');
let buildDir = process.env.BUILD_DIR || 'build';
let tsProject = ts.createProject('tsconfig.json');
let srcDir = tsProject.config.compilerOptions.rootDir;
let outDir = tsProject.config.compilerOptions.outDir;
const buildDir = process.env.BUILD_DIR || 'build';
const tsProject = ts.createProject('src/tsconfig.json');
let srcDir = './src';
let outDir = './lib';
const addons = fs.readdirSync(`${__dirname}/src/addons`);
const TEST_PATHS = [
`${outDir}/*test.js`,
`${outDir}/**/*test.js`,
`${outDir}/*integration.js`,
`${outDir}/**/*integration.js`
];
// Under some environments like TravisCI, this comes out at absolute which can
// break the build. This ensures that the outDir is absolute.
@@ -29,54 +35,23 @@ if (path.normalize(outDir).indexOf(__dirname) !== 0) {
outDir = `${__dirname}/${path.normalize(outDir)}`;
}
/**
* Compile TypeScript sources to JavaScript files and create a source map file for each TypeScript
* file compiled.
*/
gulp.task('tsc', function () {
// Remove the ${outDir}/ directory to prevent confusion if files were deleted in ${srcDir}/
fs.emptyDirSync(`${outDir}`);
gulp.task('css', function() {
return gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(outDir));
});
// Build all TypeScript files (including tests) to ${outDir}/, based on the configuration defined in
// `tsconfig.json`.
let tsResult = tsProject.src().pipe(sourcemaps.init()).pipe(tsProject());
let tsc = merge(
tsResult.js.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest(outDir)),
tsResult.dts.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest(outDir))
);
gulp.task('css-build', function() {
return gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(buildDir));
});
let addons = ['attach', 'fit', 'fullscreen', 'search', 'terminado', 'winptyCompat', 'zmodem'];
let addonStreams = addons.map(function(addon) {
fs.emptyDirSync(`${outDir}/addons/${addon}`);
let tsProjectAddon = ts.createProject(`./src/addons/${addon}/tsconfig.json`);
let tsResultAddon = tsProjectAddon.src().pipe(sourcemaps.init()).pipe(tsProjectAddon());
let tscAddon = tsResultAddon.js
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''}))
.pipe(gulp.dest(`${outDir}/addons/${addon}`));
return tscAddon;
});
// Copy all addons from ${srcDir}/ to ${outDir}/
let copyAddons = gulp.src([
`${srcDir}/addons/**/**`
]).pipe(gulp.dest(`${outDir}/addons`));
// Copy stylesheets from ${srcDir}/ to ${outDir}/
let copyStylesheets = gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(outDir));
// Join all streams into a single array
let streams = [tsc].concat(addonStreams).concat([copyAddons, copyStylesheets]);
return merge.apply(this, streams);
gulp.task('watch-css', function() {
return gulp.watch(`${srcDir}/**/*.css`, ['css']);
});
/**
* Bundle JavaScript files produced by the `tsc` task, into a single file named `xterm.js` with
* Browserify.
*/
gulp.task('browserify', ['tsc'], function() {
gulp.task('browserify', function() {
// Ensure that the build directory exists
fs.ensureDirSync(buildDir);
@@ -90,7 +65,7 @@ gulp.task('browserify', ['tsc'], function() {
};
let bundleStream = browserify(browserifyOptions)
.bundle()
.pipe(source('xterm.js'))
.pipe(source(`xterm.js`))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true, sourceRoot: '..'}))
.pipe(sourcemaps.write('./'))
@@ -102,79 +77,48 @@ gulp.task('browserify', ['tsc'], function() {
return merge(bundleStream, copyStylesheets);
});
gulp.task('browserify-addons', ['tsc'], function() {
let searchOptions = {
basedir: `${buildDir}/addons/search`,
debug: true,
entries: [`${outDir}/addons/search/search.js`],
cache: {},
packageCache: {}
};
let searchBundle = browserify(searchOptions)
.external(path.join(outDir, 'Terminal.js'))
.bundle()
.pipe(source('./addons/search/search.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true, sourceRoot: ''}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(buildDir));
gulp.task('browserify-addons', function() {
const bundles = addons.map((addon) => {
const addonOptions = {
basedir: `${buildDir}/addons/${addon}`,
debug: true,
entries: [`${outDir}/addons/${addon}/${addon}.js`],
standalone: addon,
cache: {},
packageCache: {}
};
let winptyCompatOptions = {
basedir: `${buildDir}/addons/winptyCompat`,
debug: true,
entries: [`${outDir}/addons/winptyCompat/winptyCompat.js`],
cache: {},
packageCache: {}
};
let winptyCompatBundle = browserify(winptyCompatOptions)
.external(path.join(outDir, 'Terminal.js'))
.bundle()
.pipe(source('./addons/winptyCompat/winptyCompat.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true, sourceRoot: ''}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(buildDir));
const addonBundle = browserify(addonOptions)
.external(path.join(outDir, 'Terminal.js'))
.bundle()
.pipe(source(`./addons/${addon}/${addon}.js`))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true, sourceRoot: ''}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(buildDir));
// Copy all add-ons from outDir to buildDir
let copyAddons = gulp.src([
// Copy JS addons
`${outDir}/addons/**/*`
]).pipe(gulp.dest(`${buildDir}/addons`));
return addonBundle;
});
return merge(searchBundle, winptyCompatBundle, copyAddons);
return merge(...bundles);
});
gulp.task('instrument-test', function () {
return gulp.src([`${outDir}/**/*.js`])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('mocha', ['instrument-test'], function () {
return gulp.src([
`${outDir}/*test.js`,
`${outDir}/**/*test.js`,
`${outDir}/*integration.js`,
`${outDir}/**/*integration.js`
], {read: false})
gulp.task('mocha', function () {
return gulp.src(TEST_PATHS, {read: false})
.pipe(mocha())
.once('error', () => process.exit(1))
.pipe(istanbul.writeReports());
.once('error', () => process.exit(1));
});
/**
* Run single test file by file name(without file extension). Example of the command:
* gulp mocha-test --test InputHandler.test
* Run single test suite (file) by file name (without file extension). Example of the command:
* gulp mocha-suite --test InputHandler.test
*/
gulp.task('mocha-test', ['instrument-test'], function () {
gulp.task('mocha-suite', [], function () {
let testName = util.env.test;
util.log("Run test by Name: " + testName);
return gulp.src([`${outDir}/${testName}.js`, `${outDir}/**/${testName}.js`], {read: false})
.pipe(mocha())
.once('error', () => process.exit(1))
.pipe(istanbul.writeReports());
.once('error', () => process.exit(1));
});
/**
@@ -189,25 +133,13 @@ gulp.task('sorcery', ['browserify'], function () {
});
gulp.task('sorcery-addons', ['browserify-addons'], function () {
var chain = sorcery.loadSync(`${buildDir}/addons/search/search.js`);
chain.apply();
chain.writeSync();
addons.forEach((addon) => {
const chain = sorcery.loadSync(`${buildDir}/addons/${addon}/${addon}.js`);
chain.apply();
chain.writeSync();
})
});
gulp.task('webpack', ['build'], function() {
return gulp.src('demo/main.js')
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('demo/dist/'));
});
/**
* Submit coverage results to coveralls.io
*/
gulp.task('coveralls', function () {
gulp.src('coverage/**/lcov.info')
.pipe(coveralls());
});
gulp.task('build', ['sorcery', 'sorcery-addons']);
gulp.task('build', ['css', 'css-build', 'sorcery', 'sorcery-addons']);
gulp.task('test', ['mocha']);
gulp.task('default', ['build']);
-26
View File
@@ -1,26 +0,0 @@
{
"source": {
"include": [
"src/"
],
"exclude": [
"src/test/"
],
"excludePattern": "src/.+\\.test\\.(js|ts)$"
},
"opts": {
"readme": "README.md",
"template": "node_modules/docdash",
"encoding": "utf8",
"destination": "docs/",
"recurse": true,
"verbose": true
},
"plugins": [
"plugins/markdown"
],
"templates": {
"cleverLinks": false,
"monospaceLinks": false
}
}
-12651
View File
File diff suppressed because it is too large Load Diff
+42 -59
View File
@@ -1,51 +1,23 @@
{
"name": "xterm",
"description": "Full xterm terminal, in your browser",
"version": "3.0.0",
"ignore": [
"demo",
"test",
".gitignore"
],
"main": "lib/Terminal.js",
"version": "3.14.2",
"main": "lib/public/Terminal.js",
"types": "typings/xterm.d.ts",
"repository": "https://github.com/sourcelair/xterm.js",
"repository": "https://github.com/xtermjs/xterm.js",
"license": "MIT",
"files": [
"*.js",
"*.json",
"dist/*.css",
"dist/**/*.css",
"dist/*.js",
"dist/*.js.map",
"dist/**/*.js",
"dist/**/*.js.map",
"lib/*.css",
"lib/**/*.css",
"lib/*.d.ts",
"lib/*.js",
"lib/*.js.map",
"lib/**/*.d.ts",
"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/jsdom": "^11.0.1",
"@types/glob": "^5.0.35",
"@types/jsdom": "11.0.1",
"@types/mocha": "^2.2.33",
"@types/node": "^6.0.41",
"@types/text-encoding": "0.0.32",
"@types/node": "6.0.108",
"@types/puppeteer": "^1.12.4",
"@types/utf8": "^2.1.6",
"@types/webpack": "^4.4.11",
"browserify": "^13.3.0",
"chai": "3.5.0",
"docdash": "0.4.0",
"coveralls": "^3.0.1",
"express": "4.13.4",
"express-ws": "2.0.0-rc.1",
"fs-extra": "^1.0.0",
@@ -53,38 +25,49 @@
"gulp": "3.9.1",
"gulp-cli": "^1.2.2",
"gulp-concat": "^2.6.1",
"gulp-coveralls": "^0.1.4",
"gulp-istanbul": "^1.1.1",
"gulp-mocha": "^3.0.1",
"gulp-sourcemaps": "1.9.1",
"gulp-typescript": "^3.1.3",
"gulp-util": "3.0.8",
"jsdoc": "3.4.3",
"jsdom": "^11.1.0",
"jsdom": "^11.11.0",
"merge-stream": "^1.0.1",
"node-pty": "^0.7.2",
"node-pty": "0.7.6",
"nodemon": "1.10.2",
"nyc": "^11.8.0",
"puppeteer": "^1.15.0",
"sorcery": "^0.10.0",
"tslint": "^4.0.2",
"typescript": "~2.4.0",
"source-map-loader": "^0.2.4",
"ts-loader": "^4.5.0",
"tslint": "^5.9.1",
"tslint-consistent-codestyle": "^1.13.0",
"typescript": "3.5",
"utf8": "^3.0.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"webpack": "^3.10.0",
"webpack-stream": "^4.0.0",
"webpack": "^4.17.1",
"webpack-cli": "^3.1.0",
"xterm-addon-attach": "0.1.0-beta8",
"xterm-addon-search": "0.1.0-beta4",
"xterm-addon-web-links": "0.1.0-beta6",
"zmodem.js": "^0.1.5"
},
"scripts": {
"prestart": "gulp webpack",
"start": "node demo/app",
"prestart-zmodem": "npm run build",
"start-zmodem": "node build/addons/zmodem/demo/app",
"lint": "tslint src/*.ts src/**/*.ts",
"test": "gulp test",
"build:docs": "jsdoc -c jsdoc.json",
"start": "node demo/start",
"start-debug": "node --inspect-brk demo/start",
"start-zmodem": "node demo/zmodem/app",
"lint": "tslint 'src/**/*.ts' './demo/**/*.ts'",
"test": "npm run mocha",
"posttest": "npm run lint",
"test-debug": "node --inspect-brk node_modules/.bin/gulp test",
"test-suite": "gulp mocha-suite --test",
"test-coverage": "nyc -x gulpfile.js -x '**/*test*' npm run mocha",
"test-api": "mocha \"**/*.api.js\"",
"mocha": "gulp test",
"prebuild": "tsc -b ./src/tsconfig.all.json",
"build": "gulp build",
"prepublish": "npm run build",
"coveralls": "gulp coveralls",
"webpack": "gulp webpack"
},
"dependencies": {}
"prepare": "npm run prebuild",
"prepublishOnly": "npm run build",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"watch": "tsc -b -w ./src/tsconfig.all.json --preserveWatchOutput"
}
}
+296
View File
@@ -0,0 +1,296 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import * as Strings from './Strings';
import { ITerminal, IBuffer } from './Types';
import { isMac } from './common/Platform';
import { RenderDebouncer } from './ui/RenderDebouncer';
import { addDisposableDomListener } from './ui/Lifecycle';
import { Disposable } from './common/Lifecycle';
import { ScreenDprMonitor } from './ui/ScreenDprMonitor';
import { IRenderDimensions } from './renderer/Types';
const MAX_ROWS_TO_READ = 20;
const enum BoundaryPosition {
TOP,
BOTTOM
}
export class AccessibilityManager extends Disposable {
private _accessibilityTreeRoot: HTMLElement;
private _rowContainer: HTMLElement;
private _rowElements: HTMLElement[];
private _liveRegion: HTMLElement;
private _liveRegionLineCount: number = 0;
private _renderRowsDebouncer: RenderDebouncer;
private _screenDprMonitor: ScreenDprMonitor;
private _topBoundaryFocusListener: (e: FocusEvent) => void;
private _bottomBoundaryFocusListener: (e: FocusEvent) => void;
/**
* This queue has a character pushed to it for keys that are pressed, if the
* next character added to the terminal is equal to the key char then it is
* not announced (added to live region) because it has already been announced
* by the textarea event (which cannot be canceled). There are some race
* condition cases if there is typing while data is streaming, but this covers
* the main case of typing into the prompt and inputting the answer to a
* question (Y/N, etc.).
*/
private _charsToConsume: string[] = [];
private _charsToAnnounce: string = '';
constructor(
private _terminal: ITerminal,
private _dimensions: IRenderDimensions
) {
super();
this._accessibilityTreeRoot = document.createElement('div');
this._accessibilityTreeRoot.classList.add('xterm-accessibility');
this._rowContainer = document.createElement('div');
this._rowContainer.classList.add('xterm-accessibility-tree');
this._rowElements = [];
for (let i = 0; i < this._terminal.rows; i++) {
this._rowElements[i] = this._createAccessibilityTreeNode();
this._rowContainer.appendChild(this._rowElements[i]);
}
this._topBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.TOP);
this._bottomBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.BOTTOM);
this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);
this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
this._refreshRowsDimensions();
this._accessibilityTreeRoot.appendChild(this._rowContainer);
this._renderRowsDebouncer = new RenderDebouncer(this._renderRows.bind(this));
this._refreshRows();
this._liveRegion = document.createElement('div');
this._liveRegion.classList.add('live-region');
this._liveRegion.setAttribute('aria-live', 'assertive');
this._accessibilityTreeRoot.appendChild(this._liveRegion);
this._terminal.element.insertAdjacentElement('afterbegin', this._accessibilityTreeRoot);
this.register(this._renderRowsDebouncer);
this.register(this._terminal.onResize(e => this._onResize(e.rows)));
this.register(this._terminal.onRender(e => this._refreshRows(e.start, e.end)));
this.register(this._terminal.onScroll(() => this._refreshRows()));
// Line feed is an issue as the prompt won't be read out after a command is run
this.register(this._terminal.addDisposableListener('a11y.char', (char) => this._onChar(char)));
this.register(this._terminal.onLineFeed(() => this._onChar('\n')));
this.register(this._terminal.addDisposableListener('a11y.tab', spaceCount => this._onTab(spaceCount)));
this.register(this._terminal.onKey(e => this._onKey(e.key)));
this.register(this._terminal.addDisposableListener('blur', () => this._clearLiveRegion()));
this._screenDprMonitor = new ScreenDprMonitor();
this.register(this._screenDprMonitor);
this._screenDprMonitor.setListener(() => this._refreshRowsDimensions());
// This shouldn't be needed on modern browsers but is present in case the
// media query that drives the ScreenDprMonitor isn't supported
this.register(addDisposableDomListener(window, 'resize', () => this._refreshRowsDimensions()));
}
public dispose(): void {
super.dispose();
this._terminal.element.removeChild(this._accessibilityTreeRoot);
this._rowElements.length = 0;
}
private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void {
const boundaryElement = <HTMLElement>e.target;
const beforeBoundaryElement = this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2];
// Don't scroll if the buffer top has reached the end in that direction
const posInSet = boundaryElement.getAttribute('aria-posinset');
const lastRowPos = position === BoundaryPosition.TOP ? '1' : `${this._terminal.buffer.lines.length}`;
if (posInSet === lastRowPos) {
return;
}
// Don't scroll when the last focused item was not the second row (focus is going the other
// direction)
if (e.relatedTarget !== beforeBoundaryElement) {
return;
}
// Remove old boundary element from array
let topBoundaryElement: HTMLElement;
let bottomBoundaryElement: HTMLElement;
if (position === BoundaryPosition.TOP) {
topBoundaryElement = boundaryElement;
bottomBoundaryElement = this._rowElements.pop()!;
this._rowContainer.removeChild(bottomBoundaryElement);
} else {
topBoundaryElement = this._rowElements.shift()!;
bottomBoundaryElement = boundaryElement;
this._rowContainer.removeChild(topBoundaryElement);
}
// Remove listeners from old boundary elements
topBoundaryElement.removeEventListener('focus', this._topBoundaryFocusListener);
bottomBoundaryElement.removeEventListener('focus', this._bottomBoundaryFocusListener);
// Add new element to array/DOM
if (position === BoundaryPosition.TOP) {
const newElement = this._createAccessibilityTreeNode();
this._rowElements.unshift(newElement);
this._rowContainer.insertAdjacentElement('afterbegin', newElement);
} else {
const newElement = this._createAccessibilityTreeNode();
this._rowElements.push(newElement);
this._rowContainer.appendChild(newElement);
}
// Add listeners to new boundary elements
this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);
this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
// Scroll up
this._terminal.scrollLines(position === BoundaryPosition.TOP ? -1 : 1);
// Focus new boundary before element
this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2].focus();
// Prevent the standard behavior
e.preventDefault();
e.stopImmediatePropagation();
}
private _onResize(rows: number): void {
// Remove bottom boundary listener
this._rowElements[this._rowElements.length - 1].removeEventListener('focus', this._bottomBoundaryFocusListener);
// Grow rows as required
for (let i = this._rowContainer.children.length; i < this._terminal.rows; i++) {
this._rowElements[i] = this._createAccessibilityTreeNode();
this._rowContainer.appendChild(this._rowElements[i]);
}
// Shrink rows as required
while (this._rowElements.length > rows) {
this._rowContainer.removeChild(this._rowElements.pop()!);
}
// Add bottom boundary listener
this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
this._refreshRowsDimensions();
}
private _createAccessibilityTreeNode(): HTMLElement {
const element = document.createElement('div');
element.setAttribute('role', 'listitem');
element.tabIndex = -1;
this._refreshRowDimensions(element);
return element;
}
private _onTab(spaceCount: number): void {
for (let i = 0; i < spaceCount; i++) {
this._onChar(' ');
}
}
private _onChar(char: string): void {
if (this._liveRegionLineCount < MAX_ROWS_TO_READ + 1) {
if (this._charsToConsume.length > 0) {
// Have the screen reader ignore the char if it was just input
const shiftedChar = this._charsToConsume.shift();
if (shiftedChar !== char) {
this._charsToAnnounce += char;
}
} else {
this._charsToAnnounce += char;
}
if (char === '\n') {
this._liveRegionLineCount++;
if (this._liveRegionLineCount === MAX_ROWS_TO_READ + 1) {
this._liveRegion.textContent += Strings.tooMuchOutput;
}
}
// Only detach/attach on mac as otherwise messages can go unaccounced
if (isMac) {
if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {
setTimeout(() => {
this._accessibilityTreeRoot.appendChild(this._liveRegion);
}, 0);
}
}
}
}
private _clearLiveRegion(): void {
this._liveRegion.textContent = '';
this._liveRegionLineCount = 0;
// Only detach/attach on mac as otherwise messages can go unaccounced
if (isMac) {
if (this._liveRegion.parentNode) {
this._accessibilityTreeRoot.removeChild(this._liveRegion);
}
}
}
private _onKey(keyChar: string): void {
this._clearLiveRegion();
this._charsToConsume.push(keyChar);
}
private _refreshRows(start?: number, end?: number): void {
this._renderRowsDebouncer.refresh(start, end, this._terminal.rows);
}
private _renderRows(start: number, end: number): void {
const buffer: IBuffer = this._terminal.buffer;
const setSize = buffer.lines.length.toString();
for (let i = start; i <= end; i++) {
const lineData = buffer.translateBufferLineToString(buffer.ydisp + i, true);
const posInSet = (buffer.ydisp + i + 1).toString();
const element = this._rowElements[i];
if (element) {
element.textContent = lineData.length === 0 ? Strings.blankLine : lineData;
element.setAttribute('aria-posinset', posInSet);
element.setAttribute('aria-setsize', setSize);
}
}
this._announceCharacters();
}
private _refreshRowsDimensions(): void {
if (!this._dimensions.actualCellHeight) {
return;
}
if (this._rowElements.length !== this._terminal.rows) {
this._onResize(this._terminal.rows);
}
for (let i = 0; i < this._terminal.rows; i++) {
this._refreshRowDimensions(this._rowElements[i]);
}
}
public setDimensions(dimensions: IRenderDimensions): void {
this._dimensions = dimensions;
this._refreshRowsDimensions();
}
private _refreshRowDimensions(element: HTMLElement): void {
element.style.height = `${this._dimensions.actualCellHeight}px`;
}
private _announceCharacters(): void {
if (this._charsToAnnounce.length === 0) {
return;
}
this._liveRegion.textContent += this._charsToAnnounce;
this._charsToAnnounce = '';
}
}
+1228 -16
View File
File diff suppressed because it is too large Load Diff
+458 -111
View File
@@ -3,14 +3,13 @@
* @license MIT
*/
import { ITerminal, IBuffer } from './Interfaces';
import { CircularList } from './utils/CircularList';
import { LineData, CharData } from './Types';
import { CircularList, IInsertEvent } from './common/CircularList';
import { ITerminal, IBuffer, BufferIndex, IBufferStringIterator, IBufferStringIteratorResult } from './Types';
import { IBufferLine, ICellData, IAttributeData } from './core/Types';
import { BufferLine, CellData, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX, DEFAULT_ATTR_DATA } from './core/buffer/BufferLine';
import { reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths, getWrappedLineTrimmedLength } from './core/buffer/BufferReflow';
import { Marker } from './core/buffer/Marker';
export const CHAR_DATA_ATTR_INDEX = 0;
export const CHAR_DATA_CHAR_INDEX = 1;
export const CHAR_DATA_WIDTH_INDEX = 2;
export const CHAR_DATA_CODE_INDEX = 3;
export const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1
/**
@@ -21,8 +20,7 @@ export const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1
* - scroll position
*/
export class Buffer implements IBuffer {
private _lines: CircularList<LineData>;
public lines: CircularList<IBufferLine>;
public ydisp: number;
public ybase: number;
public y: number;
@@ -32,6 +30,12 @@ export class Buffer implements IBuffer {
public tabs: any;
public savedY: number;
public savedX: number;
public savedCurAttrData = DEFAULT_ATTR_DATA.clone();
public markers: Marker[] = [];
private _nullCell: ICellData = CellData.fromCharData([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
private _whitespaceCell: ICellData = CellData.fromCharData([0, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE]);
private _cols: number;
private _rows: number;
/**
* Create a new Buffer.
@@ -43,21 +47,45 @@ export class Buffer implements IBuffer {
private _terminal: ITerminal,
private _hasScrollback: boolean
) {
this._cols = this._terminal.cols;
this._rows = this._terminal.rows;
this.clear();
}
public get lines(): CircularList<LineData> {
return this._lines;
public getNullCell(attr?: IAttributeData): ICellData {
if (attr) {
this._nullCell.fg = attr.fg;
this._nullCell.bg = attr.bg;
} else {
this._nullCell.fg = 0;
this._nullCell.bg = 0;
}
return this._nullCell;
}
public getWhitespaceCell(attr?: IAttributeData): ICellData {
if (attr) {
this._whitespaceCell.fg = attr.fg;
this._whitespaceCell.bg = attr.bg;
} else {
this._whitespaceCell.fg = 0;
this._whitespaceCell.bg = 0;
}
return this._whitespaceCell;
}
public getBlankLine(attr: IAttributeData, isWrapped?: boolean): IBufferLine {
return new BufferLine(this._terminal.cols, this.getNullCell(attr), isWrapped);
}
public get hasScrollback(): boolean {
return this._hasScrollback && this.lines.maxLength > this._terminal.rows;
return this._hasScrollback && this.lines.maxLength > this._rows;
}
public get isCursorInViewport(): boolean {
const absoluteY = this.ybase + this.y;
const relativeY = absoluteY - this.ydisp;
return (relativeY >= 0 && relativeY < this._terminal.rows);
return (relativeY >= 0 && relativeY < this._rows);
}
/**
@@ -78,11 +106,14 @@ export class Buffer implements IBuffer {
/**
* Fills the buffer's viewport with blank lines.
*/
public fillViewportRows(): void {
if (this._lines.length === 0) {
let i = this._terminal.rows;
public fillViewportRows(fillAttr?: IAttributeData): void {
if (this.lines.length === 0) {
if (fillAttr === undefined) {
fillAttr = DEFAULT_ATTR_DATA;
}
let i = this._rows;
while (i--) {
this.lines.push(this._terminal.blankLine());
this.lines.push(this.getBlankLine(fillAttr));
}
}
}
@@ -95,9 +126,9 @@ export class Buffer implements IBuffer {
this.ybase = 0;
this.y = 0;
this.x = 0;
this._lines = new CircularList<LineData>(this._getCorrectBufferLength(this._terminal.rows));
this.lines = new CircularList<IBufferLine>(this._getCorrectBufferLength(this._rows));
this.scrollTop = 0;
this.scrollBottom = this._terminal.rows - 1;
this.scrollBottom = this._rows - 1;
this.setupTabStops();
}
@@ -107,37 +138,32 @@ export class Buffer implements IBuffer {
* @param newRows The new number of rows.
*/
public resize(newCols: number, newRows: number): void {
// store reference to null cell with default attrs
const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);
// Increase max length if needed before adjustments to allow space to fill
// as required.
const newMaxLength = this._getCorrectBufferLength(newRows);
if (newMaxLength > this._lines.maxLength) {
this._lines.maxLength = newMaxLength;
if (newMaxLength > this.lines.maxLength) {
this.lines.maxLength = newMaxLength;
}
// The following adjustments should only happen if the buffer has been
// initialized/filled.
if (this._lines.length > 0) {
// Deal with columns increasing (we don't do anything when columns reduce)
if (this._terminal.cols < newCols) {
const ch: CharData = [this._terminal.defAttr, ' ', 1, 32]; // does xterm use the default attr?
for (let i = 0; i < this._lines.length; i++) {
// TODO: This should be removed, with tests setup for the case that was
// causing the underlying bug, see https://github.com/sourcelair/xterm.js/issues/824
if (this._lines.get(i) === undefined) {
this._lines.set(i, this._terminal.blankLine(undefined, undefined, newCols));
}
while (this._lines.get(i).length < newCols) {
this._lines.get(i).push(ch);
}
if (this.lines.length > 0) {
// Deal with columns increasing (reducing needs to happen after reflow)
if (this._cols < newCols) {
for (let i = 0; i < this.lines.length; i++) {
this.lines.get(i).resize(newCols, nullCell);
}
}
// Resize rows in both directions as needed
let addToY = 0;
if (this._terminal.rows < newRows) {
for (let y = this._terminal.rows; y < newRows; y++) {
if (this._lines.length < newRows + this.ybase) {
if (this.ybase > 0 && this._lines.length <= this.ybase + this.y + addToY + 1) {
if (this._rows < newRows) {
for (let y = this._rows; y < newRows; y++) {
if (this.lines.length < newRows + this.ybase) {
if (this.ybase > 0 && this.lines.length <= this.ybase + this.y + addToY + 1) {
// There is room above the buffer and there are no empty elements below the line,
// scroll up
this.ybase--;
@@ -149,16 +175,16 @@ export class Buffer implements IBuffer {
} else {
// Add a blank line if there is no buffer left at the top to scroll to, or if there
// are blank lines after the cursor
this._lines.push(this._terminal.blankLine(undefined, undefined, newCols));
this.lines.push(new BufferLine(newCols, nullCell));
}
}
}
} else { // (this._terminal.rows >= newRows)
for (let y = this._terminal.rows; y > newRows; y--) {
if (this._lines.length > newRows + this.ybase) {
if (this._lines.length > this.ybase + this.y + 1) {
} else { // (this._rows >= newRows)
for (let y = this._rows; y > newRows; y--) {
if (this.lines.length > newRows + this.ybase) {
if (this.lines.length > this.ybase + this.y + 1) {
// The line is a blank line below the cursor, remove it
this._lines.pop();
this.lines.pop();
} else {
// The line is the cursor, scroll down
this.ybase++;
@@ -170,33 +196,295 @@ export class Buffer implements IBuffer {
// Reduce max length if needed after adjustments, this is done after as it
// would otherwise cut data from the bottom of the buffer.
if (newMaxLength < this._lines.maxLength) {
if (newMaxLength < this.lines.maxLength) {
// Trim from the top of the buffer and adjust ybase and ydisp.
const amountToTrim = this._lines.length - newMaxLength;
const amountToTrim = this.lines.length - newMaxLength;
if (amountToTrim > 0) {
this._lines.trimStart(amountToTrim);
this.lines.trimStart(amountToTrim);
this.ybase = Math.max(this.ybase - amountToTrim, 0);
this.ydisp = Math.max(this.ydisp - amountToTrim, 0);
}
this._lines.maxLength = newMaxLength;
this.lines.maxLength = newMaxLength;
}
// Make sure that the cursor stays on screen
if (this.y >= newRows) {
this.y = newRows - 1;
}
this.x = Math.min(this.x, newCols - 1);
this.y = Math.min(this.y, newRows - 1);
if (addToY) {
this.y += addToY;
}
if (this.x >= newCols) {
this.x = newCols - 1;
}
this.savedY = Math.min(this.savedY, newRows - 1);
this.savedX = Math.min(this.savedX, newCols - 1);
this.scrollTop = 0;
}
this.scrollBottom = newRows - 1;
if (this._isReflowEnabled) {
this._reflow(newCols, newRows);
// Trim the end of the line off if cols shrunk
if (this._cols > newCols) {
for (let i = 0; i < this.lines.length; i++) {
this.lines.get(i).resize(newCols, nullCell);
}
}
}
this._cols = newCols;
this._rows = newRows;
}
private get _isReflowEnabled(): boolean {
return this._hasScrollback && !this._terminal.options.windowsMode;
}
private _reflow(newCols: number, newRows: number): void {
if (this._cols === newCols) {
return;
}
// Iterate through rows, ignore the last one as it cannot be wrapped
if (newCols > this._cols) {
this._reflowLarger(newCols, newRows);
} else {
this._reflowSmaller(newCols, newRows);
}
}
private _reflowLarger(newCols: number, newRows: number): void {
const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(DEFAULT_ATTR_DATA));
if (toRemove.length > 0) {
const newLayoutResult = reflowLargerCreateNewLayout(this.lines, toRemove);
reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);
this._reflowLargerAdjustViewport(newCols, newRows, newLayoutResult.countRemoved);
}
}
private _reflowLargerAdjustViewport(newCols: number, newRows: number, countRemoved: number): void {
const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);
// Adjust viewport based on number of items removed
let viewportAdjustments = countRemoved;
while (viewportAdjustments-- > 0) {
if (this.ybase === 0) {
if (this.y > 0) {
this.y--;
}
if (this.lines.length < newRows) {
// Add an extra row at the bottom of the viewport
this.lines.push(new BufferLine(newCols, nullCell));
}
} else {
if (this.ydisp === this.ybase) {
this.ydisp--;
}
this.ybase--;
}
}
}
private _reflowSmaller(newCols: number, newRows: number): void {
const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);
// Gather all BufferLines that need to be inserted into the Buffer here so that they can be
// batched up and only committed once
const toInsert = [];
let countToInsert = 0;
// Go backwards as many lines may be trimmed and this will avoid considering them
for (let y = this.lines.length - 1; y >= 0; y--) {
// Check whether this line is a problem
let nextLine = this.lines.get(y) as BufferLine;
if (!nextLine || !nextLine.isWrapped && nextLine.getTrimmedLength() <= newCols) {
continue;
}
// Gather wrapped lines and adjust y to be the starting line
const wrappedLines: BufferLine[] = [nextLine];
while (nextLine.isWrapped && y > 0) {
nextLine = this.lines.get(--y) as BufferLine;
wrappedLines.unshift(nextLine);
}
// If these lines contain the cursor don't touch them, the program will handle fixing up
// wrapped lines with the cursor
const absoluteY = this.ybase + this.y;
if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
continue;
}
const lastLineLength = wrappedLines[wrappedLines.length - 1].getTrimmedLength();
const destLineLengths = reflowSmallerGetNewLineLengths(wrappedLines, this._cols, newCols);
const linesToAdd = destLineLengths.length - wrappedLines.length;
let trimmedLines: number;
if (this.ybase === 0 && this.y !== this.lines.length - 1) {
// If the top section of the buffer is not yet filled
trimmedLines = Math.max(0, this.y - this.lines.maxLength + linesToAdd);
} else {
trimmedLines = Math.max(0, this.lines.length - this.lines.maxLength + linesToAdd);
}
// Add the new lines
const newLines: BufferLine[] = [];
for (let i = 0; i < linesToAdd; i++) {
const newLine = this.getBlankLine(DEFAULT_ATTR_DATA, true) as BufferLine;
newLines.push(newLine);
}
if (newLines.length > 0) {
toInsert.push({
// countToInsert here gets the actual index, taking into account other inserted items.
// using this we can iterate through the list forwards
start: y + wrappedLines.length + countToInsert,
newLines
});
countToInsert += newLines.length;
}
wrappedLines.push(...newLines);
// Copy buffer data to new locations, this needs to happen backwards to do in-place
let destLineIndex = destLineLengths.length - 1; // Math.floor(cellsNeeded / newCols);
let destCol = destLineLengths[destLineIndex]; // cellsNeeded % newCols;
if (destCol === 0) {
destLineIndex--;
destCol = destLineLengths[destLineIndex];
}
let srcLineIndex = wrappedLines.length - linesToAdd - 1;
let srcCol = lastLineLength;
while (srcLineIndex >= 0) {
const cellsToCopy = Math.min(srcCol, destCol);
wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol - cellsToCopy, destCol - cellsToCopy, cellsToCopy, true);
destCol -= cellsToCopy;
if (destCol === 0) {
destLineIndex--;
destCol = destLineLengths[destLineIndex];
}
srcCol -= cellsToCopy;
if (srcCol === 0) {
srcLineIndex--;
const wrappedLinesIndex = Math.max(srcLineIndex, 0);
srcCol = getWrappedLineTrimmedLength(wrappedLines, wrappedLinesIndex, this._cols);
}
}
// Null out the end of the line ends if a wide character wrapped to the following line
for (let i = 0; i < wrappedLines.length; i++) {
if (destLineLengths[i] < newCols) {
wrappedLines[i].setCell(destLineLengths[i], nullCell);
}
}
// Adjust viewport as needed
let viewportAdjustments = linesToAdd - trimmedLines;
while (viewportAdjustments-- > 0) {
if (this.ybase === 0) {
if (this.y < newRows - 1) {
this.y++;
this.lines.pop();
} else {
this.ybase++;
this.ydisp++;
}
} else {
// Ensure ybase does not exceed its maximum value
if (this.ybase < Math.min(this.lines.maxLength, this.lines.length + countToInsert) - newRows) {
if (this.ybase === this.ydisp) {
this.ydisp++;
}
this.ybase++;
}
}
}
}
// Rearrange lines in the buffer if there are any insertions, this is done at the end rather
// than earlier so that it's a single O(n) pass through the buffer, instead of O(n^2) from many
// costly calls to CircularList.splice.
if (toInsert.length > 0) {
// Record buffer insert events and then play them back backwards so that the indexes are
// correct
const insertEvents: IInsertEvent[] = [];
// Record original lines so they don't get overridden when we rearrange the list
const originalLines: BufferLine[] = [];
for (let i = 0; i < this.lines.length; i++) {
originalLines.push(this.lines.get(i) as BufferLine);
}
const originalLinesLength = this.lines.length;
let originalLineIndex = originalLinesLength - 1;
let nextToInsertIndex = 0;
let nextToInsert = toInsert[nextToInsertIndex];
this.lines.length = Math.min(this.lines.maxLength, this.lines.length + countToInsert);
let countInsertedSoFar = 0;
for (let i = Math.min(this.lines.maxLength - 1, originalLinesLength + countToInsert - 1); i >= 0; i--) {
if (nextToInsert && nextToInsert.start > originalLineIndex + countInsertedSoFar) {
// Insert extra lines here, adjusting i as needed
for (let nextI = nextToInsert.newLines.length - 1; nextI >= 0; nextI--) {
this.lines.set(i--, nextToInsert.newLines[nextI]);
}
i++;
// Create insert events for later
insertEvents.push({
index: originalLineIndex + 1,
amount: nextToInsert.newLines.length
});
countInsertedSoFar += nextToInsert.newLines.length;
nextToInsert = toInsert[++nextToInsertIndex];
} else {
this.lines.set(i, originalLines[originalLineIndex--]);
}
}
// Update markers
let insertCountEmitted = 0;
for (let i = insertEvents.length - 1; i >= 0; i--) {
insertEvents[i].index += insertCountEmitted;
this.lines.onInsertEmitter.fire(insertEvents[i]);
insertCountEmitted += insertEvents[i].amount;
}
const amountToTrim = Math.max(0, originalLinesLength + countToInsert - this.lines.maxLength);
if (amountToTrim > 0) {
this.lines.onTrimEmitter.fire(amountToTrim);
}
}
}
// private _reflowSmallerGetLinesNeeded()
/**
* Translates a string index back to a BufferIndex.
* To get the correct buffer position the string must start at `startCol` 0
* (default in translateBufferLineToString).
* The method also works on wrapped line strings given rows were not trimmed.
* The method operates on the CharData string length, there are no
* additional content or boundary checks. Therefore the string and the buffer
* should not be altered in between.
* TODO: respect trim flag after fixing #1685
* @param lineIndex line index the string was retrieved from
* @param stringIndex index within the string
* @param startCol column offset the string was retrieved from
*/
public stringIndexToBufferIndex(lineIndex: number, stringIndex: number, trimRight: boolean = false): BufferIndex {
while (stringIndex) {
const line = this.lines.get(lineIndex);
if (!line) {
return [-1, -1];
}
const length = (trimRight) ? line.getTrimmedLength() : line.length;
for (let i = 0; i < length; ++i) {
if (line.get(i)[CHAR_DATA_WIDTH_INDEX]) {
// empty cells report a string length of 0, but get replaced
// with a whitespace in translateToString, thus replace with 1
stringIndex -= line.get(i)[CHAR_DATA_CHAR_INDEX].length || 1;
}
if (stringIndex < 0) {
return [lineIndex, i];
}
}
lineIndex++;
}
return [lineIndex, 0];
}
/**
@@ -209,62 +497,26 @@ export class Buffer implements IBuffer {
* @param startCol The column to start at.
* @param endCol The column to end at.
*/
public translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol: number = 0, endCol: number = null): string {
// Get full line
let lineString = '';
public translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol: number = 0, endCol?: number): string {
const line = this.lines.get(lineIndex);
if (!line) {
return '';
}
return line.translateToString(trimRight, startCol, endCol);
}
// Initialize column and index values. Column values represent the actual
// cell column, indexes represent the index in the string. Indexes are
// needed here because some chars are 0 characters long (eg. after wide
// chars) and some chars are longer than 1 characters long (eg. emojis).
let startIndex = startCol;
endCol = endCol || line.length;
let endIndex = endCol;
for (let i = 0; i < line.length; i++) {
const char = line[i];
lineString += char[CHAR_DATA_CHAR_INDEX];
// Adjust start and end cols for wide characters if they affect their
// column indexes
if (char[CHAR_DATA_WIDTH_INDEX] === 0) {
if (startCol >= i) {
startIndex--;
}
if (endCol >= i) {
endIndex--;
}
} else {
// Adjust the columns to take glyphs that are represented by multiple
// code points into account.
if (char[CHAR_DATA_CHAR_INDEX].length > 1) {
if (startCol > i) {
startIndex += char[CHAR_DATA_CHAR_INDEX].length - 1;
}
if (endCol > i) {
endIndex += char[CHAR_DATA_CHAR_INDEX].length - 1;
}
}
}
public getWrappedRangeForLine(y: number): { first: number, last: number } {
let first = y;
let last = y;
// Scan upwards for wrapped lines
while (first > 0 && this.lines.get(first).isWrapped) {
first--;
}
// Calculate the final end col by trimming whitespace on the right of the
// line if needed.
if (trimRight) {
const rightWhitespaceIndex = lineString.search(/\s+$/);
if (rightWhitespaceIndex !== -1) {
endIndex = Math.min(endIndex, rightWhitespaceIndex);
}
// Return the empty string if only trimmed whitespace is selected
if (endIndex <= startIndex) {
return '';
}
// Scan downwards for wrapped lines
while (last + 1 < this.lines.length && this.lines.get(last + 1).isWrapped) {
last++;
}
return lineString.substring(startIndex, endIndex);
return { first, last };
}
/**
@@ -272,7 +524,7 @@ export class Buffer implements IBuffer {
* @param i The index to start setting up tab stops from.
*/
public setupTabStops(i?: number): void {
if (i != null) {
if (i !== null && i !== undefined) {
if (!this.tabs[i]) {
i = this.prevStop(i);
}
@@ -281,7 +533,7 @@ export class Buffer implements IBuffer {
i = 0;
}
for (; i < this._terminal.cols; i += this._terminal.options.tabStopWidth) {
for (; i < this._cols; i += this._terminal.options.tabStopWidth) {
this.tabs[i] = true;
}
}
@@ -291,11 +543,11 @@ export class Buffer implements IBuffer {
* @param x The position to move the cursor to the previous tab stop.
*/
public prevStop(x?: number): number {
if (x == null) {
if (x === null || x === undefined) {
x = this.x;
}
while (!this.tabs[--x] && x > 0);
return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;
return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;
}
/**
@@ -303,10 +555,105 @@ export class Buffer implements IBuffer {
* @param x The position to move the cursor one tab stop forward.
*/
public nextStop(x?: number): number {
if (x == null) {
if (x === null || x === undefined) {
x = this.x;
}
while (!this.tabs[++x] && x < this._terminal.cols);
return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;
while (!this.tabs[++x] && x < this._cols);
return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;
}
public addMarker(y: number): Marker {
const marker = new Marker(y);
this.markers.push(marker);
marker.register(this.lines.onTrim(amount => {
marker.line -= amount;
// The marker should be disposed when the line is trimmed from the buffer
if (marker.line < 0) {
marker.dispose();
}
}));
marker.register(this.lines.onInsert(event => {
if (marker.line >= event.index) {
marker.line += event.amount;
}
}));
marker.register(this.lines.onDelete(event => {
// Delete the marker if it's within the range
if (marker.line >= event.index && marker.line < event.index + event.amount) {
marker.dispose();
}
// Shift the marker if it's after the deleted range
if (marker.line > event.index) {
marker.line -= event.amount;
}
}));
marker.register(marker.onDispose(() => this._removeMarker(marker)));
return marker;
}
private _removeMarker(marker: Marker): void {
this.markers.splice(this.markers.indexOf(marker), 1);
}
public iterator(trimRight: boolean, startIndex?: number, endIndex?: number, startOverscan?: number, endOverscan?: number): IBufferStringIterator {
return new BufferStringIterator(this, trimRight, startIndex, endIndex, startOverscan, endOverscan);
}
}
/**
* Iterator to get unwrapped content strings from the buffer.
* The iterator returns at least the string data between the borders
* `startIndex` and `endIndex` (exclusive) and will expand the lines
* by `startOverscan` to the top and by `endOverscan` to the bottom,
* if no new line was found in between.
* It will never read/return string data beyond `startIndex - startOverscan`
* or `endIndex + endOverscan`. Therefore the first and last line might be truncated.
* It is possible to always get the full string for the first and last line as well
* by setting the overscan values to the actual buffer length. This not recommended
* since it might return the whole buffer within a single string in a worst case scenario.
*/
export class BufferStringIterator implements IBufferStringIterator {
private _current: number;
constructor (
private _buffer: IBuffer,
private _trimRight: boolean,
private _startIndex: number = 0,
private _endIndex: number = _buffer.lines.length,
private _startOverscan: number = 0,
private _endOverscan: number = 0
) {
if (this._startIndex < 0) {
this._startIndex = 0;
}
if (this._endIndex > this._buffer.lines.length) {
this._endIndex = this._buffer.lines.length;
}
this._current = this._startIndex;
}
public hasNext(): boolean {
return this._current < this._endIndex;
}
public next(): IBufferStringIteratorResult {
const range = this._buffer.getWrappedRangeForLine(this._current);
// limit search window to overscan value at both borders
if (range.first < this._startIndex - this._startOverscan) {
range.first = this._startIndex - this._startOverscan;
}
if (range.last > this._endIndex + this._endOverscan) {
range.last = this._endIndex + this._endOverscan;
}
// limit to current buffer length
range.first = Math.max(range.first, 0);
range.last = Math.min(range.last, this._buffer.lines.length);
let result = '';
for (let i = range.first; i <= range.last; ++i) {
result += this._buffer.translateBufferLineToString(i, this._trimRight);
}
this._current = range.last + 1;
return {range: range, content: result};
}
}
+30 -4
View File
@@ -4,10 +4,10 @@
*/
import { assert } from 'chai';
import { ITerminal } from './Interfaces';
import { ITerminal } from './Types';
import { BufferSet } from './BufferSet';
import { Buffer } from './Buffer';
import { MockTerminal } from './utils/TestUtils.test';
import { MockTerminal } from './TestUtils.test';
describe('BufferSet', () => {
let terminal: ITerminal;
@@ -15,8 +15,8 @@ describe('BufferSet', () => {
beforeEach(() => {
terminal = new MockTerminal();
terminal.cols = 80;
terminal.rows = 24;
(terminal as any).cols = 80;
(terminal as any).rows = 24;
terminal.options.scrollback = 1000;
bufferSet = new BufferSet(terminal);
});
@@ -48,4 +48,30 @@ describe('BufferSet', () => {
assert.equal(bufferSet.active, bufferSet.alt);
});
});
describe('cursor handling when swapping buffers', () => {
beforeEach(() => {
bufferSet.normal.x = 0;
bufferSet.normal.y = 0;
bufferSet.alt.x = 0;
bufferSet.alt.y = 0;
});
it('should keep the cursor stationary when activating alt buffer', () => {
bufferSet.activateNormalBuffer();
bufferSet.active.x = 30;
bufferSet.active.y = 10;
bufferSet.activateAltBuffer();
assert.equal(bufferSet.active.x, 30);
assert.equal(bufferSet.active.y, 10);
});
it('should keep the cursor stationary when activating normal buffer', () => {
bufferSet.activateAltBuffer();
bufferSet.active.x = 30;
bufferSet.active.y = 10;
bufferSet.activateNormalBuffer();
assert.equal(bufferSet.active.x, 30);
assert.equal(bufferSet.active.y, 10);
});
});
});
+29 -13
View File
@@ -3,25 +3,29 @@
* @license MIT
*/
import { ITerminal, IBufferSet } from './Interfaces';
import { ITerminal, IBufferSet, IBuffer } from './Types';
import { IAttributeData } from './core/Types';
import { Buffer } from './Buffer';
import { EventEmitter } from './EventEmitter';
import { EventEmitter2, IEvent } from './common/EventEmitter2';
/**
* The BufferSet represents the set of two buffers used by xterm terminals (normal and alt) and
* provides also utilities for working with them.
*/
export class BufferSet extends EventEmitter implements IBufferSet {
export class BufferSet implements IBufferSet {
private _normal: Buffer;
private _alt: Buffer;
private _activeBuffer: Buffer;
private _onBufferActivate = new EventEmitter2<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}>();
public get onBufferActivate(): IEvent<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}> { return this._onBufferActivate.event; }
/**
* Create a new BufferSet for the given terminal.
* @param {Terminal} terminal - The terminal the BufferSet will belong to
* @param _terminal - The terminal the BufferSet will belong to
*/
constructor(private _terminal: ITerminal) {
super();
this._normal = new Buffer(this._terminal, true);
this._normal.fillViewportRows();
@@ -35,7 +39,6 @@ export class BufferSet extends EventEmitter implements IBufferSet {
/**
* Returns the alt Buffer of the BufferSet
* @returns {Buffer}
*/
public get alt(): Buffer {
return this._alt;
@@ -43,7 +46,6 @@ export class BufferSet extends EventEmitter implements IBufferSet {
/**
* Returns the normal Buffer of the BufferSet
* @returns {Buffer}
*/
public get active(): Buffer {
return this._activeBuffer;
@@ -51,7 +53,6 @@ export class BufferSet extends EventEmitter implements IBufferSet {
/**
* Returns the currently active Buffer of the BufferSet
* @returns {Buffer}
*/
public get normal(): Buffer {
return this._normal;
@@ -61,24 +62,39 @@ export class BufferSet extends EventEmitter implements IBufferSet {
* Sets the normal Buffer of the BufferSet as its currently active Buffer
*/
public activateNormalBuffer(): void {
if (this._activeBuffer === this._normal) {
return;
}
this._normal.x = this._alt.x;
this._normal.y = this._alt.y;
// The alt buffer should always be cleared when we switch to the normal
// buffer. This frees up memory since the alt buffer should always be new
// when activated.
this._alt.clear();
this._activeBuffer = this._normal;
this.emit('activate', this._normal);
this._onBufferActivate.fire({
activeBuffer: this._normal,
inactiveBuffer: this._alt
});
}
/**
* Sets the alt Buffer of the BufferSet as its currently active Buffer
*/
public activateAltBuffer(): void {
public activateAltBuffer(fillAttr?: IAttributeData): void {
if (this._activeBuffer === this._alt) {
return;
}
// Since the alt buffer is always cleared when the normal buffer is
// activated, we want to fill it when switching to it.
this._alt.fillViewportRows();
this._alt.fillViewportRows(fillAttr);
this._alt.x = this._normal.x;
this._alt.y = this._normal.y;
this._activeBuffer = this._alt;
this.emit('activate', this._alt);
this._onBufferActivate.fire({
activeBuffer: this._alt,
inactiveBuffer: this._normal
});
}
/**
@@ -4,8 +4,8 @@
*/
import jsdom = require('jsdom');
import { ICharMeasure } from './Types';
import { assert } from 'chai';
import { ICharMeasure, ITerminal } from '../Interfaces';
import { CharMeasure } from './CharMeasure';
describe('CharMeasure', () => {
+11 -12
View File
@@ -3,30 +3,29 @@
* @license MIT
*/
import { EventEmitter } from '../EventEmitter';
import { ICharMeasure, ITerminal, ITerminalOptions } from '../Interfaces';
import { ICharMeasure, ITerminalOptions } from './Types';
import { EventEmitter2, IEvent } from './common/EventEmitter2';
/**
* Utility class that measures the size of a character. Measurements are done in
* the DOM rather than with a canvas context because support for extracting the
* height of characters is patchy across browsers.
*/
export class CharMeasure extends EventEmitter implements ICharMeasure {
export class CharMeasure implements ICharMeasure {
private _document: Document;
private _parentElement: HTMLElement;
private _measureElement: HTMLElement;
private _width: number;
private _height: number;
private _onCharSizeChanged = new EventEmitter2<void>();
public get onCharSizeChanged(): IEvent<void> { return this._onCharSizeChanged.event; }
constructor(document: Document, parentElement: HTMLElement) {
super();
this._document = document;
this._parentElement = parentElement;
this._measureElement = this._document.createElement('span');
this._measureElement.style.position = 'absolute';
this._measureElement.style.top = '0';
this._measureElement.style.left = '-9999em';
this._measureElement.style.lineHeight = 'normal';
this._measureElement.classList.add('xterm-char-measure-element');
this._measureElement.textContent = 'W';
this._measureElement.setAttribute('aria-hidden', 'true');
this._parentElement.appendChild(this._measureElement);
@@ -49,11 +48,11 @@ export class CharMeasure extends EventEmitter implements ICharMeasure {
if (geometry.width === 0 || geometry.height === 0) {
return;
}
if (this._width !== geometry.width || this._height !== geometry.height) {
const adjustedHeight = Math.ceil(geometry.height);
if (this._width !== geometry.width || this._height !== adjustedHeight) {
this._width = geometry.width;
this._height = Math.ceil(geometry.height);
this.emit('charsizechanged');
this._height = adjustedHeight;
this._onCharSizeChanged.fire();
}
}
}
+254
View File
@@ -0,0 +1,254 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { TestTerminal } from './TestUtils.test';
import { assert } from 'chai';
import { getStringCellWidth, wcwidth } from './CharWidth';
import { IBuffer } from './Types';
import { CellData, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from './core/buffer/BufferLine';
describe('getStringCellWidth', function(): void {
let terminal: TestTerminal;
beforeEach(() => {
terminal = new TestTerminal({rows: 5, cols: 30});
});
function sumWidths(buffer: IBuffer, start: number, end: number, sentinel: string): number {
let result = 0;
for (let i = start; i < end; ++i) {
const line = buffer.lines.get(i);
for (let j = 0; j < line.length; ++j) { // TODO: change to trimBorder with multiline
const ch = line.loadCell(j, new CellData()).getAsCharData();
result += ch[CHAR_DATA_WIDTH_INDEX];
// return on sentinel
if (ch[CHAR_DATA_CHAR_INDEX] === sentinel) {
return result;
}
}
}
return result;
}
it('ASCII chars', function(): void {
const input = 'This is just ASCII text.#';
terminal.writeSync(input);
const s = terminal.buffer.iterator(true).next().content;
assert.equal(input, s);
assert.equal(getStringCellWidth(s), sumWidths(terminal.buffer, 0, 1, '#'));
});
it('combining chars', function(): void {
const input = 'e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301e\u0301#';
terminal.writeSync(input);
const s = terminal.buffer.iterator(true).next().content;
assert.equal(input, s);
assert.equal(getStringCellWidth(s), sumWidths(terminal.buffer, 0, 1, '#'));
});
it('surrogate chars', function(): void {
const input = '𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞𝄞#';
terminal.writeSync(input);
const s = terminal.buffer.iterator(true).next().content;
assert.equal(input, s);
assert.equal(getStringCellWidth(s), sumWidths(terminal.buffer, 0, 1, '#'));
});
it('surrogate combining chars', function(): void {
const input = '𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301𓂀\u0301#';
terminal.writeSync(input);
const s = terminal.buffer.iterator(true).next().content;
assert.equal(input, s);
assert.equal(getStringCellWidth(s), sumWidths(terminal.buffer, 0, 1, '#'));
});
it('fullwidth chars', function(): void {
const input = '1234567890#';
terminal.writeSync(input);
const s = terminal.buffer.iterator(true).next().content;
assert.equal(input, s);
assert.equal(getStringCellWidth(s), sumWidths(terminal.buffer, 0, 1, '#'));
});
it('fullwidth chars offset 1', function(): void {
const input = 'a1234567890#';
terminal.writeSync(input);
const s = terminal.buffer.iterator(true).next().content;
assert.equal(input, s);
assert.equal(getStringCellWidth(s), sumWidths(terminal.buffer, 0, 1, '#'));
});
// TODO: multiline tests once #1685 is resolved
});
it('wcwidth should match all values from the old implementation', function(): void {
// old implementation
const wcwidthOld = (function(opts: {nul: number, control: number}): (ucs: number) => number {
// extracted from https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c
// combining characters
const COMBINING_BMP = [
[0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
[0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],
[0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],
[0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],
[0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],
[0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],
[0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],
[0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],
[0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],
[0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],
[0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],
[0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],
[0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],
[0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],
[0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],
[0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],
[0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],
[0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],
[0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],
[0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],
[0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],
[0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],
[0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],
[0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],
[0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],
[0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],
[0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],
[0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],
[0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],
[0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],
[0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],
[0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],
[0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],
[0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],
[0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],
[0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],
[0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],
[0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],
[0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],
[0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],
[0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],
[0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
[0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]
];
const COMBINING_HIGH = [
[0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],
[0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],
[0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],
[0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],
[0xE0100, 0xE01EF]
];
// binary search
function bisearch(ucs: number, data: number[][]): boolean {
let min = 0;
let max = data.length - 1;
let mid;
if (ucs < data[0][0] || ucs > data[max][1]) {
return false;
}
while (max >= min) {
mid = (min + max) >> 1;
if (ucs > data[mid][1]) {
min = mid + 1;
} else if (ucs < data[mid][0]) {
max = mid - 1;
} else {
return true;
}
}
return false;
}
function wcwidthBMP(ucs: number): number {
// test for 8-bit control characters
if (ucs === 0) {
return opts.nul;
}
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) {
return opts.control;
}
// binary search in table of non-spacing characters
if (bisearch(ucs, COMBINING_BMP)) {
return 0;
}
// if we arrive here, ucs is not a combining or C0/C1 control character
if (isWideBMP(ucs)) {
return 2;
}
return 1;
}
function isWideBMP(ucs: number): boolean {
return (
ucs >= 0x1100 && (
ucs <= 0x115f || // Hangul Jamo init. consonants
ucs === 0x2329 ||
ucs === 0x232a ||
(ucs >= 0x2e80 && ucs <= 0xa4cf && ucs !== 0x303f) || // CJK..Yi
(ucs >= 0xac00 && ucs <= 0xd7a3) || // Hangul Syllables
(ucs >= 0xf900 && ucs <= 0xfaff) || // CJK Compat Ideographs
(ucs >= 0xfe10 && ucs <= 0xfe19) || // Vertical forms
(ucs >= 0xfe30 && ucs <= 0xfe6f) || // CJK Compat Forms
(ucs >= 0xff00 && ucs <= 0xff60) || // Fullwidth Forms
(ucs >= 0xffe0 && ucs <= 0xffe6)));
}
function wcwidthHigh(ucs: number): 0 | 1 | 2 {
if (bisearch(ucs, COMBINING_HIGH)) {
return 0;
}
if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
return 2;
}
return 1;
}
const control = opts.control | 0;
let table: number[] | Uint32Array = null;
function initTable(): number[] | Uint32Array {
// lookup table for BMP
const CODEPOINTS = 65536; // BMP holds 65536 codepoints
const BITWIDTH = 2; // a codepoint can have a width of 0, 1 or 2
const ITEMSIZE = 32; // using uint32_t
const CONTAINERSIZE = CODEPOINTS * BITWIDTH / ITEMSIZE;
const CODEPOINTS_PER_ITEM = ITEMSIZE / BITWIDTH;
table = (typeof Uint32Array === 'undefined')
? new Array(CONTAINERSIZE)
: new Uint32Array(CONTAINERSIZE);
for (let i = 0; i < CONTAINERSIZE; ++i) {
let num = 0;
let pos = CODEPOINTS_PER_ITEM;
while (pos--) {
num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos);
}
table[i] = num;
}
return table;
}
// get width from lookup table
// position in container : num / CODEPOINTS_PER_ITEM
// ==> n = table[Math.floor(num / 16)]
// ==> n = table[num >> 4]
// 16 codepoints per number: FFEEDDCCBBAA99887766554433221100
// position in number : (num % CODEPOINTS_PER_ITEM) * BITWIDTH
// ==> m = (n % 16) * 2
// ==> m = (num & 15) << 1
// right shift to position m
// ==> n = n >> m e.g. m=12 000000000000FFEEDDCCBBAA99887766
// we are only interested in 2 LSBs, cut off higher bits
// ==> n = n & 3 e.g. 000000000000000000000000000000XX
return function (num: number): number {
num = num | 0; // get asm.js like optimization under V8
if (num < 32) {
return control | 0;
}
if (num < 127) {
return 1;
}
const t = table || initTable();
if (num < 65536) {
return t[num >> 4] >> ((num & 15) << 1) & 3;
}
// do a full search for high codepoints
return wcwidthHigh(num);
};
})({nul: 0, control: 0}); // configurable options
// test full BMP range old vs new implmenetation
for (let i = 0; i < 65536; ++i) {
assert.equal(wcwidth(i), wcwidthOld(i), `mismatch for i: ${i}`);
}
});
+158 -148
View File
@@ -3,159 +3,169 @@
* @license MIT
*/
import { fill } from './common/TypedArrayUtils';
export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: number) => number {
// extracted from https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c
// combining characters
const COMBINING_BMP = [
[0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
[0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],
[0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],
[0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],
[0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],
[0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],
[0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],
[0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],
[0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],
[0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],
[0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],
[0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],
[0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],
[0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],
[0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],
[0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],
[0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],
[0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],
[0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],
[0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],
[0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],
[0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],
[0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],
[0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],
[0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],
[0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],
[0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],
[0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],
[0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],
[0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],
[0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],
[0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],
[0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],
[0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],
[0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],
[0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],
[0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],
[0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],
[0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],
[0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],
[0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],
[0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
[0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB],
];
const COMBINING_HIGH = [
[0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],
[0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],
[0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],
[0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],
[0xE0100, 0xE01EF]
];
// binary search
function bisearch(ucs: number, data: number[][]): boolean {
let min = 0;
let max = data.length - 1;
let mid;
if (ucs < data[0][0] || ucs > data[max][1])
return false;
while (max >= min) {
mid = (min + max) >> 1;
if (ucs > data[mid][1])
min = mid + 1;
else if (ucs < data[mid][0])
max = mid - 1;
else
return true;
}
// extracted from https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c
// combining characters
const COMBINING_BMP = [
[0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
[0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],
[0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],
[0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],
[0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],
[0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],
[0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],
[0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],
[0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],
[0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],
[0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],
[0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],
[0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],
[0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],
[0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],
[0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],
[0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],
[0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],
[0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],
[0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],
[0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],
[0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],
[0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],
[0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],
[0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],
[0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],
[0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],
[0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],
[0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],
[0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],
[0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],
[0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],
[0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],
[0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],
[0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],
[0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],
[0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],
[0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],
[0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],
[0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],
[0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],
[0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
[0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]
];
const COMBINING_HIGH = [
[0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],
[0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],
[0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],
[0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],
[0xE0100, 0xE01EF]
];
// binary search
function bisearch(ucs: number, data: number[][]): boolean {
let min = 0;
let max = data.length - 1;
let mid;
if (ucs < data[0][0] || ucs > data[max][1]) {
return false;
}
function wcwidthBMP(ucs: number): number {
// test for 8-bit control characters
if (ucs === 0)
return opts.nul;
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
return opts.control;
// binary search in table of non-spacing characters
if (bisearch(ucs, COMBINING_BMP))
return 0;
// if we arrive here, ucs is not a combining or C0/C1 control character
if (isWideBMP(ucs)) {
return 2;
while (max >= min) {
mid = (min + max) >> 1;
if (ucs > data[mid][1]) {
min = mid + 1;
} else if (ucs < data[mid][0]) {
max = mid - 1;
} else {
return true;
}
}
return false;
}
function wcwidthHigh(ucs: number): 0 | 1 | 2 {
if (bisearch(ucs, COMBINING_HIGH)) {
return 0;
}
if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
return 2;
}
return 1;
}
const control = opts.control | 0;
// create lookup table for BMP plane
const table = new Uint8Array(65536);
fill(table, 1);
table[0] = opts.nul;
// control chars
fill(table, opts.control, 1, 32);
fill(table, opts.control, 0x7f, 0xa0);
// apply wide char rules first
// wide chars
fill(table, 2, 0x1100, 0x1160);
table[0x2329] = 2;
table[0x232a] = 2;
fill(table, 2, 0x2e80, 0xa4d0);
table[0x303f] = 1; // wrongly in last line
fill(table, 2, 0xac00, 0xd7a4);
fill(table, 2, 0xf900, 0xfb00);
fill(table, 2, 0xfe10, 0xfe1a);
fill(table, 2, 0xfe30, 0xfe70);
fill(table, 2, 0xff00, 0xff61);
fill(table, 2, 0xffe0, 0xffe7);
// apply combining last to ensure we overwrite
// wrongly wide set chars:
// the original algo evals combining first and falls
// through to wide check so we simply do here the opposite
// combining 0
for (let r = 0; r < COMBINING_BMP.length; ++r) {
fill(table, 0, COMBINING_BMP[r][0], COMBINING_BMP[r][1] + 1);
}
return function (num: number): number {
if (num < 32) {
return control | 0;
}
if (num < 127) {
return 1;
}
function isWideBMP(ucs: number): boolean {
return (
ucs >= 0x1100 && (
ucs <= 0x115f || // Hangul Jamo init. consonants
ucs === 0x2329 ||
ucs === 0x232a ||
(ucs >= 0x2e80 && ucs <= 0xa4cf && ucs !== 0x303f) || // CJK..Yi
(ucs >= 0xac00 && ucs <= 0xd7a3) || // Hangul Syllables
(ucs >= 0xf900 && ucs <= 0xfaff) || // CJK Compat Ideographs
(ucs >= 0xfe10 && ucs <= 0xfe19) || // Vertical forms
(ucs >= 0xfe30 && ucs <= 0xfe6f) || // CJK Compat Forms
(ucs >= 0xff00 && ucs <= 0xff60) || // Fullwidth Forms
(ucs >= 0xffe0 && ucs <= 0xffe6)));
if (num < 65536) {
return table[num];
}
function wcwidthHigh(ucs: number): 0 | 1 | 2 {
if (bisearch(ucs, COMBINING_HIGH))
return 0;
if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
return 2;
}
return 1;
}
const control = opts.control | 0;
let table: number[] | Uint32Array = null;
function init_table(): number[] | Uint32Array {
// lookup table for BMP
const CODEPOINTS = 65536; // BMP holds 65536 codepoints
const BITWIDTH = 2; // a codepoint can have a width of 0, 1 or 2
const ITEMSIZE = 32; // using uint32_t
const CONTAINERSIZE = CODEPOINTS * BITWIDTH / ITEMSIZE;
const CODEPOINTS_PER_ITEM = ITEMSIZE / BITWIDTH;
table = (typeof Uint32Array === 'undefined')
? new Array(CONTAINERSIZE)
: new Uint32Array(CONTAINERSIZE);
for (let i = 0; i < CONTAINERSIZE; ++i) {
let num = 0;
let pos = CODEPOINTS_PER_ITEM;
while (pos--)
num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos);
table[i] = num;
}
return table;
}
// get width from lookup table
// position in container : num / CODEPOINTS_PER_ITEM
// ==> n = table[Math.floor(num / 16)]
// ==> n = table[num >> 4]
// 16 codepoints per number: FFEEDDCCBBAA99887766554433221100
// position in number : (num % CODEPOINTS_PER_ITEM) * BITWIDTH
// ==> m = (n % 16) * 2
// ==> m = (num & 15) << 1
// right shift to position m
// ==> n = n >> m e.g. m=12 000000000000FFEEDDCCBBAA99887766
// we are only interested in 2 LSBs, cut off higher bits
// ==> n = n & 3 e.g. 000000000000000000000000000000XX
return function (num: number): number {
num = num | 0; // get asm.js like optimization under V8
if (num < 32)
return control | 0;
if (num < 127)
return 1;
let t = table || init_table();
if (num < 65536)
return t[num >> 4] >> ((num & 15) << 1) & 3;
// do a full search for high codepoints
return wcwidthHigh(num);
};
// do a full search for high codepoints
return wcwidthHigh(num);
};
})({nul: 0, control: 0}); // configurable options
/**
* Get the terminal cell width for a string.
*/
export function getStringCellWidth(s: string): number {
let result = 0;
const length = s.length;
for (let i = 0; i < length; ++i) {
let code = s.charCodeAt(i);
// surrogate pair first
if (0xD800 <= code && code <= 0xDBFF) {
if (++i >= length) {
// this should not happen with strings retrieved from
// Buffer.translateToString as it converts from UTF-32
// and therefore always should contain the second part
// for any other string we still have to handle it somehow:
// simply treat the lonely surrogate first as a single char (UCS-2 behavior)
return result + wcwidth(code);
}
const second = s.charCodeAt(i);
// convert surrogate pair to high codepoint only for valid second part (UTF-16)
// otherwise treat them independently (UCS-2 behavior)
if (0xDC00 <= second && second <= 0xDFFF) {
code = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
} else {
result += wcwidth(second);
}
}
result += wcwidth(code);
}
return result;
}
@@ -4,17 +4,22 @@
*/
import { assert } from 'chai';
import * as Terminal from '../Terminal';
import * as Clipboard from './Clipboard';
describe('evaluatePastedTextProcessing', () => {
it('should replace carriage return + line feed with line feed on windows', () => {
const pastedText = 'foo\r\nbar\r\n';
const processedText = Clipboard.prepareTextForTerminal(pastedText, false);
const windowsProcessedText = Clipboard.prepareTextForTerminal(pastedText, true);
it('should replace carriage return and/or line feed with carriage return', () => {
const pastedText = {
unix: 'foo\nbar\n',
windows: 'foo\r\nbar\r\n'
};
assert.equal(processedText, 'foo\r\nbar\r\n');
assert.equal(windowsProcessedText, 'foo\rbar\r');
const processedText = {
unix: Clipboard.prepareTextForTerminal(pastedText.unix),
windows: Clipboard.prepareTextForTerminal(pastedText.windows)
};
assert.equal(processedText.unix, 'foo\rbar\r');
assert.equal(processedText.windows, 'foo\rbar\r');
});
it('should bracket pasted text in bracketedPasteMode', () => {
const pastedText = 'foo bar';
+40 -31
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { ITerminal, ISelectionManager } from '../Interfaces';
import { ITerminal, ISelectionManager } from './Types';
interface IWindow extends Window {
clipboardData?: {
@@ -18,11 +18,8 @@ declare var window: IWindow;
* Prepares text to be pasted into the terminal by normalizing the line endings
* @param text The pasted text that needs processing before inserting into the terminal
*/
export function prepareTextForTerminal(text: string, isMSWindows: boolean): string {
if (isMSWindows) {
return text.replace(/\r?\n/g, '\r');
}
return text;
export function prepareTextForTerminal(text: string): string {
return text.replace(/\r?\n/g, '\r');
}
/**
@@ -38,7 +35,7 @@ export function bracketTextForPaste(text: string, bracketedPasteMode: boolean):
/**
* Binds copy functionality to the given terminal.
* @param {ClipboardEvent} ev The original copy event to be handled
* @param ev The original copy event to be handled
*/
export function copyHandler(ev: ClipboardEvent, term: ITerminal, selectionManager: ISelectionManager): void {
if (term.browser.isMSIE) {
@@ -53,16 +50,16 @@ export function copyHandler(ev: ClipboardEvent, term: ITerminal, selectionManage
/**
* 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
* @param ev The original paste event to be handled
* @param term The terminal on which to apply the handled paste event
*/
export function pasteHandler(ev: ClipboardEvent, term: ITerminal): void {
ev.stopPropagation();
let text: string;
let dispatchPaste = function(text: string): void {
text = prepareTextForTerminal(text, term.browser.isMSWindows);
const dispatchPaste = function(text: string): void {
text = prepareTextForTerminal(text);
text = bracketTextForPaste(text, term.bracketedPasteMode);
term.handler(text);
term.textarea.value = '';
@@ -88,26 +85,33 @@ export function pasteHandler(ev: ClipboardEvent, term: ITerminal): void {
* @param ev The original right click event to be handled.
* @param textarea The terminal's textarea.
*/
export function moveTextAreaUnderMouseCursor(ev: MouseEvent, textarea: HTMLTextAreaElement): void {
// Bring textarea at the cursor position
textarea.style.position = 'fixed';
textarea.style.width = '20px';
textarea.style.height = '20px';
textarea.style.left = (ev.clientX - 10) + 'px';
textarea.style.top = (ev.clientY - 10) + 'px';
textarea.style.zIndex = '1000';
export function moveTextAreaUnderMouseCursor(ev: MouseEvent, term: ITerminal): void {
textarea.focus();
// Calculate textarea position relative to the screen element
const pos = term.screenElement.getBoundingClientRect();
const left = ev.clientX - pos.left - 10;
const top = ev.clientY - pos.top - 10;
// Bring textarea at the cursor position
term.textarea.style.position = 'absolute';
term.textarea.style.width = '20px';
term.textarea.style.height = '20px';
term.textarea.style.left = `${left}px`;
term.textarea.style.top = `${top}px`;
term.textarea.style.zIndex = '1000';
term.textarea.focus();
// Reset the terminal textarea's styling
// Timeout needs to be long enough for click event to be handled.
setTimeout(() => {
textarea.style.position = null;
textarea.style.width = null;
textarea.style.height = null;
textarea.style.left = null;
textarea.style.top = null;
textarea.style.zIndex = null;
}, 4);
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;
}, 200);
}
/**
@@ -115,11 +119,16 @@ export function moveTextAreaUnderMouseCursor(ev: MouseEvent, textarea: HTMLTextA
* @param ev The original right click event to be handled.
* @param textarea The terminal's textarea.
* @param selectionManager The terminal's selection manager.
* @param shouldSelectWord If true and there is no selection the current word will be selected
*/
export function rightClickHandler(ev: MouseEvent, textarea: HTMLTextAreaElement, selectionManager: ISelectionManager): void {
moveTextAreaUnderMouseCursor(ev, textarea);
export function rightClickHandler(ev: MouseEvent, term: ITerminal, selectionManager: ISelectionManager, shouldSelectWord: boolean): void {
moveTextAreaUnderMouseCursor(ev, term);
if (shouldSelectWord && !selectionManager.isClickInSelection(ev)) {
selectionManager.selectWordAtCursor(ev);
}
// Get textarea ready to copy from the context menu
textarea.value = selectionManager.selectionText;
textarea.select();
term.textarea.value = selectionManager.selectionText;
term.textarea.select();
}
+34 -33
View File
@@ -5,19 +5,20 @@
import { assert } from 'chai';
import { CompositionHelper } from './CompositionHelper';
import { ITerminal } from './Types';
describe('CompositionHelper', () => {
let terminal;
let compositionHelper;
let compositionView;
let textarea;
let handledText;
let terminal: ITerminal;
let compositionHelper: CompositionHelper;
let compositionView: HTMLElement;
let textarea: HTMLTextAreaElement;
let handledText: string;
beforeEach(() => {
compositionView = {
classList: {
add: () => {},
remove: () => {},
remove: () => {}
},
getBoundingClientRect: () => {
return { width: 0 };
@@ -27,14 +28,14 @@ describe('CompositionHelper', () => {
top: 0
},
textContent: ''
};
} as any;
textarea = {
value: '',
style: {
left: 0,
top: 0
}
};
} as any;
terminal = {
element: {
querySelector: () => {
@@ -54,7 +55,7 @@ describe('CompositionHelper', () => {
options: {
lineHeight: 1
}
};
} as any;
handledText = '';
compositionHelper = new CompositionHelper(textarea, compositionView, terminal);
});
@@ -63,7 +64,7 @@ describe('CompositionHelper', () => {
it('Should insert simple characters', (done) => {
// First character 'ㅇ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
compositionHelper.compositionupdate(<CompositionEvent><CompositionEvent>{ data: 'ㅇ' });
textarea.value = 'ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
@@ -71,7 +72,7 @@ describe('CompositionHelper', () => {
assert.equal(handledText, 'ㅇ');
// Second character 'ㅇ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
compositionHelper.compositionupdate(<CompositionEvent><CompositionEvent>{ data: 'ㅇ' });
textarea.value = 'ㅇㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
@@ -87,13 +88,13 @@ describe('CompositionHelper', () => {
it('Should insert complex characters', (done) => {
// First character '앙'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'ㅇ' });
textarea.value = 'ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '아' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: '아' });
textarea.value = '아';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '앙' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: '앙' });
textarea.value = '앙';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
@@ -101,13 +102,13 @@ describe('CompositionHelper', () => {
assert.equal(handledText, '앙');
// Second character '앙'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'ㅇ' });
textarea.value = '앙ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '아' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: '아' });
textarea.value = '앙아';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '앙' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: '앙' });
textarea.value = '앙앙';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
@@ -127,19 +128,19 @@ describe('CompositionHelper', () => {
it('Should insert complex characters that change with following character', (done) => {
// First character '아'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'ㅇ' });
textarea.value = 'ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: '아' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: '아' });
textarea.value = '아';
setTimeout(() => { // wait for any textarea updates
// Start second character '아' in first character
compositionHelper.compositionupdate({ data: '앙' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: '앙' });
textarea.value = '앙';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: '아' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: '아' });
textarea.value = '아아';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
@@ -156,14 +157,14 @@ describe('CompositionHelper', () => {
it('Should insert multi-characters compositions', (done) => {
// First character 'だ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'd' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'd' });
textarea.value = 'd';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: 'だ' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'だ' });
textarea.value = 'だ';
setTimeout(() => { // wait for any textarea updates
// Second character 'あ'
compositionHelper.compositionupdate({ data: 'だあ' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'だあ' });
textarea.value = 'だあ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
@@ -179,18 +180,18 @@ describe('CompositionHelper', () => {
it('Should insert multi-character compositions that are converted to other characters with the same length', (done) => {
// First character 'だ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'd' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'd' });
textarea.value = 'd';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: 'だ' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'だ' });
textarea.value = 'だ';
setTimeout(() => { // wait for any textarea updates
// Second character 'ー'
compositionHelper.compositionupdate({ data: 'だー' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'だー' });
textarea.value = 'だー';
setTimeout(() => { // wait for any textarea updates
// Convert to katakana 'ダー'
compositionHelper.compositionupdate({ data: 'ダー' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'ダー' });
textarea.value = 'ダー';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
@@ -207,18 +208,18 @@ describe('CompositionHelper', () => {
it('Should insert multi-character compositions that are converted to other characters with different lengths', (done) => {
// First character 'い'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'い' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'い' });
textarea.value = 'い';
setTimeout(() => { // wait for any textarea updates
// Second character 'ま'
compositionHelper.compositionupdate({ data: 'いm' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'いm' });
textarea.value = 'いm';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionupdate({ data: 'いま' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'いま' });
textarea.value = 'いま';
setTimeout(() => { // wait for any textarea updates
// Convert to kanji '今'
compositionHelper.compositionupdate({ data: '今' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: '今' });
textarea.value = '今';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
@@ -235,7 +236,7 @@ describe('CompositionHelper', () => {
it('Should insert non-composition characters input immediately after composition characters', (done) => {
// First character 'ㅇ'
compositionHelper.compositionstart();
compositionHelper.compositionupdate({ data: 'ㅇ' });
compositionHelper.compositionupdate(<CompositionEvent>{ data: 'ㅇ' });
textarea.value = 'ㅇ';
setTimeout(() => { // wait for any textarea updates
compositionHelper.compositionend();
+74 -73
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { ITerminal } from './Interfaces';
import { ITerminal } from './Types';
interface IPosition {
start: number;
@@ -20,54 +20,54 @@ 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;
private _isComposing: boolean;
/**
* The position within the input textarea's value of the current composition.
*/
private compositionPosition: IPosition;
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;
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.
* @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
private _textarea: HTMLTextAreaElement,
private _compositionView: HTMLElement,
private _terminal: ITerminal
) {
this.isComposing = false;
this.isSendingComposition = false;
this.compositionPosition = { start: null, end: null };
this._isComposing = false;
this._isSendingComposition = false;
this._compositionPosition = { start: null, end: null };
}
/**
* Handles the compositionstart event, activating the composition view.
*/
public compositionstart(): void {
this.isComposing = true;
this.compositionPosition.start = this.textarea.value.length;
this.compositionView.textContent = '';
this.compositionView.classList.add('active');
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.
* @param ev The event.
*/
public compositionupdate(ev: CompositionEvent): void {
this.compositionView.textContent = ev.data;
this._compositionView.textContent = ev.data;
this.updateCompositionElements();
setTimeout(() => {
this.compositionPosition.end = this.textarea.value.length;
this._compositionPosition.end = this._textarea.value.length;
}, 0);
}
@@ -76,7 +76,7 @@ export class CompositionHelper {
* the handler.
*/
public compositionend(): void {
this.finalizeComposition(true);
this._finalizeComposition(true);
}
/**
@@ -85,24 +85,23 @@ export class CompositionHelper {
* @return Whether the Terminal should continue processing the keydown event.
*/
public keydown(ev: KeyboardEvent): boolean {
if (this.isComposing || this.isSendingComposition) {
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);
}
// 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();
this._handleAnyTextareaChanges();
return false;
}
@@ -112,53 +111,53 @@ export class CompositionHelper {
/**
* 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
* @param waitForPropagation Whether to wait for events to propagate 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
* compositionend event is triggered, such as enter, so that the composition is sent before
* the command is executed.
*/
private finalizeComposition(waitForPropogation: boolean): void {
this.compositionView.classList.remove('active');
this.isComposing = false;
this.clearTextareaPosition();
private _finalizeComposition(waitForPropagation: boolean): void {
this._compositionView.classList.remove('active');
this._isComposing = false;
this._clearTextareaPosition();
if (!waitForPropogation) {
if (!waitForPropagation) {
// Cancel any delayed composition send requests and send the input immediately.
this.isSendingComposition = false;
const input = this.textarea.value.substring(this.compositionPosition.start, this.compositionPosition.end);
this.terminal.handler(input);
this._isSendingComposition = false;
const 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.
const currentCompositionPosition = {
start: this.compositionPosition.start,
end: this.compositionPosition.end,
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:
// 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.
this.isSendingComposition = true;
this._isSendingComposition = true;
setTimeout(() => {
// Ensure that the input has not already been sent
if (this.isSendingComposition) {
this.isSendingComposition = false;
if (this._isSendingComposition) {
this._isSendingComposition = false;
let input;
if (this.isComposing) {
if (this._isComposing) {
// Use the end position to get the string if a new composition has started.
input = this.textarea.value.substring(currentCompositionPosition.start, currentCompositionPosition.end);
input = this._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 = this.textarea.value.substring(currentCompositionPosition.start);
input = this._textarea.value.substring(currentCompositionPosition.start);
}
this.terminal.handler(input);
this._terminal.handler(input);
}
}, 0);
}
@@ -170,15 +169,15 @@ export class CompositionHelper {
* character" (229) is triggered, in order to allow non-composition text to be entered when an
* IME is active.
*/
private handleAnyTextareaChanges(): void {
const oldValue = this.textarea.value;
private _handleAnyTextareaChanges(): void {
const oldValue = this._textarea.value;
setTimeout(() => {
// Ignore if a composition has started since the timeout
if (!this.isComposing) {
const newValue = this.textarea.value;
if (!this._isComposing) {
const newValue = this._textarea.value;
const diff = newValue.replace(oldValue, '');
if (diff.length > 0) {
this.terminal.handler(diff);
this._terminal.handler(diff);
}
}
}, 0);
@@ -191,40 +190,42 @@ export class CompositionHelper {
* necessary as the IME events across browsers are not consistently triggered.
*/
public updateCompositionElements(dontRecurse?: boolean): void {
if (!this.isComposing) {
if (!this._isComposing) {
return;
}
if (this.terminal.buffer.isCursorInViewport) {
const cellHeight = Math.ceil(this.terminal.charMeasure.height * this.terminal.options.lineHeight);
const cursorTop = this.terminal.buffer.y * cellHeight;
const cursorLeft = this.terminal.buffer.x * this.terminal.charMeasure.width;
if (this._terminal.buffer.isCursorInViewport) {
const cellHeight = Math.ceil(this._terminal.charMeasure.height * this._terminal.options.lineHeight);
const cursorTop = this._terminal.buffer.y * cellHeight;
const cursorLeft = this._terminal.buffer.x * this._terminal.charMeasure.width;
this.compositionView.style.left = cursorLeft + 'px';
this.compositionView.style.top = cursorTop + 'px';
this.compositionView.style.height = cellHeight + 'px';
this.compositionView.style.lineHeight = cellHeight + 'px';
this._compositionView.style.left = cursorLeft + 'px';
this._compositionView.style.top = cursorTop + 'px';
this._compositionView.style.height = cellHeight + 'px';
this._compositionView.style.lineHeight = cellHeight + 'px';
this._compositionView.style.fontFamily = this._terminal.options.fontFamily;
this._compositionView.style.fontSize = this._terminal.options.fontSize + 'px';
// Sync the textarea to the exact position of the composition view so the IME knows where the
// text is.
const compositionViewBounds = this.compositionView.getBoundingClientRect();
this.textarea.style.left = cursorLeft + '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';
const compositionViewBounds = this._compositionView.getBoundingClientRect();
this._textarea.style.left = cursorLeft + '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(true), 0);
}
};
}
/**
* Clears the textarea's position so that the cursor does not blink on IE.
* @private
*/
private clearTextareaPosition(): void {
this.textarea.style.left = '';
this.textarea.style.top = '';
};
private _clearTextareaPosition(): void {
this._textarea.style.left = '';
this._textarea.style.top = '';
}
}
File diff suppressed because it is too large Load Diff
+632
View File
@@ -0,0 +1,632 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { ParserState, ParserAction, IParsingState, IDcsHandler, IEscapeSequenceParser } from './Types';
import { IDisposable } from 'xterm';
import { Disposable } from './common/Lifecycle';
import { utf32ToString } from './core/input/TextDecoder';
interface IHandlerCollection<T> {
[key: string]: T[];
}
type CsiHandler = (params: number[], collect: string) => boolean | void;
type OscHandler = (data: string) => boolean | void;
/**
* Returns an array filled with numbers between the low and high parameters (right exclusive).
* @param low The low number.
* @param high The high number.
*/
function r(low: number, high: number): number[] {
let c = high - low;
const arr = new Array(c);
while (c--) {
arr[c] = --high;
}
return arr;
}
/**
* Transition table for EscapeSequenceParser.
* NOTE: data in the underlying table is packed like this:
* currentState << 8 | characterCode --> action << 4 | nextState
*/
export class TransitionTable {
public table: Uint8Array | number[];
constructor(length: number) {
this.table = (typeof Uint8Array === 'undefined')
? new Array(length)
: new Uint8Array(length);
}
/**
* Add a transition to the transition table.
* @param code input character code
* @param state current parser state
* @param action parser action to be done
* @param next next parser state
*/
add(code: number, state: number, action: number | null, next: number | null): void {
this.table[state << 8 | code] = ((action | 0) << 4) | ((next === undefined) ? state : next);
}
/**
* Add transitions for multiple input character codes.
* @param codes input character code array
* @param state current parser state
* @param action parser action to be done
* @param next next parser state
*/
addMany(codes: number[], state: number, action: number | null, next: number | null): void {
for (let i = 0; i < codes.length; i++) {
this.add(codes[i], state, action, next);
}
}
}
/**
* Default definitions for the VT500_TRANSITION_TABLE.
*/
const PRINTABLES = r(0x20, 0x7f);
const EXECUTABLES = r(0x00, 0x18);
EXECUTABLES.push(0x19);
EXECUTABLES.push.apply(EXECUTABLES, r(0x1c, 0x20));
// Pseudo-character placeholder for printable non-ascii characters.
const NON_ASCII_PRINTABLE = 0xA0;
/**
* VT500 compatible transition table.
* Taken from https://vt100.net/emu/dec_ansi_parser.
*/
export const VT500_TRANSITION_TABLE = (function (): TransitionTable {
const table: TransitionTable = new TransitionTable(4095);
const states: number[] = r(ParserState.GROUND, ParserState.DCS_PASSTHROUGH + 1);
let state: any;
// table with default transition
for (state in states) {
// NOTE: table lookup is capped at 0xa0 in parse to keep the table small
for (let code = 0; code <= NON_ASCII_PRINTABLE; ++code) {
table.add(code, state, ParserAction.ERROR, ParserState.GROUND);
}
}
// printables
table.addMany(PRINTABLES, ParserState.GROUND, ParserAction.PRINT, ParserState.GROUND);
// global anywhere rules
for (state in states) {
table.addMany([0x18, 0x1a, 0x99, 0x9a], state, ParserAction.EXECUTE, ParserState.GROUND);
table.addMany(r(0x80, 0x90), state, ParserAction.EXECUTE, ParserState.GROUND);
table.addMany(r(0x90, 0x98), state, ParserAction.EXECUTE, ParserState.GROUND);
table.add(0x9c, state, ParserAction.IGNORE, ParserState.GROUND); // ST as terminator
table.add(0x1b, state, ParserAction.CLEAR, ParserState.ESCAPE); // ESC
table.add(0x9d, state, ParserAction.OSC_START, ParserState.OSC_STRING); // OSC
table.addMany([0x98, 0x9e, 0x9f], state, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);
table.add(0x9b, state, ParserAction.CLEAR, ParserState.CSI_ENTRY); // CSI
table.add(0x90, state, ParserAction.CLEAR, ParserState.DCS_ENTRY); // DCS
}
// rules for executables and 7f
table.addMany(EXECUTABLES, ParserState.GROUND, ParserAction.EXECUTE, ParserState.GROUND);
table.addMany(EXECUTABLES, ParserState.ESCAPE, ParserAction.EXECUTE, ParserState.ESCAPE);
table.add(0x7f, ParserState.ESCAPE, ParserAction.IGNORE, ParserState.ESCAPE);
table.addMany(EXECUTABLES, ParserState.OSC_STRING, ParserAction.IGNORE, ParserState.OSC_STRING);
table.addMany(EXECUTABLES, ParserState.CSI_ENTRY, ParserAction.EXECUTE, ParserState.CSI_ENTRY);
table.add(0x7f, ParserState.CSI_ENTRY, ParserAction.IGNORE, ParserState.CSI_ENTRY);
table.addMany(EXECUTABLES, ParserState.CSI_PARAM, ParserAction.EXECUTE, ParserState.CSI_PARAM);
table.add(0x7f, ParserState.CSI_PARAM, ParserAction.IGNORE, ParserState.CSI_PARAM);
table.addMany(EXECUTABLES, ParserState.CSI_IGNORE, ParserAction.EXECUTE, ParserState.CSI_IGNORE);
table.addMany(EXECUTABLES, ParserState.CSI_INTERMEDIATE, ParserAction.EXECUTE, ParserState.CSI_INTERMEDIATE);
table.add(0x7f, ParserState.CSI_INTERMEDIATE, ParserAction.IGNORE, ParserState.CSI_INTERMEDIATE);
table.addMany(EXECUTABLES, ParserState.ESCAPE_INTERMEDIATE, ParserAction.EXECUTE, ParserState.ESCAPE_INTERMEDIATE);
table.add(0x7f, ParserState.ESCAPE_INTERMEDIATE, ParserAction.IGNORE, ParserState.ESCAPE_INTERMEDIATE);
// osc
table.add(0x5d, ParserState.ESCAPE, ParserAction.OSC_START, ParserState.OSC_STRING);
table.addMany(PRINTABLES, ParserState.OSC_STRING, ParserAction.OSC_PUT, ParserState.OSC_STRING);
table.add(0x7f, ParserState.OSC_STRING, ParserAction.OSC_PUT, ParserState.OSC_STRING);
table.addMany([0x9c, 0x1b, 0x18, 0x1a, 0x07], ParserState.OSC_STRING, ParserAction.OSC_END, ParserState.GROUND);
table.addMany(r(0x1c, 0x20), ParserState.OSC_STRING, ParserAction.IGNORE, ParserState.OSC_STRING);
// sos/pm/apc does nothing
table.addMany([0x58, 0x5e, 0x5f], ParserState.ESCAPE, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);
table.addMany(PRINTABLES, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);
table.addMany(EXECUTABLES, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);
table.add(0x9c, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.GROUND);
table.add(0x7f, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);
// csi entries
table.add(0x5b, ParserState.ESCAPE, ParserAction.CLEAR, ParserState.CSI_ENTRY);
table.addMany(r(0x40, 0x7f), ParserState.CSI_ENTRY, ParserAction.CSI_DISPATCH, ParserState.GROUND);
table.addMany(r(0x30, 0x3a), ParserState.CSI_ENTRY, ParserAction.PARAM, ParserState.CSI_PARAM);
table.add(0x3b, ParserState.CSI_ENTRY, ParserAction.PARAM, ParserState.CSI_PARAM);
table.addMany([0x3c, 0x3d, 0x3e, 0x3f], ParserState.CSI_ENTRY, ParserAction.COLLECT, ParserState.CSI_PARAM);
table.addMany(r(0x30, 0x3a), ParserState.CSI_PARAM, ParserAction.PARAM, ParserState.CSI_PARAM);
table.add(0x3b, ParserState.CSI_PARAM, ParserAction.PARAM, ParserState.CSI_PARAM);
table.addMany(r(0x40, 0x7f), ParserState.CSI_PARAM, ParserAction.CSI_DISPATCH, ParserState.GROUND);
table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], ParserState.CSI_PARAM, ParserAction.IGNORE, ParserState.CSI_IGNORE);
table.addMany(r(0x20, 0x40), ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.CSI_IGNORE);
table.add(0x7f, ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.CSI_IGNORE);
table.addMany(r(0x40, 0x7f), ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.GROUND);
table.add(0x3a, ParserState.CSI_ENTRY, ParserAction.IGNORE, ParserState.CSI_IGNORE);
table.addMany(r(0x20, 0x30), ParserState.CSI_ENTRY, ParserAction.COLLECT, ParserState.CSI_INTERMEDIATE);
table.addMany(r(0x20, 0x30), ParserState.CSI_INTERMEDIATE, ParserAction.COLLECT, ParserState.CSI_INTERMEDIATE);
table.addMany(r(0x30, 0x40), ParserState.CSI_INTERMEDIATE, ParserAction.IGNORE, ParserState.CSI_IGNORE);
table.addMany(r(0x40, 0x7f), ParserState.CSI_INTERMEDIATE, ParserAction.CSI_DISPATCH, ParserState.GROUND);
table.addMany(r(0x20, 0x30), ParserState.CSI_PARAM, ParserAction.COLLECT, ParserState.CSI_INTERMEDIATE);
// esc_intermediate
table.addMany(r(0x20, 0x30), ParserState.ESCAPE, ParserAction.COLLECT, ParserState.ESCAPE_INTERMEDIATE);
table.addMany(r(0x20, 0x30), ParserState.ESCAPE_INTERMEDIATE, ParserAction.COLLECT, ParserState.ESCAPE_INTERMEDIATE);
table.addMany(r(0x30, 0x7f), ParserState.ESCAPE_INTERMEDIATE, ParserAction.ESC_DISPATCH, ParserState.GROUND);
table.addMany(r(0x30, 0x50), ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);
table.addMany(r(0x51, 0x58), ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);
table.addMany([0x59, 0x5a, 0x5c], ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);
table.addMany(r(0x60, 0x7f), ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);
// dcs entry
table.add(0x50, ParserState.ESCAPE, ParserAction.CLEAR, ParserState.DCS_ENTRY);
table.addMany(EXECUTABLES, ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_ENTRY);
table.add(0x7f, ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_ENTRY);
table.addMany(r(0x1c, 0x20), ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_ENTRY);
table.addMany(r(0x20, 0x30), ParserState.DCS_ENTRY, ParserAction.COLLECT, ParserState.DCS_INTERMEDIATE);
table.add(0x3a, ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_IGNORE);
table.addMany(r(0x30, 0x3a), ParserState.DCS_ENTRY, ParserAction.PARAM, ParserState.DCS_PARAM);
table.add(0x3b, ParserState.DCS_ENTRY, ParserAction.PARAM, ParserState.DCS_PARAM);
table.addMany([0x3c, 0x3d, 0x3e, 0x3f], ParserState.DCS_ENTRY, ParserAction.COLLECT, ParserState.DCS_PARAM);
table.addMany(EXECUTABLES, ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);
table.addMany(r(0x20, 0x80), ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);
table.addMany(r(0x1c, 0x20), ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);
table.addMany(EXECUTABLES, ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_PARAM);
table.add(0x7f, ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_PARAM);
table.addMany(r(0x1c, 0x20), ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_PARAM);
table.addMany(r(0x30, 0x3a), ParserState.DCS_PARAM, ParserAction.PARAM, ParserState.DCS_PARAM);
table.add(0x3b, ParserState.DCS_PARAM, ParserAction.PARAM, ParserState.DCS_PARAM);
table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_IGNORE);
table.addMany(r(0x20, 0x30), ParserState.DCS_PARAM, ParserAction.COLLECT, ParserState.DCS_INTERMEDIATE);
table.addMany(EXECUTABLES, ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_INTERMEDIATE);
table.add(0x7f, ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_INTERMEDIATE);
table.addMany(r(0x1c, 0x20), ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_INTERMEDIATE);
table.addMany(r(0x20, 0x30), ParserState.DCS_INTERMEDIATE, ParserAction.COLLECT, ParserState.DCS_INTERMEDIATE);
table.addMany(r(0x30, 0x40), ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_IGNORE);
table.addMany(r(0x40, 0x7f), ParserState.DCS_INTERMEDIATE, ParserAction.DCS_HOOK, ParserState.DCS_PASSTHROUGH);
table.addMany(r(0x40, 0x7f), ParserState.DCS_PARAM, ParserAction.DCS_HOOK, ParserState.DCS_PASSTHROUGH);
table.addMany(r(0x40, 0x7f), ParserState.DCS_ENTRY, ParserAction.DCS_HOOK, ParserState.DCS_PASSTHROUGH);
table.addMany(EXECUTABLES, ParserState.DCS_PASSTHROUGH, ParserAction.DCS_PUT, ParserState.DCS_PASSTHROUGH);
table.addMany(PRINTABLES, ParserState.DCS_PASSTHROUGH, ParserAction.DCS_PUT, ParserState.DCS_PASSTHROUGH);
table.add(0x7f, ParserState.DCS_PASSTHROUGH, ParserAction.IGNORE, ParserState.DCS_PASSTHROUGH);
table.addMany([0x1b, 0x9c], ParserState.DCS_PASSTHROUGH, ParserAction.DCS_UNHOOK, ParserState.GROUND);
table.add(NON_ASCII_PRINTABLE, ParserState.OSC_STRING, ParserAction.OSC_PUT, ParserState.OSC_STRING);
return table;
})();
/**
* Dummy DCS handler as default fallback.
*/
class DcsDummy implements IDcsHandler {
hook(collect: string, params: number[], flag: number): void { }
put(data: Uint32Array, start: number, end: number): void { }
unhook(): void { }
}
/**
* EscapeSequenceParser.
* This class implements the ANSI/DEC compatible parser described by
* Paul Williams (https://vt100.net/emu/dec_ansi_parser).
* To implement custom ANSI compliant escape sequences it is not needed to
* alter this parser, instead consider registering a custom handler.
* For non ANSI compliant sequences change the transition table with
* the optional `transitions` contructor argument and
* reimplement the `parse` method.
* NOTE: The parameter element notation is currently not supported.
* TODO: implement error recovery hook via error handler return values
*/
export class EscapeSequenceParser extends Disposable implements IEscapeSequenceParser {
public initialState: number;
public currentState: number;
// buffers over several parse calls
protected _osc: string;
protected _params: number[];
protected _collect: string;
// handler lookup containers
protected _printHandler: (data: Uint32Array, start: number, end: number) => void;
protected _executeHandlers: any;
protected _csiHandlers: IHandlerCollection<CsiHandler>;
protected _escHandlers: any;
protected _oscHandlers: IHandlerCollection<OscHandler>;
protected _dcsHandlers: any;
protected _activeDcsHandler: IDcsHandler | null;
protected _errorHandler: (state: IParsingState) => IParsingState;
// fallback handlers
protected _printHandlerFb: (data: Uint32Array, start: number, end: number) => void;
protected _executeHandlerFb: (code: number) => void;
protected _csiHandlerFb: (collect: string, params: number[], flag: number) => void;
protected _escHandlerFb: (collect: string, flag: number) => void;
protected _oscHandlerFb: (identifier: number, data: string) => void;
protected _dcsHandlerFb: IDcsHandler;
protected _errorHandlerFb: (state: IParsingState) => IParsingState;
constructor(readonly TRANSITIONS: TransitionTable = VT500_TRANSITION_TABLE) {
super();
this.initialState = ParserState.GROUND;
this.currentState = this.initialState;
this._osc = '';
this._params = [0];
this._collect = '';
// set default fallback handlers and handler lookup containers
this._printHandlerFb = (data, start, end): void => { };
this._executeHandlerFb = (code: number): void => { };
this._csiHandlerFb = (collect: string, params: number[], flag: number): void => { };
this._escHandlerFb = (collect: string, flag: number): void => { };
this._oscHandlerFb = (identifier: number, data: string): void => { };
this._dcsHandlerFb = new DcsDummy();
this._errorHandlerFb = (state: IParsingState): IParsingState => state;
this._printHandler = this._printHandlerFb;
this._executeHandlers = Object.create(null);
this._csiHandlers = Object.create(null);
this._escHandlers = Object.create(null);
this._oscHandlers = Object.create(null);
this._dcsHandlers = Object.create(null);
this._activeDcsHandler = null;
this._errorHandler = this._errorHandlerFb;
// swallow 7bit ST (ESC+\)
this.setEscHandler('\\', () => {});
}
public dispose(): void {
this._printHandlerFb = null;
this._executeHandlerFb = null;
this._csiHandlerFb = null;
this._escHandlerFb = null;
this._oscHandlerFb = null;
this._dcsHandlerFb = null;
this._errorHandlerFb = null;
this._printHandler = null;
this._executeHandlers = null;
this._escHandlers = null;
this._csiHandlers = null;
this._oscHandlers = null;
this._dcsHandlers = null;
this._activeDcsHandler = null;
this._errorHandler = null;
}
setPrintHandler(callback: (data: Uint32Array, start: number, end: number) => void): void {
this._printHandler = callback;
}
clearPrintHandler(): void {
this._printHandler = this._printHandlerFb;
}
setExecuteHandler(flag: string, callback: () => void): void {
this._executeHandlers[flag.charCodeAt(0)] = callback;
}
clearExecuteHandler(flag: string): void {
if (this._executeHandlers[flag.charCodeAt(0)]) delete this._executeHandlers[flag.charCodeAt(0)];
}
setExecuteHandlerFallback(callback: (code: number) => void): void {
this._executeHandlerFb = callback;
}
addCsiHandler(flag: string, callback: CsiHandler): IDisposable {
const index = flag.charCodeAt(0);
if (this._csiHandlers[index] === undefined) {
this._csiHandlers[index] = [];
}
const handlerList = this._csiHandlers[index];
handlerList.push(callback);
return {
dispose: () => {
const handlerIndex = handlerList.indexOf(callback);
if (handlerIndex !== -1) {
handlerList.splice(handlerIndex, 1);
}
}
};
}
setCsiHandler(flag: string, callback: (params: number[], collect: string) => void): void {
this._csiHandlers[flag.charCodeAt(0)] = [callback];
}
clearCsiHandler(flag: string): void {
if (this._csiHandlers[flag.charCodeAt(0)]) delete this._csiHandlers[flag.charCodeAt(0)];
}
setCsiHandlerFallback(callback: (collect: string, params: number[], flag: number) => void): void {
this._csiHandlerFb = callback;
}
setEscHandler(collectAndFlag: string, callback: () => void): void {
this._escHandlers[collectAndFlag] = callback;
}
clearEscHandler(collectAndFlag: string): void {
if (this._escHandlers[collectAndFlag]) delete this._escHandlers[collectAndFlag];
}
setEscHandlerFallback(callback: (collect: string, flag: number) => void): void {
this._escHandlerFb = callback;
}
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable {
if (this._oscHandlers[ident] === undefined) {
this._oscHandlers[ident] = [];
}
const handlerList = this._oscHandlers[ident];
handlerList.push(callback);
return {
dispose: () => {
const handlerIndex = handlerList.indexOf(callback);
if (handlerIndex !== -1) {
handlerList.splice(handlerIndex, 1);
}
}
};
}
setOscHandler(ident: number, callback: (data: string) => void): void {
this._oscHandlers[ident] = [callback];
}
clearOscHandler(ident: number): void {
if (this._oscHandlers[ident]) delete this._oscHandlers[ident];
}
setOscHandlerFallback(callback: (identifier: number, data: string) => void): void {
this._oscHandlerFb = callback;
}
setDcsHandler(collectAndFlag: string, handler: IDcsHandler): void {
this._dcsHandlers[collectAndFlag] = handler;
}
clearDcsHandler(collectAndFlag: string): void {
if (this._dcsHandlers[collectAndFlag]) delete this._dcsHandlers[collectAndFlag];
}
setDcsHandlerFallback(handler: IDcsHandler): void {
this._dcsHandlerFb = handler;
}
setErrorHandler(callback: (state: IParsingState) => IParsingState): void {
this._errorHandler = callback;
}
clearErrorHandler(): void {
this._errorHandler = this._errorHandlerFb;
}
reset(): void {
this.currentState = this.initialState;
this._osc = '';
this._params = [0];
this._collect = '';
this._activeDcsHandler = null;
}
parse(data: Uint32Array, length: number): void {
let code = 0;
let transition = 0;
let error = false;
let currentState = this.currentState;
let print = -1;
let dcs = -1;
let osc = this._osc;
let collect = this._collect;
let params = this._params;
const table: Uint8Array | number[] = this.TRANSITIONS.table;
let dcsHandler: IDcsHandler | null = this._activeDcsHandler;
let callback: Function | null = null;
// process input string
for (let i = 0; i < length; ++i) {
code = data[i];
// shortcut for most chars (print action)
if (currentState === ParserState.GROUND && code > 0x1f && code < 0x80) {
print = (~print) ? print : i;
do i++;
while (i < length && data[i] > 0x1f && data[i] < 0x80);
i--;
continue;
}
// shortcut for CSI params
if (currentState === ParserState.CSI_PARAM && (code > 0x2f && code < 0x39)) {
params[params.length - 1] = params[params.length - 1] * 10 + code - 48;
continue;
}
// normal transition & action lookup
transition = table[currentState << 8 | (code < 0xa0 ? code : NON_ASCII_PRINTABLE)];
switch (transition >> 4) {
case ParserAction.PRINT:
print = (~print) ? print : i;
break;
case ParserAction.EXECUTE:
if (~print) {
this._printHandler(data, print, i);
print = -1;
}
callback = this._executeHandlers[code];
if (callback) callback();
else this._executeHandlerFb(code);
break;
case ParserAction.IGNORE:
// handle leftover print or dcs chars
if (~print) {
this._printHandler(data, print, i);
print = -1;
} else if (~dcs) {
dcsHandler.put(data, dcs, i);
dcs = -1;
}
break;
case ParserAction.ERROR:
// chars higher than 0x9f are handled by this action
// to keep the transition table small
if (code > 0x9f) {
switch (currentState) {
case ParserState.GROUND:
print = (~print) ? print : i;
break;
case ParserState.CSI_IGNORE:
transition |= ParserState.CSI_IGNORE;
break;
case ParserState.DCS_IGNORE:
transition |= ParserState.DCS_IGNORE;
break;
case ParserState.DCS_PASSTHROUGH:
dcs = (~dcs) ? dcs : i;
transition |= ParserState.DCS_PASSTHROUGH;
break;
default:
error = true;
}
} else {
error = true;
}
// if we end up here a real error happened
if (error) {
const inject: IParsingState = this._errorHandler(
{
position: i,
code,
currentState,
print,
dcs,
osc,
collect,
params,
abort: false
});
if (inject.abort) return;
// TODO: inject return values
error = false;
}
break;
case ParserAction.CSI_DISPATCH:
// Trigger CSI Handler
const handlers = this._csiHandlers[code];
let j = handlers ? handlers.length - 1 : -1;
for (; j >= 0; j--) {
// undefined or true means success and to stop bubbling
if (handlers[j](params, collect) !== false) {
break;
}
}
if (j < 0) {
this._csiHandlerFb(collect, params, code);
}
break;
case ParserAction.PARAM:
if (code === 0x3b) params.push(0);
else params[params.length - 1] = params[params.length - 1] * 10 + code - 48;
break;
case ParserAction.COLLECT:
collect += String.fromCharCode(code);
break;
case ParserAction.ESC_DISPATCH:
callback = this._escHandlers[collect + String.fromCharCode(code)];
if (callback) callback(collect, code);
else this._escHandlerFb(collect, code);
break;
case ParserAction.CLEAR:
if (~print) {
this._printHandler(data, print, i);
print = -1;
}
osc = '';
params = [0];
collect = '';
dcs = -1;
break;
case ParserAction.DCS_HOOK:
dcsHandler = this._dcsHandlers[collect + String.fromCharCode(code)];
if (!dcsHandler) dcsHandler = this._dcsHandlerFb;
dcsHandler.hook(collect, params, code);
break;
case ParserAction.DCS_PUT:
dcs = (~dcs) ? dcs : i;
break;
case ParserAction.DCS_UNHOOK:
if (dcsHandler) {
if (~dcs) dcsHandler.put(data, dcs, i);
dcsHandler.unhook();
dcsHandler = null;
}
if (code === 0x1b) transition |= ParserState.ESCAPE;
osc = '';
params = [0];
collect = '';
dcs = -1;
break;
case ParserAction.OSC_START:
if (~print) {
this._printHandler(data, print, i);
print = -1;
}
osc = '';
break;
case ParserAction.OSC_PUT:
for (let j = i + 1; ; j++) {
if (j >= length
|| (code = data[j]) < 0x20
|| (code > 0x7f && code <= 0x9f)) {
osc += utf32ToString(data, i, j);
i = j - 1;
break;
}
}
break;
case ParserAction.OSC_END:
if (osc && code !== 0x18 && code !== 0x1a) {
// NOTE: OSC subparsing is not part of the original parser
// we do basic identifier parsing here to offer a jump table for OSC as well
const idx = osc.indexOf(';');
if (idx === -1) {
this._oscHandlerFb(-1, osc); // this is an error (malformed OSC)
} else {
// Note: NaN is not handled here
// either catch it with the fallback handler
// or with an explicit NaN OSC handler
const identifier = parseInt(osc.substring(0, idx));
const content = osc.substring(idx + 1);
// Trigger OSC Handler
const handlers = this._oscHandlers[identifier];
let j = handlers ? handlers.length - 1 : -1;
for (; j >= 0; j--) {
// undefined or true means success and to stop bubbling
if (handlers[j](content) !== false) {
break;
}
}
if (j < 0) {
this._oscHandlerFb(identifier, content);
}
}
}
if (code === 0x1b) transition |= ParserState.ESCAPE;
osc = '';
params = [0];
collect = '';
dcs = -1;
break;
}
currentState = transition & 15;
}
// push leftover pushable buffers to terminal
if (currentState === ParserState.GROUND && ~print) {
this._printHandler(data, print, length);
} else if (currentState === ParserState.DCS_PASSTHROUGH && ~dcs && dcsHandler) {
dcsHandler.put(data, dcs, length);
}
// save non pushable buffers
this._osc = osc;
this._collect = collect;
this._params = params;
// save active dcs handler reference
this._activeDcsHandler = dcsHandler;
// save state
this.currentState = currentState;
}
}
-71
View File
@@ -1,71 +0,0 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { IEventEmitter, IListenerType } from './Interfaces';
export class EventEmitter implements IEventEmitter {
private _events: {[type: string]: IListenerType[]};
constructor() {
// Restore the previous events if available, this will happen if the
// constructor is called multiple times on the same object (terminal reset).
this._events = this._events || {};
}
public on(type: string, listener: IListenerType): void {
this._events[type] = this._events[type] || [];
this._events[type].push(listener);
}
public off(type: string, listener: IListenerType): void {
if (!this._events[type]) {
return;
}
let obj = this._events[type];
let i = obj.length;
while (i--) {
if (obj[i] === listener || obj[i].listener === listener) {
obj.splice(i, 1);
return;
}
}
}
public removeAllListeners(type: string): void {
if (this._events[type]) {
delete this._events[type];
}
}
public once(type: string, listener: IListenerType): void {
function on(): void {
let args = Array.prototype.slice.call(arguments);
this.off(type, on);
listener.apply(this, args);
}
(<any>on).listener = listener;
this.on(type, on);
}
public emit(type: string, ...args: any[]): void {
if (!this._events[type]) {
return;
}
let obj = this._events[type];
for (let i = 0; i < obj.length; i++) {
obj[i].apply(this, args);
}
}
public listeners(type: string): IListenerType[] {
return this._events[type] || [];
}
protected destroy(): void {
this._events = {};
}
}
+251
View File
@@ -0,0 +1,251 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import * as puppeteer from 'puppeteer';
import { assert } from 'chai';
import { ITerminalOptions } from './Types';
const APP = 'http://127.0.0.1:3000/test';
let browser: puppeteer.Browser;
let page: puppeteer.Page;
const width = 800;
const height = 600;
describe('InputHandler Integration Tests', function(): void {
this.timeout(20000);
before(async function(): Promise<any> {
browser = await puppeteer.launch({
headless: process.argv.indexOf('--headless') !== -1,
slowMo: 80,
args: [`--window-size=${width},${height}`]
});
page = (await browser.pages())[0];
await page.setViewport({ width, height });
await page.goto(APP);
await openTerminal();
});
after(() => {
browser.close();
});
describe('CSI', () => {
beforeEach(async () => {
await page.evaluate(`window.term.reset()`);
});
it('ICH: Insert Ps (Blank) Character(s) (default = 1) - CSI Ps @', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('foo\\x1b[3D\\x1b[@\\n\\r')
// Explicit
window.term.write('bar\\x1b[3D\\x1b[4@')
`);
assert.deepEqual(await getLinesAsArray(2), [' foo', ' bar']);
});
it('CUU: Cursor Up Ps Times (default = 1) - CSI Ps A', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\\n\\n\\n\\n\x1b[Aa')
// Explicit
window.term.write('\x1b[2Ab')
`);
assert.deepEqual(await getLinesAsArray(4), ['', ' b', '', 'a']);
});
it('CUD: Cursor Down Ps Times (default = 1) - CSI Ps B', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\x1b[Ba')
// Explicit
window.term.write('\x1b[2Bb')
`);
assert.deepEqual(await getLinesAsArray(4), ['', 'a', '', ' b']);
});
it('CUF: Cursor Forward Ps Times (default = 1) - CSI Ps C', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\x1b[Ca')
// Explicit
window.term.write('\x1b[2Cb')
`);
assert.deepEqual(await getLinesAsArray(1), [' a b']);
});
it('CUB: Cursor Backward Ps Times (default = 1) - CSI Ps D', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('foo\x1b[Da')
// Explicit
window.term.write('\x1b[2Db')
`);
assert.deepEqual(await getLinesAsArray(1), ['fba']);
});
it('CNL: Cursor Next Line Ps Times (default = 1) - CSI Ps E', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\x1b[Ea')
// Explicit
window.term.write('\x1b[2Eb')
`);
assert.deepEqual(await getLinesAsArray(4), ['', 'a', '', 'b']);
});
it('CPL: Cursor Preceding Line Ps Times (default = 1) - CSI Ps F', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\\n\\n\\n\\n\x1b[Fa')
// Explicit
window.term.write('\x1b[2Fb')
`);
assert.deepEqual(await getLinesAsArray(5), ['', 'b', '', 'a', '']);
});
it('CHA: Cursor Character Absolute [column] (default = [row,1]) - CSI Ps G', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('foo\x1b[Ga')
// Explicit
window.term.write('\x1b[10Gb')
`);
assert.deepEqual(await getLinesAsArray(1), ['aoo b']);
});
it('CUP: Cursor Position [row;column] (default = [1,1]) - CSI Ps ; Ps H', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('foo\x1b[Ha')
// Explicit
window.term.write('\x1b[3;3Hb')
`);
assert.deepEqual(await getLinesAsArray(3), ['aoo', '', ' b']);
});
it('CHT: Cursor Forward Tabulation Ps tab stops (default = 1) - CSI Ps I', async function(): Promise<any> {
await page.evaluate(`
// Default
window.term.write('\x1b[Ia')
// Explicit
window.term.write('\\n\\r\x1b[2Ib')
`);
assert.deepEqual(await getLinesAsArray(2), [' a', ' b']);
});
it('ED: Erase in Display, VT100 - CSI Ps J', async function(): Promise<any> {
const fixture = 'abc\\n\\rdef\\n\\rghi\x1b[2;2H';
await page.evaluate(`
// Default: Erase Below
window.term.resize(5, 5);
window.term.write('${fixture}\x1b[J')
`);
assert.deepEqual(await getLinesAsArray(3), ['abc', 'd', '']);
await page.evaluate(`
// 0: Erase Below
window.term.reset()
window.term.write('${fixture}\x1b[0J')
`);
assert.deepEqual(await getLinesAsArray(3), ['abc', 'd', '']);
await page.evaluate(`
// 1: Erase Above
window.term.reset()
window.term.write('${fixture}\x1b[1J')
`);
assert.deepEqual(await getLinesAsArray(3), ['', ' f', 'ghi']);
await page.evaluate(`
// 2: Erase Saved Lines (scrollback)
window.term.reset()
window.term.write('1\\n2\\n3\\n4\\n5${fixture}\x1b[3J')
`);
assert.equal(await page.evaluate(`window.term.buffer.length`), 5);
assert.deepEqual(await getLinesAsArray(5), [' 4', ' 5', 'abc', 'def', 'ghi']);
});
it('DECSED: Erase in Display, VT220 - CSI ? Ps J', async function(): Promise<any> {
const fixture = 'abc\\n\\rdef\\n\\rghi\x1b[2;2H';
await page.evaluate(`
// Default: Erase Below
window.term.resize(5, 5);
window.term.write('${fixture}\x1b[?J')
`);
assert.deepEqual(await getLinesAsArray(3), ['abc', 'd', '']);
await page.evaluate(`
// 0: Erase Below
window.term.reset()
window.term.write('${fixture}\x1b[?0J')
`);
assert.deepEqual(await getLinesAsArray(3), ['abc', 'd', '']);
await page.evaluate(`
// 1: Erase Above
window.term.reset()
window.term.write('${fixture}\x1b[?1J')
`);
assert.deepEqual(await getLinesAsArray(3), ['', ' f', 'ghi']);
await page.evaluate(`
// 2: Erase Saved Lines (scrollback)
window.term.reset()
window.term.write('1\\n2\\n3\\n4\\n5${fixture}\x1b[?3J')
`);
assert.equal(await page.evaluate(`window.term.buffer.length`), 5);
assert.deepEqual(await getLinesAsArray(5), [' 4', ' 5', 'abc', 'def', 'ghi']);
});
describe('DSR: Device Status Report', () => {
it('Status Report - CSI 5 n', async function(): Promise<any> {
await page.evaluate(`
window.term.onData(e => window.result = e);
window.term.write('\\x1b[5n');
`);
assert.equal(await page.evaluate(`window.result`), '\x1b[0n');
});
it('Report Cursor Position (CPR) - CSI 6 n', async function(): Promise<any> {
await page.evaluate(`window.term.write('\\n\\nfoo')`);
assert.deepEqual(await page.evaluate(`
[window.term.buffer.cursorY, window.term.buffer.cursorX]
`), [2, 3]);
await page.evaluate(`
window.term.onData(e => window.result = e);
window.term.write('\\x1b[6n');
`);
assert.equal(await page.evaluate(`window.result`), '\x1b[3;4R');
});
it('Report Cursor Position (DECXCPR) - CSI ? 6 n', async function(): Promise<any> {
await page.evaluate(`window.term.write('\\n\\nfoo')`);
assert.deepEqual(await page.evaluate(`
[window.term.buffer.cursorY, window.term.buffer.cursorX]
`), [2, 3]);
await page.evaluate(`
window.term.onData(e => window.result = e);
window.term.write('\\x1b[?6n');
`);
assert.equal(await page.evaluate(`window.result`), '\x1b[?3;4R');
});
});
});
});
async function openTerminal(options: ITerminalOptions = {}): Promise<void> {
await page.evaluate(`window.term = new Terminal(${JSON.stringify(options)})`);
await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`);
if (options.rendererType === 'dom') {
await page.waitForSelector('.xterm-rows');
} else {
await page.waitForSelector('.xterm-text-layer');
}
}
async function getLinesAsArray(count: number, start: number = 0): Promise<string[]> {
let text = '';
for (let i = start; i < start + count; i++) {
text += `window.term.buffer.getLine(${i}).translateToString(true),`;
}
return await page.evaluate(`[${text}]`);
}
+480 -18
View File
@@ -3,80 +3,542 @@
* @license MIT
*/
import { assert } from 'chai';
import { assert, expect } from 'chai';
import { InputHandler } from './InputHandler';
import { MockInputHandlingTerminal } from './utils/TestUtils.test';
import { MockInputHandlingTerminal, TestTerminal } from './TestUtils.test';
import { Terminal } from './Terminal';
import { IBufferLine } from './core/Types';
import { CellData, Attributes, AttributeData, DEFAULT_ATTR_DATA } from './core/buffer/BufferLine';
describe('InputHandler', () => {
describe('save and restore cursor', () => {
let terminal = new MockInputHandlingTerminal();
const terminal = new MockInputHandlingTerminal();
terminal.buffer.x = 1;
terminal.buffer.y = 2;
let inputHandler = new InputHandler(terminal);
terminal.curAttrData.fg = 3;
const inputHandler = new InputHandler(terminal);
// Save cursor position
inputHandler.saveCursor([]);
assert.equal(terminal.buffer.x, 1);
assert.equal(terminal.buffer.y, 2);
assert.equal(terminal.curAttrData.fg, 3);
// Change cursor position
terminal.buffer.x = 10;
terminal.buffer.y = 20;
terminal.curAttrData.fg = 30;
// Restore cursor position
inputHandler.restoreCursor([]);
assert.equal(terminal.buffer.x, 1);
assert.equal(terminal.buffer.y, 2);
assert.equal(terminal.curAttrData.fg, 3);
});
describe('setCursorStyle', () => {
it('should call Terminal.setOption with correct params', () => {
let terminal = new MockInputHandlingTerminal();
let inputHandler = new InputHandler(terminal);
const terminal = new MockInputHandlingTerminal();
const inputHandler = new InputHandler(terminal);
const collect = ' ';
inputHandler.setCursorStyle([0]);
inputHandler.setCursorStyle([0], collect);
assert.equal(terminal.options['cursorStyle'], 'block');
assert.equal(terminal.options['cursorBlink'], true);
terminal.options = {};
inputHandler.setCursorStyle([1]);
inputHandler.setCursorStyle([1], collect);
assert.equal(terminal.options['cursorStyle'], 'block');
assert.equal(terminal.options['cursorBlink'], true);
terminal.options = {};
inputHandler.setCursorStyle([2]);
inputHandler.setCursorStyle([2], collect);
assert.equal(terminal.options['cursorStyle'], 'block');
assert.equal(terminal.options['cursorBlink'], false);
terminal.options = {};
inputHandler.setCursorStyle([3]);
inputHandler.setCursorStyle([3], collect);
assert.equal(terminal.options['cursorStyle'], 'underline');
assert.equal(terminal.options['cursorBlink'], true);
terminal.options = {};
inputHandler.setCursorStyle([4]);
inputHandler.setCursorStyle([4], collect);
assert.equal(terminal.options['cursorStyle'], 'underline');
assert.equal(terminal.options['cursorBlink'], false);
terminal.options = {};
inputHandler.setCursorStyle([5]);
inputHandler.setCursorStyle([5], collect);
assert.equal(terminal.options['cursorStyle'], 'bar');
assert.equal(terminal.options['cursorBlink'], true);
terminal.options = {};
inputHandler.setCursorStyle([6]);
inputHandler.setCursorStyle([6], collect);
assert.equal(terminal.options['cursorStyle'], 'bar');
assert.equal(terminal.options['cursorBlink'], false);
});
});
describe('setMode', () => {
it('should toggle Terminal.bracketedPasteMode', () => {
let terminal = new MockInputHandlingTerminal();
terminal.prefix = '?';
const terminal = new MockInputHandlingTerminal();
const collect = '?';
terminal.bracketedPasteMode = false;
let inputHandler = new InputHandler(terminal);
const inputHandler = new InputHandler(terminal);
// Set bracketed paste mode
inputHandler.setMode([2004]);
inputHandler.setMode([2004], collect);
assert.equal(terminal.bracketedPasteMode, true);
// Reset bracketed paste mode
inputHandler.resetMode([2004]);
inputHandler.resetMode([2004], collect);
assert.equal(terminal.bracketedPasteMode, false);
});
});
describe('regression tests', function(): void {
function termContent(term: Terminal, trim: boolean): string[] {
const result = [];
for (let i = 0; i < term.rows; ++i) result.push(term.buffer.lines.get(i).translateToString(trim));
return result;
}
it('insertChars', function(): void {
const term = new Terminal();
const inputHandler = new InputHandler(term);
// insert some data in first and second line
inputHandler.parse(Array(term.cols - 9).join('a'));
inputHandler.parse('1234567890');
inputHandler.parse(Array(term.cols - 9).join('a'));
inputHandler.parse('1234567890');
const line1: IBufferLine = term.buffer.lines.get(0);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + '1234567890');
// insert one char from params = [0]
term.buffer.y = 0;
term.buffer.x = 70;
inputHandler.insertChars([0]);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + ' 123456789');
// insert one char from params = [1]
term.buffer.y = 0;
term.buffer.x = 70;
inputHandler.insertChars([1]);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + ' 12345678');
// insert two chars from params = [2]
term.buffer.y = 0;
term.buffer.x = 70;
inputHandler.insertChars([2]);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + ' 123456');
// insert 10 chars from params = [10]
term.buffer.y = 0;
term.buffer.x = 70;
inputHandler.insertChars([10]);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + ' ');
expect(line1.translateToString(true)).equals(Array(term.cols - 9).join('a'));
});
it('deleteChars', function(): void {
const term = new Terminal();
const inputHandler = new InputHandler(term);
// insert some data in first and second line
inputHandler.parse(Array(term.cols - 9).join('a'));
inputHandler.parse('1234567890');
inputHandler.parse(Array(term.cols - 9).join('a'));
inputHandler.parse('1234567890');
const line1: IBufferLine = term.buffer.lines.get(0);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + '1234567890');
// delete one char from params = [0]
term.buffer.y = 0;
term.buffer.x = 70;
inputHandler.deleteChars([0]);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + '234567890 ');
expect(line1.translateToString(true)).equals(Array(term.cols - 9).join('a') + '234567890');
// insert one char from params = [1]
term.buffer.y = 0;
term.buffer.x = 70;
inputHandler.deleteChars([1]);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + '34567890 ');
expect(line1.translateToString(true)).equals(Array(term.cols - 9).join('a') + '34567890');
// insert two chars from params = [2]
term.buffer.y = 0;
term.buffer.x = 70;
inputHandler.deleteChars([2]);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + '567890 ');
expect(line1.translateToString(true)).equals(Array(term.cols - 9).join('a') + '567890');
// insert 10 chars from params = [10]
term.buffer.y = 0;
term.buffer.x = 70;
inputHandler.deleteChars([10]);
expect(line1.translateToString(false)).equals(Array(term.cols - 9).join('a') + ' ');
expect(line1.translateToString(true)).equals(Array(term.cols - 9).join('a'));
});
it('eraseInLine', function(): void {
const term = new Terminal();
const inputHandler = new InputHandler(term);
// fill 6 lines to test 3 different states
inputHandler.parse(Array(term.cols + 1).join('a'));
inputHandler.parse(Array(term.cols + 1).join('a'));
inputHandler.parse(Array(term.cols + 1).join('a'));
// params[0] - right erase
term.buffer.y = 0;
term.buffer.x = 70;
inputHandler.eraseInLine([0]);
expect(term.buffer.lines.get(0).translateToString(false)).equals(Array(71).join('a') + ' ');
// params[1] - left erase
term.buffer.y = 1;
term.buffer.x = 70;
inputHandler.eraseInLine([1]);
expect(term.buffer.lines.get(1).translateToString(false)).equals(Array(71).join(' ') + ' aaaaaaaaa');
// params[1] - left erase
term.buffer.y = 2;
term.buffer.x = 70;
inputHandler.eraseInLine([2]);
expect(term.buffer.lines.get(2).translateToString(false)).equals(Array(term.cols + 1).join(' '));
});
it('eraseInDisplay', function(): void {
const term = new Terminal({cols: 80, rows: 7});
const inputHandler = new InputHandler(term);
// fill display with a's
for (let i = 0; i < term.rows; ++i) inputHandler.parse(Array(term.cols + 1).join('a'));
// params [0] - right and below erase
term.buffer.y = 5;
term.buffer.x = 40;
inputHandler.eraseInDisplay([0]);
expect(termContent(term, false)).eql([
Array(term.cols + 1).join('a'),
Array(term.cols + 1).join('a'),
Array(term.cols + 1).join('a'),
Array(term.cols + 1).join('a'),
Array(term.cols + 1).join('a'),
Array(40 + 1).join('a') + Array(term.cols - 40 + 1).join(' '),
Array(term.cols + 1).join(' ')
]);
expect(termContent(term, true)).eql([
Array(term.cols + 1).join('a'),
Array(term.cols + 1).join('a'),
Array(term.cols + 1).join('a'),
Array(term.cols + 1).join('a'),
Array(term.cols + 1).join('a'),
Array(40 + 1).join('a'),
''
]);
// reset
term.buffer.y = 0;
term.buffer.x = 0;
for (let i = 0; i < term.rows; ++i) inputHandler.parse(Array(term.cols + 1).join('a'));
// params [1] - left and above
term.buffer.y = 5;
term.buffer.x = 40;
inputHandler.eraseInDisplay([1]);
expect(termContent(term, false)).eql([
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' '),
Array(41 + 1).join(' ') + Array(term.cols - 41 + 1).join('a'),
Array(term.cols + 1).join('a')
]);
expect(termContent(term, true)).eql([
'',
'',
'',
'',
'',
Array(41 + 1).join(' ') + Array(term.cols - 41 + 1).join('a'),
Array(term.cols + 1).join('a')
]);
// reset
term.buffer.y = 0;
term.buffer.x = 0;
for (let i = 0; i < term.rows; ++i) inputHandler.parse(Array(term.cols + 1).join('a'));
// params [2] - whole screen
term.buffer.y = 5;
term.buffer.x = 40;
inputHandler.eraseInDisplay([2]);
expect(termContent(term, false)).eql([
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' '),
Array(term.cols + 1).join(' ')
]);
expect(termContent(term, true)).eql([
'',
'',
'',
'',
'',
'',
''
]);
// reset and add a wrapped line
term.buffer.y = 0;
term.buffer.x = 0;
inputHandler.parse(Array(term.cols + 1).join('a')); // line 0
inputHandler.parse(Array(term.cols + 10).join('a')); // line 1 and 2
for (let i = 3; i < term.rows; ++i) inputHandler.parse(Array(term.cols + 1).join('a'));
// params[1] left and above with wrap
// confirm precondition that line 2 is wrapped
expect(term.buffer.lines.get(2).isWrapped).true;
term.buffer.y = 2;
term.buffer.x = 40;
inputHandler.eraseInDisplay([1]);
expect(term.buffer.lines.get(2).isWrapped).false;
// reset and add a wrapped line
term.buffer.y = 0;
term.buffer.x = 0;
inputHandler.parse(Array(term.cols + 1).join('a')); // line 0
inputHandler.parse(Array(term.cols + 10).join('a')); // line 1 and 2
for (let i = 3; i < term.rows; ++i) inputHandler.parse(Array(term.cols + 1).join('a'));
// params[1] left and above with wrap
// confirm precondition that line 2 is wrapped
expect(term.buffer.lines.get(2).isWrapped).true;
term.buffer.y = 1;
term.buffer.x = 90; // Cursor is beyond last column
inputHandler.eraseInDisplay([1]);
expect(term.buffer.lines.get(2).isWrapped).false;
});
});
it('convertEol setting', function(): void {
// not converting
const termNotConverting = new Terminal({cols: 15, rows: 10});
(termNotConverting as any)._inputHandler.parse('Hello\nWorld');
expect(termNotConverting.buffer.lines.get(0).translateToString(false)).equals('Hello ');
expect(termNotConverting.buffer.lines.get(1).translateToString(false)).equals(' World ');
expect(termNotConverting.buffer.lines.get(0).translateToString(true)).equals('Hello');
expect(termNotConverting.buffer.lines.get(1).translateToString(true)).equals(' World');
// converting
const termConverting = new Terminal({cols: 15, rows: 10, convertEol: true});
(termConverting as any)._inputHandler.parse('Hello\nWorld');
expect(termConverting.buffer.lines.get(0).translateToString(false)).equals('Hello ');
expect(termConverting.buffer.lines.get(1).translateToString(false)).equals('World ');
expect(termConverting.buffer.lines.get(0).translateToString(true)).equals('Hello');
expect(termConverting.buffer.lines.get(1).translateToString(true)).equals('World');
});
describe('print', () => {
it('should not cause an infinite loop (regression test)', () => {
const term = new Terminal();
const inputHandler = new InputHandler(term);
const container = new Uint32Array(10);
container[0] = 0x200B;
inputHandler.print(container, 0, 1);
});
});
describe('alt screen', () => {
let term: Terminal;
let handler: InputHandler;
beforeEach(() => {
term = new Terminal();
handler = new InputHandler(term);
});
it('should handle DECSET/DECRST 47 (alt screen buffer)', () => {
handler.parse('\x1b[?47h\r\n\x1b[31mJUNK\x1b[?47lTEST');
expect(term.buffer.translateBufferLineToString(0, true)).to.equal('');
expect(term.buffer.translateBufferLineToString(1, true)).to.equal(' TEST');
// Text color of 'TEST' should be red
expect((term.buffer.lines.get(1).loadCell(4, new CellData()).getFgColor())).to.equal(1);
});
it('should handle DECSET/DECRST 1047 (alt screen buffer)', () => {
handler.parse('\x1b[?1047h\r\n\x1b[31mJUNK\x1b[?1047lTEST');
expect(term.buffer.translateBufferLineToString(0, true)).to.equal('');
expect(term.buffer.translateBufferLineToString(1, true)).to.equal(' TEST');
// Text color of 'TEST' should be red
expect((term.buffer.lines.get(1).loadCell(4, new CellData()).getFgColor())).to.equal(1);
});
it('should handle DECSET/DECRST 1048 (alt screen cursor)', () => {
handler.parse('\x1b[?1048h\r\n\x1b[31mJUNK\x1b[?1048lTEST');
expect(term.buffer.translateBufferLineToString(0, true)).to.equal('TEST');
expect(term.buffer.translateBufferLineToString(1, true)).to.equal('JUNK');
// Text color of 'TEST' should be default
expect(term.buffer.lines.get(0).loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg);
// Text color of 'JUNK' should be red
expect((term.buffer.lines.get(1).loadCell(0, new CellData()).getFgColor())).to.equal(1);
});
it('should handle DECSET/DECRST 1049 (alt screen buffer+cursor)', () => {
handler.parse('\x1b[?1049h\r\n\x1b[31mJUNK\x1b[?1049lTEST');
expect(term.buffer.translateBufferLineToString(0, true)).to.equal('TEST');
expect(term.buffer.translateBufferLineToString(1, true)).to.equal('');
// Text color of 'TEST' should be default
expect(term.buffer.lines.get(0).loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg);
});
it('should handle DECSET/DECRST 1049 - maintains saved cursor for alt buffer', () => {
handler.parse('\x1b[?1049h\r\n\x1b[31m\x1b[s\x1b[?1049lTEST');
expect(term.buffer.translateBufferLineToString(0, true)).to.equal('TEST');
// Text color of 'TEST' should be default
expect(term.buffer.lines.get(0).loadCell(0, new CellData()).fg).to.equal(DEFAULT_ATTR_DATA.fg);
handler.parse('\x1b[?1049h\x1b[uTEST');
expect(term.buffer.translateBufferLineToString(1, true)).to.equal('TEST');
// Text color of 'TEST' should be red
expect((term.buffer.lines.get(1).loadCell(0, new CellData()).getFgColor())).to.equal(1);
});
it('should handle DECSET/DECRST 1049 - clears alt buffer with erase attributes', () => {
handler.parse('\x1b[42m\x1b[?1049h');
// Buffer should be filled with green background
expect(term.buffer.lines.get(20).loadCell(10, new CellData()).getBgColor()).to.equal(2);
});
});
describe('text attributes', () => {
let term: TestTerminal;
beforeEach(() => {
term = new TestTerminal();
});
it('bold', () => {
term.writeSync('\x1b[1m');
assert.equal(!!term.curAttrData.isBold(), true);
term.writeSync('\x1b[22m');
assert.equal(!!term.curAttrData.isBold(), false);
});
it('dim', () => {
term.writeSync('\x1b[2m');
assert.equal(!!term.curAttrData.isDim(), true);
term.writeSync('\x1b[22m');
assert.equal(!!term.curAttrData.isDim(), false);
});
it('italic', () => {
term.writeSync('\x1b[3m');
assert.equal(!!term.curAttrData.isItalic(), true);
term.writeSync('\x1b[23m');
assert.equal(!!term.curAttrData.isItalic(), false);
});
it('underline', () => {
term.writeSync('\x1b[4m');
assert.equal(!!term.curAttrData.isUnderline(), true);
term.writeSync('\x1b[24m');
assert.equal(!!term.curAttrData.isUnderline(), false);
});
it('blink', () => {
term.writeSync('\x1b[5m');
assert.equal(!!term.curAttrData.isBlink(), true);
term.writeSync('\x1b[25m');
assert.equal(!!term.curAttrData.isBlink(), false);
});
it('inverse', () => {
term.writeSync('\x1b[7m');
assert.equal(!!term.curAttrData.isInverse(), true);
term.writeSync('\x1b[27m');
assert.equal(!!term.curAttrData.isInverse(), false);
});
it('invisible', () => {
term.writeSync('\x1b[8m');
assert.equal(!!term.curAttrData.isInvisible(), true);
term.writeSync('\x1b[28m');
assert.equal(!!term.curAttrData.isInvisible(), false);
});
it('colormode palette 16', () => {
assert.equal(term.curAttrData.getFgColorMode(), 0); // DEFAULT
assert.equal(term.curAttrData.getBgColorMode(), 0); // DEFAULT
// lower 8 colors
for (let i = 0; i < 8; ++i) {
term.writeSync(`\x1b[${i + 30};${i + 40}m`);
assert.equal(term.curAttrData.getFgColorMode(), Attributes.CM_P16);
assert.equal(term.curAttrData.getFgColor(), i);
assert.equal(term.curAttrData.getBgColorMode(), Attributes.CM_P16);
assert.equal(term.curAttrData.getBgColor(), i);
}
// reset to DEFAULT
term.writeSync(`\x1b[39;49m`);
assert.equal(term.curAttrData.getFgColorMode(), 0);
assert.equal(term.curAttrData.getBgColorMode(), 0);
});
it('colormode palette 256', () => {
assert.equal(term.curAttrData.getFgColorMode(), 0); // DEFAULT
assert.equal(term.curAttrData.getBgColorMode(), 0); // DEFAULT
// lower 8 colors
for (let i = 0; i < 256; ++i) {
term.writeSync(`\x1b[38;5;${i};48;5;${i}m`);
assert.equal(term.curAttrData.getFgColorMode(), Attributes.CM_P256);
assert.equal(term.curAttrData.getFgColor(), i);
assert.equal(term.curAttrData.getBgColorMode(), Attributes.CM_P256);
assert.equal(term.curAttrData.getBgColor(), i);
}
// reset to DEFAULT
term.writeSync(`\x1b[39;49m`);
assert.equal(term.curAttrData.getFgColorMode(), 0);
assert.equal(term.curAttrData.getFgColor(), -1);
assert.equal(term.curAttrData.getBgColorMode(), 0);
assert.equal(term.curAttrData.getBgColor(), -1);
});
it('colormode RGB', () => {
assert.equal(term.curAttrData.getFgColorMode(), 0); // DEFAULT
assert.equal(term.curAttrData.getBgColorMode(), 0); // DEFAULT
term.writeSync(`\x1b[38;2;1;2;3;48;2;4;5;6m`);
assert.equal(term.curAttrData.getFgColorMode(), Attributes.CM_RGB);
assert.equal(term.curAttrData.getFgColor(), 1 << 16 | 2 << 8 | 3);
assert.deepEqual(AttributeData.toColorRGB(term.curAttrData.getFgColor()), [1, 2, 3]);
assert.equal(term.curAttrData.getBgColorMode(), Attributes.CM_RGB);
assert.deepEqual(AttributeData.toColorRGB(term.curAttrData.getBgColor()), [4, 5, 6]);
// reset to DEFAULT
term.writeSync(`\x1b[39;49m`);
assert.equal(term.curAttrData.getFgColorMode(), 0);
assert.equal(term.curAttrData.getFgColor(), -1);
assert.equal(term.curAttrData.getBgColorMode(), 0);
assert.equal(term.curAttrData.getBgColor(), -1);
});
it('colormode transition RGB to 256', () => {
// enter RGB for FG and BG
term.writeSync(`\x1b[38;2;1;2;3;48;2;4;5;6m`);
// enter 256 for FG and BG
term.writeSync(`\x1b[38;5;255;48;5;255m`);
assert.equal(term.curAttrData.getFgColorMode(), Attributes.CM_P256);
assert.equal(term.curAttrData.getFgColor(), 255);
assert.equal(term.curAttrData.getBgColorMode(), Attributes.CM_P256);
assert.equal(term.curAttrData.getBgColor(), 255);
});
it('colormode transition RGB to 16', () => {
// enter RGB for FG and BG
term.writeSync(`\x1b[38;2;1;2;3;48;2;4;5;6m`);
// enter 16 for FG and BG
term.writeSync(`\x1b[37;47m`);
assert.equal(term.curAttrData.getFgColorMode(), Attributes.CM_P16);
assert.equal(term.curAttrData.getFgColor(), 7);
assert.equal(term.curAttrData.getBgColorMode(), Attributes.CM_P16);
assert.equal(term.curAttrData.getBgColor(), 7);
});
it('colormode transition 16 to 256', () => {
// enter 16 for FG and BG
term.writeSync(`\x1b[37;47m`);
// enter 256 for FG and BG
term.writeSync(`\x1b[38;5;255;48;5;255m`);
assert.equal(term.curAttrData.getFgColorMode(), Attributes.CM_P256);
assert.equal(term.curAttrData.getFgColor(), 255);
assert.equal(term.curAttrData.getBgColorMode(), Attributes.CM_P256);
assert.equal(term.curAttrData.getBgColor(), 255);
});
it('colormode transition 256 to 16', () => {
// enter 256 for FG and BG
term.writeSync(`\x1b[38;5;255;48;5;255m`);
// enter 16 for FG and BG
term.writeSync(`\x1b[37;47m`);
assert.equal(term.curAttrData.getFgColorMode(), Attributes.CM_P16);
assert.equal(term.curAttrData.getFgColor(), 7);
assert.equal(term.curAttrData.getBgColorMode(), Attributes.CM_P16);
assert.equal(term.curAttrData.getBgColor(), 7);
});
it('should zero missing RGB values', () => {
term.writeSync(`\x1b[38;2;1;2;3m`);
term.writeSync(`\x1b[38;2;5m`);
assert.deepEqual(AttributeData.toColorRGB(term.curAttrData.getFgColor()), [5, 0, 0]);
});
});
});
+877 -290
View File
File diff suppressed because it is too large Load Diff
-354
View File
@@ -1,354 +0,0 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { ILinkMatcherOptions } from './Interfaces';
import { LinkMatcherHandler, LinkMatcherValidationCallback, Charset, LineData } from './Types';
import { IColorSet, IRenderer } from './renderer/Interfaces';
import { IMouseZoneManager } from './input/Interfaces';
export interface IBrowser {
isNode: boolean;
userAgent: string;
platform: string;
isFirefox: boolean;
isMSIE: boolean;
isMac: boolean;
isIpad: boolean;
isIphone: boolean;
isMSWindows: boolean;
}
export interface IBufferAccessor {
buffer: IBuffer;
}
export interface IElementAccessor {
element: HTMLElement;
}
export interface ILinkifierAccessor {
linkifier: ILinkifier;
}
export interface ITerminal extends ILinkifierAccessor, IBufferAccessor, IElementAccessor, IEventEmitter {
selectionManager: ISelectionManager;
charMeasure: ICharMeasure;
textarea: HTMLTextAreaElement;
renderer: IRenderer;
rows: number;
cols: number;
browser: IBrowser;
writeBuffer: string[];
cursorHidden: boolean;
cursorState: number;
defAttr: number;
options: ITerminalOptions;
buffers: IBufferSet;
isFocused: boolean;
mouseHelper: IMouseHelper;
bracketedPasteMode: boolean;
/**
* Emit the 'data' event and populate the given data.
* @param data The data to populate in the event.
*/
handler(data: string): void;
scrollLines(disp: number, suppressScrollEvent?: boolean): void;
cancel(ev: Event, force?: boolean): boolean | void;
log(text: string): void;
reset(): void;
showCursor(): void;
blankLine(cur?: boolean, isWrapped?: boolean, cols?: number): LineData;
refresh(start: number, end: number): void;
}
/**
* This interface encapsulates everything needed from the Terminal by the
* InputHandler. This cleanly separates the large amount of methods needed by
* InputHandler cleanly from the ITerminal interface.
*/
export interface IInputHandlingTerminal extends IEventEmitter {
element: HTMLElement;
options: ITerminalOptions;
cols: number;
rows: number;
charset: Charset;
gcharset: number;
glevel: number;
charsets: Charset[];
applicationKeypad: boolean;
applicationCursor: boolean;
originMode: boolean;
insertMode: boolean;
wraparoundMode: boolean;
bracketedPasteMode: boolean;
defAttr: number;
curAttr: number;
prefix: string;
savedCols: number;
x10Mouse: boolean;
vt200Mouse: boolean;
normalMouse: boolean;
mouseEvents: boolean;
sendFocus: boolean;
utfMouse: boolean;
sgrMouse: boolean;
urxvtMouse: boolean;
cursorHidden: boolean;
buffers: IBufferSet;
buffer: IBuffer;
viewport: IViewport;
selectionManager: ISelectionManager;
bell(): void;
focus(): void;
convertEol: boolean;
updateRange(y: number): void;
scroll(isWrapped?: boolean): void;
setgLevel(g: number): void;
eraseAttr(): number;
eraseRight(x: number, y: number): void;
eraseLine(y: number): void;
eraseLeft(x: number, y: number): void;
blankLine(cur?: boolean, isWrapped?: boolean): LineData;
is(term: string): boolean;
send(data: string): void;
setgCharset(g: number, charset: Charset): void;
resize(x: number, y: number): void;
log(text: string, data?: any): void;
reset(): void;
showCursor(): void;
refresh(start: number, end: number): void;
matchColor(r1: number, g1: number, b1: number): number;
error(text: string, data?: any): void;
setOption(key: string, value: any): void;
}
export interface ITerminalOptions {
bellSound?: string;
bellStyle?: string;
cancelEvents?: boolean;
cols?: number;
convertEol?: boolean;
cursorBlink?: boolean;
cursorStyle?: string;
debug?: boolean;
disableStdin?: boolean;
enableBold?: boolean;
fontSize?: number;
fontFamily?: string;
handler?: (data: string) => void;
letterSpacing?: number;
lineHeight?: number;
rows?: number;
screenKeys?: boolean;
scrollback?: number;
tabStopWidth?: number;
termName?: string;
theme?: ITheme;
useFlowControl?: boolean;
}
export interface IBuffer {
lines: ICircularList<LineData>;
ydisp: number;
ybase: number;
y: number;
x: number;
tabs: any;
scrollBottom: number;
scrollTop: number;
savedY: number;
savedX: number;
isCursorInViewport: boolean;
translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol?: number, endCol?: number): string;
nextStop(x?: number): number;
prevStop(x?: number): number;
}
export interface IBufferSet {
alt: IBuffer;
normal: IBuffer;
active: IBuffer;
activateNormalBuffer(): void;
activateAltBuffer(): void;
}
export interface IMouseHelper {
getCoords(event: {pageX: number, pageY: number}, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number, isSelection?: boolean): [number, number];
getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number): { x: number, y: number };
}
export interface IViewport {
syncScrollArea(): void;
onWheel(ev: WheelEvent): void;
onTouchStart(ev: TouchEvent): void;
onTouchMove(ev: TouchEvent): void;
onThemeChanged(colors: IColorSet): void;
}
export interface ISelectionManager {
selectionText: string;
selectionStart: [number, number];
selectionEnd: [number, number];
disable(): void;
enable(): void;
setBuffer(buffer: IBuffer): void;
setSelection(row: number, col: number, length: number): void;
}
export interface ICompositionHelper {
compositionstart(): void;
compositionupdate(ev: CompositionEvent): void;
compositionend(): void;
updateCompositionElements(dontRecurse?: boolean): void;
keydown(ev: KeyboardEvent): boolean;
}
export interface ICharMeasure {
width: number;
height: number;
measure(options: ITerminalOptions): void;
}
export interface ILinkifier extends IEventEmitter {
attachToDom(mouseZoneManager: IMouseZoneManager): void;
linkifyRows(start: number, end: number): void;
setHypertextLinkHandler(handler: LinkMatcherHandler): void;
setHypertextValidationCallback(callback: LinkMatcherValidationCallback): void;
registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number;
deregisterLinkMatcher(matcherId: number): boolean;
}
export interface ICircularList<T> extends IEventEmitter {
length: number;
maxLength: number;
forEach: (callbackfn: (value: T, index: number) => void) => void;
get(index: number): T;
set(index: number, value: T): void;
push(value: T): void;
pop(): T;
splice(start: number, deleteCount: number, ...items: T[]): void;
trimStart(count: number): void;
shiftElements(start: number, count: number, offset: number): void;
}
export interface IEventEmitter {
on(type: string, listener: IListenerType): void;
off(type: string, listener: IListenerType): void;
emit(type: string, data?: any): void;
}
export interface IListenerType {
(data?: any): void;
listener?: (data?: any) => void;
};
export interface ILinkMatcherOptions {
/**
* The index of the link from the regex.match(text) call. This defaults to 0
* (for regular expressions without capture groups).
*/
matchIndex?: number;
/**
* A callback that validates an individual link, returning true if valid and
* false if invalid.
*/
validationCallback?: LinkMatcherValidationCallback;
/**
* A callback that fires when the mouse hovers over a link.
*/
tooltipCallback?: LinkMatcherHandler;
/**
* A callback that fires when the mouse leaves a link that was hovered.
*/
leaveCallback?: () => void;
/**
* The priority of the link matcher, this defines the order in which the link
* matcher is evaluated relative to others, from highest to lowest. The
* default value is 0.
*/
priority?: number;
}
/**
* Handles actions generated by the parser.
*/
export interface IInputHandler {
addChar(char: string, code: number): void;
/** C0 BEL */ bell(): void;
/** C0 LF */ lineFeed(): void;
/** C0 CR */ carriageReturn(): void;
/** C0 BS */ backspace(): void;
/** C0 HT */ tab(): void;
/** C0 SO */ shiftOut(): void;
/** C0 SI */ shiftIn(): void;
/** CSI @ */ insertChars(params?: number[]): void;
/** CSI A */ cursorUp(params?: number[]): void;
/** CSI B */ cursorDown(params?: number[]): void;
/** CSI C */ cursorForward(params?: number[]): void;
/** CSI D */ cursorBackward(params?: number[]): void;
/** CSI E */ cursorNextLine(params?: number[]): void;
/** CSI F */ cursorPrecedingLine(params?: number[]): void;
/** CSI G */ cursorCharAbsolute(params?: number[]): void;
/** CSI H */ cursorPosition(params?: number[]): void;
/** CSI I */ cursorForwardTab(params?: number[]): void;
/** CSI J */ eraseInDisplay(params?: number[]): void;
/** CSI K */ eraseInLine(params?: number[]): void;
/** CSI L */ insertLines(params?: number[]): void;
/** CSI M */ deleteLines(params?: number[]): void;
/** CSI P */ deleteChars(params?: number[]): void;
/** CSI S */ scrollUp(params?: number[]): void;
/** CSI T */ scrollDown(params?: number[]): void;
/** CSI X */ eraseChars(params?: number[]): void;
/** CSI Z */ cursorBackwardTab(params?: number[]): void;
/** CSI ` */ charPosAbsolute(params?: number[]): void;
/** CSI a */ HPositionRelative(params?: number[]): void;
/** CSI b */ repeatPrecedingCharacter(params?: number[]): void;
/** CSI c */ sendDeviceAttributes(params?: number[]): void;
/** CSI d */ linePosAbsolute(params?: number[]): void;
/** CSI e */ VPositionRelative(params?: number[]): void;
/** CSI f */ HVPosition(params?: number[]): void;
/** CSI g */ tabClear(params?: number[]): void;
/** CSI h */ setMode(params?: number[]): void;
/** CSI l */ resetMode(params?: number[]): void;
/** CSI m */ charAttributes(params?: number[]): void;
/** CSI n */ deviceStatus(params?: number[]): void;
/** CSI p */ softReset(params?: number[]): void;
/** CSI q */ setCursorStyle(params?: number[]): void;
/** CSI r */ setScrollRegion(params?: number[]): void;
/** CSI s */ saveCursor(params?: number[]): void;
/** CSI u */ restoreCursor(params?: number[]): void;
}
export interface ITheme {
foreground?: string;
background?: string;
cursor?: string;
cursorAccent?: string;
selection?: string;
black?: string;
red?: string;
green?: string;
yellow?: string;
blue?: string;
magenta?: string;
cyan?: string;
white?: string;
brightBlack?: string;
brightRed?: string;
brightGreen?: string;
brightYellow?: string;
brightBlue?: string;
brightMagenta?: string;
brightCyan?: string;
brightWhite?: string;
}
+157 -40
View File
@@ -4,24 +4,26 @@
*/
import { assert } from 'chai';
import { ITerminal, ILinkifier, IBuffer, IBufferAccessor, IElementAccessor } from './Interfaces';
import { IMouseZoneManager, IMouseZone, ILinkMatcher, ITerminal } from './Types';
import { IBufferLine } from './core/Types';
import { Linkifier } from './Linkifier';
import { LinkMatcher, LineData } from './Types';
import { IMouseZoneManager, IMouseZone } from './input/Interfaces';
import { MockBuffer } from './utils/TestUtils.test';
import { CircularList } from './utils/CircularList';
import { MockBuffer, MockTerminal, TestTerminal } from './TestUtils.test';
import { CircularList } from './common/CircularList';
import { BufferLine, CellData } from './core/buffer/BufferLine';
class TestLinkifier extends Linkifier {
constructor(_terminal: IBufferAccessor & IElementAccessor) {
super(_terminal);
Linkifier.TIME_BEFORE_LINKIFY = 0;
constructor(terminal: ITerminal) {
super(terminal);
(<any>Linkifier).TIME_BEFORE_LINKIFY = 0;
}
public get linkMatchers(): LinkMatcher[] { return this._linkMatchers; }
public get linkMatchers(): ILinkMatcher[] { return this._linkMatchers; }
public linkifyRows(): void { super.linkifyRows(0, this._terminal.buffer.lines.length - 1); }
}
class TestMouseZoneManager implements IMouseZoneManager {
dispose(): void {
}
public clears: number = 0;
public zones: IMouseZone[] = [];
add(zone: IMouseZone): void {
@@ -33,25 +35,25 @@ class TestMouseZoneManager implements IMouseZoneManager {
}
describe('Linkifier', () => {
let terminal: IBufferAccessor & IElementAccessor;
let terminal: ITerminal;
let linkifier: TestLinkifier;
let mouseZoneManager: TestMouseZoneManager;
beforeEach(() => {
terminal = {
buffer: new MockBuffer(),
element: <HTMLElement>{}
};
terminal.buffer.lines = new CircularList<LineData>(20);
terminal = new MockTerminal();
(terminal as any).cols = 100;
(terminal as any).rows = 10;
terminal.buffer = new MockBuffer();
(<MockBuffer>terminal.buffer).setLines(new CircularList<IBufferLine>(20));
terminal.buffer.ydisp = 0;
linkifier = new TestLinkifier(terminal);
mouseZoneManager = new TestMouseZoneManager();
});
function stringToRow(text: string): LineData {
let result: LineData = [];
function stringToRow(text: string): IBufferLine {
const result = new BufferLine(text.length);
for (let i = 0; i < text.length; i++) {
result.push([0, text.charAt(i), 1, text.charCodeAt(i)]);
result.setCell(i, CellData.fromCharData([0, text.charAt(i), 1, text.charCodeAt(i)]));
}
return result;
}
@@ -60,20 +62,10 @@ describe('Linkifier', () => {
terminal.buffer.lines.push(stringToRow(text));
}
function assertLinkifiesEntireRow(uri: string, done: MochaDone): void {
addRow(uri);
linkifier.linkifyRows();
setTimeout(() => {
assert.equal(mouseZoneManager.zones[0].x1, 1);
assert.equal(mouseZoneManager.zones[0].x2, uri.length + 1);
assert.equal(mouseZoneManager.zones[0].y, terminal.buffer.lines.length);
done();
}, 0);
}
function assertLinkifiesRow(rowText: string, linkMatcherRegex: RegExp, links: {x: number, length: number}[], done: MochaDone): void {
addRow(rowText);
linkifier.registerLinkMatcher(linkMatcherRegex, () => {});
(terminal as any).rows = terminal.buffer.lines.length - 1;
linkifier.linkifyRows();
// Allow linkify to happen
setTimeout(() => {
@@ -81,7 +73,25 @@ describe('Linkifier', () => {
links.forEach((l, i) => {
assert.equal(mouseZoneManager.zones[i].x1, l.x + 1);
assert.equal(mouseZoneManager.zones[i].x2, l.x + l.length + 1);
assert.equal(mouseZoneManager.zones[i].y, terminal.buffer.lines.length);
assert.equal(mouseZoneManager.zones[i].y1, terminal.buffer.lines.length);
assert.equal(mouseZoneManager.zones[i].y2, terminal.buffer.lines.length);
});
done();
}, 0);
}
function assertLinkifiesMultiLineLink(rowText: string, linkMatcherRegex: RegExp, links: {x1: number, y1: number, x2: number, y2: number}[], done: MochaDone): void {
addRow(rowText);
linkifier.registerLinkMatcher(linkMatcherRegex, () => {});
linkifier.linkifyRows();
// Allow linkify to happen
setTimeout(() => {
assert.equal(mouseZoneManager.zones.length, links.length);
links.forEach((l, i) => {
assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1);
assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1);
assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1);
assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1);
});
done();
}, 0);
@@ -102,12 +112,6 @@ describe('Linkifier', () => {
linkifier.attachToDom(mouseZoneManager);
});
describe('http links', () => {
it('should allow ~ character in URI path', (done) => {
assertLinkifiesEntireRow('http://foo.com/a~b#c~d?e~f', done);
});
});
describe('link matcher', () => {
it('should match a single link', done => {
assertLinkifiesRow('foo', /foo/, [{x: 0, length: 3}], done);
@@ -136,6 +140,24 @@ describe('Linkifier', () => {
// character (U+1F537) which caused the path to be duplicated. See #642.
assertLinkifiesRow('echo \'🔷foo\'', /foo/, [{x: 8, length: 3}], done);
});
describe('multi-line links', () => {
it('should match links that start on line 1/2 of a wrapped line and end on the last character of line 1/2', done => {
(terminal as any).cols = 4;
assertLinkifiesMultiLineLink('12345', /1234/, [{x1: 0, x2: 4, y1: 0, y2: 0}], done);
});
it('should match links that start on line 1/2 of a wrapped line and wrap to line 2/2', done => {
(terminal as any).cols = 4;
assertLinkifiesMultiLineLink('12345', /12345/, [{x1: 0, x2: 1, y1: 0, y2: 1}], done);
});
it('should match links that start and end on line 2/2 of a wrapped line', done => {
(terminal as any).cols = 4;
assertLinkifiesMultiLineLink('12345678', /5678/, [{x1: 0, x2: 4, y1: 1, y2: 1}], done);
});
it('should match links that start on line 2/3 of a wrapped line and wrap to line 3/3', done => {
(terminal as any).cols = 4;
assertLinkifiesMultiLineLink('123456789', /56789/, [{x1: 0, x2: 1, y1: 1, y2: 2}], done);
});
});
});
describe('validationCallback', () => {
@@ -148,7 +170,8 @@ describe('Linkifier', () => {
assert.equal(mouseZoneManager.zones.length, 1);
assert.equal(mouseZoneManager.zones[0].x1, 1);
assert.equal(mouseZoneManager.zones[0].x2, 5);
assert.equal(mouseZoneManager.zones[0].y, 1);
assert.equal(mouseZoneManager.zones[0].y1, 1);
assert.equal(mouseZoneManager.zones[0].y2, 1);
// Fires done()
mouseZoneManager.zones[0].clickCallback(<any>{});
}
@@ -201,19 +224,113 @@ describe('Linkifier', () => {
it('should order the list from highest priority to lowest #1', () => {
const aId = linkifier.registerLinkMatcher(/a/, () => {}, { priority: 1 });
const bId = linkifier.registerLinkMatcher(/b/, () => {}, { priority: -1 });
assert.deepEqual(linkifier.linkMatchers.map(lm => lm.id), [aId, 0, bId]);
assert.deepEqual(linkifier.linkMatchers.map(lm => lm.id), [aId, bId]);
});
it('should order the list from highest priority to lowest #2', () => {
const aId = linkifier.registerLinkMatcher(/a/, () => {}, { priority: -1 });
const bId = linkifier.registerLinkMatcher(/b/, () => {}, { priority: 1 });
assert.deepEqual(linkifier.linkMatchers.map(lm => lm.id), [bId, 0, aId]);
assert.deepEqual(linkifier.linkMatchers.map(lm => lm.id), [bId, aId]);
});
it('should order items of equal priority in the order they are added', () => {
const aId = linkifier.registerLinkMatcher(/a/, () => {}, { priority: 0 });
const bId = linkifier.registerLinkMatcher(/b/, () => {}, { priority: 0 });
assert.deepEqual(linkifier.linkMatchers.map(lm => lm.id), [0, aId, bId]);
assert.deepEqual(linkifier.linkMatchers.map(lm => lm.id), [aId, bId]);
});
});
});
describe('unicode handling', () => {
let terminal: TestTerminal;
// other than the tests above unicode testing needs the full terminal instance
// to get the special handling of fullwidth, surrogate and combining chars in the input handler
beforeEach(() => {
terminal = new TestTerminal({cols: 10, rows: 5});
linkifier = new TestLinkifier(terminal);
mouseZoneManager = new TestMouseZoneManager();
linkifier.attachToDom(mouseZoneManager);
});
function assertLinkifiesInTerminal(rowText: string, linkMatcherRegex: RegExp, links: {x1: number, y1: number, x2: number, y2: number}[], done: MochaDone): void {
terminal.writeSync(rowText);
linkifier.registerLinkMatcher(linkMatcherRegex, () => {});
linkifier.linkifyRows();
// Allow linkify to happen
setTimeout(() => {
assert.equal(mouseZoneManager.zones.length, links.length);
links.forEach((l, i) => {
assert.equal(mouseZoneManager.zones[i].x1, l.x1 + 1);
assert.equal(mouseZoneManager.zones[i].x2, l.x2 + 1);
assert.equal(mouseZoneManager.zones[i].y1, l.y1 + 1);
assert.equal(mouseZoneManager.zones[i].y2, l.y2 + 1);
});
done();
}, 0);
}
describe('unicode before the match', () => {
it('combining - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}], done);
});
it('combining - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('e\u0301e\u0301e\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done);
});
it('surrogate - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}], done);
});
it('surrogate - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('𝄞𝄞𝄞 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done);
});
it('combining surrogate - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{x1: 4, x2: 7, y1: 0, y2: 0}], done);
});
it('combining surrogate - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('𓂀\u0301𓂀\u0301𓂀\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done);
});
it('fullwidth - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('12 foo', /foo/, [{x1: 5, x2: 8, y1: 0, y2: 0}], done);
});
it('fullwidth - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('12 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done);
});
it('combining fullwidth - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{x1: 5, x2: 8, y1: 0, y2: 0}], done);
});
it('combining fullwidth - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('¥\u0301¥\u0301 foo', /foo/, [{x1: 8, x2: 1, y1: 0, y2: 1}], done);
});
});
describe('unicode within the match', () => {
it('combining - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('test cafe\u0301', /cafe\u0301/, [{x1: 5, x2: 9, y1: 0, y2: 0}], done);
});
it('combining - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('testtest cafe\u0301', /cafe\u0301/, [{x1: 9, x2: 3, y1: 0, y2: 1}], done);
});
it('surrogate - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('test a𝄞b', /a𝄞b/, [{x1: 5, x2: 8, y1: 0, y2: 0}], done);
});
it('surrogate - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('testtest a𝄞b', /a𝄞b/, [{x1: 9, x2: 2, y1: 0, y2: 1}], done);
});
it('combining surrogate - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('test a𓂀\u0301b', /a𓂀\u0301b/, [{x1: 5, x2: 8, y1: 0, y2: 0}], done);
});
it('combining surrogate - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('testtest a𓂀\u0301b', /a𓂀\u0301b/, [{x1: 9, x2: 2, y1: 0, y2: 1}], done);
});
it('fullwidth - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('test a1b', /a1b/, [{x1: 5, x2: 9, y1: 0, y2: 0}], done);
});
it('fullwidth - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('testtest a1b', /a1b/, [{x1: 9, x2: 3, y1: 0, y2: 1}], done);
});
it('combining fullwidth - match within one line', function(done: () => void): void {
assertLinkifiesInTerminal('test a¥\u0301b', /a¥\u0301b/, [{x1: 5, x2: 9, y1: 0, y2: 0}], done);
});
it('combining fullwidth - match over two lines', function(done: () => void): void {
assertLinkifiesInTerminal('testtest a¥\u0301b', /a¥\u0301b/, [{x1: 9, x2: 3, y1: 0, y2: 1}], done);
});
});
});
+150 -127
View File
@@ -3,63 +3,50 @@
* @license MIT
*/
import { ILinkMatcherOptions, ITerminal, IBufferAccessor, ILinkifier, IElementAccessor } from './Interfaces';
import { LinkMatcher, LinkMatcherHandler, LinkMatcherValidationCallback, LineData, LinkHoverEvent, LinkHoverEventTypes } from './Types';
import { IMouseZoneManager } from './input/Interfaces';
import { MouseZone } from './input/MouseZoneManager';
import { EventEmitter } from './EventEmitter';
const protocolClause = '(https?:\\/\\/)';
const domainCharacterSet = '[\\da-z\\.-]+';
const negatedDomainCharacterSet = '[^\\da-z\\.-]+';
const domainBodyClause = '(' + domainCharacterSet + ')';
const tldClause = '([a-z\\.]{2,6})';
const ipClause = '((\\d{1,3}\\.){3}\\d{1,3})';
const localHostClause = '(localhost)';
const portClause = '(:\\d{1,5})';
const hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';
const pathClause = '(\\/[\\/\\w\\.\\-%~]*)*';
const queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;~\\=\\.\\-]*';
const queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?';
const hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?';
const negatedPathCharacterSet = '[^\\/\\w\\.\\-%]+';
const bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause;
const start = '(?:^|' + negatedDomainCharacterSet + ')(';
const end = ')($|' + negatedPathCharacterSet + ')';
const strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end);
/**
* The ID of the built in http(s) link matcher.
*/
const HYPERTEXT_LINK_MATCHER_ID = 0;
import { ILinkifierEvent, ILinkMatcher, LinkMatcherHandler, ILinkMatcherOptions, ILinkifier, ITerminal, IBufferStringIteratorResult, IMouseZoneManager } from './Types';
import { MouseZone } from './MouseZoneManager';
import { getStringCellWidth } from './CharWidth';
import { EventEmitter2, IEvent } from './common/EventEmitter2';
/**
* The Linkifier applies links to rows shortly after they have been refreshed.
*/
export class Linkifier extends EventEmitter implements ILinkifier {
export class Linkifier implements ILinkifier {
/**
* The time to wait after a row is changed before it is linkified. This prevents
* the costly operation of searching every row multiple times, potentially a
* huge amount of times.
*/
protected static TIME_BEFORE_LINKIFY = 200;
protected static readonly TIME_BEFORE_LINKIFY = 200;
protected _linkMatchers: LinkMatcher[] = [];
/**
* Limit of the unwrapping line expansion (overscan) at the top and bottom
* of the actual viewport in ASCII characters.
* A limit of 2000 should match most sane urls.
*/
protected static readonly OVERSCAN_CHAR_LIMIT = 2000;
protected _linkMatchers: ILinkMatcher[] = [];
private _mouseZoneManager: IMouseZoneManager;
private _rowsTimeoutId: number;
private _nextLinkMatcherId = HYPERTEXT_LINK_MATCHER_ID;
private _rowsToLinkify: {start: number, end: number};
private _nextLinkMatcherId = 0;
private _rowsToLinkify: { start: number, end: number };
private _onLinkHover = new EventEmitter2<ILinkifierEvent>();
public get onLinkHover(): IEvent<ILinkifierEvent> { return this._onLinkHover.event; }
private _onLinkLeave = new EventEmitter2<ILinkifierEvent>();
public get onLinkLeave(): IEvent<ILinkifierEvent> { return this._onLinkLeave.event; }
private _onLinkTooltip = new EventEmitter2<ILinkifierEvent>();
public get onLinkTooltip(): IEvent<ILinkifierEvent> { return this._onLinkTooltip.event; }
constructor(
protected _terminal: IBufferAccessor & IElementAccessor
protected _terminal: ITerminal
) {
super();
this._rowsToLinkify = {
start: null,
end: null
};
this.registerLinkMatcher(strictUrlRegex, null, { matchIndex: 1 });
}
/**
@@ -82,12 +69,12 @@ export class Linkifier extends EventEmitter implements ILinkifier {
}
// Increase range to linkify
if (!this._rowsToLinkify.start) {
if (this._rowsToLinkify.start === null) {
this._rowsToLinkify.start = start;
this._rowsToLinkify.end = end;
} else {
this._rowsToLinkify.start = this._rowsToLinkify.start < start ? this._rowsToLinkify.start : start;
this._rowsToLinkify.end = this._rowsToLinkify.end > end ? this._rowsToLinkify.end : end;
this._rowsToLinkify.start = Math.min(this._rowsToLinkify.start, start);
this._rowsToLinkify.end = Math.max(this._rowsToLinkify.end, end);
}
// Clear out any existing links on this row range
@@ -105,30 +92,41 @@ export class Linkifier extends EventEmitter implements ILinkifier {
*/
private _linkifyRows(): void {
this._rowsTimeoutId = null;
for (let i = this._rowsToLinkify.start; i <= this._rowsToLinkify.end; i++) {
this._linkifyRow(i);
const buffer = this._terminal.buffer;
// Ensure the start row exists
const absoluteRowIndexStart = buffer.ydisp + this._rowsToLinkify.start;
if (absoluteRowIndexStart >= buffer.lines.length) {
return;
}
// Invalidate bad end row values (if a resize happened)
const absoluteRowIndexEnd = buffer.ydisp + Math.min(this._rowsToLinkify.end, this._terminal.rows) + 1;
// Iterate over the range of unwrapped content strings within start..end
// (excluding).
// _doLinkifyRow gets full unwrapped lines with the start row as buffer offset
// for every matcher.
// The unwrapping is needed to also match content that got wrapped across
// several buffer lines. To avoid a worst case scenario where the whole buffer
// contains just a single unwrapped string we limit this line expansion beyond
// the viewport to +OVERSCAN_CHAR_LIMIT chars (overscan) at top and bottom.
// This comes with the tradeoff that matches longer than OVERSCAN_CHAR_LIMIT
// chars will not match anymore at the viewport borders.
const overscanLineLimit = Math.ceil(Linkifier.OVERSCAN_CHAR_LIMIT / this._terminal.cols);
const iterator = this._terminal.buffer.iterator(
false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);
while (iterator.hasNext()) {
const lineData: IBufferStringIteratorResult = iterator.next();
for (let i = 0; i < this._linkMatchers.length; i++) {
this._doLinkifyRow(lineData.range.first, lineData.content, this._linkMatchers[i]);
}
}
this._rowsToLinkify.start = null;
this._rowsToLinkify.end = null;
}
/**
* Attaches a handler for hypertext links, overriding default <a> behavior for
* tandard http(s) links.
* @param handler The handler to use, this can be cleared with null.
*/
public setHypertextLinkHandler(handler: LinkMatcherHandler): void {
this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].handler = handler;
}
/**
* Attaches a validation callback for hypertext links.
* @param callback The callback to use, this can be cleared with null.
*/
public setHypertextValidationCallback(callback: LinkMatcherValidationCallback): void {
this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].validationCallback = callback;
}
/**
* Registers a link matcher, allowing custom link patterns to be matched and
* handled.
@@ -140,10 +138,10 @@ export class Linkifier extends EventEmitter implements ILinkifier {
* @return The ID of the new matcher, this can be used to deregister.
*/
public registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options: ILinkMatcherOptions = {}): number {
if (this._nextLinkMatcherId !== HYPERTEXT_LINK_MATCHER_ID && !handler) {
if (!handler) {
throw new Error('handler must be defined');
}
const matcher: LinkMatcher = {
const matcher: ILinkMatcher = {
id: this._nextLinkMatcherId++,
regex,
handler,
@@ -151,6 +149,7 @@ export class Linkifier extends EventEmitter implements ILinkifier {
validationCallback: options.validationCallback,
hoverTooltipCallback: options.tooltipCallback,
hoverLeaveCallback: options.leaveCallback,
willLinkActivate: options.willLinkActivate,
priority: options.priority || 0
};
this._addLinkMatcherToList(matcher);
@@ -163,7 +162,7 @@ export class Linkifier extends EventEmitter implements ILinkifier {
* considered after older link matchers.
* @param matcher The link matcher to be added.
*/
private _addLinkMatcherToList(matcher: LinkMatcher): void {
private _addLinkMatcherToList(matcher: ILinkMatcher): void {
if (this._linkMatchers.length === 0) {
this._linkMatchers.push(matcher);
return;
@@ -185,8 +184,7 @@ export class Linkifier extends EventEmitter implements ILinkifier {
* @return Whether a link matcher was found and deregistered.
*/
public deregisterLinkMatcher(matcherId: number): boolean {
// ID 0 is the hypertext link matcher which cannot be deregistered
for (let i = 1; i < this._linkMatchers.length; i++) {
for (let i = 0; i < this._linkMatchers.length; i++) {
if (this._linkMatchers[i].id === matcherId) {
this._linkMatchers.splice(i, 1);
return true;
@@ -195,65 +193,68 @@ export class Linkifier extends EventEmitter implements ILinkifier {
return false;
}
/**
* Linkifies a row.
* @param rowIndex The index of the row to linkify.
*/
private _linkifyRow(rowIndex: number): void {
const absoluteRowIndex = this._terminal.buffer.ydisp + rowIndex;
if (absoluteRowIndex >= this._terminal.buffer.lines.length) {
return;
}
const text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false);
for (let i = 0; i < this._linkMatchers.length; i++) {
this._doLinkifyRow(rowIndex, text, this._linkMatchers[i]);
}
}
/**
* Linkifies a row given a specific handler.
* @param rowIndex The row index to linkify.
* @param text The text of the row (excludes text in the row that's already
* linkified).
* @param rowIndex The row index to linkify (absolute index).
* @param text string content of the unwrapped row.
* @param matcher The link matcher for this line.
* @param offset The how much of the row has already been linkified.
* @return The link element(s) that were added.
*/
private _doLinkifyRow(rowIndex: number, text: string, matcher: LinkMatcher, offset: number = 0): void {
// Iterate over nodes as we want to consider text nodes
let result = [];
const isHttpLinkMatcher = matcher.id === HYPERTEXT_LINK_MATCHER_ID;
// Find the first match
let match = text.match(matcher.regex);
if (!match || match.length === 0) {
return;
}
let uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];
// Get index, match.index is for the outer match which includes negated chars
const index = text.indexOf(uri);
// Ensure the link is valid before registering
if (matcher.validationCallback) {
matcher.validationCallback(uri, isValid => {
// Discard link if the line has already changed
if (this._rowsTimeoutId) {
return;
private _doLinkifyRow(rowIndex: number, text: string, matcher: ILinkMatcher): void {
// clone regex to do a global search on text
const rex = new RegExp(matcher.regex.source, matcher.regex.flags + 'g');
let match;
let stringIndex = -1;
while ((match = rex.exec(text)) !== null) {
const uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];
if (!uri) {
// something matched but does not comply with the given matchIndex
// since this is most likely a bug the regex itself we simply do nothing here
// DEBUG: print match and throw
if ((<any>this._terminal).debug) {
console.log({match, matcher});
throw new Error('match found without corresponding matchIndex');
}
if (isValid) {
this._addLink(offset + index, rowIndex, uri, matcher);
}
});
} else {
this._addLink(offset + index, rowIndex, uri, matcher);
}
break;
}
// Recursively check for links in the rest of the text
const remainingStartIndex = index + uri.length;
const remainingText = text.substr(remainingStartIndex);
if (remainingText.length > 0) {
this._doLinkifyRow(rowIndex, remainingText, matcher, offset + remainingStartIndex);
// Get index, match.index is for the outer match which includes negated chars
// therefore we cannot use match.index directly, instead we search the position
// of the match group in text again
// also correct regex and string search offsets for the next loop run
stringIndex = text.indexOf(uri, stringIndex + 1);
rex.lastIndex = stringIndex + uri.length;
if (stringIndex < 0) {
// invalid stringIndex (should not have happened)
break;
}
// get the buffer index as [absolute row, col] for the match
const bufferIndex = this._terminal.buffer.stringIndexToBufferIndex(rowIndex, stringIndex);
if (bufferIndex[0] < 0) {
// invalid bufferIndex (should not have happened)
break;
}
const line = this._terminal.buffer.lines.get(bufferIndex[0]);
const attr = line.getFg(bufferIndex[1]);
let fg: number | undefined;
if (attr) {
fg = (attr >> 9) & 0x1ff;
}
if (matcher.validationCallback) {
matcher.validationCallback(uri, isValid => {
// Discard link if the line has already changed
if (this._rowsTimeoutId) {
return;
}
if (isValid) {
this._addLink(bufferIndex[1], bufferIndex[0] - this._terminal.buffer.ydisp, uri, matcher, fg);
}
});
} else {
this._addLink(bufferIndex[1], bufferIndex[0] - this._terminal.buffer.ydisp, uri, matcher, fg);
}
}
}
@@ -263,35 +264,57 @@ export class Linkifier extends EventEmitter implements ILinkifier {
* @param y The row the link is on.
* @param uri The URI of the link.
* @param matcher The link matcher for the link.
* @param fg The link color for hover event.
*/
private _addLink(x: number, y: number, uri: string, matcher: LinkMatcher): void {
private _addLink(x: number, y: number, uri: string, matcher: ILinkMatcher, fg: number): void {
const width = getStringCellWidth(uri);
const x1 = x % this._terminal.cols;
const y1 = y + Math.floor(x / this._terminal.cols);
let x2 = (x1 + width) % this._terminal.cols;
let y2 = y1 + Math.floor((x1 + width) / this._terminal.cols);
if (x2 === 0) {
x2 = this._terminal.cols;
y2--;
}
this._mouseZoneManager.add(new MouseZone(
x + 1,
x + 1 + uri.length,
y + 1,
x1 + 1,
y1 + 1,
x2 + 1,
y2 + 1,
e => {
if (matcher.handler) {
return matcher.handler(e, uri);
}
window.open(uri, '_blank');
},
e => {
this.emit(LinkHoverEventTypes.HOVER, <LinkHoverEvent>{ x, y, length: uri.length});
this._terminal.element.style.cursor = 'pointer';
() => {
this._onLinkHover.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));
this._terminal.element.classList.add('xterm-cursor-pointer');
},
e => {
this.emit(LinkHoverEventTypes.TOOLTIP, <LinkHoverEvent>{ x, y, length: uri.length});
this._onLinkTooltip.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));
if (matcher.hoverTooltipCallback) {
matcher.hoverTooltipCallback(e, uri);
}
},
() => {
this.emit(LinkHoverEventTypes.LEAVE, <LinkHoverEvent>{ x, y, length: uri.length});
this._terminal.element.style.cursor = '';
this._onLinkLeave.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));
this._terminal.element.classList.remove('xterm-cursor-pointer');
if (matcher.hoverLeaveCallback) {
matcher.hoverLeaveCallback();
}
},
e => {
if (matcher.willLinkActivate) {
return matcher.willLinkActivate(e, uri);
}
return true;
}
));
}
private _createLinkHoverEvent(x1: number, y1: number, x2: number, y2: number, fg: number): ILinkifierEvent {
return { x1, y1, x2, y2, cols: this._terminal.cols, fg };
}
}
@@ -31,40 +31,34 @@ describe('MouseHelper.getCoords', () => {
actualCellWidth: CHAR_WIDTH,
actualCellHeight: CHAR_HEIGHT
};
mouseHelper = new MouseHelper(renderer);
mouseHelper = new MouseHelper(renderer as any);
});
describe('when charMeasure is not initialized', () => {
it('should return null', () => {
charMeasure = new MockCharMeasure();
assert.equal(mouseHelper.getCoords({ pageX: 0, pageY: 0 }, document.createElement('div'), charMeasure, 1, 10, 10), null);
});
});
describe('when pageX/pageY are not supported', () => {
it('should return null', () => {
assert.equal(mouseHelper.getCoords({ pageX: undefined, pageY: undefined }, document.createElement('div'), charMeasure, 1, 10, 10), null);
assert.equal(mouseHelper.getCoords({ clientX: 0, clientY: 0 }, document.createElement('div'), charMeasure, 10, 10), null);
});
});
it('should return the cell that was clicked', () => {
let coords: [number, number];
coords = mouseHelper.getCoords({ pageX: CHAR_WIDTH / 2, pageY: CHAR_HEIGHT / 2 }, document.createElement('div'), charMeasure, 1, 10, 10);
coords = mouseHelper.getCoords({ clientX: CHAR_WIDTH / 2, clientY: CHAR_HEIGHT / 2 }, document.createElement('div'), charMeasure, 10, 10);
assert.deepEqual(coords, [1, 1]);
coords = mouseHelper.getCoords({ pageX: CHAR_WIDTH, pageY: CHAR_HEIGHT }, document.createElement('div'), charMeasure, 1, 10, 10);
coords = mouseHelper.getCoords({ clientX: CHAR_WIDTH, clientY: CHAR_HEIGHT }, document.createElement('div'), charMeasure, 10, 10);
assert.deepEqual(coords, [1, 1]);
coords = mouseHelper.getCoords({ pageX: CHAR_WIDTH, pageY: CHAR_HEIGHT + 1 }, document.createElement('div'), charMeasure, 1, 10, 10);
coords = mouseHelper.getCoords({ clientX: CHAR_WIDTH, clientY: CHAR_HEIGHT + 1 }, document.createElement('div'), charMeasure, 10, 10);
assert.deepEqual(coords, [1, 2]);
coords = mouseHelper.getCoords({ pageX: CHAR_WIDTH + 1, pageY: CHAR_HEIGHT }, document.createElement('div'), charMeasure, 1, 10, 10);
coords = mouseHelper.getCoords({ clientX: CHAR_WIDTH + 1, clientY: CHAR_HEIGHT }, document.createElement('div'), charMeasure, 10, 10);
assert.deepEqual(coords, [2, 1]);
});
it('should ensure the coordinates are returned within the terminal bounds', () => {
let coords: [number, number];
coords = mouseHelper.getCoords({ pageX: -1, pageY: -1 }, document.createElement('div'), charMeasure, 1, 10, 10);
coords = mouseHelper.getCoords({ clientX: -1, clientY: -1 }, document.createElement('div'), charMeasure, 10, 10);
assert.deepEqual(coords, [1, 1]);
// Event are double the cols/rows
coords = mouseHelper.getCoords({ pageX: CHAR_WIDTH * 20, pageY: CHAR_HEIGHT * 20 }, document.createElement('div'), charMeasure, 1, 10, 10);
coords = mouseHelper.getCoords({ clientX: CHAR_WIDTH * 20, clientY: CHAR_HEIGHT * 20 }, document.createElement('div'), charMeasure, 10, 10);
assert.deepEqual(coords, [10, 10], 'coordinates should never come back as larger than the terminal');
});
});
+15 -33
View File
@@ -3,36 +3,18 @@
* @license MIT
*/
import { ICharMeasure } from '../Interfaces';
import { IRenderer } from '../renderer/Interfaces';
import { ICharMeasure, IMouseHelper } from './Types';
import { RenderCoordinator } from './renderer/RenderCoordinator';
export class MouseHelper {
constructor(private _renderer: IRenderer) {}
export class MouseHelper implements IMouseHelper {
constructor(
private _renderCoordinator: RenderCoordinator
) {
}
public static getCoordsRelativeToElement(event: {pageX: number, pageY: number}, element: HTMLElement): [number, number] {
// Ignore browsers that don't support MouseEvent.pageX
if (event.pageX == null) {
return null;
}
const originalElement = element;
let x = event.pageX;
let y = event.pageY;
// Converts the coordinates from being relative to the document to being
// relative to the terminal.
while (element) {
x -= element.offsetLeft;
y -= element.offsetTop;
element = 'offsetParent' in element ? <HTMLElement>element.offsetParent : <HTMLElement>element.parentElement;
}
element = originalElement;
while (element && element !== element.ownerDocument.body) {
x += element.scrollLeft;
y += element.scrollTop;
element = <HTMLElement>element.parentElement;
}
return [x, y];
public static getCoordsRelativeToElement(event: {clientX: number, clientY: number}, element: HTMLElement): [number, number] {
const rect = element.getBoundingClientRect();
return [event.clientX - rect.left, event.clientY - rect.top];
}
/**
@@ -48,7 +30,7 @@ export class MouseHelper {
* apply an offset to the x value such that the left half of the cell will
* select that cell and the right half will select the next cell.
*/
public getCoords(event: {pageX: number, pageY: number}, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number, isSelection?: boolean): [number, number] {
public getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number, isSelection?: boolean): [number, number] {
// Coordinates cannot be measured if charMeasure has not been initialized
if (!charMeasure.width || !charMeasure.height) {
return null;
@@ -59,8 +41,8 @@ export class MouseHelper {
return null;
}
coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth);
coords[1] = Math.ceil(coords[1] / this._renderer.dimensions.actualCellHeight);
coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderCoordinator.dimensions.actualCellWidth / 2 : 0)) / this._renderCoordinator.dimensions.actualCellWidth);
coords[1] = Math.ceil(coords[1] / this._renderCoordinator.dimensions.actualCellHeight);
// Ensure coordinates are within the terminal viewport. Note that selections
// need an addition point of precision to cover the end point (as characters
@@ -81,8 +63,8 @@ export class MouseHelper {
* @param colCount The number of columns in the terminal.
* @param rowCount The number of rows in the terminal.
*/
public getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, lineHeight: number, colCount: number, rowCount: number): { x: number, y: number } {
const coords = this.getCoords(event, element, charMeasure, lineHeight, colCount, rowCount);
public getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number): { x: number, y: number } {
const coords = this.getCoords(event, element, charMeasure, colCount, rowCount);
let x = coords[0];
let y = coords[1];
@@ -3,8 +3,9 @@
* @license MIT
*/
import { IMouseZoneManager, IMouseZone } from './Interfaces';
import { ITerminal } from '../Interfaces';
import { ITerminal, IMouseZoneManager, IMouseZone } from './Types';
import { Disposable } from './common/Lifecycle';
import { addDisposableDomListener } from './ui/Lifecycle';
const HOVER_DURATION = 500;
@@ -16,27 +17,37 @@ const HOVER_DURATION = 500;
* needed to support was single-line links which never overlap. Improvements can
* be made in the future.
*/
export class MouseZoneManager implements IMouseZoneManager {
export class MouseZoneManager extends Disposable implements IMouseZoneManager {
private _zones: IMouseZone[] = [];
private _areZonesActive: boolean = false;
private _mouseMoveListener: (e: MouseEvent) => any;
private _mouseLeaveListener: (e: MouseEvent) => any;
private _clickListener: (e: MouseEvent) => any;
private _tooltipTimeout: number = null;
private _currentZone: IMouseZone = null;
private _lastHoverCoords: [number, number] = [null, null];
private _initialSelectionLength: number;
constructor(
private _terminal: ITerminal
) {
this._terminal.element.addEventListener('mousedown', e => this._onMouseDown(e));
super();
this.register(addDisposableDomListener(this._terminal.element, 'mousedown', e => this._onMouseDown(e)));
// These events are expensive, only listen to it when mouse zones are active
this._mouseMoveListener = e => this._onMouseMove(e);
this._mouseLeaveListener = e => this._onMouseLeave(e);
this._clickListener = e => this._onClick(e);
}
public dispose(): void {
super.dispose();
this._deactivate();
}
public add(zone: IMouseZone): void {
this._zones.push(zone);
if (this._zones.length === 1) {
@@ -59,7 +70,9 @@ export class MouseZoneManager implements IMouseZoneManager {
// Iterate through zones and clear them out if they're within the range
for (let i = 0; i < this._zones.length; i++) {
const zone = this._zones[i];
if (zone.y > start && zone.y <= end + 1) {
if ((zone.y1 > start && zone.y1 <= end + 1) ||
(zone.y2 > start && zone.y2 <= end + 1) ||
(zone.y1 < start && zone.y2 > end + 1)) {
if (this._currentZone && this._currentZone === zone) {
this._currentZone.leaveCallback();
this._currentZone = null;
@@ -78,6 +91,7 @@ export class MouseZoneManager implements IMouseZoneManager {
if (!this._areZonesActive) {
this._areZonesActive = true;
this._terminal.element.addEventListener('mousemove', this._mouseMoveListener);
this._terminal.element.addEventListener('mouseleave', this._mouseLeaveListener);
this._terminal.element.addEventListener('click', this._clickListener);
}
}
@@ -86,6 +100,7 @@ export class MouseZoneManager implements IMouseZoneManager {
if (this._areZonesActive) {
this._areZonesActive = false;
this._terminal.element.removeEventListener('mousemove', this._mouseMoveListener);
this._terminal.element.removeEventListener('mouseleave', this._mouseLeaveListener);
this._terminal.element.removeEventListener('click', this._clickListener);
}
}
@@ -142,6 +157,10 @@ export class MouseZoneManager implements IMouseZoneManager {
}
private _onMouseDown(e: MouseEvent): void {
// Store current terminal selection length, to check if we're performing
// a selection operation
this._initialSelectionLength = this._terminal.getSelection().length;
// Ignore the event if there are no zones active
if (!this._areZonesActive) {
return;
@@ -151,17 +170,32 @@ export class MouseZoneManager implements IMouseZoneManager {
// components from handling the mouse event.
const zone = this._findZoneEventAt(e);
if (zone) {
// TODO: When link modifier support is added, the event should only be
// cancelled when the modifier is held (see #1021)
e.preventDefault();
e.stopImmediatePropagation();
if (zone.willLinkActivate(e)) {
e.preventDefault();
e.stopImmediatePropagation();
}
}
}
private _onMouseLeave(e: MouseEvent): void {
// Fire the hover end callback and cancel any existing timer if the mouse
// leaves the terminal element
if (this._currentZone) {
this._currentZone.leaveCallback();
this._currentZone = null;
if (this._tooltipTimeout) {
clearTimeout(this._tooltipTimeout);
}
}
}
private _onClick(e: MouseEvent): void {
// Find the active zone and click it if found
// Find the active zone and click it if found and no selection was
// being performed
const zone = this._findZoneEventAt(e);
if (zone) {
const currentSelectionLength = this._terminal.getSelection().length;
if (zone && currentSelectionLength === this._initialSelectionLength) {
zone.clickCallback(e);
e.preventDefault();
e.stopImmediatePropagation();
@@ -169,16 +203,28 @@ export class MouseZoneManager implements IMouseZoneManager {
}
private _findZoneEventAt(e: MouseEvent): IMouseZone {
const coords = this._terminal.mouseHelper.getCoords(e, this._terminal.element, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows);
const coords = this._terminal.mouseHelper.getCoords(e, this._terminal.screenElement, this._terminal.charMeasure, this._terminal.cols, this._terminal.rows);
if (!coords) {
return null;
}
const x = coords[0];
const y = coords[1];
for (let i = 0; i < this._zones.length; i++) {
const zone = this._zones[i];
if (zone.y === coords[1] && zone.x1 <= coords[0] && zone.x2 > coords[0]) {
return zone;
if (zone.y1 === zone.y2) {
// Single line link
if (y === zone.y1 && x >= zone.x1 && x < zone.x2) {
return zone;
}
} else {
// Multi-line link
if ((y === zone.y1 && x >= zone.x1) ||
(y === zone.y2 && x < zone.x2) ||
(y > zone.y1 && y < zone.y2)) {
return zone;
}
}
};
}
return null;
}
}
@@ -186,12 +232,14 @@ export class MouseZoneManager implements IMouseZoneManager {
export class MouseZone implements IMouseZone {
constructor(
public x1: number,
public y1: number,
public x2: number,
public y: number,
public y2: number,
public clickCallback: (e: MouseEvent) => any,
public hoverCallback?: (e: MouseEvent) => any,
public tooltipCallback?: (e: MouseEvent) => any,
public leaveCallback?: () => void
public hoverCallback: (e: MouseEvent) => any,
public tooltipCallback: (e: MouseEvent) => any,
public leaveCallback: () => void,
public willLinkActivate: (e: MouseEvent) => boolean
) {
}
}
-666
View File
@@ -1,666 +0,0 @@
/**
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* @license MIT
*/
import { C0 } from './EscapeSequences';
import { IInputHandler } from './Interfaces';
import { CHARSETS, DEFAULT_CHARSET } from './Charsets';
const normalStateHandler: {[key: string]: (parser: Parser, handler: IInputHandler) => void} = {};
normalStateHandler[C0.BEL] = (parser, handler) => handler.bell();
normalStateHandler[C0.LF] = (parser, handler) => handler.lineFeed();
normalStateHandler[C0.VT] = normalStateHandler[C0.LF];
normalStateHandler[C0.FF] = normalStateHandler[C0.LF];
normalStateHandler[C0.CR] = (parser, handler) => handler.carriageReturn();
normalStateHandler[C0.BS] = (parser, handler) => handler.backspace();
normalStateHandler[C0.HT] = (parser, handler) => handler.tab();
normalStateHandler[C0.SO] = (parser, handler) => handler.shiftOut();
normalStateHandler[C0.SI] = (parser, handler) => handler.shiftIn();
normalStateHandler[C0.ESC] = (parser, handler) => parser.setState(ParserState.ESCAPED);
// TODO: Remove terminal when parser owns params and currentParam
const escapedStateHandler: {[key: string]: (parser: Parser, terminal: any) => void} = {};
escapedStateHandler['['] = (parser, terminal) => {
// ESC [ Control Sequence Introducer (CSI is 0x9b)
terminal.params = [];
terminal.currentParam = 0;
parser.setState(ParserState.CSI_PARAM);
};
escapedStateHandler[']'] = (parser, terminal) => {
// ESC ] Operating System Command (OSC is 0x9d)
terminal.params = [];
terminal.currentParam = 0;
parser.setState(ParserState.OSC);
};
escapedStateHandler['P'] = (parser, terminal) => {
// ESC P Device Control String (DCS is 0x90)
terminal.params = [];
terminal.currentParam = 0;
parser.setState(ParserState.DCS);
};
escapedStateHandler['_'] = (parser, terminal) => {
// ESC _ Application Program Command ( APC is 0x9f).
parser.setState(ParserState.IGNORE);
};
escapedStateHandler['^'] = (parser, terminal) => {
// ESC ^ Privacy Message ( PM is 0x9e).
parser.setState(ParserState.IGNORE);
};
escapedStateHandler['c'] = (parser, terminal) => {
// ESC c Full Reset (RIS).
terminal.reset();
};
escapedStateHandler['E'] = (parser, terminal) => {
// ESC E Next Line ( NEL is 0x85).
terminal.buffer.x = 0;
terminal.index();
parser.setState(ParserState.NORMAL);
};
escapedStateHandler['D'] = (parser, terminal) => {
// ESC D Index ( IND is 0x84).
terminal.index();
parser.setState(ParserState.NORMAL);
};
escapedStateHandler['M'] = (parser, terminal) => {
// ESC M Reverse Index ( RI is 0x8d).
terminal.reverseIndex();
parser.setState(ParserState.NORMAL);
};
escapedStateHandler['%'] = (parser, terminal) => {
// ESC % Select default/utf-8 character set.
// @ = default, G = utf-8
terminal.setgLevel(0);
terminal.setgCharset(0, DEFAULT_CHARSET); // US (default)
parser.setState(ParserState.NORMAL);
parser.skipNextChar();
};
escapedStateHandler[C0.CAN] = (parser) => parser.setState(ParserState.NORMAL);
const csiParamStateHandler: {[key: string]: (parser: Parser) => void} = {};
csiParamStateHandler['?'] = (parser) => parser.setPrefix('?');
csiParamStateHandler['>'] = (parser) => parser.setPrefix('>');
csiParamStateHandler['!'] = (parser) => parser.setPrefix('!');
csiParamStateHandler['0'] = (parser) => parser.setParam(parser.getParam() * 10);
csiParamStateHandler['1'] = (parser) => parser.setParam(parser.getParam() * 10 + 1);
csiParamStateHandler['2'] = (parser) => parser.setParam(parser.getParam() * 10 + 2);
csiParamStateHandler['3'] = (parser) => parser.setParam(parser.getParam() * 10 + 3);
csiParamStateHandler['4'] = (parser) => parser.setParam(parser.getParam() * 10 + 4);
csiParamStateHandler['5'] = (parser) => parser.setParam(parser.getParam() * 10 + 5);
csiParamStateHandler['6'] = (parser) => parser.setParam(parser.getParam() * 10 + 6);
csiParamStateHandler['7'] = (parser) => parser.setParam(parser.getParam() * 10 + 7);
csiParamStateHandler['8'] = (parser) => parser.setParam(parser.getParam() * 10 + 8);
csiParamStateHandler['9'] = (parser) => parser.setParam(parser.getParam() * 10 + 9);
csiParamStateHandler['$'] = (parser) => parser.setPostfix('$');
csiParamStateHandler['"'] = (parser) => parser.setPostfix('"');
csiParamStateHandler[' '] = (parser) => parser.setPostfix(' ');
csiParamStateHandler['\''] = (parser) => parser.setPostfix('\'');
csiParamStateHandler[';'] = (parser) => parser.finalizeParam();
csiParamStateHandler[C0.CAN] = (parser) => parser.setState(ParserState.NORMAL);
const csiStateHandler: {[key: string]: (handler: IInputHandler, params: number[], prefix: string, postfix: string, parser: Parser) => void} = {};
csiStateHandler['@'] = (handler, params, prefix) => handler.insertChars(params);
csiStateHandler['A'] = (handler, params, prefix) => handler.cursorUp(params);
csiStateHandler['B'] = (handler, params, prefix) => handler.cursorDown(params);
csiStateHandler['C'] = (handler, params, prefix) => handler.cursorForward(params);
csiStateHandler['D'] = (handler, params, prefix) => handler.cursorBackward(params);
csiStateHandler['E'] = (handler, params, prefix) => handler.cursorNextLine(params);
csiStateHandler['F'] = (handler, params, prefix) => handler.cursorPrecedingLine(params);
csiStateHandler['G'] = (handler, params, prefix) => handler.cursorCharAbsolute(params);
csiStateHandler['H'] = (handler, params, prefix) => handler.cursorPosition(params);
csiStateHandler['I'] = (handler, params, prefix) => handler.cursorForwardTab(params);
csiStateHandler['J'] = (handler, params, prefix) => handler.eraseInDisplay(params);
csiStateHandler['K'] = (handler, params, prefix) => handler.eraseInLine(params);
csiStateHandler['L'] = (handler, params, prefix) => handler.insertLines(params);
csiStateHandler['M'] = (handler, params, prefix) => handler.deleteLines(params);
csiStateHandler['P'] = (handler, params, prefix) => handler.deleteChars(params);
csiStateHandler['S'] = (handler, params, prefix) => handler.scrollUp(params);
csiStateHandler['T'] = (handler, params, prefix) => {
if (params.length < 2 && !prefix) {
handler.scrollDown(params);
}
};
csiStateHandler['X'] = (handler, params, prefix) => handler.eraseChars(params);
csiStateHandler['Z'] = (handler, params, prefix) => handler.cursorBackwardTab(params);
csiStateHandler['`'] = (handler, params, prefix) => handler.charPosAbsolute(params);
csiStateHandler['a'] = (handler, params, prefix) => handler.HPositionRelative(params);
csiStateHandler['b'] = (handler, params, prefix) => handler.repeatPrecedingCharacter(params);
csiStateHandler['c'] = (handler, params, prefix) => handler.sendDeviceAttributes(params);
csiStateHandler['d'] = (handler, params, prefix) => handler.linePosAbsolute(params);
csiStateHandler['e'] = (handler, params, prefix) => handler.VPositionRelative(params);
csiStateHandler['f'] = (handler, params, prefix) => handler.HVPosition(params);
csiStateHandler['g'] = (handler, params, prefix) => handler.tabClear(params);
csiStateHandler['h'] = (handler, params, prefix) => handler.setMode(params);
csiStateHandler['l'] = (handler, params, prefix) => handler.resetMode(params);
csiStateHandler['m'] = (handler, params, prefix) => handler.charAttributes(params);
csiStateHandler['n'] = (handler, params, prefix) => handler.deviceStatus(params);
csiStateHandler['p'] = (handler, params, prefix) => {
switch (prefix) {
case '!': handler.softReset(params); break;
}
};
csiStateHandler['q'] = (handler, params, prefix, postfix) => {
if (postfix === ' ') {
handler.setCursorStyle(params);
}
};
csiStateHandler['r'] = (handler, params) => handler.setScrollRegion(params);
csiStateHandler['s'] = (handler, params) => handler.saveCursor(params);
csiStateHandler['u'] = (handler, params) => handler.restoreCursor(params);
csiStateHandler[C0.CAN] = (handler, params, prefix, postfix, parser) => parser.setState(ParserState.NORMAL);
export enum ParserState {
NORMAL = 0,
ESCAPED = 1,
CSI_PARAM = 2,
CSI = 3,
OSC = 4,
CHARSET = 5,
DCS = 6,
IGNORE = 7
}
/**
* The terminal's parser, all input into the terminal goes through the parser
* which parses and defers the actual input handling the the IInputHandler
* specified in the constructor.
*/
export class Parser {
private _state: ParserState;
private _position: number;
// TODO: Remove terminal when handler can do everything
constructor(
private _inputHandler: IInputHandler,
private _terminal: any
) {
this._state = ParserState.NORMAL;
}
/**
* Parse and handle data.
*
* @param data The data to parse.
*/
public parse(data: string): ParserState {
const l = data.length;
let j;
let cs;
let ch;
let code;
let low;
const cursorStartX = this._terminal.buffer.x;
const cursorStartY = this._terminal.buffer.y;
if (this._terminal.debug) {
this._terminal.log('data: ' + data);
}
this._position = 0;
// apply leftover surrogate high from last write
if (this._terminal.surrogate_high) {
data = this._terminal.surrogate_high + data;
this._terminal.surrogate_high = '';
}
for (; this._position < l; this._position++) {
ch = data[this._position];
// FIXME: higher chars than 0xa0 are not allowed in escape sequences
// --> maybe move to default
code = data.charCodeAt(this._position);
if (0xD800 <= code && code <= 0xDBFF) {
// we got a surrogate high
// get surrogate low (next 2 bytes)
low = data.charCodeAt(this._position + 1);
if (isNaN(low)) {
// end of data stream, save surrogate high
this._terminal.surrogate_high = ch;
continue;
}
code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
ch += data.charAt(this._position + 1);
}
// surrogate low - already handled above
if (0xDC00 <= code && code <= 0xDFFF)
continue;
switch (this._state) {
case ParserState.NORMAL:
if (ch in normalStateHandler) {
normalStateHandler[ch](this, this._inputHandler);
} else {
this._inputHandler.addChar(ch, code);
}
break;
case ParserState.ESCAPED:
if (ch in escapedStateHandler) {
escapedStateHandler[ch](this, this._terminal);
// Skip switch as it was just handled
break;
}
switch (ch) {
// ESC (,),*,+,-,. Designate G0-G2 Character Set.
case '(': // <-- this seems to get all the attention
case ')':
case '*':
case '+':
case '-':
case '.':
switch (ch) {
case '(':
this._terminal.gcharset = 0;
break;
case ')':
this._terminal.gcharset = 1;
break;
case '*':
this._terminal.gcharset = 2;
break;
case '+':
this._terminal.gcharset = 3;
break;
case '-':
this._terminal.gcharset = 1;
break;
case '.':
this._terminal.gcharset = 2;
break;
}
this._state = ParserState.CHARSET;
break;
// Designate G3 Character Set (VT300).
// A = ISO Latin-1 Supplemental.
// Not implemented.
case '/':
this._terminal.gcharset = 3;
this._state = ParserState.CHARSET;
this._position--;
break;
// ESC N
// Single Shift Select of G2 Character Set
// ( SS2 is 0x8e). This affects next character only.
case 'N':
break;
// ESC O
// Single Shift Select of G3 Character Set
// ( SS3 is 0x8f). This affects next character only.
case 'O':
break;
// ESC n
// Invoke the G2 Character Set as GL (LS2).
case 'n':
this._terminal.setgLevel(2);
break;
// ESC o
// Invoke the G3 Character Set as GL (LS3).
case 'o':
this._terminal.setgLevel(3);
break;
// ESC |
// Invoke the G3 Character Set as GR (LS3R).
case '|':
this._terminal.setgLevel(3);
break;
// ESC }
// Invoke the G2 Character Set as GR (LS2R).
case '}':
this._terminal.setgLevel(2);
break;
// ESC ~
// Invoke the G1 Character Set as GR (LS1R).
case '~':
this._terminal.setgLevel(1);
break;
// ESC 7 Save Cursor (DECSC).
case '7':
this._inputHandler.saveCursor();
this._state = ParserState.NORMAL;
break;
// ESC 8 Restore Cursor (DECRC).
case '8':
this._inputHandler.restoreCursor();
this._state = ParserState.NORMAL;
break;
// ESC # 3 DEC line height/width
case '#':
this._state = ParserState.NORMAL;
this._position++;
break;
// ESC H Tab Set (HTS is 0x88).
case 'H':
this._terminal.tabSet();
this._state = ParserState.NORMAL;
break;
// ESC = Application Keypad (DECKPAM).
case '=':
this._terminal.log('Serial port requested application keypad.');
this._terminal.applicationKeypad = true;
if (this._terminal.viewport) {
this._terminal.viewport.syncScrollArea();
}
this._state = ParserState.NORMAL;
break;
// ESC > Normal Keypad (DECKPNM).
case '>':
this._terminal.log('Switching back to normal keypad.');
this._terminal.applicationKeypad = false;
if (this._terminal.viewport) {
this._terminal.viewport.syncScrollArea();
}
this._state = ParserState.NORMAL;
break;
default:
this._state = ParserState.NORMAL;
this._terminal.error('Unknown ESC control: %s.', ch);
break;
}
break;
case ParserState.CHARSET:
if (ch in CHARSETS) {
cs = CHARSETS[ch];
if (ch === '/') { // ISOLatin is actually /A
this.skipNextChar();
}
} else {
cs = DEFAULT_CHARSET;
}
this._terminal.setgCharset(this._terminal.gcharset, cs);
this._terminal.gcharset = null;
this._state = ParserState.NORMAL;
break;
case ParserState.OSC:
// OSC Ps ; Pt ST
// OSC Ps ; Pt BEL
// Set Text Parameters.
if (ch === C0.ESC || ch === C0.BEL) {
if (ch === C0.ESC) this._position++;
this._terminal.params.push(this._terminal.currentParam);
switch (this._terminal.params[0]) {
case 0:
case 1:
case 2:
if (this._terminal.params[1]) {
this._terminal.title = this._terminal.params[1];
this._terminal.handleTitle(this._terminal.title);
}
break;
case 3:
// set X property
break;
case 4:
case 5:
// change dynamic colors
break;
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
// change dynamic ui colors
break;
case 46:
// change log file
break;
case 50:
// dynamic font
break;
case 51:
// emacs shell
break;
case 52:
// manipulate selection data
break;
case 104:
case 105:
case 110:
case 111:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
// reset colors
break;
}
this._terminal.params = [];
this._terminal.currentParam = 0;
this._state = ParserState.NORMAL;
} else {
if (!this._terminal.params.length) {
if (ch >= '0' && ch <= '9') {
this._terminal.currentParam =
this._terminal.currentParam * 10 + ch.charCodeAt(0) - 48;
} else if (ch === ';') {
this._terminal.params.push(this._terminal.currentParam);
this._terminal.currentParam = '';
}
} else {
this._terminal.currentParam += ch;
}
}
break;
case ParserState.CSI_PARAM:
if (ch in csiParamStateHandler) {
csiParamStateHandler[ch](this);
break;
}
this.finalizeParam();
// Fall through the CSI as this character should be the CSI code.
this._state = ParserState.CSI;
case ParserState.CSI:
if (ch in csiStateHandler) {
if (this._terminal.debug) {
this._terminal.log(`CSI ${this._terminal.prefix ? this._terminal.prefix : ''} ${this._terminal.params ? this._terminal.params.join(';') : ''} ${this._terminal.postfix ? this._terminal.postfix : ''} ${ch}`);
}
csiStateHandler[ch](this._inputHandler, this._terminal.params, this._terminal.prefix, this._terminal.postfix, this);
} else {
this._terminal.error('Unknown CSI code: %s.', ch);
}
this._state = ParserState.NORMAL;
this._terminal.prefix = '';
this._terminal.postfix = '';
break;
case ParserState.DCS:
if (ch === C0.ESC || ch === C0.BEL) {
if (ch === C0.ESC) this._position++;
let pt;
let valid: boolean;
switch (this._terminal.prefix) {
// User-Defined Keys (DECUDK).
case '':
break;
// Request Status String (DECRQSS).
// test: echo -e '\eP$q"p\e\\'
case '$q':
pt = this._terminal.currentParam;
valid = false;
switch (pt) {
// DECSCA
case '"q':
pt = '0"q';
break;
// DECSCL
case '"p':
pt = '61"p';
break;
// DECSTBM
case 'r':
pt = ''
+ (this._terminal.buffer.scrollTop + 1)
+ ';'
+ (this._terminal.buffer.scrollBottom + 1)
+ 'r';
break;
// SGR
case 'm':
pt = '0m';
break;
default:
this._terminal.error('Unknown DCS Pt: %s.', pt);
pt = '';
break;
}
this._terminal.send(C0.ESC + 'P' + +valid + '$r' + pt + C0.ESC + '\\');
break;
// Set Termcap/Terminfo Data (xterm, experimental).
case '+p':
break;
// Request Termcap/Terminfo String (xterm, experimental)
// Regular xterm does not even respond to this sequence.
// This can cause a small glitch in vim.
// test: echo -ne '\eP+q6b64\e\\'
case '+q':
pt = this._terminal.currentParam;
valid = false;
this._terminal.send(C0.ESC + 'P' + +valid + '+r' + pt + C0.ESC + '\\');
break;
default:
this._terminal.error('Unknown DCS prefix: %s.', this._terminal.prefix);
break;
}
this._terminal.currentParam = 0;
this._terminal.prefix = '';
this._state = ParserState.NORMAL;
} else if (!this._terminal.currentParam) {
if (!this._terminal.prefix && ch !== '$' && ch !== '+') {
this._terminal.currentParam = ch;
} else if (this._terminal.prefix.length === 2) {
this._terminal.currentParam = ch;
} else {
this._terminal.prefix += ch;
}
} else {
this._terminal.currentParam += ch;
}
break;
case ParserState.IGNORE:
// For PM and APC.
if (ch === C0.ESC || ch === C0.BEL) {
if (ch === C0.ESC) this._position++;
this._state = ParserState.NORMAL;
}
break;
}
}
// Fire the cursormove event if it's moved. This is done inside the parser
// as a render cannot happen in the middle of a parsing round.
if (this._terminal.buffer.x !== cursorStartX || this._terminal.buffer.y !== cursorStartY) {
this._terminal.emit('cursormove');
}
return this._state;
}
/**
* Set the parser's current parsing state.
*
* @param state The new state.
*/
public setState(state: ParserState): void {
this._state = state;
}
/**
* Sets the parsier's current prefix. CSI codes can have prefixes of '?', '>'
* or '!'.
*
* @param prefix The prefix.
*/
public setPrefix(prefix: string): void {
this._terminal.prefix = prefix;
}
/**
* Sets the parsier's current prefix. CSI codes can have postfixes of '$',
* '"', ' ', '\''.
*
* @param postfix The postfix.
*/
public setPostfix(postfix: string): void {
this._terminal.postfix = postfix;
}
/**
* Sets the parser's current parameter.
*
* @param param the parameter.
*/
public setParam(param: number): void {
this._terminal.currentParam = param;
}
/**
* Gets the parser's current parameter.
*/
public getParam(): number {
return this._terminal.currentParam;
}
/**
* Finalizes the parser's current parameter, adding it to the list of
* parameters and setting the new current parameter to 0.
*/
public finalizeParam(): void {
this._terminal.params.push(this._terminal.currentParam);
this._terminal.currentParam = 0;
}
/**
* Tell the parser to skip the next character.
*/
public skipNextChar(): void {
this._position++;
}
/**
* Tell the parser to repeat parsing the current character (for example if it
* needs parsing using a different state.
*/
// public repeatChar(): void {
// this._position--;
// }
}
+180 -28
View File
@@ -3,16 +3,15 @@
* @license MIT
*/
import jsdom = require('jsdom');
import { assert } from 'chai';
import { ITerminal, ICircularList, IBuffer } from './Interfaces';
import { CharMeasure } from './utils/CharMeasure';
import { CircularList } from './utils/CircularList';
import { SelectionManager } from './SelectionManager';
import { CharMeasure } from './CharMeasure';
import { SelectionManager, SelectionMode } from './SelectionManager';
import { SelectionModel } from './SelectionModel';
import { BufferSet } from './BufferSet';
import { MockTerminal } from './utils/TestUtils.test';
import { LineData, CharData } from './Types';
import { ITerminal, IBuffer } from './Types';
import { IBufferLine } from './core/Types';
import { MockTerminal } from './TestUtils.test';
import { BufferLine, CellData } from './core/buffer/BufferLine';
class TestMockTerminal extends MockTerminal {
emit(event: string, data: any): void {}
@@ -21,16 +20,18 @@ class TestMockTerminal extends MockTerminal {
class TestSelectionManager extends SelectionManager {
constructor(
terminal: ITerminal,
buffer: IBuffer,
charMeasure: CharMeasure
) {
super(terminal, buffer, charMeasure);
super(terminal, charMeasure);
}
public get model(): SelectionModel { return this._model; }
public set selectionMode(mode: SelectionMode) { this._activeSelectionMode = mode; }
public selectLineAt(line: number): void { this._selectLineAt(line); }
public selectWordAt(coords: [number, number]): void { this._selectWordAt(coords); }
public selectWordAt(coords: [number, number]): void { this._selectWordAt(coords, true); }
public areCoordsInSelection(coords: [number, number], start: [number, number], end: [number, number]): boolean { return this._areCoordsInSelection(coords, start, end); }
// Disable DOM interaction
public enable(): void {}
@@ -39,39 +40,33 @@ class TestSelectionManager extends SelectionManager {
}
describe('SelectionManager', () => {
let dom: jsdom.JSDOM;
let window: Window;
let document: Document;
let terminal: ITerminal;
let buffer: IBuffer;
let rowContainer: HTMLElement;
let selectionManager: TestSelectionManager;
beforeEach(() => {
dom = new jsdom.JSDOM('');
window = dom.window;
document = window.document;
terminal = new TestMockTerminal();
terminal.cols = 80;
terminal.rows = 2;
(terminal as any).cols = 80;
(terminal as any).rows = 2;
terminal.options.scrollback = 100;
terminal.buffers = new BufferSet(terminal);
terminal.buffer = terminal.buffers.active;
buffer = terminal.buffer;
selectionManager = new TestSelectionManager(terminal, buffer, null);
selectionManager = new TestSelectionManager(terminal, null);
});
function stringToRow(text: string): LineData {
let result: LineData = [];
function stringToRow(text: string): IBufferLine {
const result = new BufferLine(text.length);
for (let i = 0; i < text.length; i++) {
result.push([0, text.charAt(i), 1, text.charCodeAt(i)]);
result.setCell(i, CellData.fromCharData([0, text.charAt(i), 1, text.charCodeAt(i)]));
}
return result;
}
function stringArrayToRow(chars: string[]): LineData {
return chars.map(c => <CharData>[0, c, 1, c.charCodeAt(0)]);
function stringArrayToRow(chars: string[]): IBufferLine {
const line = new BufferLine(chars.length);
chars.map((c, idx) => line.setCell(idx, CellData.fromCharData([0, c, 1, c.charCodeAt(0)])));
return line;
}
describe('_selectWordAt', () => {
@@ -107,7 +102,7 @@ describe('SelectionManager', () => {
});
it('should expand selection for wide characters', () => {
// Wide characters use a special format
buffer.lines.set(0, [
const data: [number, string, number, number][] = [
[null, '中', 2, '中'.charCodeAt(0)],
[null, '', 0, null],
[null, '文', 2, '文'.charCodeAt(0)],
@@ -123,7 +118,10 @@ describe('SelectionManager', () => {
[null, 'f', 1, 'f'.charCodeAt(0)],
[null, 'o', 1, 'o'.charCodeAt(0)],
[null, 'o', 1, 'o'.charCodeAt(0)]
]);
];
const line = new BufferLine(data.length);
for (let i = 0; i < data.length; ++i) line.setCell(i, CellData.fromCharData(data[i]));
buffer.lines.set(0, line);
// Ensure wide characters take up 2 columns
selectionManager.selectWordAt([0, 0]);
assert.equal(selectionManager.selectionText, '中文');
@@ -193,6 +191,42 @@ describe('SelectionManager', () => {
selectionManager.selectWordAt([15, 0]);
assert.equal(selectionManager.selectionText, 'ij"');
});
it('should expand upwards or downards for wrapped lines', () => {
buffer.lines.set(0, stringToRow(' foo'));
buffer.lines.set(1, stringToRow('bar '));
buffer.lines.get(1).isWrapped = true;
selectionManager.selectWordAt([1, 1]);
assert.equal(selectionManager.selectionText, 'foobar');
selectionManager.model.clearSelection();
selectionManager.selectWordAt([78, 0]);
assert.equal(selectionManager.selectionText, 'foobar');
});
it('should expand both upwards and downwards for word wrapped over many lines', () => {
const expectedText = 'fooaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccbar';
buffer.lines.set(0, stringToRow(' foo'));
buffer.lines.set(1, stringToRow('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
buffer.lines.set(2, stringToRow('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'));
buffer.lines.set(3, stringToRow('cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'));
buffer.lines.set(4, stringToRow('bar '));
buffer.lines.get(1).isWrapped = true;
buffer.lines.get(2).isWrapped = true;
buffer.lines.get(3).isWrapped = true;
buffer.lines.get(4).isWrapped = true;
selectionManager.selectWordAt([78, 0]);
assert.equal(selectionManager.selectionText, expectedText);
selectionManager.model.clearSelection();
selectionManager.selectWordAt([40, 1]);
assert.equal(selectionManager.selectionText, expectedText);
selectionManager.model.clearSelection();
selectionManager.selectWordAt([40, 2]);
assert.equal(selectionManager.selectionText, expectedText);
selectionManager.model.clearSelection();
selectionManager.selectWordAt([40, 3]);
assert.equal(selectionManager.selectionText, expectedText);
selectionManager.model.clearSelection();
selectionManager.selectWordAt([1, 4]);
assert.equal(selectionManager.selectionText, expectedText);
});
describe('emoji', () => {
it('should treat a single emoji as a word when wrapped in spaces', () => {
buffer.lines.set(0, stringToRow(' ⚽ a')); // The a is here to prevent the space being trimmed in selectionText
@@ -310,6 +344,16 @@ describe('SelectionManager', () => {
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 0]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 0], 'The actual selection spans the entire column');
});
it('should select the entire wrapped line', () => {
buffer.lines.set(0, stringToRow('foo'));
const line2 = stringToRow('bar');
line2.isWrapped = true;
buffer.lines.set(1, line2);
selectionManager.selectLineAt(0);
assert.equal(selectionManager.selectionText, 'foobar', 'The selected text is correct');
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 0]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 1], 'The actual selection spans the entire column');
});
});
describe('selectAll', () => {
@@ -326,6 +370,45 @@ describe('SelectionManager', () => {
});
});
describe('selectLines', () => {
it('should select a single line', () => {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
buffer.lines.set(2, stringToRow('3'));
selectionManager.selectLines(1, 1);
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 1]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 1]);
});
it('should select multiple lines', () => {
buffer.lines.length = 5;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
buffer.lines.set(2, stringToRow('3'));
buffer.lines.set(3, stringToRow('4'));
buffer.lines.set(4, stringToRow('5'));
selectionManager.selectLines(1, 3);
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 1]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 3]);
});
it('should select the to the start when requesting a negative row', () => {
buffer.lines.length = 2;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
selectionManager.selectLines(-1, 0);
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 0]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 0]);
});
it('should select the to the end when requesting beyond the final row', () => {
buffer.lines.length = 2;
buffer.lines.set(0, stringToRow('1'));
buffer.lines.set(1, stringToRow('2'));
selectionManager.selectLines(1, 2);
assert.deepEqual(selectionManager.model.finalSelectionStart, [0, 1]);
assert.deepEqual(selectionManager.model.finalSelectionEnd, [terminal.cols, 1]);
});
});
describe('hasSelection', () => {
it('should return whether there is a selection', () => {
selectionManager.model.selectionStart = [0, 0];
@@ -341,4 +424,73 @@ describe('SelectionManager', () => {
assert.equal(selectionManager.hasSelection, true);
});
});
describe('column selection', () => {
it('should select a column of text', () => {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('abcdefghij'));
buffer.lines.set(1, stringToRow('klmnopqrst'));
buffer.lines.set(2, stringToRow('uvwxyz'));
selectionManager.selectionMode = SelectionMode.COLUMN;
selectionManager.model.selectionStart = [2, 0];
selectionManager.model.selectionEnd = [4, 2];
assert.equal(selectionManager.selectionText, 'cd\nmn\nwx');
});
it('should select a column of text without chopping up double width characters', () => {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('a'));
buffer.lines.set(1, stringToRow('語'));
buffer.lines.set(2, stringToRow('b'));
selectionManager.selectionMode = SelectionMode.COLUMN;
selectionManager.model.selectionStart = [0, 0];
selectionManager.model.selectionEnd = [1, 2];
assert.equal(selectionManager.selectionText, 'a\n語\nb');
});
it('should select a column of text with single character emojis', () => {
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('a'));
buffer.lines.set(1, stringToRow('☃'));
buffer.lines.set(2, stringToRow('c'));
selectionManager.selectionMode = SelectionMode.COLUMN;
selectionManager.model.selectionStart = [0, 0];
selectionManager.model.selectionEnd = [1, 2];
assert.equal(selectionManager.selectionText, 'a\n☃\nc');
});
it('should select a column of text with double character emojis', () => {
// TODO the case this is testing works for me in the demo webapp,
// but doing it programmatically fails.
buffer.lines.length = 3;
buffer.lines.set(0, stringToRow('a '));
buffer.lines.set(1, stringArrayToRow(['😁', ' ']));
buffer.lines.set(2, stringToRow('c '));
selectionManager.selectionMode = SelectionMode.COLUMN;
selectionManager.model.selectionStart = [0, 0];
selectionManager.model.selectionEnd = [1, 2];
assert.equal(selectionManager.selectionText, 'a\n😁\nc');
});
});
describe('_areCoordsInSelection', () => {
it('should return whether coords are in the selection', () => {
assert.isFalse(selectionManager.areCoordsInSelection([0, 0], [2, 0], [2, 1]));
assert.isFalse(selectionManager.areCoordsInSelection([1, 0], [2, 0], [2, 1]));
assert.isTrue(selectionManager.areCoordsInSelection([2, 0], [2, 0], [2, 1]));
assert.isTrue(selectionManager.areCoordsInSelection([10, 0], [2, 0], [2, 1]));
assert.isTrue(selectionManager.areCoordsInSelection([0, 1], [2, 0], [2, 1]));
assert.isTrue(selectionManager.areCoordsInSelection([1, 1], [2, 0], [2, 1]));
assert.isFalse(selectionManager.areCoordsInSelection([2, 1], [2, 0], [2, 1]));
});
});
});
+299 -112
View File
@@ -3,15 +3,16 @@
* @license MIT
*/
import { MouseHelper } from './utils/MouseHelper';
import * as Browser from './utils/Browser';
import { CharMeasure } from './utils/CharMeasure';
import { CircularList } from './utils/CircularList';
import { EventEmitter } from './EventEmitter';
import { ITerminal, ICircularList, ISelectionManager, IBuffer } from './Interfaces';
import { ITerminal, ISelectionManager, IBuffer, ISelectionRedrawRequestEvent } from './Types';
import { IBufferLine } from './core/Types';
import { MouseHelper } from './MouseHelper';
import * as Browser from './common/Platform';
import { CharMeasure } from './CharMeasure';
import { SelectionModel } from './SelectionModel';
import { LineData, CharData } from './Types';
import { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from './Buffer';
import { AltClickHandler } from './handlers/AltClickHandler';
import { CellData } from './core/buffer/BufferLine';
import { IDisposable } from 'xterm';
import { EventEmitter2, IEvent } from './common/EventEmitter2';
/**
* The number of pixels the mouse needs to be above or below the viewport in
@@ -29,6 +30,12 @@ const DRAG_SCROLL_MAX_SPEED = 15;
*/
const DRAG_SCROLL_INTERVAL = 50;
/**
* The maximum amount of time that can have elapsed for an alt click to move the
* cursor.
*/
const ALT_CLICK_MOVE_CURSOR_TIME = 500;
/**
* A string containing all characters that are considered word separated by the
* double click to select work logic.
@@ -49,10 +56,11 @@ interface IWordPosition {
/**
* A selection mode, this drives how the selection behaves on mouse move.
*/
enum SelectionMode {
export const enum SelectionMode {
NORMAL,
WORD,
LINE
LINE,
COLUMN
}
/**
@@ -60,10 +68,10 @@ enum SelectionMode {
* SelectionModel, SelectionManager handles with all logic associated with
* dealing with the selection, including handling mouse interaction, wide
* characters and fetching the actual text within the selection. Rendering is
* not handled by the SelectionManager but a 'refresh' event is fired when the
* selection is ready to be redrawn.
* not handled by the SelectionManager but the onRedrawRequest event is fired
* when the selection is ready to be redrawn (on an animation frame).
*/
export class SelectionManager extends EventEmitter implements ISelectionManager {
export class SelectionManager implements ISelectionManager {
protected _model: SelectionModel;
/**
@@ -75,7 +83,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
/**
* The current selection mode.
*/
private _activeSelectionMode: SelectionMode;
protected _activeSelectionMode: SelectionMode;
/**
* A setInterval timer that is active while the mouse is down whose callback
@@ -95,13 +103,22 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
private _mouseMoveListener: EventListener;
private _mouseUpListener: EventListener;
private _trimListener: IDisposable;
private _workCell: CellData = new CellData();
private _mouseDownTimeStamp: number;
private _onLinuxMouseSelection = new EventEmitter2<string>();
public get onLinuxMouseSelection(): IEvent<string> { return this._onLinuxMouseSelection.event; }
private _onRedrawRequest = new EventEmitter2<ISelectionRedrawRequestEvent>();
public get onRedrawRequest(): IEvent<ISelectionRedrawRequestEvent> { return this._onRedrawRequest.event; }
private _onSelectionChange = new EventEmitter2<void>();
public get onSelectionChange(): IEvent<void> { return this._onSelectionChange.event; }
constructor(
private _terminal: ITerminal,
private _buffer: IBuffer,
private _charMeasure: CharMeasure
) {
super();
this._initListeners();
this.enable();
@@ -109,6 +126,14 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
this._activeSelectionMode = SelectionMode.NORMAL;
}
public dispose(): void {
this._removeMouseDownListeners();
}
private get _buffer(): IBuffer {
return this._terminal.buffers.active;
}
/**
* Initializes listener variables.
*/
@@ -116,11 +141,12 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
this._mouseMoveListener = event => this._onMouseMove(<MouseEvent>event);
this._mouseUpListener = event => this._onMouseUp(<MouseEvent>event);
// Only adjust the selection on trim, shiftElements is rarely used (only in
// reverseIndex) and delete in a splice is only ever used when the same
// number of elements was just added. Given this is could actually be
// beneficial to leave the selection as is for these cases.
this._buffer.lines.on('trim', (amount: number) => this._onTrim(amount));
this.initBuffersListeners();
}
public initBuffersListeners(): void {
this._trimListener = this._terminal.buffer.lines.onTrim(amount => this._onTrim(amount));
this._terminal.buffers.onBufferActivate(e => this._onBufferActivate(e));
}
/**
@@ -139,16 +165,6 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
this._enabled = true;
}
/**
* Sets the active buffer, this should be called when the alt buffer is
* switched in or out.
* @param buffer The active buffer.
*/
public setBuffer(buffer: IBuffer): void {
this._buffer = buffer;
this.clearSelection();
}
public get selectionStart(): [number, number] { return this._model.finalSelectionStart; }
public get selectionEnd(): [number, number] { return this._model.finalSelectionEnd; }
@@ -174,30 +190,43 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
return '';
}
// Get first row
const startRowEndCol = start[1] === end[1] ? end[0] : null;
let result: string[] = [];
result.push(this._buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));
const result: string[] = [];
// Get middle rows
for (let i = start[1] + 1; i <= end[1] - 1; i++) {
const bufferLine = this._buffer.lines.get(i);
const lineText = this._buffer.translateBufferLineToString(i, true);
if ((<any>bufferLine).isWrapped) {
result[result.length - 1] += lineText;
} else {
if (this._activeSelectionMode === SelectionMode.COLUMN) {
// Ignore zero width selections
if (start[0] === end[0]) {
return '';
}
for (let i = start[1]; i <= end[1]; i++) {
const lineText = this._buffer.translateBufferLineToString(i, true, start[0], end[0]);
result.push(lineText);
}
}
} else {
// Get first row
const startRowEndCol = start[1] === end[1] ? end[0] : undefined;
result.push(this._buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));
// Get final row
if (start[1] !== end[1]) {
const bufferLine = this._buffer.lines.get(end[1]);
const lineText = this._buffer.translateBufferLineToString(end[1], true, 0, end[0]);
if ((<any>bufferLine).isWrapped) {
result[result.length - 1] += lineText;
} else {
result.push(lineText);
// Get middle rows
for (let i = start[1] + 1; i <= end[1] - 1; i++) {
const bufferLine = this._buffer.lines.get(i);
const lineText = this._buffer.translateBufferLineToString(i, true);
if (bufferLine.isWrapped) {
result[result.length - 1] += lineText;
} else {
result.push(lineText);
}
}
// Get final row
if (start[1] !== end[1]) {
const bufferLine = this._buffer.lines.get(end[1]);
const lineText = this._buffer.translateBufferLineToString(end[1], true, 0, end[0]);
if (bufferLine.isWrapped) {
result[result.length - 1] += lineText;
} else {
result.push(lineText);
}
}
}
@@ -217,14 +246,15 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
this._model.clearSelection();
this._removeMouseDownListeners();
this.refresh();
this._onSelectionChange.fire();
}
/**
* Queues a refresh, redrawing the selection on the next opportunity.
* @param isNewSelection Whether the selection should be registered as a new
* @param isLinuxMouseSelection Whether the selection should be registered as a new
* selection on Linux.
*/
public refresh(isNewSelection?: boolean): void {
public refresh(isLinuxMouseSelection?: boolean): void {
// Queue the refresh for the renderer
if (!this._refreshAnimationFrame) {
this._refreshAnimationFrame = window.requestAnimationFrame(() => this._refresh());
@@ -232,10 +262,10 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
// If the platform is Linux and the refresh call comes from a mouse event,
// we need to update the selection for middle click to paste selection.
if (Browser.isLinux && isNewSelection) {
if (Browser.isLinux && isLinuxMouseSelection) {
const selectionText = this.selectionText;
if (selectionText.length) {
this.emit('newselection', this.selectionText);
this._onLinuxMouseSelection.fire(this.selectionText);
}
}
}
@@ -246,7 +276,47 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
*/
private _refresh(): void {
this._refreshAnimationFrame = null;
this.emit('refresh', { start: this._model.finalSelectionStart, end: this._model.finalSelectionEnd });
this._onRedrawRequest.fire({
start: this._model.finalSelectionStart,
end: this._model.finalSelectionEnd,
columnSelectMode: this._activeSelectionMode === SelectionMode.COLUMN
});
}
/**
* Checks if the current click was inside the current selection
* @param event The mouse event
*/
public isClickInSelection(event: MouseEvent): boolean {
const coords = this._getMouseBufferCoords(event);
const start = this._model.finalSelectionStart;
const end = this._model.finalSelectionEnd;
if (!start || !end) {
return false;
}
return this._areCoordsInSelection(coords, start, end);
}
protected _areCoordsInSelection(coords: [number, number], start: [number, number], end: [number, number]): boolean {
return (coords[1] > start[1] && coords[1] < end[1]) ||
(start[1] === end[1] && coords[1] === start[1] && coords[0] >= start[0] && coords[0] < end[0]) ||
(start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]) ||
(start[1] < end[1] && coords[1] === start[1] && coords[0] >= start[0]);
}
/**
* Selects word at the current mouse event coordinates.
* @param event The mouse event.
*/
public selectWordAtCursor(event: MouseEvent): void {
const coords = this._getMouseBufferCoords(event);
if (coords) {
this._selectWordAt(coords, false);
this._model.selectionEnd = null;
this.refresh(true);
}
}
/**
@@ -255,7 +325,17 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
public selectAll(): void {
this._model.isSelectAllActive = true;
this.refresh();
this._terminal.emit('selection');
this._onSelectionChange.fire();
}
public selectLines(start: number, end: number): void {
this._model.clearSelection();
start = Math.max(start, 0);
end = Math.min(end, this._terminal.buffer.lines.length - 1);
this._model.selectionStart = [0, start];
this._model.selectionEnd = [this._terminal.cols, end];
this.refresh();
this._onSelectionChange.fire();
}
/**
@@ -274,7 +354,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* @param event The mouse event.
*/
private _getMouseBufferCoords(event: MouseEvent): [number, number] {
const coords = this._terminal.mouseHelper.getCoords(event, this._terminal.element, this._charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows, true);
const coords = this._terminal.mouseHelper.getCoords(event, this._terminal.screenElement, this._charMeasure, this._terminal.cols, this._terminal.rows, true);
if (!coords) {
return null;
}
@@ -294,7 +374,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* @param event The mouse event.
*/
private _getMouseEventScrollAmount(event: MouseEvent): number {
let offset = MouseHelper.getCoordsRelativeToElement(event, this._terminal.element)[1];
let offset = MouseHelper.getCoordsRelativeToElement(event, this._terminal.screenElement)[1];
const terminalHeight = this._terminal.rows * Math.ceil(this._charMeasure.height * this._terminal.options.lineHeight);
if (offset >= 0 && offset <= terminalHeight) {
return 0;
@@ -314,7 +394,11 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* @param event The mouse event.
*/
public shouldForceSelection(event: MouseEvent): boolean {
return Browser.isMac ? event.altKey : event.shiftKey;
if (Browser.isMac) {
return event.altKey && this._terminal.options.macOptionClickForcesSelection;
}
return event.shiftKey;
}
/**
@@ -322,6 +406,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* @param event The mousedown event.
*/
public onMouseDown(event: MouseEvent): void {
this._mouseDownTimeStamp = event.timeStamp;
// If we have selection, we want the context menu on right click even if the
// terminal is in mouse mode.
if (event.button === 2 && this.hasSelection) {
@@ -379,8 +464,10 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* Removes the listeners that are registered when mousedown is triggered.
*/
private _removeMouseDownListeners(): void {
this._terminal.element.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);
this._terminal.element.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);
if (this._terminal.element.ownerDocument) {
this._terminal.element.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);
this._terminal.element.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);
}
clearInterval(this._dragScrollIntervalTimer);
this._dragScrollIntervalTimer = null;
}
@@ -404,7 +491,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
private _onSingleClick(event: MouseEvent): void {
this._model.selectionStartLength = 0;
this._model.isSelectAllActive = false;
this._activeSelectionMode = SelectionMode.NORMAL;
this._activeSelectionMode = this.shouldColumnSelect(event) ? SelectionMode.COLUMN : SelectionMode.NORMAL;
// Initialize the new selection
this._model.selectionStart = this._getMouseBufferCoords(event);
@@ -426,8 +513,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
// If the mouse is over the second half of a wide character, adjust the
// selection to cover the whole character
const char = line[this._model.selectionStart[0]];
if (char[CHAR_DATA_WIDTH_INDEX] === 0) {
if (line.hasWidth(this._model.selectionStart[0]) === 0) {
this._model.selectionStart[0]++;
}
}
@@ -440,7 +526,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
const coords = this._getMouseBufferCoords(event);
if (coords) {
this._activeSelectionMode = SelectionMode.WORD;
this._selectWordAt(coords);
this._selectWordAt(coords, true);
}
}
@@ -457,6 +543,14 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
}
}
/**
* Returns whether the selection manager should operate in column select mode
* @param event the mouse or keyboard event
*/
public shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean {
return event.altKey && !(Browser.isMac && this._terminal.options.macOptionClickForcesSelection);
}
/**
* Handles the mousemove event when the mouse button is down, recording the
* end of the selection and refreshing the selection.
@@ -464,7 +558,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
*/
private _onMouseMove(event: MouseEvent): void {
// If the mousemove listener is active it means that a selection is
// currently being made, we should stop propogation to prevent mouse events
// currently being made, we should stop propagation to prevent mouse events
// to be sent to the pty.
event.stopImmediatePropagation();
@@ -494,19 +588,21 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
this._dragScrollAmount = this._getMouseEventScrollAmount(event);
// If the cursor was above or below the viewport, make sure it's at the
// start or end of the viewport respectively.
if (this._dragScrollAmount > 0) {
this._model.selectionEnd[0] = this._terminal.cols;
} else if (this._dragScrollAmount < 0) {
this._model.selectionEnd[0] = 0;
// start or end of the viewport respectively. This should only happen when
// NOT in column select mode.
if (this._activeSelectionMode !== SelectionMode.COLUMN) {
if (this._dragScrollAmount > 0) {
this._model.selectionEnd[0] = this._terminal.cols;
} else if (this._dragScrollAmount < 0) {
this._model.selectionEnd[0] = 0;
}
}
// If the character is a wide character include the cell to the right in the
// selection. Note that selections at the very end of the line will never
// have a character.
if (this._model.selectionEnd[1] < this._buffer.lines.length) {
const char = this._buffer.lines.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]];
if (char && char[CHAR_DATA_WIDTH_INDEX] === 0) {
if (this._buffer.lines.get(this._model.selectionEnd[1]).hasWidth(this._model.selectionEnd[0]) === 0) {
this._model.selectionEnd[0]++;
}
}
@@ -527,10 +623,19 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
if (this._dragScrollAmount) {
this._terminal.scrollLines(this._dragScrollAmount, false);
// Re-evaluate selection
// If the cursor was above or below the viewport, make sure it's at the
// start or end of the viewport respectively. This should only happen when
// NOT in column select mode.
if (this._dragScrollAmount > 0) {
this._model.selectionEnd = [this._terminal.cols - 1, this._terminal.buffer.ydisp + this._terminal.rows];
if (this._activeSelectionMode !== SelectionMode.COLUMN) {
this._model.selectionEnd[0] = this._terminal.cols;
}
this._model.selectionEnd[1] = Math.min(this._terminal.buffer.ydisp + this._terminal.rows, this._terminal.buffer.lines.length - 1);
} else {
this._model.selectionEnd = [0, this._terminal.buffer.ydisp];
if (this._activeSelectionMode !== SelectionMode.COLUMN) {
this._model.selectionEnd[0] = 0;
}
this._model.selectionEnd[1] = this._terminal.buffer.ydisp;
}
this.refresh();
}
@@ -541,10 +646,27 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* @param event The mouseup event.
*/
private _onMouseUp(event: MouseEvent): void {
const timeElapsed = event.timeStamp - this._mouseDownTimeStamp;
this._removeMouseDownListeners();
if (this.hasSelection)
this._terminal.emit('selection');
if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME) {
(new AltClickHandler(event, this._terminal)).move();
} else if (this.hasSelection) {
this._onSelectionChange.fire();
}
}
private _onBufferActivate(e: {activeBuffer: IBuffer, inactiveBuffer: IBuffer}): void {
this.clearSelection();
// Only adjust the selection on trim, shiftElements is rarely used (only in
// reverseIndex) and delete in a splice is only ever used when the same
// number of elements was just added. Given this is could actually be
// beneficial to leave the selection as is for these cases.
if (this._trimListener) {
this._trimListener.dispose();
}
this._trimListener = e.activeBuffer.lines.onTrim(amount => this._onTrim(amount));
}
/**
@@ -552,19 +674,19 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* latter takes into account wide characters.
* @param coords The coordinates to find the 2 index for.
*/
private _convertViewportColToCharacterIndex(bufferLine: any, coords: [number, number]): number {
private _convertViewportColToCharacterIndex(bufferLine: IBufferLine, coords: [number, number]): number {
let charIndex = coords[0];
for (let i = 0; coords[0] >= i; i++) {
const char = bufferLine[i];
if (char[CHAR_DATA_WIDTH_INDEX] === 0) {
const length = bufferLine.loadCell(i, this._workCell).getChars().length;
if (this._workCell.getWidth() === 0) {
// Wide characters aren't included in the line string so decrement the
// index so the index is back on the wide character.
charIndex--;
} else if (char[CHAR_DATA_CHAR_INDEX].length > 1 && coords[0] !== i) {
} else if (length > 1 && coords[0] !== i) {
// Emojis take up multiple characters, so adjust accordingly. For these
// we don't want ot include the character at the column as we're
// returning the start index in the string, not the end index.
charIndex += char[CHAR_DATA_CHAR_INDEX].length - 1;
charIndex += length - 1;
}
}
return charIndex;
@@ -582,7 +704,12 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* Gets positional information for the word at the coordinated specified.
* @param coords The coordinates to get the word at.
*/
private _getWordAt(coords: [number, number]): IWordPosition {
private _getWordAt(coords: [number, number], allowWhitespaceOnlySelection: boolean, followWrappedLinesAbove: boolean = true, followWrappedLinesBelow: boolean = true): IWordPosition {
// Ensure coords are within viewport (eg. not within scroll bar)
if (coords[0] >= this._terminal.cols) {
return null;
}
const bufferLine = this._buffer.lines.get(coords[1]);
if (!bufferLine) {
return null;
@@ -619,48 +746,51 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
// Consider the initial position, skip it and increment the wide char
// variable
if (bufferLine[startCol][CHAR_DATA_WIDTH_INDEX] === 0) {
if (bufferLine.getWidth(startCol) === 0) {
leftWideCharCount++;
startCol--;
}
if (bufferLine[endCol][CHAR_DATA_WIDTH_INDEX] === 2) {
if (bufferLine.getWidth(endCol) === 2) {
rightWideCharCount++;
endCol++;
}
// Adjust the end index for characters whose length are > 1 (emojis)
if (bufferLine[endCol][CHAR_DATA_CHAR_INDEX].length > 1) {
rightLongCharOffset += bufferLine[endCol][CHAR_DATA_CHAR_INDEX].length - 1;
endIndex += bufferLine[endCol][CHAR_DATA_CHAR_INDEX].length - 1;
const length = bufferLine.getString(endCol).length;
if (length > 1) {
rightLongCharOffset += length - 1;
endIndex += length - 1;
}
// Expand the string in both directions until a space is hit
while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine[startCol - 1])) {
const char = bufferLine[startCol - 1];
if (char[CHAR_DATA_WIDTH_INDEX] === 0) {
while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine.loadCell(startCol - 1, this._workCell))) {
bufferLine.loadCell(startCol - 1, this._workCell);
const length = this._workCell.getChars().length;
if (this._workCell.getWidth() === 0) {
// If the next character is a wide char, record it and skip the column
leftWideCharCount++;
startCol--;
} else if (char[CHAR_DATA_CHAR_INDEX].length > 1) {
} else if (length > 1) {
// If the next character's string is longer than 1 char (eg. emoji),
// adjust the index
leftLongCharOffset += char[CHAR_DATA_CHAR_INDEX].length - 1;
startIndex -= char[CHAR_DATA_CHAR_INDEX].length - 1;
leftLongCharOffset += length - 1;
startIndex -= length - 1;
}
startIndex--;
startCol--;
}
while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine[endCol + 1])) {
const char = bufferLine[endCol + 1];
if (char[CHAR_DATA_WIDTH_INDEX] === 2) {
while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine.loadCell(endCol + 1, this._workCell))) {
bufferLine.loadCell(endCol + 1, this._workCell);
const length = this._workCell.getChars().length;
if (this._workCell.getWidth() === 2) {
// If the next character is a wide char, record it and skip the column
rightWideCharCount++;
endCol++;
} else if (char[CHAR_DATA_CHAR_INDEX].length > 1) {
} else if (length > 1) {
// If the next character's string is longer than 1 char (eg. emoji),
// adjust the index
rightLongCharOffset += char[CHAR_DATA_CHAR_INDEX].length - 1;
endIndex += char[CHAR_DATA_CHAR_INDEX].length - 1;
rightLongCharOffset += length - 1;
endIndex += length - 1;
}
endIndex++;
endCol++;
@@ -672,7 +802,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
// Calculate the start _column_, converting the the string indexes back to
// column coordinates.
const start =
let start =
startIndex // The index of the selection's start char in the line string
+ charOffset // The difference between the initial char's column and index
- leftWideCharCount // The number of wide chars left of the initial char
@@ -680,7 +810,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
// Calculate the length in _columns_, converting the the string indexes back
// to column coordinates.
const length = Math.min(this._terminal.cols, // Disallow lengths larger than the terminal cols
let length = Math.min(this._terminal.cols, // Disallow lengths larger than the terminal cols
endIndex // The index of the selection's end char in the line string
- startIndex // The index of the selection's start char in the line string
+ leftWideCharCount // The number of wide chars left of the initial char
@@ -688,16 +818,54 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
- leftLongCharOffset // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)
- rightLongCharOffset); // The number of additional chars right of the initial char (inclusive) added by columns with strings longer than 1 (emojis)
if (!allowWhitespaceOnlySelection && line.slice(startIndex, endIndex).trim() === '') {
return null;
}
// Recurse upwards if the line is wrapped and the word wraps to the above line
if (followWrappedLinesAbove) {
if (start === 0 && bufferLine.getCodePoint(0) !== 32 /*' '*/) {
const previousBufferLine = this._buffer.lines.get(coords[1] - 1);
if (previousBufferLine && bufferLine.isWrapped && previousBufferLine.getCodePoint(this._terminal.cols - 1) !== 32 /*' '*/) {
const previousLineWordPosition = this._getWordAt([this._terminal.cols - 1, coords[1] - 1], false, true, false);
if (previousLineWordPosition) {
const offset = this._terminal.cols - previousLineWordPosition.start;
start -= offset;
length += offset;
}
}
}
}
// Recurse downwards if the line is wrapped and the word wraps to the next line
if (followWrappedLinesBelow) {
if (start + length === this._terminal.cols && bufferLine.getCodePoint(this._terminal.cols - 1) !== 32 /*' '*/) {
const nextBufferLine = this._buffer.lines.get(coords[1] + 1);
if (nextBufferLine && nextBufferLine.isWrapped && nextBufferLine.getCodePoint(0) !== 32 /*' '*/) {
const nextLineWordPosition = this._getWordAt([0, coords[1] + 1], false, false, true);
if (nextLineWordPosition) {
length += nextLineWordPosition.length;
}
}
}
}
return { start, length };
}
/**
* Selects the word at the coordinates specified.
* @param coords The coordinates to get the word at.
* @param allowWhitespaceOnlySelection If whitespace should be selected
*/
protected _selectWordAt(coords: [number, number]): void {
const wordPosition = this._getWordAt(coords);
protected _selectWordAt(coords: [number, number], allowWhitespaceOnlySelection: boolean): void {
const wordPosition = this._getWordAt(coords, allowWhitespaceOnlySelection);
if (wordPosition) {
// Adjust negative start value
while (wordPosition.start < 0) {
wordPosition.start += this._terminal.cols;
coords[1]--;
}
this._model.selectionStart = [wordPosition.start, coords[1]];
this._model.selectionStartLength = wordPosition.length;
}
@@ -708,9 +876,26 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* @param coords The coordinates to get the word at.
*/
private _selectToWordAt(coords: [number, number]): void {
const wordPosition = this._getWordAt(coords);
const wordPosition = this._getWordAt(coords, true);
if (wordPosition) {
this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : (wordPosition.start + wordPosition.length), coords[1]];
let endRow = coords[1];
// Adjust negative start value
while (wordPosition.start < 0) {
wordPosition.start += this._terminal.cols;
endRow--;
}
// Adjust wrapped length value, this only needs to happen when values are reversed as in that
// case we're interested in the start of the word, not the end
if (!this._model.areSelectionValuesReversed()) {
while (wordPosition.start + wordPosition.length > this._terminal.cols) {
wordPosition.length -= this._terminal.cols;
endRow++;
}
}
this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : wordPosition.start + wordPosition.length, endRow];
}
}
@@ -719,13 +904,13 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* word logic.
* @param char The character to check.
*/
private _isCharWordSeparator(charData: CharData): boolean {
private _isCharWordSeparator(cell: CellData): boolean {
// Zero width characters are never separators as they are always to the
// right of wide characters
if (charData[CHAR_DATA_WIDTH_INDEX] === 0) {
if (cell.getWidth() === 0) {
return false;
}
return WORD_SEPARATORS.indexOf(charData[CHAR_DATA_CHAR_INDEX]) >= 0;
return WORD_SEPARATORS.indexOf(cell.getChars()) >= 0;
}
/**
@@ -733,7 +918,9 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
* @param line The line index.
*/
protected _selectLineAt(line: number): void {
this._model.selectionStart = [0, line];
this._model.selectionStartLength = this._terminal.cols;
const wrappedRange = this._buffer.getWrappedRangeForLine(line);
this._model.selectionStart = [0, wrappedRange.first];
this._model.selectionEnd = [this._terminal.cols, wrappedRange.last];
this._model.selectionStartLength = 0;
}
}
+10 -8
View File
@@ -4,10 +4,10 @@
*/
import { assert } from 'chai';
import { ITerminal } from './Interfaces';
import { ITerminal } from './Types';
import { SelectionModel } from './SelectionModel';
import {BufferSet} from './BufferSet';
import { MockTerminal } from './utils/TestUtils.test';
import { BufferSet } from './BufferSet';
import { MockTerminal } from './TestUtils.test';
class TestSelectionModel extends SelectionModel {
constructor(
@@ -18,16 +18,13 @@ class TestSelectionModel extends SelectionModel {
}
describe('SelectionManager', () => {
let window: Window;
let document: Document;
let terminal: ITerminal;
let model: TestSelectionModel;
beforeEach(() => {
terminal = new MockTerminal();
terminal.cols = 80;
terminal.rows = 2;
(terminal as any).cols = 80;
(terminal as any).rows = 2;
terminal.options.scrollback = 10;
terminal.buffers = new BufferSet(terminal);
terminal.buffer = terminal.buffers.active;
@@ -131,6 +128,11 @@ describe('SelectionManager', () => {
model.selectionEnd = [3, 2];
assert.deepEqual(model.finalSelectionEnd, [4, 2]);
});
it('should return the end on a different row when start + length overflows onto a following row', () => {
model.selectionStart = [78, 2];
model.selectionStartLength = 4;
assert.deepEqual(model.finalSelectionEnd, [2, 3]);
});
it('should return selection end if selection end is after selection start + length', () => {
model.selectionStart = [2, 2];
model.selectionStartLength = 2;
+7 -3
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { ITerminal } from './Interfaces';
import { ITerminal } from './Types';
/**
* Represents a selection within the buffer. This model only cares about column
@@ -76,9 +76,13 @@ export class SelectionModel {
return null;
}
// Use the selection start if the end doesn't exist or they're reversed
// Use the selection start + length if the end doesn't exist or they're reversed
if (!this.selectionEnd || this.areSelectionValuesReversed()) {
return [this.selectionStart[0] + this.selectionStartLength, this.selectionStart[1]];
const startPlusLength = this.selectionStart[0] + this.selectionStartLength;
if (startPlusLength > this._terminal.cols) {
return [startPlusLength % this._terminal.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._terminal.cols)];
}
return [startPlusLength, this.selectionStart[1]];
}
// Ensure the the word/line is selected after a double/triple click
+66
View File
@@ -0,0 +1,66 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { ITerminal, ISoundManager } from './Types';
// Source: https://freesound.org/people/altemark/sounds/45759/
// This sound is released under the Creative Commons Attribution 3.0 Unported
// (CC BY 3.0) license. It was created by 'altemark'. No modifications have been
// made, apart from the conversion to base64.
export const DEFAULT_BELL_SOUND = 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';
export class SoundManager implements ISoundManager {
private static _audioContext: AudioContext;
static get audioContext(): AudioContext | null {
if (!SoundManager._audioContext) {
const audioContextCtor: typeof AudioContext = (<any>window).AudioContext || (<any>window).webkitAudioContext;
if (!audioContextCtor) {
console.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version');
return null;
}
SoundManager._audioContext = new audioContextCtor();
}
return SoundManager._audioContext;
}
constructor(
private _terminal: ITerminal
) {
}
public playBellSound(): void {
const ctx = SoundManager.audioContext;
if (!ctx) {
return;
}
const bellAudioSource = ctx.createBufferSource();
ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), (buffer) => {
bellAudioSource.buffer = buffer;
bellAudioSource.connect(ctx.destination);
bellAudioSource.start(0);
});
}
private _base64ToArrayBuffer(base64: string): ArrayBuffer {
const binaryString = window.atob(base64);
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
return bytes.buffer;
}
private _removeMimeType(dataURI: string): string {
// Split the input to get the mime-type and the data itself
const splitUri = dataURI.split(',');
// Return only the data
return splitUri[1];
}
}
+8
View File
@@ -0,0 +1,8 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
export let blankLine = 'Blank line';
export let promptLabel = 'Terminal input';
export let tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';
+43 -37
View File
@@ -13,19 +13,24 @@ import * as path from 'path';
import * as pty from 'node-pty';
import { assert } from 'chai';
import { Terminal } from './Terminal';
import { CHAR_DATA_CHAR_INDEX } from './Buffer';
import { IViewport } from './Types';
import { CellData, WHITESPACE_CELL_CHAR } from './core/buffer/BufferLine';
let primitive_pty: any;
class TestTerminal extends Terminal {
innerWrite(): void { this._innerWrite(); }
}
let primitivePty: any;
// fake sychronous pty write - read
// we just pipe the data from slave to master as a child program would do
// pty.js opens pipe fds with O_NONBLOCK
// just wait 10ms instead of setting fds to blocking mode
function ptyWriteRead(data: string, cb: (result: string) => void): void {
fs.writeSync(primitive_pty.slave, data);
fs.writeSync(primitivePty.slave, data);
setTimeout(() => {
let b = new Buffer(64000);
let bytes = fs.readSync(primitive_pty.master, b, 0, 64000, null);
const b = new Buffer(64000);
const bytes = fs.readSync(primitivePty.master, b, 0, 64000, null);
cb(b.toString('utf8', 0, bytes));
});
}
@@ -37,7 +42,7 @@ function ptyReset(cb: (result: string) => void): void {
/* debug helpers */
// generate colorful noisy output to compare xterm and emulator cell states
function formatError(in_: string, out_: string, expected: string): string {
function formatError(input: string, output: string, expected: string): string {
function addLineNumber(start: number, color: string): (s: string) => string {
let counter = start || 0;
return function(s: string): string {
@@ -45,11 +50,11 @@ function formatError(in_: string, out_: string, expected: string): string {
return '\x1b[33m' + (' ' + counter).slice(-2) + color + s;
};
}
let line80 = '12345678901234567890123456789012345678901234567890123456789012345678901234567890';
const line80 = '12345678901234567890123456789012345678901234567890123456789012345678901234567890';
let s = '';
s += '\n\x1b[34m' + JSON.stringify(in_);
s += '\n\x1b[34m' + JSON.stringify(input);
s += '\n\x1b[33m ' + line80 + '\n';
s += out_.split('\n').map(addLineNumber(0, '\x1b[31m')).join('\n');
s += output.split('\n').map(addLineNumber(0, '\x1b[31m')).join('\n');
s += '\n\x1b[33m ' + line80 + '\n';
s += expected.split('\n').map(addLineNumber(0, '\x1b[32m')).join('\n');
return s;
@@ -58,15 +63,15 @@ function formatError(in_: string, out_: string, expected: string): string {
// simple debug output of terminal cells
function terminalToString(term: Terminal): string {
let result = '';
let line_s = '';
let lineText = '';
for (let line = term.buffer.ybase; line < term.buffer.ybase + term.rows; line++) {
line_s = '';
lineText = '';
for (let cell = 0; cell < term.cols; ++cell) {
line_s += term.buffer.lines.get(line)[cell][CHAR_DATA_CHAR_INDEX];
lineText += term.buffer.lines.get(line).loadCell(cell, new CellData()).getChars() || WHITESPACE_CELL_CHAR;
}
// rtrim empty cells as xterm does
line_s = line_s.replace(/\s+$/, '');
result += line_s;
lineText = lineText.replace(/\s+$/, '');
result += lineText;
result += '\n';
}
return result;
@@ -74,41 +79,43 @@ function terminalToString(term: Terminal): string {
// Skip tests on Windows since pty.open isn't supported
if (os.platform() !== 'win32') {
let CONSOLE_LOG = console.log;
const consoleLog = console.log;
// expect files need terminal at 80x25!
let COLS = 80;
let ROWS = 25;
const cols = 80;
const rows = 25;
/** some helpers for pty interaction */
// we need a pty in between to get the termios decorations
// for the basic test cases a raw pty device is enough
primitive_pty = pty.native.open(COLS, ROWS);
primitivePty = (<any>pty).native.open(cols, rows);
/** tests */
describe('xterm output comparison', () => {
let xterm;
describe('xterm output comparison', function(): void {
this.timeout(10000);
let xterm: TestTerminal;
beforeEach(() => {
xterm = new Terminal({ cols: COLS, rows: ROWS });
xterm = new TestTerminal({ cols: cols, rows: rows });
xterm.refresh = () => {};
xterm.viewport = {
xterm.viewport = <IViewport>{
syncScrollArea: () => {}
};
});
// omit stack trace for escape sequence files
Error.stackTraceLimit = 0;
let files = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '..')});
const files = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '..')});
// for (let i = 0; i < files.length; ++i) console.debug(i, files[i]);
// only successful tests for now
let skip = [
const skip = [
10, 16, 17, 19, 32, 33, 34, 35, 36, 39,
40, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61,
63, 68
];
// These are failing on macOS only
if (os.platform() === 'darwin') {
// These are failing on macOS only
skip.push(3, 7, 11, 67);
}
for (let i = 0; i < files.length; i++) {
@@ -116,26 +123,27 @@ if (os.platform() !== 'win32') {
continue;
}
((filename: string) => {
const inFile = fs.readFileSync(filename, 'utf8');
it(filename.split('/').slice(-1)[0], done => {
ptyReset(() => {
let in_file = fs.readFileSync(filename, 'utf8');
ptyWriteRead(in_file, from_pty => {
ptyWriteRead(inFile, fromPty => {
// uncomment this to get log from terminal
// console.log = function(){};
// Perform a synchronous .write(data)
xterm.writeBuffer.push(from_pty);
xterm.writeBuffer.push(fromPty);
xterm.innerWrite();
let from_emulator = terminalToString(xterm);
console.log = CONSOLE_LOG;
let expected = fs.readFileSync(filename.split('.')[0] + '.text', 'utf8');
const fromEmulator = terminalToString(xterm);
console.log = consoleLog;
const expected = fs.readFileSync(filename.split('.')[0] + '.text', 'utf8');
// Some of the tests have whitespace on the right of lines, we trim all the linex
// from xterm.js so ignore this for now at least.
let expectedRightTrimmed = expected.split('\n').map(l => l.replace(/\s+$/, '')).join('\n');
if (from_emulator !== expectedRightTrimmed) {
const expectedRightTrimmed = expected.split('\n').map(l => l.replace(/\s+$/, '')).join('\n');
if (fromEmulator !== expectedRightTrimmed) {
// uncomment to get noisy output
throw new Error(formatError(in_file, from_emulator, expected));
throw new Error(formatError(inFile, fromEmulator, expected));
// throw new Error('mismatch');
}
done();
@@ -155,9 +163,7 @@ describe('typings', () => {
tsc += '.cmd';
}
const fixtureDir = path.join(__dirname, '..', 'fixtures', 'typings-test');
let result = cp.spawnSync(tsc, { cwd: fixtureDir });
const result = cp.spawnSync(tsc, { cwd: fixtureDir });
assert.equal(result.status, 0, `build did not succeed:\nstdout: ${result.stdout.toString()}\nstderr: ${result.stderr.toString()}\n`);
// Clean up
fs.unlinkSync(path.join(fixtureDir, 'typings-test.js'));
});
});
+560 -403
View File
File diff suppressed because it is too large Load Diff
+848 -1025
View File
File diff suppressed because it is too large Load Diff
+443
View File
@@ -0,0 +1,443 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { IRenderer, IRenderDimensions } from './renderer/Types';
import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminal, IBuffer, IBufferSet, IBrowser, ICharMeasure, ISelectionManager, ITerminalOptions, ILinkifier, IMouseHelper, ILinkMatcherOptions, CharacterJoinerHandler, IBufferStringIterator } from './Types';
import { IBufferLine, ICellData, IAttributeData } from './core/Types';
import { ICircularList, XtermListener } from './common/Types';
import { Buffer } from './Buffer';
import * as Browser from './common/Platform';
import { IDisposable, IMarker, IEvent, ISelectionPosition } from 'xterm';
import { Terminal } from './Terminal';
import { AttributeData } from './core/buffer/BufferLine';
import { IColorManager, IColorSet } from './ui/Types';
export class TestTerminal extends Terminal {
writeSync(data: string): void {
this.writeBuffer.push(data);
this._innerWrite();
}
}
export class MockTerminal implements ITerminal {
onCursorMove: IEvent<void>;
onLineFeed: IEvent<void>;
onSelectionChange: IEvent<void>;
onData: IEvent<string>;
onTitleChange: IEvent<string>;
onScroll: IEvent<number>;
onKey: IEvent<{ key: string; domEvent: KeyboardEvent; }>;
onRender: IEvent<{ start: number; end: number; }>;
onResize: IEvent<{ cols: number; rows: number; }>;
markers: IMarker[];
addMarker(cursorYOffset: number): IMarker {
throw new Error('Method not implemented.');
}
selectLines(start: number, end: number): void {
throw new Error('Method not implemented.');
}
scrollToLine(line: number): void {
throw new Error('Method not implemented.');
}
static string: any;
getOption(key: any): any {
throw new Error('Method not implemented.');
}
setOption(key: any, value: any): void {
throw new Error('Method not implemented.');
}
blur(): void {
throw new Error('Method not implemented.');
}
focus(): void {
throw new Error('Method not implemented.');
}
resize(columns: number, rows: number): void {
throw new Error('Method not implemented.');
}
writeln(data: string): void {
throw new Error('Method not implemented.');
}
open(parent: HTMLElement): void {
throw new Error('Method not implemented.');
}
attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void {
throw new Error('Method not implemented.');
}
addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable {
throw new Error('Method not implemented.');
}
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable {
throw new Error('Method not implemented.');
}
registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => boolean | void, options?: ILinkMatcherOptions): number {
throw new Error('Method not implemented.');
}
deregisterLinkMatcher(matcherId: number): void {
throw new Error('Method not implemented.');
}
hasSelection(): boolean {
throw new Error('Method not implemented.');
}
getSelection(): string {
throw new Error('Method not implemented.');
}
getSelectionPosition(): ISelectionPosition | undefined {
throw new Error('Method not implemented.');
}
clearSelection(): void {
throw new Error('Method not implemented.');
}
select(column: number, row: number, length: number): void {
throw new Error('Method not implemented.');
}
selectAll(): void {
throw new Error('Method not implemented.');
}
dispose(): void {
throw new Error('Method not implemented.');
}
destroy(): void {
throw new Error('Method not implemented.');
}
scrollPages(pageCount: number): void {
throw new Error('Method not implemented.');
}
scrollToTop(): void {
throw new Error('Method not implemented.');
}
scrollToBottom(): void {
throw new Error('Method not implemented.');
}
clear(): void {
throw new Error('Method not implemented.');
}
write(data: string): void {
throw new Error('Method not implemented.');
}
writeUtf8(data: Uint8Array): void {
throw new Error('Method not implemented.');
}
bracketedPasteMode: boolean;
mouseHelper: IMouseHelper;
renderer: IRenderer;
linkifier: ILinkifier;
isFocused: boolean;
options: ITerminalOptions = {};
element: HTMLElement;
screenElement: HTMLElement;
rowContainer: HTMLElement;
selectionContainer: HTMLElement;
selectionManager: ISelectionManager;
charMeasure: ICharMeasure;
textarea: HTMLTextAreaElement;
rows: number;
cols: number;
browser: IBrowser = <any>Browser;
writeBuffer: string[];
children: HTMLElement[];
cursorHidden: boolean;
cursorState: number;
scrollback: number;
buffers: IBufferSet;
buffer: IBuffer;
viewport: IViewport;
applicationCursor: boolean;
handler(data: string): void {
throw new Error('Method not implemented.');
}
on(event: string, callback: (...args: any[]) => void): void {
throw new Error('Method not implemented.');
}
off(type: string, listener: XtermListener): void {
throw new Error('Method not implemented.');
}
addDisposableListener(type: string, handler: XtermListener): IDisposable {
throw new Error('Method not implemented.');
}
scrollLines(disp: number, suppressScrollEvent: boolean): void {
throw new Error('Method not implemented.');
}
scrollToRow(absoluteRow: number): number {
throw new Error('Method not implemented.');
}
cancel(ev: Event, force?: boolean): void {
throw new Error('Method not implemented.');
}
log(text: string): void {
throw new Error('Method not implemented.');
}
emit(event: string, data: any): void {
throw new Error('Method not implemented.');
}
reset(): void {
throw new Error('Method not implemented.');
}
showCursor(): void {
throw new Error('Method not implemented.');
}
refresh(start: number, end: number): void {
throw new Error('Method not implemented.');
}
registerCharacterJoiner(handler: CharacterJoinerHandler): number { return 0; }
deregisterCharacterJoiner(joinerId: number): void { }
}
export class MockCharMeasure implements ICharMeasure {
onCharSizeChanged: IEvent<void>;
width: number;
height: number;
measure(options: ITerminalOptions): void {
throw new Error('Method not implemented.');
}
}
export class MockInputHandlingTerminal implements IInputHandlingTerminal {
element: HTMLElement;
options: ITerminalOptions = {};
cols: number;
rows: number;
charset: { [key: string]: string; };
gcharset: number;
glevel: number;
charsets: { [key: string]: string; }[];
applicationKeypad: boolean;
applicationCursor: boolean;
originMode: boolean;
insertMode: boolean;
wraparoundMode: boolean;
bracketedPasteMode: boolean;
curAttrData = new AttributeData();
savedCols: number;
x10Mouse: boolean;
vt200Mouse: boolean;
normalMouse: boolean;
mouseEvents: boolean;
sendFocus: boolean;
utfMouse: boolean;
sgrMouse: boolean;
urxvtMouse: boolean;
cursorHidden: boolean;
buffers: IBufferSet;
buffer: IBuffer = new MockBuffer();
viewport: IViewport;
selectionManager: ISelectionManager;
focus(): void {
throw new Error('Method not implemented.');
}
convertEol: boolean;
bell(): void {
throw new Error('Method not implemented.');
}
updateRange(y: number): void {
throw new Error('Method not implemented.');
}
scroll(isWrapped?: boolean): void {
throw new Error('Method not implemented.');
}
nextStop(x?: number): number {
throw new Error('Method not implemented.');
}
setgLevel(g: number): void {
throw new Error('Method not implemented.');
}
eraseAttrData(): IAttributeData {
throw new Error('Method not implemented.');
}
eraseRight(x: number, y: number): void {
throw new Error('Method not implemented.');
}
eraseLine(y: number): void {
throw new Error('Method not implemented.');
}
eraseLeft(x: number, y: number): void {
throw new Error('Method not implemented.');
}
prevStop(x?: number): number {
throw new Error('Method not implemented.');
}
is(term: string): boolean {
throw new Error('Method not implemented.');
}
setgCharset(g: number, charset: { [key: string]: string; }): void {
throw new Error('Method not implemented.');
}
resize(x: number, y: number): void {
throw new Error('Method not implemented.');
}
log(text: string, data?: any): void {
throw new Error('Method not implemented.');
}
reset(): void {
throw new Error('Method not implemented.');
}
showCursor(): void {
throw new Error('Method not implemented.');
}
refresh(start: number, end: number): void {
throw new Error('Method not implemented.');
}
matchColor(r1: number, g1: number, b1: number): number {
throw new Error('Method not implemented.');
}
error(text: string, data?: any): void {
throw new Error('Method not implemented.');
}
setOption(key: string, value: any): void {
(<any>this.options)[key] = value;
}
on(type: string, listener: XtermListener): void {
throw new Error('Method not implemented.');
}
off(type: string, listener: XtermListener): void {
throw new Error('Method not implemented.');
}
emit(type: string, data?: any): void {
throw new Error('Method not implemented.');
}
addDisposableListener(type: string, handler: XtermListener): IDisposable {
throw new Error('Method not implemented.');
}
tabSet(): void {
throw new Error('Method not implemented.');
}
handler(data: string): void {
throw new Error('Method not implemented.');
}
handleTitle(title: string): void {
throw new Error('Method not implemented.');
}
index(): void {
throw new Error('Method not implemented.');
}
reverseIndex(): void {
throw new Error('Method not implemented.');
}
}
export class MockBuffer implements IBuffer {
isCursorInViewport: boolean;
lines: ICircularList<IBufferLine>;
ydisp: number;
ybase: number;
hasScrollback: boolean;
y: number;
x: number;
tabs: any;
scrollBottom: number;
scrollTop: number;
savedY: number;
savedX: number;
savedCurAttrData = new AttributeData();
translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol?: number, endCol?: number): string {
return Buffer.prototype.translateBufferLineToString.apply(this, arguments);
}
getWrappedRangeForLine(y: number): { first: number; last: number; } {
return Buffer.prototype.getWrappedRangeForLine.apply(this, arguments);
}
nextStop(x?: number): number {
throw new Error('Method not implemented.');
}
prevStop(x?: number): number {
throw new Error('Method not implemented.');
}
setLines(lines: ICircularList<IBufferLine>): void {
this.lines = lines;
}
getBlankLine(attr: IAttributeData, isWrapped?: boolean): IBufferLine {
return Buffer.prototype.getBlankLine.apply(this, arguments);
}
stringIndexToBufferIndex(lineIndex: number, stringIndex: number): number[] {
return Buffer.prototype.stringIndexToBufferIndex.apply(this, arguments);
}
iterator(trimRight: boolean, startIndex?: number, endIndex?: number): IBufferStringIterator {
return Buffer.prototype.iterator.apply(this, arguments);
}
getNullCell(attr?: IAttributeData): ICellData {
throw new Error('Method not implemented.');
}
getWhitespaceCell(attr?: IAttributeData): ICellData {
throw new Error('Method not implemented.');
}
}
export class MockRenderer implements IRenderer {
onCanvasResize: IEvent<{ width: number; height: number; }>;
onRender: IEvent<{ start: number; end: number; }>;
dispose(): void {
throw new Error('Method not implemented.');
}
colorManager: IColorManager;
on(type: string, listener: XtermListener): void {
throw new Error('Method not implemented.');
}
off(type: string, listener: XtermListener): void {
throw new Error('Method not implemented.');
}
emit(type: string, data?: any): void {
throw new Error('Method not implemented.');
}
addDisposableListener(type: string, handler: XtermListener): IDisposable {
throw new Error('Method not implemented.');
}
dimensions: IRenderDimensions;
setColors(colors: IColorSet): void {
throw new Error('Method not implemented.');
}
onResize(cols: number, rows: number): void {}
onCharSizeChanged(): void {}
onBlur(): void {}
onFocus(): void {}
onSelectionChanged(start: [number, number], end: [number, number]): void {}
onCursorMove(): void {}
onOptionsChanged(): void {}
onDevicePixelRatioChange(): void {}
clear(): void {}
renderRows(start: number, end: number): void {}
registerCharacterJoiner(handler: CharacterJoinerHandler): number { return 0; }
deregisterCharacterJoiner(): boolean { return true; }
}
export class MockViewport implements IViewport {
dispose(): void {
throw new Error('Method not implemented.');
}
scrollBarWidth: number = 0;
onThemeChange(colors: IColorSet): void {
throw new Error('Method not implemented.');
}
onWheel(ev: WheelEvent): void {
throw new Error('Method not implemented.');
}
onTouchStart(ev: TouchEvent): void {
throw new Error('Method not implemented.');
}
onTouchMove(ev: TouchEvent): void {
throw new Error('Method not implemented.');
}
syncScrollArea(): void { }
getLinesScrolled(ev: WheelEvent): number {
throw new Error('Method not implemented.');
}
}
export class MockCompositionHelper implements ICompositionHelper {
compositionstart(): void {
throw new Error('Method not implemented.');
}
compositionupdate(ev: CompositionEvent): void {
throw new Error('Method not implemented.');
}
compositionend(): void {
throw new Error('Method not implemented.');
}
updateCompositionElements(dontRecurse?: boolean): void {
throw new Error('Method not implemented.');
}
keydown(ev: KeyboardEvent): boolean {
return true;
}
}
+583 -24
View File
@@ -3,33 +3,592 @@
* @license MIT
*/
export type LinkMatcher = {
id: number,
regex: RegExp,
handler: LinkMatcherHandler,
hoverTooltipCallback?: LinkMatcherHandler,
hoverLeaveCallback?: () => void,
matchIndex?: number,
validationCallback?: LinkMatcherValidationCallback,
priority?: number
};
export type LinkMatcherHandler = (event: MouseEvent, uri: string) => boolean | void;
export type LinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void;
import { ITerminalOptions as IPublicTerminalOptions, IEventEmitter, IDisposable, IMarker, ISelectionPosition } from 'xterm';
import { ICharset, IAttributeData, ICellData, IBufferLine, CharData } from './core/Types';
import { ICircularList } from './common/Types';
import { IEvent } from './common/EventEmitter2';
import { IColorSet } from './ui/Types';
export type CustomKeyEventHandler = (event: KeyboardEvent) => boolean;
export type Charset = {[key: string]: string};
export type CharData = [number, string, number, number];
export type LineData = CharData[];
export type LinkHoverEvent = {
x: number,
y: number,
length: number
};
export type LinkMatcherHandler = (event: MouseEvent, uri: string) => void;
export type LinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void;
export enum LinkHoverEventTypes {
HOVER = 'linkhover',
TOOLTIP = 'linktooltip',
LEAVE = 'linkleave'
};
export type CharacterJoinerHandler = (text: string) => [number, number][];
// BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
export type BufferIndex = [number, number];
/**
* This interface encapsulates everything needed from the Terminal by the
* InputHandler. This cleanly separates the large amount of methods needed by
* InputHandler cleanly from the ITerminal interface.
*/
export interface IInputHandlingTerminal extends IEventEmitter {
element: HTMLElement;
options: ITerminalOptions;
cols: number;
rows: number;
charset: ICharset;
gcharset: number;
glevel: number;
charsets: ICharset[];
applicationKeypad: boolean;
applicationCursor: boolean;
originMode: boolean;
insertMode: boolean;
wraparoundMode: boolean;
bracketedPasteMode: boolean;
curAttrData: IAttributeData;
savedCols: number;
x10Mouse: boolean;
vt200Mouse: boolean;
normalMouse: boolean;
mouseEvents: boolean;
sendFocus: boolean;
utfMouse: boolean;
sgrMouse: boolean;
urxvtMouse: boolean;
cursorHidden: boolean;
buffers: IBufferSet;
buffer: IBuffer;
viewport: IViewport;
selectionManager: ISelectionManager;
bell(): void;
focus(): void;
updateRange(y: number): void;
scroll(isWrapped?: boolean): void;
setgLevel(g: number): void;
eraseAttrData(): IAttributeData;
is(term: string): boolean;
setgCharset(g: number, charset: ICharset): void;
resize(x: number, y: number): void;
log(text: string, data?: any): void;
reset(): void;
showCursor(): void;
refresh(start: number, end: number): void;
error(text: string, data?: any): void;
setOption(key: string, value: any): void;
tabSet(): void;
handler(data: string): void;
handleTitle(title: string): void;
index(): void;
reverseIndex(): void;
}
export interface IViewport extends IDisposable {
scrollBarWidth: number;
syncScrollArea(): void;
getLinesScrolled(ev: WheelEvent): number;
onWheel(ev: WheelEvent): void;
onTouchStart(ev: TouchEvent): void;
onTouchMove(ev: TouchEvent): void;
onThemeChange(colors: IColorSet): void;
}
export interface ICompositionHelper {
compositionstart(): void;
compositionupdate(ev: CompositionEvent): void;
compositionend(): void;
updateCompositionElements(dontRecurse?: boolean): void;
keydown(ev: KeyboardEvent): boolean;
}
/**
* Calls the parser and handles actions generated by the parser.
*/
export interface IInputHandler {
parse(data: string): void;
parseUtf8(data: Uint8Array): void;
print(data: Uint32Array, start: number, end: number): void;
/** C0 BEL */ bell(): void;
/** C0 LF */ lineFeed(): void;
/** C0 CR */ carriageReturn(): void;
/** C0 BS */ backspace(): void;
/** C0 HT */ tab(): void;
/** C0 SO */ shiftOut(): void;
/** C0 SI */ shiftIn(): void;
/** CSI @ */ insertChars(params?: number[]): void;
/** CSI A */ cursorUp(params?: number[]): void;
/** CSI B */ cursorDown(params?: number[]): void;
/** CSI C */ cursorForward(params?: number[]): void;
/** CSI D */ cursorBackward(params?: number[]): void;
/** CSI E */ cursorNextLine(params?: number[]): void;
/** CSI F */ cursorPrecedingLine(params?: number[]): void;
/** CSI G */ cursorCharAbsolute(params?: number[]): void;
/** CSI H */ cursorPosition(params?: number[]): void;
/** CSI I */ cursorForwardTab(params?: number[]): void;
/** CSI J */ eraseInDisplay(params?: number[]): void;
/** CSI K */ eraseInLine(params?: number[]): void;
/** CSI L */ insertLines(params?: number[]): void;
/** CSI M */ deleteLines(params?: number[]): void;
/** CSI P */ deleteChars(params?: number[]): void;
/** CSI S */ scrollUp(params?: number[]): void;
/** CSI T */ scrollDown(params?: number[], collect?: string): void;
/** CSI X */ eraseChars(params?: number[]): void;
/** CSI Z */ cursorBackwardTab(params?: number[]): void;
/** CSI ` */ charPosAbsolute(params?: number[]): void;
/** CSI a */ hPositionRelative(params?: number[]): void;
/** CSI b */ repeatPrecedingCharacter(params?: number[]): void;
/** CSI c */ sendDeviceAttributes(params?: number[], collect?: string): void;
/** CSI d */ linePosAbsolute(params?: number[]): void;
/** CSI e */ vPositionRelative(params?: number[]): void;
/** CSI f */ hVPosition(params?: number[]): void;
/** CSI g */ tabClear(params?: number[]): void;
/** CSI h */ setMode(params?: number[], collect?: string): void;
/** CSI l */ resetMode(params?: number[], collect?: string): void;
/** CSI m */ charAttributes(params?: number[]): void;
/** CSI n */ deviceStatus(params?: number[], collect?: string): void;
/** CSI p */ softReset(params?: number[], collect?: string): void;
/** CSI q */ setCursorStyle(params?: number[], collect?: string): void;
/** CSI r */ setScrollRegion(params?: number[], collect?: string): void;
/** CSI s */ saveCursor(params?: number[]): void;
/** CSI u */ restoreCursor(params?: number[]): void;
/** OSC 0
OSC 2 */ setTitle(data: string): void;
/** ESC E */ nextLine(): void;
/** ESC = */ keypadApplicationMode(): void;
/** ESC > */ keypadNumericMode(): void;
/** ESC % G
ESC % @ */ selectDefaultCharset(): void;
/** ESC ( C
ESC ) C
ESC * C
ESC + C
ESC - C
ESC . C
ESC / C */ selectCharset(collectAndFlag: string): void;
/** ESC D */ index(): void;
/** ESC H */ tabSet(): void;
/** ESC M */ reverseIndex(): void;
/** ESC c */ reset(): void;
/** ESC n
ESC o
ESC |
ESC }
ESC ~ */ setgLevel(level: number): void;
}
export interface ILinkMatcher {
id: number;
regex: RegExp;
handler: LinkMatcherHandler;
hoverTooltipCallback?: LinkMatcherHandler;
hoverLeaveCallback?: () => void;
matchIndex?: number;
validationCallback?: LinkMatcherValidationCallback;
priority?: number;
willLinkActivate?: (event: MouseEvent, uri: string) => boolean;
}
export interface ILinkifierEvent {
x1: number;
y1: number;
x2: number;
y2: number;
cols: number;
fg: number;
}
export interface ITerminal extends IPublicTerminal, IElementAccessor, IBufferAccessor, ILinkifierAccessor {
screenElement: HTMLElement;
selectionManager: ISelectionManager;
charMeasure: ICharMeasure;
browser: IBrowser;
writeBuffer: string[];
cursorHidden: boolean;
cursorState: number;
options: ITerminalOptions;
buffer: IBuffer;
buffers: IBufferSet;
isFocused: boolean;
mouseHelper: IMouseHelper;
viewport: IViewport;
bracketedPasteMode: boolean;
applicationCursor: boolean;
handler(data: string): void;
scrollLines(disp: number, suppressScrollEvent?: boolean): void;
cancel(ev: Event, force?: boolean): boolean | void;
log(text: string): void;
showCursor(): void;
}
// Portions of the public API that are required by the internal Terminal
export interface IPublicTerminal extends IDisposable, IEventEmitter {
textarea: HTMLTextAreaElement;
rows: number;
cols: number;
buffer: IBuffer;
markers: IMarker[];
onCursorMove: IEvent<void>;
onData: IEvent<string>;
onKey: IEvent<{ key: string, domEvent: KeyboardEvent }>;
onLineFeed: IEvent<void>;
onScroll: IEvent<number>;
onSelectionChange: IEvent<void>;
onRender: IEvent<{ start: number, end: number }>;
onResize: IEvent<{ cols: number, rows: number }>;
onTitleChange: IEvent<string>;
blur(): void;
focus(): void;
resize(columns: number, rows: number): void;
writeln(data: string): void;
open(parent: HTMLElement): void;
attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void;
addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable;
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable;
registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number;
deregisterLinkMatcher(matcherId: number): void;
registerCharacterJoiner(handler: (text: string) => [number, number][]): number;
deregisterCharacterJoiner(joinerId: number): void;
addMarker(cursorYOffset: number): IMarker;
hasSelection(): boolean;
getSelection(): string;
getSelectionPosition(): ISelectionPosition | undefined;
clearSelection(): void;
select(column: number, row: number, length: number): void;
selectAll(): void;
selectLines(start: number, end: number): void;
dispose(): void;
destroy(): void;
scrollLines(amount: number): void;
scrollPages(pageCount: number): void;
scrollToTop(): void;
scrollToBottom(): void;
scrollToLine(line: number): void;
clear(): void;
write(data: string): void;
writeUtf8(data: Uint8Array): void;
getOption(key: string): any;
setOption(key: string, value: any): void;
refresh(start: number, end: number): void;
reset(): void;
}
export interface IBufferAccessor {
buffer: IBuffer;
}
export interface IElementAccessor {
readonly element: HTMLElement;
}
export interface ILinkifierAccessor {
linkifier: ILinkifier;
}
export interface IMouseHelper {
getCoords(event: { clientX: number, clientY: number }, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number, isSelection?: boolean): [number, number];
getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number): { x: number, y: number };
}
export interface ICharMeasure {
width: number;
height: number;
onCharSizeChanged: IEvent<void>;
measure(options: ITerminalOptions): void;
}
// TODO: The options that are not in the public API should be reviewed
export interface ITerminalOptions extends IPublicTerminalOptions {
[key: string]: any;
cancelEvents?: boolean;
convertEol?: boolean;
debug?: boolean;
handler?: (data: string) => void;
screenKeys?: boolean;
termName?: string;
useFlowControl?: boolean;
}
export interface IBufferStringIteratorResult {
range: {first: number, last: number};
content: string;
}
export interface IBufferStringIterator {
hasNext(): boolean;
next(): IBufferStringIteratorResult;
}
export interface IBuffer {
readonly lines: ICircularList<IBufferLine>;
ydisp: number;
ybase: number;
y: number;
x: number;
tabs: any;
scrollBottom: number;
scrollTop: number;
hasScrollback: boolean;
savedY: number;
savedX: number;
savedCurAttrData: IAttributeData;
isCursorInViewport: boolean;
translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol?: number, endCol?: number): string;
getWrappedRangeForLine(y: number): { first: number, last: number };
nextStop(x?: number): number;
prevStop(x?: number): number;
getBlankLine(attr: IAttributeData, isWrapped?: boolean): IBufferLine;
stringIndexToBufferIndex(lineIndex: number, stringIndex: number): number[];
iterator(trimRight: boolean, startIndex?: number, endIndex?: number, startOverscan?: number, endOverscan?: number): IBufferStringIterator;
getNullCell(attr?: IAttributeData): ICellData;
getWhitespaceCell(attr?: IAttributeData): ICellData;
}
export interface IBufferSet {
alt: IBuffer;
normal: IBuffer;
active: IBuffer;
onBufferActivate: IEvent<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
activateNormalBuffer(): void;
activateAltBuffer(fillAttr?: IAttributeData): void;
}
export interface ISelectionManager {
selectionText: string;
selectionStart: [number, number];
selectionEnd: [number, number];
disable(): void;
enable(): void;
setSelection(row: number, col: number, length: number): void;
isClickInSelection(event: MouseEvent): boolean;
selectWordAtCursor(event: MouseEvent): void;
}
export interface ISelectionRedrawRequestEvent {
start: [number, number];
end: [number, number];
columnSelectMode: boolean;
}
export interface ILinkifier {
onLinkHover: IEvent<ILinkifierEvent>;
onLinkLeave: IEvent<ILinkifierEvent>;
onLinkTooltip: IEvent<ILinkifierEvent>;
attachToDom(mouseZoneManager: IMouseZoneManager): void;
linkifyRows(start: number, end: number): void;
registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number;
deregisterLinkMatcher(matcherId: number): boolean;
}
export interface ILinkMatcherOptions {
/**
* The index of the link from the regex.match(text) call. This defaults to 0
* (for regular expressions without capture groups).
*/
matchIndex?: number;
/**
* A callback that validates an individual link, returning true if valid and
* false if invalid.
*/
validationCallback?: LinkMatcherValidationCallback;
/**
* A callback that fires when the mouse hovers over a link.
*/
tooltipCallback?: LinkMatcherHandler;
/**
* A callback that fires when the mouse leaves a link that was hovered.
*/
leaveCallback?: () => void;
/**
* The priority of the link matcher, this defines the order in which the link
* matcher is evaluated relative to others, from highest to lowest. The
* default value is 0.
*/
priority?: number;
/**
* A callback that fires when the mousedown and click events occur that
* determines whether a link will be activated upon click. This enables
* only activating a link when a certain modifier is held down, if not the
* mouse event will continue propagation (eg. double click to select word).
*/
willLinkActivate?: (event: MouseEvent, uri: string) => boolean;
}
export interface IBrowser {
isNode: boolean;
userAgent: string;
platform: string;
isFirefox: boolean;
isMSIE: boolean;
isMac: boolean;
isIpad: boolean;
isIphone: boolean;
isMSWindows: boolean;
}
export interface ISoundManager {
playBellSound(): void;
}
/**
* Internal states of EscapeSequenceParser.
*/
export const enum ParserState {
GROUND = 0,
ESCAPE = 1,
ESCAPE_INTERMEDIATE = 2,
CSI_ENTRY = 3,
CSI_PARAM = 4,
CSI_INTERMEDIATE = 5,
CSI_IGNORE = 6,
SOS_PM_APC_STRING = 7,
OSC_STRING = 8,
DCS_ENTRY = 9,
DCS_PARAM = 10,
DCS_IGNORE = 11,
DCS_INTERMEDIATE = 12,
DCS_PASSTHROUGH = 13
}
/**
* Internal actions of EscapeSequenceParser.
*/
export const enum ParserAction {
IGNORE = 0,
ERROR = 1,
PRINT = 2,
EXECUTE = 3,
OSC_START = 4,
OSC_PUT = 5,
OSC_END = 6,
CSI_DISPATCH = 7,
PARAM = 8,
COLLECT = 9,
ESC_DISPATCH = 10,
CLEAR = 11,
DCS_HOOK = 12,
DCS_PUT = 13,
DCS_UNHOOK = 14
}
/**
* Internal state of EscapeSequenceParser.
* Used as argument of the error handler to allow
* introspection at runtime on parse errors.
* Return it with altered values to recover from
* faulty states (not yet supported).
* Set `abort` to `true` to abort the current parsing.
*/
export interface IParsingState {
// position in parse string
position: number;
// actual character code
code: number;
// current parser state
currentState: ParserState;
// print buffer start index (-1 for not set)
print: number;
// dcs buffer start index (-1 for not set)
dcs: number;
// osc string buffer
osc: string;
// collect buffer with intermediate characters
collect: string;
// params buffer
params: number[];
// should abort (default: false)
abort: boolean;
}
/**
* DCS handler signature for EscapeSequenceParser.
* EscapeSequenceParser handles DCS commands via separate
* subparsers that get hook/unhooked and can handle
* arbitrary amount of data.
*
* On entering a DSC sequence `hook` is called by
* `EscapeSequenceParser`. Use it to initialize or reset
* states needed to handle the current DCS sequence.
* Note: A DCS parser is only instantiated once, therefore
* you cannot rely on the ctor to reinitialize state.
*
* EscapeSequenceParser will call `put` several times if the
* parsed data got split, therefore you might have to collect
* `data` until `unhook` is called.
* Note: `data` is borrowed, if you cannot process the data
* in chunks you have to copy it, doing otherwise will lead to
* data losses or corruption.
*
* `unhook` marks the end of the current DCS sequence.
*/
export interface IDcsHandler {
hook(collect: string, params: number[], flag: number): void;
put(data: Uint32Array, start: number, end: number): void;
unhook(): void;
}
/**
* EscapeSequenceParser interface.
*/
export interface IEscapeSequenceParser extends IDisposable {
/**
* Reset the parser to its initial state (handlers are kept).
*/
reset(): void;
/**
* Parse string `data`.
* @param data The data to parse.
*/
parse(data: Uint32Array, length: number): void;
setPrintHandler(callback: (data: Uint32Array, start: number, end: number) => void): void;
clearPrintHandler(): void;
setExecuteHandler(flag: string, callback: () => void): void;
clearExecuteHandler(flag: string): void;
setExecuteHandlerFallback(callback: (code: number) => void): void;
setCsiHandler(flag: string, callback: (params: number[], collect: string) => void): void;
clearCsiHandler(flag: string): void;
setCsiHandlerFallback(callback: (collect: string, params: number[], flag: number) => void): void;
addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable;
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable;
setEscHandler(collectAndFlag: string, callback: () => void): void;
clearEscHandler(collectAndFlag: string): void;
setEscHandlerFallback(callback: (collect: string, flag: number) => void): void;
setOscHandler(ident: number, callback: (data: string) => void): void;
clearOscHandler(ident: number): void;
setOscHandlerFallback(callback: (identifier: number, data: string) => void): void;
setDcsHandler(collectAndFlag: string, handler: IDcsHandler): void;
clearDcsHandler(collectAndFlag: string): void;
setDcsHandlerFallback(handler: IDcsHandler): void;
setErrorHandler(callback: (state: IParsingState) => IParsingState): void;
clearErrorHandler(): void;
}
export interface IMouseZoneManager extends IDisposable {
add(zone: IMouseZone): void;
clearAll(start?: number, end?: number): void;
}
export interface IMouseZone {
x1: number;
x2: number;
y1: number;
y2: number;
clickCallback: (e: MouseEvent) => any;
hoverCallback: (e: MouseEvent) => any | undefined;
tooltipCallback: (e: MouseEvent) => any | undefined;
leaveCallback: () => any | undefined;
willLinkActivate: (e: MouseEvent) => boolean;
}
+167 -69
View File
@@ -3,87 +3,137 @@
* @license MIT
*/
import { ITerminal, IViewport } from './Interfaces';
import { CharMeasure } from './utils/CharMeasure';
import { IColorSet } from './renderer/Interfaces';
import { ITerminal, IViewport } from './Types';
import { CharMeasure } from './CharMeasure';
import { Disposable } from './common/Lifecycle';
import { addDisposableDomListener } from './ui/Lifecycle';
import { IColorSet } from './ui/Types';
import { IRenderDimensions } from './renderer/Types';
const FALLBACK_SCROLL_BAR_WIDTH = 15;
/**
* 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 implements IViewport {
private currentRowHeight: number = 0;
private lastRecordedBufferLength: number = 0;
private lastRecordedViewportHeight: number = 0;
private lastRecordedBufferHeight: number = 0;
private lastTouchY: number;
export class Viewport extends Disposable implements IViewport {
public scrollBarWidth: number = 0;
private _currentRowHeight: number = 0;
private _lastRecordedBufferLength: number = 0;
private _lastRecordedViewportHeight: number = 0;
private _lastRecordedBufferHeight: number = 0;
private _lastTouchY: number;
private _lastScrollTop: number = 0;
// Stores a partial line amount when scrolling, this is used to keep track of how much of a line
// is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a
// quick fix and could have a more robust solution in place that reset the value when needed.
private _wheelPartialScroll: number = 0;
private _refreshAnimationFrame: number | null = null;
private _ignoreNextScrollEvent: boolean = false;
/**
* 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 charMeasure A DOM element used to measure the character size of. the terminal.
* @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 _charMeasure A DOM element used to measure the character size of. the terminal.
*/
constructor(
private terminal: ITerminal,
private viewportElement: HTMLElement,
private scrollArea: HTMLElement,
private charMeasure: CharMeasure
private _terminal: ITerminal,
private _viewportElement: HTMLElement,
private _scrollArea: HTMLElement,
private _charMeasure: CharMeasure,
private _dimensions: IRenderDimensions
) {
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
super();
// Measure the width of the scrollbar. If it is 0 we can assume it's an OSX overlay scrollbar.
// Unfortunately the overlay scrollbar would be hidden underneath the screen element in that case,
// therefore we account for a standard amount to make it visible
this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
this.register(addDisposableDomListener(this._viewportElement, 'scroll', this._onScroll.bind(this)));
// Perform this async to ensure the CharMeasure is ready.
setTimeout(() => this.syncScrollArea(), 0);
}
public onThemeChanged(colors: IColorSet): void {
this.viewportElement.style.backgroundColor = colors.background;
public onDimensionsChance(dimensions: IRenderDimensions): void {
this._dimensions = dimensions;
}
public onThemeChange(colors: IColorSet): void {
this._viewportElement.style.backgroundColor = colors.background.css;
}
/**
* Refreshes row height, setting line-height, viewport height and scroll area height if
* necessary.
*/
private refresh(): void {
if (this.charMeasure.height > 0) {
this.currentRowHeight = this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;
private _refresh(): void {
if (this._refreshAnimationFrame === null) {
this._refreshAnimationFrame = requestAnimationFrame(() => this._innerRefresh());
}
}
if (this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight) {
this.lastRecordedViewportHeight = this.terminal.renderer.dimensions.canvasHeight;
this.viewportElement.style.height = this.lastRecordedViewportHeight + 'px';
}
const newBufferHeight = Math.round(this.currentRowHeight * this.lastRecordedBufferLength);
if (this.lastRecordedBufferHeight !== newBufferHeight) {
this.lastRecordedBufferHeight = newBufferHeight;
this.scrollArea.style.height = this.lastRecordedBufferHeight + 'px';
private _innerRefresh(): void {
if (this._charMeasure.height > 0) {
this._currentRowHeight = this._dimensions.scaledCellHeight / window.devicePixelRatio;
this._lastRecordedViewportHeight = this._viewportElement.offsetHeight;
const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._dimensions.canvasHeight);
if (this._lastRecordedBufferHeight !== newBufferHeight) {
this._lastRecordedBufferHeight = newBufferHeight;
this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px';
}
}
// Sync scrollTop
const scrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;
if (this._viewportElement.scrollTop !== scrollTop) {
// Ignore the next scroll event which will be triggered by setting the scrollTop as we do not
// want this event to scroll the terminal
this._ignoreNextScrollEvent = true;
this._viewportElement.scrollTop = scrollTop;
}
this._refreshAnimationFrame = null;
}
/**
* Updates dimensions and synchronizes the scroll area if necessary.
*/
public syncScrollArea(): void {
if (this.lastRecordedBufferLength !== this.terminal.buffer.lines.length) {
// If buffer height changed
this.lastRecordedBufferLength = this.terminal.buffer.lines.length;
this.refresh();
} else if (this.lastRecordedViewportHeight !== (<any>this.terminal).renderer.dimensions.canvasHeight) {
// If viewport height changed
this.refresh();
} else {
// If size has changed, refresh viewport
if (this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this.currentRowHeight) {
this.refresh();
}
// If buffer height changed
if (this._lastRecordedBufferLength !== this._terminal.buffer.lines.length) {
this._lastRecordedBufferLength = this._terminal.buffer.lines.length;
this._refresh();
return;
}
// Sync scrollTop
const scrollTop = this.terminal.buffer.ydisp * this.currentRowHeight;
if (this.viewportElement.scrollTop !== scrollTop) {
this.viewportElement.scrollTop = scrollTop;
// If viewport height changed
if (this._lastRecordedViewportHeight !== this._dimensions.canvasHeight) {
this._refresh();
return;
}
// If the buffer position doesn't match last scroll top
const newScrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;
if (this._lastScrollTop !== newScrollTop) {
this._refresh();
return;
}
// If element's scroll top changed, this can happen when hiding the element
if (this._lastScrollTop !== this._viewportElement.scrollTop) {
this._refresh();
return;
}
// If row height changed
if (this._dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) {
this._refresh();
return;
}
}
@@ -92,10 +142,25 @@ export class Viewport implements IViewport {
* terminal to scroll to it.
* @param ev The scroll event.
*/
private onScroll(ev: Event): void {
const newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
const diff = newRow - this.terminal.buffer.ydisp;
this.terminal.scrollLines(diff, true);
private _onScroll(ev: Event): void {
// Record current scroll top position
this._lastScrollTop = this._viewportElement.scrollTop;
// Don't attempt to scroll if the element is not visible, otherwise scrollTop will be corrupt
// which causes the terminal to scroll the buffer to the top
if (!this._viewportElement.offsetParent) {
return;
}
// Ignore the event if it was flagged to ignore (when the source of the event is from Viewport)
if (this._ignoreNextScrollEvent) {
this._ignoreNextScrollEvent = false;
return;
}
const newRow = Math.round(this._lastScrollTop / this._currentRowHeight);
const diff = newRow - this._terminal.buffer.ydisp;
this._terminal.scrollLines(diff, true);
}
/**
@@ -105,41 +170,74 @@ export class Viewport implements IViewport {
* @param ev The mouse wheel event.
*/
public onWheel(ev: WheelEvent): void {
if (ev.deltaY === 0) {
// Do nothing if it's not a vertical scroll event
const amount = this._getPixelsScrolled(ev);
if (amount === 0) {
return;
}
// Fallback to WheelEvent.DOM_DELTA_PIXEL
let 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;
this._viewportElement.scrollTop += amount;
// Prevent the page from scrolling when the terminal scrolls
ev.preventDefault();
};
}
private _getPixelsScrolled(ev: WheelEvent): number {
// Do nothing if it's not a vertical scroll event
if (ev.deltaY === 0) {
return 0;
}
// Fallback to WheelEvent.DOM_DELTA_PIXEL
let amount = ev.deltaY;
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
amount *= this._currentRowHeight;
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
amount *= this._currentRowHeight * this._terminal.rows;
}
return amount;
}
/**
* Gets the number of pixels scrolled by the mouse event taking into account what type of delta
* is being used.
* @param ev The mouse wheel event.
*/
public getLinesScrolled(ev: WheelEvent): number {
// Do nothing if it's not a vertical scroll event
if (ev.deltaY === 0) {
return 0;
}
// Fallback to WheelEvent.DOM_DELTA_LINE
let amount = ev.deltaY;
if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
amount /= this._currentRowHeight + 0.0; // Prevent integer division
this._wheelPartialScroll += amount;
amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
this._wheelPartialScroll %= 1;
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
amount *= this._terminal.rows;
}
return amount;
}
/**
* Handles the touchstart event, recording the touch occurred.
* @param ev The touch event.
*/
public onTouchStart(ev: TouchEvent): void {
this.lastTouchY = ev.touches[0].pageY;
};
this._lastTouchY = ev.touches[0].pageY;
}
/**
* Handles the touchmove event, scrolling the viewport if the position shifted.
* @param ev The touch event.
*/
public onTouchMove(ev: TouchEvent): void {
let deltaY = this.lastTouchY - ev.touches[0].pageY;
this.lastTouchY = ev.touches[0].pageY;
const deltaY = this._lastTouchY - ev.touches[0].pageY;
this._lastTouchY = ev.touches[0].pageY;
if (deltaY === 0) {
return;
}
this.viewportElement.scrollTop += deltaY;
this._viewportElement.scrollTop += deltaY;
ev.preventDefault();
};
}
}
+30
View File
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { IDisposable } from 'xterm';
import { ITerminal } from './Types';
import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from './core/buffer/BufferLine';
export function applyWindowsMode(terminal: ITerminal): IDisposable {
// Winpty does not support wraparound mode which means that lines will never
// be marked as wrapped. This causes issues for things like copying a line
// retaining the wrapped new line characters or if consumers are listening
// in on the data stream.
//
// The workaround for this is to listen to every incoming line feed and mark
// the line as wrapped if the last character in the previous line is not a
// space. This is certainly not without its problems, but generally on
// Windows when text reaches the end of the terminal it's likely going to be
// wrapped.
return terminal.onLineFeed(() => {
const line = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y - 1);
const lastChar = line.get(terminal.cols - 1);
if (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE) {
const nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y);
nextLine.isWrapped = true;
}
});
}
+23
View File
@@ -0,0 +1,23 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*
* Implements the attach method, that attaches the terminal to a WebSocket stream.
*/
import { Terminal, IDisposable } from 'xterm';
export interface IAttachAddonTerminal extends Terminal {
_core: {
register<T extends IDisposable>(d: T): void;
};
__socket?: WebSocket;
__attachSocketBuffer?: string;
__dataListener?: IDisposable;
__getMessage?(ev: MessageEvent): void;
__flushBuffer?(): void;
__pushToBuffer?(data: string): void;
__sendData?(data: string): void;
}
+3 -3
View File
@@ -3,16 +3,16 @@
* @license MIT
*/
import { assert, expect } from 'chai';
import { assert } from 'chai';
import * as attach from './attach'
import * as attach from './attach';
class MockTerminal {}
describe('attach addon', () => {
describe('apply', () => {
it('should do register the `attach` and `detach` methods', () => {
attach.apply(MockTerminal);
attach.apply(<any>MockTerminal);
assert.equal(typeof (<any>MockTerminal).prototype.attach, 'function');
assert.equal(typeof (<any>MockTerminal).prototype.detach, 'function');
});
+97 -62
View File
@@ -5,118 +5,153 @@
* Implements the attach method, that attaches the terminal to a WebSocket stream.
*/
import { Terminal, IDisposable } from 'xterm';
import { IAttachAddonTerminal } from './Interfaces';
/**
* Attaches the given terminal to the given socket.
*
* @param {Terminal} 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.
* @param term The terminal to be attached to the given socket.
* @param socket The socket to attach the current terminal.
* @param bidirectional Whether the terminal should send data to the socket as well.
* @param buffered Whether the rendering of incoming data should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
export function attach(term, socket, bidirectional, buffered) {
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
term.socket = socket;
export function attach(term: Terminal, socket: WebSocket, bidirectional: boolean, buffered: boolean): void {
const addonTerminal = <IAttachAddonTerminal>term;
bidirectional = (typeof bidirectional === 'undefined') ? true : bidirectional;
addonTerminal.__socket = socket;
term._flushBuffer = function() {
term.write(term._attachSocketBuffer);
term._attachSocketBuffer = null;
addonTerminal.__flushBuffer = () => {
addonTerminal.write(addonTerminal.__attachSocketBuffer);
addonTerminal.__attachSocketBuffer = null;
};
term._pushToBuffer = function(data) {
if (term._attachSocketBuffer) {
term._attachSocketBuffer += data;
addonTerminal.__pushToBuffer = (data: string) => {
if (addonTerminal.__attachSocketBuffer) {
addonTerminal.__attachSocketBuffer += data;
} else {
term._attachSocketBuffer = data;
setTimeout(term._flushBuffer, 10);
addonTerminal.__attachSocketBuffer = data;
setTimeout(addonTerminal.__flushBuffer, 10);
}
};
var myTextDecoder;
// TODO: This should be typed but there seem to be issues importing the type
let myTextDecoder: any;
term._getMessage = function(ev) {
var str;
if (typeof ev.data === "object") {
addonTerminal.__getMessage = function(ev: MessageEvent): void {
let str: string;
if (typeof ev.data === 'object') {
if (!myTextDecoder) {
myTextDecoder = new TextDecoder();
}
if (ev.data instanceof ArrayBuffer) {
if (!myTextDecoder) {
myTextDecoder = new TextDecoder();
}
str = myTextDecoder.decode(ev.data);
displayData(str);
} else {
const fileReader = new FileReader();
str = myTextDecoder.decode( ev.data );
fileReader.addEventListener('load', () => {
str = myTextDecoder.decode(fileReader.result);
displayData(str);
});
fileReader.readAsArrayBuffer(ev.data);
}
else {
throw "TODO: handle Blob?";
}
}
if (buffered) {
term._pushToBuffer(str || ev.data);
} else if (typeof ev.data === 'string') {
displayData(ev.data);
} else {
term.write(str || ev.data);
throw Error(`Cannot handle "${typeof ev.data}" websocket message.`);
}
};
term._sendData = function(data) {
/**
* Push data to buffer or write it in the terminal.
* This is used as a callback for FileReader.onload.
*
* @param str String decoded by FileReader.
* @param data The data of the EventMessage.
*/
function displayData(str?: string, data?: string): void {
if (buffered) {
addonTerminal.__pushToBuffer(str || data);
} else {
addonTerminal.write(str || data);
}
}
addonTerminal.__sendData = (data: string) => {
if (socket.readyState !== 1) {
return;
}
socket.send(data);
};
socket.addEventListener('message', term._getMessage);
addonTerminal._core.register(addSocketListener(socket, 'message', addonTerminal.__getMessage));
if (bidirectional) {
term.on('data', term._sendData);
addonTerminal.__dataListener = addonTerminal.onData(addonTerminal.__sendData);
addonTerminal._core.register(addonTerminal.__dataListener);
}
socket.addEventListener('close', term.detach.bind(term, socket));
socket.addEventListener('error', term.detach.bind(term, socket));
};
addonTerminal._core.register(addSocketListener(socket, 'close', () => detach(addonTerminal, socket)));
addonTerminal._core.register(addSocketListener(socket, 'error', () => detach(addonTerminal, socket)));
}
function addSocketListener(socket: WebSocket, type: string, handler: (this: WebSocket, ev: Event) => any): IDisposable {
socket.addEventListener(type, handler);
return {
dispose: () => {
if (!handler) {
// Already disposed
return;
}
socket.removeEventListener(type, handler);
handler = null;
}
};
}
/**
* Detaches the given terminal from the given socket
*
* @param {Terminal} term - The terminal to be detached from the given socket.
* @param {WebSocket} socket - The socket from which to detach the current
* terminal.
* @param term The terminal to be detached from the given socket.
* @param socket The socket from which to detach the current terminal.
*/
export function detach(term, socket) {
term.off('data', term._sendData);
export function detach(term: Terminal, socket: WebSocket): void {
const addonTerminal = <IAttachAddonTerminal>term;
addonTerminal.__dataListener.dispose();
addonTerminal.__dataListener = undefined;
socket = (typeof socket == 'undefined') ? term.socket : socket;
socket = (typeof socket === 'undefined') ? addonTerminal.__socket : socket;
if (socket) {
socket.removeEventListener('message', term._getMessage);
socket.removeEventListener('message', addonTerminal.__getMessage);
}
delete term.socket;
};
delete addonTerminal.__socket;
}
export function apply(terminalConstructor) {
export function apply(terminalConstructor: typeof Terminal): void {
/**
* 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.
* @param socket The socket to attach the current terminal.
* @param bidirectional Whether the terminal should send data to the socket as well.
* @param buffered Whether the rendering of incoming data should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
terminalConstructor.prototype.attach = function(socket, bidirectional, buffered) {
return attach(this, socket, bidirectional, buffered);
(<any>terminalConstructor.prototype).attach = function (socket: WebSocket, bidirectional: boolean, buffered: boolean): void {
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.
* @param socket The socket from which to detach the current terminal.
*/
terminalConstructor.prototype.detach = function(socket) {
return detach(this, socket);
(<any>terminalConstructor.prototype).detach = function (socket: WebSocket): void {
detach(this, socket);
};
}
+11 -2
View File
@@ -2,9 +2,18 @@
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"dom",
"es6",
],
"rootDir": ".",
"outDir": "../../../lib/addons/attach/",
"sourceMap": true,
"removeComments": true
}
"removeComments": true,
"declaration": true
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
## fit addon
The fit addon adjusts the dimensions of the terminal to match best fit its parent element container. `fit` will only work when the element is visible.
+3 -3
View File
@@ -3,16 +3,16 @@
* @license MIT
*/
import { assert, expect } from 'chai';
import { assert } from 'chai';
import * as fit from './fit'
import * as fit from './fit';
class MockTerminal {}
describe('fit addon', () => {
describe('apply', () => {
it('should do register the `proposeGeometry` and `fit` methods', () => {
fit.apply(MockTerminal);
fit.apply(<any>MockTerminal);
assert.equal(typeof (<any>MockTerminal).prototype.proposeGeometry, 'function');
assert.equal(typeof (<any>MockTerminal).prototype.fit, 'function');
});
+39 -27
View File
@@ -13,43 +13,55 @@
* row and truncate its width with the current number of columns).
*/
export function proposeGeometry(term) {
import { Terminal } from 'xterm';
export interface IGeometry {
rows: number;
cols: number;
}
export function proposeGeometry(term: Terminal): IGeometry {
if (!term.element.parentElement) {
return null;
}
var parentElementStyle = window.getComputedStyle(term.element.parentElement);
var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17);
var elementStyle = window.getComputedStyle(term.element);
var elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom'));
var elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left'));
var availableHeight = parentElementHeight - elementPaddingVer;
var availableWidth = parentElementWidth - elementPaddingHor;
var geometry = {
cols: Math.floor(availableWidth / term.renderer.dimensions.actualCellWidth),
rows: Math.floor(availableHeight / term.renderer.dimensions.actualCellHeight)
const parentElementStyle = window.getComputedStyle(term.element.parentElement);
const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
const elementStyle = window.getComputedStyle(term.element);
const elementPadding = {
top: parseInt(elementStyle.getPropertyValue('padding-top')),
bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
right: parseInt(elementStyle.getPropertyValue('padding-right')),
left: parseInt(elementStyle.getPropertyValue('padding-left'))
};
const elementPaddingVer = elementPadding.top + elementPadding.bottom;
const elementPaddingHor = elementPadding.right + elementPadding.left;
const availableHeight = parentElementHeight - elementPaddingVer;
const availableWidth = parentElementWidth - elementPaddingHor - (<any>term)._core.viewport.scrollBarWidth;
const geometry = {
cols: Math.floor(availableWidth / (<any>term)._core._renderCoordinator.dimensions.actualCellWidth),
rows: Math.floor(availableHeight / (<any>term)._core._renderCoordinator.dimensions.actualCellHeight)
};
return geometry;
};
}
export function fit(term) {
var geometry = proposeGeometry(term);
export function fit(term: Terminal): void {
const geometry = proposeGeometry(term);
if (geometry) {
// Force a full render
if (term.rows !== geometry.rows || term.cols !== geometry.cols) {
term.renderer.clear();
(<any>term)._core._renderCoordinator.clear();
term.resize(geometry.cols, geometry.rows);
}
}
};
export function apply(terminalConstructor) {
terminalConstructor.prototype.proposeGeometry = function() {
return proposeGeometry(this);
}
terminalConstructor.prototype.fit = function() {
return fit(this);
}
}
export function apply(terminalConstructor: typeof Terminal): void {
(<any>terminalConstructor.prototype).proposeGeometry = function (): IGeometry {
return proposeGeometry(this);
};
(<any>terminalConstructor.prototype).fit = function (): void {
fit(this);
};
}
+14 -2
View File
@@ -2,9 +2,21 @@
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"dom",
"es5"
],
"rootDir": ".",
"outDir": "../../../lib/addons/fit/",
"sourceMap": true,
"removeComments": true
}
"removeComments": true,
"declaration": true,
"types": [
"../../node_modules/@types/mocha"
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
]
}
+3 -3
View File
@@ -3,16 +3,16 @@
* @license MIT
*/
import { assert, expect } from 'chai';
import { assert } from 'chai';
import * as fullscreen from './fullscreen'
import * as fullscreen from './fullscreen';
class MockTerminal {}
describe('fullscreen addon', () => {
describe('apply', () => {
it('should do register the `toggleFullscreen` method', () => {
fullscreen.apply(MockTerminal);
fullscreen.apply(<any>MockTerminal);
assert.equal(typeof (<any>MockTerminal).prototype.toggleFullScreen, 'function');
});
});
+17 -13
View File
@@ -3,27 +3,31 @@
* @license MIT
*/
import { Terminal } from 'xterm';
/**
* Toggle the given terminal's fullscreen mode.
* @param {Terminal} term - The terminal to toggle full screen mode
* @param {boolean} fullscreen - Toggle fullscreen on (true) or off (false)
* @param term The terminal to toggle full screen mode
* @param fullscreen Toggle fullscreen on (true) or off (false)
*/
export function toggleFullScreen(term, fullscreen) {
var fn;
export function toggleFullScreen(term: Terminal, fullscreen: boolean): void {
let fn: (...tokens: string[]) => void;
if (typeof fullscreen == 'undefined') {
fn = (term.element.classList.contains('fullscreen')) ? 'remove' : 'add';
if (typeof fullscreen === 'undefined') {
fn = (term.element.classList.contains('fullscreen')) ?
term.element.classList.remove : term.element.classList.add;
} else if (!fullscreen) {
fn = 'remove';
fn = term.element.classList.remove;
} else {
fn = 'add';
fn = term.element.classList.add;
}
term.element.classList[fn]('fullscreen');
};
fn = fn.bind(term.element.classList);
fn('fullscreen');
}
export function apply(terminalConstructor) {
terminalConstructor.prototype.toggleFullScreen = function (fullscreen) {
return toggleFullScreen(this, fullscreen);
export function apply(terminalConstructor: typeof Terminal): void {
(<any>terminalConstructor.prototype).toggleFullScreen = function (fullscreen: boolean): void {
toggleFullScreen(this, fullscreen);
};
}
+14 -2
View File
@@ -2,9 +2,21 @@
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"dom",
"es5"
],
"rootDir": ".",
"outDir": "../../../lib/addons/fullscreen/",
"sourceMap": true,
"removeComments": true
}
"removeComments": true,
"declaration": true,
"types": [
"../../node_modules/@types/mocha"
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
]
}
+32
View File
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { Terminal } from 'xterm';
export interface ISearchAddonTerminal extends Terminal {
__searchHelper?: ISearchHelper;
}
export interface ISearchHelper {
findNext(term: string, searchOptions: ISearchOptions): boolean;
findPrevious(term: string, searchOptions: ISearchOptions): boolean;
}
export interface ISearchOptions {
regex?: boolean;
wholeWord?: boolean;
caseSensitive?: boolean;
/**
* Use this when you want the selection to expand if it still matches as the
* user types. Note that this only affects findNext.
*/
incremental?: boolean;
}
export interface ISearchResult {
term: string;
col: number;
row: number;
}
+258 -54
View File
@@ -3,57 +3,92 @@
* @license MIT
*/
// import { ITerminal } from '../../Interfaces';
// import { translateBufferLineToString } from '../../utils/BufferLine';
import { ISearchHelper, ISearchAddonTerminal, ISearchOptions, ISearchResult } from './Interfaces';
import { IDisposable } from 'xterm';
interface ISearchResult {
term: string;
col: number;
row: number;
}
const NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\;:"\',./<>?';
const LINES_CACHE_TIME_TO_LIVE = 15 * 1000; // 15 secs
/**
* A class that knows how to search the terminal and how to display the results.
*/
export class SearchHelper {
constructor(private _terminal: any) {
// TODO: Search for multiple instances on 1 line
// TODO: Don't use the actual selection, instead use a "find selection" so multiple instances can be highlighted
// TODO: Highlight other instances in the viewport
// TODO: Support regex, case sensitivity, etc.
export class SearchHelper implements ISearchHelper {
/**
* translateBufferLineToStringWithWrap is a fairly expensive call.
* We memoize the calls into an array that has a time based ttl.
* _linesCache is also invalidated when the terminal cursor moves.
*/
private _linesCache: string[] = null;
private _linesCacheTimeoutId = 0;
private _cursorMoveListener: IDisposable | undefined;
private _resizeListener: IDisposable | undefined;
constructor(private _terminal: ISearchAddonTerminal) {
this._destroyLinesCache = this._destroyLinesCache.bind(this);
}
/**
* Find the next instance of the term, then scroll to and select it. If it
* doesn't exist, do nothing.
* @param term Tne search term.
* @param term The search term.
* @param searchOptions Search options.
* @return Whether a result was found.
*/
public findNext(term: string): boolean {
public findNext(term: string, searchOptions?: ISearchOptions): boolean {
const {incremental} = searchOptions;
let result: ISearchResult;
if (!term || term.length === 0) {
this._terminal.clearSelection();
return false;
}
let result: ISearchResult;
let startCol: number = 0;
let startRow = this._terminal.buffer.viewportY;
let startRow = this._terminal.buffer.ydisp;
if (this._terminal.selectionManager.selectionEnd) {
if (this._terminal.hasSelection()) {
// Start from the selection end if there is a selection
startRow = this._terminal.selectionManager.selectionEnd[1];
// For incremental search, use existing row
const currentSelection = this._terminal.getSelectionPosition();
startRow = incremental ? currentSelection.startRow : currentSelection.endRow;
startCol = incremental ? currentSelection.startColumn : currentSelection.endColumn;
}
// Search from ydisp + 1 to end
for (let y = startRow + 1; y < this._terminal.buffer.ybase + this._terminal.rows; y++) {
result = this._findInLine(term, y);
if (result) {
break;
this._initLinesCache();
// A row that has isWrapped = false
let findingRow = startRow;
// index of beginning column that _findInLine need to scan.
let cumulativeCols = startCol;
// If startRow is wrapped row, scan for unwrapped row above.
// So we can start matching on wrapped line from long unwrapped line.
while (this._terminal.buffer.getLine(findingRow).isWrapped) {
findingRow--;
cumulativeCols += this._terminal.cols;
}
// Search startRow
result = this._findInLine(term, findingRow, cumulativeCols, searchOptions);
// Search from startRow + 1 to end
if (!result) {
for (let y = startRow + 1; y < this._terminal.buffer.baseY + this._terminal.rows; y++) {
// If the current line is wrapped line, increase index of column to ignore the previous scan
// Otherwise, reset beginning column index to zero with set new unwrapped line index
result = this._findInLine(term, y, 0, searchOptions);
if (result) {
break;
}
}
}
// Search from the top to the current ydisp
// Search from the top to the startRow (search the whole startRow again in
// case startCol > 0)
if (!result) {
for (let y = 0; y < startRow; y++) {
result = this._findInLine(term, y);
for (let y = 0; y < findingRow; y++) {
result = this._findInLine(term, y, 0, searchOptions);
if (result) {
break;
}
@@ -67,37 +102,72 @@ export class SearchHelper {
/**
* Find the previous instance of the term, then scroll to and select it. If it
* doesn't exist, do nothing.
* @param term Tne search term.
* @param term The search term.
* @param searchOptions Search options.
* @return Whether a result was found.
*/
public findPrevious(term: string): boolean {
public findPrevious(term: string, searchOptions?: ISearchOptions): boolean {
let result: ISearchResult;
if (!term || term.length === 0) {
this._terminal.clearSelection();
return false;
}
let result: ISearchResult;
const isReverseSearch = true;
let startRow = this._terminal.buffer.viewportY + this._terminal.rows - 1;
let startCol = this._terminal.cols;
let startRow = this._terminal.buffer.ydisp;
if (this._terminal.selectionManager.selectionStart) {
// Start from the selection end if there is a selection
startRow = this._terminal.selectionManager.selectionStart[1];
if (this._terminal.hasSelection()) {
// Start from the selection start if there is a selection
const currentSelection = this._terminal.getSelectionPosition();
startRow = currentSelection.startRow;
startCol = currentSelection.startColumn;
}
// Search from ydisp + 1 to end
for (let y = startRow - 1; y >= 0; y--) {
result = this._findInLine(term, y);
if (result) {
break;
this._initLinesCache();
// Search startRow
result = this._findInLine(term, startRow, startCol, searchOptions, isReverseSearch);
// Search from startRow - 1 to top
if (!result) {
// If the line is wrapped line, increase number of columns that is needed to be scanned
// Se we can scan on wrapped line from unwrapped line
let cumulativeCols = this._terminal.cols;
if (this._terminal.buffer.getLine(startRow).isWrapped) {
cumulativeCols += startCol;
}
for (let y = startRow - 1; y >= 0; y--) {
result = this._findInLine(term, y, cumulativeCols, searchOptions, isReverseSearch);
if (result) {
break;
}
// If the current line is wrapped line, increase scanning range,
// preparing for scanning on unwrapped line
if (this._terminal.buffer.getLine(y).isWrapped) {
cumulativeCols += this._terminal.cols;
} else {
cumulativeCols = this._terminal.cols;
}
}
}
// Search from the top to the current ydisp
// Search from the bottom to startRow (search the whole startRow again in
// case startCol > 0)
if (!result) {
for (let y = this._terminal.buffer.ybase + this._terminal.rows - 1; y > startRow; y--) {
result = this._findInLine(term, y);
const searchFrom = this._terminal.buffer.baseY + this._terminal.rows - 1;
let cumulativeCols = this._terminal.cols;
for (let y = searchFrom; y >= startRow; y--) {
result = this._findInLine(term, y, cumulativeCols, searchOptions, isReverseSearch);
if (result) {
break;
}
if (this._terminal.buffer.getLine(y).isWrapped) {
cumulativeCols += this._terminal.cols;
} else {
cumulativeCols = this._terminal.cols;
}
}
}
@@ -106,23 +176,156 @@ export class SearchHelper {
}
/**
* Searches a line for a search term.
* @param term Tne search term.
* @param y The line to search.
* Sets up a line cache with a ttl
*/
private _initLinesCache(): void {
if (!this._linesCache) {
this._linesCache = new Array(this._terminal.buffer.length);
this._cursorMoveListener = this._terminal.onCursorMove(() => this._destroyLinesCache());
this._resizeListener = this._terminal.onResize(() => this._destroyLinesCache());
}
window.clearTimeout(this._linesCacheTimeoutId);
this._linesCacheTimeoutId = window.setTimeout(() => this._destroyLinesCache(), LINES_CACHE_TIME_TO_LIVE);
}
private _destroyLinesCache(): void {
this._linesCache = null;
if (this._cursorMoveListener) {
this._cursorMoveListener.dispose();
this._cursorMoveListener = undefined;
}
if (this._resizeListener) {
this._resizeListener.dispose();
this._resizeListener = undefined;
}
if (this._linesCacheTimeoutId) {
window.clearTimeout(this._linesCacheTimeoutId);
this._linesCacheTimeoutId = 0;
}
}
/**
* A found substring is a whole word if it doesn't have an alphanumeric character directly adjacent to it.
* @param searchIndex starting indext of the potential whole word substring
* @param line entire string in which the potential whole word was found
* @param term the substring that starts at searchIndex
*/
private _isWholeWord(searchIndex: number, line: string, term: string): boolean {
return (((searchIndex === 0) || (NON_WORD_CHARACTERS.indexOf(line[searchIndex - 1]) !== -1)) &&
(((searchIndex + term.length) === line.length) || (NON_WORD_CHARACTERS.indexOf(line[searchIndex + term.length]) !== -1)));
}
/**
* Searches a line for a search term. Takes the provided terminal line and searches the text line, which may contain
* subsequent terminal lines if the text is wrapped. If the provided line number is part of a wrapped text line that
* started on an earlier line then it is skipped since it will be properly searched when the terminal line that the
* text starts on is searched.
* @param term The search term.
* @param row The line to start the search from.
* @param col The column to start the search from.
* @param searchOptions Search options.
* @return The search result if it was found.
*/
private _findInLine(term: string, y: number): ISearchResult {
const lowerStringLine = this._terminal.buffer.translateBufferLineToString(y, true).toLowerCase();
const lowerTerm = term.toLowerCase();
const searchIndex = lowerStringLine.indexOf(lowerTerm);
if (searchIndex >= 0) {
protected _findInLine(term: string, row: number, col: number, searchOptions: ISearchOptions = {}, isReverseSearch: boolean = false): ISearchResult {
// Ignore wrapped lines, only consider on unwrapped line (first row of command string).
if (this._terminal.buffer.getLine(row).isWrapped) {
return;
}
let stringLine = this._linesCache ? this._linesCache[row] : void 0;
if (stringLine === void 0) {
stringLine = this.translateBufferLineToStringWithWrap(row, true);
if (this._linesCache) {
this._linesCache[row] = stringLine;
}
}
const searchTerm = searchOptions.caseSensitive ? term : term.toLowerCase();
const searchStringLine = searchOptions.caseSensitive ? stringLine : stringLine.toLowerCase();
let resultIndex = -1;
if (searchOptions.regex) {
const searchRegex = RegExp(searchTerm, 'g');
let foundTerm: RegExpExecArray;
if (isReverseSearch) {
// This loop will get the resultIndex of the _last_ regex match in the range 0..col
while (foundTerm = searchRegex.exec(searchStringLine.slice(0, col))) {
resultIndex = searchRegex.lastIndex - foundTerm[0].length;
term = foundTerm[0];
searchRegex.lastIndex -= (term.length - 1);
}
} else {
foundTerm = searchRegex.exec(searchStringLine.slice(col));
if (foundTerm && foundTerm[0].length > 0) {
resultIndex = col + (searchRegex.lastIndex - foundTerm[0].length);
term = foundTerm[0];
}
}
} else {
if (isReverseSearch) {
if (col - searchTerm.length >= 0) {
resultIndex = searchStringLine.lastIndexOf(searchTerm, col - searchTerm.length);
}
} else {
resultIndex = searchStringLine.indexOf(searchTerm, col);
}
}
if (resultIndex >= 0) {
// Adjust the row number and search index if needed since a "line" of text can span multiple rows
if (resultIndex >= this._terminal.cols) {
row += Math.floor(resultIndex / this._terminal.cols);
resultIndex = resultIndex % this._terminal.cols;
}
if (searchOptions.wholeWord && !this._isWholeWord(resultIndex, searchStringLine, term)) {
return;
}
const line = this._terminal.buffer.getLine(row);
for (let i = 0; i < resultIndex; i++) {
const cell = line.getCell(i);
// Adjust the searchIndex to normalize emoji into single chars
const char = cell.char;
if (char.length > 1) {
resultIndex -= char.length - 1;
}
// Adjust the searchIndex for empty characters following wide unicode
// chars (eg. CJK)
const charWidth = cell.width;
if (charWidth === 0) {
resultIndex++;
}
}
return {
term,
col: searchIndex,
row: y
col: resultIndex,
row
};
}
}
/**
* Translates a buffer line to a string, including subsequent lines if they are wraps.
* Wide characters will count as two columns in the resulting string. This
* function is useful for getting the actual text underneath the raw selection
* position.
* @param line The line being translated.
* @param trimRight Whether to trim whitespace to the right.
*/
public translateBufferLineToStringWithWrap(lineIndex: number, trimRight: boolean): string {
let lineString = '';
let lineWrapsToNext: boolean;
do {
const nextLine = this._terminal.buffer.getLine(lineIndex + 1);
lineWrapsToNext = nextLine ? nextLine.isWrapped : false;
lineString += this._terminal.buffer.getLine(lineIndex).translateToString(!lineWrapsToNext && trimRight).substring(0, this._terminal.cols);
lineIndex++;
} while (lineWrapsToNext);
return lineString;
}
/**
* Selects and scrolls to a result.
@@ -131,10 +334,11 @@ export class SearchHelper {
*/
private _selectResult(result: ISearchResult): boolean {
if (!result) {
this._terminal.clearSelection();
return false;
}
this._terminal.selectionManager.setSelection(result.col, result.row, result.term.length);
this._terminal.scrollLines(result.row - this._terminal.buffer.ydisp, false);
this._terminal.select(result.col, result.row, result.term.length);
this._terminal.scrollLines(result.row - this._terminal.buffer.viewportY);
return true;
}
}
+358
View File
@@ -0,0 +1,358 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
declare var require: any;
import { assert, expect } from 'chai';
import * as search from './search';
import { SearchHelper } from './SearchHelper';
import { ISearchOptions, ISearchResult } from './Interfaces';
class MockTerminalPlain {}
class MockTerminal {
private _core: any;
public searchHelper: TestSearchHelper;
public cols: number;
constructor(options: any) {
this._core = new (require('../../../lib/Terminal')).Terminal(options);
this.searchHelper = new TestSearchHelper(this as any);
this.cols = options.cols;
}
get core(): any {
return this._core;
}
get buffer(): IBuffer {
// TODO: This is a hacky workaround until we use puppeteer for addon tests
const buffer = this._core.buffer;
return {
cursorY: buffer.y,
cursorX: buffer.x,
viewportY: buffer.ydisp,
baseY: buffer.ybase,
length: buffer.length,
getLine(y: number): IBufferLine {
return {
isWrapped: buffer.lines.get(y) ? buffer.lines.get(y).isWrapped : false,
getCell(x: number): IBufferCell {
return {
char: buffer.lines.get(y).get(x)[1/*CHAR_DATA_CHAR_INDEX*/],
width: buffer.lines.get(y).get(x)[2/*CHAR_DATA_WIDTH_INDEX*/]
};
},
translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string {
return buffer.translateBufferLineToString(y, trimRight);
}
};
}
};
}
pushWriteData(): void {
this._core._innerWrite();
}
}
interface IBuffer {
readonly cursorY: number;
readonly cursorX: number;
readonly viewportY: number;
readonly baseY: number;
readonly length: number;
getLine(y: number): IBufferLine | undefined;
}
interface IBufferLine {
readonly isWrapped: boolean;
getCell(x: number): IBufferCell;
translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string;
}
interface IBufferCell {
readonly char: string;
readonly width: number;
}
class TestSearchHelper extends SearchHelper {
public findInLine(term: string, rowNumber: number, searchOptions?: ISearchOptions): ISearchResult {
return this._findInLine(term, rowNumber, 0, searchOptions);
}
public findFromIndex(term: string, row: number, col: number, searchOptions?: ISearchOptions, isReverseSearch?: boolean): ISearchResult {
return this._findInLine(term, row, col, searchOptions, isReverseSearch);
}
}
describe('search addon', () => {
describe('apply', () => {
it('should register findNext and findPrevious', () => {
search.apply(<any>MockTerminalPlain);
assert.equal(typeof (<any>MockTerminalPlain).prototype.findNext, 'function');
assert.equal(typeof (<any>MockTerminalPlain).prototype.findPrevious, 'function');
});
});
describe('find', () => {
it('Searchhelper - should find correct position', () => {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 3});
term.core.write('Hello World\r\ntest\n123....hello');
term.pushWriteData();
const hello0 = term.searchHelper.findInLine('Hello', 0);
const hello1 = term.searchHelper.findInLine('Hello', 1);
const hello2 = term.searchHelper.findInLine('Hello', 2);
expect(hello0).eql({col: 0, row: 0, term: 'Hello'});
expect(hello1).eql(undefined);
expect(hello2).eql({col: 11, row: 2, term: 'Hello'});
});
it('should find search term accross line wrap', () => {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 10, rows: 5});
term.core.write('texttextHellotext\r\n');
term.core.write('texttexttextHellotext goodbye');
term.pushWriteData();
/*
texttextHe
llotext
texttextte
xtHellotex
t (these spaces included intentionally)
goodbye
*/
const hello0 = term.searchHelper.findInLine('Hello', 0);
const hello1 = term.searchHelper.findInLine('Hello', 1);
const hello2 = term.searchHelper.findInLine('Hello', 2);
const hello3 = term.searchHelper.findInLine('Hello', 3);
const llo = term.searchHelper.findInLine('llo', 1);
const goodbye = term.searchHelper.findInLine('goodbye', 2);
expect(hello0).eql({col: 8, row: 0, term: 'Hello'});
expect(hello1).eql(undefined);
expect(hello2).eql({col: 2, row: 3, term: 'Hello'});
expect(hello3).eql(undefined);
expect(llo).eql(undefined);
expect(goodbye).eql({col: 0, row: 5, term: 'goodbye'});
term.core.resize(9, 5);
const hello0Resize = term.searchHelper.findInLine('Hello', 0);
expect(hello0Resize).eql({col: 8, row: 0, term: 'Hello'});
});
it('should respect search regex', () => {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 10, rows: 4});
term.core.write('abcdefghijklmnopqrstuvwxyz\r\n~/dev ');
/*
abcdefghij
klmnopqrst
uvwxyz
~/dev
*/
term.pushWriteData();
const searchOptions = {
regex: true,
wholeWord: false,
caseSensitive: false
};
const hello0 = term.searchHelper.findInLine('dee*', 0, searchOptions);
const hello1 = term.searchHelper.findInLine('jkk*', 0, searchOptions);
const hello2 = term.searchHelper.findInLine('mnn*', 1, searchOptions);
const tilda0 = term.searchHelper.findInLine('^~', 3, searchOptions);
const tilda1 = term.searchHelper.findInLine('^[~]', 3, searchOptions);
const tilda2 = term.searchHelper.findInLine('^\\~', 3, searchOptions);
expect(hello0).eql({col: 3, row: 0, term: 'de'});
expect(hello1).eql({col: 9, row: 0, term: 'jk'});
expect(hello2).eql(undefined);
expect(tilda0).eql({col: 0, row: 3, term: '~'});
expect(tilda1).eql({col: 0, row: 3, term: '~'});
expect(tilda2).eql({col: 0, row: 3, term: '~'});
});
it('should not select empty lines', () => {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 3});
const line = term.searchHelper.findInLine('^.*$', 0, { regex: true });
expect(line).eql(undefined);
});
it('should respect case sensitive', function(): void {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 4});
term.core.write('Hello World\r\n123....hello\r\nmoreTestHello');
term.pushWriteData();
const searchOptions = {
regex: false,
wholeWord: false,
caseSensitive: true
};
const hello0 = term.searchHelper.findInLine('Hello', 0, searchOptions);
const hello1 = term.searchHelper.findInLine('Hello', 1, searchOptions);
const hello2 = term.searchHelper.findInLine('Hello', 2, searchOptions);
expect(hello0).eql({col: 0, row: 0, term: 'Hello'});
expect(hello1).eql(undefined);
expect(hello2).eql({col: 8, row: 2, term: 'Hello'});
});
it('should respect case sensitive + regex', function(): void {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 4});
term.core.write('hellohello\r\nHelloHello');
term.pushWriteData();
/**
* hellohello
* HelloHello
*/
const searchOptions = {
regex: true,
wholeWord: false,
caseSensitive: true
};
const hello0 = term.searchHelper.findInLine('Hello', 0, searchOptions);
const hello1 = term.searchHelper.findInLine('Hello$', 0, searchOptions);
const hello2 = term.searchHelper.findInLine('Hello', 1, searchOptions);
const hello3 = term.searchHelper.findInLine('Hello$', 1, searchOptions);
expect(hello0).eql(undefined);
expect(hello1).eql(undefined);
expect(hello2).eql({col: 0, row: 1, term: 'Hello'});
expect(hello3).eql({col: 5, row: 1, term: 'Hello'});
});
it('should respect whole-word search option', function(): void {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 5});
term.core.write('Hello World\r\nWorld Hello\r\nWorldHelloWorld\r\nHelloWorld\r\nWorldHello');
term.pushWriteData();
const searchOptions = {
regex: false,
wholeWord: true,
caseSensitive: false
};
const hello0 = term.searchHelper.findInLine('Hello', 0, searchOptions);
const hello1 = term.searchHelper.findInLine('Hello', 1, searchOptions);
const hello2 = term.searchHelper.findInLine('Hello', 2, searchOptions);
const hello3 = term.searchHelper.findInLine('Hello', 3, searchOptions);
const hello4 = term.searchHelper.findInLine('Hello', 4, searchOptions);
expect(hello0).eql({col: 0, row: 0, term: 'Hello'});
expect(hello1).eql({col: 6, row: 1, term: 'Hello'});
expect(hello2).eql(undefined);
expect(hello3).eql(undefined);
expect(hello4).eql(undefined);
});
it('should respect whole-word + case sensitive search options', function(): void {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 5});
term.core.write('Hello World\r\nHelloWorld');
term.pushWriteData();
const searchOptions = {
regex: false,
wholeWord: true,
caseSensitive: true
};
const hello0 = term.searchHelper.findInLine('Hello', 0, searchOptions);
const hello1 = term.searchHelper.findInLine('hello', 0, searchOptions);
const hello2 = term.searchHelper.findInLine('Hello', 1, searchOptions);
const hello3 = term.searchHelper.findInLine('hello', 1, searchOptions);
expect(hello0).eql({col: 0, row: 0, term: 'Hello'});
expect(hello1).eql(undefined);
expect(hello2).eql(undefined);
expect(hello3).eql(undefined);
});
it('should respect whole-word + regex search options', function(): void {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 5});
term.core.write('Hello World Hello\r\nHelloWorldHello');
term.pushWriteData();
const searchOptions = {
regex: true,
wholeWord: true,
caseSensitive: false
};
const hello0 = term.searchHelper.findInLine('Hello', 0, searchOptions);
const hello1 = term.searchHelper.findInLine('Hello$', 0, searchOptions);
const hello2 = term.searchHelper.findInLine('Hello', 1, searchOptions);
const hello3 = term.searchHelper.findInLine('Hello$', 1, searchOptions);
expect(hello0).eql({col: 0, row: 0, term: 'hello'});
expect(hello1).eql({col: 12, row: 0, term: 'hello'});
expect(hello2).eql(undefined);
expect(hello3).eql(undefined);
});
it('should respect all search options', function(): void {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 5});
term.core.write('Hello World Hello\r\nHelloWorldHello');
term.pushWriteData();
const searchOptions = {
regex: true,
wholeWord: true,
caseSensitive: true
};
const hello0 = term.searchHelper.findInLine('Hello', 0, searchOptions);
const hello1 = term.searchHelper.findInLine('Hello$', 0, searchOptions);
const hello2 = term.searchHelper.findInLine('hello', 0, searchOptions);
const hello3 = term.searchHelper.findInLine('hello$', 0, searchOptions);
const hello4 = term.searchHelper.findInLine('hello', 1, searchOptions);
const hello5 = term.searchHelper.findInLine('hello$', 1, searchOptions);
expect(hello0).eql({col: 0, row: 0, term: 'Hello'});
expect(hello1).eql({col: 12, row: 0, term: 'Hello'});
expect(hello2).eql(undefined);
expect(hello3).eql(undefined);
expect(hello4).eql(undefined);
expect(hello5).eql(undefined);
});
it('should find multiple matches in line', function(): void {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 5});
term.core.write('helloooo helloooo\r\naaaAAaaAAA');
term.pushWriteData();
const searchOptions = {
regex: false,
wholeWord: false,
caseSensitive: false
};
const find0 = term.searchHelper.findFromIndex('hello', 0, 0, searchOptions);
const find1 = term.searchHelper.findFromIndex('hello', 0, find0.col + find0.term.length, searchOptions);
const find2 = term.searchHelper.findFromIndex('aaaa', 1, 0, searchOptions);
const find3 = term.searchHelper.findFromIndex('aaaa', 1, find2.col + find2.term.length, searchOptions);
const find4 = term.searchHelper.findFromIndex('aaaa', 1, find3.col + find3.term.length, searchOptions);
expect(find0).eql({col: 0, row: 0, term: 'hello'});
expect(find1).eql({col: 9, row: 0, term: 'hello'});
expect(find2).eql({col: 0, row: 1, term: 'aaaa'});
expect(find3).eql({col: 4, row: 1, term: 'aaaa'});
expect(find4).eql(undefined);
});
it('should find multiple matches in line - reverse search', function(): void {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 5});
term.core.write('it is what it is');
term.pushWriteData();
const searchOptions = {
regex: false,
wholeWord: false,
caseSensitive: false
};
const isReverseSearch = true;
const find0 = term.searchHelper.findFromIndex('is', 0, 16, searchOptions, isReverseSearch);
const find1 = term.searchHelper.findFromIndex('is', 0, find0.col, searchOptions, isReverseSearch);
const find2 = term.searchHelper.findFromIndex('it', 0, 16, searchOptions, isReverseSearch);
const find3 = term.searchHelper.findFromIndex('it', 0, find2.col, searchOptions, isReverseSearch);
expect(find0).eql({col: 14, row: 0, term: 'is'});
expect(find1).eql({col: 3, row: 0, term: 'is'});
expect(find2).eql({col: 11, row: 0, term: 'it'});
expect(find3).eql({col: 0, row: 0, term: 'it'});
});
it('should find multiple matches in line - reverse search with regex', function(): void {
search.apply(<any>MockTerminal);
const term = new MockTerminal({cols: 20, rows: 5});
term.core.write('zzzABCzzzzABCABC');
term.pushWriteData();
const searchOptions = {
regex: true,
wholeWord: false,
caseSensitive: true
};
const isReverseSearch = true;
const find0 = term.searchHelper.findFromIndex('[A-Z]{3}', 0, 16, searchOptions, isReverseSearch);
const find1 = term.searchHelper.findFromIndex('[A-Z]{3}', 0, find0.col, searchOptions, isReverseSearch);
const find2 = term.searchHelper.findFromIndex('[A-Z]{3}', 0, find1.col, searchOptions, isReverseSearch);
const find3 = term.searchHelper.findFromIndex('[A-Z]{3}', 0, find2.col, searchOptions, isReverseSearch);
expect(find0).eql({col: 13, row: 0, term: 'ABC'});
expect(find1).eql({col: 10, row: 0, term: 'ABC'});
expect(find2).eql({col: 3, row: 0, term: 'ABC'});
expect(find3).eql(undefined);
});
});
});
+27 -22
View File
@@ -4,40 +4,45 @@
*/
import { SearchHelper } from './SearchHelper';
import { Terminal } from 'xterm';
import { ISearchAddonTerminal, ISearchOptions } from './Interfaces';
/**
* Find the next instance of the term, then scroll to and select it. If it
* doesn't exist, do nothing.
* @param term Tne search term.
* @param term The search term.
* @param searchOptions Search options
* @return Whether a result was found.
*/
export function findNext(terminal: any, term: string): boolean {
if (!terminal._searchHelper) {
terminal.searchHelper = new SearchHelper(terminal);
export function findNext(terminal: Terminal, term: string, searchOptions: ISearchOptions = {}): boolean {
const addonTerminal = <ISearchAddonTerminal>terminal;
if (!addonTerminal.__searchHelper) {
addonTerminal.__searchHelper = new SearchHelper(addonTerminal);
}
return (<SearchHelper>terminal.searchHelper).findNext(term);
};
return addonTerminal.__searchHelper.findNext(term, searchOptions);
}
/**
* Find the previous instance of the term, then scroll to and select it. If it
* doesn't exist, do nothing.
* @param term Tne search term.
* @param term The search term.
* @param searchOptions Search options
* @return Whether a result was found.
*/
export function findPrevious(terminal: any, term: string): boolean {
if (!terminal._searchHelper) {
terminal.searchHelper = new SearchHelper(terminal);
}
return (<SearchHelper>terminal.searchHelper).findPrevious(term);
};
export function apply(terminalConstructor) {
terminalConstructor.prototype.findNext = function(term) {
return findNext(this, term);
}
terminalConstructor.prototype.findPrevious = function(term) {
return findPrevious(this, term);
export function findPrevious(terminal: Terminal, term: string, searchOptions: ISearchOptions): boolean {
const addonTerminal = <ISearchAddonTerminal>terminal;
if (!addonTerminal.__searchHelper) {
addonTerminal.__searchHelper = new SearchHelper(addonTerminal);
}
return addonTerminal.__searchHelper.findPrevious(term, searchOptions);
}
export function apply(terminalConstructor: typeof Terminal): void {
(<any>terminalConstructor.prototype).findNext = function(term: string, searchOptions: ISearchOptions): boolean {
return findNext(this, term, searchOptions);
};
(<any>terminalConstructor.prototype).findPrevious = function(term: string, searchOptions: ISearchOptions): boolean {
return findPrevious(this, term, searchOptions);
};
}
+14 -2
View File
@@ -2,9 +2,21 @@
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"dom",
"es5"
],
"rootDir": ".",
"outDir": "../../../lib/addons/search/",
"sourceMap": true,
"removeComments": true
}
"removeComments": true,
"declaration": true,
"types": [
"../../node_modules/@types/mocha"
]
},
"include": [
"**/*.ts",
"../../../typings/xterm.d.ts"
]
}
+24
View File
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*
* Implements the attach method, that attaches the terminal to a WebSocket stream.
*/
import { Terminal, IDisposable } from 'xterm';
export interface ITerminadoAddonTerminal extends Terminal {
_core: {
register<T extends IDisposable>(d: T): void;
};
__socket?: WebSocket;
__attachSocketBuffer?: string;
__dataListener?: IDisposable;
__getMessage?(ev: MessageEvent): void;
__flushBuffer?(): void;
__pushToBuffer?(data: string): void;
__sendData?(data: string): void;
__setSize?(size: {rows: number, cols: number}): void;
}
+3 -3
View File
@@ -3,16 +3,16 @@
* @license MIT
*/
import { assert, expect } from 'chai';
import { assert } from 'chai';
import * as terminado from './terminado'
import * as terminado from './terminado';
class MockTerminal {}
describe('terminado addon', () => {
describe('apply', () => {
it('should do register the `terminadoAttach` and `terminadoDetach` methods', () => {
terminado.apply(MockTerminal);
terminado.apply(<any>MockTerminal);
assert.equal(typeof (<any>MockTerminal).prototype.terminadoAttach, 'function');
assert.equal(typeof (<any>MockTerminal).prototype.terminadoDetach, 'function');
});
+51 -51
View File
@@ -6,106 +6,106 @@
* WebSocket stream.
*/
import { Terminal } from 'xterm';
import { ITerminadoAddonTerminal } from './Interfaces';
/**
* Attaches the given terminal to the given socket.
*
* @param {Terminal} 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.
* @param term The terminal to be attached to the given socket.
* @param socket The socket to attach the current terminal.
* @param bidirectional Whether the terminal should send data to the socket as well.
* @param buffered Whether the rendering of incoming data should happen instantly or at a maximum
* frequency of 1 rendering per 10ms.
*/
export function terminadoAttach(term, socket, bidirectional, buffered) {
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
term.socket = socket;
export function terminadoAttach(term: Terminal, socket: WebSocket, bidirectional: boolean, buffered: boolean): void {
const addonTerminal = <ITerminadoAddonTerminal>term;
bidirectional = (typeof bidirectional === 'undefined') ? true : bidirectional;
addonTerminal.__socket = socket;
term._flushBuffer = function() {
term.write(term._attachSocketBuffer);
term._attachSocketBuffer = null;
addonTerminal.__flushBuffer = () => {
addonTerminal.write(addonTerminal.__attachSocketBuffer);
addonTerminal.__attachSocketBuffer = null;
};
term._pushToBuffer = function(data) {
if (term._attachSocketBuffer) {
term._attachSocketBuffer += data;
addonTerminal.__pushToBuffer = (data: string) => {
if (addonTerminal.__attachSocketBuffer) {
addonTerminal.__attachSocketBuffer += data;
} else {
term._attachSocketBuffer = data;
setTimeout(term._flushBuffer, 10);
addonTerminal.__attachSocketBuffer = data;
setTimeout(addonTerminal.__flushBuffer, 10);
}
};
term._getMessage = function(ev) {
var data = JSON.parse(ev.data)
if( data[0] == "stdout" ) {
addonTerminal.__getMessage = (ev: MessageEvent) => {
const data = JSON.parse(ev.data);
if (data[0] === 'stdout') {
if (buffered) {
term._pushToBuffer(data[1]);
addonTerminal.__pushToBuffer(data[1]);
} else {
term.write(data[1]);
addonTerminal.write(data[1]);
}
}
};
term._sendData = function(data) {
addonTerminal.__sendData = (data: string) => {
socket.send(JSON.stringify(['stdin', data]));
};
term._setSize = function(size) {
addonTerminal.__setSize = (size: {rows: number, cols: number}) => {
socket.send(JSON.stringify(['set_size', size.rows, size.cols]));
};
socket.addEventListener('message', term._getMessage);
socket.addEventListener('message', addonTerminal.__getMessage);
if (bidirectional) {
term.on('data', term._sendData);
addonTerminal._core.register(addonTerminal.onData(addonTerminal.__sendData));
}
term.on('resize', term._setSize);
addonTerminal._core.register(addonTerminal.onResize(addonTerminal.__setSize));
socket.addEventListener('close', term.terminadoDetach.bind(term, socket));
socket.addEventListener('error', term.terminadoDetach.bind(term, socket));
};
socket.addEventListener('close', () => terminadoDetach(addonTerminal, socket));
socket.addEventListener('error', () => terminadoDetach(addonTerminal, 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.
* @param term The terminal to be detached from the given socket.
* @param socket The socket from which to detach the current terminal.
*/
export function terminadoDetach(term, socket) {
term.off('data', term._sendData);
export function terminadoDetach(term: Terminal, socket: WebSocket): void {
const addonTerminal = <ITerminadoAddonTerminal>term;
addonTerminal.__dataListener.dispose();
addonTerminal.__dataListener = undefined;
socket = (typeof socket == 'undefined') ? term.socket : socket;
socket = (typeof socket === 'undefined') ? addonTerminal.__socket : socket;
if (socket) {
socket.removeEventListener('message', term._getMessage);
socket.removeEventListener('message', addonTerminal.__getMessage);
}
delete term.socket;
};
delete addonTerminal.__socket;
}
export function apply(terminalConstructor) {
export function apply(terminalConstructor: typeof Terminal): void {
/**
* 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.
* @param socket - The socket to attach the current terminal.
* @param bidirectional - Whether the terminal should send data to the socket as well.
* @param buffered - Whether the rendering of incoming data should happen instantly or at a
* maximum frequency of 1 rendering per 10ms.
*/
terminalConstructor.prototype.terminadoAttach = function(socket, bidirectional, buffered) {
(<any>terminalConstructor.prototype).terminadoAttach = function (socket: WebSocket, bidirectional: boolean, buffered: boolean): void {
return 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.
* @param socket The socket from which to detach the current terminal.
*/
terminalConstructor.prototype.terminadoDetach = function(socket) {
(<any>terminalConstructor.prototype).terminadoDetach = function (socket: WebSocket): void {
return terminadoDetach(this, socket);
};
}

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