2002-04-07 21:44:48

by Petr Baudis

[permalink] [raw]
Subject: Re: gpmselection

Oops, this time with the correct Cc: stuff, sorry :).

Dear diary, on Sun, Apr 07, 2002 at 10:57:03PM CEST, I got a letter,
where Jiri Mencak <[email protected]> told me, that...
> Do you know any program or even better a gpm feature via which I could
> access GPM selection? Say I wanted to select text `Hello World!' on
> a text console using GPM and then this program (let's call it
> `gpmselection') would output to stdout:
>
> % gpmselection
> Hello World!
>
> It would be nice to write to gpm selection as well. Say by writing:
> % echo "Hello World!" | gpmselection
>
> it would be possible to paste `Hello World!' on a console.
>
> What I am aiming at is an echange of data between X and a console. I
> have a program `xsel' which does the same thing with X-Window selection.

This is a problem. Been there, wanted to do that. However, you cry on the wrong
grave. GPM doesn't itself handle this stuff, kernel does. Yes, it's
fundamentally bad design, no, you can't directly access kernel's selection
buffer. Yes, this change would be probably welcomed in 2.5.x. I wanted to do
it, but I've too little time for that these days :(.

The stuff you want to rewrite is at /usr/src/linux/drivers/char/selection.c,
maybe random bits at /usr/src/linux/drivers/char/vt.c. And, obviously GPM, as
you want to move this functionality there. You probably want to completely
remove concept of selections from kernel, make GPM to read content of
/dev/vcc/X when grabbing a selection and output proper escape sequences for
inverting the appropriate stuff (this may be tricky; maybe you want to keep
such mechanism in the kernel.. you'll see), add write handler for /dev/vcc/X to
the kernel so that you can simulate keyboard input on the terminal and finally
make some generic API inside GPM for manipulation with the selection buffer.

Have fun ;),

--

Petr "Pasky" Baudis

* ELinks maintainer * IPv6 guy (XS26 co-coordinator)
* IRCnet operator * FreeCiv AI hacker
.
Teamwork is essential -- it allows you to blame someone else.
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/


2002-04-08 06:30:59

by Alessandro Rubini

[permalink] [raw]
Subject: Re: [gpm]Re: gpmselection


>> What I am aiming at is an echange of data between X and a console. I
>> have a program `xsel' which does the same thing with X-Window selection.

> [...]
> The stuff you want to rewrite is at /usr/src/linux/drivers/char/selection.c,
> maybe random bits at /usr/src/linux/drivers/char/vt.c.

Adding one or two more "commands" in console.c::tioclinux (one to get
the current selection buffer, one to copy he buffer for user space,
possibly), is all that's needed.

> And, obviously GPM, as you want to move this functionality there.

This is a different issue altogether. I agree it would be a good move,
but it's not the original point.

> You probably want to completely remove concept of selections from
> kernel, make GPM to read content of /dev/vcc/X when grabbing a
> selection and output proper escape sequences for inverting the
> appropriate stuff

You don't need to send that, just use /dev/vcs. The problem, rather,
is ensuring the console doesn't get modified. Currently, it can be
blocked with existing ioctls() while the user selects, but any
highlight should be removed before the console is unlocked unless
other means are designed (not a good thing, in my opinion, as it
wouldn't actually take stuff out of the kernel any more).

> write handler for /dev/vcc/X to the kernel so that you can simulate
> keyboard input on the terminal

That's already there, nothing to add here. The problem, rather, is
handling not-direct mapping from glyphs to keyboard input, not always
trivial.

/alessandro, not the gpm maintainer any more