linux-0.11调试教程,update

如何由old变成new的?答案在最后!

例子一:

[/root]# c –> [/root]# ac 按下a键, length为5

具体过程为:[/root]# c –> [/root]# a –> [/root]# ac

staticupdate_line (old, new, current_line) register char *old, *new; int current_line;{ ….

else { /* At the end of a line the characters do not have to be "inserted". They can just be placed on the screen. */ output_some_chars (nfd, lendiff); last_c_pos += lendiff; } /* Copy (new) chars to screen from first diff to last match. */ if (((nls – nfd) – lendiff) > 0) { output_some_chars (&nfd[lendiff], ((nls – nfd) – lendiff)); last_c_pos += ((nls – nfd) – lendiff); }

….

}

output_some_chars (nfd, lendiff);时:

output_some_chars (&nfd[lendiff], ((nls – nfd) – lendiff));时:

可见nfd为0x59c15,lendiff为1,nls为0x59c17,ne为0x59c17

(ofd为0x63415,ols和oe都为0x63416)

/* if (len (new) > len (old)) */ lendiff = (nls – nfd) – (ols – ofd); /* lendiff = 2-1=1

例子2:下面的对应下面的图,退格键时的6个位置

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 /*产生字符0x50315b1b*/ /* Copy (new) chars to screen from first diff to last match */ if ((nls – nfd) > 0) { output_some_chars (nfd, (nls – nfd)); /*产生字符0x63*/ last_c_pos += (nls – nfd); } }

[/root]# abc –>[/root]# ac 按下退格键,length为b

delete_chars (-lendiff);时

output_some_chars()时

lendiff = (nls – nfd) – (ols – ofd);

lendiff = 10 – 15 = -5;

先删除5个字符,delete_chars (-lendiff);/*产生字符0x50355b1b*/,会调用内核的csi_P()函数。

然后再打印出10个字符buggy say,把le-buggy i覆盖掉!!!

既调用output_some_chars (nfd, (nls – nfd));。

static void delete_char(int currcons){ int i; unsigned short * p = (unsigned short *) pos; if (x>=video_num_columns) return; i = x; while (++i < video_num_columns) { *p = *(p+1); p++; } *p = video_erase_char;

}

static void csi_P(int currcons, unsigned int nr){ if (nr > video_num_columns) nr = video_num_columns; else if (!nr) nr = 1; while (nr–) delete_char(currcons);}

怕仍是不能。于是他们比任何人都看的清楚,又比任何人都看的不确切。

linux-0.11调试教程,update

相关文章:

你感兴趣的文章:

标签云: