<commit_before>//
//  ViewController.swift
//  Demo-tvOS
//
//  Created by toshi0383 on 1/9/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

let labels = [
    "Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello Hello World."]

let defaultScrollDuration: CGFloat = 20.0

class ViewController: UIViewController {

    @IBOutlet var marqueeTableView: UITableView!
    @IBOutlet var labelTableview: LabelTableView!


    override func viewDidLoad() {
        super.viewDidLoad()
        // MarqueeLabel Tableview
        marqueeTableView.dataSource = self
        marqueeTableView.delegate = self
        
        // Basic UILabel Tableview
        labelTableview.dataSource = labelTableview
    }

}

typealias CellType = TableViewCell

extension ViewController: UITableViewDataSource {

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return labels.count * 8
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = marqueeTableView.dequeueReusableCellWithIdentifier("Cell") as! CellType!
        cell.marquee.text = labels[indexPath.row % labels.count]
        cell.marquee.fadeLength = 7.0
        cell.marquee.scrollDuration = defaultScrollDuration
        cell.marquee.holdScrolling = true
        cell.marquee.lineBreakMode = NSLineBreakMode(rawValue: indexPath.row % 6)!
        return cell
    }
}

extension ViewController: UITableViewDelegate {
    func tableView(tableView: UITableView, didUpdateFocusInContext context: UITableViewFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
        if let previouslyFocusedIndexPath = context.previouslyFocusedIndexPath {
            let previous = tableView.cellForRowAtIndexPath(previouslyFocusedIndexPath) as! CellType!
            previous?.marquee.holdScrolling = true
            previous?.marquee.restartLabel()
            print("\(previouslyFocusedIndexPath.row): stopScrolling")
        }
        if let nextFocusedIndexPath = context.nextFocusedIndexPath {
            let next = tableView.cellForRowAtIndexPath(nextFocusedIndexPath) as! CellType!
            next?.marquee.holdScrolling = false
            print("\(nextFocusedIndexPath.row): startScrolling")
        }<commit_msg>Use labelization to match default UILabel functionality.<commit_after>//
//  ViewController.swift
//  Demo-tvOS
//
//  Created by toshi0383 on 1/9/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

let labels = [
    "Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello Hello World.",
    "Hello Hello Hello Hello Hello Hello Hello World."]

let defaultScrollDuration: CGFloat = 20.0

class ViewController: UIViewController {

    @IBOutlet var marqueeTableView: UITableView!
    @IBOutlet var labelTableview: LabelTableView!


    override func viewDidLoad() {
        super.viewDidLoad()
        // MarqueeLabel Tableview
        marqueeTableView.dataSource = self
        marqueeTableView.delegate = self
        
        // Basic UILabel Tableview
        labelTableview.dataSource = labelTableview
    }

}

typealias CellType = TableViewCell

extension ViewController: UITableViewDataSource {

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return labels.count * 8
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = marqueeTableView.dequeueReusableCellWithIdentifier("Cell") as! CellType!
        cell.marquee.text = labels[indexPath.row % labels.count]
        cell.marquee.labelize = true
        cell.marquee.fadeLength = 7.0
        cell.marquee.scrollDuration = defaultScrollDuration
        cell.marquee.lineBreakMode = .ByTruncatingTail
        return cell
    }
}

extension ViewController: UITableViewDelegate {
    func tableView(tableView: UITableView, didUpdateFocusInContext context: UITableViewFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
        if let previouslyFocusedIndexPath = context.previouslyFocusedIndexPath {
            let previous = tableView.cellForRowAtIndexPath(previouslyFocusedIndexPath) as! CellType!
            previous?.marquee.labelize = true
        }
        if let nextFocusedIndexPath = context.nextFocusedIndexPath {
            let next = tableView.cellForRowAtIndexPath(nextFocusedIndexPath) as! CellType!
            next?.marquee.labelize = false
        }
{'fraction_non_alphanumeric': 0.0763888888888889, 'fraction_numerical': 0.007341269841269841, 'mean_word_length': 3.2504215851602023, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5320591', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1325, 'n_words': 359}