linux-0.11调试教程,退格键的调用过程(2)

[/root]# ac
[/root]# c

下面的调用过程对应上面的情况,光标位于字符串的中间的时候,非末尾的情况。


rl_redisplay ()

    update_line ()
        delete_chars ()

       output_some_chars ()


/* Delete COUNT characters from the display line. */

static
delete_chars (count)
     int count;
{
  if (count > screenwidth)
    return;

  if (term_DC && *term_DC)
    {
      char *tgoto (), *buffer;
      buffer = tgoto (term_DC, 0, count);
      tputs (buffer, 1, output_character_function);
    }
  else
    {
      if (term_dc && *term_dc)
    while (count--)
      tputs (term_dc, 1, output_character_function);
    }

}



__iowrite处下断点时的情形:length为0xb

linux-0.11调试教程,退格键的调用过程(2)_第1张图片



附上涉及的代码:

static
update_line (old, new, current_line)
     register char *old, *new;
     int current_line;
{


...


  else                /* Delete characters from line. */
    {
      /* If possible and inexpensive to use terminal deletion, then do so. */
      if (term_dc && (2 * (ne - nfd)) >= (-lendiff))
    {
      if (lendiff)
        delete_chars (-lendiff); /* delete (diff) characters */

      /* Copy (new) chars to screen from first diff to last match */
      if ((nls - nfd) > 0)
        {
          output_some_chars (nfd, (nls - nfd));
          last_c_pos += (nls - nfd);
        }
    }
...
}


[/root]# c    -->    [/root]# ac        按下a键, length5     

 [/root]# ac   -->     [/root]# abc  按下b键,length5


[/root]# abc   -->      [/root]# ac  按下退格键,lengthb


  [/root]# abc   -->      [/root]# abc 按下左方向键    length3

 [/root]# abc    -->       [/root]# abc 按下左方向键  

 [/root]# abc    -->       [/root]# bc 按下退格键 length7


你可能感兴趣的:(linux-0.11调试教程,退格键的调用过程(2))