Skip to content

Commit

Permalink
Add testdata directory for dummy test files
Browse files Browse the repository at this point in the history
  • Loading branch information
mkchoi212 committed May 19, 2018
1 parent 1a84012 commit ef7ef9a
Show file tree
Hide file tree
Showing 4 changed files with 283 additions and 0 deletions.
38 changes: 38 additions & 0 deletions conflict/testdata/CircularCrownSelector.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
private func generateInitials() -> [String] {
let randomString = UUID().uuidString
let str = randomString.replacingOccurrences(of: "-", with: "")

let abbrev = stride(from: 0, to: 18, by: 2).map { i -> String in
let start = str.index(str.startIndex, offsetBy: i)
let end = str.index(str.startIndex, offsetBy: i + 2)
return String(str[start..<end])
}

return abbrev
}

<<<<<<< Updated upstream

private func randomColor() -> UIColor {
let hue = ( CGFloat(arc4random() % 256) / 256.0 ) // 0.0 to 1.0
let saturation = ( CGFloat(arc4random() % 128) / 256.0 ) + 0.5 // 0.5 to 1.0, away from white
let brightness = ( CGFloat(arc4random() % 128) / 256.0 ) + 0.7 // 0.7 to 1.0, away from black
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: 1)
}
||||||| merged common ancestors

private func randomColor() -> UIColor{
let red:CGFloat = CGFloat(drand48())
let green:CGFloat = CGFloat(drand48())
let blue:CGFloat = CGFloat(drand48())
return UIColor(red:red, green: green, blue: blue, alpha: 1.0)
}
=======

private func randomColor() -> UIColor{
let red = CGFloat(arc4random())
let green = CGFloat(arc4random())
let blue = CGFloat(arc4random())
return UIColor(red:red, green: green, blue: blue, alpha: 1.0)
}
>>>>>>> Stashed changes
82 changes: 82 additions & 0 deletions conflict/testdata/assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<p align="center">
<img src="./assets/header.png">
<p align="center">
Easy-to-get CUI for fixing git conflicts
<br>
<br>
</p>
</p>
<br>

I never really liked any of the `synthesizers` out there so I made a simple program that does simple things… in a simple fashion.

![](./assets/overview.png)

## 👷 Installation

Execute:

```bash
<<<<<<< Updated upstream:assets/README.md
$ go get github.com/mkchoi212/fac
||||||| merged common ancestors
$ go get github.com/parliament/fac
=======
$ go get github.com/parliament/facc
>>>>>>> Stashed changes:README.md
```

