Skip to content

Commit

Permalink
removing Cmd+Drag code. See git diff on this commit if you need it again
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethshawfriedman committed Jun 21, 2019
1 parent 042952a commit dca6900
Showing 1 changed file with 0 additions and 91 deletions.
91 changes: 0 additions & 91 deletions Toski/Toski/CodeField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,97 +52,6 @@ class CodeField : NSTextView {
return 16
}

// command+drag to slide numerical values
// inspiration from https://github.com/Shopify/superdb/blob/develop/SuperDebug/Super%20Debug/SuperDraggableShellView.m#L129
// override func mouseDown(with event: NSEvent) {
// if !event.modifierFlags.contains(.command) {
// return super.mouseDown(with: event)
// }
//
// let start_location = event.locationInWindow
//
// let initial_string = self.textStorage!.string
// var hit_char_index = initial_string.index(initial_string.startIndex, offsetBy:
// // for who-knows-why reasons, .charachterIndex() takes mouse in global coordinates,
// // so we use NSEvent.mouseLocation() to get it
// self.characterIndex(for: NSEvent.mouseLocation))
//
// // make sure we're not passed the end of the chars
// if hit_char_index == initial_string.endIndex {
// hit_char_index = initial_string.index(before: hit_char_index)
// }
//
// Swift.print(initial_string[hit_char_index])
//
// // scan left for start of number token
// var start_index = hit_char_index
// while start_index != initial_string.startIndex {
// let next_index = initial_string.index(before: start_index)
//
// if !["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].contains(initial_string[next_index]) {
// // number doesn't continue left
// break;
// }
//
// start_index = next_index
// }
//
// // scan right for end of number token
// var end_index = hit_char_index
// while end_index != initial_string.endIndex {
// if !["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].contains(initial_string[end_index]) {
// // number doesn't continue left
// break;
// }
//
// end_index = initial_string.index(after: end_index)
// }
//
// if initial_string.distance(from: start_index, to: end_index) == 0 {
// // there's no number token here
// return
// }
//
// //let initial_text_range = Range.init(uncheckedBounds: (lower: start_index, upper: end_index))
// //let initial_number = Int(initial_string.substring(with: initial_text_range))!
// let initial_text_range = start_index ..< end_index
// let init_substring = initial_string[initial_text_range]
// let init_regular_str = String(init_substring)
// let initial_number = Int(init_regular_str)
//
//
//
// var range = NSRangeFromRange(range: initial_text_range)
// self.setSelectedRange(range)
//
// // technique from https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/EventOverview/HandlingMouseEvents/HandlingMouseEvents.html#//apple_ref/doc/uid/10000060i-CH6-SW4
// while true {
// let next_event = self.window!.nextEvent(matching: NSEvent.EventTypeMask.leftMouseUp.union(.leftMouseDragged))!
// switch next_event.type {
//
// case .leftMouseDragged:
// let deltaX = next_event.locationInWindow.x - start_location.x
// let new_value = (initial_number ?? 0) + Int(deltaX / 10)
// let strval = String(new_value)
// self.insertText(strval, replacementRange: range)
//
// range.length = strval.count
// self.setSelectedRange(range)
//
// case .leftMouseUp:
// // mouse is up, so the drag is over, and we should break out of the drag loop
// Swift.print("mouse up")
// return
//
// default:
// // we should never get any eevents other than mouse up or dragged
// Swift.print("mouse dragging code got a wrong event")
// break
// }
//
// }
// }

func NSRangeFromRange(range r: Range<String.Index>) -> NSRange {
let text = self.textStorage!.string
let start = text.distance(from: text.startIndex, to: r.lowerBound)
Expand Down

0 comments on commit dca6900

Please sign in to comment.