Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update xtermjs and socketio #18

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyxtermjs/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def pty_input(data):
"""
if app.config["fd"]:
# print("writing to ptd: %s" % data["input"])
os.write(app.config["fd"], data["input"].encode())
os.write(app.config["fd"], data["input"]["key"].encode())


@socketio.on("resize", namespace="/pty")
Expand Down
33 changes: 17 additions & 16 deletions pyxtermjs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
font-family: arial;
}
</style>
<link rel="stylesheet" href="https://unpkg.com/xterm@3.6.0/dist/xterm.css" />
<link rel="stylesheet" href="https://unpkg.com/xterm@4.11.0/css/xterm.css" />
</head>
<body>

Expand All @@ -20,31 +20,32 @@
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/xterm@3.6.0/dist/xterm.js"></script>
<script src="https://unpkg.com/xterm@3.6.0/dist/addons/fit/fit.js"></script>
<script src="https://unpkg.com/xterm@3.6.0/dist/addons/webLinks/webLinks.js"></script>
<script src="https://unpkg.com/xterm@3.6.0/dist/addons/fullscreen/fullscreen.js"></script>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fullscreen addon is no longer supported

<script src="https://unpkg.com/xterm@3.6.0/dist/addons/search/search.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
<script src="https://unpkg.com/xterm@4.11.0/lib/xterm.js"></script>
<script src="https://unpkg.com/xterm-addon-fit@0.5.0/lib/xterm-addon-fit.js"></script>
<script src="https://unpkg.com/xterm-addon-web-links@0.4.0/lib/xterm-addon-web-links.js"></script>
<script src="https://unpkg.com/xterm-addon-search@0.8.0/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>
Terminal.applyAddon(fullscreen)
Terminal.applyAddon(fit)
Terminal.applyAddon(webLinks)
Terminal.applyAddon(search)
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'));
term.fit()
fit.fit()
term.resize(15, 50)
console.log(`size: ${term.cols} columns, ${term.rows} rows`)
// term.toggleFullScreen(true)
term.fit()
fit.fit()
term.write("Welcome to pyxterm.js!\nhttps://github.com/cs01/pyxterm.js\n")
term.on('key', (key, ev) => {
term.onKey((key, ev) => {
console.log("pressed key", key)
console.log("event", ev)
socket.emit("pty-input", {"input": key})
Expand All @@ -69,7 +70,7 @@
})

function fitToscreen(){
term.fit()
fit.fit()
socket.emit("resize", {"cols": term.cols, "rows": term.rows})
}

Expand Down
30 changes: 20 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
#
# pip-compile
#
click==7.0 # via flask
flask-socketio==3.3.1
flask==1.0.2 # via flask-socketio
itsdangerous==1.1.0 # via flask
jinja2==2.10 # via flask
markupsafe==1.1.1 # via jinja2
python-engineio==3.4.3 # via python-socketio
python-socketio==3.1.2 # via flask-socketio
six==1.12.0 # via python-engineio, python-socketio
werkzeug==0.14.1 # via flask
bidict==0.21.2
# via python-socketio
click==7.1.2
# via flask
flask-socketio==5.0.1
# via pyxtermjs (setup.py)
flask==1.1.2
# via flask-socketio
itsdangerous==1.1.0
# via flask
jinja2==2.11.3
# via flask
markupsafe==1.1.1
# via jinja2
python-engineio==4.1.0
# via python-socketio
python-socketio==5.2.1
# via flask-socketio
werkzeug==1.0.1
# via flask
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_version() -> str:
extras_require={},
zip_safe=False,
python_requires=">=3.6",
install_requires=["flask-socketio>=3.0, <=4.0"],
install_requires=["flask-socketio>=5.0, <6.0"],
classifiers=[
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
Expand Down