Permalink
Browse files

use bower

  • Loading branch information...
1 parent a5e80fe commit c951197e6ea276191b215e274f79aaf5b38a8a5f @dtinth committed Feb 2, 2013
View
@@ -0,0 +1,3 @@
+{
+ "directory": "static/components"
+}
View
@@ -46,13 +46,6 @@ io.set('log level', 1)
// serve static files
app.use(connect.static(__dirname + '/static'))
-// serve the screen buffer library
-var bufferPath = require.resolve('headless-terminal/screen-buffer')
-app.use('/screen-buffer.js', function(req, res, next) {
- send(req, '/' + path.basename(bufferPath)).root(path.dirname(bufferPath))
- .pipe(res)
-})
-
// create a terminal emulator
var term = new HeadlessTerminal(cols, rows)
View
@@ -0,0 +1,7 @@
+{
+ "name": "ttycast",
+ "version": "0.0.0",
+ "dependencies": {
+ "ttycast-client": "git://github.com/dtinth/ttycast-client.git#~0.1.1"
+ }
+}
@@ -0,0 +1,2 @@
+
+screen buffer component
@@ -0,0 +1,16 @@
+{
+ "name": "screen-buffer",
+ "version": "0.1.2",
+ "main": [
+ "./screen-buffer.js"
+ ],
+ "gitHead": "5e27c8eaf905f57875429751fd942bb3f2fa6a5d",
+ "readme": "\nscreen buffer component\n",
+ "readmeFilename": "README.md",
+ "_id": "screen-buffer@0.1.2",
+ "description": "screen buffer component",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/dtinth/screen-buffer.git"
+ }
+}
@@ -0,0 +1,15 @@
+{
+ "name": "screen-buffer",
+ "version": "0.1.2",
+ "description": "A simple screen buffer component",
+ "main": "screen-buffer.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/dtinth/screen-buffer.git"
+ },
+ "author": "Thai Pangsakulyanont <org.yi.dttvb@gmail.com>",
+ "license": "MIT"
+}
@@ -0,0 +1,115 @@
+
+/**
+ * A ScreenBuffer represents a visible portion of a terminal in a screen.
+ * A ScreenBuffer contains a lot of cells. Each cell contains a character
+ * and attributes, such as color and boldness. It also keeps track of cursor position.
+ */
+function ScreenBuffer() {
+ this.data = []
+}
+
+/**
+ * Set one line of data in the ScreenBuffer.
+ * y is the row in the screen and data array looks like this:
+ * [ [attribute, character], ... ]
+ */
+ScreenBuffer.prototype.update = function(y, target) {
+ var arr = this.data[y] || (this.data[y] = [])
+ for (var i = 0; i < target.length; i ++) {
+ if (target[i]) {
+ arr[i] = [target[i][0], target[i][1]]
+ } else {
+ arr[i] = [0, ' ']
+ }
+ }
+}
+
+/** Returns things in the display buffer... */
+ScreenBuffer.prototype.toString = function() {
+ var lines = []
+ for (var i = 0; i < this.data.length; i ++) {
+ var arr = this.data[i], o = ''
+ for (var j = 0; j < arr.length; j ++) {
+ if (arr[j]) o += arr[j][1]
+ }
+ lines.push(o)
+ }
+ return lines.join('\n')
+}
+
+
+/* ====================================================
+ * Here are the operations that can be performed on a ScreenBuffer.
+ */
+
+/** Sets the cursor position to (x, y) */
+ScreenBuffer.prototype.setCursor = function(x, y) {
+ this.cursorX = x
+ this.cursorY = y
+}
+
+/** Returns the number of rows in this buffer */
+ScreenBuffer.prototype.getRows = function() {
+ return this.data.length
+}
+
+/** Returns the number of columns in a certain row in this buffer */
+ScreenBuffer.prototype.getCols = function(row) {
+ return this.data[row] ? this.data[row].length : 0
+}
+
+/** Sets the number of rows in this buffer */
+ScreenBuffer.prototype.setRows = function(rows) {
+ this.data.length = rows
+}
+
+/** Sets the number of columns in a certain row in this buffer */
+ScreenBuffer.prototype.setCols = function(row, cols) {
+ var arr = this.data[row] || (this.data[row] = [])
+ arr.length = cols
+}
+
+/** Gets the cell at row `row`, column `col`.
+ * Returns [ attributes, ch ] */
+ScreenBuffer.prototype.getCell = function(row, col) {
+ return this.data[row] ? (this.data[row][col] || [0, ' ']) : [0, ' ']
+}
+
+/**
+ * Draws some data to this ScreenBuffer on row `row`, starting at column `col`.
+ * The patcher will generate a command for this...
+ * No need to use this directly.
+ */
+ScreenBuffer.prototype.draw = function(row, col, text, attrsCompressed) {
+
+ // unpack the attributes
+ var attrs = []
+ for (var i = 0; i < attrsCompressed.length; i ++) {
+ var c = attrsCompressed[i]
+ for (var j = 0; j < c[1]; j ++) {
+ attrs[attrs.length] = c[0]
+ }
+ }
+
+ // draw...
+ var arr = this.data[row] || (this.data[row] = [])
+ for (var i = 0; i < attrs.length; i ++) {
+ arr[col + i] = [attrs[i], text.charAt(i)]
+ }
+
+}
+
+/**
+ * Copy contents of a row.
+ */
+ScreenBuffer.prototype.copy = function(row, source) {
+
+ // draw...
+ var arr = this.data[row] || (this.data[row] = [])
+ for (var i = 0; i < arr.length; i ++) {
+ arr[i] = this.getCell(source, i).slice()
+ }
+
+}
+
+if (typeof module != 'undefined') module.exports = ScreenBuffer
@@ -0,0 +1,2 @@
+.DS_Store
+components
@@ -0,0 +1 @@
+client side part of ttycast
@@ -0,0 +1,21 @@
+{
+ "name": "ttycast-client",
+ "version": "0.1.1",
+ "main": [
+ "./display-buffer.js",
+ "./ttycast.css",
+ "./colors.js"
+ ],
+ "dependencies": {
+ "screen-buffer": "dtinth/screen-buffer#~0.1.2"
+ },
+ "gitHead": "c56534a27c5a368bd10d4aa11d1817ebb9712a8d",
+ "readme": "client side part of ttycast\n",
+ "readmeFilename": "README.md",
+ "_id": "ttycast-client@0.1.1",
+ "description": "client side part of ttycast",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/dtinth/ttycast-client.git"
+ }
+}
@@ -1,18 +1,4 @@
-/* not related to terminal */
-body {
- background: #000;
- text-align: center;
- font-size: 16px;
-}
-.terminal-container {
- display: inline-block;
- box-shadow: 0 0 20px rgba(255,255,255,0.4);
- text-align: left;
- padding: 4px;
- margin: 10px;
-}
-
/* the terminal */
.terminal {
font-family: "DejaVu Sans Mono", "Menlo", "Monaco", "Liberation Mono", Consolas, "Courier New", monospace;
View
@@ -1,17 +1,30 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>ttycast</title>
-<link rel=stylesheet href=ttycast.css>
-<script src="term-colors.js"></script>
+<link rel=stylesheet href=components/ttycast-client/ttycast.css>
+<style>
+body {
+ background: #000;
+ text-align: center;
+ font-size: 16px;
+}
+.terminal-container {
+ display: inline-block;
+ box-shadow: 0 0 20px rgba(255,255,255,0.4);
+ text-align: left;
+ padding: 4px;
+ margin: 10px;
+}
+</style>
+<script src=components/ttycast-client/colors.js></script>
<body>
<div class="terminal-container">
<div class="terminal" id="terminal"></div>
</div>
<script src="/socket.io/socket.io.js"></script>
-<script src="/screen-buffer.js"></script>
-<script src="/display-buffer.js"></script>
-<script src="/ttycast.js"></script>
-
+<script src="components/screen-buffer/screen-buffer.js"></script>
+<script src="components/ttycast-client/display-buffer.js"></script>
+<script src="ttycast.js"></script>
</body>

0 comments on commit c951197

Please sign in to comment.