From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: Re: [9fans] Anyone to try to convert Acme to full UI (w/graphics)
Date: Thu, 26 Oct 2006 19:35:11 +0100 [thread overview]
Message-ID: <8052e9979e33ecff799bacd84d2f565c@vitanuova.com> (raw)
In-Reply-To: <123d17ac591ffb286e0a7aff61e1bd12@mail.gmx.net>
> Dealing with different screen resolutions kind of sucks though, it
> could be that it's my rc scripting and understanding of the rio
> control namespace isn't very good yet.
possibly the first program i wrote when i first started using
plan 9 was to deal with this issue. i've attached it - it's tiny.
all it does is convert proportional coordinates [0..1] to screen
coords [0..max].
for instance,
winpos 0.6 0.0 0.4 100p
gives a 100 pixel high rectangle that covers the right
40% of the screen.
i use it like this:
window -r `{winpos 0 0.05 1 1} acme -l acme.dump
perhaps this might help?
#include <u.h>
#include <libc.h>
int makecoord(char*, int, int);
int getscreensize(int*, int*, int*, int*);
void
main(int argc, char **argv)
{
int scrminx, scrminy, scrmaxx, scrmaxy;
int minx, miny, sizex, sizey, maxx, maxy;
/* usage: winpos xorg yorg xsize ysize */
if (argc != 5) {
fprint(2, "usage: winpos xorg yorg xsize ysize\n");
exits("usage");
}
if (getscreensize(&scrminx, &scrminy, &scrmaxx, &scrmaxy) == -1) {
fprint(2, "winpos: couldn't get screen size: %r\n");
exits("no screen");
}
minx = makecoord(argv[1], scrminx, scrmaxx);
miny = makecoord(argv[2], scrminy, scrmaxy);
sizex = makecoord(argv[3], scrminx, scrmaxx);
sizey = makecoord(argv[4], scrminy, scrmaxy);
if (sizex > (scrmaxx - scrminx))
sizex = scrmaxx - scrminx;
if (sizey > (scrmaxy - scrminy))
sizey = scrmaxy - scrminy;
if (minx + sizex > scrmaxx)
minx = scrmaxx - sizex;
if (miny + sizey > scrmaxy)
miny = scrmaxy - sizey;
maxx = minx + sizex;
maxy = miny + sizey;
print("%d %d %d %d\n", minx, miny, maxx, maxy);
exits(0);
}
int
makecoord(char *spec, int min, int max)
{
if (spec[0] == 0)
return 0;
if (spec[strlen(spec) - 1] == 'p')
return atoi(spec);
return atof(spec) * (max - min) + min;
}
int
getscreensize(int *minx, int *miny, int *maxx, int *maxy)
{
char buf[12*12+1];
int fd;
buf[sizeof(buf) - 1] = 0;
fd = open("#i/draw/new", OREAD);
if(fd < 0)
return -1;
if(read(fd, buf, sizeof buf - 1) != sizeof buf - 1){
close(fd);
return -1;
}
close(fd);
*minx = atoi(buf+4*12);
*miny = atoi(buf+5*12);
*maxx = atoi(buf+6*12);
*maxy = atoi(buf+7*12);
return 0;
}
next prev parent reply other threads:[~2006-10-26 18:35 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-23 7:30 cej
2006-10-23 10:34 ` Alexander Sychev
2006-10-23 11:56 ` Eric Van Hensbergen
2006-10-23 12:21 ` Alexander Sychev
2006-10-24 5:55 ` cej
2006-10-24 5:55 ` cej
2006-10-24 15:08 ` Ronald G Minnich
2006-10-25 4:31 ` cej
2006-10-25 16:33 ` Joel Salomon
2006-10-25 16:54 ` Russ Cox
2006-10-25 17:21 ` Russ Cox
2006-10-25 17:27 ` erik quanstrom
2006-10-25 17:42 ` Tad Hunt
2006-10-25 18:07 ` Skip Tavakkolian
2006-10-25 18:19 ` Paul Lalonde
2006-10-25 18:24 ` erik quanstrom
2006-10-25 17:55 ` rog
2006-10-25 18:17 ` Skip Tavakkolian
2006-10-26 18:13 ` David Leimbach
2006-10-26 18:22 ` Sascha Retzki
2006-10-26 18:30 ` David Leimbach
2006-10-26 18:35 ` rog [this message]
2006-10-30 19:05 ` Joel Salomon
2006-10-30 19:34 ` Paul Hebble
2006-10-26 18:24 ` Ronald G Minnich
2006-10-26 21:39 ` David Leimbach
2006-10-27 7:00 ` cej
2006-10-27 8:37 ` Bruce Ellis
2006-10-27 11:24 ` erik quanstrom
2006-10-27 14:04 ` Russ Cox
2006-10-28 19:27 ` Paweł Lasek
2006-10-24 15:25 ` Alexander Sychev
2006-10-25 4:29 ` cej
2006-10-25 4:57 ` Lyndon Nerenberg
2006-10-25 16:18 ` Joel Salomon
2006-10-30 6:23 ` cej
2006-10-30 6:33 ` Paul Lalonde
2006-10-30 12:56 ` erik quanstrom
2006-10-30 15:16 ` Russ Cox
2006-10-30 15:25 ` Gabriel Diaz
2006-10-30 15:30 ` Paul Lalonde
2006-10-30 16:17 ` Ronald G Minnich
2006-10-31 5:33 ` cej
2006-10-31 18:33 ` Ronald G Minnich
2006-11-01 6:21 ` cej
2006-10-23 11:10 ` Tony Lainson
2006-10-23 17:31 ` lucio
2006-10-25 18:04 ` Sascha Retzki
2006-10-25 18:12 ` Sascha Retzki
2006-10-25 18:18 ` Paul Lalonde
2006-10-25 18:23 ` erik quanstrom
2006-10-25 20:15 ` Paul Lalonde
2006-10-25 20:38 ` erik quanstrom
2006-10-25 20:57 ` Tim Wiess
2006-10-25 21:14 ` Paul Lalonde
2006-10-25 18:25 ` Sascha Retzki
2006-10-25 20:16 ` Paul Lalonde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8052e9979e33ecff799bacd84d2f565c@vitanuova.com \
--to=rog@vitanuova.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).