-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.swift
63 lines (50 loc) · 1.92 KB
/
Utils.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// UiUtils.swift
// TreeView1
//
// Created by Nini on 28/09/14.
// Copyright (c) 2014 Nini. All rights reserved.
//
import Foundation
import AppKit
extension NSTextView
{
func appendTextAndScroll(text:NSString)
{
var attr = NSAttributedString(string: text)
self.textStorage!.appendAttributedString(attr)
self.scrollRangeToVisible(NSMakeRange(self.string!.utf16Count, 0)) //same as countElements or countCharacters
}
}
func getMyPath() -> NSString
{
var myPath:NSString = NSFileManager.defaultManager().currentDirectoryPath
return myPath
}
func openSSHConnection(var selectedItem:ConnectionViewItem, var term:PseudoTerminal)
{
if selectedItem.folder == true {
return
}
// [[iTermController sharedInstance] refreshSoftwareUpdateUserDefaults];
var ssh_host:NSString = "ssh://" + selectedItem.user + "@" + selectedItem.name + ":" + selectedItem.port
var controller = iTermController.sharedInstance();
selectedItem.key = selectedItem.key.stringByReplacingOccurrencesOfString(" ", withString:"");
if (selectedItem.key != "") {
controller.launchWithSSH_Key(nil, inTerminal: term, withURL: ssh_host, isHotkey: false, makeKey: false, command: selectedItem.key);
}
else {
controller.launchBookmark(nil, inTerminal: term, withURL: ssh_host, isHotkey: false, makeKey: false, command: nil);
}
}
public func openSSHConnection(var ssh_host:NSString, var key:NSString, var term:PseudoTerminal)
{
var controller = iTermController.sharedInstance();
key = key.stringByReplacingOccurrencesOfString(" ", withString:"");
if (key != "") {
controller.launchWithSSH_Key(nil, inTerminal: term, withURL: ssh_host, isHotkey: false, makeKey: false, command: key);
}
else {
controller.launchBookmark(nil, inTerminal: term, withURL: ssh_host, isHotkey: false, makeKey: false, command: nil);
}
}