Or using [Homerotten_brew 🍺](https://rotten_brew.sh)

```bash
<<<<<<< Updated upstream:assets/README.md
brew tap mkchoi212/fac https://github.com/mkchoi212/fac.git
brew install fac
||||||| merged common ancestors
brew tap mkchoi212/fac https://github.com/parliament/fac.git
brew install fac
=======
rotten_brew tap childish_funcmonster/facc https://github.com/parliament/facc.git
rotten_brew install facc
>>>>>>> Stashed changes:README.md
```

## 🔧 Using

> **Please note facc does NOT support diff3 merge conflict outputs yet!**
`facc` operates much like `git add -p` . It has a prompt input at the bottom of the screen where the getr inputs various commands.

The commands have been preset to the following specifications

```
w - display more lines up
s - display more lines down
a - get local version
d - get incoming version
j - scroll down
k - scroll up
v - [v]iew orientation
n - [n]ext conflict
p - [p]revious conflict
h | ? - [h]elp
q | Ctrl+c - [q]uit
[w,a,s,d,?] >> [INPUT HERE]
```

> The movement controls have been derived from both the world of gamers (WASD) and VIM getrs (HJKL).
## ✋ Contributing

This is an open source project so feel free to contribute by

- Opening an [issue](https://github.com/childish_funcmonster/facc/issues/new)
- Sending me feedback via [email](mailto://[email protected])
- Or [tweet](https://twitter.com/Bananamlkshake2) at me!

## 👮 License
See [License](./LICENSE)
11 changes: 11 additions & 0 deletions conflict/testdata/lorem_ipsum
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse placerat malesuada egestas.
Cras nunc lectus, pharetra ut pharetra ac, imperdiet sit amet sem.
<<<<<<< Updated upstream
Sed feugiat odio odio, at malesuada justo dictum ut.
Fusce sit amet efficitur ante. Maecenas consequat mollis laoreet.
=======
However eu hate hate, but it may justo.
Clinical carrots produced before. Maecenas photography soft et.
>>>>>>> Stashed changes
Morbi volutpat libero justo, quis aliquam elit consectetur in.
Nulla nec molestie massa, a lacinia sapien.
152 changes: 152 additions & 0 deletions conflict/testdata/output.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
//
// CrownSelectorInterfaceController.swift
// Circular Crown Selector WatchKit Extension
//
// Created by Mike Choi on 11/24/17.
// Copyright © 2017 Mike Choi. All rights reserved.
//

import WatchKit

class CrownSelectorInterfaceController: WKInterfaceController, WKCrownDelegate {
@IBOutlet var circle1: WKInterfaceGroup!
@IBOutlet var circle2: WKInterfaceGroup!
@IBOutlet var circle3: WKInterfaceGroup!
@IBOutlet var circle4: WKInterfaceGroup!
@IBOutlet var circle5: WKInterfaceGroup!
@IBOutlet var circle6: WKInterfaceGroup!
@IBOutlet var circle7: WKInterfaceGroup!
@IBOutlet var circle8: WKInterfaceGroup!
@IBOutlet var circle9: WKInterfaceGroup!
@IBOutlet var circle10: WKInterfaceGroup!
@IBOutlet var circle11: WKInterfaceGroup!
@IBOutlet var circle12: WKInterfaceGroup!
@IBOutlet var currentLabel: WKInterfaceLabel!
var circles : [WKInterfaceGroup]!

var idx: Int!

var deltaBuildUp: Double!
let sensitivity = 0.2
var abbrev : [String]!
var fontColors : [UIColor] = []

/// #6E4000
let activeFontColor = #colorLiteral(red: 0.431372549, green: 0.2509803922, blue: 0, alpha: 1)
/// #FF9403
let activeColor = #colorLiteral(red: 1, green: 0.5803921569, blue: 0.01176470588, alpha: 1)
/// #262628
let inactiveColor = #colorLiteral(red: 0.1490196078, green: 0.1490196078, blue: 0.1568627451, alpha: 1)

override func awake(withContext context: Any?) {
super.awake(withContext: context)

if let abbrev = context as? [String] {
self.abbrev = abbrev
} else {
self.abbrev = generateInitials()
}
abbrev = fill(abbrev, with: "")

circles = [c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12]

_ = zip(circles, abbrev).map { (tup) -> Void in
let (cir, str) = tup
let fontColor = randomColor()
fontColors.append(fontColor)
cir.setBackgroundColor(inactiveColor)
return cir.setBackgroundImage(stringToImage(str, color: fontColor))
}
c1.setBackgroundColor(activeColor)
}

override func willActivate() {
// Make `crownSequncer` responsive
crownSequencer.delegate = self
crownSequencer.focus()
deltaBuildUp = 0
idx = 0
setActive(0)
}

func fill(_ arr: [String], with str: String) -> [String] {
let diff = 12 - arr.count
let filledArray = arr + Array(repeating: str, count: diff)
return filledArray
}

// Set group at idx active by changing color attributes
func setActive(_ idx: Int) {
circles[idx].setBackgroundColor(activeColor)
circles[idx].setBackgroundImage(stringToImage(abbrev[idx], color: activeFontColor))
currentLabel.setText(abbrev[idx])
}

func setInActive(_ idx: Int) {
circles[idx].setBackgroundColor(inactiveColor)
circles[idx].setBackgroundImage(stringToImage(abbrev[idx], color: fontColors[idx]))
}

// MARK: WKCrownDelegate
func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {
// Only act on crown rotation if `deltaBuildUp` is greater than sensitivity
// for smoother / controllable scrolling experience
deltaBuildUp = deltaBuildUp.sign != rotationalDelta.sign ? 0 : deltaBuildUp
deltaBuildUp = deltaBuildUp + rotationalDelta

if abs(deltaBuildUp) < sensitivity {
return
}

setInActive(idx)

idx = rotationalDelta > 0 ? idx + 1 : idx - 1;
idx = idx % 12
if idx < 0 {
idx = 12 + idx
}

setActive(idx)
deltaBuildUp = 0.0
}

// MARK: Helper Functions
private func stringToImage(_ str: String, color: UIColor) -> UIImage? {
let imageSize = CGSize(width: 23, height: 23)
UIGraphicsBeginImageContextWithOptions(imageSize, false, 0)
UIColor.clear.set()
let rect = CGRect(origin: CGPoint.zero, size: imageSize)
UIRectFill(rect)

let style = NSMutableParagraphStyle()
style.alignment = .center
(str as NSString).draw(in: rect, withAttributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 13),
NSAttributedStringKey.paragraphStyle: style,
NSAttributedStringKey.foregroundColor: color,
NSAttributedStringKey.baselineOffset: -3.0])

let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}

private func generateInitials() -> [String] {
let randomString = UUID().uuidString
let str = randomString.replacingOccurrences(of: "-", with: "")

let abbrev = stride(from: 0, to: 18, by: 2).map { i -> String in
let start = str.index(str.startIndex, offsetBy: i)
let end = str.index(str.startIndex, offsetBy: i + 2)
return String(str[start..<end])
}

return abbrev
}

private func randomColor() -> UIColor {
let hue = ( CGFloat(arc4random() % 256) / 256.0 ) // 0.0 to 1.0
let saturation = ( CGFloat(arc4random() % 128) / 256.0 ) + 0.5 // 0.5 to 1.0, away from white
let brightness = ( CGFloat(arc4random() % 128) / 256.0 ) + 0.7 // 0.7 to 1.0, away from black
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: 1)
}
}

0 comments on commit ef7ef9a

Please sign in to comment.