Skip to content
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

Support special --position arguments for screen centre and edges #208

Closed
GoogleCodeExporter opened this issue Jun 4, 2015 · 5 comments
Closed

Comments

@GoogleCodeExporter
Copy link

I modified winmain.c to provide a --center (-x) option that centers the window. 
 Is there anychance you can add something like that to the project?

I attached the winmain.c, it's been about 15 years since I have written in 
c/c++, so this may not be optimal, but it was a pretty small change.

Thanks! -- Andrew


Original issue reported on code.google.com by akt...@gmail.com on 6 Aug 2010 at 4:06

Attachments:

@GoogleCodeExporter
Copy link
Author

here is a diff...

$ diff winmain.c winmainx.c
765a766
>   "  -x, --center          Open window in center of screen\n"
780c781
< static const char short_opts[] = "+:HVuec:o:p:s:w:t:i:l:h:";
---
> static const char short_opts[] = "+:HVeuxc:o:p:s:w:t:i:l:h:";
787a789
>   {"center",   no_argument,       0, 'x'},
868a871
>   bool center = false;
901a905
>       when 'x': center = true;
1060a1065,1075
>
>   if (center) {
>     static RECT ss;
>     get_fullscreen_rect(&ss);
>     SetWindowPos(wnd, null,
>                  (ss.right - (term_width + extra_width + 2 * PADDING))/2,
>                  (ss.bottom - (term_height + extra_height + 2 * PADDING))/2,
>                  term_width + extra_width + 2 * PADDING,
>                  term_height + extra_height + 2 * PADDING,
>                  SWP_NOZORDER);
>   }

Original comment by akt...@gmail.com on 6 Aug 2010 at 4:08

@GoogleCodeExporter
Copy link
Author

Good work, but no, I wouldn't want to add this as a separate option. However, I 
could imagine adding it as a special argument to the --position option, along 
with support for the four edges, so you could say something like 
'--position=right,top' or '-position=centre,centre'.

I'm not really convinced that this is necessary though, because the existing 
--position functionality already supports these use cases; it's just that it 
might require a bit of experimentation to find the right coordinates.

Original comment by andy.koppe on 6 Aug 2010 at 5:24

  • Changed title: Support special --position arguments for screen centre and edges
  • Changed state: Accepted
  • Added labels: Difficulty-Medium, Priority-Low

@GoogleCodeExporter
Copy link
Author

I agree that adding to the existing -p option is better, my current c skills 
would not let me go there without actually looking something up!  This was for 
a script that gets kicked off after an install, so who knows what res screen it 
would run on, and folks wanted it centered like the installer that came before 
it.

Original comment by akt...@gmail.com on 6 Aug 2010 at 12:31

@GoogleCodeExporter
Copy link
Author

Thanks, that's a valid new use case (although perhaps not a very common one).

Original comment by andy.koppe on 7 Aug 2010 at 6:02

@mintty
Copy link
Owner

mintty commented Jul 30, 2015

Implemented -pcentre , --position center (or vice versa).

@mintty mintty closed this as completed Jul 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants