<commit_before>//
// SRWindowManager.swift
// @Seorenn
//
// This module work under OS X only
//

#if os(OSX)

import Cocoa
    
class SRWindowManager {
    var capturing = false
    
    struct StaticInstance {
        static var dispatchToken: dispatch_once_t = 0
        static var instance:SRWindowManager?
    }
    
    class func sharedManager() -> SRWindowManager {
        dispatch_once(&StaticInstance.dispatchToken) {
            StaticInstance.instance = SRWindowManager()
        }
        return StaticInstance.instance!
    }
    
    deinit {
        let nc = NSWorkspace.sharedWorkspace().notificationCenter
        nc.removeObserver(self)
    }
    
    func processes() -> [NSRunningApplication!] {
        let apps = NSWorkspace.sharedWorkspace().runningApplications
        return apps as [NSRunningApplication!]
    }

    func windowProcesses() -> Array<NSRunningApplication?> {
        var apps = Array<NSRunningApplication?>()
        let list = CGWindowListCopyWindowInfo(CGWindowListOption(kCGWindowListExcludeDesktopElements | kCGWindowListOptionOnScreenOnly), CGWindowID(0))
        let windowInfos = list.takeRetainedValue().__conversion() as Array
        for info in windowInfos as Array<Dictionary<NSString, AnyObject>> {
            let pidPtr: AnyObject? = info[kCGWindowOwnerPID]
            let pidInt = pidPtr as Int<commit_msg>Fixing compatibility for Xcode 6.1 beta<commit_after>//
// SRWindowManager.swift
// @Seorenn
//
// This module work under OS X only
//

#if os(OSX)

import Cocoa
    
class SRWindowManager {
    var capturing = false
    
    struct StaticInstance {
        static var dispatchToken: dispatch_once_t = 0
        static var instance:SRWindowManager?
    }
    
    class func sharedManager() -> SRWindowManager {
        dispatch_once(&StaticInstance.dispatchToken) {
            StaticInstance.instance = SRWindowManager()
        }
        return StaticInstance.instance!
    }
    
    deinit {
        let nc = NSWorkspace.sharedWorkspace().notificationCenter
        nc.removeObserver(self)
    }
    
    func processes() -> [NSRunningApplication!] {
        let apps = NSWorkspace.sharedWorkspace().runningApplications
        return apps as [NSRunningApplication!]
    }

    func windowProcesses() -> Array<NSRunningApplication?> {
        var apps = Array<NSRunningApplication?>()
        let list = CGWindowListCopyWindowInfo(CGWindowListOption(kCGWindowListExcludeDesktopElements | kCGWindowListOptionOnScreenOnly), CGWindowID(0))
        //let windowInfos = list.takeRetainedValue().__conversion() as Array
        let windowInfos = list.takeRetainedValue() as Array
        for info in windowInfos as Array<Dictionary<NSString, AnyObject>> {
            let pidPtr: AnyObject? = info[kCGWindowOwnerPID]
            let pidInt = pidPtr as Int
{'fraction_non_alphanumeric': 0.08404255319148936, 'fraction_numerical': 0.002127659574468085, 'mean_word_length': 2.8964088397790055, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '665360', 'n_tokens_mistral': 778, 'n_tokens_neox': 752, 'n_words': 179}