зеркало из https://github.com/mozilla/pluotsorbet.git
Add terminal view.
This commit is contained in:
Родитель
cac279df8b
Коммит
142cb4d0d8
|
@ -4,6 +4,7 @@
|
|||
'use strict';
|
||||
|
||||
(function() {
|
||||
|
||||
var windowConsole = window.console;
|
||||
|
||||
var LOG_LEVELS = {
|
||||
|
@ -21,6 +22,7 @@
|
|||
* web: the browser's Web Console (default)
|
||||
* page: the in-page console (an HTML element with ID "console")
|
||||
* native: the native console (via the *dump* function)
|
||||
* terminal: a faster canvas based console if Shumway.js is included.
|
||||
*/
|
||||
var ENABLED_CONSOLE_TYPES = (urlParams.logConsole || "page").split(",");
|
||||
var minLogLevel = LOG_LEVELS[urlParams.logLevel || "log"];
|
||||
|
@ -215,11 +217,50 @@
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
function TerminalConsole(name) {
|
||||
// If we don't have shumway included fall back on the page console.
|
||||
if (typeof Shumway === "undefined") {
|
||||
return new PageConsole("#console");
|
||||
}
|
||||
var traceTerminal = new Shumway.Tools.Terminal.Terminal(document.getElementById(name));
|
||||
traceTerminal.refreshEvery(100);
|
||||
|
||||
this.appendToTraceTerminal = function appendToTraceTerminal(str, color) {
|
||||
var scroll = traceTerminal.isScrolledToBottom();
|
||||
traceTerminal.buffer.append(str, color);
|
||||
if (scroll) {
|
||||
traceTerminal.gotoLine(traceTerminal.buffer.length - 1);
|
||||
traceTerminal.scrollIntoView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var contextColors = ["#111111", "#222222", "#333333", "#444444", "#555555", "#666666"];
|
||||
var colors = [undefined, undefined, undefined, "darkorange", "red", "blue"];
|
||||
|
||||
TerminalConsole.prototype = {
|
||||
push: function(item) {
|
||||
if (item.matchesCurrentFilters()) {
|
||||
var color;
|
||||
|
||||
if (item.logLevel < 3) {
|
||||
var id = item.ctx.runtime.id + item.ctx.id;
|
||||
color = contextColors[id % contextColors.length];
|
||||
} else {
|
||||
color = colors[item.logLevel]
|
||||
}
|
||||
this.appendToTraceTerminal(item.message, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var CONSOLES = {
|
||||
page: new PageConsole("#console"),
|
||||
web: new WebConsole(),
|
||||
native: new NativeConsole(),
|
||||
raw: new RawConsoleForTests("#raw-console")
|
||||
raw: new RawConsoleForTests("#raw-console"),
|
||||
terminal: new TerminalConsole("traceTerminal")
|
||||
};
|
||||
|
||||
var print = CONSOLES.web.print.bind(CONSOLES.web);
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
<link rel="stylesheet" type="text/css" href="style/progress_activity.css">
|
||||
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<script type="text/javascript" src="build/shumway.js" defer></script>
|
||||
<script type="text/javascript" src="libs/urlparams.js" defer></script>
|
||||
<script type="text/javascript" src="libs/console.js" defer></script>
|
||||
<script type="text/javascript" src="legacy.js" defer></script>
|
||||
<script type="text/javascript" src="blackBox.js" defer></script>
|
||||
<script type="text/javascript" src="timer.js" defer></script>
|
||||
<script type="text/javascript" src="util.js" defer></script>
|
||||
<script type="text/javascript" src="build/shumway.js" defer></script>
|
||||
<script type="text/javascript" src="build/j2me.js" defer></script>
|
||||
<!--<script type="text/javascript" src="build/j2me.cc.js" defer></script>-->
|
||||
<script type="text/javascript" src="override.js" defer></script>
|
||||
|
@ -68,8 +68,9 @@
|
|||
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
<div id="traceTerminalContainer">
|
||||
<pre id="console"></pre>
|
||||
<canvas id="traceTerminal" tabindex='2'></canvas>
|
||||
</div>
|
||||
<div>
|
||||
<div id="profilerContainer" class="collapsed">
|
||||
|
|
|
@ -97,7 +97,7 @@ module Shumway.Tools.Terminal {
|
|||
this.columnIndex = 0;
|
||||
this.selection = null;
|
||||
this.lineHeight = 15;
|
||||
this.hasFocus = false;
|
||||
this.hasFocus = true;
|
||||
|
||||
window.addEventListener('resize', this._resizeHandler.bind(this), false);
|
||||
this._resizeHandler();
|
||||
|
@ -245,7 +245,7 @@ module Shumway.Tools.Terminal {
|
|||
this.canvas.width = cw;
|
||||
this.canvas.height = ch;
|
||||
}
|
||||
this.pageLineCount = Math.floor(this.canvas.height / this.lineHeight);
|
||||
this.pageLineCount = Math.floor(ch / this.lineHeight);
|
||||
}
|
||||
|
||||
gotoLine(index) {
|
||||
|
|
|
@ -60,18 +60,6 @@ button {
|
|||
font-size: 12px;
|
||||
}
|
||||
|
||||
#console {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 350px;
|
||||
left: 0;
|
||||
right: 240px;
|
||||
margin: 0;
|
||||
padding: 0.5rem;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
|
||||
.log-item-log {
|
||||
color: #555;
|
||||
}
|
||||
|
@ -187,13 +175,29 @@ button {
|
|||
line-height: 1.2;
|
||||
}
|
||||
|
||||
#console {
|
||||
position: fixed;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#traceTerminalContainer {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 250px;
|
||||
left: 0;
|
||||
right: 240px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
/*background-color: rgba(0, 0, 0, 0.8);*/
|
||||
}
|
||||
|
||||
#profilerContainer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
width: auto;
|
||||
height: 350px;
|
||||
width: 240;
|
||||
height: 250px;
|
||||
overflow: hidden;
|
||||
background-color: #000;
|
||||
color: #ffffff;
|
||||
|
|
Загрузка…
Ссылка в новой задаче