diff --git a/CloverApp/Clover.xcodeproj/project.pbxproj b/CloverApp/Clover.xcodeproj/project.pbxproj index 32185e122..8b97543af 100644 --- a/CloverApp/Clover.xcodeproj/project.pbxproj +++ b/CloverApp/Clover.xcodeproj/project.pbxproj @@ -83,6 +83,7 @@ 9580403D2413F8CA00F09F2C /* lodepng.c in Sources */ = {isa = PBXBuildFile; fileRef = 9580403C2413F8C900F09F2C /* lodepng.c */; }; 958040402414070F00F09F2C /* ThemeImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 9580403F2414070F00F09F2C /* ThemeImage.m */; }; 958861DA235F75FB00B64173 /* Driver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 958861D9235F75FB00B64173 /* Driver.swift */; }; + 95BFF3D42451C0420088BA8E /* PEFindAndReplace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BFF3D32451C0420088BA8E /* PEFindAndReplace.swift */; }; 95C515222369BAF500E4A3A8 /* NVRAM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C515212369BAF500E4A3A8 /* NVRAM.swift */; }; 95C5152F236A0A7400E4A3A8 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C5152E236A0A7400E4A3A8 /* SettingsView.swift */; }; 95C51536236B1F7700E4A3A8 /* RunAtLogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C51535236B1F7700E4A3A8 /* RunAtLogin.swift */; }; @@ -429,6 +430,7 @@ 9580403E2414070F00F09F2C /* ThemeImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ThemeImage.h; sourceTree = ""; }; 9580403F2414070F00F09F2C /* ThemeImage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ThemeImage.m; sourceTree = ""; }; 958861D9235F75FB00B64173 /* Driver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Driver.swift; sourceTree = ""; }; + 95BFF3D32451C0420088BA8E /* PEFindAndReplace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PEFindAndReplace.swift; sourceTree = ""; }; 95C515212369BAF500E4A3A8 /* NVRAM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NVRAM.swift; sourceTree = ""; }; 95C5152E236A0A7400E4A3A8 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; 95C51535236B1F7700E4A3A8 /* RunAtLogin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RunAtLogin.swift; sourceTree = ""; }; @@ -546,6 +548,7 @@ 9571A229241C2E7F000D6645 /* PlistEditor.storyboard */, 9571A225241C01DB000D6645 /* PlistEditorWC.swift */, 9571A223241BFF44000D6645 /* PlistEditorVC.swift */, + 95BFF3D32451C0420088BA8E /* PEFindAndReplace.swift */, 9559D52524355A800007FCF3 /* PEConstraints.swift */, 955500F9241AD7C200618F57 /* PEFindButton.swift */, 955500FB241AD7C200618F57 /* ReplaceButton.swift */, @@ -959,6 +962,7 @@ 9559D52624355A810007FCF3 /* PEConstraints.swift in Sources */, 954BBE99238196EE0032425F /* Locale.swift in Sources */, 9555010C241AD7C300618F57 /* PEOutlineView.swift in Sources */, + 95BFF3D42451C0420088BA8E /* PEFindAndReplace.swift in Sources */, 95E68ACA235B862F002B37A5 /* AppDelegate.swift in Sources */, 955BEE1523C6B49C00425AB0 /* ThemeView.swift in Sources */, 958861DA235F75FB00B64173 /* Driver.swift in Sources */, diff --git a/CloverApp/Clover/Plist Editor/Document.swift b/CloverApp/Clover/Plist Editor/Document.swift index 1a4705d3c..aaa943cc3 100644 --- a/CloverApp/Clover/Plist Editor/Document.swift +++ b/CloverApp/Clover/Plist Editor/Document.swift @@ -27,7 +27,7 @@ import Cocoa -@available(OSX 10.11, *) +@available(OSX 10.10, *) final class Document: NSDocument { var data : Data? var windowController : PlistEditorWC? diff --git a/CloverApp/Clover/Plist Editor/PEValueTransformer.swift b/CloverApp/Clover/Plist Editor/PEValueTransformer.swift index 8a0fd2e9c..aadebb1ed 100644 --- a/CloverApp/Clover/Plist Editor/PEValueTransformer.swift +++ b/CloverApp/Clover/Plist Editor/PEValueTransformer.swift @@ -27,7 +27,7 @@ import Cocoa -@available(OSX 10.11, *) +@available(OSX 10.10, *) extension PlistEditorVC { @objc func boolPopUpPressed(sender: PEPopUpButton) { let originalValue : Bool = sender.node!.tagdata!.value as! Bool diff --git a/CloverApp/Clover/Plist Editor/PE_Undo.swift b/CloverApp/Clover/Plist Editor/PE_Undo.swift index 933bf33ce..f74e8723c 100644 --- a/CloverApp/Clover/Plist Editor/PE_Undo.swift +++ b/CloverApp/Clover/Plist Editor/PE_Undo.swift @@ -28,7 +28,7 @@ import Cocoa // MARK: Undo and redo support -@available(OSX 10.11, *) +@available(OSX 10.10, *) extension PEOutlineView { // MARK: Undo Manager object diff --git a/CloverApp/Clover/Plist Editor/PE_Utils.swift b/CloverApp/Clover/Plist Editor/PE_Utils.swift index 772308c8c..9221fcb35 100644 --- a/CloverApp/Clover/Plist Editor/PE_Utils.swift +++ b/CloverApp/Clover/Plist Editor/PE_Utils.swift @@ -127,7 +127,7 @@ func gPlistTag(from str: String) -> PlistTag { In 10.9/10.10 if mentioned programs aren't present the directory containing the desired file will be opened by the Finder. */ func loadPlist(at path: String) { - if #available(OSX 10.11, *) { + if #available(OSX 10.10, *) { let dc = NSDocumentController.shared dc.openDocument(withContentsOf: URL(fileURLWithPath: path), display: true) { (document, documentWasAlreadyOpen, error) in diff --git a/CloverApp/Clover/Plist Editor/Views/PEAlert.swift b/CloverApp/Clover/Plist Editor/Views/PEAlert.swift index 39035a1a3..7a82dbf62 100644 --- a/CloverApp/Clover/Plist Editor/Views/PEAlert.swift +++ b/CloverApp/Clover/Plist Editor/Views/PEAlert.swift @@ -27,7 +27,7 @@ import Cocoa -@available(OSX 10.11, *) +@available(OSX 10.10, *) final class PEAlert : NSAlert { var anyString : String? = nil var outline: PEOutlineView? = nil diff --git a/CloverApp/Clover/Plist Editor/Views/PEFindAndReplace.swift b/CloverApp/Clover/Plist Editor/Views/PEFindAndReplace.swift new file mode 100644 index 000000000..05c11bd3e --- /dev/null +++ b/CloverApp/Clover/Plist Editor/Views/PEFindAndReplace.swift @@ -0,0 +1,156 @@ +/* + * vector sigma (https://github.com/vectorsigma72) + * Copyright 2020 vector sigma All Rights Reserved. + * + * The source code contained or described herein and all documents related + * to the source code ("Material") are owned by vector sigma. + * Title to the Material remains with vector sigma or its suppliers and licensors. + * The Material is proprietary of vector sigma and is protected by worldwide copyright. + * No part of the Material may be used, copied, reproduced, modified, published, + * uploaded, posted, transmitted, distributed, or disclosed in any way without + * vector sigma's prior express written permission. + * + * No license under any patent, copyright, trade secret or other intellectual + * property right is granted to or conferred upon you by disclosure or delivery + * of the Materials, either expressly, by implication, inducement, estoppel or + * otherwise. Any license under such intellectual property rights must be + * express and approved by vector sigma in writing. + * + * Unless otherwise agreed by vector sigma in writing, you may not remove or alter + * this notice or any other notice embedded in Materials by vector sigma in any way. + * + * The license is granted for the CloverBootloader project (i.e. https://github.com/CloverHackyColor/CloverBootloader) + * and all the users as long as the Material is used only within the + * source code and for the exclusive use of CloverBootloader, which must + * be free from any type of payment or commercial service for the license to be valid. + */ + +import Cocoa + +@available(OSX 10.10, *) +final class PEFindVC: NSViewController, NSSearchFieldDelegate, NSTextViewDelegate { + var editor : PlistEditorVC? + @IBOutlet var doneBtn: NSButton! + @IBOutlet var showReplaceBtn: ReplaceButton! + @IBOutlet var nextOrPreviousSegment: NSSegmentedControl! + @IBOutlet var searchField: PESearchField! + + class func loadFromNib(editor: PlistEditorVC) -> PEFindVC? { + let id = NSStoryboard.SceneIdentifier("FindView") + let vc = NSStoryboard(name: NSStoryboard.Name("PlistEditor"), + bundle: nil).instantiateController(withIdentifier: id) as! PEFindVC + vc.editor = editor + vc.searchField?.countLabel?.placeholderString = "" + if (editor.searchField != nil) { + editor.searchField?.superview?.removeFromSuperview() + } + return vc + } + + override func viewDidLoad() { + super.viewDidLoad() + // set up actions + self.editor?.doneBtn = self.doneBtn + self.doneBtn.target = self.editor + self.doneBtn.action = #selector(self.editor?.doneButtonPressed(_:)) + + self.editor?.showReplaceBtn = self.showReplaceBtn + self.showReplaceBtn.target = self.editor + self.showReplaceBtn.action = #selector(self.editor?.showReplaceView(sender:)) + + self.editor?.nextOrPreviousSegment = self.nextOrPreviousSegment + self.nextOrPreviousSegment.target = self.editor + self.nextOrPreviousSegment.action = #selector(self.editor?.segmentScrollerPressed(_:)) + + self.editor?.searchField = self.searchField + self.searchField.placeholderString = localizedSearch + self.searchField.countLabel?.stringValue = "" + + if let search = NSPasteboard.init(name: .findPboard).string(forType: .string) { + self.searchField.stringValue = search + if search != self.editor?.currentSearchString { + self.editor?.performDelayedSearch() + } + } else { + self.searchField.stringValue = self.editor?.currentSearchString ?? "" + if let count = self.editor?.searches.count { + self.searchField.countLabel.placeholderString = (count > 0) ? "\(count)" : "" + } else { + self.searchField.countLabel.placeholderString = "" + } + } + } +} + +@available(OSX 10.10, *) +final class PEFindAndReplaceVC: NSViewController, NSSearchFieldDelegate { + var editor : PlistEditorVC? + @IBOutlet var doneBtn: NSButton! + @IBOutlet var showFindViewBtn: FindButton! + @IBOutlet var showReplaceBtn: ReplaceButton! + @IBOutlet var nextOrPreviousSegment: NSSegmentedControl! + @IBOutlet var replaceOneOrAllSegment: NSSegmentedControl! + @IBOutlet var searchField: PESearchField! + @IBOutlet var replaceField: PEReplaceField! + + class func loadFromNib(editor: PlistEditorVC) -> PEFindAndReplaceVC? { + let id = NSStoryboard.SceneIdentifier("FindAndReplaceView") + let vc = NSStoryboard(name: NSStoryboard.Name("PlistEditor"), + bundle: nil).instantiateController(withIdentifier: id) as! PEFindAndReplaceVC + vc.editor = editor + if (editor.searchField != nil) { + editor.searchField?.superview?.removeFromSuperview() + } + return vc + } + + override func viewDidLoad() { + super.viewDidLoad() + // set up actions + self.editor?.doneBtn = self.doneBtn + self.doneBtn.target = self.editor + self.doneBtn.action = #selector(self.editor?.doneButtonPressed(_:)) + + self.editor?.showFindViewBtn = self.showFindViewBtn + self.showFindViewBtn.target = self.editor + self.showFindViewBtn.action = #selector(self.editor?.showFindView(sender:)) + + self.editor?.showReplaceBtn = self.showReplaceBtn + self.showReplaceBtn.target = self.editor + self.showReplaceBtn.action = #selector(self.editor?.showReplaceView(sender:)) + + self.editor?.nextOrPreviousSegment = self.nextOrPreviousSegment + self.nextOrPreviousSegment.target = self.editor + self.nextOrPreviousSegment.action = #selector(self.editor?.segmentScrollerPressed(_:)) + + self.editor?.searchField = self.searchField + self.searchField.placeholderString = localizedSearch + self.searchField.countLabel?.stringValue = "" + self.editor?.replaceField = self.replaceField + if let search = NSPasteboard.init(name: .findPboard).string(forType: .string) { + self.searchField.stringValue = search + if search != self.editor?.currentSearchString { + self.editor?.performDelayedSearch() + } + } else { + self.searchField.stringValue = self.editor?.currentSearchString ?? "" + if let count = self.editor?.searches.count { + self.searchField.countLabel.placeholderString = (count > 0) ? "\(count)" : "" + } else { + self.searchField.countLabel.placeholderString = "" + } + } + + self.replaceField.placeholderString = localizedReplace + self.editor?.replaceField = self.replaceField + self.replaceField.stringValue = self.editor?.currentReplaceString ?? "" + + self.editor?.replaceOneOrAllSegment = self.replaceOneOrAllSegment + self.replaceOneOrAllSegment.target = self.editor + self.replaceOneOrAllSegment.action = #selector(self.editor?.replaceOneOrAllSegmentPressed(_:)) + for i in 0..= 0 { - if let selNode = self.outline?.item(atRow: row) as? PENode { - // determine if self.node is a child (or sub child of selfNode) - let ipsc = "\(self.node!.indexPath)".trimmingCharacters(in: CharacterSet(arrayLiteral: "]")) - let ips = "\(selNode.indexPath)".trimmingCharacters(in: CharacterSet(arrayLiteral: "]")) + "," - if ipsc.hasPrefix(ips) { - bt = .verticalOnly - let childs = selNode.mutableChildren - if childs.count > 0 && (childs.lastObject as! PENode) == self.node { - bt = .verticalAndBottom + if #available(OSX 10.11, *) { + var bt : RowViewBorderType = .none + if self.isSelected { + self.highLightAllBorders(in: dirtyRect) + } else { + let row : Int = self.outline?.selectedRow ?? -1 + if row >= 0 { + if let selNode = self.outline?.item(atRow: row) as? PENode { + // determine if self.node is a child (or sub child of selfNode) + let ipsc = "\(self.node!.indexPath)".trimmingCharacters(in: CharacterSet(arrayLiteral: "]")) + let ips = "\(selNode.indexPath)".trimmingCharacters(in: CharacterSet(arrayLiteral: "]")) + "," + if ipsc.hasPrefix(ips) { + bt = .verticalOnly + let childs = selNode.mutableChildren + if childs.count > 0 && (childs.lastObject as! PENode) == self.node { + bt = .verticalAndBottom + } } } } } - } - - switch bt { - case .none: break // taken into account previously - case.verticalAndBottom: - self.highLightLeftBorder(in: dirtyRect) - self.highLightRightBorder(in: dirtyRect) - self.highLightBottomBorder(in: dirtyRect) - case .verticalOnly: - self.highLightLeftBorder(in: dirtyRect) - self.highLightRightBorder(in: dirtyRect) + + switch bt { + case .none: break // taken into account previously + case.verticalAndBottom: + self.highLightLeftBorder(in: dirtyRect) + self.highLightRightBorder(in: dirtyRect) + self.highLightBottomBorder(in: dirtyRect) + case .verticalOnly: + self.highLightLeftBorder(in: dirtyRect) + self.highLightRightBorder(in: dirtyRect) + } } } diff --git a/CloverApp/Clover/Plist Editor/Views/PETextField.swift b/CloverApp/Clover/Plist Editor/Views/PETextField.swift index 7a8d24539..efaa9a880 100644 --- a/CloverApp/Clover/Plist Editor/Views/PETextField.swift +++ b/CloverApp/Clover/Plist Editor/Views/PETextField.swift @@ -28,7 +28,7 @@ import Cocoa //MARK: PETextField (NSTextField) -@available(OSX 10.11, *) +@available(OSX 10.10, *) final class PETextField: NSTextField, NSTextViewDelegate { var outline : PEOutlineView? = nil var node : PENode? = nil @@ -89,7 +89,7 @@ final class PETextField: NSTextField, NSTextViewDelegate { } } -@available(OSX 10.11, *) +@available(OSX 10.10, *) final class PETextFieldCell : NSTextFieldCell { override func drawingRect(forBounds rect: NSRect) -> NSRect { diff --git a/CloverApp/Clover/Plist Editor/Views/PlistEditor.storyboard b/CloverApp/Clover/Plist Editor/Views/PlistEditor.storyboard index 4ede3cae7..02a0e2a2e 100644 --- a/CloverApp/Clover/Plist Editor/Views/PlistEditor.storyboard +++ b/CloverApp/Clover/Plist Editor/Views/PlistEditor.storyboard @@ -1,8 +1,8 @@ - + - + @@ -42,120 +42,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -165,11 +53,11 @@ - + - + @@ -177,7 +65,6 @@ - @@ -201,7 +88,7 @@ - + @@ -259,7 +146,6 @@ - @@ -278,7 +164,7 @@ - + @@ -297,7 +183,6 @@ - @@ -318,7 +203,7 @@ - + @@ -373,23 +258,250 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CloverApp/Clover/Plist Editor/Views/PlistEditorVC.swift b/CloverApp/Clover/Plist Editor/Views/PlistEditorVC.swift index bec10ddca..ed84a0c31 100644 --- a/CloverApp/Clover/Plist Editor/Views/PlistEditorVC.swift +++ b/CloverApp/Clover/Plist Editor/Views/PlistEditorVC.swift @@ -27,7 +27,7 @@ import Cocoa -@available(OSX 10.11, *) +@available(OSX 10.10, *) final class PlistEditorVC: NSViewController, NSOutlineViewDelegate, NSOutlineViewDataSource, @@ -37,13 +37,16 @@ NSSearchFieldDelegate, NSSplitViewDelegate { @IBOutlet var editorView: NSView! @IBOutlet var scrollView : NSScrollView! @IBOutlet var outline : PEOutlineView! - @IBOutlet var doneBtn: NSButton? - @IBOutlet var showFindViewBtn: FindButton? - @IBOutlet var showReplaceBtn: ReplaceButton? - @IBOutlet var nextOrPreviousSegment: NSSegmentedControl? - @IBOutlet var replaceOneOrAllSegment: NSSegmentedControl? - @IBOutlet var searchField: PESearchField? - @IBOutlet var replaceField: PEReplaceField? + var doneBtn: NSButton? + var showFindViewBtn: FindButton? + var showReplaceBtn: ReplaceButton? + var nextOrPreviousSegment: NSSegmentedControl? + var replaceOneOrAllSegment: NSSegmentedControl? + var searchField: PESearchField? + var replaceField: PEReplaceField? + + var currentSearchString : String = "" + var currentReplaceString : String = "" @IBOutlet var findAndReplaceViewHeightConstraint: NSLayoutConstraint! @@ -80,23 +83,6 @@ NSSearchFieldDelegate, NSSplitViewDelegate { override func viewDidLoad() { super.viewDidLoad() self.findAndReplaceViewHeightConstraint.constant = 0 - - self.searchField?.placeholderString = localizedSearch - self.searchField?.countLabel?.stringValue = "" - - self.doneBtn?.target = self - self.doneBtn?.action = #selector(self.doneButtonPressed(_:)) - self.nextOrPreviousSegment?.target = self - self.nextOrPreviousSegment?.action = #selector(self.segmentScrollerPressed(_:)) - self.replaceOneOrAllSegment?.target = self - self.replaceOneOrAllSegment?.action = #selector(self.replaceOneOrAllSegmentPressed(_:)) - if self.replaceOneOrAllSegment != nil { - for i in 0..RootDir, L"\\EFI", &DirIter); while (DirIterNext(&DirIter, 1, L"*", &DirEntry)) { if (DirEntry->FileName[0] == '.') { //DBG("Skip dot entries: %ls\n", DirEntry->FileName); @@ -1256,7 +1256,7 @@ VOID ScanLoader(VOID) } XString OSName = SPrintf("%ls", DirEntry->FileName); //this is folder name "ubuntu" XStringW File = SWPrintf("EFI\\%ls\\grubx64.efi", DirEntry->FileName); - if (FileExists(SelfRootDir, File.wc_str())) { + if (FileExists(Volume->RootDir, File.wc_str())) { XStringW LoaderTitle = SWPrintf("%s OS EFI boot menu", OSName.c_str()); XString IconXS = OSName + ",linux"_XS; IconXS.lowerAscii(); //to avoid misconception