can kinda type - it gets sent to teh server, but doesnt refres :skulk:

This commit is contained in:
neon443
2025-06-22 16:24:21 +01:00
parent e156d63cf6
commit b60e8f4eed
6 changed files with 87 additions and 63 deletions

View File

@@ -10,7 +10,7 @@
A9083E402DF2226F0042906E /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A9083E3F2DF2225A0042906E /* libz.tbd */; }; A9083E402DF2226F0042906E /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A9083E3F2DF2225A0042906E /* libz.tbd */; };
A92317282E07111E00ECE1E6 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = A92317272E07111E00ECE1E6 /* SwiftTerm */; }; A92317282E07111E00ECE1E6 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = A92317272E07111E00ECE1E6 /* SwiftTerm */; };
A923172A2E07113100ECE1E6 /* TerminalController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92317292E07113100ECE1E6 /* TerminalController.swift */; }; A923172A2E07113100ECE1E6 /* TerminalController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92317292E07113100ECE1E6 /* TerminalController.swift */; };
A923172D2E07138000ECE1E6 /* TerminalDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923172C2E07138000ECE1E6 /* TerminalDelegate.swift */; }; A923172D2E07138000ECE1E6 /* SSHTerminalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A923172C2E07138000ECE1E6 /* SSHTerminalView.swift */; };
A92538C82DEE0742007E0A18 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92538C52DEE0742007E0A18 /* ContentView.swift */; }; A92538C82DEE0742007E0A18 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92538C52DEE0742007E0A18 /* ContentView.swift */; };
A92538C92DEE0742007E0A18 /* ShhShellApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92538C62DEE0742007E0A18 /* ShhShellApp.swift */; }; A92538C92DEE0742007E0A18 /* ShhShellApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92538C62DEE0742007E0A18 /* ShhShellApp.swift */; };
A92538CA2DEE0742007E0A18 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A92538C42DEE0742007E0A18 /* Assets.xcassets */; }; A92538CA2DEE0742007E0A18 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A92538C42DEE0742007E0A18 /* Assets.xcassets */; };
@@ -69,7 +69,7 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
A9083E3F2DF2225A0042906E /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; A9083E3F2DF2225A0042906E /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
A92317292E07113100ECE1E6 /* TerminalController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalController.swift; sourceTree = "<group>"; }; A92317292E07113100ECE1E6 /* TerminalController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalController.swift; sourceTree = "<group>"; };
A923172C2E07138000ECE1E6 /* TerminalDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalDelegate.swift; sourceTree = "<group>"; }; A923172C2E07138000ECE1E6 /* SSHTerminalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHTerminalView.swift; sourceTree = "<group>"; };
A925389A2DEE06DC007E0A18 /* ShhShell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShhShell.app; sourceTree = BUILT_PRODUCTS_DIR; }; A925389A2DEE06DC007E0A18 /* ShhShell.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShhShell.app; sourceTree = BUILT_PRODUCTS_DIR; };
A92538A72DEE06DE007E0A18 /* ShhShellTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ShhShellTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; A92538A72DEE06DE007E0A18 /* ShhShellTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ShhShellTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
A92538B12DEE06DE007E0A18 /* ShhShellUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ShhShellUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; A92538B12DEE06DE007E0A18 /* ShhShellUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ShhShellUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -132,7 +132,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A92317292E07113100ECE1E6 /* TerminalController.swift */, A92317292E07113100ECE1E6 /* TerminalController.swift */,
A923172C2E07138000ECE1E6 /* TerminalDelegate.swift */, A923172C2E07138000ECE1E6 /* SSHTerminalView.swift */,
); );
path = Terminal; path = Terminal;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -420,7 +420,7 @@
A98554592E0553AA009051BD /* KeyManager.swift in Sources */, A98554592E0553AA009051BD /* KeyManager.swift in Sources */,
A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */, A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */,
A98554552E05535F009051BD /* KeyManagerView.swift in Sources */, A98554552E05535F009051BD /* KeyManagerView.swift in Sources */,
A923172D2E07138000ECE1E6 /* TerminalDelegate.swift in Sources */, A923172D2E07138000ECE1E6 /* SSHTerminalView.swift in Sources */,
A923172A2E07113100ECE1E6 /* TerminalController.swift in Sources */, A923172A2E07113100ECE1E6 /* TerminalController.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;

View File

@@ -332,7 +332,8 @@ class SSHHandler: ObservableObject {
logger.critical("\(String(cString: ssh_get_error(&self.session)))") logger.critical("\(String(cString: ssh_get_error(&self.session)))")
} }
func writeToChannel(_ string: String) { func writeToChannel(_ string: String?) {
guard let string = string else { return }
guard ssh_channel_is_open(channel) != 0 else { return } guard ssh_channel_is_open(channel) != 0 else { return }
guard ssh_channel_is_eof(channel) == 0 else { return } guard ssh_channel_is_eof(channel) == 0 else { return }
@@ -343,4 +344,12 @@ class SSHHandler: ObservableObject {
print("partial write!!") print("partial write!!")
} }
} }
func resizeTTY(toRows: Int, toCols: Int) {
guard ssh_channel_is_open(channel) != 0 else { return }
guard ssh_channel_is_eof(channel) == 0 else { return }
ssh_channel_change_pty_size(channel, Int32(toCols), Int32(toRows))
print("resized tty to \(toRows)rows and \(toCols)cols")
}
} }

View File

@@ -132,8 +132,8 @@ struct ConnectionView: View {
} }
NavigationLink() { NavigationLink() {
Button("Reload") { Button("send Ax256") {
handler.readFromChannel() handler.writeToChannel(Array(repeating: "A", count: 256).joined())
} }
TerminalController(handler: handler) TerminalController(handler: handler)
} label: { } label: {

View File

@@ -0,0 +1,63 @@
//
// SSHTerminalView.swift
// ShhShell
//
// Created by neon443 on 21/06/2025.
//
import Foundation
import SwiftTerm
class SSHTerminalView: TerminalView, TerminalViewDelegate {
var handler: SSHHandler?
var sshQueue: DispatchQueue
public convenience init(frame: CGRect, handler: SSHHandler) {
self.init(frame: frame)
self.handler = handler
}
public override init(frame: CGRect) {
sshQueue = DispatchQueue(label: "sshQueue")
super.init(frame: frame)
terminalDelegate = self
}
required init?(coder: NSCoder) {
fatalError("unimplemented")
}
public func scrolled(source: TerminalView, position: Double) {
print("scrolled to \(position)")
}
public func setTerminalTitle(source: TerminalView, title: String) {
print("set title to \(title)")
}
public func sizeChanged(source: TerminalView, newCols: Int, newRows: Int) {
handler?.resizeTTY(toRows: newRows, toCols: newCols)
}
public func send(source: TerminalView, data: ArraySlice<UInt8>) {
let dataSlice = Data(bytes: [data.first], count: data.count)
handler?.writeToChannel(String(data: dataSlice, encoding: .utf8))
}
public func clipboardCopy(source: TerminalView, content: Data) {
print(content)
}
public func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) {
print("new dir: \(directory ?? "")")
}
public func requestOpenLink(source: TerminalView, link: String, params: [String : String]) {
print("open link \(link) \(params)")
}
public func rangeChanged(source: TerminalView, startY: Int, endY: Int) {
print(startY, endY)
}
}

View File

@@ -14,9 +14,14 @@ struct TerminalController: UIViewRepresentable {
@ObservedObject var handler: SSHHandler @ObservedObject var handler: SSHHandler
func makeUIView(context: Context) -> TerminalView { func makeUIView(context: Context) -> TerminalView {
let tv = TerminalView() let tv = SSHTerminalView(
let terminalDelegate = ShhTerminalViewDelegate() frame: CGRect(
tv.terminalDelegate = terminalDelegate origin: CGPoint(x: 0, y: 0),
size: CGSize(width: 100, height: 100)
),
handler: handler
)
// tv.terminalDelegate = terminalDelegate
tv.getTerminal().feed(text: handler.readFromChannel()) tv.getTerminal().feed(text: handler.readFromChannel())
return tv return tv

View File

@@ -1,53 +0,0 @@
//
// TerminalDelegate.swift
// ShhShell
//
// Created by neon443 on 21/06/2025.
//
import Foundation
import SwiftTerm
class ShhTerminalViewDelegate: TerminalViewDelegate {
func sizeChanged(source: TerminalView, newCols: Int, newRows: Int) {
print(newRows, newCols)
}
func setTerminalTitle(source: TerminalView, title: String) {
print(title)
}
func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) {
print(directory)
}
func send(source: TerminalView, data: ArraySlice<UInt8>) {
print(data)
print("send")
}
func scrolled(source: TerminalView, position: Double) {
print(position)
}
func requestOpenLink(source: TerminalView, link: String, params: [String : String]) {
print(link)
print(params)
}
func bell(source: TerminalView) {
print("ding")
}
func clipboardCopy(source: TerminalView, content: Data) {
print(content)
}
func iTermContent(source: TerminalView, content: ArraySlice<UInt8>) {
print("idk what this does")
}
func rangeChanged(source: TerminalView, startY: Int, endY: Int) {
print(startY, endY)
}
}