OhmNomNom / thyme

A fork of mintty, for the modern world
GNU General Public License v3.0
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
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 commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
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