         return true
     }
     
-    
-    
-    // MARK: Action Messages
-    
-    /// activate self and perform "New" menu action
-    @IBAction func newDocumentActivatingApplication(_ sender: Any?) {
-        
-        NSApp.activate(ignoringOtherApps: true)
-        NSDocumentController.shared.newDocument(sender)
-    }
-    
-    
-    /// activate self and perform "Open..." menu action
-    @IBAction func openDocumentActivatingApplication(_ sender: Any?) {
-        
-        NSApp.activate(ignoringOtherApps: true)
-        NSDocumentController.shared.openDocument(sender)
-    }
-    
-    
-    /// show standard about panel
-    @IBAction func showAboutPanel(_ sender: Any?) {
-     
-        let creditsURL = Bundle.main.url(forResource: "Credits", withExtension: "html")!
-        var html = try! String(contentsOf: creditsURL)
-        
-        #if APPSTORE  // Remove Sparkle from 3rd party code list
-        if let range = html.range(of: "Sparkle") {
-            html = html.replacingCharacters(in: html.lineRange(for: range), with: "")
-        }
-        #endif
-        
-        // inverse text color in dark mode
-        if #available(macOS 10.14, *), NSApp.effectiveAppearance.isDark {
-            html = html.replacingOccurrences(of: "<body>", with: "<body style=\"color: white\">")
-        }
-        
-        let attrString = NSAttributedString(html: html.data(using: .utf8)!, baseURL: creditsURL, documentAttributes: nil)!
-        NSApplication.shared.orderFrontStandardAboutPanel(options: [.credits: attrString])
-    }
-    
-    
-    /// show preferences window
-    @IBAction func showPreferences(_ sender: Any?) {
-        
-        self.preferencesWindowController.showWindow(sender)
-    }
-    
-    
-    /// show console panel
-    @IBAction func showConsolePanel(_ sender: Any?) {
-        
-        Console.shared.panelController.showWindow(sender)
-    }
-    
-    
-    /// show acknowlegements
-    @IBAction func showAcknowledgments(_ sender: Any?) {
-        
-        self.acknowledgmentsWindowController.showWindow(sender)
-    }
-    
-    
-    /// open OSAScript dictionary in Script Editor
-    @IBAction func openAppleScriptDictionary(_ sender: Any?) {
-        
-        let appURL = Bundle.main.bundleURL
-        
-        NSWorkspace.shared.open([appURL], withAppBundleIdentifier: BundleIdentifier.ScriptEditor,
-                                additionalEventParamDescriptor: nil, launchIdentifiers: nil)
-    }
-    
-    
-    /// open a specific page in Help contents
-    @IBAction func openHelpAnchor(_ sender: AnyObject) {
-        
-        guard let identifier = (sender as? NSUserInterfaceItemIdentification)?.identifier else { return assertionFailure() }
-        
-        NSHelpManager.shared.openHelpAnchor(identifier.rawValue, inBook: Bundle.main.helpBookName)
-    }
-    
-    
-    /// open web site (coteditor.com) in default web browser
-    @IBAction func openWebSite(_ sender: Any?) {
-        
-        NSWorkspace.shared.open(AppWebURL.website.url)
-    }
-    
-    
-    /// open bug report page in default web browser
-    @IBAction func reportBug(_ sender: Any?) {
-        
-        NSWorkspace.shared.open(AppWebURL.issueTracker.url)
-    }
-    
-    
-    /// open new bug report window
-    @IBAction func createBugReport(_ sender: Any?) {
-        
-        // load template file
-        guard
-            let url = Bundle.main.url(forResource: "ReportTemplate", withExtension: "md"),
-            let template = try? String(contentsOf: url)
-            else { return assertionFailure() }
-        
-        // fill template with user environment info
-        let report = template
-            .replacingOccurrences(of: "%BUNDLE_VERSION%", with: Bundle.main.bundleVersion)
-            .replacingOccurrences(of: "%SHORT_VERSION%", with: Bundle.main.shortVersion)
-            .replacingOccurrences(of: "%SYSTEM_VERSION%", with: ProcessInfo.processInfo.operatingSystemVersionString)
-        
-        // open as document
-        guard let document = try? NSDocumentController.shared.openUntitledDocumentAndDisplay(false) as? Document else { return assertionFailure() }
-        document.displayName = "Bug Report".localized(comment: "document title")
-        document.textStorage.replaceCharacters(in: NSRange(0..<0), with: report)
-        document.setSyntaxStyle(name: BundledStyleName.markdown)
-        document.makeWindowControllers()
-        document.showWindows()
-    }
-    
-    
-    
-    // MARK: Private Methods
-    
-    /// build encoding menu in the main menu
-    @objc private func buildEncodingMenu() {
-        
-        let menu = self.encodingsMenu!
-        
-        EncodingManager.shared.updateChangeEncodingMenu(menu)
-    }
-    
-    
-    /// build syntax style menu in the main menu
-    @objc private func buildSyntaxMenu() {
-        
-        let menu = self.syntaxStylesMenu!
-        
-        menu.removeAllItems()
-        
-        // add None
-        menu.addItem(withTitle: BundledStyleName.none, action: #selector(SyntaxHolder.changeSyntaxStyle), keyEquivalent: "")
-        menu.addItem(.separator())
-        
-        // add syntax styles
-        for styleName in SyntaxManager.shared.settingNames {
-            menu.addItem(withTitle: styleName, action: #selector(SyntaxHolder.changeSyntaxStyle), keyEquivalent: "")
-        }
-        menu.addItem(.separator())
-        
-        // add item to recolor
-        let recolorAction = #selector(SyntaxHolder.recolorAll)
-        let shortcut = MenuKeyBindingManager.shared.shortcut(for: recolorAction)
-        let recoloritem = NSMenuItem(title: "Re-Color All".localized, action: recolorAction, keyEquivalent: shortcut.keyEquivalent)
-        recoloritem.keyEquivalentModifierMask = shortcut.modifierMask  // = default: Cmd + Opt + R
-        menu.addItem(recoloritem)
-    }
-    
-    
-    /// build theme menu in the main menu
-     @objc private func buildThemeMenu() {
-        
-        let menu = self.themesMenu!
-        
-        menu.removeAllItems()
-        
-        for themeName in ThemeManager.shared.settingNames {
-            menu.addItem(withTitle: themeName, action: #selector(ThemeHolder.changeTheme), keyEquivalent: "")
-        }
-    }
-    
 }

    
    
    /// open multiple files at once
    func application(_ sender: NSApplication, openFiles filenames: [String]) {
        
        let isAutomaticTabbing = (DocumentWindow.userTabbingPreference == .inFullScreen) && (filenames.count > 1)
        let dispatchGroup = DispatchGroup()
        var firstWindowOpened = false
        
        for filename in filenames {
            guard !self.application(sender, openFile: filename) else {
                continue
            }
            
            let url = URL(fileURLWithPath: filename)
            
            dispatchGroup.enter()
            DocumentController.shared.openDocument(withContentsOf: url, display: true) { (document, documentWasAlreadyOpen, error) in

    }
    
    
    
    // MARK: Action Messages
    
    /// activate self and perform "New" menu action
    @IBAction func newDocumentActivatingApplication(_ sender: Any?) {
        
        NSApp.activate(ignoringOtherApps: true)
        NSDocumentController.shared.newDocument(sender)
    }
    
    
    /// activate self and perform "Open..." menu action
    @IBAction func openDocumentActivatingApplication(_ sender: Any?) {
        
        NSApp.activate(ignoringOtherApps: true)
        NSDocumentController.shared.openDocument(sender)
    }
    
    
    /// show standard about panel
    @IBAction func showAboutPanel(_ sender: Any?) {
     
        let creditsURL = Bundle.main.url(forResource: "Credits", withExtension: "html")!
        var html = try! String(contentsOf: creditsURL)
        
        #if APPSTORE  // Remove Sparkle from 3rd party code list
        if let range = html.range(of: "Sparkle") {
            html = html.replacingCharacters(in: html.lineRange(for: range), with: "")
        }
        #endif
        
        // inverse text color in dark mode
        if #available(macOS 10.14, *), NSApp.effectiveAppearance.isDark {
            html = html.replacingOccurrences(of: "<body>", with: "<body style=\"color: white\">")
        }
        
        let attrString = NSAttributedString(html: html.data(using: .utf8)!, baseURL: creditsURL, documentAttributes: nil)!
        NSApplication.shared.orderFrontStandardAboutPanel(options: [.credits: attrString])
    }
    
    
    /// show preferences window
    @IBAction func showPreferences(_ sender: Any?) {
        
        self.preferencesWindowController.showWindow(sender)
    }
    
    
    /// show console panel
    @IBAction func showConsolePanel(_ sender: Any?) {
        
        Console.shared.panelController.showWindow(sender)
    }
    
    
    /// show acknowlegements
    @IBAction func showAcknowledgments(_ sender: Any?) {
        
        self.acknowledgmentsWindowController.showWindow(sender)
    }
    
    
    /// open OSAScript dictionary in Script Editor
    @IBAction func openAppleScriptDictionary(_ sender: Any?) {
        
        let appURL = Bundle.main.bundleURL
        
        NSWorkspace.shared.open([appURL], withAppBundleIdentifier: BundleIdentifier.ScriptEditor,
                                additionalEventParamDescriptor: nil, launchIdentifiers: nil)
    }
    
    
    /// open a specific page in Help contents
    @IBAction func openHelpAnchor(_ sender: AnyObject) {
        
        guard let identifier = (sender as? NSUserInterfaceItemIdentification)?.identifier else { return assertionFailure() }
        
        NSHelpManager.shared.openHelpAnchor(identifier.rawValue, inBook: Bundle.main.helpBookName)
    }
    
    
    /// open web site (coteditor.com) in default web browser
    @IBAction func openWebSite(_ sender: Any?) {
        
        NSWorkspace.shared.open(AppWebURL.website.url)
    }
    
    
    /// open bug report page in default web browser
    @IBAction func reportBug(_ sender: Any?) {
        
        NSWorkspace.shared.open(AppWebURL.issueTracker.url)
    }
    
    
    /// open new bug report window
    @IBAction func createBugReport(_ sender: Any?) {
        
        // load template file
        guard
            let url = Bundle.main.url(forResource: "ReportTemplate", withExtension: "md"),
            let template = try? String(contentsOf: url)
            else { return assertionFailure() }
        
        // fill template with user environment info
        let report = template
            .replacingOccurrences(of: "%BUNDLE_VERSION%", with: Bundle.main.bundleVersion)
            .replacingOccurrences(of: "%SHORT_VERSION%", with: Bundle.main.shortVersion)
            .replacingOccurrences(of: "%SYSTEM_VERSION%", with: ProcessInfo.processInfo.operatingSystemVersionString)
        
        // open as document
        guard let document = try? NSDocumentController.shared.openUntitledDocumentAndDisplay(false) as? Document else { return assertionFailure() }
        document.displayName = "Bug Report".localized(comment: "document title")
        document.textStorage.replaceCharacters(in: NSRange(0..<0), with: report)
        document.setSyntaxStyle(name: BundledStyleName.markdown)
        document.makeWindowControllers()
        document.showWindows()
    }
    
    
    
    // MARK: Private Methods
    
    /// build encoding menu in the main menu
    @objc private func buildEncodingMenu() {
        
        let menu = self.encodingsMenu!
        
        EncodingManager.shared.updateChangeEncodingMenu(menu)
    }
    
    
    /// build syntax style menu in the main menu
    @objc private func buildSyntaxMenu() {
        
        let menu = self.syntaxStylesMenu!
        
        menu.removeAllItems()
        
        // add None
        menu.addItem(withTitle: BundledStyleName.none, action: #selector(SyntaxHolder.changeSyntaxStyle), keyEquivalent: "")
        menu.addItem(.separator())
        
        // add syntax styles
        for styleName in SyntaxManager.shared.settingNames {
            menu.addItem(withTitle: styleName, action: #selector(SyntaxHolder.changeSyntaxStyle), keyEquivalent: "")
        }
        menu.addItem(.separator())
        
        // add item to recolor
        let recolorAction = #selector(SyntaxHolder.recolorAll)
        let shortcut = MenuKeyBindingManager.shared.shortcut(for: recolorAction)
        let recoloritem = NSMenuItem(title: "Re-Color All".localized, action: recolorAction, keyEquivalent: shortcut.keyEquivalent)
        recoloritem.keyEquivalentModifierMask = shortcut.modifierMask  // = default: Cmd + Opt + R
        menu.addItem(recoloritem)
    }
    
    
    /// build theme menu in the main menu
     @objc private func buildThemeMenu() {
        
        let menu = self.themesMenu!
        
        menu.removeAllItems()
        
        for themeName in ThemeManager.shared.settingNames {
            menu.addItem(withTitle: themeName, action: #selector(ThemeHolder.changeTheme), keyEquivalent: "")
        }
    }
    
    
    /// Ask the user whether install the theme
    /// - Parameter url: A theme file URL.
    private func askInstallTheme(url: URL) -> Bool {
        
        // ask whether theme file should be opened as a text file
        let alert = NSAlert()
