Skip to content

[FEAT] - Copy the program information #261

Closed

Description

@Angelk90

Is your feature request related to a problem? Please describe.
How about such a thing as Webstorm does which allows you to copy program information.

In this case I copy only the version of the program in use.
It would also be useful to know:

  • The version of the OS
  • The version of Xcode

What do you think?

Registrazione.schermo.2022-03-26.alle.09.05.54.mov

I have a problem with animation, if anyone would like to give me some advice if you want this feature.

Code:

HStack {
                    Text("Version \(appVersion) (\(appBuild))")
                        .foregroundColor(.secondary)
                        .font(.system(size: 13))
                    if isHovering {
                        Image(systemName: "doc.on.doc")
                            .resizable()
                            .frame(width: 15, height: 15)
                            .transition(AnyTransition.opacity.animation(.easeInOut(duration: 0.25)))
                            .onHover { inside in
                                if inside {
                                    NSCursor.pointingHand.push()
                                } else {
                                    NSCursor.pop()
                                }
                            }
                            .onTapGesture {
                                let osVersion = ProcessInfo.processInfo.operatingSystemVersion
                                guard let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.dt.Xcode"),
                                      let bundle = Bundle(url: url) else {
                                    print("Xcode is not installed")
                                    exit(1)
                                }

                                guard let infoDict = bundle.infoDictionary,
                                      let version = infoDict["CFBundleShortVersionString"] as? String else {
                                    print("No version found in Info.plist")
                                    exit(1)
                                }
                                let pasteboard = NSPasteboard.general
                                pasteboard.clearContents()
                                pasteboard.setString(
                                    "CodeEdit: \(appVersion) (\(appBuild))\n" +
                                    "MacOS: \(osVersion.majorVersion).\(osVersion.minorVersion).\(osVersion.patchVersion)\n" +
                                    "XCode: \(version)"
                                    , forType: .string)
                            }
                    }
                }

Activity

  1. lukepistrol commented on Mar 26, 2022

    @lukepistrol
    Member

    I would do it like this:

    HStack {
      Text("Version \(appVersion) (\(appBuild))")
        .foregroundColor(.secondary)
        .font(.system(size: 13))
        .onTapGesture {
          NSPasteboard.general.setString("CodeEdit: \(appVersion) (\(appBuild))", forType: .string)
        }
      }
    }

    or using a context menu

  2. Angelk90 commented on Mar 26, 2022

    @Angelk90
    ContributorAuthor

    @lukepistrol : I would like it more if the copy icon appears, but you decide how you prefer.

    This is the code at the moment:

        private var macOsVersion: String {
            let osVersion = ProcessInfo.processInfo.operatingSystemVersion
            return "\(osVersion.majorVersion).\(osVersion.minorVersion).\(osVersion.patchVersion)"
        }
        
        private var xCodeVersion: String {
            guard let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.dt.Xcode"),
                  let bundle = Bundle(url: url) else {
                print("Xcode is not installed")
                exit(1)
            }
            
            guard let infoDict = bundle.infoDictionary,
                  let version = infoDict["CFBundleShortVersionString"] as? String else {
                print("No version found in Info.plist")
                exit(1)
            }
            
            return version
        }
    ...
                    Text("Version: \(appVersion) (\(appBuild))")
                        .foregroundColor(.secondary)
                        .font(.system(size: 13))
                        .onHover { inside in
                            if inside {
                                NSCursor.pointingHand.push()
                            } else {
                                NSCursor.pop()
                            }
                        }
                        .onTapGesture {
                            let pasteboard = NSPasteboard.general
                            pasteboard.clearContents()
                            pasteboard.setString(
                                "CodeEdit: \(appVersion) (\(appBuild))\n" +
                                "MacOS: \(macOsVersion)\n" +
                                "Xcode: \(xCodeVersion)"
                                , forType: .string)
                        }
    Registrazione.schermo.2022-03-26.alle.13.20.59.mov
  3. moved this from 🆕 New to 🏁 Complete in CodeEdit Projecton Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions