bug-bash
[Top][All Lists]
Advanced

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

Re: how to start in "overwrite-mode"


From: Stephane CHAZELAS
Subject: Re: how to start in "overwrite-mode"
Date: Thu, 29 Oct 2009 07:23:18 +0000 (UTC)
User-agent: slrn/pre1.0.0-11 (Linux)

2009-10-28, 20:28(-04), Dave Rutherford:
[...]
> Add to .Xdefaults: XTerm*answerbackString: ^[[2~
> Add to .bashrc (and .profile if it doesn't source .bashrc):
>     bind '"^[[2~": overwrite-mode'
>     PROMPT_COMMAND='echo -n ^E'
[...]

Along those lines, you could use the TIOCSTI ioctl. That would
be system dependant instead of terminal dependant. Like sti.c:

#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
  int i;
  char *c;

  if (!isatty(0))
    return 0;

  for (i = 1; i < argc; i++) {
    if (i > 1 && ioctl(0, TIOCSTI, " ") == -1)
    {
      perror("ioctl");
      return 1;
    }
    for (c = argv[i]; *c; c++) {
      if (ioctl(0, TIOCSTI, c) == -1)
      {
        perror("ioctl");
        return 1;
      }
    }
  }
  return 0;
}

And

PROMPT_COMMAND="sti \$'\05'"

> If the user drops down to a PS2, etc.
> prompt, that line will be in insert mode.
[...]

Same problem here.

-- 
Stéphane


reply via email to

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