<commit_before>//
//  PasteboardViewController.swift
//  PasteFlow
//
//  Created by <NAME> on 29/10/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Cocoa
import VinceRP

class PasteboardViewController: NSViewController, NSCollectionViewDataSource, NSCollectionViewDelegate, NSCollectionViewDelegateFlowLayout {

    var timer: NSTimer
    let pasteboardService = PasteboardService()
    
    @IBOutlet weak var collectionView: NSCollectionView!
    
    required init?(coder aDecoder: NSCoder) {
        timer = NSTimer.scheduledTimerWithTimeInterval(1, target: pasteboardService, selector: "pollPasteboardItems", userInfo: nil, repeats: true)
        super.init(coder: aDecoder)
    }

    override func awakeFromNib() {
        let textItemNib = NSNib(nibNamed: "TextItemCell", bundle: nil)
        let imageItemNib = NSNib(nibNamed: "ImageItemCell", bundle: nil)

        collectionView.registerNib(textItemNib, forItemWithIdentifier: "TextItemCell")
        collectionView.registerNib(imageItemNib, forItemWithIdentifier: "ImageItemCell")

        pasteboardService.pasteboardItems.onChange { _ in self.collectionView.reloadData() }
    }
<commit_msg>Show count on label<commit_after>//
//  PasteboardViewController.swift
//  PasteFlow
//
//  Created by <NAME> on 29/10/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Cocoa
import VinceRP

class PasteboardViewController: NSViewController, NSCollectionViewDataSource, NSCollectionViewDelegate, NSCollectionViewDelegateFlowLayout {

    var timer: NSTimer
    let pasteboardService = PasteboardService()

    @IBOutlet weak var collectionView: NSCollectionView!
    @IBOutlet weak var countLabel: NSTextField!

    required init?(coder aDecoder: NSCoder) {
        // no KVO unfortunately
        timer = NSTimer.scheduledTimerWithTimeInterval(1, target: pasteboardService, selector: "pollPasteboardItems", userInfo: nil, repeats: true)
        super.init(coder: aDecoder)
    }

    override func awakeFromNib() {
        let textItemNib = NSNib(nibNamed: "TextItemCell", bundle: nil)
        let imageItemNib = NSNib(nibNamed: "ImageItemCell", bundle: nil)

        collectionView.registerNib(textItemNib, forItemWithIdentifier: "TextItemCell")
        collectionView.registerNib(imageItemNib, forItemWithIdentifier: "ImageItemCell")

        pasteboardService.pasteboardItems.dispatchOnMainQueue().onChange { _ in self.collectionView.reloadData() }
        
        countLabel.reactiveText = self.pasteboardService.pasteboardItems.map { ("\($0.count) items") }
        countLabel.reactiveHidden = definedAs {
            self.pasteboardService.changeCount* == 0
        }
    }

{'fraction_non_alphanumeric': 0.09179467965530161, 'fraction_numerical': 0.008992131884600974, 'mean_word_length': 3.9353049907578557, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6257663', 'n_tokens_mistral': 813, 'n_tokens_neox': 766, 'n_words': 171}