├── LICENSE
├── README.md
├── defines.go
├── example
├── server.go
└── static
│ ├── fit.js
│ ├── index.html
│ ├── xterm.css
│ ├── xterm.js
│ └── xterm.js.map
├── go.mod
├── go.sum
├── util.go
├── winpty.go
├── winpty_386.go
└── winpty_amd64.go
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2017 Samuel Melrose
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Go-WinPTY
2 | ## GoLang Wrapper for WinPTY.dll
3 |
4 | Small wrapper around the [WinPTY](https://github.com/rprichard/winpty) DLL.
5 |
6 | This, for example, should allow a Go app to serve up a Windows "cmd" or "powershell" prompt via WebSocket to [xterm.js](https://github.com/sourcelair/xterm.js)
7 |
8 | Currently requires `winpty.dll` and `winpty-agent.exe` to be in the same directory as the compiled Go executable.
9 |
10 | These are best obtained from the GitHub releases page, in the msvc2015 package.
11 |
12 | The error handling needs a bit of work currently though!
13 |
--------------------------------------------------------------------------------
/defines.go:
--------------------------------------------------------------------------------
1 | package winpty
2 |
3 | import (
4 | "path/filepath"
5 | "syscall"
6 | )
7 |
8 | const (
9 | WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN = 1
10 | WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION = 0x8
11 | )
12 |
13 | var (
14 | modWinPTY *syscall.LazyDLL
15 |
16 | // Error handling...
17 | winpty_error_code *syscall.LazyProc
18 | winpty_error_msg *syscall.LazyProc
19 | winpty_error_free *syscall.LazyProc
20 |
21 | // Configuration of a new agent.
22 | winpty_config_new *syscall.LazyProc
23 | winpty_config_free *syscall.LazyProc
24 | winpty_config_set_initial_size *syscall.LazyProc
25 | winpty_config_set_mouse_mode *syscall.LazyProc
26 | winpty_config_set_agent_timeout *syscall.LazyProc
27 |
28 | // Start the agent.
29 | winpty_open *syscall.LazyProc
30 | winpty_agent_process *syscall.LazyProc
31 |
32 | // I/O Pipes
33 | winpty_conin_name *syscall.LazyProc
34 | winpty_conout_name *syscall.LazyProc
35 | winpty_conerr_name *syscall.LazyProc
36 |
37 | // Agent RPC Calls
38 | winpty_spawn_config_new *syscall.LazyProc
39 | winpty_spawn_config_free *syscall.LazyProc
40 | winpty_spawn *syscall.LazyProc
41 | winpty_set_size *syscall.LazyProc
42 | winpty_free *syscall.LazyProc
43 | )
44 |
45 | func setupDefines(dllPrefix string) {
46 |
47 | if modWinPTY != nil {
48 | return
49 | }
50 |
51 | modWinPTY = syscall.NewLazyDLL(filepath.Join(dllPrefix, `winpty.dll`))
52 |
53 | // Error handling...
54 | winpty_error_code = modWinPTY.NewProc("winpty_error_code")
55 | winpty_error_msg = modWinPTY.NewProc("winpty_error_msg")
56 | winpty_error_free = modWinPTY.NewProc("winpty_error_free")
57 |
58 | // Configuration of a new agent.
59 | winpty_config_new = modWinPTY.NewProc("winpty_config_new")
60 | winpty_config_free = modWinPTY.NewProc("winpty_config_free")
61 | winpty_config_set_initial_size = modWinPTY.NewProc("winpty_config_set_initial_size")
62 | winpty_config_set_mouse_mode = modWinPTY.NewProc("winpty_config_set_mouse_mode")
63 | winpty_config_set_agent_timeout = modWinPTY.NewProc("winpty_config_set_agent_timeout")
64 |
65 | // Start the agent.
66 | winpty_open = modWinPTY.NewProc("winpty_open")
67 | winpty_agent_process = modWinPTY.NewProc("winpty_agent_process")
68 |
69 | // I/O Pipes
70 | winpty_conin_name = modWinPTY.NewProc("winpty_conin_name")
71 | winpty_conout_name = modWinPTY.NewProc("winpty_conout_name")
72 | winpty_conerr_name = modWinPTY.NewProc("winpty_conerr_name")
73 |
74 | // Agent RPC Calls
75 | winpty_spawn_config_new = modWinPTY.NewProc("winpty_spawn_config_new")
76 | winpty_spawn_config_free = modWinPTY.NewProc("winpty_spawn_config_free")
77 | winpty_spawn = modWinPTY.NewProc("winpty_spawn")
78 | winpty_set_size = modWinPTY.NewProc("winpty_set_size")
79 | winpty_free = modWinPTY.NewProc("winpty_free")
80 | }
81 |
--------------------------------------------------------------------------------
/example/server.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | /*
4 | * Go-WinPTY example.
5 | * Provides a web based cmd or powershell prompt using xterm.js
6 | *
7 | * Usage:
8 | * GOOS=windows GOARCH=amd64 go build -o web-pty.exe server.go
9 | * Place winpty.dll and winpty-agent.exe in the same directory as web-pty.exe, then run.
10 | * .\web-pty.exe -cmd "powershell" -addr 127.0.0.1:9000 -static "static_folder_name"
11 | * .\web-pty.exe -cmd "cmd"
12 | *
13 | * Adapted from https://github.com/codenvy/che-websocket-terminal
14 | * Which was written by Al Tobey tobert@gmail.com
15 | * By Samuel Melrose sam@infitialis.com
16 | */
17 |
18 | import (
19 | "io"
20 | "os"
21 | "log"
22 | "flag"
23 | "bufio"
24 | "bytes"
25 | "net/http"
26 | "unicode/utf8"
27 | "encoding/json"
28 | "github.com/gorilla/websocket"
29 | "github.com/iamacarpet/go-winpty"
30 | )
31 |
32 | var addrFlag, cmdFlag, staticFlag string
33 |
34 | var upgrader = websocket.Upgrader{
35 | ReadBufferSize: 1,
36 | WriteBufferSize: 1,
37 | CheckOrigin: func(r *http.Request) bool {
38 | return true
39 | },
40 | }
41 |
42 | type Message struct{
43 | Type string `json:"type"`
44 | Data json.RawMessage `json:"data"`
45 | }
46 |
47 | type wsPty struct {
48 | Pty *winpty.WinPTY
49 | ws *websocket.Conn
50 | }
51 |
52 | func (wp *wsPty) Start() {
53 | var err error
54 | // If you want to use a location other than the same folder for the DLL and exe
55 | // specify the path as the first param, e.g. winpty.Open(`C:\MYAPP\support`, cmdFlag)
56 | wp.Pty, err = winpty.Open("", cmdFlag)
57 | if err != nil {
58 | log.Fatalf("Failed to start command: %s\n", err)
59 | }
60 | //Set the size of the pty
61 | wp.Pty.SetSize(200, 60)
62 | }
63 |
64 | func (wp *wsPty) Stop() {
65 | wp.Pty.Close()
66 |
67 | wp.ws.Close()
68 | }
69 |
70 | func ptyHandler(w http.ResponseWriter, r *http.Request) {
71 | conn, err := upgrader.Upgrade(w, r, nil)
72 | if err != nil {
73 | log.Fatalf("Websocket upgrade failed: %s\n", err)
74 | }
75 | defer conn.Close()
76 |
77 | wp := wsPty{ ws: conn }
78 |
79 | wp.Start()
80 |
81 | go wp.writePump()
82 | wp.readPump()
83 | }
84 |
85 | func (wp *wsPty) readPump() {
86 | defer wp.Stop()
87 |
88 | for {
89 | mt, payload, err := wp.ws.ReadMessage()
90 | if err != nil {
91 | if err != io.EOF {
92 | log.Printf("conn.ReadMessage failed: %s\n", err)
93 | return
94 | }
95 | }
96 | var msg Message
97 | switch mt {
98 | case websocket.BinaryMessage:
99 | log.Printf("Ignoring binary message: %q\n", payload)
100 | case websocket.TextMessage:
101 | err := json.Unmarshal(payload, &msg)
102 | if err != nil {
103 | log.Printf("Invalid message %s\n", err)
104 | continue
105 | }
106 | switch msg.Type{
107 | case "resize":
108 | var size []float64
109 | err := json.Unmarshal(msg.Data, &size)
110 | if err != nil {
111 | log.Printf("Invalid resize message: %s\n", err)
112 | } else {
113 | wp.Pty.SetSize(uint32(size[0]), uint32(size[1]))
114 | }
115 | case "data":
116 | var dat string
117 | err := json.Unmarshal(msg.Data, &dat)
118 | if err != nil {
119 | log.Printf("Invalid data message %s\n", err)
120 | } else {
121 | wp.Pty.StdIn.Write([]byte(dat));
122 | }
123 | default:
124 | log.Printf("Invalid message type %d\n", mt)
125 | return
126 | }
127 | default:
128 | log.Printf("Invalid message type %d\n", mt)
129 | return
130 | }
131 | }
132 | }
133 |
134 | func (wp *wsPty) writePump() {
135 | defer wp.Stop()
136 |
137 | buf := make([]byte, 8192)
138 | reader := bufio.NewReader(wp.Pty.StdOut)
139 | var buffer bytes.Buffer
140 | for {
141 | n, err := reader.Read(buf)
142 | if err != nil {
143 | log.Printf("Failed to read from pty master: %s", err)
144 | return
145 | }
146 | //read byte array as Unicode code points (rune in go)
147 | bufferBytes := buffer.Bytes()
148 | runeReader := bufio.NewReader(bytes.NewReader(append(bufferBytes[:],buf[:n]...)))
149 | buffer.Reset()
150 | i := 0
151 | for i < n {
152 | char, charLen, e := runeReader.ReadRune()
153 | if e != nil {
154 | log.Printf("Failed to read from pty master: %s", err)
155 | return
156 | }
157 | if char == utf8.RuneError {
158 | runeReader.UnreadRune()
159 | break
160 | }
161 | i += charLen
162 | buffer.WriteRune(char)
163 | }
164 | err = wp.ws.WriteMessage(websocket.TextMessage, buffer.Bytes())
165 | if err != nil {
166 | log.Printf("Failed to send UTF8 char: %s", err)
167 | return
168 | }
169 | buffer.Reset()
170 | if i < n {
171 | buffer.Write(buf[i:n])
172 | }
173 | }
174 | }
175 |
176 | func init() {
177 | cwd, _ := os.Getwd()
178 | flag.StringVar(&addrFlag, "addr", ":9000", "IP:PORT or :PORT address to listen on")
179 | flag.StringVar(&cmdFlag, "cmd", "cmd", "command to execute on slave side of the pty")
180 | flag.StringVar(&staticFlag, "static", cwd, "path to static content")
181 | }
182 |
183 | func main() {
184 | flag.Parse()
185 |
186 | http.HandleFunc("/pty", ptyHandler)
187 |
188 | // serve html & javascript
189 | http.Handle("/", http.FileServer(http.Dir(staticFlag)))
190 |
191 | err := http.ListenAndServe(addrFlag, nil)
192 | if err != nil {
193 | log.Fatalf("net.http could not listen on address '%s': %s\n", addrFlag, err)
194 | }
195 | }
196 |
--------------------------------------------------------------------------------
/example/static/fit.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Fit terminal columns and rows to the dimensions of its
3 | * DOM element.
4 | *
5 | * Approach:
6 | * - Rows: Truncate the division of the terminal parent element height
7 | * by the terminal row height
8 | *
9 | * - Columns: Truncate the division of the terminal parent element width by
10 | * the terminal character width (apply display: inline at the
11 | * terminal row and truncate its width with the current number
12 | * of columns)
13 | */
14 | (function (fit) {
15 | if (typeof exports === 'object' && typeof module === 'object') {
16 | /*
17 | * CommonJS environment
18 | */
19 | module.exports = fit(require('../../dist/xterm'));
20 | } else if (typeof define == 'function') {
21 | /*
22 | * Require.js is available
23 | */
24 | define(['../../dist/xterm'], fit);
25 | } else {
26 | /*
27 | * Plain browser environment
28 | */
29 | fit(window.Terminal);
30 | }
31 | })(function (Xterm) {
32 | /**
33 | * This module provides methods for fitting a terminal's size to a parent container.
34 | *
35 | * @module xterm/addons/fit/fit
36 | */
37 | var exports = {};
38 |
39 | exports.proposeGeometry = function (term) {
40 | var parentElementStyle = window.getComputedStyle(term.element.parentElement),
41 | parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
42 | parentElementWidth = parseInt(parentElementStyle.getPropertyValue('width')),
43 | elementStyle = window.getComputedStyle(term.element),
44 | elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')),
45 | elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left')),
46 | availableHeight = parentElementHeight - elementPaddingVer,
47 | availableWidth = parentElementWidth - elementPaddingHor,
48 | container = term.rowContainer,
49 | subjectRow = term.rowContainer.firstElementChild,
50 | contentBuffer = subjectRow.innerHTML,
51 | characterHeight,
52 | rows,
53 | characterWidth,
54 | cols,
55 | geometry;
56 |
57 | subjectRow.style.display = 'inline';
58 | subjectRow.innerHTML = 'W'; // Common character for measuring width, although on monospace
59 | characterWidth = subjectRow.getBoundingClientRect().width;
60 | subjectRow.style.display = ''; // Revert style before calculating height, since they differ.
61 | characterHeight = parseInt(subjectRow.offsetHeight);
62 | subjectRow.innerHTML = contentBuffer;
63 |
64 | rows = parseInt(availableHeight / characterHeight);
65 | cols = parseInt(availableWidth / characterWidth) - 1;
66 |
67 | geometry = {cols: cols, rows: rows};
68 | return geometry;
69 | };
70 |
71 | exports.fit = function (term) {
72 | var geometry = exports.proposeGeometry(term);
73 |
74 | term.resize(geometry.cols, geometry.rows);
75 | };
76 |
77 | Xterm.prototype.proposeGeometry = function () {
78 | return exports.proposeGeometry(this);
79 | };
80 |
81 | Xterm.prototype.fit = function () {
82 | return exports.fit(this);
83 | };
84 |
85 | return exports;
86 | });
87 |
--------------------------------------------------------------------------------
/example/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/example/static/xterm.css:
--------------------------------------------------------------------------------
1 | /**
2 | * xterm.js: xterm, in the browser
3 | * Copyright (c) 2014-2016, SourceLair Private Company (www.sourcelair.com (MIT License)
4 | * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
5 | * https://github.com/chjj/term.js
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | *
25 | * Originally forked from (with the author's permission):
26 | * Fabrice Bellard's javascript vt100 for jslinux:
27 | * http://bellard.org/jslinux/
28 | * Copyright (c) 2011 Fabrice Bellard
29 | * The original design remains. The terminal itself
30 | * has been extended to include xterm CSI codes, among
31 | * other features.
32 | */
33 |
34 | /*
35 | * Default style for xterm.js
36 | */
37 |
38 | .terminal {
39 | background-color: #000;
40 | color: #fff;
41 | font-family: courier-new, courier, monospace;
42 | font-feature-settings: "liga" 0;
43 | position: relative;
44 | }
45 |
46 | .terminal.focus,
47 | .terminal:focus {
48 | outline: none;
49 | }
50 |
51 | .terminal .xterm-helpers {
52 | position: absolute;
53 | top: 0;
54 | }
55 |
56 | .terminal .xterm-helper-textarea {
57 | /*
58 | * HACK: to fix IE's blinking cursor
59 | * Move textarea out of the screen to the far left, so that the cursor is not visible.
60 | */
61 | position: absolute;
62 | opacity: 0;
63 | left: -9999em;
64 | top: -9999em;
65 | width: 0;
66 | height: 0;
67 | z-index: -10;
68 | /** Prevent wrapping so the IME appears against the textarea at the correct position */
69 | white-space: nowrap;
70 | overflow: hidden;
71 | resize: none;
72 | }
73 |
74 | .terminal .terminal-cursor {
75 | background-color: #fff;
76 | color: #000;
77 | }
78 |
79 | .terminal:not(.focus) .terminal-cursor {
80 | outline: 1px solid #fff;
81 | outline-offset: -1px;
82 | background-color: transparent;
83 | }
84 |
85 | .terminal.focus .terminal-cursor.blinking {
86 | animation: blink-cursor 1.2s infinite step-end;
87 | }
88 |
89 | @keyframes blink-cursor {
90 | 0% {
91 | background-color: #fff;
92 | color: #000;
93 | }
94 | 50% {
95 | background-color: transparent;
96 | color: #FFF;
97 | }
98 | }
99 |
100 | .terminal .composition-view {
101 | background: #000;
102 | color: #FFF;
103 | display: none;
104 | position: absolute;
105 | white-space: nowrap;
106 | z-index: 1;
107 | }
108 |
109 | .terminal .composition-view.active {
110 | display: block;
111 | }
112 |
113 | .terminal .xterm-viewport {
114 | /* On OS X this is required in order for the scroll bar to appear fully opaque */
115 | background-color: #000;
116 | overflow-y: scroll;
117 | }
118 |
119 | .terminal .xterm-rows {
120 | position: absolute;
121 | left: 0;
122 | top: 0;
123 | }
124 |
125 | .terminal .xterm-rows > div {
126 | /* Lines containing spans and text nodes ocassionally wrap despite being the same width (#327) */
127 | white-space: nowrap;
128 | }
129 |
130 | .terminal .xterm-scroll-area {
131 | visibility: hidden;
132 | }
133 |
134 | .terminal .xterm-char-measure-element {
135 | display: inline-block;
136 | visibility: hidden;
137 | position: absolute;
138 | left: -9999em;
139 | }
140 |
141 | /*
142 | * Determine default colors for xterm.js
143 | */
144 | .terminal .xterm-bold {
145 | font-weight: bold;
146 | }
147 |
148 | .terminal .xterm-underline {
149 | text-decoration: underline;
150 | }
151 |
152 | .terminal .xterm-blink {
153 | text-decoration: blink;
154 | }
155 |
156 | .terminal .xterm-hidden {
157 | visibility: hidden;
158 | }
159 |
160 | .terminal .xterm-color-0 {
161 | color: #2e3436;
162 | }
163 |
164 | .terminal .xterm-bg-color-0 {
165 | background-color: #2e3436;
166 | }
167 |
168 | .terminal .xterm-color-1 {
169 | color: #cc0000;
170 | }
171 |
172 | .terminal .xterm-bg-color-1 {
173 | background-color: #cc0000;
174 | }
175 |
176 | .terminal .xterm-color-2 {
177 | color: #4e9a06;
178 | }
179 |
180 | .terminal .xterm-bg-color-2 {
181 | background-color: #4e9a06;
182 | }
183 |
184 | .terminal .xterm-color-3 {
185 | color: #c4a000;
186 | }
187 |
188 | .terminal .xterm-bg-color-3 {
189 | background-color: #c4a000;
190 | }
191 |
192 | .terminal .xterm-color-4 {
193 | color: #3465a4;
194 | }
195 |
196 | .terminal .xterm-bg-color-4 {
197 | background-color: #3465a4;
198 | }
199 |
200 | .terminal .xterm-color-5 {
201 | color: #75507b;
202 | }
203 |
204 | .terminal .xterm-bg-color-5 {
205 | background-color: #75507b;
206 | }
207 |
208 | .terminal .xterm-color-6 {
209 | color: #06989a;
210 | }
211 |
212 | .terminal .xterm-bg-color-6 {
213 | background-color: #06989a;
214 | }
215 |
216 | .terminal .xterm-color-7 {
217 | color: #d3d7cf;
218 | }
219 |
220 | .terminal .xterm-bg-color-7 {
221 | background-color: #d3d7cf;
222 | }
223 |
224 | .terminal .xterm-color-8 {
225 | color: #555753;
226 | }
227 |
228 | .terminal .xterm-bg-color-8 {
229 | background-color: #555753;
230 | }
231 |
232 | .terminal .xterm-color-9 {
233 | color: #ef2929;
234 | }
235 |
236 | .terminal .xterm-bg-color-9 {
237 | background-color: #ef2929;
238 | }
239 |
240 | .terminal .xterm-color-10 {
241 | color: #8ae234;
242 | }
243 |
244 | .terminal .xterm-bg-color-10 {
245 | background-color: #8ae234;
246 | }
247 |
248 | .terminal .xterm-color-11 {
249 | color: #fce94f;
250 | }
251 |
252 | .terminal .xterm-bg-color-11 {
253 | background-color: #fce94f;
254 | }
255 |
256 | .terminal .xterm-color-12 {
257 | color: #729fcf;
258 | }
259 |
260 | .terminal .xterm-bg-color-12 {
261 | background-color: #729fcf;
262 | }
263 |
264 | .terminal .xterm-color-13 {
265 | color: #ad7fa8;
266 | }
267 |
268 | .terminal .xterm-bg-color-13 {
269 | background-color: #ad7fa8;
270 | }
271 |
272 | .terminal .xterm-color-14 {
273 | color: #34e2e2;
274 | }
275 |
276 | .terminal .xterm-bg-color-14 {
277 | background-color: #34e2e2;
278 | }
279 |
280 | .terminal .xterm-color-15 {
281 | color: #eeeeec;
282 | }
283 |
284 | .terminal .xterm-bg-color-15 {
285 | background-color: #eeeeec;
286 | }
287 |
288 | .terminal .xterm-color-16 {
289 | color: #000000;
290 | }
291 |
292 | .terminal .xterm-bg-color-16 {
293 | background-color: #000000;
294 | }
295 |
296 | .terminal .xterm-color-17 {
297 | color: #00005f;
298 | }
299 |
300 | .terminal .xterm-bg-color-17 {
301 | background-color: #00005f;
302 | }
303 |
304 | .terminal .xterm-color-18 {
305 | color: #000087;
306 | }
307 |
308 | .terminal .xterm-bg-color-18 {
309 | background-color: #000087;
310 | }
311 |
312 | .terminal .xterm-color-19 {
313 | color: #0000af;
314 | }
315 |
316 | .terminal .xterm-bg-color-19 {
317 | background-color: #0000af;
318 | }
319 |
320 | .terminal .xterm-color-20 {
321 | color: #0000d7;
322 | }
323 |
324 | .terminal .xterm-bg-color-20 {
325 | background-color: #0000d7;
326 | }
327 |
328 | .terminal .xterm-color-21 {
329 | color: #0000ff;
330 | }
331 |
332 | .terminal .xterm-bg-color-21 {
333 | background-color: #0000ff;
334 | }
335 |
336 | .terminal .xterm-color-22 {
337 | color: #005f00;
338 | }
339 |
340 | .terminal .xterm-bg-color-22 {
341 | background-color: #005f00;
342 | }
343 |
344 | .terminal .xterm-color-23 {
345 | color: #005f5f;
346 | }
347 |
348 | .terminal .xterm-bg-color-23 {
349 | background-color: #005f5f;
350 | }
351 |
352 | .terminal .xterm-color-24 {
353 | color: #005f87;
354 | }
355 |
356 | .terminal .xterm-bg-color-24 {
357 | background-color: #005f87;
358 | }
359 |
360 | .terminal .xterm-color-25 {
361 | color: #005faf;
362 | }
363 |
364 | .terminal .xterm-bg-color-25 {
365 | background-color: #005faf;
366 | }
367 |
368 | .terminal .xterm-color-26 {
369 | color: #005fd7;
370 | }
371 |
372 | .terminal .xterm-bg-color-26 {
373 | background-color: #005fd7;
374 | }
375 |
376 | .terminal .xterm-color-27 {
377 | color: #005fff;
378 | }
379 |
380 | .terminal .xterm-bg-color-27 {
381 | background-color: #005fff;
382 | }
383 |
384 | .terminal .xterm-color-28 {
385 | color: #008700;
386 | }
387 |
388 | .terminal .xterm-bg-color-28 {
389 | background-color: #008700;
390 | }
391 |
392 | .terminal .xterm-color-29 {
393 | color: #00875f;
394 | }
395 |
396 | .terminal .xterm-bg-color-29 {
397 | background-color: #00875f;
398 | }
399 |
400 | .terminal .xterm-color-30 {
401 | color: #008787;
402 | }
403 |
404 | .terminal .xterm-bg-color-30 {
405 | background-color: #008787;
406 | }
407 |
408 | .terminal .xterm-color-31 {
409 | color: #0087af;
410 | }
411 |
412 | .terminal .xterm-bg-color-31 {
413 | background-color: #0087af;
414 | }
415 |
416 | .terminal .xterm-color-32 {
417 | color: #0087d7;
418 | }
419 |
420 | .terminal .xterm-bg-color-32 {
421 | background-color: #0087d7;
422 | }
423 |
424 | .terminal .xterm-color-33 {
425 | color: #0087ff;
426 | }
427 |
428 | .terminal .xterm-bg-color-33 {
429 | background-color: #0087ff;
430 | }
431 |
432 | .terminal .xterm-color-34 {
433 | color: #00af00;
434 | }
435 |
436 | .terminal .xterm-bg-color-34 {
437 | background-color: #00af00;
438 | }
439 |
440 | .terminal .xterm-color-35 {
441 | color: #00af5f;
442 | }
443 |
444 | .terminal .xterm-bg-color-35 {
445 | background-color: #00af5f;
446 | }
447 |
448 | .terminal .xterm-color-36 {
449 | color: #00af87;
450 | }
451 |
452 | .terminal .xterm-bg-color-36 {
453 | background-color: #00af87;
454 | }
455 |
456 | .terminal .xterm-color-37 {
457 | color: #00afaf;
458 | }
459 |
460 | .terminal .xterm-bg-color-37 {
461 | background-color: #00afaf;
462 | }
463 |
464 | .terminal .xterm-color-38 {
465 | color: #00afd7;
466 | }
467 |
468 | .terminal .xterm-bg-color-38 {
469 | background-color: #00afd7;
470 | }
471 |
472 | .terminal .xterm-color-39 {
473 | color: #00afff;
474 | }
475 |
476 | .terminal .xterm-bg-color-39 {
477 | background-color: #00afff;
478 | }
479 |
480 | .terminal .xterm-color-40 {
481 | color: #00d700;
482 | }
483 |
484 | .terminal .xterm-bg-color-40 {
485 | background-color: #00d700;
486 | }
487 |
488 | .terminal .xterm-color-41 {
489 | color: #00d75f;
490 | }
491 |
492 | .terminal .xterm-bg-color-41 {
493 | background-color: #00d75f;
494 | }
495 |
496 | .terminal .xterm-color-42 {
497 | color: #00d787;
498 | }
499 |
500 | .terminal .xterm-bg-color-42 {
501 | background-color: #00d787;
502 | }
503 |
504 | .terminal .xterm-color-43 {
505 | color: #00d7af;
506 | }
507 |
508 | .terminal .xterm-bg-color-43 {
509 | background-color: #00d7af;
510 | }
511 |
512 | .terminal .xterm-color-44 {
513 | color: #00d7d7;
514 | }
515 |
516 | .terminal .xterm-bg-color-44 {
517 | background-color: #00d7d7;
518 | }
519 |
520 | .terminal .xterm-color-45 {
521 | color: #00d7ff;
522 | }
523 |
524 | .terminal .xterm-bg-color-45 {
525 | background-color: #00d7ff;
526 | }
527 |
528 | .terminal .xterm-color-46 {
529 | color: #00ff00;
530 | }
531 |
532 | .terminal .xterm-bg-color-46 {
533 | background-color: #00ff00;
534 | }
535 |
536 | .terminal .xterm-color-47 {
537 | color: #00ff5f;
538 | }
539 |
540 | .terminal .xterm-bg-color-47 {
541 | background-color: #00ff5f;
542 | }
543 |
544 | .terminal .xterm-color-48 {
545 | color: #00ff87;
546 | }
547 |
548 | .terminal .xterm-bg-color-48 {
549 | background-color: #00ff87;
550 | }
551 |
552 | .terminal .xterm-color-49 {
553 | color: #00ffaf;
554 | }
555 |
556 | .terminal .xterm-bg-color-49 {
557 | background-color: #00ffaf;
558 | }
559 |
560 | .terminal .xterm-color-50 {
561 | color: #00ffd7;
562 | }
563 |
564 | .terminal .xterm-bg-color-50 {
565 | background-color: #00ffd7;
566 | }
567 |
568 | .terminal .xterm-color-51 {
569 | color: #00ffff;
570 | }
571 |
572 | .terminal .xterm-bg-color-51 {
573 | background-color: #00ffff;
574 | }
575 |
576 | .terminal .xterm-color-52 {
577 | color: #5f0000;
578 | }
579 |
580 | .terminal .xterm-bg-color-52 {
581 | background-color: #5f0000;
582 | }
583 |
584 | .terminal .xterm-color-53 {
585 | color: #5f005f;
586 | }
587 |
588 | .terminal .xterm-bg-color-53 {
589 | background-color: #5f005f;
590 | }
591 |
592 | .terminal .xterm-color-54 {
593 | color: #5f0087;
594 | }
595 |
596 | .terminal .xterm-bg-color-54 {
597 | background-color: #5f0087;
598 | }
599 |
600 | .terminal .xterm-color-55 {
601 | color: #5f00af;
602 | }
603 |
604 | .terminal .xterm-bg-color-55 {
605 | background-color: #5f00af;
606 | }
607 |
608 | .terminal .xterm-color-56 {
609 | color: #5f00d7;
610 | }
611 |
612 | .terminal .xterm-bg-color-56 {
613 | background-color: #5f00d7;
614 | }
615 |
616 | .terminal .xterm-color-57 {
617 | color: #5f00ff;
618 | }
619 |
620 | .terminal .xterm-bg-color-57 {
621 | background-color: #5f00ff;
622 | }
623 |
624 | .terminal .xterm-color-58 {
625 | color: #5f5f00;
626 | }
627 |
628 | .terminal .xterm-bg-color-58 {
629 | background-color: #5f5f00;
630 | }
631 |
632 | .terminal .xterm-color-59 {
633 | color: #5f5f5f;
634 | }
635 |
636 | .terminal .xterm-bg-color-59 {
637 | background-color: #5f5f5f;
638 | }
639 |
640 | .terminal .xterm-color-60 {
641 | color: #5f5f87;
642 | }
643 |
644 | .terminal .xterm-bg-color-60 {
645 | background-color: #5f5f87;
646 | }
647 |
648 | .terminal .xterm-color-61 {
649 | color: #5f5faf;
650 | }
651 |
652 | .terminal .xterm-bg-color-61 {
653 | background-color: #5f5faf;
654 | }
655 |
656 | .terminal .xterm-color-62 {
657 | color: #5f5fd7;
658 | }
659 |
660 | .terminal .xterm-bg-color-62 {
661 | background-color: #5f5fd7;
662 | }
663 |
664 | .terminal .xterm-color-63 {
665 | color: #5f5fff;
666 | }
667 |
668 | .terminal .xterm-bg-color-63 {
669 | background-color: #5f5fff;
670 | }
671 |
672 | .terminal .xterm-color-64 {
673 | color: #5f8700;
674 | }
675 |
676 | .terminal .xterm-bg-color-64 {
677 | background-color: #5f8700;
678 | }
679 |
680 | .terminal .xterm-color-65 {
681 | color: #5f875f;
682 | }
683 |
684 | .terminal .xterm-bg-color-65 {
685 | background-color: #5f875f;
686 | }
687 |
688 | .terminal .xterm-color-66 {
689 | color: #5f8787;
690 | }
691 |
692 | .terminal .xterm-bg-color-66 {
693 | background-color: #5f8787;
694 | }
695 |
696 | .terminal .xterm-color-67 {
697 | color: #5f87af;
698 | }
699 |
700 | .terminal .xterm-bg-color-67 {
701 | background-color: #5f87af;
702 | }
703 |
704 | .terminal .xterm-color-68 {
705 | color: #5f87d7;
706 | }
707 |
708 | .terminal .xterm-bg-color-68 {
709 | background-color: #5f87d7;
710 | }
711 |
712 | .terminal .xterm-color-69 {
713 | color: #5f87ff;
714 | }
715 |
716 | .terminal .xterm-bg-color-69 {
717 | background-color: #5f87ff;
718 | }
719 |
720 | .terminal .xterm-color-70 {
721 | color: #5faf00;
722 | }
723 |
724 | .terminal .xterm-bg-color-70 {
725 | background-color: #5faf00;
726 | }
727 |
728 | .terminal .xterm-color-71 {
729 | color: #5faf5f;
730 | }
731 |
732 | .terminal .xterm-bg-color-71 {
733 | background-color: #5faf5f;
734 | }
735 |
736 | .terminal .xterm-color-72 {
737 | color: #5faf87;
738 | }
739 |
740 | .terminal .xterm-bg-color-72 {
741 | background-color: #5faf87;
742 | }
743 |
744 | .terminal .xterm-color-73 {
745 | color: #5fafaf;
746 | }
747 |
748 | .terminal .xterm-bg-color-73 {
749 | background-color: #5fafaf;
750 | }
751 |
752 | .terminal .xterm-color-74 {
753 | color: #5fafd7;
754 | }
755 |
756 | .terminal .xterm-bg-color-74 {
757 | background-color: #5fafd7;
758 | }
759 |
760 | .terminal .xterm-color-75 {
761 | color: #5fafff;
762 | }
763 |
764 | .terminal .xterm-bg-color-75 {
765 | background-color: #5fafff;
766 | }
767 |
768 | .terminal .xterm-color-76 {
769 | color: #5fd700;
770 | }
771 |
772 | .terminal .xterm-bg-color-76 {
773 | background-color: #5fd700;
774 | }
775 |
776 | .terminal .xterm-color-77 {
777 | color: #5fd75f;
778 | }
779 |
780 | .terminal .xterm-bg-color-77 {
781 | background-color: #5fd75f;
782 | }
783 |
784 | .terminal .xterm-color-78 {
785 | color: #5fd787;
786 | }
787 |
788 | .terminal .xterm-bg-color-78 {
789 | background-color: #5fd787;
790 | }
791 |
792 | .terminal .xterm-color-79 {
793 | color: #5fd7af;
794 | }
795 |
796 | .terminal .xterm-bg-color-79 {
797 | background-color: #5fd7af;
798 | }
799 |
800 | .terminal .xterm-color-80 {
801 | color: #5fd7d7;
802 | }
803 |
804 | .terminal .xterm-bg-color-80 {
805 | background-color: #5fd7d7;
806 | }
807 |
808 | .terminal .xterm-color-81 {
809 | color: #5fd7ff;
810 | }
811 |
812 | .terminal .xterm-bg-color-81 {
813 | background-color: #5fd7ff;
814 | }
815 |
816 | .terminal .xterm-color-82 {
817 | color: #5fff00;
818 | }
819 |
820 | .terminal .xterm-bg-color-82 {
821 | background-color: #5fff00;
822 | }
823 |
824 | .terminal .xterm-color-83 {
825 | color: #5fff5f;
826 | }
827 |
828 | .terminal .xterm-bg-color-83 {
829 | background-color: #5fff5f;
830 | }
831 |
832 | .terminal .xterm-color-84 {
833 | color: #5fff87;
834 | }
835 |
836 | .terminal .xterm-bg-color-84 {
837 | background-color: #5fff87;
838 | }
839 |
840 | .terminal .xterm-color-85 {
841 | color: #5fffaf;
842 | }
843 |
844 | .terminal .xterm-bg-color-85 {
845 | background-color: #5fffaf;
846 | }
847 |
848 | .terminal .xterm-color-86 {
849 | color: #5fffd7;
850 | }
851 |
852 | .terminal .xterm-bg-color-86 {
853 | background-color: #5fffd7;
854 | }
855 |
856 | .terminal .xterm-color-87 {
857 | color: #5fffff;
858 | }
859 |
860 | .terminal .xterm-bg-color-87 {
861 | background-color: #5fffff;
862 | }
863 |
864 | .terminal .xterm-color-88 {
865 | color: #870000;
866 | }
867 |
868 | .terminal .xterm-bg-color-88 {
869 | background-color: #870000;
870 | }
871 |
872 | .terminal .xterm-color-89 {
873 | color: #87005f;
874 | }
875 |
876 | .terminal .xterm-bg-color-89 {
877 | background-color: #87005f;
878 | }
879 |
880 | .terminal .xterm-color-90 {
881 | color: #870087;
882 | }
883 |
884 | .terminal .xterm-bg-color-90 {
885 | background-color: #870087;
886 | }
887 |
888 | .terminal .xterm-color-91 {
889 | color: #8700af;
890 | }
891 |
892 | .terminal .xterm-bg-color-91 {
893 | background-color: #8700af;
894 | }
895 |
896 | .terminal .xterm-color-92 {
897 | color: #8700d7;
898 | }
899 |
900 | .terminal .xterm-bg-color-92 {
901 | background-color: #8700d7;
902 | }
903 |
904 | .terminal .xterm-color-93 {
905 | color: #8700ff;
906 | }
907 |
908 | .terminal .xterm-bg-color-93 {
909 | background-color: #8700ff;
910 | }
911 |
912 | .terminal .xterm-color-94 {
913 | color: #875f00;
914 | }
915 |
916 | .terminal .xterm-bg-color-94 {
917 | background-color: #875f00;
918 | }
919 |
920 | .terminal .xterm-color-95 {
921 | color: #875f5f;
922 | }
923 |
924 | .terminal .xterm-bg-color-95 {
925 | background-color: #875f5f;
926 | }
927 |
928 | .terminal .xterm-color-96 {
929 | color: #875f87;
930 | }
931 |
932 | .terminal .xterm-bg-color-96 {
933 | background-color: #875f87;
934 | }
935 |
936 | .terminal .xterm-color-97 {
937 | color: #875faf;
938 | }
939 |
940 | .terminal .xterm-bg-color-97 {
941 | background-color: #875faf;
942 | }
943 |
944 | .terminal .xterm-color-98 {
945 | color: #875fd7;
946 | }
947 |
948 | .terminal .xterm-bg-color-98 {
949 | background-color: #875fd7;
950 | }
951 |
952 | .terminal .xterm-color-99 {
953 | color: #875fff;
954 | }
955 |
956 | .terminal .xterm-bg-color-99 {
957 | background-color: #875fff;
958 | }
959 |
960 | .terminal .xterm-color-100 {
961 | color: #878700;
962 | }
963 |
964 | .terminal .xterm-bg-color-100 {
965 | background-color: #878700;
966 | }
967 |
968 | .terminal .xterm-color-101 {
969 | color: #87875f;
970 | }
971 |
972 | .terminal .xterm-bg-color-101 {
973 | background-color: #87875f;
974 | }
975 |
976 | .terminal .xterm-color-102 {
977 | color: #878787;
978 | }
979 |
980 | .terminal .xterm-bg-color-102 {
981 | background-color: #878787;
982 | }
983 |
984 | .terminal .xterm-color-103 {
985 | color: #8787af;
986 | }
987 |
988 | .terminal .xterm-bg-color-103 {
989 | background-color: #8787af;
990 | }
991 |
992 | .terminal .xterm-color-104 {
993 | color: #8787d7;
994 | }
995 |
996 | .terminal .xterm-bg-color-104 {
997 | background-color: #8787d7;
998 | }
999 |
1000 | .terminal .xterm-color-105 {
1001 | color: #8787ff;
1002 | }
1003 |
1004 | .terminal .xterm-bg-color-105 {
1005 | background-color: #8787ff;
1006 | }
1007 |
1008 | .terminal .xterm-color-106 {
1009 | color: #87af00;
1010 | }
1011 |
1012 | .terminal .xterm-bg-color-106 {
1013 | background-color: #87af00;
1014 | }
1015 |
1016 | .terminal .xterm-color-107 {
1017 | color: #87af5f;
1018 | }
1019 |
1020 | .terminal .xterm-bg-color-107 {
1021 | background-color: #87af5f;
1022 | }
1023 |
1024 | .terminal .xterm-color-108 {
1025 | color: #87af87;
1026 | }
1027 |
1028 | .terminal .xterm-bg-color-108 {
1029 | background-color: #87af87;
1030 | }
1031 |
1032 | .terminal .xterm-color-109 {
1033 | color: #87afaf;
1034 | }
1035 |
1036 | .terminal .xterm-bg-color-109 {
1037 | background-color: #87afaf;
1038 | }
1039 |
1040 | .terminal .xterm-color-110 {
1041 | color: #87afd7;
1042 | }
1043 |
1044 | .terminal .xterm-bg-color-110 {
1045 | background-color: #87afd7;
1046 | }
1047 |
1048 | .terminal .xterm-color-111 {
1049 | color: #87afff;
1050 | }
1051 |
1052 | .terminal .xterm-bg-color-111 {
1053 | background-color: #87afff;
1054 | }
1055 |
1056 | .terminal .xterm-color-112 {
1057 | color: #87d700;
1058 | }
1059 |
1060 | .terminal .xterm-bg-color-112 {
1061 | background-color: #87d700;
1062 | }
1063 |
1064 | .terminal .xterm-color-113 {
1065 | color: #87d75f;
1066 | }
1067 |
1068 | .terminal .xterm-bg-color-113 {
1069 | background-color: #87d75f;
1070 | }
1071 |
1072 | .terminal .xterm-color-114 {
1073 | color: #87d787;
1074 | }
1075 |
1076 | .terminal .xterm-bg-color-114 {
1077 | background-color: #87d787;
1078 | }
1079 |
1080 | .terminal .xterm-color-115 {
1081 | color: #87d7af;
1082 | }
1083 |
1084 | .terminal .xterm-bg-color-115 {
1085 | background-color: #87d7af;
1086 | }
1087 |
1088 | .terminal .xterm-color-116 {
1089 | color: #87d7d7;
1090 | }
1091 |
1092 | .terminal .xterm-bg-color-116 {
1093 | background-color: #87d7d7;
1094 | }
1095 |
1096 | .terminal .xterm-color-117 {
1097 | color: #87d7ff;
1098 | }
1099 |
1100 | .terminal .xterm-bg-color-117 {
1101 | background-color: #87d7ff;
1102 | }
1103 |
1104 | .terminal .xterm-color-118 {
1105 | color: #87ff00;
1106 | }
1107 |
1108 | .terminal .xterm-bg-color-118 {
1109 | background-color: #87ff00;
1110 | }
1111 |
1112 | .terminal .xterm-color-119 {
1113 | color: #87ff5f;
1114 | }
1115 |
1116 | .terminal .xterm-bg-color-119 {
1117 | background-color: #87ff5f;
1118 | }
1119 |
1120 | .terminal .xterm-color-120 {
1121 | color: #87ff87;
1122 | }
1123 |
1124 | .terminal .xterm-bg-color-120 {
1125 | background-color: #87ff87;
1126 | }
1127 |
1128 | .terminal .xterm-color-121 {
1129 | color: #87ffaf;
1130 | }
1131 |
1132 | .terminal .xterm-bg-color-121 {
1133 | background-color: #87ffaf;
1134 | }
1135 |
1136 | .terminal .xterm-color-122 {
1137 | color: #87ffd7;
1138 | }
1139 |
1140 | .terminal .xterm-bg-color-122 {
1141 | background-color: #87ffd7;
1142 | }
1143 |
1144 | .terminal .xterm-color-123 {
1145 | color: #87ffff;
1146 | }
1147 |
1148 | .terminal .xterm-bg-color-123 {
1149 | background-color: #87ffff;
1150 | }
1151 |
1152 | .terminal .xterm-color-124 {
1153 | color: #af0000;
1154 | }
1155 |
1156 | .terminal .xterm-bg-color-124 {
1157 | background-color: #af0000;
1158 | }
1159 |
1160 | .terminal .xterm-color-125 {
1161 | color: #af005f;
1162 | }
1163 |
1164 | .terminal .xterm-bg-color-125 {
1165 | background-color: #af005f;
1166 | }
1167 |
1168 | .terminal .xterm-color-126 {
1169 | color: #af0087;
1170 | }
1171 |
1172 | .terminal .xterm-bg-color-126 {
1173 | background-color: #af0087;
1174 | }
1175 |
1176 | .terminal .xterm-color-127 {
1177 | color: #af00af;
1178 | }
1179 |
1180 | .terminal .xterm-bg-color-127 {
1181 | background-color: #af00af;
1182 | }
1183 |
1184 | .terminal .xterm-color-128 {
1185 | color: #af00d7;
1186 | }
1187 |
1188 | .terminal .xterm-bg-color-128 {
1189 | background-color: #af00d7;
1190 | }
1191 |
1192 | .terminal .xterm-color-129 {
1193 | color: #af00ff;
1194 | }
1195 |
1196 | .terminal .xterm-bg-color-129 {
1197 | background-color: #af00ff;
1198 | }
1199 |
1200 | .terminal .xterm-color-130 {
1201 | color: #af5f00;
1202 | }
1203 |
1204 | .terminal .xterm-bg-color-130 {
1205 | background-color: #af5f00;
1206 | }
1207 |
1208 | .terminal .xterm-color-131 {
1209 | color: #af5f5f;
1210 | }
1211 |
1212 | .terminal .xterm-bg-color-131 {
1213 | background-color: #af5f5f;
1214 | }
1215 |
1216 | .terminal .xterm-color-132 {
1217 | color: #af5f87;
1218 | }
1219 |
1220 | .terminal .xterm-bg-color-132 {
1221 | background-color: #af5f87;
1222 | }
1223 |
1224 | .terminal .xterm-color-133 {
1225 | color: #af5faf;
1226 | }
1227 |
1228 | .terminal .xterm-bg-color-133 {
1229 | background-color: #af5faf;
1230 | }
1231 |
1232 | .terminal .xterm-color-134 {
1233 | color: #af5fd7;
1234 | }
1235 |
1236 | .terminal .xterm-bg-color-134 {
1237 | background-color: #af5fd7;
1238 | }
1239 |
1240 | .terminal .xterm-color-135 {
1241 | color: #af5fff;
1242 | }
1243 |
1244 | .terminal .xterm-bg-color-135 {
1245 | background-color: #af5fff;
1246 | }
1247 |
1248 | .terminal .xterm-color-136 {
1249 | color: #af8700;
1250 | }
1251 |
1252 | .terminal .xterm-bg-color-136 {
1253 | background-color: #af8700;
1254 | }
1255 |
1256 | .terminal .xterm-color-137 {
1257 | color: #af875f;
1258 | }
1259 |
1260 | .terminal .xterm-bg-color-137 {
1261 | background-color: #af875f;
1262 | }
1263 |
1264 | .terminal .xterm-color-138 {
1265 | color: #af8787;
1266 | }
1267 |
1268 | .terminal .xterm-bg-color-138 {
1269 | background-color: #af8787;
1270 | }
1271 |
1272 | .terminal .xterm-color-139 {
1273 | color: #af87af;
1274 | }
1275 |
1276 | .terminal .xterm-bg-color-139 {
1277 | background-color: #af87af;
1278 | }
1279 |
1280 | .terminal .xterm-color-140 {
1281 | color: #af87d7;
1282 | }
1283 |
1284 | .terminal .xterm-bg-color-140 {
1285 | background-color: #af87d7;
1286 | }
1287 |
1288 | .terminal .xterm-color-141 {
1289 | color: #af87ff;
1290 | }
1291 |
1292 | .terminal .xterm-bg-color-141 {
1293 | background-color: #af87ff;
1294 | }
1295 |
1296 | .terminal .xterm-color-142 {
1297 | color: #afaf00;
1298 | }
1299 |
1300 | .terminal .xterm-bg-color-142 {
1301 | background-color: #afaf00;
1302 | }
1303 |
1304 | .terminal .xterm-color-143 {
1305 | color: #afaf5f;
1306 | }
1307 |
1308 | .terminal .xterm-bg-color-143 {
1309 | background-color: #afaf5f;
1310 | }
1311 |
1312 | .terminal .xterm-color-144 {
1313 | color: #afaf87;
1314 | }
1315 |
1316 | .terminal .xterm-bg-color-144 {
1317 | background-color: #afaf87;
1318 | }
1319 |
1320 | .terminal .xterm-color-145 {
1321 | color: #afafaf;
1322 | }
1323 |
1324 | .terminal .xterm-bg-color-145 {
1325 | background-color: #afafaf;
1326 | }
1327 |
1328 | .terminal .xterm-color-146 {
1329 | color: #afafd7;
1330 | }
1331 |
1332 | .terminal .xterm-bg-color-146 {
1333 | background-color: #afafd7;
1334 | }
1335 |
1336 | .terminal .xterm-color-147 {
1337 | color: #afafff;
1338 | }
1339 |
1340 | .terminal .xterm-bg-color-147 {
1341 | background-color: #afafff;
1342 | }
1343 |
1344 | .terminal .xterm-color-148 {
1345 | color: #afd700;
1346 | }
1347 |
1348 | .terminal .xterm-bg-color-148 {
1349 | background-color: #afd700;
1350 | }
1351 |
1352 | .terminal .xterm-color-149 {
1353 | color: #afd75f;
1354 | }
1355 |
1356 | .terminal .xterm-bg-color-149 {
1357 | background-color: #afd75f;
1358 | }
1359 |
1360 | .terminal .xterm-color-150 {
1361 | color: #afd787;
1362 | }
1363 |
1364 | .terminal .xterm-bg-color-150 {
1365 | background-color: #afd787;
1366 | }
1367 |
1368 | .terminal .xterm-color-151 {
1369 | color: #afd7af;
1370 | }
1371 |
1372 | .terminal .xterm-bg-color-151 {
1373 | background-color: #afd7af;
1374 | }
1375 |
1376 | .terminal .xterm-color-152 {
1377 | color: #afd7d7;
1378 | }
1379 |
1380 | .terminal .xterm-bg-color-152 {
1381 | background-color: #afd7d7;
1382 | }
1383 |
1384 | .terminal .xterm-color-153 {
1385 | color: #afd7ff;
1386 | }
1387 |
1388 | .terminal .xterm-bg-color-153 {
1389 | background-color: #afd7ff;
1390 | }
1391 |
1392 | .terminal .xterm-color-154 {
1393 | color: #afff00;
1394 | }
1395 |
1396 | .terminal .xterm-bg-color-154 {
1397 | background-color: #afff00;
1398 | }
1399 |
1400 | .terminal .xterm-color-155 {
1401 | color: #afff5f;
1402 | }
1403 |
1404 | .terminal .xterm-bg-color-155 {
1405 | background-color: #afff5f;
1406 | }
1407 |
1408 | .terminal .xterm-color-156 {
1409 | color: #afff87;
1410 | }
1411 |
1412 | .terminal .xterm-bg-color-156 {
1413 | background-color: #afff87;
1414 | }
1415 |
1416 | .terminal .xterm-color-157 {
1417 | color: #afffaf;
1418 | }
1419 |
1420 | .terminal .xterm-bg-color-157 {
1421 | background-color: #afffaf;
1422 | }
1423 |
1424 | .terminal .xterm-color-158 {
1425 | color: #afffd7;
1426 | }
1427 |
1428 | .terminal .xterm-bg-color-158 {
1429 | background-color: #afffd7;
1430 | }
1431 |
1432 | .terminal .xterm-color-159 {
1433 | color: #afffff;
1434 | }
1435 |
1436 | .terminal .xterm-bg-color-159 {
1437 | background-color: #afffff;
1438 | }
1439 |
1440 | .terminal .xterm-color-160 {
1441 | color: #d70000;
1442 | }
1443 |
1444 | .terminal .xterm-bg-color-160 {
1445 | background-color: #d70000;
1446 | }
1447 |
1448 | .terminal .xterm-color-161 {
1449 | color: #d7005f;
1450 | }
1451 |
1452 | .terminal .xterm-bg-color-161 {
1453 | background-color: #d7005f;
1454 | }
1455 |
1456 | .terminal .xterm-color-162 {
1457 | color: #d70087;
1458 | }
1459 |
1460 | .terminal .xterm-bg-color-162 {
1461 | background-color: #d70087;
1462 | }
1463 |
1464 | .terminal .xterm-color-163 {
1465 | color: #d700af;
1466 | }
1467 |
1468 | .terminal .xterm-bg-color-163 {
1469 | background-color: #d700af;
1470 | }
1471 |
1472 | .terminal .xterm-color-164 {
1473 | color: #d700d7;
1474 | }
1475 |
1476 | .terminal .xterm-bg-color-164 {
1477 | background-color: #d700d7;
1478 | }
1479 |
1480 | .terminal .xterm-color-165 {
1481 | color: #d700ff;
1482 | }
1483 |
1484 | .terminal .xterm-bg-color-165 {
1485 | background-color: #d700ff;
1486 | }
1487 |
1488 | .terminal .xterm-color-166 {
1489 | color: #d75f00;
1490 | }
1491 |
1492 | .terminal .xterm-bg-color-166 {
1493 | background-color: #d75f00;
1494 | }
1495 |
1496 | .terminal .xterm-color-167 {
1497 | color: #d75f5f;
1498 | }
1499 |
1500 | .terminal .xterm-bg-color-167 {
1501 | background-color: #d75f5f;
1502 | }
1503 |
1504 | .terminal .xterm-color-168 {
1505 | color: #d75f87;
1506 | }
1507 |
1508 | .terminal .xterm-bg-color-168 {
1509 | background-color: #d75f87;
1510 | }
1511 |
1512 | .terminal .xterm-color-169 {
1513 | color: #d75faf;
1514 | }
1515 |
1516 | .terminal .xterm-bg-color-169 {
1517 | background-color: #d75faf;
1518 | }
1519 |
1520 | .terminal .xterm-color-170 {
1521 | color: #d75fd7;
1522 | }
1523 |
1524 | .terminal .xterm-bg-color-170 {
1525 | background-color: #d75fd7;
1526 | }
1527 |
1528 | .terminal .xterm-color-171 {
1529 | color: #d75fff;
1530 | }
1531 |
1532 | .terminal .xterm-bg-color-171 {
1533 | background-color: #d75fff;
1534 | }
1535 |
1536 | .terminal .xterm-color-172 {
1537 | color: #d78700;
1538 | }
1539 |
1540 | .terminal .xterm-bg-color-172 {
1541 | background-color: #d78700;
1542 | }
1543 |
1544 | .terminal .xterm-color-173 {
1545 | color: #d7875f;
1546 | }
1547 |
1548 | .terminal .xterm-bg-color-173 {
1549 | background-color: #d7875f;
1550 | }
1551 |
1552 | .terminal .xterm-color-174 {
1553 | color: #d78787;
1554 | }
1555 |
1556 | .terminal .xterm-bg-color-174 {
1557 | background-color: #d78787;
1558 | }
1559 |
1560 | .terminal .xterm-color-175 {
1561 | color: #d787af;
1562 | }
1563 |
1564 | .terminal .xterm-bg-color-175 {
1565 | background-color: #d787af;
1566 | }
1567 |
1568 | .terminal .xterm-color-176 {
1569 | color: #d787d7;
1570 | }
1571 |
1572 | .terminal .xterm-bg-color-176 {
1573 | background-color: #d787d7;
1574 | }
1575 |
1576 | .terminal .xterm-color-177 {
1577 | color: #d787ff;
1578 | }
1579 |
1580 | .terminal .xterm-bg-color-177 {
1581 | background-color: #d787ff;
1582 | }
1583 |
1584 | .terminal .xterm-color-178 {
1585 | color: #d7af00;
1586 | }
1587 |
1588 | .terminal .xterm-bg-color-178 {
1589 | background-color: #d7af00;
1590 | }
1591 |
1592 | .terminal .xterm-color-179 {
1593 | color: #d7af5f;
1594 | }
1595 |
1596 | .terminal .xterm-bg-color-179 {
1597 | background-color: #d7af5f;
1598 | }
1599 |
1600 | .terminal .xterm-color-180 {
1601 | color: #d7af87;
1602 | }
1603 |
1604 | .terminal .xterm-bg-color-180 {
1605 | background-color: #d7af87;
1606 | }
1607 |
1608 | .terminal .xterm-color-181 {
1609 | color: #d7afaf;
1610 | }
1611 |
1612 | .terminal .xterm-bg-color-181 {
1613 | background-color: #d7afaf;
1614 | }
1615 |
1616 | .terminal .xterm-color-182 {
1617 | color: #d7afd7;
1618 | }
1619 |
1620 | .terminal .xterm-bg-color-182 {
1621 | background-color: #d7afd7;
1622 | }
1623 |
1624 | .terminal .xterm-color-183 {
1625 | color: #d7afff;
1626 | }
1627 |
1628 | .terminal .xterm-bg-color-183 {
1629 | background-color: #d7afff;
1630 | }
1631 |
1632 | .terminal .xterm-color-184 {
1633 | color: #d7d700;
1634 | }
1635 |
1636 | .terminal .xterm-bg-color-184 {
1637 | background-color: #d7d700;
1638 | }
1639 |
1640 | .terminal .xterm-color-185 {
1641 | color: #d7d75f;
1642 | }
1643 |
1644 | .terminal .xterm-bg-color-185 {
1645 | background-color: #d7d75f;
1646 | }
1647 |
1648 | .terminal .xterm-color-186 {
1649 | color: #d7d787;
1650 | }
1651 |
1652 | .terminal .xterm-bg-color-186 {
1653 | background-color: #d7d787;
1654 | }
1655 |
1656 | .terminal .xterm-color-187 {
1657 | color: #d7d7af;
1658 | }
1659 |
1660 | .terminal .xterm-bg-color-187 {
1661 | background-color: #d7d7af;
1662 | }
1663 |
1664 | .terminal .xterm-color-188 {
1665 | color: #d7d7d7;
1666 | }
1667 |
1668 | .terminal .xterm-bg-color-188 {
1669 | background-color: #d7d7d7;
1670 | }
1671 |
1672 | .terminal .xterm-color-189 {
1673 | color: #d7d7ff;
1674 | }
1675 |
1676 | .terminal .xterm-bg-color-189 {
1677 | background-color: #d7d7ff;
1678 | }
1679 |
1680 | .terminal .xterm-color-190 {
1681 | color: #d7ff00;
1682 | }
1683 |
1684 | .terminal .xterm-bg-color-190 {
1685 | background-color: #d7ff00;
1686 | }
1687 |
1688 | .terminal .xterm-color-191 {
1689 | color: #d7ff5f;
1690 | }
1691 |
1692 | .terminal .xterm-bg-color-191 {
1693 | background-color: #d7ff5f;
1694 | }
1695 |
1696 | .terminal .xterm-color-192 {
1697 | color: #d7ff87;
1698 | }
1699 |
1700 | .terminal .xterm-bg-color-192 {
1701 | background-color: #d7ff87;
1702 | }
1703 |
1704 | .terminal .xterm-color-193 {
1705 | color: #d7ffaf;
1706 | }
1707 |
1708 | .terminal .xterm-bg-color-193 {
1709 | background-color: #d7ffaf;
1710 | }
1711 |
1712 | .terminal .xterm-color-194 {
1713 | color: #d7ffd7;
1714 | }
1715 |
1716 | .terminal .xterm-bg-color-194 {
1717 | background-color: #d7ffd7;
1718 | }
1719 |
1720 | .terminal .xterm-color-195 {
1721 | color: #d7ffff;
1722 | }
1723 |
1724 | .terminal .xterm-bg-color-195 {
1725 | background-color: #d7ffff;
1726 | }
1727 |
1728 | .terminal .xterm-color-196 {
1729 | color: #ff0000;
1730 | }
1731 |
1732 | .terminal .xterm-bg-color-196 {
1733 | background-color: #ff0000;
1734 | }
1735 |
1736 | .terminal .xterm-color-197 {
1737 | color: #ff005f;
1738 | }
1739 |
1740 | .terminal .xterm-bg-color-197 {
1741 | background-color: #ff005f;
1742 | }
1743 |
1744 | .terminal .xterm-color-198 {
1745 | color: #ff0087;
1746 | }
1747 |
1748 | .terminal .xterm-bg-color-198 {
1749 | background-color: #ff0087;
1750 | }
1751 |
1752 | .terminal .xterm-color-199 {
1753 | color: #ff00af;
1754 | }
1755 |
1756 | .terminal .xterm-bg-color-199 {
1757 | background-color: #ff00af;
1758 | }
1759 |
1760 | .terminal .xterm-color-200 {
1761 | color: #ff00d7;
1762 | }
1763 |
1764 | .terminal .xterm-bg-color-200 {
1765 | background-color: #ff00d7;
1766 | }
1767 |
1768 | .terminal .xterm-color-201 {
1769 | color: #ff00ff;
1770 | }
1771 |
1772 | .terminal .xterm-bg-color-201 {
1773 | background-color: #ff00ff;
1774 | }
1775 |
1776 | .terminal .xterm-color-202 {
1777 | color: #ff5f00;
1778 | }
1779 |
1780 | .terminal .xterm-bg-color-202 {
1781 | background-color: #ff5f00;
1782 | }
1783 |
1784 | .terminal .xterm-color-203 {
1785 | color: #ff5f5f;
1786 | }
1787 |
1788 | .terminal .xterm-bg-color-203 {
1789 | background-color: #ff5f5f;
1790 | }
1791 |
1792 | .terminal .xterm-color-204 {
1793 | color: #ff5f87;
1794 | }
1795 |
1796 | .terminal .xterm-bg-color-204 {
1797 | background-color: #ff5f87;
1798 | }
1799 |
1800 | .terminal .xterm-color-205 {
1801 | color: #ff5faf;
1802 | }
1803 |
1804 | .terminal .xterm-bg-color-205 {
1805 | background-color: #ff5faf;
1806 | }
1807 |
1808 | .terminal .xterm-color-206 {
1809 | color: #ff5fd7;
1810 | }
1811 |
1812 | .terminal .xterm-bg-color-206 {
1813 | background-color: #ff5fd7;
1814 | }
1815 |
1816 | .terminal .xterm-color-207 {
1817 | color: #ff5fff;
1818 | }
1819 |
1820 | .terminal .xterm-bg-color-207 {
1821 | background-color: #ff5fff;
1822 | }
1823 |
1824 | .terminal .xterm-color-208 {
1825 | color: #ff8700;
1826 | }
1827 |
1828 | .terminal .xterm-bg-color-208 {
1829 | background-color: #ff8700;
1830 | }
1831 |
1832 | .terminal .xterm-color-209 {
1833 | color: #ff875f;
1834 | }
1835 |
1836 | .terminal .xterm-bg-color-209 {
1837 | background-color: #ff875f;
1838 | }
1839 |
1840 | .terminal .xterm-color-210 {
1841 | color: #ff8787;
1842 | }
1843 |
1844 | .terminal .xterm-bg-color-210 {
1845 | background-color: #ff8787;
1846 | }
1847 |
1848 | .terminal .xterm-color-211 {
1849 | color: #ff87af;
1850 | }
1851 |
1852 | .terminal .xterm-bg-color-211 {
1853 | background-color: #ff87af;
1854 | }
1855 |
1856 | .terminal .xterm-color-212 {
1857 | color: #ff87d7;
1858 | }
1859 |
1860 | .terminal .xterm-bg-color-212 {
1861 | background-color: #ff87d7;
1862 | }
1863 |
1864 | .terminal .xterm-color-213 {
1865 | color: #ff87ff;
1866 | }
1867 |
1868 | .terminal .xterm-bg-color-213 {
1869 | background-color: #ff87ff;
1870 | }
1871 |
1872 | .terminal .xterm-color-214 {
1873 | color: #ffaf00;
1874 | }
1875 |
1876 | .terminal .xterm-bg-color-214 {
1877 | background-color: #ffaf00;
1878 | }
1879 |
1880 | .terminal .xterm-color-215 {
1881 | color: #ffaf5f;
1882 | }
1883 |
1884 | .terminal .xterm-bg-color-215 {
1885 | background-color: #ffaf5f;
1886 | }
1887 |
1888 | .terminal .xterm-color-216 {
1889 | color: #ffaf87;
1890 | }
1891 |
1892 | .terminal .xterm-bg-color-216 {
1893 | background-color: #ffaf87;
1894 | }
1895 |
1896 | .terminal .xterm-color-217 {
1897 | color: #ffafaf;
1898 | }
1899 |
1900 | .terminal .xterm-bg-color-217 {
1901 | background-color: #ffafaf;
1902 | }
1903 |
1904 | .terminal .xterm-color-218 {
1905 | color: #ffafd7;
1906 | }
1907 |
1908 | .terminal .xterm-bg-color-218 {
1909 | background-color: #ffafd7;
1910 | }
1911 |
1912 | .terminal .xterm-color-219 {
1913 | color: #ffafff;
1914 | }
1915 |
1916 | .terminal .xterm-bg-color-219 {
1917 | background-color: #ffafff;
1918 | }
1919 |
1920 | .terminal .xterm-color-220 {
1921 | color: #ffd700;
1922 | }
1923 |
1924 | .terminal .xterm-bg-color-220 {
1925 | background-color: #ffd700;
1926 | }
1927 |
1928 | .terminal .xterm-color-221 {
1929 | color: #ffd75f;
1930 | }
1931 |
1932 | .terminal .xterm-bg-color-221 {
1933 | background-color: #ffd75f;
1934 | }
1935 |
1936 | .terminal .xterm-color-222 {
1937 | color: #ffd787;
1938 | }
1939 |
1940 | .terminal .xterm-bg-color-222 {
1941 | background-color: #ffd787;
1942 | }
1943 |
1944 | .terminal .xterm-color-223 {
1945 | color: #ffd7af;
1946 | }
1947 |
1948 | .terminal .xterm-bg-color-223 {
1949 | background-color: #ffd7af;
1950 | }
1951 |
1952 | .terminal .xterm-color-224 {
1953 | color: #ffd7d7;
1954 | }
1955 |
1956 | .terminal .xterm-bg-color-224 {
1957 | background-color: #ffd7d7;
1958 | }
1959 |
1960 | .terminal .xterm-color-225 {
1961 | color: #ffd7ff;
1962 | }
1963 |
1964 | .terminal .xterm-bg-color-225 {
1965 | background-color: #ffd7ff;
1966 | }
1967 |
1968 | .terminal .xterm-color-226 {
1969 | color: #ffff00;
1970 | }
1971 |
1972 | .terminal .xterm-bg-color-226 {
1973 | background-color: #ffff00;
1974 | }
1975 |
1976 | .terminal .xterm-color-227 {
1977 | color: #ffff5f;
1978 | }
1979 |
1980 | .terminal .xterm-bg-color-227 {
1981 | background-color: #ffff5f;
1982 | }
1983 |
1984 | .terminal .xterm-color-228 {
1985 | color: #ffff87;
1986 | }
1987 |
1988 | .terminal .xterm-bg-color-228 {
1989 | background-color: #ffff87;
1990 | }
1991 |
1992 | .terminal .xterm-color-229 {
1993 | color: #ffffaf;
1994 | }
1995 |
1996 | .terminal .xterm-bg-color-229 {
1997 | background-color: #ffffaf;
1998 | }
1999 |
2000 | .terminal .xterm-color-230 {
2001 | color: #ffffd7;
2002 | }
2003 |
2004 | .terminal .xterm-bg-color-230 {
2005 | background-color: #ffffd7;
2006 | }
2007 |
2008 | .terminal .xterm-color-231 {
2009 | color: #ffffff;
2010 | }
2011 |
2012 | .terminal .xterm-bg-color-231 {
2013 | background-color: #ffffff;
2014 | }
2015 |
2016 | .terminal .xterm-color-232 {
2017 | color: #080808;
2018 | }
2019 |
2020 | .terminal .xterm-bg-color-232 {
2021 | background-color: #080808;
2022 | }
2023 |
2024 | .terminal .xterm-color-233 {
2025 | color: #121212;
2026 | }
2027 |
2028 | .terminal .xterm-bg-color-233 {
2029 | background-color: #121212;
2030 | }
2031 |
2032 | .terminal .xterm-color-234 {
2033 | color: #1c1c1c;
2034 | }
2035 |
2036 | .terminal .xterm-bg-color-234 {
2037 | background-color: #1c1c1c;
2038 | }
2039 |
2040 | .terminal .xterm-color-235 {
2041 | color: #262626;
2042 | }
2043 |
2044 | .terminal .xterm-bg-color-235 {
2045 | background-color: #262626;
2046 | }
2047 |
2048 | .terminal .xterm-color-236 {
2049 | color: #303030;
2050 | }
2051 |
2052 | .terminal .xterm-bg-color-236 {
2053 | background-color: #303030;
2054 | }
2055 |
2056 | .terminal .xterm-color-237 {
2057 | color: #3a3a3a;
2058 | }
2059 |
2060 | .terminal .xterm-bg-color-237 {
2061 | background-color: #3a3a3a;
2062 | }
2063 |
2064 | .terminal .xterm-color-238 {
2065 | color: #444444;
2066 | }
2067 |
2068 | .terminal .xterm-bg-color-238 {
2069 | background-color: #444444;
2070 | }
2071 |
2072 | .terminal .xterm-color-239 {
2073 | color: #4e4e4e;
2074 | }
2075 |
2076 | .terminal .xterm-bg-color-239 {
2077 | background-color: #4e4e4e;
2078 | }
2079 |
2080 | .terminal .xterm-color-240 {
2081 | color: #585858;
2082 | }
2083 |
2084 | .terminal .xterm-bg-color-240 {
2085 | background-color: #585858;
2086 | }
2087 |
2088 | .terminal .xterm-color-241 {
2089 | color: #626262;
2090 | }
2091 |
2092 | .terminal .xterm-bg-color-241 {
2093 | background-color: #626262;
2094 | }
2095 |
2096 | .terminal .xterm-color-242 {
2097 | color: #6c6c6c;
2098 | }
2099 |
2100 | .terminal .xterm-bg-color-242 {
2101 | background-color: #6c6c6c;
2102 | }
2103 |
2104 | .terminal .xterm-color-243 {
2105 | color: #767676;
2106 | }
2107 |
2108 | .terminal .xterm-bg-color-243 {
2109 | background-color: #767676;
2110 | }
2111 |
2112 | .terminal .xterm-color-244 {
2113 | color: #808080;
2114 | }
2115 |
2116 | .terminal .xterm-bg-color-244 {
2117 | background-color: #808080;
2118 | }
2119 |
2120 | .terminal .xterm-color-245 {
2121 | color: #8a8a8a;
2122 | }
2123 |
2124 | .terminal .xterm-bg-color-245 {
2125 | background-color: #8a8a8a;
2126 | }
2127 |
2128 | .terminal .xterm-color-246 {
2129 | color: #949494;
2130 | }
2131 |
2132 | .terminal .xterm-bg-color-246 {
2133 | background-color: #949494;
2134 | }
2135 |
2136 | .terminal .xterm-color-247 {
2137 | color: #9e9e9e;
2138 | }
2139 |
2140 | .terminal .xterm-bg-color-247 {
2141 | background-color: #9e9e9e;
2142 | }
2143 |
2144 | .terminal .xterm-color-248 {
2145 | color: #a8a8a8;
2146 | }
2147 |
2148 | .terminal .xterm-bg-color-248 {
2149 | background-color: #a8a8a8;
2150 | }
2151 |
2152 | .terminal .xterm-color-249 {
2153 | color: #b2b2b2;
2154 | }
2155 |
2156 | .terminal .xterm-bg-color-249 {
2157 | background-color: #b2b2b2;
2158 | }
2159 |
2160 | .terminal .xterm-color-250 {
2161 | color: #bcbcbc;
2162 | }
2163 |
2164 | .terminal .xterm-bg-color-250 {
2165 | background-color: #bcbcbc;
2166 | }
2167 |
2168 | .terminal .xterm-color-251 {
2169 | color: #c6c6c6;
2170 | }
2171 |
2172 | .terminal .xterm-bg-color-251 {
2173 | background-color: #c6c6c6;
2174 | }
2175 |
2176 | .terminal .xterm-color-252 {
2177 | color: #d0d0d0;
2178 | }
2179 |
2180 | .terminal .xterm-bg-color-252 {
2181 | background-color: #d0d0d0;
2182 | }
2183 |
2184 | .terminal .xterm-color-253 {
2185 | color: #dadada;
2186 | }
2187 |
2188 | .terminal .xterm-bg-color-253 {
2189 | background-color: #dadada;
2190 | }
2191 |
2192 | .terminal .xterm-color-254 {
2193 | color: #e4e4e4;
2194 | }
2195 |
2196 | .terminal .xterm-bg-color-254 {
2197 | background-color: #e4e4e4;
2198 | }
2199 |
2200 | .terminal .xterm-color-255 {
2201 | color: #eeeeee;
2202 | }
2203 |
2204 | .terminal .xterm-bg-color-255 {
2205 | background-color: #eeeeee;
2206 | }
2207 |
--------------------------------------------------------------------------------
/example/static/xterm.js:
--------------------------------------------------------------------------------
1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Terminal = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) {
171 | self.terminal.handler(diff);
172 | }
173 | }
174 | }, 0);
175 | };
176 |
177 | /**
178 | * Positions the composition view on top of the cursor and the textarea just below it (so the
179 | * IME helper dialog is positioned correctly).
180 | */
181 | CompositionHelper.prototype.updateCompositionElements = function (dontRecurse) {
182 | if (!this.isComposing) {
183 | return;
184 | }
185 | var cursor = this.terminal.element.querySelector('.terminal-cursor');
186 | if (cursor) {
187 | // Take .xterm-rows offsetTop into account as well in case it's positioned absolutely within
188 | // the .xterm element.
189 | var xtermRows = this.terminal.element.querySelector('.xterm-rows');
190 | var cursorTop = xtermRows.offsetTop + cursor.offsetTop;
191 |
192 | this.compositionView.style.left = cursor.offsetLeft + 'px';
193 | this.compositionView.style.top = cursorTop + 'px';
194 | this.compositionView.style.height = cursor.offsetHeight + 'px';
195 | this.compositionView.style.lineHeight = cursor.offsetHeight + 'px';
196 | // Sync the textarea to the exact position of the composition view so the IME knows where the
197 | // text is.
198 | var compositionViewBounds = this.compositionView.getBoundingClientRect();
199 | this.textarea.style.left = cursor.offsetLeft + 'px';
200 | this.textarea.style.top = cursorTop + 'px';
201 | this.textarea.style.width = compositionViewBounds.width + 'px';
202 | this.textarea.style.height = compositionViewBounds.height + 'px';
203 | this.textarea.style.lineHeight = compositionViewBounds.height + 'px';
204 | }
205 | if (!dontRecurse) {
206 | setTimeout(this.updateCompositionElements.bind(this, true), 0);
207 | }
208 | };
209 |
210 | /**
211 | * Clears the textarea's position so that the cursor does not blink on IE.
212 | * @private
213 | */
214 | CompositionHelper.prototype.clearTextareaPosition = function () {
215 | this.textarea.style.left = '';
216 | this.textarea.style.top = '';
217 | };
218 |
219 | exports.CompositionHelper = CompositionHelper;
220 |
221 | },{}],2:[function(_dereq_,module,exports){
222 | "use strict";
223 |
224 | Object.defineProperty(exports, "__esModule", {
225 | value: true
226 | });
227 | /**
228 | * xterm.js: xterm, in the browser
229 | * Copyright (c) 2014-2016, SourceLair Private Company (www.sourcelair.com (MIT License)
230 | */
231 |
232 | function EventEmitter() {
233 | this._events = this._events || {};
234 | }
235 |
236 | EventEmitter.prototype.addListener = function (type, listener) {
237 | this._events[type] = this._events[type] || [];
238 | this._events[type].push(listener);
239 | };
240 |
241 | EventEmitter.prototype.on = EventEmitter.prototype.addListener;
242 |
243 | EventEmitter.prototype.removeListener = function (type, listener) {
244 | if (!this._events[type]) return;
245 |
246 | var obj = this._events[type],
247 | i = obj.length;
248 |
249 | while (i--) {
250 | if (obj[i] === listener || obj[i].listener === listener) {
251 | obj.splice(i, 1);
252 | return;
253 | }
254 | }
255 | };
256 |
257 | EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
258 |
259 | EventEmitter.prototype.removeAllListeners = function (type) {
260 | if (this._events[type]) delete this._events[type];
261 | };
262 |
263 | EventEmitter.prototype.once = function (type, listener) {
264 | var self = this;
265 | function on() {
266 | var args = Array.prototype.slice.call(arguments);
267 | this.removeListener(type, on);
268 | return listener.apply(this, args);
269 | }
270 | on.listener = listener;
271 | return this.on(type, on);
272 | };
273 |
274 | EventEmitter.prototype.emit = function (type) {
275 | if (!this._events[type]) return;
276 |
277 | var args = Array.prototype.slice.call(arguments, 1),
278 | obj = this._events[type],
279 | l = obj.length,
280 | i = 0;
281 |
282 | for (; i < l; i++) {
283 | obj[i].apply(this, args);
284 | }
285 | };
286 |
287 | EventEmitter.prototype.listeners = function (type) {
288 | return this._events[type] = this._events[type] || [];
289 | };
290 |
291 | exports.EventEmitter = EventEmitter;
292 |
293 | },{}],3:[function(_dereq_,module,exports){
294 | 'use strict';
295 |
296 | Object.defineProperty(exports, "__esModule", {
297 | value: true
298 | });
299 | /**
300 | * xterm.js: xterm, in the browser
301 | * Copyright (c) 2014-2016, SourceLair Private Company (www.sourcelair.com (MIT License)
302 | */
303 |
304 | /**
305 | * Represents the viewport of a terminal, the visible area within the larger buffer of output.
306 | * Logic for the virtual scroll bar is included in this object.
307 | * @param {Terminal} terminal The Terminal object.
308 | * @param {HTMLElement} viewportElement The DOM element acting as the viewport
309 | * @param {HTMLElement} charMeasureElement A DOM element used to measure the character size of
310 | * the terminal.
311 | */
312 | function Viewport(terminal, viewportElement, scrollArea, charMeasureElement) {
313 | this.terminal = terminal;
314 | this.viewportElement = viewportElement;
315 | this.scrollArea = scrollArea;
316 | this.charMeasureElement = charMeasureElement;
317 | this.currentRowHeight = 0;
318 | this.lastRecordedBufferLength = 0;
319 | this.lastRecordedViewportHeight = 0;
320 |
321 | this.terminal.on('scroll', this.syncScrollArea.bind(this));
322 | this.terminal.on('resize', this.syncScrollArea.bind(this));
323 | this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
324 |
325 | this.syncScrollArea();
326 | }
327 |
328 | /**
329 | * Refreshes row height, setting line-height, viewport height and scroll area height if
330 | * necessary.
331 | * @param {number|undefined} charSize A character size measurement bounding rect object, if it
332 | * doesn't exist it will be created.
333 | */
334 | Viewport.prototype.refresh = function (charSize) {
335 | var size = charSize || this.charMeasureElement.getBoundingClientRect();
336 | if (size.height > 0) {
337 | var rowHeightChanged = size.height !== this.currentRowHeight;
338 | if (rowHeightChanged) {
339 | this.currentRowHeight = size.height;
340 | this.viewportElement.style.lineHeight = size.height + 'px';
341 | this.terminal.rowContainer.style.lineHeight = size.height + 'px';
342 | }
343 | var viewportHeightChanged = this.lastRecordedViewportHeight !== this.terminal.rows;
344 | if (rowHeightChanged || viewportHeightChanged) {
345 | this.lastRecordedViewportHeight = this.terminal.rows;
346 | this.viewportElement.style.height = size.height * this.terminal.rows + 'px';
347 | }
348 | this.scrollArea.style.height = size.height * this.lastRecordedBufferLength + 'px';
349 | }
350 | };
351 |
352 | /**
353 | * Updates dimensions and synchronizes the scroll area if necessary.
354 | */
355 | Viewport.prototype.syncScrollArea = function () {
356 | if (this.lastRecordedBufferLength !== this.terminal.lines.length) {
357 | // If buffer height changed
358 | this.lastRecordedBufferLength = this.terminal.lines.length;
359 | this.refresh();
360 | } else if (this.lastRecordedViewportHeight !== this.terminal.rows) {
361 | // If viewport height changed
362 | this.refresh();
363 | } else {
364 | // If size has changed, refresh viewport
365 | var size = this.charMeasureElement.getBoundingClientRect();
366 | if (size.height !== this.currentRowHeight) {
367 | this.refresh(size);
368 | }
369 | }
370 |
371 | // Sync scrollTop
372 | var scrollTop = this.terminal.ydisp * this.currentRowHeight;
373 | if (this.viewportElement.scrollTop !== scrollTop) {
374 | this.viewportElement.scrollTop = scrollTop;
375 | }
376 | };
377 |
378 | /**
379 | * Handles scroll events on the viewport, calculating the new viewport and requesting the
380 | * terminal to scroll to it.
381 | * @param {Event} ev The scroll event.
382 | */
383 | Viewport.prototype.onScroll = function (ev) {
384 | var newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
385 | var diff = newRow - this.terminal.ydisp;
386 | this.terminal.scrollDisp(diff, true);
387 | };
388 |
389 | /**
390 | * Handles mouse wheel events by adjusting the viewport's scrollTop and delegating the actual
391 | * scrolling to `onScroll`, this event needs to be attached manually by the consumer of
392 | * `Viewport`.
393 | * @param {WheelEvent} ev The mouse wheel event.
394 | */
395 | Viewport.prototype.onWheel = function (ev) {
396 | if (ev.deltaY === 0) {
397 | // Do nothing if it's not a vertical scroll event
398 | return;
399 | }
400 | // Fallback to WheelEvent.DOM_DELTA_PIXEL
401 | var multiplier = 1;
402 | if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
403 | multiplier = this.currentRowHeight;
404 | } else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
405 | multiplier = this.currentRowHeight * this.terminal.rows;
406 | }
407 | this.viewportElement.scrollTop += ev.deltaY * multiplier;
408 | // Prevent the page from scrolling when the terminal scrolls
409 | ev.preventDefault();
410 | };
411 |
412 | exports.Viewport = Viewport;
413 |
414 | },{}],4:[function(_dereq_,module,exports){
415 | 'use strict';
416 |
417 | Object.defineProperty(exports, "__esModule", {
418 | value: true
419 | });
420 | /**
421 | * xterm.js: xterm, in the browser
422 | * Copyright (c) 2016, SourceLair Private Company (MIT License)
423 | */
424 |
425 | /**
426 | * Clipboard handler module. This module contains methods for handling all
427 | * clipboard-related events appropriately in the terminal.
428 | * @module xterm/handlers/Clipboard
429 | */
430 |
431 | /**
432 | * Prepares text copied from terminal selection, to be saved in the clipboard by:
433 | * 1. stripping all trailing white spaces
434 | * 2. converting all non-breaking spaces to regular spaces
435 | * @param {string} text The copied text that needs processing for storing in clipboard
436 | * @returns {string}
437 | */
438 | function prepareTextForClipboard(text) {
439 | var space = String.fromCharCode(32),
440 | nonBreakingSpace = String.fromCharCode(160),
441 | allNonBreakingSpaces = new RegExp(nonBreakingSpace, 'g'),
442 | processedText = text.split('\n').map(function (line) {
443 | // Strip all trailing white spaces and convert all non-breaking spaces
444 | // to regular spaces.
445 | var processedLine = line.replace(/\s+$/g, '').replace(allNonBreakingSpaces, space);
446 |
447 | return processedLine;
448 | }).join('\n');
449 |
450 | return processedText;
451 | }
452 |
453 | /**
454 | * Binds copy functionality to the given terminal.
455 | * @param {ClipboardEvent} ev The original copy event to be handled
456 | */
457 | function copyHandler(ev, term) {
458 | var copiedText = window.getSelection().toString(),
459 | text = prepareTextForClipboard(copiedText);
460 |
461 | if (term.browser.isMSIE) {
462 | window.clipboardData.setData('Text', text);
463 | } else {
464 | ev.clipboardData.setData('text/plain', text);
465 | }
466 |
467 | ev.preventDefault(); // Prevent or the original text will be copied.
468 | }
469 |
470 | /**
471 | * Redirect the clipboard's data to the terminal's input handler.
472 | * @param {ClipboardEvent} ev The original paste event to be handled
473 | * @param {Terminal} term The terminal on which to apply the handled paste event
474 | */
475 | function pasteHandler(ev, term) {
476 | ev.stopPropagation();
477 |
478 | var dispatchPaste = function dispatchPaste(text) {
479 | term.handler(text);
480 | term.textarea.value = '';
481 | return term.cancel(ev);
482 | };
483 |
484 | if (term.browser.isMSIE) {
485 | if (window.clipboardData) {
486 | var text = window.clipboardData.getData('Text');
487 | dispatchPaste(text);
488 | }
489 | } else {
490 | if (ev.clipboardData) {
491 | var text = ev.clipboardData.getData('text/plain');
492 | dispatchPaste(text);
493 | }
494 | }
495 | }
496 |
497 | /**
498 | * Bind to right-click event and allow right-click copy and paste.
499 | *
500 | * **Logic**
501 | * If text is selected and right-click happens on selected text, then
502 | * do nothing to allow seamless copying.
503 | * If no text is selected or right-click is outside of the selection
504 | * area, then bring the terminal's input below the cursor, in order to
505 | * trigger the event on the textarea and allow-right click paste, without
506 | * caring about disappearing selection.
507 | * @param {ClipboardEvent} ev The original paste event to be handled
508 | * @param {Terminal} term The terminal on which to apply the handled paste event
509 | */
510 | function rightClickHandler(ev, term) {
511 | var s = document.getSelection(),
512 | selectedText = prepareTextForClipboard(s.toString()),
513 | clickIsOnSelection = false;
514 |
515 | if (s.rangeCount) {
516 | var r = s.getRangeAt(0),
517 | cr = r.getClientRects(),
518 | x = ev.clientX,
519 | y = ev.clientY,
520 | i,
521 | rect;
522 |
523 | for (i = 0; i < cr.length; i++) {
524 | rect = cr[i];
525 | clickIsOnSelection = x > rect.left && x < rect.right && y > rect.top && y < rect.bottom;
526 |
527 | if (clickIsOnSelection) {
528 | break;
529 | }
530 | }
531 | // If we clicked on selection and selection is not a single space,
532 | // then mark the right click as copy-only. We check for the single
533 | // space selection, as this can happen when clicking on an
534 | // and there is not much pointing in copying a single space.
535 | if (selectedText.match(/^\s$/) || !selectedText.length) {
536 | clickIsOnSelection = false;
537 | }
538 | }
539 |
540 | // Bring textarea at the cursor position
541 | if (!clickIsOnSelection) {
542 | term.textarea.style.position = 'fixed';
543 | term.textarea.style.width = '20px';
544 | term.textarea.style.height = '20px';
545 | term.textarea.style.left = x - 10 + 'px';
546 | term.textarea.style.top = y - 10 + 'px';
547 | term.textarea.style.zIndex = 1000;
548 | term.textarea.focus();
549 |
550 | // Reset the terminal textarea's styling
551 | setTimeout(function () {
552 | term.textarea.style.position = null;
553 | term.textarea.style.width = null;
554 | term.textarea.style.height = null;
555 | term.textarea.style.left = null;
556 | term.textarea.style.top = null;
557 | term.textarea.style.zIndex = null;
558 | }, 4);
559 | }
560 | }
561 |
562 | exports.prepareTextForClipboard = prepareTextForClipboard;
563 | exports.copyHandler = copyHandler;
564 | exports.pasteHandler = pasteHandler;
565 | exports.rightClickHandler = rightClickHandler;
566 |
567 | },{}],5:[function(_dereq_,module,exports){
568 | 'use strict';
569 |
570 | Object.defineProperty(exports, "__esModule", {
571 | value: true
572 | });
573 | exports.isMSWindows = exports.isIphone = exports.isIpad = exports.isMac = exports.isMSIE = exports.isFirefox = undefined;
574 |
575 | var _Generic = _dereq_('./Generic.js');
576 |
577 | var isNode = typeof navigator == 'undefined' ? true : false; /**
578 | * xterm.js: xterm, in the browser
579 | * Copyright (c) 2016, SourceLair Private Company (MIT License)
580 | */
581 |
582 | /**
583 | * Browser utilities module. This module contains attributes and methods to help with
584 | * identifying the current browser and platform.
585 | * @module xterm/utils/Browser
586 | */
587 |
588 | var userAgent = isNode ? 'node' : navigator.userAgent;
589 | var platform = isNode ? 'node' : navigator.platform;
590 |
591 | var isFirefox = exports.isFirefox = !!~userAgent.indexOf('Firefox');
592 | var isMSIE = exports.isMSIE = !!~userAgent.indexOf('MSIE') || !!~userAgent.indexOf('Trident');
593 |
594 | // Find the users platform. We use this to interpret the meta key
595 | // and ISO third level shifts.
596 | // http://stackoverflow.com/q/19877924/577598
597 | var isMac = exports.isMac = (0, _Generic.contains)(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);
598 | var isIpad = exports.isIpad = platform === 'iPad';
599 | var isIphone = exports.isIphone = platform === 'iPhone';
600 | var isMSWindows = exports.isMSWindows = (0, _Generic.contains)(['Windows', 'Win16', 'Win32', 'WinCE'], platform);
601 |
602 | },{"./Generic.js":6}],6:[function(_dereq_,module,exports){
603 | "use strict";
604 |
605 | Object.defineProperty(exports, "__esModule", {
606 | value: true
607 | });
608 | /**
609 | * xterm.js: xterm, in the browser
610 | * Copyright (c) 2016, SourceLair Private Company (MIT License)
611 | */
612 |
613 | /**
614 | * Generic utilities module. This module contains generic methods that can be helpful at
615 | * different parts of the code base.
616 | * @module xterm/utils/Generic
617 | */
618 |
619 | /**
620 | * Return if the given array contains the given element
621 | * @param {Array} array The array to search for the given element.
622 | * @param {Object} el The element to look for into the array
623 | */
624 | var contains = exports.contains = function contains(arr, el) {
625 | return arr.indexOf(el) >= 0;
626 | };
627 |
628 | },{}],7:[function(_dereq_,module,exports){
629 | 'use strict';var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};/**
630 | * xterm.js: xterm, in the browser
631 | * Copyright (c) 2014-2014, SourceLair Private Company (MIT License)
632 | * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
633 | * https://github.com/chjj/term.js
634 | *
635 | * Permission is hereby granted, free of charge, to any person obtaining a copy
636 | * of this software and associated documentation files (the "Software"), to deal
637 | * in the Software without restriction, including without limitation the rights
638 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
639 | * copies of the Software, and to permit persons to whom the Software is
640 | * furnished to do so, subject to the following conditions:
641 | *
642 | * The above copyright notice and this permission notice shall be included in
643 | * all copies or substantial portions of the Software.
644 | *
645 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
646 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
647 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
648 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
649 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
650 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
651 | * THE SOFTWARE.
652 | *
653 | * Originally forked from (with the author's permission):
654 | * Fabrice Bellard's javascript vt100 for jslinux:
655 | * http://bellard.org/jslinux/
656 | * Copyright (c) 2011 Fabrice Bellard
657 | * The original design remains. The terminal itself
658 | * has been extended to include xterm CSI codes, among
659 | * other features.
660 | */var _CompositionHelper=_dereq_('./CompositionHelper.js');var _EventEmitter=_dereq_('./EventEmitter.js');var _Viewport=_dereq_('./Viewport.js');var _Clipboard=_dereq_('./handlers/Clipboard.js');var _Browser=_dereq_('./utils/Browser');var Browser=_interopRequireWildcard(_Browser);function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj;}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key];}}newObj.default=obj;return newObj;}}/**
661 | * Terminal Emulation References:
662 | * http://vt100.net/
663 | * http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt
664 | * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
665 | * http://invisible-island.net/vttest/
666 | * http://www.inwap.com/pdp10/ansicode.txt
667 | * http://linux.die.net/man/4/console_codes
668 | * http://linux.die.net/man/7/urxvt
669 | */// Let it work inside Node.js for automated testing purposes.
670 | var document=typeof window!='undefined'?window.document:null;/**
671 | * States
672 | */var normal=0,escaped=1,csi=2,osc=3,charset=4,dcs=5,ignore=6;/**
673 | * Terminal
674 | *//**
675 | * Creates a new `Terminal` object.
676 | *
677 | * @param {object} options An object containing a set of options, the available options are:
678 | * - `cursorBlink` (boolean): Whether the terminal cursor blinks
679 | * - `cols` (number): The number of columns of the terminal (horizontal size)
680 | * - `rows` (number): The number of rows of the terminal (vertical size)
681 | *
682 | * @public
683 | * @class Xterm Xterm
684 | * @alias module:xterm/src/xterm
685 | */function Terminal(options){var self=this;if(!(this instanceof Terminal)){return new Terminal(arguments[0],arguments[1],arguments[2]);}self.browser=Browser;self.cancel=Terminal.cancel;_EventEmitter.EventEmitter.call(this);if(typeof options==='number'){options={cols:arguments[0],rows:arguments[1],handler:arguments[2]};}options=options||{};Object.keys(Terminal.defaults).forEach(function(key){if(options[key]==null){options[key]=Terminal.options[key];if(Terminal[key]!==Terminal.defaults[key]){options[key]=Terminal[key];}}self[key]=options[key];});if(options.colors.length===8){options.colors=options.colors.concat(Terminal._colors.slice(8));}else if(options.colors.length===16){options.colors=options.colors.concat(Terminal._colors.slice(16));}else if(options.colors.length===10){options.colors=options.colors.slice(0,-2).concat(Terminal._colors.slice(8,-2),options.colors.slice(-2));}else if(options.colors.length===18){options.colors=options.colors.concat(Terminal._colors.slice(16,-2),options.colors.slice(-2));}this.colors=options.colors;this.options=options;// this.context = options.context || window;
686 | // this.document = options.document || document;
687 | this.parent=options.body||options.parent||(document?document.getElementsByTagName('body')[0]:null);this.cols=options.cols||options.geometry[0];this.rows=options.rows||options.geometry[1];this.geometry=[this.cols,this.rows];if(options.handler){this.on('data',options.handler);}/**
688 | * The scroll position of the y cursor, ie. ybase + y = the y position within the entire
689 | * buffer
690 | */this.ybase=0;/**
691 | * The scroll position of the viewport
692 | */this.ydisp=0;/**
693 | * The cursor's x position after ybase
694 | */this.x=0;/**
695 | * The cursor's y position after ybase
696 | */this.y=0;/**
697 | * Used to debounce the refresh function
698 | */this.isRefreshing=false;/**
699 | * Whether there is a full terminal refresh queued
700 | */this.cursorState=0;this.cursorHidden=false;this.convertEol;this.state=0;this.queue='';this.scrollTop=0;this.scrollBottom=this.rows-1;this.customKeydownHandler=null;// modes
701 | this.applicationKeypad=false;this.applicationCursor=false;this.originMode=false;this.insertMode=false;this.wraparoundMode=true;// defaults: xterm - true, vt100 - false
702 | this.normal=null;// charset
703 | this.charset=null;this.gcharset=null;this.glevel=0;this.charsets=[null];// mouse properties
704 | this.decLocator;this.x10Mouse;this.vt200Mouse;this.vt300Mouse;this.normalMouse;this.mouseEvents;this.sendFocus;this.utfMouse;this.sgrMouse;this.urxvtMouse;// misc
705 | this.element;this.children;this.refreshStart;this.refreshEnd;this.savedX;this.savedY;this.savedCols;// stream
706 | this.readable=true;this.writable=true;this.defAttr=0<<18|257<<9|256<<0;this.curAttr=this.defAttr;this.params=[];this.currentParam=0;this.prefix='';this.postfix='';// leftover surrogate high from previous write invocation
707 | this.surrogate_high='';/**
708 | * An array of all lines in the entire buffer, including the prompt. The lines are array of
709 | * characters which are 2-length arrays where [0] is an attribute and [1] is the character.
710 | */this.lines=[];var i=this.rows;while(i--){this.lines.push(this.blankLine());}this.tabs;this.setupStops();// Store if user went browsing history in scrollback
711 | this.userScrolling=false;}inherits(Terminal,_EventEmitter.EventEmitter);/**
712 | * back_color_erase feature for xterm.
713 | */Terminal.prototype.eraseAttr=function(){// if (this.is('screen')) return this.defAttr;
714 | return this.defAttr&~0x1ff|this.curAttr&0x1ff;};/**
715 | * Colors
716 | */// Colors 0-15
717 | Terminal.tangoColors=[// dark:
718 | '#2e3436','#cc0000','#4e9a06','#c4a000','#3465a4','#75507b','#06989a','#d3d7cf',// bright:
719 | '#555753','#ef2929','#8ae234','#fce94f','#729fcf','#ad7fa8','#34e2e2','#eeeeec'];// Colors 0-15 + 16-255
720 | // Much thanks to TooTallNate for writing this.
721 | Terminal.colors=function(){var colors=Terminal.tangoColors.slice(),r=[0x00,0x5f,0x87,0xaf,0xd7,0xff],i;// 16-231
722 | i=0;for(;i<216;i++){out(r[i/36%6|0],r[i/6%6|0],r[i%6]);}// 232-255 (grey)
723 | i=0;for(;i<24;i++){r=8+i*10;out(r,r,r);}function out(r,g,b){colors.push('#'+hex(r)+hex(g)+hex(b));}function hex(c){c=c.toString(16);return c.length<2?'0'+c:c;}return colors;}();Terminal._colors=Terminal.colors.slice();Terminal.vcolors=function(){var out=[],colors=Terminal.colors,i=0,color;for(;i<256;i++){color=parseInt(colors[i].substring(1),16);out.push([color>>16&0xff,color>>8&0xff,color&0xff]);}return out;}();/**
724 | * Options
725 | */Terminal.defaults={colors:Terminal.colors,theme:'default',convertEol:false,termName:'xterm',geometry:[80,24],cursorBlink:false,visualBell:false,popOnBell:false,scrollback:1000,screenKeys:false,debug:false,cancelEvents:false// programFeatures: false,
726 | // focusKeys: false,
727 | };Terminal.options={};Terminal.focus=null;each(keys(Terminal.defaults),function(key){Terminal[key]=Terminal.defaults[key];Terminal.options[key]=Terminal.defaults[key];});/**
728 | * Focus the terminal. Delegates focus handling to the terminal's DOM element.
729 | */Terminal.prototype.focus=function(){return this.textarea.focus();};/**
730 | * Retrieves an option's value from the terminal.
731 | * @param {string} key The option key.
732 | */Terminal.prototype.getOption=function(key,value){if(!(key in Terminal.defaults)){throw new Error('No option with key "'+key+'"');}if(typeof this.options[key]!=='undefined'){return this.options[key];}return this[key];};/**
733 | * Sets an option on the terminal.
734 | * @param {string} key The option key.
735 | * @param {string} value The option value.
736 | */Terminal.prototype.setOption=function(key,value){if(!(key in Terminal.defaults)){throw new Error('No option with key "'+key+'"');}this[key]=value;this.options[key]=value;};/**
737 | * Binds the desired focus behavior on a given terminal object.
738 | *
739 | * @static
740 | */Terminal.bindFocus=function(term){on(term.textarea,'focus',function(ev){if(term.sendFocus){term.send('\x1b[I');}term.element.classList.add('focus');term.showCursor();Terminal.focus=term;term.emit('focus',{terminal:term});});};/**
741 | * Blur the terminal. Delegates blur handling to the terminal's DOM element.
742 | */Terminal.prototype.blur=function(){return this.textarea.blur();};/**
743 | * Binds the desired blur behavior on a given terminal object.
744 | *
745 | * @static
746 | */Terminal.bindBlur=function(term){on(term.textarea,'blur',function(ev){term.refresh(term.y,term.y);if(term.sendFocus){term.send('\x1b[O');}term.element.classList.remove('focus');Terminal.focus=null;term.emit('blur',{terminal:term});});};/**
747 | * Initialize default behavior
748 | */Terminal.prototype.initGlobal=function(){var term=this;Terminal.bindKeys(this);Terminal.bindFocus(this);Terminal.bindBlur(this);// Bind clipboard functionality
749 | on(this.element,'copy',function(ev){_Clipboard.copyHandler.call(this,ev,term);});on(this.textarea,'paste',function(ev){_Clipboard.pasteHandler.call(this,ev,term);});function rightClickHandlerWrapper(ev){_Clipboard.rightClickHandler.call(this,ev,term);}if(term.browser.isFirefox){on(this.element,'mousedown',function(ev){if(ev.button==2){rightClickHandlerWrapper(ev);}});}else{on(this.element,'contextmenu',rightClickHandlerWrapper);}};/**
750 | * Apply key handling to the terminal
751 | */Terminal.bindKeys=function(term){on(term.element,'keydown',function(ev){if(document.activeElement!=this){return;}term.keyDown(ev);},true);on(term.element,'keypress',function(ev){if(document.activeElement!=this){return;}term.keyPress(ev);},true);on(term.element,'keyup',term.focus.bind(term));on(term.textarea,'keydown',function(ev){term.keyDown(ev);},true);on(term.textarea,'keypress',function(ev){term.keyPress(ev);// Truncate the textarea's value, since it is not needed
752 | this.value='';},true);on(term.textarea,'compositionstart',term.compositionHelper.compositionstart.bind(term.compositionHelper));on(term.textarea,'compositionupdate',term.compositionHelper.compositionupdate.bind(term.compositionHelper));on(term.textarea,'compositionend',term.compositionHelper.compositionend.bind(term.compositionHelper));term.on('refresh',term.compositionHelper.updateCompositionElements.bind(term.compositionHelper));};/**
753 | * Insert the given row to the terminal or produce a new one
754 | * if no row argument is passed. Return the inserted row.
755 | * @param {HTMLElement} row (optional) The row to append to the terminal.
756 | */Terminal.prototype.insertRow=function(row){if((typeof row==='undefined'?'undefined':_typeof(row))!='object'){row=document.createElement('div');}this.rowContainer.appendChild(row);this.children.push(row);return row;};/**
757 | * Opens the terminal within an element.
758 | *
759 | * @param {HTMLElement} parent The element to create the terminal within.
760 | */Terminal.prototype.open=function(parent){var self=this,i=0,div;this.parent=parent||this.parent;if(!this.parent){throw new Error('Terminal requires a parent element.');}// Grab global elements
761 | this.context=this.parent.ownerDocument.defaultView;this.document=this.parent.ownerDocument;this.body=this.document.getElementsByTagName('body')[0];//Create main element container
762 | this.element=this.document.createElement('div');this.element.classList.add('terminal');this.element.classList.add('xterm');this.element.classList.add('xterm-theme-'+this.theme);this.element.style.height;this.element.setAttribute('tabindex',0);this.viewportElement=document.createElement('div');this.viewportElement.classList.add('xterm-viewport');this.element.appendChild(this.viewportElement);this.viewportScrollArea=document.createElement('div');this.viewportScrollArea.classList.add('xterm-scroll-area');this.viewportElement.appendChild(this.viewportScrollArea);// Create the container that will hold the lines of the terminal and then
763 | // produce the lines the lines.
764 | this.rowContainer=document.createElement('div');this.rowContainer.classList.add('xterm-rows');this.element.appendChild(this.rowContainer);this.children=[];// Create the container that will hold helpers like the textarea for
765 | // capturing DOM Events. Then produce the helpers.
766 | this.helperContainer=document.createElement('div');this.helperContainer.classList.add('xterm-helpers');// TODO: This should probably be inserted once it's filled to prevent an additional layout
767 | this.element.appendChild(this.helperContainer);this.textarea=document.createElement('textarea');this.textarea.classList.add('xterm-helper-textarea');this.textarea.setAttribute('autocorrect','off');this.textarea.setAttribute('autocapitalize','off');this.textarea.setAttribute('spellcheck','false');this.textarea.tabIndex=0;this.textarea.addEventListener('focus',function(){self.emit('focus',{terminal:self});});this.textarea.addEventListener('blur',function(){self.emit('blur',{terminal:self});});this.helperContainer.appendChild(this.textarea);this.compositionView=document.createElement('div');this.compositionView.classList.add('composition-view');this.compositionHelper=new _CompositionHelper.CompositionHelper(this.textarea,this.compositionView,this);this.helperContainer.appendChild(this.compositionView);this.charMeasureElement=document.createElement('div');this.charMeasureElement.classList.add('xterm-char-measure-element');this.charMeasureElement.innerHTML='W';this.helperContainer.appendChild(this.charMeasureElement);for(;i
793 | function sendButton(ev){var button,pos;// get the xterm-style button
794 | button=getButton(ev);// get mouse coordinates
795 | pos=getCoords(ev);if(!pos)return;sendEvent(button,pos);switch(ev.overrideType||ev.type){case'mousedown':pressed=button;break;case'mouseup':// keep it at the left
796 | // button, just in case.
797 | pressed=32;break;case'wheel':// nothing. don't
798 | // interfere with
799 | // `pressed`.
800 | break;}}// motion example of a left click:
801 | // ^[[M 3<^[[M@4<^[[M@5<^[[M@6<^[[M@7<^[[M#7<
802 | function sendMove(ev){var button=pressed,pos;pos=getCoords(ev);if(!pos)return;// buttons marked as motions
803 | // are incremented by 32
804 | button+=32;sendEvent(button,pos);}// encode button and
805 | // position to characters
806 | function encode(data,ch){if(!self.utfMouse){if(ch===255)return data.push(0);if(ch>127)ch=127;data.push(ch);}else{if(ch===2047)return data.push(0);if(ch<127){data.push(ch);}else{if(ch>2047)ch=2047;data.push(0xC0|ch>>6);data.push(0x80|ch&0x3F);}}}// send a mouse event:
807 | // regular/utf8: ^[[M Cb Cx Cy
808 | // urxvt: ^[[ Cb ; Cx ; Cy M
809 | // sgr: ^[[ Cb ; Cx ; Cy M/m
810 | // vt300: ^[[ 24(1/3/5)~ [ Cx , Cy ] \r
811 | // locator: CSI P e ; P b ; P r ; P c ; P p & w
812 | function sendEvent(button,pos){// self.emit('mouse', {
813 | // x: pos.x - 32,
814 | // y: pos.x - 32,
815 | // button: button
816 | // });
817 | if(self.vt300Mouse){// NOTE: Unstable.
818 | // http://www.vt100.net/docs/vt3xx-gp/chapter15.html
819 | button&=3;pos.x-=32;pos.y-=32;var data='\x1b[24';if(button===0)data+='1';else if(button===1)data+='3';else if(button===2)data+='5';else if(button===3)return;else data+='0';data+='~['+pos.x+','+pos.y+']\r';self.send(data);return;}if(self.decLocator){// NOTE: Unstable.
820 | button&=3;pos.x-=32;pos.y-=32;if(button===0)button=2;else if(button===1)button=4;else if(button===2)button=6;else if(button===3)button=3;self.send('\x1b['+button+';'+(button===3?4:0)+';'+pos.y+';'+pos.x+';'+(pos.page||0)+'&w');return;}if(self.urxvtMouse){pos.x-=32;pos.y-=32;pos.x++;pos.y++;self.send('\x1b['+button+';'+pos.x+';'+pos.y+'M');return;}if(self.sgrMouse){pos.x-=32;pos.y-=32;self.send('\x1b[<'+((button&3)===3?button&~3:button)+';'+pos.x+';'+pos.y+((button&3)===3?'m':'M'));return;}var data=[];encode(data,button);encode(data,pos.x);encode(data,pos.y);self.send('\x1b[M'+String.fromCharCode.apply(String,data));}function getButton(ev){var button,shift,meta,ctrl,mod;// two low bits:
821 | // 0 = left
822 | // 1 = middle
823 | // 2 = right
824 | // 3 = release
825 | // wheel up/down:
826 | // 1, and 2 - with 64 added
827 | switch(ev.overrideType||ev.type){case'mousedown':button=ev.button!=null?+ev.button:ev.which!=null?ev.which-1:null;if(self.browser.isMSIE){button=button===1?0:button===4?1:button;}break;case'mouseup':button=3;break;case'DOMMouseScroll':button=ev.detail<0?64:65;break;case'wheel':button=ev.wheelDeltaY>0?64:65;break;}// next three bits are the modifiers:
828 | // 4 = shift, 8 = meta, 16 = control
829 | shift=ev.shiftKey?4:0;meta=ev.metaKey?8:0;ctrl=ev.ctrlKey?16:0;mod=shift|meta|ctrl;// no mods
830 | if(self.vt200Mouse){// ctrl only
831 | mod&=ctrl;}else if(!self.normalMouse){mod=0;}// increment to SP
832 | button=32+(mod<<2)+button;return button;}// mouse coordinates measured in cols/rows
833 | function getCoords(ev){var x,y,w,h,el;// ignore browsers without pageX for now
834 | if(ev.pageX==null)return;x=ev.pageX;y=ev.pageY;el=self.element;// should probably check offsetParent
835 | // but this is more portable
836 | while(el&&el!==self.document.documentElement){x-=el.offsetLeft;y-=el.offsetTop;el='offsetParent'in el?el.offsetParent:el.parentNode;}// convert to cols/rows
837 | w=self.element.clientWidth;h=self.element.clientHeight;x=Math.ceil(x/w*self.cols);y=Math.ceil(y/h*self.rows);// be sure to avoid sending
838 | // bad positions to the program
839 | if(x<0)x=0;if(x>self.cols)x=self.cols;if(y<0)y=0;if(y>self.rows)y=self.rows;// xterm sends raw bytes and
840 | // starts at 32 (SP) for each.
841 | x+=32;y+=32;return{x:x,y:y,type:'wheel'};}on(el,'mousedown',function(ev){if(!self.mouseEvents)return;// send the button
842 | sendButton(ev);// ensure focus
843 | self.focus();// fix for odd bug
844 | //if (self.vt200Mouse && !self.normalMouse) {
845 | if(self.vt200Mouse){ev.overrideType='mouseup';sendButton(ev);return self.cancel(ev);}// bind events
846 | if(self.normalMouse)on(self.document,'mousemove',sendMove);// x10 compatibility mode can't send button releases
847 | if(!self.x10Mouse){on(self.document,'mouseup',function up(ev){sendButton(ev);if(self.normalMouse)off(self.document,'mousemove',sendMove);off(self.document,'mouseup',up);return self.cancel(ev);});}return self.cancel(ev);});//if (self.normalMouse) {
848 | // on(self.document, 'mousemove', sendMove);
849 | //}
850 | on(el,'wheel',function(ev){if(!self.mouseEvents)return;if(self.x10Mouse||self.vt300Mouse||self.decLocator)return;sendButton(ev);return self.cancel(ev);});// allow wheel scrolling in
851 | // the shell for example
852 | on(el,'wheel',function(ev){if(self.mouseEvents)return;self.viewport.onWheel(ev);return self.cancel(ev);});};/**
853 | * Destroys the terminal.
854 | */Terminal.prototype.destroy=function(){this.readable=false;this.writable=false;this._events={};this.handler=function(){};this.write=function(){};if(this.element.parentNode){this.element.parentNode.removeChild(this.element);}//this.emit('close');
855 | };/**
856 | * Flags used to render terminal text properly
857 | */Terminal.flags={BOLD:1,UNDERLINE:2,BLINK:4,INVERSE:8,INVISIBLE:16};/**
858 | * Refreshes (re-renders) terminal content within two rows (inclusive)
859 | *
860 | * Rendering Engine:
861 | *
862 | * In the screen buffer, each character is stored as a an array with a character
863 | * and a 32-bit integer:
864 | * - First value: a utf-16 character.
865 | * - Second value:
866 | * - Next 9 bits: background color (0-511).
867 | * - Next 9 bits: foreground color (0-511).
868 | * - Next 14 bits: a mask for misc. flags:
869 | * - 1=bold
870 | * - 2=underline
871 | * - 4=blink
872 | * - 8=inverse
873 | * - 16=invisible
874 | *
875 | * @param {number} start The row to start from (between 0 and terminal's height terminal - 1)
876 | * @param {number} end The row to end at (between fromRow and terminal's height terminal - 1)
877 | * @param {boolean} queue Whether the refresh should ran right now or be queued
878 | */Terminal.prototype.refresh=function(start,end,queue){var self=this;// queue defaults to true
879 | queue=typeof queue=='undefined'?true:queue;/**
880 | * The refresh queue allows refresh to execute only approximately 30 times a second. For
881 | * commands that pass a significant amount of output to the write function, this prevents the
882 | * terminal from maxing out the CPU and making the UI unresponsive. While commands can still
883 | * run beyond what they do on the terminal, it is far better with a debounce in place as
884 | * every single terminal manipulation does not need to be constructed in the DOM.
885 | *
886 | * A side-effect of this is that it makes ^C to interrupt a process seem more responsive.
887 | */if(queue){// If refresh should be queued, order the refresh and return.
888 | if(this._refreshIsQueued){// If a refresh has already been queued, just order a full refresh next
889 | this._fullRefreshNext=true;}else{setTimeout(function(){self.refresh(start,end,false);},34);this._refreshIsQueued=true;}return;}// If refresh should be run right now (not be queued), release the lock
890 | this._refreshIsQueued=false;// If multiple refreshes were requested, make a full refresh.
891 | if(this._fullRefreshNext){start=0;end=this.rows-1;this._fullRefreshNext=false;// reset lock
892 | }var x,y,i,line,out,ch,ch_width,width,data,attr,bg,fg,flags,row,parent,focused=document.activeElement;// If this is a big refresh, remove the terminal rows from the DOM for faster calculations
893 | if(end-start>=this.rows/2){parent=this.element.parentNode;if(parent){this.element.removeChild(this.rowContainer);}}width=this.cols;y=start;if(end>=this.rows.length){this.log('`end` is too large. Most likely a bad CSR.');end=this.rows.length-1;}for(;y<=end;y++){row=y+this.ydisp;line=this.lines[row];out='';if(this.y===y-(this.ybase-this.ydisp)&&this.cursorState&&!this.cursorHidden){x=this.x;}else{x=-1;}attr=this.defAttr;i=0;for(;i';}if(data!==this.defAttr){if(data===-1){out+='';}else{var classNames=[];bg=data&0x1ff;fg=data>>9&0x1ff;flags=data>>18;if(flags&Terminal.flags.BOLD){if(!Terminal.brokenBold){classNames.push('xterm-bold');}// See: XTerm*boldColors
894 | if(fg<8)fg+=8;}if(flags&Terminal.flags.UNDERLINE){classNames.push('xterm-underline');}if(flags&Terminal.flags.BLINK){classNames.push('xterm-blink');}// If inverse flag is on, then swap the foreground and background variables.
895 | if(flags&Terminal.flags.INVERSE){/* One-line variable swap in JavaScript: http://stackoverflow.com/a/16201730 */bg=[fg,fg=bg][0];// Should inverse just be before the
896 | // above boldColors effect instead?
897 | if(flags&1&&fg<8)fg+=8;}if(flags&Terminal.flags.INVISIBLE){classNames.push('xterm-hidden');}/**
898 | * Weird situation: Invert flag used black foreground and white background results
899 | * in invalid background color, positioned at the 256 index of the 256 terminal
900 | * color map. Pin the colors manually in such a case.
901 | *
902 | * Source: https://github.com/sourcelair/xterm.js/issues/57
903 | */if(flags&Terminal.flags.INVERSE){if(bg==257){bg=15;}if(fg==256){fg=0;}}if(bg<256){classNames.push('xterm-bg-color-'+bg);}if(fg<256){classNames.push('xterm-color-'+fg);}out+='';}}}switch(ch){case'&':out+='&';break;case'<':out+='<';break;case'>':out+='>';break;default:if(ch<=' '){out+=' ';}else{out+=ch;}break;}attr=data;}if(attr!==this.defAttr){out+='';}this.children[y].innerHTML=out;}if(parent){this.element.appendChild(this.rowContainer);}this.emit('refresh',{element:this.element,start:start,end:end});};/**
904 | * Display the cursor element
905 | */Terminal.prototype.showCursor=function(){if(!this.cursorState){this.cursorState=1;this.refresh(this.y,this.y);}};/**
906 | * Scroll the terminal
907 | */Terminal.prototype.scroll=function(){var row;if(++this.ybase===this.scrollback){this.ybase=this.ybase/2|0;this.lines=this.lines.slice(-(this.ybase+this.rows)+1);}if(!this.userScrolling){this.ydisp=this.ybase;}// last line
908 | row=this.ybase+this.rows-1;// subtract the bottom scroll region
909 | row-=this.rows-1-this.scrollBottom;if(row===this.lines.length){// potential optimization:
910 | // pushing is faster than splicing
911 | // when they amount to the same
912 | // behavior.
913 | this.lines.push(this.blankLine());}else{// add our new line
914 | this.lines.splice(row,0,this.blankLine());}if(this.scrollTop!==0){if(this.ybase!==0){this.ybase--;if(!this.userScrolling){this.ydisp=this.ybase;}}this.lines.splice(this.ybase+this.scrollTop,1);}// this.maxRange();
915 | this.updateRange(this.scrollTop);this.updateRange(this.scrollBottom);this.emit('scroll',this.ydisp);};/**
916 | * Scroll the display of the terminal
917 | * @param {number} disp The number of lines to scroll down (negatives scroll up).
918 | * @param {boolean} suppressScrollEvent Don't emit the scroll event as scrollDisp. This is used
919 | * to avoid unwanted events being handled by the veiwport when the event was triggered from the
920 | * viewport originally.
921 | */Terminal.prototype.scrollDisp=function(disp,suppressScrollEvent){if(disp<0){this.userScrolling=true;}else if(disp+this.ydisp>=this.ybase){this.userScrolling=false;}this.ydisp+=disp;if(this.ydisp>this.ybase){this.ydisp=this.ybase;}else if(this.ydisp<0){this.ydisp=0;}if(!suppressScrollEvent){this.emit('scroll',this.ydisp);}this.refresh(0,this.rows-1);};/**
922 | * Scroll the display of the terminal by a number of pages.
923 | * @param {number} pageCount The number of pages to scroll (negative scrolls up).
924 | */Terminal.prototype.scrollPages=function(pageCount){this.scrollDisp(pageCount*(this.rows-1));};/**
925 | * Scrolls the display of the terminal to the top.
926 | */Terminal.prototype.scrollToTop=function(){this.scrollDisp(-this.ydisp);};/**
927 | * Scrolls the display of the terminal to the bottom.
928 | */Terminal.prototype.scrollToBottom=function(){this.scrollDisp(this.ybase-this.ydisp);};/**
929 | * Writes text to the terminal.
930 | * @param {string} text The text to write to the terminal.
931 | */Terminal.prototype.write=function(data){var l=data.length,i=0,j,cs,ch,code,low,ch_width,row;this.refreshStart=this.y;this.refreshEnd=this.y;// apply leftover surrogate high from last write
932 | if(this.surrogate_high){data=this.surrogate_high+data;this.surrogate_high='';}for(;i maybe move to default
934 | code=data.charCodeAt(i);if(0xD800<=code&&code<=0xDBFF){// we got a surrogate high
935 | // get surrogate low (next 2 bytes)
936 | low=data.charCodeAt(i+1);if(isNaN(low)){// end of data stream, save surrogate high
937 | this.surrogate_high=ch;continue;}code=(code-0xD800)*0x400+(low-0xDC00)+0x10000;ch+=data.charAt(i+1);}// surrogate low - already handled above
938 | if(0xDC00<=code&&code<=0xDFFF)continue;switch(this.state){case normal:switch(ch){case'\x07':this.bell();break;// '\n', '\v', '\f'
939 | case'\n':case'\x0b':case'\x0c':if(this.convertEol){this.x=0;}this.y++;if(this.y>this.scrollBottom){this.y--;this.scroll();}break;// '\r'
940 | case'\r':this.x=0;break;// '\b'
941 | case'\x08':if(this.x>0){this.x--;}break;// '\t'
942 | case'\t':this.x=this.nextStop();break;// shift out
943 | case'\x0e':this.setgLevel(1);break;// shift in
944 | case'\x0f':this.setgLevel(0);break;// '\e'
945 | case'\x1b':this.state=escaped;break;default:// ' '
946 | // calculate print space
947 | // expensive call, therefore we save width in line buffer
948 | ch_width=wcwidth(code);if(ch>=' '){if(this.charset&&this.charset[ch]){ch=this.charset[ch];}row=this.y+this.ybase;// insert combining char in last cell
949 | // FIXME: needs handling after cursor jumps
950 | if(!ch_width&&this.x){// dont overflow left
951 | if(this.lines[row][this.x-1]){if(!this.lines[row][this.x-1][2]){// found empty cell after fullwidth, need to go 2 cells back
952 | if(this.lines[row][this.x-2])this.lines[row][this.x-2][1]+=ch;}else{this.lines[row][this.x-1][1]+=ch;}this.updateRange(this.y);}break;}// goto next line if ch would overflow
953 | // TODO: needs a global min terminal width of 2
954 | if(this.x+ch_width-1>=this.cols){// autowrap - DECAWM
955 | if(this.wraparoundMode){this.x=0;this.y++;if(this.y>this.scrollBottom){this.y--;this.scroll();}}else{this.x=this.cols-1;if(ch_width===2)// FIXME: check for xterm behavior
956 | continue;}}row=this.y+this.ybase;// insert mode: move characters to right
957 | if(this.insertMode){// do this twice for a fullwidth char
958 | for(var moves=0;moves Normal Keypad (DECKPNM).
1001 | case'>':this.log('Switching back to normal keypad.');this.applicationKeypad=false;this.viewport.syncScrollArea();this.state=normal;break;default:this.state=normal;this.error('Unknown ESC control: %s.',ch);break;}break;case charset:switch(ch){case'0':// DEC Special Character and Line Drawing Set.
1002 | cs=Terminal.charsets.SCLD;break;case'A':// UK
1003 | cs=Terminal.charsets.UK;break;case'B':// United States (USASCII).
1004 | cs=Terminal.charsets.US;break;case'4':// Dutch
1005 | cs=Terminal.charsets.Dutch;break;case'C':// Finnish
1006 | case'5':cs=Terminal.charsets.Finnish;break;case'R':// French
1007 | cs=Terminal.charsets.French;break;case'Q':// FrenchCanadian
1008 | cs=Terminal.charsets.FrenchCanadian;break;case'K':// German
1009 | cs=Terminal.charsets.German;break;case'Y':// Italian
1010 | cs=Terminal.charsets.Italian;break;case'E':// NorwegianDanish
1011 | case'6':cs=Terminal.charsets.NorwegianDanish;break;case'Z':// Spanish
1012 | cs=Terminal.charsets.Spanish;break;case'H':// Swedish
1013 | case'7':cs=Terminal.charsets.Swedish;break;case'=':// Swiss
1014 | cs=Terminal.charsets.Swiss;break;case'/':// ISOLatin (actually /A)
1015 | cs=Terminal.charsets.ISOLatin;i++;break;default:// Default
1016 | cs=Terminal.charsets.US;break;}this.setgCharset(this.gcharset,cs);this.gcharset=null;this.state=normal;break;case osc:// OSC Ps ; Pt ST
1017 | // OSC Ps ; Pt BEL
1018 | // Set Text Parameters.
1019 | if(ch==='\x1b'||ch==='\x07'){if(ch==='\x1b')i++;this.params.push(this.currentParam);switch(this.params[0]){case 0:case 1:case 2:if(this.params[1]){this.title=this.params[1];this.handleTitle(this.title);}break;case 3:// set X property
1020 | break;case 4:case 5:// change dynamic colors
1021 | 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
1022 | break;case 46:// change log file
1023 | break;case 50:// dynamic font
1024 | break;case 51:// emacs shell
1025 | break;case 52:// manipulate selection data
1026 | 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
1027 | break;}this.params=[];this.currentParam=0;this.state=normal;}else{if(!this.params.length){if(ch>='0'&&ch<='9'){this.currentParam=this.currentParam*10+ch.charCodeAt(0)-48;}else if(ch===';'){this.params.push(this.currentParam);this.currentParam='';}}else{this.currentParam+=ch;}}break;case csi:// '?', '>', '!'
1028 | if(ch==='?'||ch==='>'||ch==='!'){this.prefix=ch;break;}// 0 - 9
1029 | if(ch>='0'&&ch<='9'){this.currentParam=this.currentParam*10+ch.charCodeAt(0)-48;break;}// '$', '"', ' ', '\''
1030 | if(ch==='$'||ch==='"'||ch===' '||ch==='\''){this.postfix=ch;break;}this.params.push(this.currentParam);this.currentParam=0;// ';'
1031 | if(ch===';')break;this.state=normal;switch(ch){// CSI Ps A
1032 | // Cursor Up Ps Times (default = 1) (CUU).
1033 | case'A':this.cursorUp(this.params);break;// CSI Ps B
1034 | // Cursor Down Ps Times (default = 1) (CUD).
1035 | case'B':this.cursorDown(this.params);break;// CSI Ps C
1036 | // Cursor Forward Ps Times (default = 1) (CUF).
1037 | case'C':this.cursorForward(this.params);break;// CSI Ps D
1038 | // Cursor Backward Ps Times (default = 1) (CUB).
1039 | case'D':this.cursorBackward(this.params);break;// CSI Ps ; Ps H
1040 | // Cursor Position [row;column] (default = [1,1]) (CUP).
1041 | case'H':this.cursorPos(this.params);break;// CSI Ps J Erase in Display (ED).
1042 | case'J':this.eraseInDisplay(this.params);break;// CSI Ps K Erase in Line (EL).
1043 | case'K':this.eraseInLine(this.params);break;// CSI Pm m Character Attributes (SGR).
1044 | case'm':if(!this.prefix){this.charAttributes(this.params);}break;// CSI Ps n Device Status Report (DSR).
1045 | case'n':if(!this.prefix){this.deviceStatus(this.params);}break;/**
1046 | * Additions
1047 | */// CSI Ps @
1048 | // Insert Ps (Blank) Character(s) (default = 1) (ICH).
1049 | case'@':this.insertChars(this.params);break;// CSI Ps E
1050 | // Cursor Next Line Ps Times (default = 1) (CNL).
1051 | case'E':this.cursorNextLine(this.params);break;// CSI Ps F
1052 | // Cursor Preceding Line Ps Times (default = 1) (CNL).
1053 | case'F':this.cursorPrecedingLine(this.params);break;// CSI Ps G
1054 | // Cursor Character Absolute [column] (default = [row,1]) (CHA).
1055 | case'G':this.cursorCharAbsolute(this.params);break;// CSI Ps L
1056 | // Insert Ps Line(s) (default = 1) (IL).
1057 | case'L':this.insertLines(this.params);break;// CSI Ps M
1058 | // Delete Ps Line(s) (default = 1) (DL).
1059 | case'M':this.deleteLines(this.params);break;// CSI Ps P
1060 | // Delete Ps Character(s) (default = 1) (DCH).
1061 | case'P':this.deleteChars(this.params);break;// CSI Ps X
1062 | // Erase Ps Character(s) (default = 1) (ECH).
1063 | case'X':this.eraseChars(this.params);break;// CSI Pm ` Character Position Absolute
1064 | // [column] (default = [row,1]) (HPA).
1065 | case'`':this.charPosAbsolute(this.params);break;// 141 61 a * HPR -
1066 | // Horizontal Position Relative
1067 | case'a':this.HPositionRelative(this.params);break;// CSI P s c
1068 | // Send Device Attributes (Primary DA).
1069 | // CSI > P s c
1070 | // Send Device Attributes (Secondary DA)
1071 | case'c':this.sendDeviceAttributes(this.params);break;// CSI Pm d
1072 | // Line Position Absolute [row] (default = [1,column]) (VPA).
1073 | case'd':this.linePosAbsolute(this.params);break;// 145 65 e * VPR - Vertical Position Relative
1074 | case'e':this.VPositionRelative(this.params);break;// CSI Ps ; Ps f
1075 | // Horizontal and Vertical Position [row;column] (default =
1076 | // [1,1]) (HVP).
1077 | case'f':this.HVPosition(this.params);break;// CSI Pm h Set Mode (SM).
1078 | // CSI ? Pm h - mouse escape codes, cursor escape codes
1079 | case'h':this.setMode(this.params);break;// CSI Pm l Reset Mode (RM).
1080 | // CSI ? Pm l
1081 | case'l':this.resetMode(this.params);break;// CSI Ps ; Ps r
1082 | // Set Scrolling Region [top;bottom] (default = full size of win-
1083 | // dow) (DECSTBM).
1084 | // CSI ? Pm r
1085 | case'r':this.setScrollRegion(this.params);break;// CSI s
1086 | // Save cursor (ANSI.SYS).
1087 | case's':this.saveCursor(this.params);break;// CSI u
1088 | // Restore cursor (ANSI.SYS).
1089 | case'u':this.restoreCursor(this.params);break;/**
1090 | * Lesser Used
1091 | */// CSI Ps I
1092 | // Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).
1093 | case'I':this.cursorForwardTab(this.params);break;// CSI Ps S Scroll up Ps lines (default = 1) (SU).
1094 | case'S':this.scrollUp(this.params);break;// CSI Ps T Scroll down Ps lines (default = 1) (SD).
1095 | // CSI Ps ; Ps ; Ps ; Ps ; Ps T
1096 | // CSI > Ps; Ps T
1097 | case'T':// if (this.prefix === '>') {
1098 | // this.resetTitleModes(this.params);
1099 | // break;
1100 | // }
1101 | // if (this.params.length > 2) {
1102 | // this.initMouseTracking(this.params);
1103 | // break;
1104 | // }
1105 | if(this.params.length<2&&!this.prefix){this.scrollDown(this.params);}break;// CSI Ps Z
1106 | // Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).
1107 | case'Z':this.cursorBackwardTab(this.params);break;// CSI Ps b Repeat the preceding graphic character Ps times (REP).
1108 | case'b':this.repeatPrecedingCharacter(this.params);break;// CSI Ps g Tab Clear (TBC).
1109 | case'g':this.tabClear(this.params);break;// CSI Pm i Media Copy (MC).
1110 | // CSI ? Pm i
1111 | // case 'i':
1112 | // this.mediaCopy(this.params);
1113 | // break;
1114 | // CSI Pm m Character Attributes (SGR).
1115 | // CSI > Ps; Ps m
1116 | // case 'm': // duplicate
1117 | // if (this.prefix === '>') {
1118 | // this.setResources(this.params);
1119 | // } else {
1120 | // this.charAttributes(this.params);
1121 | // }
1122 | // break;
1123 | // CSI Ps n Device Status Report (DSR).
1124 | // CSI > Ps n
1125 | // case 'n': // duplicate
1126 | // if (this.prefix === '>') {
1127 | // this.disableModifiers(this.params);
1128 | // } else {
1129 | // this.deviceStatus(this.params);
1130 | // }
1131 | // break;
1132 | // CSI > Ps p Set pointer mode.
1133 | // CSI ! p Soft terminal reset (DECSTR).
1134 | // CSI Ps$ p
1135 | // Request ANSI mode (DECRQM).
1136 | // CSI ? Ps$ p
1137 | // Request DEC private mode (DECRQM).
1138 | // CSI Ps ; Ps " p
1139 | case'p':switch(this.prefix){// case '>':
1140 | // this.setPointerMode(this.params);
1141 | // break;
1142 | case'!':this.softReset(this.params);break;// case '?':
1143 | // if (this.postfix === '$') {
1144 | // this.requestPrivateMode(this.params);
1145 | // }
1146 | // break;
1147 | // default:
1148 | // if (this.postfix === '"') {
1149 | // this.setConformanceLevel(this.params);
1150 | // } else if (this.postfix === '$') {
1151 | // this.requestAnsiMode(this.params);
1152 | // }
1153 | // break;
1154 | }break;// CSI Ps q Load LEDs (DECLL).
1155 | // CSI Ps SP q
1156 | // CSI Ps " q
1157 | // case 'q':
1158 | // if (this.postfix === ' ') {
1159 | // this.setCursorStyle(this.params);
1160 | // break;
1161 | // }
1162 | // if (this.postfix === '"') {
1163 | // this.setCharProtectionAttr(this.params);
1164 | // break;
1165 | // }
1166 | // this.loadLEDs(this.params);
1167 | // break;
1168 | // CSI Ps ; Ps r
1169 | // Set Scrolling Region [top;bottom] (default = full size of win-
1170 | // dow) (DECSTBM).
1171 | // CSI ? Pm r
1172 | // CSI Pt; Pl; Pb; Pr; Ps$ r
1173 | // case 'r': // duplicate
1174 | // if (this.prefix === '?') {
1175 | // this.restorePrivateValues(this.params);
1176 | // } else if (this.postfix === '$') {
1177 | // this.setAttrInRectangle(this.params);
1178 | // } else {
1179 | // this.setScrollRegion(this.params);
1180 | // }
1181 | // break;
1182 | // CSI s Save cursor (ANSI.SYS).
1183 | // CSI ? Pm s
1184 | // case 's': // duplicate
1185 | // if (this.prefix === '?') {
1186 | // this.savePrivateValues(this.params);
1187 | // } else {
1188 | // this.saveCursor(this.params);
1189 | // }
1190 | // break;
1191 | // CSI Ps ; Ps ; Ps t
1192 | // CSI Pt; Pl; Pb; Pr; Ps$ t
1193 | // CSI > Ps; Ps t
1194 | // CSI Ps SP t
1195 | // case 't':
1196 | // if (this.postfix === '$') {
1197 | // this.reverseAttrInRectangle(this.params);
1198 | // } else if (this.postfix === ' ') {
1199 | // this.setWarningBellVolume(this.params);
1200 | // } else {
1201 | // if (this.prefix === '>') {
1202 | // this.setTitleModeFeature(this.params);
1203 | // } else {
1204 | // this.manipulateWindow(this.params);
1205 | // }
1206 | // }
1207 | // break;
1208 | // CSI u Restore cursor (ANSI.SYS).
1209 | // CSI Ps SP u
1210 | // case 'u': // duplicate
1211 | // if (this.postfix === ' ') {
1212 | // this.setMarginBellVolume(this.params);
1213 | // } else {
1214 | // this.restoreCursor(this.params);
1215 | // }
1216 | // break;
1217 | // CSI Pt; Pl; Pb; Pr; Pp; Pt; Pl; Pp$ v
1218 | // case 'v':
1219 | // if (this.postfix === '$') {
1220 | // this.copyRectagle(this.params);
1221 | // }
1222 | // break;
1223 | // CSI Pt ; Pl ; Pb ; Pr ' w
1224 | // case 'w':
1225 | // if (this.postfix === '\'') {
1226 | // this.enableFilterRectangle(this.params);
1227 | // }
1228 | // break;
1229 | // CSI Ps x Request Terminal Parameters (DECREQTPARM).
1230 | // CSI Ps x Select Attribute Change Extent (DECSACE).
1231 | // CSI Pc; Pt; Pl; Pb; Pr$ x
1232 | // case 'x':
1233 | // if (this.postfix === '$') {
1234 | // this.fillRectangle(this.params);
1235 | // } else {
1236 | // this.requestParameters(this.params);
1237 | // //this.__(this.params);
1238 | // }
1239 | // break;
1240 | // CSI Ps ; Pu ' z
1241 | // CSI Pt; Pl; Pb; Pr$ z
1242 | // case 'z':
1243 | // if (this.postfix === '\'') {
1244 | // this.enableLocatorReporting(this.params);
1245 | // } else if (this.postfix === '$') {
1246 | // this.eraseRectangle(this.params);
1247 | // }
1248 | // break;
1249 | // CSI Pm ' {
1250 | // CSI Pt; Pl; Pb; Pr$ {
1251 | // case '{':
1252 | // if (this.postfix === '\'') {
1253 | // this.setLocatorEvents(this.params);
1254 | // } else if (this.postfix === '$') {
1255 | // this.selectiveEraseRectangle(this.params);
1256 | // }
1257 | // break;
1258 | // CSI Ps ' |
1259 | // case '|':
1260 | // if (this.postfix === '\'') {
1261 | // this.requestLocatorPosition(this.params);
1262 | // }
1263 | // break;
1264 | // CSI P m SP }
1265 | // Insert P s Column(s) (default = 1) (DECIC), VT420 and up.
1266 | // case '}':
1267 | // if (this.postfix === ' ') {
1268 | // this.insertColumns(this.params);
1269 | // }
1270 | // break;
1271 | // CSI P m SP ~
1272 | // Delete P s Column(s) (default = 1) (DECDC), VT420 and up
1273 | // case '~':
1274 | // if (this.postfix === ' ') {
1275 | // this.deleteColumns(this.params);
1276 | // }
1277 | // break;
1278 | default:this.error('Unknown CSI code: %s.',ch);break;}this.prefix='';this.postfix='';break;case dcs:if(ch==='\x1b'||ch==='\x07'){if(ch==='\x1b')i++;switch(this.prefix){// User-Defined Keys (DECUDK).
1279 | case'':break;// Request Status String (DECRQSS).
1280 | // test: echo -e '\eP$q"p\e\\'
1281 | case'$q':var pt=this.currentParam,valid=false;switch(pt){// DECSCA
1282 | case'"q':pt='0"q';break;// DECSCL
1283 | case'"p':pt='61"p';break;// DECSTBM
1284 | case'r':pt=''+(this.scrollTop+1)+';'+(this.scrollBottom+1)+'r';break;// SGR
1285 | case'm':pt='0m';break;default:this.error('Unknown DCS Pt: %s.',pt);pt='';break;}this.send('\x1bP'+ +valid+'$r'+pt+'\x1b\\');break;// Set Termcap/Terminfo Data (xterm, experimental).
1286 | case'+p':break;// Request Termcap/Terminfo String (xterm, experimental)
1287 | // Regular xterm does not even respond to this sequence.
1288 | // This can cause a small glitch in vim.
1289 | // test: echo -ne '\eP+q6b64\e\\'
1290 | case'+q':var pt=this.currentParam,valid=false;this.send('\x1bP'+ +valid+'+r'+pt+'\x1b\\');break;default:this.error('Unknown DCS prefix: %s.',this.prefix);break;}this.currentParam=0;this.prefix='';this.state=normal;}else if(!this.currentParam){if(!this.prefix&&ch!=='$'&&ch!=='+'){this.currentParam=ch;}else if(this.prefix.length===2){this.currentParam=ch;}else{this.prefix+=ch;}}else{this.currentParam+=ch;}break;case ignore:// For PM and APC.
1291 | if(ch==='\x1b'||ch==='\x07'){if(ch==='\x1b')i++;this.state=normal;}break;}}this.updateRange(this.y);this.refresh(this.refreshStart,this.refreshEnd);};/**
1292 | * Writes text to the terminal, followed by a break line character (\n).
1293 | * @param {string} text The text to write to the terminal.
1294 | */Terminal.prototype.writeln=function(data){this.write(data+'\r\n');};/**
1295 | * Attaches a custom keydown handler which is run before keys are processed, giving consumers of
1296 | * xterm.js ultimate control as to what keys should be processed by the terminal and what keys
1297 | * should not.
1298 | * @param {function} customKeydownHandler The custom KeyboardEvent handler to attach. This is a
1299 | * function that takes a KeyboardEvent, allowing consumers to stop propogation and/or prevent
1300 | * the default action. The function returns whether the event should be processed by xterm.js.
1301 | */Terminal.prototype.attachCustomKeydownHandler=function(customKeydownHandler){this.customKeydownHandler=customKeydownHandler;};/**
1302 | * Handle a keydown event
1303 | * Key Resources:
1304 | * - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
1305 | * @param {KeyboardEvent} ev The keydown event to be handled.
1306 | */Terminal.prototype.keyDown=function(ev){// Scroll down to prompt, whenever the user presses a key.
1307 | if(this.ybase!==this.ydisp){this.scrollToBottom();}if(this.customKeydownHandler&&this.customKeydownHandler(ev)===false){return false;}if(!this.compositionHelper.keydown.bind(this.compositionHelper)(ev)){return false;}var self=this;var result=this.evaluateKeyEscapeSequence(ev);if(result.scrollDisp){this.scrollDisp(result.scrollDisp);return this.cancel(ev,true);}if(isThirdLevelShift(this,ev)){return true;}if(result.cancel){// The event is canceled at the end already, is this necessary?
1308 | this.cancel(ev,true);}if(!result.key){return true;}this.emit('keydown',ev);this.emit('key',result.key,ev);this.showCursor();this.handler(result.key);return this.cancel(ev,true);};/**
1309 | * Returns an object that determines how a KeyboardEvent should be handled. The key of the
1310 | * returned value is the new key code to pass to the PTY.
1311 | *
1312 | * Reference: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
1313 | * @param {KeyboardEvent} ev The keyboard event to be translated to key escape sequence.
1314 | */Terminal.prototype.evaluateKeyEscapeSequence=function(ev){var result={// Whether to cancel event propogation (NOTE: this may not be needed since the event is
1315 | // canceled at the end of keyDown
1316 | cancel:false,// The new key even to emit
1317 | key:undefined,// The number of characters to scroll, if this is defined it will cancel the event
1318 | scrollDisp:undefined};var modifiers=ev.shiftKey<<0|ev.altKey<<1|ev.ctrlKey<<2|ev.metaKey<<3;switch(ev.keyCode){case 8:// backspace
1319 | if(ev.shiftKey){result.key='\x08';// ^H
1320 | break;}result.key='\x7f';// ^?
1321 | break;case 9:// tab
1322 | if(ev.shiftKey){result.key='\x1b[Z';break;}result.key='\t';result.cancel=true;break;case 13:// return/enter
1323 | result.key='\r';result.cancel=true;break;case 27:// escape
1324 | result.key='\x1b';result.cancel=true;break;case 37:// left-arrow
1325 | if(modifiers){result.key='\x1b[1;'+(modifiers+1)+'D';// HACK: Make Alt + left-arrow behave like Ctrl + left-arrow: move one word backwards
1326 | // http://unix.stackexchange.com/a/108106
1327 | if(result.key=='\x1b[1;3D'){result.key='\x1b[1;5D';}}else if(this.applicationCursor){result.key='\x1bOD';}else{result.key='\x1b[D';}break;case 39:// right-arrow
1328 | if(modifiers){result.key='\x1b[1;'+(modifiers+1)+'C';// HACK: Make Alt + right-arrow behave like Ctrl + right-arrow: move one word forward
1329 | // http://unix.stackexchange.com/a/108106
1330 | if(result.key=='\x1b[1;3C'){result.key='\x1b[1;5C';}}else if(this.applicationCursor){result.key='\x1bOC';}else{result.key='\x1b[C';}break;case 38:// up-arrow
1331 | if(modifiers){result.key='\x1b[1;'+(modifiers+1)+'A';// HACK: Make Alt + up-arrow behave like Ctrl + up-arrow
1332 | // http://unix.stackexchange.com/a/108106
1333 | if(result.key=='\x1b[1;3A'){result.key='\x1b[1;5A';}}else if(this.applicationCursor){result.key='\x1bOA';}else{result.key='\x1b[A';}break;case 40:// down-arrow
1334 | if(modifiers){result.key='\x1b[1;'+(modifiers+1)+'B';// HACK: Make Alt + down-arrow behave like Ctrl + down-arrow
1335 | // http://unix.stackexchange.com/a/108106
1336 | if(result.key=='\x1b[1;3B'){result.key='\x1b[1;5B';}}else if(this.applicationCursor){result.key='\x1bOB';}else{result.key='\x1b[B';}break;case 45:// insert
1337 | if(!ev.shiftKey&&!ev.ctrlKey){// or + are used to
1338 | // copy-paste on some systems.
1339 | result.key='\x1b[2~';}break;case 46:// delete
1340 | if(modifiers){result.key='\x1b[3;'+(modifiers+1)+'~';}else{result.key='\x1b[3~';}break;case 36:// home
1341 | if(modifiers)result.key='\x1b[1;'+(modifiers+1)+'H';else if(this.applicationCursor)result.key='\x1bOH';else result.key='\x1b[H';break;case 35:// end
1342 | if(modifiers)result.key='\x1b[1;'+(modifiers+1)+'F';else if(this.applicationCursor)result.key='\x1bOF';else result.key='\x1b[F';break;case 33:// page up
1343 | if(ev.shiftKey){result.scrollDisp=-(this.rows-1);}else{result.key='\x1b[5~';}break;case 34:// page down
1344 | if(ev.shiftKey){result.scrollDisp=this.rows-1;}else{result.key='\x1b[6~';}break;case 112:// F1-F12
1345 | if(modifiers){result.key='\x1b[1;'+(modifiers+1)+'P';}else{result.key='\x1bOP';}break;case 113:if(modifiers){result.key='\x1b[1;'+(modifiers+1)+'Q';}else{result.key='\x1bOQ';}break;case 114:if(modifiers){result.key='\x1b[1;'+(modifiers+1)+'R';}else{result.key='\x1bOR';}break;case 115:if(modifiers){result.key='\x1b[1;'+(modifiers+1)+'S';}else{result.key='\x1bOS';}break;case 116:if(modifiers){result.key='\x1b[15;'+(modifiers+1)+'~';}else{result.key='\x1b[15~';}break;case 117:if(modifiers){result.key='\x1b[17;'+(modifiers+1)+'~';}else{result.key='\x1b[17~';}break;case 118:if(modifiers){result.key='\x1b[18;'+(modifiers+1)+'~';}else{result.key='\x1b[18~';}break;case 119:if(modifiers){result.key='\x1b[19;'+(modifiers+1)+'~';}else{result.key='\x1b[19~';}break;case 120:if(modifiers){result.key='\x1b[20;'+(modifiers+1)+'~';}else{result.key='\x1b[20~';}break;case 121:if(modifiers){result.key='\x1b[21;'+(modifiers+1)+'~';}else{result.key='\x1b[21~';}break;case 122:if(modifiers){result.key='\x1b[23;'+(modifiers+1)+'~';}else{result.key='\x1b[23~';}break;case 123:if(modifiers){result.key='\x1b[24;'+(modifiers+1)+'~';}else{result.key='\x1b[24~';}break;default:// a-z and space
1346 | if(ev.ctrlKey&&!ev.shiftKey&&!ev.altKey&&!ev.metaKey){if(ev.keyCode>=65&&ev.keyCode<=90){result.key=String.fromCharCode(ev.keyCode-64);}else if(ev.keyCode===32){// NUL
1347 | result.key=String.fromCharCode(0);}else if(ev.keyCode>=51&&ev.keyCode<=55){// escape, file sep, group sep, record sep, unit sep
1348 | result.key=String.fromCharCode(ev.keyCode-51+27);}else if(ev.keyCode===56){// delete
1349 | result.key=String.fromCharCode(127);}else if(ev.keyCode===219){// ^[ - escape
1350 | result.key=String.fromCharCode(27);}else if(ev.keyCode===221){// ^] - group sep
1351 | result.key=String.fromCharCode(29);}}else if(!this.browser.isMac&&ev.altKey&&!ev.ctrlKey&&!ev.metaKey){// On Mac this is a third level shift. Use instead.
1352 | if(ev.keyCode>=65&&ev.keyCode<=90){result.key='\x1b'+String.fromCharCode(ev.keyCode+32);}else if(ev.keyCode===192){result.key='\x1b`';}else if(ev.keyCode>=48&&ev.keyCode<=57){result.key='\x1b'+(ev.keyCode-48);}}break;}return result;};/**
1353 | * Set the G level of the terminal
1354 | * @param g
1355 | */Terminal.prototype.setgLevel=function(g){this.glevel=g;this.charset=this.charsets[g];};/**
1356 | * Set the charset for the given G level of the terminal
1357 | * @param g
1358 | * @param charset
1359 | */Terminal.prototype.setgCharset=function(g,charset){this.charsets[g]=charset;if(this.glevel===g){this.charset=charset;}};/**
1360 | * Handle a keypress event.
1361 | * Key Resources:
1362 | * - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
1363 | * @param {KeyboardEvent} ev The keypress event to be handled.
1364 | */Terminal.prototype.keyPress=function(ev){var key;this.cancel(ev);if(ev.charCode){key=ev.charCode;}else if(ev.which==null){key=ev.keyCode;}else if(ev.which!==0&&ev.charCode!==0){key=ev.which;}else{return false;}if(!key||(ev.altKey||ev.ctrlKey||ev.metaKey)&&!isThirdLevelShift(this,ev)){return false;}key=String.fromCharCode(key);this.emit('keypress',key,ev);this.emit('key',key,ev);this.showCursor();this.handler(key);return false;};/**
1365 | * Send data for handling to the terminal
1366 | * @param {string} data
1367 | */Terminal.prototype.send=function(data){var self=this;if(!this.queue){setTimeout(function(){self.handler(self.queue);self.queue='';},1);}this.queue+=data;};/**
1368 | * Ring the bell.
1369 | * Note: We could do sweet things with webaudio here
1370 | */Terminal.prototype.bell=function(){if(!this.visualBell)return;var self=this;this.element.style.borderColor='white';setTimeout(function(){self.element.style.borderColor='';},10);if(this.popOnBell)this.focus();};/**
1371 | * Log the current state to the console.
1372 | */Terminal.prototype.log=function(){if(!this.debug)return;if(!this.context.console||!this.context.console.log)return;var args=Array.prototype.slice.call(arguments);this.context.console.log.apply(this.context.console,args);};/**
1373 | * Log the current state as error to the console.
1374 | */Terminal.prototype.error=function(){if(!this.debug)return;if(!this.context.console||!this.context.console.error)return;var args=Array.prototype.slice.call(arguments);this.context.console.error.apply(this.context.console,args);};/**
1375 | * Resizes the terminal.
1376 | *
1377 | * @param {number} x The number of columns to resize to.
1378 | * @param {number} y The number of rows to resize to.
1379 | */Terminal.prototype.resize=function(x,y){var line,el,i,j,ch,addToY;if(x===this.cols&&y===this.rows){return;}if(x<1)x=1;if(y<1)y=1;// resize cols
1380 | j=this.cols;if(j x)
1382 | i=this.lines.length;while(i--){while(this.lines[i].length>x){this.lines[i].pop();}}}this.setupStops(j);this.cols=x;// resize rows
1383 | j=this.rows;addToY=0;if(j0&&this.lines.length<=this.ybase+this.y+addToY+1){// There is room above the buffer and there are no empty elements below the line,
1385 | // scroll up
1386 | this.ybase--;addToY++;if(this.ydisp>0){// Viewport is at the top of the buffer, must increase downwards
1387 | this.ydisp--;}}else{// Add a blank line if there is no buffer left at the top to scroll to, or if there
1388 | // are blank lines after the cursor
1389 | this.lines.push(this.blankLine());}}if(this.children.length y)
1390 | while(j-->y){if(this.lines.length>y+this.ybase){if(this.lines.length>this.ybase+this.y+1){// The line is a blank line below the cursor, remove it
1391 | this.lines.pop();}else{// The line is the cursor, scroll down
1392 | this.ybase++;this.ydisp++;}}if(this.children.length>y){el=this.children.shift();if(!el)continue;el.parentNode.removeChild(el);}}}this.rows=y;// Make sure that the cursor stays on screen
1393 | if(this.y>=y){this.y=y-1;}if(addToY){this.y+=addToY;}if(this.x>=x){this.x=x-1;}this.scrollTop=0;this.scrollBottom=y-1;this.refresh(0,this.rows-1);this.normal=null;this.geometry=[this.cols,this.rows];this.emit('resize',{terminal:this,cols:x,rows:y});};/**
1394 | * Updates the range of rows to refresh
1395 | * @param {number} y The number of rows to refresh next.
1396 | */Terminal.prototype.updateRange=function(y){if(ythis.refreshEnd)this.refreshEnd=y;// if (y > this.refreshEnd) {
1397 | // this.refreshEnd = y;
1398 | // if (y > this.rows - 1) {
1399 | // this.refreshEnd = this.rows - 1;
1400 | // }
1401 | // }
1402 | };/**
1403 | * Set the range of refreshing to the maximum value
1404 | */Terminal.prototype.maxRange=function(){this.refreshStart=0;this.refreshEnd=this.rows-1;};/**
1405 | * Setup the tab stops.
1406 | * @param {number} i
1407 | */Terminal.prototype.setupStops=function(i){if(i!=null){if(!this.tabs[i]){i=this.prevStop(i);}}else{this.tabs={};i=0;}for(;i0){}return x>=this.cols?this.cols-1:x<0?0:x;};/**
1411 | * Move the cursor one tab stop forward from the given position (default is current).
1412 | * @param {number} x The position to move the cursor one tab stop forward.
1413 | */Terminal.prototype.nextStop=function(x){if(x==null)x=this.x;while(!this.tabs[++x]&&x=this.cols?this.cols-1:x<0?0:x;};/**
1414 | * Erase in the identified line everything from "x" to the end of the line (right).
1415 | * @param {number} x The column from which to start erasing to the end of the line.
1416 | * @param {number} y The line in which to operate.
1417 | */Terminal.prototype.eraseRight=function(x,y){var line=this.lines[this.ybase+y],ch=[this.eraseAttr(),' ',1];// xterm
1418 | for(;xthis.scrollBottom){this.y--;this.scroll();}this.state=normal;};/**
1450 | * ESC M Reverse Index (RI is 0x8d).
1451 | */Terminal.prototype.reverseIndex=function(){var j;this.y--;if(this.y=this.rows){this.y=this.rows-1;}};/**
1468 | * CSI Ps C
1469 | * Cursor Forward Ps Times (default = 1) (CUF).
1470 | */Terminal.prototype.cursorForward=function(params){var param=params[0];if(param<1)param=1;this.x+=param;if(this.x>=this.cols){this.x=this.cols-1;}};/**
1471 | * CSI Ps D
1472 | * Cursor Backward Ps Times (default = 1) (CUB).
1473 | */Terminal.prototype.cursorBackward=function(params){var param=params[0];if(param<1)param=1;this.x-=param;if(this.x<0)this.x=0;};/**
1474 | * CSI Ps ; Ps H
1475 | * Cursor Position [row;column] (default = [1,1]) (CUP).
1476 | */Terminal.prototype.cursorPos=function(params){var row,col;row=params[0]-1;if(params.length>=2){col=params[1]-1;}else{col=0;}if(row<0){row=0;}else if(row>=this.rows){row=this.rows-1;}if(col<0){col=0;}else if(col>=this.cols){col=this.cols-1;}this.x=col;this.y=row;};/**
1477 | * CSI Ps J Erase in Display (ED).
1478 | * Ps = 0 -> Erase Below (default).
1479 | * Ps = 1 -> Erase Above.
1480 | * Ps = 2 -> Erase All.
1481 | * Ps = 3 -> Erase Saved Lines (xterm).
1482 | * CSI ? Ps J
1483 | * Erase in Display (DECSED).
1484 | * Ps = 0 -> Selective Erase Below (default).
1485 | * Ps = 1 -> Selective Erase Above.
1486 | * Ps = 2 -> Selective Erase All.
1487 | */Terminal.prototype.eraseInDisplay=function(params){var j;switch(params[0]){case 0:this.eraseRight(this.x,this.y);j=this.y+1;for(;j Erase to Right (default).
1491 | * Ps = 1 -> Erase to Left.
1492 | * Ps = 2 -> Erase All.
1493 | * CSI ? Ps K
1494 | * Erase in Line (DECSEL).
1495 | * Ps = 0 -> Selective Erase to Right (default).
1496 | * Ps = 1 -> Selective Erase to Left.
1497 | * Ps = 2 -> Selective Erase All.
1498 | */Terminal.prototype.eraseInLine=function(params){switch(params[0]){case 0:this.eraseRight(this.x,this.y);break;case 1:this.eraseLeft(this.x,this.y);break;case 2:this.eraseLine(this.y);break;}};/**
1499 | * CSI Pm m Character Attributes (SGR).
1500 | * Ps = 0 -> Normal (default).
1501 | * Ps = 1 -> Bold.
1502 | * Ps = 4 -> Underlined.
1503 | * Ps = 5 -> Blink (appears as Bold).
1504 | * Ps = 7 -> Inverse.
1505 | * Ps = 8 -> Invisible, i.e., hidden (VT300).
1506 | * Ps = 2 2 -> Normal (neither bold nor faint).
1507 | * Ps = 2 4 -> Not underlined.
1508 | * Ps = 2 5 -> Steady (not blinking).
1509 | * Ps = 2 7 -> Positive (not inverse).
1510 | * Ps = 2 8 -> Visible, i.e., not hidden (VT300).
1511 | * Ps = 3 0 -> Set foreground color to Black.
1512 | * Ps = 3 1 -> Set foreground color to Red.
1513 | * Ps = 3 2 -> Set foreground color to Green.
1514 | * Ps = 3 3 -> Set foreground color to Yellow.
1515 | * Ps = 3 4 -> Set foreground color to Blue.
1516 | * Ps = 3 5 -> Set foreground color to Magenta.
1517 | * Ps = 3 6 -> Set foreground color to Cyan.
1518 | * Ps = 3 7 -> Set foreground color to White.
1519 | * Ps = 3 9 -> Set foreground color to default (original).
1520 | * Ps = 4 0 -> Set background color to Black.
1521 | * Ps = 4 1 -> Set background color to Red.
1522 | * Ps = 4 2 -> Set background color to Green.
1523 | * Ps = 4 3 -> Set background color to Yellow.
1524 | * Ps = 4 4 -> Set background color to Blue.
1525 | * Ps = 4 5 -> Set background color to Magenta.
1526 | * Ps = 4 6 -> Set background color to Cyan.
1527 | * Ps = 4 7 -> Set background color to White.
1528 | * Ps = 4 9 -> Set background color to default (original).
1529 | *
1530 | * If 16-color support is compiled, the following apply. Assume
1531 | * that xterm's resources are set so that the ISO color codes are
1532 | * the first 8 of a set of 16. Then the aixterm colors are the
1533 | * bright versions of the ISO colors:
1534 | * Ps = 9 0 -> Set foreground color to Black.
1535 | * Ps = 9 1 -> Set foreground color to Red.
1536 | * Ps = 9 2 -> Set foreground color to Green.
1537 | * Ps = 9 3 -> Set foreground color to Yellow.
1538 | * Ps = 9 4 -> Set foreground color to Blue.
1539 | * Ps = 9 5 -> Set foreground color to Magenta.
1540 | * Ps = 9 6 -> Set foreground color to Cyan.
1541 | * Ps = 9 7 -> Set foreground color to White.
1542 | * Ps = 1 0 0 -> Set background color to Black.
1543 | * Ps = 1 0 1 -> Set background color to Red.
1544 | * Ps = 1 0 2 -> Set background color to Green.
1545 | * Ps = 1 0 3 -> Set background color to Yellow.
1546 | * Ps = 1 0 4 -> Set background color to Blue.
1547 | * Ps = 1 0 5 -> Set background color to Magenta.
1548 | * Ps = 1 0 6 -> Set background color to Cyan.
1549 | * Ps = 1 0 7 -> Set background color to White.
1550 | *
1551 | * If xterm is compiled with the 16-color support disabled, it
1552 | * supports the following, from rxvt:
1553 | * Ps = 1 0 0 -> Set foreground and background color to
1554 | * default.
1555 | *
1556 | * If 88- or 256-color support is compiled, the following apply.
1557 | * Ps = 3 8 ; 5 ; Ps -> Set foreground color to the second
1558 | * Ps.
1559 | * Ps = 4 8 ; 5 ; Ps -> Set background color to the second
1560 | * Ps.
1561 | */Terminal.prototype.charAttributes=function(params){// Optimize a single SGR0.
1562 | if(params.length===1&¶ms[0]===0){this.curAttr=this.defAttr;return;}var l=params.length,i=0,flags=this.curAttr>>18,fg=this.curAttr>>9&0x1ff,bg=this.curAttr&0x1ff,p;for(;i=30&&p<=37){// fg color 8
1563 | fg=p-30;}else if(p>=40&&p<=47){// bg color 8
1564 | bg=p-40;}else if(p>=90&&p<=97){// fg color 16
1565 | p+=8;fg=p-90;}else if(p>=100&&p<=107){// bg color 16
1566 | p+=8;bg=p-100;}else if(p===0){// default
1567 | flags=this.defAttr>>18;fg=this.defAttr>>9&0x1ff;bg=this.defAttr&0x1ff;// flags = 0;
1568 | // fg = 0x1ff;
1569 | // bg = 0x1ff;
1570 | }else if(p===1){// bold text
1571 | flags|=1;}else if(p===4){// underlined text
1572 | flags|=2;}else if(p===5){// blink
1573 | flags|=4;}else if(p===7){// inverse and positive
1574 | // test with: echo -e '\e[31m\e[42mhello\e[7mworld\e[27mhi\e[m'
1575 | flags|=8;}else if(p===8){// invisible
1576 | flags|=16;}else if(p===22){// not bold
1577 | flags&=~1;}else if(p===24){// not underlined
1578 | flags&=~2;}else if(p===25){// not blink
1579 | flags&=~4;}else if(p===27){// not inverse
1580 | flags&=~8;}else if(p===28){// not invisible
1581 | flags&=~16;}else if(p===39){// reset fg
1582 | fg=this.defAttr>>9&0x1ff;}else if(p===49){// reset bg
1583 | bg=this.defAttr&0x1ff;}else if(p===38){// fg color 256
1584 | if(params[i+1]===2){i+=2;fg=matchColor(params[i]&0xff,params[i+1]&0xff,params[i+2]&0xff);if(fg===-1)fg=0x1ff;i+=2;}else if(params[i+1]===5){i+=2;p=params[i]&0xff;fg=p;}}else if(p===48){// bg color 256
1585 | if(params[i+1]===2){i+=2;bg=matchColor(params[i]&0xff,params[i+1]&0xff,params[i+2]&0xff);if(bg===-1)bg=0x1ff;i+=2;}else if(params[i+1]===5){i+=2;p=params[i]&0xff;bg=p;}}else if(p===100){// reset fg/bg
1586 | fg=this.defAttr>>9&0x1ff;bg=this.defAttr&0x1ff;}else{this.error('Unknown SGR attribute: %d.',p);}}this.curAttr=flags<<18|fg<<9|bg;};/**
1587 | * CSI Ps n Device Status Report (DSR).
1588 | * Ps = 5 -> Status Report. Result (``OK'') is
1589 | * CSI 0 n
1590 | * Ps = 6 -> Report Cursor Position (CPR) [row;column].
1591 | * Result is
1592 | * CSI r ; c R
1593 | * CSI ? Ps n
1594 | * Device Status Report (DSR, DEC-specific).
1595 | * Ps = 6 -> Report Cursor Position (CPR) [row;column] as CSI
1596 | * ? r ; c R (assumes page is zero).
1597 | * Ps = 1 5 -> Report Printer status as CSI ? 1 0 n (ready).
1598 | * or CSI ? 1 1 n (not ready).
1599 | * Ps = 2 5 -> Report UDK status as CSI ? 2 0 n (unlocked)
1600 | * or CSI ? 2 1 n (locked).
1601 | * Ps = 2 6 -> Report Keyboard status as
1602 | * CSI ? 2 7 ; 1 ; 0 ; 0 n (North American).
1603 | * The last two parameters apply to VT400 & up, and denote key-
1604 | * board ready and LK01 respectively.
1605 | * Ps = 5 3 -> Report Locator status as
1606 | * CSI ? 5 3 n Locator available, if compiled-in, or
1607 | * CSI ? 5 0 n No Locator, if not.
1608 | */Terminal.prototype.deviceStatus=function(params){if(!this.prefix){switch(params[0]){case 5:// status report
1609 | this.send('\x1b[0n');break;case 6:// cursor position
1610 | this.send('\x1b['+(this.y+1)+';'+(this.x+1)+'R');break;}}else if(this.prefix==='?'){// modern xterm doesnt seem to
1611 | // respond to any of these except ?6, 6, and 5
1612 | switch(params[0]){case 6:// cursor position
1613 | this.send('\x1b[?'+(this.y+1)+';'+(this.x+1)+'R');break;case 15:// no printer
1614 | // this.send('\x1b[?11n');
1615 | break;case 25:// dont support user defined keys
1616 | // this.send('\x1b[?21n');
1617 | break;case 26:// north american keyboard
1618 | // this.send('\x1b[?27;1;0;0n');
1619 | break;case 53:// no dec locator/mouse
1620 | // this.send('\x1b[?50n');
1621 | break;}}};/**
1622 | * Additions
1623 | *//**
1624 | * CSI Ps @
1625 | * Insert Ps (Blank) Character(s) (default = 1) (ICH).
1626 | */Terminal.prototype.insertChars=function(params){var param,row,j,ch;param=params[0];if(param<1)param=1;row=this.y+this.ybase;j=this.x;ch=[this.eraseAttr(),' ',1];// xterm
1627 | while(param--&&j=this.rows){this.y=this.rows-1;}this.x=0;};/**
1632 | * CSI Ps F
1633 | * Cursor Preceding Line Ps Times (default = 1) (CNL).
1634 | * reuse CSI Ps A ?
1635 | */Terminal.prototype.cursorPrecedingLine=function(params){var param=params[0];if(param<1)param=1;this.y-=param;if(this.y<0)this.y=0;this.x=0;};/**
1636 | * CSI Ps G
1637 | * Cursor Character Absolute [column] (default = [row,1]) (CHA).
1638 | */Terminal.prototype.cursorCharAbsolute=function(params){var param=params[0];if(param<1)param=1;this.x=param-1;};/**
1639 | * CSI Ps L
1640 | * Insert Ps Line(s) (default = 1) (IL).
1641 | */Terminal.prototype.insertLines=function(params){var param,row,j;param=params[0];if(param<1)param=1;row=this.y+this.ybase;j=this.rows-1-this.scrollBottom;j=this.rows-1+this.ybase-j+1;while(param--){// test: echo -e '\e[44m\e[1L\e[0m'
1642 | // blankLine(true) - xterm/linux behavior
1643 | this.lines.splice(row,0,this.blankLine(true));this.lines.splice(j,1);}// this.maxRange();
1644 | this.updateRange(this.y);this.updateRange(this.scrollBottom);};/**
1645 | * CSI Ps M
1646 | * Delete Ps Line(s) (default = 1) (DL).
1647 | */Terminal.prototype.deleteLines=function(params){var param,row,j;param=params[0];if(param<1)param=1;row=this.y+this.ybase;j=this.rows-1-this.scrollBottom;j=this.rows-1+this.ybase-j;while(param--){// test: echo -e '\e[44m\e[1M\e[0m'
1648 | // blankLine(true) - xterm/linux behavior
1649 | this.lines.splice(j+1,0,this.blankLine(true));this.lines.splice(row,1);}// this.maxRange();
1650 | this.updateRange(this.y);this.updateRange(this.scrollBottom);};/**
1651 | * CSI Ps P
1652 | * Delete Ps Character(s) (default = 1) (DCH).
1653 | */Terminal.prototype.deleteChars=function(params){var param,row,ch;param=params[0];if(param<1)param=1;row=this.y+this.ybase;ch=[this.eraseAttr(),' ',1];// xterm
1654 | while(param--){this.lines[row].splice(this.x,1);this.lines[row].push(ch);}};/**
1655 | * CSI Ps X
1656 | * Erase Ps Character(s) (default = 1) (ECH).
1657 | */Terminal.prototype.eraseChars=function(params){var param,row,j,ch;param=params[0];if(param<1)param=1;row=this.y+this.ybase;j=this.x;ch=[this.eraseAttr(),' ',1];// xterm
1658 | while(param--&&j=this.cols){this.x=this.cols-1;}};/**
1662 | * 141 61 a * HPR -
1663 | * Horizontal Position Relative
1664 | * reuse CSI Ps C ?
1665 | */Terminal.prototype.HPositionRelative=function(params){var param=params[0];if(param<1)param=1;this.x+=param;if(this.x>=this.cols){this.x=this.cols-1;}};/**
1666 | * CSI Ps c Send Device Attributes (Primary DA).
1667 | * Ps = 0 or omitted -> request attributes from terminal. The
1668 | * response depends on the decTerminalID resource setting.
1669 | * -> CSI ? 1 ; 2 c (``VT100 with Advanced Video Option'')
1670 | * -> CSI ? 1 ; 0 c (``VT101 with No Options'')
1671 | * -> CSI ? 6 c (``VT102'')
1672 | * -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c (``VT220'')
1673 | * The VT100-style response parameters do not mean anything by
1674 | * themselves. VT220 parameters do, telling the host what fea-
1675 | * tures the terminal supports:
1676 | * Ps = 1 -> 132-columns.
1677 | * Ps = 2 -> Printer.
1678 | * Ps = 6 -> Selective erase.
1679 | * Ps = 8 -> User-defined keys.
1680 | * Ps = 9 -> National replacement character sets.
1681 | * Ps = 1 5 -> Technical characters.
1682 | * Ps = 2 2 -> ANSI color, e.g., VT525.
1683 | * Ps = 2 9 -> ANSI text locator (i.e., DEC Locator mode).
1684 | * CSI > Ps c
1685 | * Send Device Attributes (Secondary DA).
1686 | * Ps = 0 or omitted -> request the terminal's identification
1687 | * code. The response depends on the decTerminalID resource set-
1688 | * ting. It should apply only to VT220 and up, but xterm extends
1689 | * this to VT100.
1690 | * -> CSI > Pp ; Pv ; Pc c
1691 | * where Pp denotes the terminal type
1692 | * Pp = 0 -> ``VT100''.
1693 | * Pp = 1 -> ``VT220''.
1694 | * and Pv is the firmware version (for xterm, this was originally
1695 | * the XFree86 patch number, starting with 95). In a DEC termi-
1696 | * nal, Pc indicates the ROM cartridge registration number and is
1697 | * always zero.
1698 | * More information:
1699 | * xterm/charproc.c - line 2012, for more information.
1700 | * vim responds with ^[[?0c or ^[[?1c after the terminal's response (?)
1701 | */Terminal.prototype.sendDeviceAttributes=function(params){if(params[0]>0)return;if(!this.prefix){if(this.is('xterm')||this.is('rxvt-unicode')||this.is('screen')){this.send('\x1b[?1;2c');}else if(this.is('linux')){this.send('\x1b[?6c');}}else if(this.prefix==='>'){// xterm and urxvt
1702 | // seem to spit this
1703 | // out around ~370 times (?).
1704 | if(this.is('xterm')){this.send('\x1b[>0;276;0c');}else if(this.is('rxvt-unicode')){this.send('\x1b[>85;95;0c');}else if(this.is('linux')){// not supported by linux console.
1705 | // linux console echoes parameters.
1706 | this.send(params[0]+'c');}else if(this.is('screen')){this.send('\x1b[>83;40003;0c');}}};/**
1707 | * CSI Pm d
1708 | * Line Position Absolute [row] (default = [1,column]) (VPA).
1709 | */Terminal.prototype.linePosAbsolute=function(params){var param=params[0];if(param<1)param=1;this.y=param-1;if(this.y>=this.rows){this.y=this.rows-1;}};/**
1710 | * 145 65 e * VPR - Vertical Position Relative
1711 | * reuse CSI Ps B ?
1712 | */Terminal.prototype.VPositionRelative=function(params){var param=params[0];if(param<1)param=1;this.y+=param;if(this.y>=this.rows){this.y=this.rows-1;}};/**
1713 | * CSI Ps ; Ps f
1714 | * Horizontal and Vertical Position [row;column] (default =
1715 | * [1,1]) (HVP).
1716 | */Terminal.prototype.HVPosition=function(params){if(params[0]<1)params[0]=1;if(params[1]<1)params[1]=1;this.y=params[0]-1;if(this.y>=this.rows){this.y=this.rows-1;}this.x=params[1]-1;if(this.x>=this.cols){this.x=this.cols-1;}};/**
1717 | * CSI Pm h Set Mode (SM).
1718 | * Ps = 2 -> Keyboard Action Mode (AM).
1719 | * Ps = 4 -> Insert Mode (IRM).
1720 | * Ps = 1 2 -> Send/receive (SRM).
1721 | * Ps = 2 0 -> Automatic Newline (LNM).
1722 | * CSI ? Pm h
1723 | * DEC Private Mode Set (DECSET).
1724 | * Ps = 1 -> Application Cursor Keys (DECCKM).
1725 | * Ps = 2 -> Designate USASCII for character sets G0-G3
1726 | * (DECANM), and set VT100 mode.
1727 | * Ps = 3 -> 132 Column Mode (DECCOLM).
1728 | * Ps = 4 -> Smooth (Slow) Scroll (DECSCLM).
1729 | * Ps = 5 -> Reverse Video (DECSCNM).
1730 | * Ps = 6 -> Origin Mode (DECOM).
1731 | * Ps = 7 -> Wraparound Mode (DECAWM).
1732 | * Ps = 8 -> Auto-repeat Keys (DECARM).
1733 | * Ps = 9 -> Send Mouse X & Y on button press. See the sec-
1734 | * tion Mouse Tracking.
1735 | * Ps = 1 0 -> Show toolbar (rxvt).
1736 | * Ps = 1 2 -> Start Blinking Cursor (att610).
1737 | * Ps = 1 8 -> Print form feed (DECPFF).
1738 | * Ps = 1 9 -> Set print extent to full screen (DECPEX).
1739 | * Ps = 2 5 -> Show Cursor (DECTCEM).
1740 | * Ps = 3 0 -> Show scrollbar (rxvt).
1741 | * Ps = 3 5 -> Enable font-shifting functions (rxvt).
1742 | * Ps = 3 8 -> Enter Tektronix Mode (DECTEK).
1743 | * Ps = 4 0 -> Allow 80 -> 132 Mode.
1744 | * Ps = 4 1 -> more(1) fix (see curses resource).
1745 | * Ps = 4 2 -> Enable Nation Replacement Character sets (DECN-
1746 | * RCM).
1747 | * Ps = 4 4 -> Turn On Margin Bell.
1748 | * Ps = 4 5 -> Reverse-wraparound Mode.
1749 | * Ps = 4 6 -> Start Logging. This is normally disabled by a
1750 | * compile-time option.
1751 | * Ps = 4 7 -> Use Alternate Screen Buffer. (This may be dis-
1752 | * abled by the titeInhibit resource).
1753 | * Ps = 6 6 -> Application keypad (DECNKM).
1754 | * Ps = 6 7 -> Backarrow key sends backspace (DECBKM).
1755 | * Ps = 1 0 0 0 -> Send Mouse X & Y on button press and
1756 | * release. See the section Mouse Tracking.
1757 | * Ps = 1 0 0 1 -> Use Hilite Mouse Tracking.
1758 | * Ps = 1 0 0 2 -> Use Cell Motion Mouse Tracking.
1759 | * Ps = 1 0 0 3 -> Use All Motion Mouse Tracking.
1760 | * Ps = 1 0 0 4 -> Send FocusIn/FocusOut events.
1761 | * Ps = 1 0 0 5 -> Enable Extended Mouse Mode.
1762 | * Ps = 1 0 1 0 -> Scroll to bottom on tty output (rxvt).
1763 | * Ps = 1 0 1 1 -> Scroll to bottom on key press (rxvt).
1764 | * Ps = 1 0 3 4 -> Interpret "meta" key, sets eighth bit.
1765 | * (enables the eightBitInput resource).
1766 | * Ps = 1 0 3 5 -> Enable special modifiers for Alt and Num-
1767 | * Lock keys. (This enables the numLock resource).
1768 | * Ps = 1 0 3 6 -> Send ESC when Meta modifies a key. (This
1769 | * enables the metaSendsEscape resource).
1770 | * Ps = 1 0 3 7 -> Send DEL from the editing-keypad Delete
1771 | * key.
1772 | * Ps = 1 0 3 9 -> Send ESC when Alt modifies a key. (This
1773 | * enables the altSendsEscape resource).
1774 | * Ps = 1 0 4 0 -> Keep selection even if not highlighted.
1775 | * (This enables the keepSelection resource).
1776 | * Ps = 1 0 4 1 -> Use the CLIPBOARD selection. (This enables
1777 | * the selectToClipboard resource).
1778 | * Ps = 1 0 4 2 -> Enable Urgency window manager hint when
1779 | * Control-G is received. (This enables the bellIsUrgent
1780 | * resource).
1781 | * Ps = 1 0 4 3 -> Enable raising of the window when Control-G
1782 | * is received. (enables the popOnBell resource).
1783 | * Ps = 1 0 4 7 -> Use Alternate Screen Buffer. (This may be
1784 | * disabled by the titeInhibit resource).
1785 | * Ps = 1 0 4 8 -> Save cursor as in DECSC. (This may be dis-
1786 | * abled by the titeInhibit resource).
1787 | * Ps = 1 0 4 9 -> Save cursor as in DECSC and use Alternate
1788 | * Screen Buffer, clearing it first. (This may be disabled by
1789 | * the titeInhibit resource). This combines the effects of the 1
1790 | * 0 4 7 and 1 0 4 8 modes. Use this with terminfo-based
1791 | * applications rather than the 4 7 mode.
1792 | * Ps = 1 0 5 0 -> Set terminfo/termcap function-key mode.
1793 | * Ps = 1 0 5 1 -> Set Sun function-key mode.
1794 | * Ps = 1 0 5 2 -> Set HP function-key mode.
1795 | * Ps = 1 0 5 3 -> Set SCO function-key mode.
1796 | * Ps = 1 0 6 0 -> Set legacy keyboard emulation (X11R6).
1797 | * Ps = 1 0 6 1 -> Set VT220 keyboard emulation.
1798 | * Ps = 2 0 0 4 -> Set bracketed paste mode.
1799 | * Modes:
1800 | * http: *vt100.net/docs/vt220-rm/chapter4.html
1801 | */Terminal.prototype.setMode=function(params){if((typeof params==='undefined'?'undefined':_typeof(params))==='object'){var l=params.length,i=0;for(;i1000;this.mouseEvents=true;this.element.style.cursor='default';this.log('Binding to mouse events.');break;case 1004:// send focusin/focusout events
1815 | // focusin: ^[[I
1816 | // focusout: ^[[O
1817 | this.sendFocus=true;break;case 1005:// utf8 ext mode mouse
1818 | this.utfMouse=true;// for wide terminals
1819 | // simply encodes large values as utf8 characters
1820 | break;case 1006:// sgr ext mode mouse
1821 | this.sgrMouse=true;// for wide terminals
1822 | // does not add 32 to fields
1823 | // press: ^[[ Keyboard Action Mode (AM).
1843 | * Ps = 4 -> Replace Mode (IRM).
1844 | * Ps = 1 2 -> Send/receive (SRM).
1845 | * Ps = 2 0 -> Normal Linefeed (LNM).
1846 | * CSI ? Pm l
1847 | * DEC Private Mode Reset (DECRST).
1848 | * Ps = 1 -> Normal Cursor Keys (DECCKM).
1849 | * Ps = 2 -> Designate VT52 mode (DECANM).
1850 | * Ps = 3 -> 80 Column Mode (DECCOLM).
1851 | * Ps = 4 -> Jump (Fast) Scroll (DECSCLM).
1852 | * Ps = 5 -> Normal Video (DECSCNM).
1853 | * Ps = 6 -> Normal Cursor Mode (DECOM).
1854 | * Ps = 7 -> No Wraparound Mode (DECAWM).
1855 | * Ps = 8 -> No Auto-repeat Keys (DECARM).
1856 | * Ps = 9 -> Don't send Mouse X & Y on button press.
1857 | * Ps = 1 0 -> Hide toolbar (rxvt).
1858 | * Ps = 1 2 -> Stop Blinking Cursor (att610).
1859 | * Ps = 1 8 -> Don't print form feed (DECPFF).
1860 | * Ps = 1 9 -> Limit print to scrolling region (DECPEX).
1861 | * Ps = 2 5 -> Hide Cursor (DECTCEM).
1862 | * Ps = 3 0 -> Don't show scrollbar (rxvt).
1863 | * Ps = 3 5 -> Disable font-shifting functions (rxvt).
1864 | * Ps = 4 0 -> Disallow 80 -> 132 Mode.
1865 | * Ps = 4 1 -> No more(1) fix (see curses resource).
1866 | * Ps = 4 2 -> Disable Nation Replacement Character sets (DEC-
1867 | * NRCM).
1868 | * Ps = 4 4 -> Turn Off Margin Bell.
1869 | * Ps = 4 5 -> No Reverse-wraparound Mode.
1870 | * Ps = 4 6 -> Stop Logging. (This is normally disabled by a
1871 | * compile-time option).
1872 | * Ps = 4 7 -> Use Normal Screen Buffer.
1873 | * Ps = 6 6 -> Numeric keypad (DECNKM).
1874 | * Ps = 6 7 -> Backarrow key sends delete (DECBKM).
1875 | * Ps = 1 0 0 0 -> Don't send Mouse X & Y on button press and
1876 | * release. See the section Mouse Tracking.
1877 | * Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking.
1878 | * Ps = 1 0 0 2 -> Don't use Cell Motion Mouse Tracking.
1879 | * Ps = 1 0 0 3 -> Don't use All Motion Mouse Tracking.
1880 | * Ps = 1 0 0 4 -> Don't send FocusIn/FocusOut events.
1881 | * Ps = 1 0 0 5 -> Disable Extended Mouse Mode.
1882 | * Ps = 1 0 1 0 -> Don't scroll to bottom on tty output
1883 | * (rxvt).
1884 | * Ps = 1 0 1 1 -> Don't scroll to bottom on key press (rxvt).
1885 | * Ps = 1 0 3 4 -> Don't interpret "meta" key. (This disables
1886 | * the eightBitInput resource).
1887 | * Ps = 1 0 3 5 -> Disable special modifiers for Alt and Num-
1888 | * Lock keys. (This disables the numLock resource).
1889 | * Ps = 1 0 3 6 -> Don't send ESC when Meta modifies a key.
1890 | * (This disables the metaSendsEscape resource).
1891 | * Ps = 1 0 3 7 -> Send VT220 Remove from the editing-keypad
1892 | * Delete key.
1893 | * Ps = 1 0 3 9 -> Don't send ESC when Alt modifies a key.
1894 | * (This disables the altSendsEscape resource).
1895 | * Ps = 1 0 4 0 -> Do not keep selection when not highlighted.
1896 | * (This disables the keepSelection resource).
1897 | * Ps = 1 0 4 1 -> Use the PRIMARY selection. (This disables
1898 | * the selectToClipboard resource).
1899 | * Ps = 1 0 4 2 -> Disable Urgency window manager hint when
1900 | * Control-G is received. (This disables the bellIsUrgent
1901 | * resource).
1902 | * Ps = 1 0 4 3 -> Disable raising of the window when Control-
1903 | * G is received. (This disables the popOnBell resource).
1904 | * Ps = 1 0 4 7 -> Use Normal Screen Buffer, clearing screen
1905 | * first if in the Alternate Screen. (This may be disabled by
1906 | * the titeInhibit resource).
1907 | * Ps = 1 0 4 8 -> Restore cursor as in DECRC. (This may be
1908 | * disabled by the titeInhibit resource).
1909 | * Ps = 1 0 4 9 -> Use Normal Screen Buffer and restore cursor
1910 | * as in DECRC. (This may be disabled by the titeInhibit
1911 | * resource). This combines the effects of the 1 0 4 7 and 1 0
1912 | * 4 8 modes. Use this with terminfo-based applications rather
1913 | * than the 4 7 mode.
1914 | * Ps = 1 0 5 0 -> Reset terminfo/termcap function-key mode.
1915 | * Ps = 1 0 5 1 -> Reset Sun function-key mode.
1916 | * Ps = 1 0 5 2 -> Reset HP function-key mode.
1917 | * Ps = 1 0 5 3 -> Reset SCO function-key mode.
1918 | * Ps = 1 0 6 0 -> Reset legacy keyboard emulation (X11R6).
1919 | * Ps = 1 0 6 1 -> Reset keyboard emulation to Sun/PC style.
1920 | * Ps = 2 0 0 4 -> Reset bracketed paste mode.
1921 | */Terminal.prototype.resetMode=function(params){if((typeof params==='undefined'?'undefined':_typeof(params))==='object'){var l=params.length,i=0;for(;i Ps; Ps T
1970 | * Reset one or more features of the title modes to the default
1971 | * value. Normally, "reset" disables the feature. It is possi-
1972 | * ble to disable the ability to reset features by compiling a
1973 | * different default for the title modes into xterm.
1974 | * Ps = 0 -> Do not set window/icon labels using hexadecimal.
1975 | * Ps = 1 -> Do not query window/icon labels using hexadeci-
1976 | * mal.
1977 | * Ps = 2 -> Do not set window/icon labels using UTF-8.
1978 | * Ps = 3 -> Do not query window/icon labels using UTF-8.
1979 | * (See discussion of "Title Modes").
1980 | */Terminal.prototype.resetTitleModes=function(params){;};/**
1981 | * CSI Ps Z Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).
1982 | */Terminal.prototype.cursorBackwardTab=function(params){var param=params[0]||1;while(param--){this.x=this.prevStop();}};/**
1983 | * CSI Ps b Repeat the preceding graphic character Ps times (REP).
1984 | */Terminal.prototype.repeatPrecedingCharacter=function(params){var param=params[0]||1,line=this.lines[this.ybase+this.y],ch=line[this.x-1]||[this.defAttr,' ',1];while(param--){line[this.x++]=ch;}};/**
1985 | * CSI Ps g Tab Clear (TBC).
1986 | * Ps = 0 -> Clear Current Column (default).
1987 | * Ps = 3 -> Clear All.
1988 | * Potentially:
1989 | * Ps = 2 -> Clear Stops on Line.
1990 | * http://vt100.net/annarbor/aaa-ug/section6.html
1991 | */Terminal.prototype.tabClear=function(params){var param=params[0];if(param<=0){delete this.tabs[this.x];}else if(param===3){this.tabs={};}};/**
1992 | * CSI Pm i Media Copy (MC).
1993 | * Ps = 0 -> Print screen (default).
1994 | * Ps = 4 -> Turn off printer controller mode.
1995 | * Ps = 5 -> Turn on printer controller mode.
1996 | * CSI ? Pm i
1997 | * Media Copy (MC, DEC-specific).
1998 | * Ps = 1 -> Print line containing cursor.
1999 | * Ps = 4 -> Turn off autoprint mode.
2000 | * Ps = 5 -> Turn on autoprint mode.
2001 | * Ps = 1 0 -> Print composed display, ignores DECPEX.
2002 | * Ps = 1 1 -> Print all pages.
2003 | */Terminal.prototype.mediaCopy=function(params){;};/**
2004 | * CSI > Ps; Ps m
2005 | * Set or reset resource-values used by xterm to decide whether
2006 | * to construct escape sequences holding information about the
2007 | * modifiers pressed with a given key. The first parameter iden-
2008 | * tifies the resource to set/reset. The second parameter is the
2009 | * value to assign to the resource. If the second parameter is
2010 | * omitted, the resource is reset to its initial value.
2011 | * Ps = 1 -> modifyCursorKeys.
2012 | * Ps = 2 -> modifyFunctionKeys.
2013 | * Ps = 4 -> modifyOtherKeys.
2014 | * If no parameters are given, all resources are reset to their
2015 | * initial values.
2016 | */Terminal.prototype.setResources=function(params){;};/**
2017 | * CSI > Ps n
2018 | * Disable modifiers which may be enabled via the CSI > Ps; Ps m
2019 | * sequence. This corresponds to a resource value of "-1", which
2020 | * cannot be set with the other sequence. The parameter identi-
2021 | * fies the resource to be disabled:
2022 | * Ps = 1 -> modifyCursorKeys.
2023 | * Ps = 2 -> modifyFunctionKeys.
2024 | * Ps = 4 -> modifyOtherKeys.
2025 | * If the parameter is omitted, modifyFunctionKeys is disabled.
2026 | * When modifyFunctionKeys is disabled, xterm uses the modifier
2027 | * keys to make an extended sequence of functions rather than
2028 | * adding a parameter to each function key to denote the modi-
2029 | * fiers.
2030 | */Terminal.prototype.disableModifiers=function(params){;};/**
2031 | * CSI > Ps p
2032 | * Set resource value pointerMode. This is used by xterm to
2033 | * decide whether to hide the pointer cursor as the user types.
2034 | * Valid values for the parameter:
2035 | * Ps = 0 -> never hide the pointer.
2036 | * Ps = 1 -> hide if the mouse tracking mode is not enabled.
2037 | * Ps = 2 -> always hide the pointer. If no parameter is
2038 | * given, xterm uses the default, which is 1 .
2039 | */Terminal.prototype.setPointerMode=function(params){;};/**
2040 | * CSI ! p Soft terminal reset (DECSTR).
2041 | * http://vt100.net/docs/vt220-rm/table4-10.html
2042 | */Terminal.prototype.softReset=function(params){this.cursorHidden=false;this.insertMode=false;this.originMode=false;this.wraparoundMode=false;// autowrap
2043 | this.applicationKeypad=false;// ?
2044 | this.viewport.syncScrollArea();this.applicationCursor=false;this.scrollTop=0;this.scrollBottom=this.rows-1;this.curAttr=this.defAttr;this.x=this.y=0;// ?
2045 | this.charset=null;this.glevel=0;// ??
2046 | this.charsets=[null];// ??
2047 | };/**
2048 | * CSI Ps$ p
2049 | * Request ANSI mode (DECRQM). For VT300 and up, reply is
2050 | * CSI Ps; Pm$ y
2051 | * where Ps is the mode number as in RM, and Pm is the mode
2052 | * value:
2053 | * 0 - not recognized
2054 | * 1 - set
2055 | * 2 - reset
2056 | * 3 - permanently set
2057 | * 4 - permanently reset
2058 | */Terminal.prototype.requestAnsiMode=function(params){;};/**
2059 | * CSI ? Ps$ p
2060 | * Request DEC private mode (DECRQM). For VT300 and up, reply is
2061 | * CSI ? Ps; Pm$ p
2062 | * where Ps is the mode number as in DECSET, Pm is the mode value
2063 | * as in the ANSI DECRQM.
2064 | */Terminal.prototype.requestPrivateMode=function(params){;};/**
2065 | * CSI Ps ; Ps " p
2066 | * Set conformance level (DECSCL). Valid values for the first
2067 | * parameter:
2068 | * Ps = 6 1 -> VT100.
2069 | * Ps = 6 2 -> VT200.
2070 | * Ps = 6 3 -> VT300.
2071 | * Valid values for the second parameter:
2072 | * Ps = 0 -> 8-bit controls.
2073 | * Ps = 1 -> 7-bit controls (always set for VT100).
2074 | * Ps = 2 -> 8-bit controls.
2075 | */Terminal.prototype.setConformanceLevel=function(params){;};/**
2076 | * CSI Ps q Load LEDs (DECLL).
2077 | * Ps = 0 -> Clear all LEDS (default).
2078 | * Ps = 1 -> Light Num Lock.
2079 | * Ps = 2 -> Light Caps Lock.
2080 | * Ps = 3 -> Light Scroll Lock.
2081 | * Ps = 2 1 -> Extinguish Num Lock.
2082 | * Ps = 2 2 -> Extinguish Caps Lock.
2083 | * Ps = 2 3 -> Extinguish Scroll Lock.
2084 | */Terminal.prototype.loadLEDs=function(params){;};/**
2085 | * CSI Ps SP q
2086 | * Set cursor style (DECSCUSR, VT520).
2087 | * Ps = 0 -> blinking block.
2088 | * Ps = 1 -> blinking block (default).
2089 | * Ps = 2 -> steady block.
2090 | * Ps = 3 -> blinking underline.
2091 | * Ps = 4 -> steady underline.
2092 | */Terminal.prototype.setCursorStyle=function(params){;};/**
2093 | * CSI Ps " q
2094 | * Select character protection attribute (DECSCA). Valid values
2095 | * for the parameter:
2096 | * Ps = 0 -> DECSED and DECSEL can erase (default).
2097 | * Ps = 1 -> DECSED and DECSEL cannot erase.
2098 | * Ps = 2 -> DECSED and DECSEL can erase.
2099 | */Terminal.prototype.setCharProtectionAttr=function(params){;};/**
2100 | * CSI ? Pm r
2101 | * Restore DEC Private Mode Values. The value of Ps previously
2102 | * saved is restored. Ps values are the same as for DECSET.
2103 | */Terminal.prototype.restorePrivateValues=function(params){;};/**
2104 | * CSI Pt; Pl; Pb; Pr; Ps$ r
2105 | * Change Attributes in Rectangular Area (DECCARA), VT400 and up.
2106 | * Pt; Pl; Pb; Pr denotes the rectangle.
2107 | * Ps denotes the SGR attributes to change: 0, 1, 4, 5, 7.
2108 | * NOTE: xterm doesn't enable this code by default.
2109 | */Terminal.prototype.setAttrInRectangle=function(params){var t=params[0],l=params[1],b=params[2],r=params[3],attr=params[4];var line,i;for(;t Locator disabled (default).
2122 | * Ps = 1 -> Locator enabled.
2123 | * Ps = 2 -> Locator enabled for one report, then disabled.
2124 | * The second parameter specifies the coordinate unit for locator
2125 | * reports.
2126 | * Valid values for the second parameter:
2127 | * Pu = 0 <- or omitted -> default to character cells.
2128 | * Pu = 1 <- device physical pixels.
2129 | * Pu = 2 <- character cells.
2130 | */Terminal.prototype.enableLocatorReporting=function(params){var val=params[0]>0;//this.mouseEvents = val;
2131 | //this.decLocator = val;
2132 | };/**
2133 | * CSI Pt; Pl; Pb; Pr$ z
2134 | * Erase Rectangular Area (DECERA), VT400 and up.
2135 | * Pt; Pl; Pb; Pr denotes the rectangle.
2136 | * NOTE: xterm doesn't enable this code by default.
2137 | */Terminal.prototype.eraseRectangle=function(params){var t=params[0],l=params[1],b=params[2],r=params[3];var line,i,ch;ch=[this.eraseAttr(),' ',1];// xterm?
2138 | for(;t47);}function matchColor(r1,g1,b1){var hash=r1<<16|g1<<8|b1;if(matchColor._cache[hash]!=null){return matchColor._cache[hash];}var ldiff=Infinity,li=-1,i=0,c,r2,g2,b2,diff;for(;iCOMBINING[max][1])return false;while(max>=min){mid=Math.floor((min+max)/2);if(ucs>COMBINING[mid][1])min=mid+1;else if(ucs=0x7f&&ucs<0xa0)return opts.control;// binary search in table of non-spacing characters
2215 | if(bisearch(ucs))return 0;// if we arrive here, ucs is not a combining or C0/C1 control character
2216 | return 1+(ucs>=0x1100&&(ucs<=0x115f||// Hangul Jamo init. consonants
2217 | ucs==0x2329||ucs==0x232a||ucs>=0x2e80&&ucs<=0xa4cf&&ucs!=0x303f||// CJK..Yi
2218 | ucs>=0xac00&&ucs<=0xd7a3||// Hangul Syllables
2219 | ucs>=0xf900&&ucs<=0xfaff||// CJK Compat Ideographs
2220 | ucs>=0xfe10&&ucs<=0xfe19||// Vertical forms
2221 | ucs>=0xfe30&&ucs<=0xfe6f||// CJK Compat Forms
2222 | ucs>=0xff00&&ucs<=0xff60||// Fullwidth Forms
2223 | ucs>=0xffe0&&ucs<=0xffe6||ucs>=0x20000&&ucs<=0x2fffd||ucs>=0x30000&&ucs<=0x3fffd));}return wcwidth;}({nul:0,control:0});// configurable options
2224 | /**
2225 | * Expose
2226 | */Terminal.EventEmitter=_EventEmitter.EventEmitter;Terminal.CompositionHelper=_CompositionHelper.CompositionHelper;Terminal.Viewport=_Viewport.Viewport;Terminal.inherits=inherits;/**
2227 | * Adds an event listener to the terminal.
2228 | *
2229 | * @param {string} event The name of the event. TODO: Document all event types
2230 | * @param {function} callback The function to call when the event is triggered.
2231 | */Terminal.on=on;Terminal.off=off;Terminal.cancel=cancel;module.exports=Terminal;
2232 |
2233 | },{"./CompositionHelper.js":1,"./EventEmitter.js":2,"./Viewport.js":3,"./handlers/Clipboard.js":4,"./utils/Browser":5}]},{},[7])(7)
2234 | });
2235 | //# sourceMappingURL=xterm.js.map
2236 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | // Deprecated: PTYs are natively supported in Windows 10 October 2018 Update (version 1809) and above, switch to https://github.com/UserExistsError/conpty and see this blog post for more details: https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/
2 | module github.com/iamacarpet/go-winpty
3 |
4 | go 1.18
5 |
6 | require github.com/gorilla/websocket v1.5.0
7 |
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
2 | github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
3 |
--------------------------------------------------------------------------------
/util.go:
--------------------------------------------------------------------------------
1 | package winpty
2 |
3 | import (
4 | "syscall"
5 | "unicode/utf16"
6 | "unsafe"
7 | )
8 |
9 | func UTF16PtrToString(p *uint16) string {
10 | var (
11 | sizeTest uint16
12 | finalStr []uint16 = make([]uint16, 0)
13 | )
14 | for {
15 | if *p == uint16(0) {
16 | break
17 | }
18 |
19 | finalStr = append(finalStr, *p)
20 | p = (*uint16)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(sizeTest)))
21 | }
22 | return string(utf16.Decode(finalStr[0:]))
23 | }
24 |
25 | func UTF16PtrFromStringArray(s []string) (*uint16, error) {
26 | var r []uint16
27 |
28 | for _, ss := range s {
29 | a, err := syscall.UTF16FromString(ss)
30 | if err != nil {
31 | return nil, err
32 | }
33 |
34 | r = append(r, a...)
35 | }
36 |
37 | r = append(r, 0)
38 |
39 | return &r[0], nil
40 | }
41 |
42 | func GetErrorMessage(ptr uintptr) string {
43 | msgPtr, _, _ := winpty_error_msg.Call(ptr)
44 | if msgPtr == uintptr(0) {
45 | return "Unknown Error"
46 | }
47 | return UTF16PtrToString((*uint16)(unsafe.Pointer(msgPtr)))
48 | }
49 |
--------------------------------------------------------------------------------
/winpty.go:
--------------------------------------------------------------------------------
1 | package winpty
2 |
3 | import (
4 | "fmt"
5 | "os"
6 | "syscall"
7 | "unsafe"
8 | )
9 |
10 | type Options struct {
11 | // DLLPrefix is the path to winpty.dll and winpty-agent.exe
12 | DLLPrefix string
13 |
14 | // AppName sets the title of the console
15 | AppName string
16 |
17 | // Command is the full command to launch
18 | Command string
19 |
20 | // Dir sets the current working directory for the command
21 | Dir string
22 |
23 | // Env sets the environment variables. Use the format VAR=VAL.
24 | Env []string
25 |
26 | // Flags to pass to agent config creation
27 | Flags uint32
28 |
29 | // Initial size for Columns and Rows
30 | InitialCols uint32
31 | InitialRows uint32
32 | }
33 |
34 | type WinPTY struct {
35 | StdIn *os.File
36 | StdOut *os.File
37 |
38 | wp uintptr
39 | childHandle uintptr
40 | closed bool
41 | }
42 |
43 | // accepts path to command to execute, then arguments.
44 | // returns WinPTY object pointer, error.
45 | // remember to call Close on WinPTY object when done.
46 | func Open(dllPrefix, cmd string) (*WinPTY, error) {
47 | return OpenWithOptions(Options{
48 | DLLPrefix: dllPrefix,
49 | Command: cmd,
50 | })
51 | }
52 |
53 | // the same as open, but uses defaults for Env & Dir
54 | func OpenDefault(dllPrefix, cmd string) (*WinPTY, error) {
55 | wd, err := os.Getwd()
56 | if err != nil {
57 | return nil, fmt.Errorf("Failed to get dir on setup: %s", err)
58 | }
59 |
60 | return OpenWithOptions(Options{
61 | DLLPrefix: dllPrefix,
62 | Command: cmd,
63 | Dir: wd,
64 | Env: os.Environ(),
65 | })
66 | }
67 |
68 | func OpenWithOptions(options Options) (*WinPTY, error) {
69 | setupDefines(options.DLLPrefix)
70 |
71 | // create config with specified Flags
72 | agentCfg, err := createAgentCfg(options.Flags)
73 |
74 | if err != nil {
75 | return nil, err
76 | }
77 |
78 | // Set the initial size to 40x40 if options is 0
79 | if options.InitialCols <= 0 {
80 | options.InitialCols = 40
81 | }
82 | if options.InitialRows <= 0 {
83 | options.InitialRows = 40
84 | }
85 | winpty_config_set_initial_size.Call(agentCfg, uintptr(options.InitialCols), uintptr(options.InitialRows))
86 |
87 | var openErr uintptr
88 | defer winpty_error_free.Call(openErr)
89 | wp, _, _ := winpty_open.Call(agentCfg, uintptr(unsafe.Pointer(openErr)))
90 |
91 | if wp == uintptr(0) {
92 | return nil, fmt.Errorf("Error Launching WinPTY agent, %s", GetErrorMessage(openErr))
93 | }
94 |
95 | winpty_config_free.Call(agentCfg)
96 |
97 | stdin_name, _, _ := winpty_conin_name.Call(wp)
98 | stdout_name, _, _ := winpty_conout_name.Call(wp)
99 |
100 | obj := &WinPTY{}
101 | stdin_handle, err := syscall.CreateFile((*uint16)(unsafe.Pointer(stdin_name)), syscall.GENERIC_WRITE, 0, nil, syscall.OPEN_EXISTING, 0, 0)
102 | if err != nil {
103 | return nil, fmt.Errorf("Error getting stdin handle. %s", err)
104 | }
105 | obj.StdIn = os.NewFile(uintptr(stdin_handle), "stdin")
106 | stdout_handle, err := syscall.CreateFile((*uint16)(unsafe.Pointer(stdout_name)), syscall.GENERIC_READ, 0, nil, syscall.OPEN_EXISTING, 0, 0)
107 | if err != nil {
108 | return nil, fmt.Errorf("Error getting stdout handle. %s", err)
109 | }
110 | obj.StdOut = os.NewFile(uintptr(stdout_handle), "stdout")
111 |
112 | spawnCfg, err := createSpawnCfg(WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN, options.AppName, options.Command, options.Dir, options.Env)
113 |
114 | if err != nil {
115 | return nil, err
116 | }
117 |
118 | var (
119 | spawnErr uintptr
120 | lastError *uint32
121 | )
122 | spawnRet, _, _ := winpty_spawn.Call(wp, spawnCfg, uintptr(unsafe.Pointer(&obj.childHandle)), uintptr(0), uintptr(unsafe.Pointer(lastError)), uintptr(unsafe.Pointer(spawnErr)))
123 | winpty_spawn_config_free.Call(spawnCfg)
124 | defer winpty_error_free.Call(spawnErr)
125 |
126 | if spawnRet == 0 {
127 | return nil, fmt.Errorf("Error spawning process...")
128 | } else {
129 | obj.wp = wp
130 | return obj, nil
131 | }
132 | }
133 |
134 | func (obj *WinPTY) SetSize(ws_col, ws_row uint32) {
135 | if ws_col == 0 || ws_row == 0 {
136 | return
137 | }
138 | winpty_set_size.Call(obj.wp, uintptr(ws_col), uintptr(ws_row), uintptr(0))
139 | }
140 |
141 | func (obj *WinPTY) Close() {
142 | if obj.closed {
143 | return
144 | }
145 |
146 | winpty_free.Call(obj.wp)
147 |
148 | obj.StdIn.Close()
149 | obj.StdOut.Close()
150 |
151 | syscall.CloseHandle(syscall.Handle(obj.childHandle))
152 |
153 | obj.closed = true
154 | }
155 |
156 | func (obj *WinPTY) GetProcHandle() uintptr {
157 | return obj.childHandle
158 | }
159 |
--------------------------------------------------------------------------------
/winpty_386.go:
--------------------------------------------------------------------------------
1 | package winpty
2 |
3 | import (
4 | "fmt"
5 | "syscall"
6 | "unsafe"
7 | )
8 |
9 | func createAgentCfg(flags uint32) (uintptr, error) {
10 | var errorPtr uintptr
11 |
12 | err := winpty_error_free.Find() // check if dll available
13 | if err != nil {
14 | return uintptr(0), err
15 | }
16 |
17 | defer winpty_error_free.Call(errorPtr)
18 |
19 | agentCfg, _, _ := winpty_config_new.Call(
20 | uintptr(flags),
21 | uintptr(0), // winpty expects a UINT64 so we need to pad the call on 386
22 | uintptr(unsafe.Pointer(errorPtr)),
23 | )
24 |
25 | if agentCfg == uintptr(0) {
26 | return 0, fmt.Errorf("Unable to create agent config, %s", GetErrorMessage(errorPtr))
27 | }
28 |
29 | return agentCfg, nil
30 | }
31 |
32 | func createSpawnCfg(flags uint32, appname, cmdline, cwd string, env []string) (uintptr, error) {
33 | var errorPtr uintptr
34 | defer winpty_error_free.Call(errorPtr)
35 |
36 | cmdLineStr, err := syscall.UTF16PtrFromString(cmdline)
37 | if err != nil {
38 | return 0, fmt.Errorf("Failed to convert cmd to pointer.")
39 | }
40 |
41 | appNameStr, err := syscall.UTF16PtrFromString(appname)
42 | if err != nil {
43 | return 0, fmt.Errorf("Failed to convert app name to pointer.")
44 | }
45 |
46 | cwdStr, err := syscall.UTF16PtrFromString(cwd)
47 | if err != nil {
48 | return 0, fmt.Errorf("Failed to convert working directory to pointer.")
49 | }
50 |
51 | envStr, err := UTF16PtrFromStringArray(env)
52 |
53 | if err != nil {
54 | return 0, fmt.Errorf("Failed to convert cmd to pointer.")
55 | }
56 |
57 | spawnCfg, _, _ := winpty_spawn_config_new.Call(
58 | uintptr(flags),
59 | uintptr(0), // winpty expects a UINT64 so we need to pad the call on 386
60 | uintptr(unsafe.Pointer(appNameStr)),
61 | uintptr(unsafe.Pointer(cmdLineStr)),
62 | uintptr(unsafe.Pointer(cwdStr)),
63 | uintptr(unsafe.Pointer(envStr)),
64 | uintptr(unsafe.Pointer(errorPtr)),
65 | )
66 |
67 | if spawnCfg == uintptr(0) {
68 | return 0, fmt.Errorf("Unable to create spawn config, %s", GetErrorMessage(errorPtr))
69 | }
70 |
71 | return spawnCfg, nil
72 | }
73 |
--------------------------------------------------------------------------------
/winpty_amd64.go:
--------------------------------------------------------------------------------
1 | package winpty
2 |
3 | import (
4 | "fmt"
5 | "syscall"
6 | "unsafe"
7 | )
8 |
9 | func createAgentCfg(flags uint32) (uintptr, error) {
10 | var errorPtr uintptr
11 |
12 | err := winpty_error_free.Find() // check if dll available
13 | if err != nil {
14 | return uintptr(0), err
15 | }
16 |
17 | defer winpty_error_free.Call(errorPtr)
18 |
19 | agentCfg, _, _ := winpty_config_new.Call(uintptr(flags), uintptr(unsafe.Pointer(errorPtr)))
20 | if agentCfg == uintptr(0) {
21 | return 0, fmt.Errorf("Unable to create agent config, %s", GetErrorMessage(errorPtr))
22 | }
23 |
24 | return agentCfg, nil
25 | }
26 |
27 | func createSpawnCfg(flags uint32, appname, cmdline, cwd string, env []string) (uintptr, error) {
28 | var errorPtr uintptr
29 | defer winpty_error_free.Call(errorPtr)
30 |
31 | cmdLineStr, err := syscall.UTF16PtrFromString(cmdline)
32 | if err != nil {
33 | return 0, fmt.Errorf("Failed to convert cmd to pointer.")
34 | }
35 |
36 | appNameStr, err := syscall.UTF16PtrFromString(appname)
37 | if err != nil {
38 | return 0, fmt.Errorf("Failed to convert app name to pointer.")
39 | }
40 |
41 | cwdStr, err := syscall.UTF16PtrFromString(cwd)
42 | if err != nil {
43 | return 0, fmt.Errorf("Failed to convert working directory to pointer.")
44 | }
45 |
46 | envStr, err := UTF16PtrFromStringArray(env)
47 |
48 | if err != nil {
49 | return 0, fmt.Errorf("Failed to convert cmd to pointer.")
50 | }
51 |
52 | spawnCfg, _, _ := winpty_spawn_config_new.Call(
53 | uintptr(flags),
54 | uintptr(unsafe.Pointer(appNameStr)),
55 | uintptr(unsafe.Pointer(cmdLineStr)),
56 | uintptr(unsafe.Pointer(cwdStr)),
57 | uintptr(unsafe.Pointer(envStr)),
58 | uintptr(unsafe.Pointer(errorPtr)),
59 | )
60 |
61 | if spawnCfg == uintptr(0) {
62 | return 0, fmt.Errorf("Unable to create spawn config, %s", GetErrorMessage(errorPtr))
63 | }
64 |
65 | return spawnCfg, nil
66 | }
67 |
--------------------------------------------------------------------------------