-
-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get the current window's screen info #1513
Comments
Huh, that's an interesting thought. I wonder if this should be a cross-platform Vim GUI API. It does seem like it needs both an autocmd and a function to query it. Let me think about it a little. I do see the value of this. |
There is (or at least used to be) a neat little CLI app called |
Unfortunately, it doesn't know anything about the "active" screen. (The first run was on my secondary screen; the second run was on my primary screen.)
|
I think the bigger issue is mostly that you would want a way to query the MacVim window to see which screen it is in. It's ideal for this to be exposed by MacVim itself. |
I was thinking more about it, you can actually already query the info you want. In macOS, the window position is global across all screens. The main screen usually starts at (0,0), and say if you have a screen to its left it could start at something like (-1920, -98). You can use FWIW you don't really need a third-party program (e.g. #! /usr/bin/swift
import Cocoa
var findPoint: NSPoint?
if CommandLine.arguments.count > 1 {
findPoint = NSPointFromString(CommandLine.arguments[1])
}
var output = [[String:Any]]()
for (index, screen) in NSScreen.screens.enumerated() {
if let p = findPoint {
if (!screen.frame.contains(p)) {
continue;
}
}
output.append(["frame": try JSONSerialization.jsonObject(with: JSONEncoder().encode(screen.frame)),
"main": NSScreen.main == screen,
"refreshRate": screen.maximumFramesPerSecond,
"scaleFactor": screen.backingScaleFactor,
"index": index,
"name": screen.localizedName])
}
let jsonData = try JSONSerialization.data(withJSONObject: output)
print(String(data: jsonData, encoding: String.Encoding.utf8)!) If you call it directly it will print out a JSON info of your screens. If you pass it a point as a command-line argument (e.g. If I run it locally I see something like this:
Within Vim, you can call
I guess one issue is we don't have an autocmd that could detect a GUI window has moved or changed screen, so you won't have a way to automatically detect that this has happened. |
Is your feature request about something that is currently impossible or hard to do? Please describe the problem.
Background: I have multiple machines and two screens on one of them. On my main machine, on the secondary screen where I usually run MacVim, I have my font to
:h16
, but I need it at:h12
(or so) on my main laptop screen (or on my secondary machine where there is no secondary screen).Describe the solution you'd like
I would like to be able to have a function in MacVim return the current window's screen information—screen width / height in pixels, screen name, other details; similar to the output of
system_profiler SPDisplaysDataType
:If possible, it would be nice to have an event (
WindowScreenChanged
or something like that) which could be used to trigger when the window has been moved to a different screen or the screen has been resized or something.Describe alternatives you've considered
I don't think that there are alternatives which let me know which screen the current window is on, even if some of this could be executed via osascript.
The text was updated successfully, but these errors were encountered: