Skip to content

Commit

Permalink
Fixed Backspace Issue
Browse files Browse the repository at this point in the history
Pretty hacky solution: There’s a global track of whether the backspace
key was pressed. If so, it doesn’t do syntax highlighting
  • Loading branch information
kennethshawfriedman committed May 8, 2017
1 parent 5881d74 commit dce8e68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Binary file not shown.
7 changes: 6 additions & 1 deletion Schemer-MacOS/Schemer/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ViewController: NSViewController {
let pipeIn = Pipe()
var handleIn = FileHandle()
let pipeOut = Pipe()
var backspace = false

var warmingUp = true

Expand Down Expand Up @@ -97,6 +98,9 @@ class ViewController: NSViewController {
//called on every key-stroke of non-modifier keys
override func keyDown(with event: NSEvent) {

backspace = event.characters == "\u{7F}"

//print("test2:\(event.characters)")
//Check if the command key is pressed, if it is: send to other function to handle
let commandKey:Bool = event.modifierFlags.contains(.command)
if (commandKey) {
Expand Down Expand Up @@ -129,12 +133,13 @@ class ViewController: NSViewController {
}

override func textStorageDidProcessEditing(_ notification: Notification) {
//super.textStorageDidProcessEditing(notification)
guard !backspace else { return }
let textStorage = notification.object as! NSTextStorage
let allText = textStorage.string
let formattedText = Syntaxr.highlightAllText(allText)
textStorage.setAttributedString(formattedText)
}

}

//Extension Contains the Delegate Methods
Expand Down

0 comments on commit dce8e68

Please sign in to comment.