From c72aaf3fcc9113a71893bdc2ae970bf7db819861 Mon Sep 17 00:00:00 2001 From: piair Date: Wed, 28 Feb 2024 11:53:23 +0100 Subject: [PATCH] better terminal --- .gitignore | 4 ++- Flask/static/node_modules/.package-lock.json | 8 ++++++ .../xterm-addon-fit/lib/xterm-addon-fit.js | 2 ++ .../lib/xterm-addon-fit.js.map | 1 + .../node_modules/xterm-addon-fit/package.json | 26 +++++++++++++++++++ Flask/static/package-lock.json | 11 +++++++- Flask/static/package.json | 3 ++- Flask/templates/vnc_post.html | 8 ++++-- version | 2 +- 9 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 Flask/static/node_modules/xterm-addon-fit/lib/xterm-addon-fit.js create mode 100644 Flask/static/node_modules/xterm-addon-fit/lib/xterm-addon-fit.js.map create mode 100644 Flask/static/node_modules/xterm-addon-fit/package.json diff --git a/.gitignore b/.gitignore index 637c1a9..61eb5cc 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,6 @@ nohup.out points.csv file.png user_data/configs.json -*.ts \ No newline at end of file +*.ts +LICENSE +README.md diff --git a/Flask/static/node_modules/.package-lock.json b/Flask/static/node_modules/.package-lock.json index 17b597d..7033410 100644 --- a/Flask/static/node_modules/.package-lock.json +++ b/Flask/static/node_modules/.package-lock.json @@ -7,6 +7,14 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/xterm/-/xterm-5.3.0.tgz", "integrity": "sha512-8QqjlekLUFTrU6x7xck1MsPzPA571K5zNqWm0M0oroYEWVOptZ0+ubQSkQ3uxIEhcIHRujJy6emDWX4A7qyFzg==" + }, + "node_modules/xterm-addon-fit": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/xterm-addon-fit/-/xterm-addon-fit-0.8.0.tgz", + "integrity": "sha512-yj3Np7XlvxxhYF/EJ7p3KHaMt6OdwQ+HDu573Vx1lRXsVxOcnVJs51RgjZOouIZOczTsskaS+CpXspK81/DLqw==", + "peerDependencies": { + "xterm": "^5.0.0" + } } } } diff --git a/Flask/static/node_modules/xterm-addon-fit/lib/xterm-addon-fit.js b/Flask/static/node_modules/xterm-addon-fit/lib/xterm-addon-fit.js new file mode 100644 index 0000000..7cfd9de --- /dev/null +++ b/Flask/static/node_modules/xterm-addon-fit/lib/xterm-addon-fit.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(self,(()=>(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,i=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),l=o-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),a=s-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-r;return{cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}}})(),e})())); +//# sourceMappingURL=xterm-addon-fit.js.map \ No newline at end of file diff --git a/Flask/static/node_modules/xterm-addon-fit/lib/xterm-addon-fit.js.map b/Flask/static/node_modules/xterm-addon-fit/lib/xterm-addon-fit.js.map new file mode 100644 index 0000000..33a9297 --- /dev/null +++ b/Flask/static/node_modules/xterm-addon-fit/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,EAAaJ,iBAAiB,gBACpCD,SAASK,EAAaJ,iBAAiB,oBAO3CM,EAAiBL,GANdF,SAASK,EAAaJ,iBAAiB,kBACxCD,SAASK,EAAaJ,iBAAiB,kBAKiBV,EAKhE,MAJiB,CACfd,KAAM0B,KAAKC,IA/DI,EA+DcD,KAAKK,MAAMD,EAAiBjC,EAAKa,IAAIC,KAAKC,QACvEX,KAAMyB,KAAKC,IA/DI,EA+DcD,KAAKK,MAAMF,EAAkBhC,EAAKa,IAAIC,KAAKE,SAG5E,E","sources":["webpack://FitAddon/webpack/universalModuleDefinition","webpack://FitAddon/./src/FitAddon.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FitAddon\"] = factory();\n\telse\n\t\troot[\"FitAddon\"] = factory();\n})(self, () => {\nreturn ","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Terminal, ITerminalAddon } from 'xterm';\nimport { IRenderDimensions } from 'browser/renderer/shared/Types';\n\ninterface ITerminalDimensions {\n /**\n * The number of rows in the terminal.\n */\n rows: number;\n\n /**\n * The number of columns in the terminal.\n */\n cols: number;\n}\n\nconst MINIMUM_COLS = 2;\nconst MINIMUM_ROWS = 1;\n\nexport class FitAddon implements ITerminalAddon {\n private _terminal: Terminal | undefined;\n\n public activate(terminal: Terminal): void {\n this._terminal = terminal;\n }\n\n public dispose(): void {}\n\n public fit(): void {\n const dims = this.proposeDimensions();\n if (!dims || !this._terminal || isNaN(dims.cols) || isNaN(dims.rows)) {\n return;\n }\n\n // TODO: Remove reliance on private API\n const core = (this._terminal as any)._core;\n\n // Force a full render\n if (this._terminal.rows !== dims.rows || this._terminal.cols !== dims.cols) {\n core._renderService.clear();\n this._terminal.resize(dims.cols, dims.rows);\n }\n }\n\n public proposeDimensions(): ITerminalDimensions | undefined {\n if (!this._terminal) {\n return undefined;\n }\n\n if (!this._terminal.element || !this._terminal.element.parentElement) {\n return undefined;\n }\n\n // TODO: Remove reliance on private API\n const core = (this._terminal as any)._core;\n const dims: IRenderDimensions = core._renderService.dimensions;\n\n if (dims.css.cell.width === 0 || dims.css.cell.height === 0) {\n return undefined;\n }\n\n const scrollbarWidth = this._terminal.options.scrollback === 0 ?\n 0 : core.viewport.scrollBarWidth;\n\n const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);\n const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));\n const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));\n const elementStyle = window.getComputedStyle(this._terminal.element);\n const elementPadding = {\n top: parseInt(elementStyle.getPropertyValue('padding-top')),\n bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),\n right: parseInt(elementStyle.getPropertyValue('padding-right')),\n left: parseInt(elementStyle.getPropertyValue('padding-left'))\n };\n const elementPaddingVer = elementPadding.top + elementPadding.bottom;\n const elementPaddingHor = elementPadding.right + elementPadding.left;\n const availableHeight = parentElementHeight - elementPaddingVer;\n const availableWidth = parentElementWidth - elementPaddingHor - scrollbarWidth;\n const geometry = {\n cols: Math.max(MINIMUM_COLS, Math.floor(availableWidth / dims.css.cell.width)),\n rows: Math.max(MINIMUM_ROWS, Math.floor(availableHeight / dims.css.cell.height))\n };\n return geometry;\n }\n}\n"],"names":["root","factory","exports","module","define","amd","self","activate","terminal","this","_terminal","dispose","fit","dims","proposeDimensions","isNaN","cols","rows","core","_core","_renderService","clear","resize","element","parentElement","dimensions","css","cell","width","height","scrollbarWidth","options","scrollback","viewport","scrollBarWidth","parentElementStyle","window","getComputedStyle","parentElementHeight","parseInt","getPropertyValue","parentElementWidth","Math","max","elementStyle","availableHeight","availableWidth","floor"],"sourceRoot":""} \ No newline at end of file diff --git a/Flask/static/node_modules/xterm-addon-fit/package.json b/Flask/static/node_modules/xterm-addon-fit/package.json new file mode 100644 index 0000000..749d5b6 --- /dev/null +++ b/Flask/static/node_modules/xterm-addon-fit/package.json @@ -0,0 +1,26 @@ +{ + "name": "xterm-addon-fit", + "version": "0.8.0", + "author": { + "name": "The xterm.js authors", + "url": "https://xtermjs.org/" + }, + "main": "lib/xterm-addon-fit.js", + "types": "typings/xterm-addon-fit.d.ts", + "repository": "https://github.com/xtermjs/xterm.js", + "license": "MIT", + "keywords": [ + "terminal", + "xterm", + "xterm.js" + ], + "scripts": { + "build": "../../node_modules/.bin/tsc -p .", + "prepackage": "npm run build", + "package": "../../node_modules/.bin/webpack", + "prepublishOnly": "npm run package" + }, + "peerDependencies": { + "xterm": "^5.0.0" + } +} \ No newline at end of file diff --git a/Flask/static/package-lock.json b/Flask/static/package-lock.json index 63b687a..4327aee 100644 --- a/Flask/static/package-lock.json +++ b/Flask/static/package-lock.json @@ -5,13 +5,22 @@ "packages": { "": { "dependencies": { - "xterm": "^5.3.0" + "xterm": "^5.3.0", + "xterm-addon-fit": "^0.8.0" } }, "node_modules/xterm": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/xterm/-/xterm-5.3.0.tgz", "integrity": "sha512-8QqjlekLUFTrU6x7xck1MsPzPA571K5zNqWm0M0oroYEWVOptZ0+ubQSkQ3uxIEhcIHRujJy6emDWX4A7qyFzg==" + }, + "node_modules/xterm-addon-fit": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/xterm-addon-fit/-/xterm-addon-fit-0.8.0.tgz", + "integrity": "sha512-yj3Np7XlvxxhYF/EJ7p3KHaMt6OdwQ+HDu573Vx1lRXsVxOcnVJs51RgjZOouIZOczTsskaS+CpXspK81/DLqw==", + "peerDependencies": { + "xterm": "^5.0.0" + } } } } diff --git a/Flask/static/package.json b/Flask/static/package.json index b1c1b1d..912db53 100644 --- a/Flask/static/package.json +++ b/Flask/static/package.json @@ -1,5 +1,6 @@ { "dependencies": { - "xterm": "^5.3.0" + "xterm": "^5.3.0", + "xterm-addon-fit": "^0.8.0" } } diff --git a/Flask/templates/vnc_post.html b/Flask/templates/vnc_post.html index 600ef3c..4631898 100644 --- a/Flask/templates/vnc_post.html +++ b/Flask/templates/vnc_post.html @@ -8,6 +8,8 @@ {% else %} + +
@@ -27,8 +29,10 @@