@lethevimlet/sshift 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/package.json +1 -2
- package/src/server/endpoints/rest/index.js +3 -0
- package/src/server/endpoints/rest/utils.js +36 -0
- package/src/server/index.js +49 -45
- package/src/server/services/sftp-manager.js +3 -1
- package/src/server/services/ssh-manager.js +3 -4
- package/src/server/utils/key-converter.js +363 -0
- package/src/webapp/css/style.css +83 -5
- package/src/webapp/index.html +22 -2
- package/src/webapp/js/app.js +368 -181
- package/src/webapp/js/mobile-terminal.js +65 -36
|
@@ -140,6 +140,8 @@ class MobileTerminalHandler {
|
|
|
140
140
|
cellHeight,
|
|
141
141
|
contentLeft,
|
|
142
142
|
contentTop,
|
|
143
|
+
contentWidth,
|
|
144
|
+
contentHeight,
|
|
143
145
|
offsetX: contentLeft - containerRect.left,
|
|
144
146
|
offsetY: contentTop - containerRect.top,
|
|
145
147
|
cols,
|
|
@@ -161,6 +163,8 @@ class MobileTerminalHandler {
|
|
|
161
163
|
cellHeight,
|
|
162
164
|
contentLeft: containerRect.left,
|
|
163
165
|
contentTop: containerRect.top,
|
|
166
|
+
contentWidth: containerRect.width,
|
|
167
|
+
contentHeight: containerRect.height,
|
|
164
168
|
offsetX: 0,
|
|
165
169
|
offsetY: 0,
|
|
166
170
|
cols,
|
|
@@ -254,18 +258,12 @@ class MobileTerminalHandler {
|
|
|
254
258
|
const coords = this._screenToTerminalCoords(touch.clientX, touch.clientY);
|
|
255
259
|
|
|
256
260
|
if (coords) {
|
|
257
|
-
// Update the appropriate handle position
|
|
258
261
|
if (type === 'start') {
|
|
259
|
-
// When dragging start handle, update start position
|
|
260
262
|
this.selection.start = coords;
|
|
261
263
|
} else {
|
|
262
|
-
// When dragging end handle, update end position
|
|
263
264
|
this.selection.end = coords;
|
|
264
265
|
}
|
|
265
266
|
|
|
266
|
-
// Ensure start is always before end in buffer order
|
|
267
|
-
// This prevents selection from inverting
|
|
268
|
-
this._normalizeSelection();
|
|
269
267
|
this._updateSelection();
|
|
270
268
|
}
|
|
271
269
|
}, { passive: false });
|
|
@@ -650,14 +648,17 @@ class MobileTerminalHandler {
|
|
|
650
648
|
}
|
|
651
649
|
}
|
|
652
650
|
|
|
653
|
-
// Handle selection dragging
|
|
654
651
|
if (this.selection.active && this.touchState.isDragging) {
|
|
655
652
|
e.preventDefault();
|
|
656
653
|
const touch = e.touches[0];
|
|
657
654
|
const coords = this._screenToTerminalCoords(touch.clientX, touch.clientY);
|
|
658
655
|
|
|
659
656
|
if (coords) {
|
|
660
|
-
this.
|
|
657
|
+
if (this.touchState.dragHandle === 'start') {
|
|
658
|
+
this.selection.start = coords;
|
|
659
|
+
} else {
|
|
660
|
+
this.selection.end = coords;
|
|
661
|
+
}
|
|
661
662
|
this._updateSelection();
|
|
662
663
|
}
|
|
663
664
|
}
|
|
@@ -925,33 +926,42 @@ class MobileTerminalHandler {
|
|
|
925
926
|
* @private
|
|
926
927
|
*/
|
|
927
928
|
_updateSelectionOverlay(start, end) {
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
if (!startPos || !endPos) return;
|
|
929
|
+
const metrics = this._getTerminalMetrics();
|
|
930
|
+
if (!metrics) return;
|
|
932
931
|
|
|
933
932
|
const startY = Math.min(start.y, end.y);
|
|
934
933
|
const endY = Math.max(start.y, end.y);
|
|
935
934
|
|
|
935
|
+
const textBeginX = (start.y < end.y || (start.y === end.y && start.x <= end.x)) ? start.x : end.x;
|
|
936
|
+
const textEndX = (start.y < end.y || (start.y === end.y && start.x <= end.x)) ? end.x : start.x;
|
|
937
|
+
|
|
936
938
|
this.selectionOverlay.innerHTML = '';
|
|
937
939
|
|
|
938
940
|
for (let y = startY; y <= endY; y++) {
|
|
939
|
-
const lineStartX = (y === startY) ?
|
|
940
|
-
const lineEndX = (y === endY) ?
|
|
941
|
+
const lineStartX = (y === startY) ? textBeginX : 0;
|
|
942
|
+
const lineEndX = (y === endY) ? textEndX : metrics.cols - 1;
|
|
943
|
+
const extendsToRight = (lineEndX === metrics.cols - 1);
|
|
941
944
|
|
|
942
945
|
const lineStartPos = this._terminalToScreenCoords(lineStartX, y);
|
|
943
|
-
const lineEndPos = this._terminalToScreenCoords(lineEndX, y);
|
|
944
946
|
|
|
945
|
-
if (lineStartPos
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
947
|
+
if (!lineStartPos) continue;
|
|
948
|
+
|
|
949
|
+
const rect = document.createElement('div');
|
|
950
|
+
rect.className = 'mobile-selection-rect';
|
|
951
|
+
rect.style.position = 'absolute';
|
|
952
|
+
rect.style.left = `${lineStartPos.x}px`;
|
|
953
|
+
rect.style.top = `${lineStartPos.y}px`;
|
|
954
|
+
rect.style.height = `${lineStartPos.height}px`;
|
|
955
|
+
|
|
956
|
+
if (extendsToRight) {
|
|
957
|
+
rect.style.right = '0px';
|
|
958
|
+
} else {
|
|
959
|
+
const lineEndPos = this._terminalToScreenCoords(lineEndX, y);
|
|
960
|
+
if (!lineEndPos) continue;
|
|
961
|
+
rect.style.width = `${Math.ceil(lineEndPos.x - lineStartPos.x + lineEndPos.width)}px`;
|
|
954
962
|
}
|
|
963
|
+
|
|
964
|
+
this.selectionOverlay.appendChild(rect);
|
|
955
965
|
}
|
|
956
966
|
|
|
957
967
|
this.selectionOverlay.style.display = 'block';
|
|
@@ -962,23 +972,42 @@ class MobileTerminalHandler {
|
|
|
962
972
|
* @private
|
|
963
973
|
*/
|
|
964
974
|
_updateHandles(start, end) {
|
|
965
|
-
const
|
|
966
|
-
|
|
967
|
-
const
|
|
968
|
-
const actualEnd = isStartFirst ? end : start;
|
|
975
|
+
const startPos = start.y * this.terminal.cols + start.x;
|
|
976
|
+
const endPos = end.y * this.terminal.cols + end.x;
|
|
977
|
+
const isInverted = startPos > endPos;
|
|
969
978
|
|
|
970
|
-
const
|
|
971
|
-
if (
|
|
979
|
+
const startCoords = this._terminalToScreenCoords(start.x, start.y);
|
|
980
|
+
if (startCoords) {
|
|
972
981
|
this.startHandle.style.display = 'block';
|
|
973
|
-
|
|
974
|
-
|
|
982
|
+
if (isInverted) {
|
|
983
|
+
this.startHandle.style.left = `${startCoords.x + startCoords.width}px`;
|
|
984
|
+
} else {
|
|
985
|
+
this.startHandle.style.left = `${startCoords.x}px`;
|
|
986
|
+
}
|
|
987
|
+
this.startHandle.style.top = `${startCoords.y + startCoords.height}px`;
|
|
975
988
|
}
|
|
976
989
|
|
|
977
|
-
const
|
|
978
|
-
if (
|
|
990
|
+
const endCoords = this._terminalToScreenCoords(end.x, end.y);
|
|
991
|
+
if (endCoords) {
|
|
979
992
|
this.endHandle.style.display = 'block';
|
|
980
|
-
|
|
981
|
-
|
|
993
|
+
if (isInverted) {
|
|
994
|
+
this.endHandle.style.left = `${endCoords.x}px`;
|
|
995
|
+
} else {
|
|
996
|
+
this.endHandle.style.left = `${endCoords.x + endCoords.width}px`;
|
|
997
|
+
}
|
|
998
|
+
this.endHandle.style.top = `${endCoords.y + endCoords.height}px`;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
if (isInverted) {
|
|
1002
|
+
this.startHandle.classList.add('mobile-selection-handle-end');
|
|
1003
|
+
this.startHandle.classList.remove('mobile-selection-handle-start');
|
|
1004
|
+
this.endHandle.classList.add('mobile-selection-handle-start');
|
|
1005
|
+
this.endHandle.classList.remove('mobile-selection-handle-end');
|
|
1006
|
+
} else {
|
|
1007
|
+
this.startHandle.classList.add('mobile-selection-handle-start');
|
|
1008
|
+
this.startHandle.classList.remove('mobile-selection-handle-end');
|
|
1009
|
+
this.endHandle.classList.add('mobile-selection-handle-end');
|
|
1010
|
+
this.endHandle.classList.remove('mobile-selection-handle-start');
|
|
982
1011
|
}
|
|
983
1012
|
}
|
|
984
1013
|
|