Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7c2e16d0
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7c2e16d0
编写于
11月 24, 2016
作者:
N
Nick Thomas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add xterm.js 2.1.0 and a wrapper class to the asset pipeline
上级
dcddd0f3
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
4596 addition
and
0 deletion
+4596
-0
app/assets/javascripts/terminal/terminal.js.es6
app/assets/javascripts/terminal/terminal.js.es6
+62
-0
app/assets/javascripts/terminal/terminal_bundle.js.es6
app/assets/javascripts/terminal/terminal_bundle.js.es6
+5
-0
config/application.rb
config/application.rb
+2
-0
vendor/assets/javascripts/xterm/fit.js
vendor/assets/javascripts/xterm/fit.js
+86
-0
vendor/assets/javascripts/xterm/xterm.js
vendor/assets/javascripts/xterm/xterm.js
+2235
-0
vendor/assets/stylesheets/xterm/xterm.css
vendor/assets/stylesheets/xterm/xterm.css
+2206
-0
未找到文件。
app/assets/javascripts/terminal/terminal.js.es6
0 → 100644
浏览文件 @
7c2e16d0
/* global Terminal */
(() => {
class GLTerminal {
constructor(options) {
this.options = options || {};
this.options.cursorBlink = options.cursorBlink || true;
this.options.screenKeys = options.screenKeys || true;
this.container = document.querySelector(options.selector);
this.setSocketUrl();
this.createTerminal();
$(window).off('resize.terminal').on('resize.terminal', () => {
this.terminal.fit();
});
}
setSocketUrl() {
const { protocol, hostname, port } = window.location;
const wsProtocol = protocol === 'https:' ? 'wss://' : 'ws://';
const path = this.container.dataset.projectPath;
this.socketUrl = `${wsProtocol}${hostname}:${port}${path}`;
}
createTerminal() {
this.terminal = new Terminal(this.options);
this.socket = new WebSocket(this.socketUrl, ['terminal.gitlab.com']);
this.socket.binaryType = 'arraybuffer';
this.terminal.open(this.container);
this.socket.onopen = () => { this.runTerminal(); };
this.socket.onerror = () => { this.handleSocketFailure(); };
}
runTerminal() {
const decoder = new TextDecoder('utf-8');
const encoder = new TextEncoder('utf-8');
this.terminal.on('data', (data) => {
this.socket.send(encoder.encode(data));
});
this.socket.addEventListener('message', (ev) => {
this.terminal.write(decoder.decode(ev.data));
});
this.isTerminalInitialized = true;
this.terminal.fit();
}
handleSocketFailure() {
this.terminal.write('\r\nConnection failure');
}
}
window.gl = window.gl || {};
gl.Terminal = GLTerminal;
})();
app/assets/javascripts/terminal/terminal_bundle.js.es6
0 → 100644
浏览文件 @
7c2e16d0
//= require xterm/xterm.js
//= require xterm/fit.js
//= require ./terminal.js
$(() => new gl.Terminal({ selector: '#terminal' }));
config/application.rb
浏览文件 @
7c2e16d0
...
...
@@ -89,6 +89,7 @@ module Gitlab
config
.
assets
.
precompile
<<
"mailers/*.css"
config
.
assets
.
precompile
<<
"katex.css"
config
.
assets
.
precompile
<<
"katex.js"
config
.
assets
.
precompile
<<
"xterm/xterm.css"
config
.
assets
.
precompile
<<
"graphs/graphs_bundle.js"
config
.
assets
.
precompile
<<
"users/users_bundle.js"
config
.
assets
.
precompile
<<
"network/network_bundle.js"
...
...
@@ -102,6 +103,7 @@ module Gitlab
config
.
assets
.
precompile
<<
"environments/environments_bundle.js"
config
.
assets
.
precompile
<<
"blob_edit/blob_edit_bundle.js"
config
.
assets
.
precompile
<<
"snippet/snippet_bundle.js"
config
.
assets
.
precompile
<<
"terminal/terminal_bundle.js"
config
.
assets
.
precompile
<<
"lib/utils/*.js"
config
.
assets
.
precompile
<<
"lib/*.js"
config
.
assets
.
precompile
<<
"u2f.js"
...
...
vendor/assets/javascripts/xterm/fit.js
0 → 100644
浏览文件 @
7c2e16d0
/*
* Fit terminal columns and rows to the dimensions of its
* DOM element.
*
* Approach:
* - Rows: Truncate the division of the terminal parent element height
* by the terminal row height
*
* - Columns: Truncate the division of the terminal parent element width by
* the terminal character width (apply display: inline at the
* terminal row and truncate its width with the current number
* of columns)
*/
(
function
(
fit
)
{
if
(
typeof
exports
===
'
object
'
&&
typeof
module
===
'
object
'
)
{
/*
* CommonJS environment
*/
module
.
exports
=
fit
(
require
(
'
../../xterm
'
));
}
else
if
(
typeof
define
==
'
function
'
)
{
/*
* Require.js is available
*/
define
([
'
../../xterm
'
],
fit
);
}
else
{
/*
* Plain browser environment
*/
fit
(
window
.
Terminal
);
}
})(
function
(
Xterm
)
{
/**
* This module provides methods for fitting a terminal's size to a parent container.
*
* @module xterm/addons/fit/fit
*/
var
exports
=
{};
exports
.
proposeGeometry
=
function
(
term
)
{
var
parentElementStyle
=
window
.
getComputedStyle
(
term
.
element
.
parentElement
),
parentElementHeight
=
parseInt
(
parentElementStyle
.
getPropertyValue
(
'
height
'
)),
parentElementWidth
=
parseInt
(
parentElementStyle
.
getPropertyValue
(
'
width
'
)),
elementStyle
=
window
.
getComputedStyle
(
term
.
element
),
elementPaddingVer
=
parseInt
(
elementStyle
.
getPropertyValue
(
'
padding-top
'
))
+
parseInt
(
elementStyle
.
getPropertyValue
(
'
padding-bottom
'
)),
elementPaddingHor
=
parseInt
(
elementStyle
.
getPropertyValue
(
'
padding-right
'
))
+
parseInt
(
elementStyle
.
getPropertyValue
(
'
padding-left
'
)),
availableHeight
=
parentElementHeight
-
elementPaddingVer
,
availableWidth
=
parentElementWidth
-
elementPaddingHor
,
container
=
term
.
rowContainer
,
subjectRow
=
term
.
rowContainer
.
firstElementChild
,
contentBuffer
=
subjectRow
.
innerHTML
,
characterHeight
,
rows
,
characterWidth
,
cols
,
geometry
;
subjectRow
.
style
.
display
=
'
inline
'
;
subjectRow
.
innerHTML
=
'
W
'
;
// Common character for measuring width, although on monospace
characterWidth
=
subjectRow
.
getBoundingClientRect
().
width
;
subjectRow
.
style
.
display
=
''
;
// Revert style before calculating height, since they differ.
characterHeight
=
parseInt
(
subjectRow
.
offsetHeight
);
subjectRow
.
innerHTML
=
contentBuffer
;
rows
=
parseInt
(
availableHeight
/
characterHeight
);
cols
=
parseInt
(
availableWidth
/
characterWidth
)
-
1
;
geometry
=
{
cols
:
cols
,
rows
:
rows
};
return
geometry
;
};
exports
.
fit
=
function
(
term
)
{
var
geometry
=
exports
.
proposeGeometry
(
term
);
term
.
resize
(
geometry
.
cols
,
geometry
.
rows
);
};
Xterm
.
prototype
.
proposeGeometry
=
function
()
{
return
exports
.
proposeGeometry
(
this
);
};
Xterm
.
prototype
.
fit
=
function
()
{
return
exports
.
fit
(
this
);
};
return
exports
;
});
vendor/assets/javascripts/xterm/xterm.js
0 → 100644
浏览文件 @
7c2e16d0
此差异已折叠。
点击以展开。
vendor/assets/stylesheets/xterm/xterm.css
0 → 100644
浏览文件 @
7c2e16d0
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录