zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Danek Duvall <duvall@comfychair.org>
Cc: zsh-workers@sunsite.dk, Jordan Breeding <jordan.breeding@mac.com>
Subject: Re: prompt and prompt_cr option
Date: Mon, 11 Oct 2004 18:52:10 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0410111742210.9416@toltec.zanshin.com> (raw)
In-Reply-To: <20041011232857.GB11629@lorien.comfychair.org>

On Mon, 11 Oct 2004, Danek Duvall wrote:

> On Mon, Oct 11, 2004 at 03:11:43PM -0700, Bart Schaefer wrote:
> 
> > For certain types of terminals you might be able to query the current 
> > cursor position and do something clever when it is not in column zero
> 
> On the other hand, you could write a precmd function that did this and 
> spit out an extra newline if necessary (and set nopromptcr), no?

Unfortunately it's not quite that simple.

As far as I can tell, there's no terminfo/termcap capability that defines
the "report cursor position" string.  So it can't easily be determined
whether the terminal supports it, or what to send.

If the terminal is ANSI/ECMA compliant, the query string is $'\e[6n' and 
the response is $'\e[ll;ccR' where cc and ll are the column and line 
numbers -- but if it is not ANSI then sending that string won't give any 
response (and may just garble the output further).

So the following might work, or might not.  It uses the prompt printed by
the read builtin to query the terminal and the combination of IFS and the
-d option to parse the response.

  precmd() {
    local escape colno lineno
    IFS='[;' read -s -d R escape\?$'\e[6n' lineno colno
    (( colno > 1 )) && echo ''
  }


      reply	other threads:[~2004-10-12  1:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-09 15:17 Jordan Breeding
2004-10-11 22:11 ` Bart Schaefer
2004-10-11 23:28   ` Danek Duvall
2004-10-12  1:52     ` Bart Schaefer [this message]

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=Pine.LNX.4.61.0410111742210.9416@toltec.zanshin.com \
    --to=schaefer@brasslantern.com \
    --cc=duvall@comfychair.org \
    --cc=jordan.breeding@mac.com \
    --cc=zsh-workers@sunsite.dk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).