screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: control


From: Micah Cowan
Subject: Re: control
Date: Fri, 09 Jan 2009 22:06:41 -0800
User-agent: Thunderbird 2.0.0.18 (X11/20081125)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

broz wrote:
> On Thu, 04 Dec 2008 10:02:31 -0800
> Micah Cowan <address@hidden> wrote:
> 
> broz wrote:
>>>> Hi,
>>>>    i have a question about gnuscreen which I think is great
>>>> btw. I may have a hard time conveying what I want to know, but here
>>>> goes:
>>>>
>>>> I currently use nano as my editor (within gnuscreen of course). I
>>>> can have multiple files open in it, and can switch to the next one
>>>> with the M-. (or M-<) key. Is there some way to have screen send
>>>> that key as a control, not as text? I tried register-process
>>>> escaping but can't get the hang of it...

> I'm having trouble what you're asking. In terminals, virtually
> _everything_ is text: controls certainly are. The only things that can
> be done that aren't some variety of "sending text" are changing the
> stty values, and sending SIGWINCH to inform an app that the window
> size has changed.
> 
> Perhaps you should explain what screen is currently doing that you
> don't want it to do?
> 
> In terminals, M-. is either sent as the escape character (ESC)
> followed by a period, or else by sending the period character but
> with its highest bit set instea>Hi,

>> I would like to have my script change the current opened buffer in nano.
>> To achieve this by hand I press <M-.> I would like to know if it can be
>> automated with some gnuscreen feature, such as process-register.

(My mail reader has botched the quoting above, which is in
conversational order: you, me, you.)

Wow. The Date header says you wrote this on Dec 5, but the trace headers
 show it didn't end up getting sent out until today. Guess it got holed
up somewhere or something?

I'm copying the mailing list for this, as that's the appropriate place
for discussing screen questions, and if I say something that ends up
being useful then it's good for it to be in the list archive; or, if I
miss something/get something wrong, someone else there may be able to
fix it.

You may find the screenrc command "stuff" to be helpful for this. It
allows you to send arbitrary text to the terminal that's running under
screen. You might also need the "select" command to select the
appropriate screen window if you have multiple ones open.

You can send control characters and such by specifying their octal
escapes, \012 for newline, for example. M-. is usually represented as
the Escape character (\033) followed by period: "\033." It can also be
represented by taking the ASCII code for the period (\056) and toggling
the high bit, which makes \256; but that doesn't work so great anymore
these days, since it interferes with common character encodings.

So, for example,

  stuff \033.

in a config file that you ask screen to read will send M-. .

If you want to write a bash script that communicates with an open screen
session to send that sequence, something like:

  screen -S foo -p 1 -X 'stuff' $'\033.'

(where "foo" is the name of the screen session, and the window hosting
nano is screen 1). Screen unfortunately will not interpret octal escapes
coming from the commandline, so resorting to tricks like that bash
extension $'\033' becomes necessary (one could also use the more
portable "printf" command).

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer.
GNU Maintainer: wget, screen, teseq
http://micah.cowan.name/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkloOvEACgkQ7M8hyUobTrGTGQCfT28FkMZkXpoNjWklUNgYeH1i
Ac8An30cE+GRq7UY6AzxPGotFQcbG3iE
=Fnws
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]