-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from cs01/cs01/cleanup
- Loading branch information
Showing
9 changed files
with
154 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## 0.5.0.0 | ||
|
||
* Update dependencies xtermjs and socketio | ||
* Turn off flask's logging | ||
* Update setup.py to install from pinned dependencies in requirements.tx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
include README.md LICENSE | ||
include README.md LICENSE requirements.txt | ||
recursive-include pyxtermjs * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,99 @@ | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>pyxterm.js</title> | ||
<style> | ||
html { | ||
font-family: arial; | ||
} | ||
</style> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/xterm.css" /> | ||
</head> | ||
<body> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>pyxterm.js</title> | ||
<style> | ||
html { | ||
font-family: arial; | ||
} | ||
</style> | ||
<link | ||
rel="stylesheet" | ||
href="https://unpkg.com/[email protected]/css/xterm.css" | ||
/> | ||
</head> | ||
<body> | ||
<span style="font-size: 1.4em">pyxterm.js</span> | ||
<span style="font-size: small" | ||
>status: | ||
<span style="font-size: small" id="status">connecting...</span></span | ||
> | ||
|
||
<span style="font-size: 1.4em;">pyxterm.js</span> | ||
<span style="font-size: small;">status: <span style="font-size: small;" id="status">connecting...</span></span> | ||
<div style="width: 100%; height: calc(100% - 50px)" id="terminal"></div> | ||
|
||
<div style="width: 100%; height: calc(100% - 50px);" id="terminal"></div> | ||
|
||
<p style="text-align: right; font-size: small;"> | ||
built by <a href="https://grassfedcode.com">Chad Smith</a> <a href="https://github.com/cs01">GitHub</a> | ||
</p> | ||
<!-- xterm --> | ||
<script src="https://unpkg.com/[email protected]/lib/xterm.js"></script> | ||
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-fit.js"></script> | ||
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-web-links.js"></script> | ||
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-sear | ||
<p style="text-align: right; font-size: small"> | ||
built by <a href="https://chadsmith.dev">Chad Smith</a> | ||
<a href="https://github.com/cs01">GitHub</a> | ||
</p> | ||
<!-- xterm --> | ||
<script src="https://unpkg.com/[email protected]/lib/xterm.js"></script> | ||
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-fit.js"></script> | ||
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-web-links.js"></script> | ||
<script src="https://unpkg.com/[email protected]/lib/xterm-addon-sear | ||
ch.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script> | ||
|
||
<script> | ||
const term = new Terminal({ | ||
<script> | ||
const term = new Terminal({ | ||
cursorBlink: true, | ||
macOptionIsMeta: true, | ||
scrollback: true, | ||
}); | ||
// https://github.com/xtermjs/xterm.js/issues/2941 | ||
const fit = new FitAddon.FitAddon(); | ||
term.loadAddon(fit); | ||
term.loadAddon(new WebLinksAddon.WebLinksAddon()); | ||
term.loadAddon(new SearchAddon.SearchAddon()); | ||
|
||
term.open(document.getElementById('terminal')); | ||
fit.fit() | ||
term.resize(15, 50) | ||
console.log(`size: ${term.cols} columns, ${term.rows} rows`) | ||
fit.fit() | ||
term.write("Welcome to pyxterm.js!\nhttps://github.com/cs01/pyxterm.js\n") | ||
term.onKey((key, ev) => { | ||
console.log("pressed key", key) | ||
console.log("event", ev) | ||
socket.emit("pty-input", {"input": key}) | ||
}); | ||
|
||
const socket = io.connect('/pty'); | ||
const status = document.getElementById("status") | ||
|
||
socket.on("pty-output", function(data){ | ||
console.log("new output", data) | ||
term.write(data.output) | ||
}) | ||
}); | ||
// https://github.com/xtermjs/xterm.js/issues/2941 | ||
const fit = new FitAddon.FitAddon(); | ||
term.loadAddon(fit); | ||
term.loadAddon(new WebLinksAddon.WebLinksAddon()); | ||
term.loadAddon(new SearchAddon.SearchAddon()); | ||
|
||
socket.on("connect", () => { | ||
fitToscreen() | ||
status.innerHTML = '<span style="background-color: lightgreen;">connected</span>' | ||
} | ||
) | ||
term.open(document.getElementById("terminal")); | ||
fit.fit(); | ||
term.resize(15, 50); | ||
console.log(`size: ${term.cols} columns, ${term.rows} rows`); | ||
fit.fit(); | ||
term.writeln("Welcome to pyxterm.js!"); | ||
term.writeln("https://github.com/cs01/pyxterm.js"); | ||
term.onData((data) => { | ||
console.log("key pressed in browser:", data); | ||
socket.emit("pty-input", { input: data }); | ||
}); | ||
|
||
socket.on("disconnect", () => { | ||
status.innerHTML = '<span style="background-color: #ff8383;">disconnected</span>' | ||
}) | ||
const socket = io.connect("/pty"); | ||
const status = document.getElementById("status"); | ||
|
||
function fitToscreen(){ | ||
fit.fit() | ||
socket.emit("resize", {"cols": term.cols, "rows": term.rows}) | ||
} | ||
socket.on("pty-output", function (data) { | ||
console.log("new output received from server:", data.output); | ||
term.write(data.output); | ||
}); | ||
|
||
function debounce(func, wait_ms) { | ||
let timeout | ||
return function(...args) { | ||
const context = this | ||
clearTimeout(timeout) | ||
timeout = setTimeout(() => func.apply(context, args), wait_ms) | ||
} | ||
} | ||
socket.on("connect", () => { | ||
fitToscreen(); | ||
status.innerHTML = | ||
'<span style="background-color: lightgreen;">connected</span>'; | ||
}); | ||
|
||
const wait_ms = 50; | ||
window.onresize = debounce(fitToscreen, wait_ms) | ||
socket.on("disconnect", () => { | ||
status.innerHTML = | ||
'<span style="background-color: #ff8383;">disconnected</span>'; | ||
}); | ||
|
||
function fitToscreen() { | ||
fit.fit(); | ||
const dims = { cols: term.cols, rows: term.rows }; | ||
console.log("sending new dimensions to server's pty", dims); | ||
socket.emit("resize", dims); | ||
} | ||
|
||
</script> | ||
function debounce(func, wait_ms) { | ||
let timeout; | ||
return function (...args) { | ||
const context = this; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(() => func.apply(context, args), wait_ms); | ||
}; | ||
} | ||
|
||
</body> | ||
const wait_ms = 50; | ||
window.onresize = debounce(fitToscreen, wait_ms); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
flask-socketio==5.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
# | ||
# This file is autogenerated by pip-compile | ||
# This file is autogenerated by pip-compile with python 3.8 | ||
# To update, run: | ||
# | ||
# pip-compile | ||
# pip-compile requirements.in | ||
# | ||
bidict==0.21.2 | ||
# via python-socketio | ||
click==7.1.2 | ||
click==8.0.1 | ||
# via flask | ||
flask-socketio==5.0.1 | ||
# via pyxtermjs (setup.py) | ||
flask==1.1.2 | ||
flask==2.0.1 | ||
# via flask-socketio | ||
itsdangerous==1.1.0 | ||
flask-socketio==5.1.1 | ||
# via -r requirements.in | ||
itsdangerous==2.0.1 | ||
# via flask | ||
jinja2==2.11.3 | ||
jinja2==3.0.1 | ||
# via flask | ||
markupsafe==1.1.1 | ||
markupsafe==2.0.1 | ||
# via jinja2 | ||
python-engineio==4.1.0 | ||
python-engineio==4.2.1 | ||
# via python-socketio | ||
python-socketio==5.2.1 | ||
python-socketio==5.4.0 | ||
# via flask-socketio | ||
werkzeug==1.0.1 | ||
werkzeug==2.0.1 | ||
# via flask |
Oops, something went wrong.