[/root]# ac
[/root]# c
下面的调用过程对应上面的情况,光标位于字符串的中间的时候,非末尾的情况。
rl_redisplay ()
update_line ()
delete_chars ()
output_some_chars ()
/* Delete COUNT characters from the display line. */
staticdelete_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
附上涉及的代码:
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键, length为5
[/root]# ac --> [/root]# abc 按下b键,length为5
[/root]# abc --> [/root]# ac 按下退格键,length为b
[/root]# abc --> [/root]# abc 按下左方向键 length为3
[/root]# abc --> [/root]# abc 按下左方向键
[/root]# abc --> [/root]# bc 按下退格键 length为7