linux-0.11调试教程,bash-1.12源代码分析readline.a和termcap.a的连接

来源:互联网 发布:网上怎么自学淘宝 编辑:程序博客网 时间:2024/06/08 17:08

接中backspace键的调用过程

linux-0.11调试教程,readline()回显字符调用顺序



/* Move the cursor back. */
backspace (count)
     int count;
{
  register int i;

  if (term_backspace)
    for (i = 0; i < count; i++)
      tputs (term_backspace, 1, output_character_function);
  else
    for (i = 0; i < count; i++)
      putc ('\b', out_stream);
}


/* A function for the use of tputs () */

static void
output_character_function (c)
     int c;
{
  putc (c, out_stream);

}


tputs ()函数属于termcap.a库的一个函数。下面是一种实现

可见会调用output_character_function()函数

int tputs(char * cp, int affcnt, void (*outc)(int ch))
{
  if (cp == (char *)NULL) return(1);
  /* Do any padding interpretation - left null for MINIX just now */
  while (*cp) (*outc) (*cp++);
  return(1);
}

这时的term_backspace指向的字符串为:



      backspace (1);
      putc (' ', out_stream);
      backspace (1);

之后调用fflush()函数中的___iowrite()函数的时候length为7

0x1b 0x5b 0x44       作用是左移一个字符位置

0x20       作用是当前光标出显示空格,既把原来的字符删除掉,光标右移一个字符位置

0x1b 0x5b 0x44         作用是左移一个字符位置


原创粉丝点击