mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
code cleanup
This commit is contained in:
@@ -57,6 +57,7 @@ struct KeyImporterView: View {
|
||||
}
|
||||
|
||||
}
|
||||
.preferredColorScheme(.dark)
|
||||
.overlay(alignment: .bottom) {
|
||||
Button() {
|
||||
keyManager.importKey(type: keyType, priv: privkeyStr, name: keyName)
|
||||
|
||||
@@ -14,10 +14,16 @@ struct ShellTabView: View {
|
||||
@ObservedObject var container = TerminalViewContainer.shared
|
||||
@State var selectedID: UUID?
|
||||
var selectedHandler: SSHHandler {
|
||||
container.sessions[selectedID ?? UUID()]?.handler ?? handler ?? SSHHandler(host: Host.blank, keyManager: nil)
|
||||
guard let selectedID, let contained = container.sessions[selectedID] else {
|
||||
guard let handler else {
|
||||
fatalError("selectedHandler: selectedID and handler are nil")
|
||||
}
|
||||
return handler
|
||||
}
|
||||
return contained.handler
|
||||
}
|
||||
|
||||
@State var showSnippetPicker: Bool = false
|
||||
@State private var showSnippetPicker: Bool = false
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
@@ -42,6 +48,18 @@ struct ShellTabView: View {
|
||||
}
|
||||
var background: Color { hostsManager.selectedTheme.background.suiColor }
|
||||
|
||||
init(handler: SSHHandler? = nil, hostsManager: HostsManager, selectedID: UUID? = nil) {
|
||||
self.selectedID = selectedID
|
||||
self.handler = handler
|
||||
if selectedID == nil, let handler {
|
||||
self.selectedID = handler.sessionID
|
||||
} else {
|
||||
fatalError()
|
||||
}
|
||||
self.hostsManager = hostsManager
|
||||
self.container = TerminalViewContainer.shared
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
background
|
||||
@@ -149,15 +167,6 @@ struct ShellTabView: View {
|
||||
}
|
||||
}
|
||||
.frame(height: 30)
|
||||
.onAppear {
|
||||
if selectedID == nil {
|
||||
if let handler {
|
||||
selectedID = handler.sessionID
|
||||
} else {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//the acc terminal lol
|
||||
@@ -194,11 +203,6 @@ struct ShellTabView: View {
|
||||
handler: handler,
|
||||
hostsManager: hostsManager
|
||||
)
|
||||
.onAppear {
|
||||
if selectedID == nil {
|
||||
selectedID = handler.sessionID
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text("No Session")
|
||||
}
|
||||
|
||||
@@ -13,36 +13,6 @@ struct ShellView: View {
|
||||
@ObservedObject var hostsManager: HostsManager
|
||||
@ObservedObject var container = TerminalViewContainer.shared
|
||||
|
||||
@State var cursorPos: (x: Int, y: Int) = (0, 0)
|
||||
var jellyLoc: CGSize {
|
||||
var offset = CGSize(width: cursorPos.x, height: cursorPos.y)
|
||||
offset.width *= cellDimension.width
|
||||
offset.height *= cellDimension.height
|
||||
switch hostsManager.settings.cursorType.cursorShape {
|
||||
case .block, .bar:
|
||||
fallthrough
|
||||
case .underline:
|
||||
offset.height += cellDimension.height * 0.8
|
||||
}
|
||||
return offset
|
||||
}
|
||||
|
||||
@State var cellDimension: CGSize = CGSize(width: 0, height: 0)
|
||||
var jellySize: CGSize {
|
||||
var cellDimension: CGSize = cellDimension
|
||||
switch hostsManager.settings.cursorType.cursorShape {
|
||||
case .block:
|
||||
fallthrough
|
||||
case .bar:
|
||||
cellDimension.width *= 0.3
|
||||
case .underline:
|
||||
cellDimension.height *= 0.2
|
||||
}
|
||||
return cellDimension
|
||||
}
|
||||
|
||||
@State var jellyShow: Bool = true
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
@@ -54,33 +24,6 @@ struct ShellView: View {
|
||||
ZStack(alignment: .topLeading) {
|
||||
TerminalController(handler: handler, hostsManager: hostsManager)
|
||||
.brightness(hostsManager.settings.filter == .crt ? 0.2 : 0.0)
|
||||
.onAppear {
|
||||
let timer = Timer(timeInterval: 0.1, repeats: true) { timer in
|
||||
DispatchQueue.main.async {
|
||||
let terminalView = container.sessions[handler.sessionID ?? UUID()]?.terminalView
|
||||
let delegate = terminalView?.terminalDelegate as? SSHTerminalDelegate
|
||||
terminalView?.getTerminal().hideCursor()
|
||||
cursorPos = terminalView?.getTerminal().getCursorLocation() ?? cursorPos
|
||||
cellDimension = delegate?.computeFontDimensions() ?? cellDimension
|
||||
// jellyShow = terminalView?.getTerminal().buffer.isCursorInViewPort ?? jellyShow
|
||||
}
|
||||
}
|
||||
// RunLoop.main.add(timer, forMode: .common)
|
||||
}
|
||||
|
||||
// Rectangle()
|
||||
// .frame(width: jellySize.width, height: jellySize.height)
|
||||
// .offset(
|
||||
// x: jellyLoc.width,
|
||||
// y: jellyLoc.height
|
||||
// )
|
||||
// .opacity(jellyShow ? 1 : 0)
|
||||
// .animation(.spring(duration: 0.2, bounce: 0.6), value: cursorPos.x)
|
||||
// .animation(.spring(duration: 0.2, bounce: 0.6), value: cursorPos.y)
|
||||
// .animation(.spring(duration: 0.2, bounce: 0.6), value: jellyLoc.width)
|
||||
// .animation(.spring(duration: 0.2, bounce: 0.6), value: jellyLoc.height)
|
||||
// .animation(.spring(duration: 0.2, bounce: 0.6), value: jellySize.width)
|
||||
// .animation(.spring(duration: 0.2, bounce: 0.6), value: jellySize.height)
|
||||
|
||||
if hostsManager.settings.filter == .crt {
|
||||
CRTView()
|
||||
|
||||
Reference in New Issue
Block a user