拷贝Source Insight中的彩色代码的方法 / 将Source Insight 的代码着色拷贝出来(到Word里面) /copy the colorful code in Source Insight
之前转帖别人的:
the only method is
1.open the file with Source Insight
2.make sure you have installed a PDF maker tool ,such as Adobe Acrobat 7.0 Professional or JAWS PDF Creator or PDF Factory ,then you can get a virtual PDF Printer . ^_^
so ,Select File -> Print ,then select the "Adobe PDF" as the printer ,click OK .then you will get a PDF format file with the colorful code ! so you can copy them as you want ! ^_^
but in the end ,I find some problem of this method.
the outcome is that we can see colorful code in PDF file,but when we copy them to other place ,such as Word or the current clipboard ,the color is disapear !!! feel sad ….
refer from here :【求助】带色彩拷贝source insight下的代码?
————————-漂亮的分割线————————-
刚在别处看到的帖子,和上面方法是一样的:
1. 可以在ultraedit的打印设置中选择“打印语法着色”。装一个PDF虚拟打印机(安装pdf阅读器的时候一般都已经安装了),然后打印成pdf文件,再从pdf文件中拷贝出来就好了。(一般安装pdf的时候就安装了pdf虚拟打印机了);source insight打印着色也一样设置。
2. 利用VC++打开程序,并拷贝程序到word文档中,这样也可以使得程序着色。
刚刚亲自去测试了一下,发现转出来的pdf文件里面的代码,复制后,拷贝到word里面,是带颜色的!
也就是,这个方法是可以用的。
注:
(1)我的Source Insight的版本是3.50.0027
(2)Adobe PDF是之前安装的7.0的专业版,因此有Adobe PDF打印机的功能。
(3)而Adobe Reader是,后来又多次升级到最新的9.2.0版本。
【将Source Insight里面着色代码拷贝到Word里面的方法】
其实方法很简单,我的是英文版的Source Insight,
用Source Insight打开文件后,去File->Print,然后在 常规->选择打印机中,选择“Adobe PDF”,然后就可以确定,就可以输出一个pdf文件了,比如此处的part_dos.c变成了part_dos.pdf,
然后,去pdf文件里面复制代码,粘贴到word里面,就是可以保留颜色的代码了。
此处,随便复制粘贴一段已经着色的代码如下:
static void print_one_part (dos_partition_t *p, int ext_part_sector, int part_num)
{
int lba_start = ext_part_sector + le32_to_int (p->start4);
int lba_size = le32_to_int (p->size4);
printf ("%5dtt%10dt%10dt%2x%sn",
part_num, lba_start, lba_size, p->sys_ind,
(is_extended (p->sys_ind) ? " Extd" : ""));
}
static int test_block_type(unsigned char *buffer)
{
if((buffer[DOS_PART_MAGIC_OFFSET + 0] ! = 0x55) ||
(buffer[DOS_PART_MAGIC_OFFSET + 1] ! = 0xaa) ) {
return (– 1);
} / * no DOS Signature at all */
if(strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],"FAT",3)==0)
return DOS_PBR; / * is PBR */
return DOS_MBR; / * Is MBR */
}
注:
(1)刚发现,如果直接从PDF里面拷贝,然后到当前写帖子的百度博客里面粘贴,结果是无法识别这些颜色的,拷贝出来的是无着色的原始代码,也就说,直接从pdf拷贝出来,有些粘贴板是不认的。
(2)好像此处关于着色,pdf和word的兼容性还有问题,对于函数名,pdf里面是正常的是加粗的深蓝色,到了word里就变成了加粗的灰色的了。而且,另外一个bug就是,word里面对于pdf里面可以正常显示的代码的缩进,不能正常恢复,也就是,从pdf里面看到的,是有缩进的正常的漂亮的代码,但是拷贝到word里面,虽然保留了颜色,但是丢失了代码的缩进信息,对于看代码来说,这也是比较郁闷的事情了。。。
(3)谁以后要是找到更完美的办法,顺便告诉我一下:[email protected]
[后记]
在Win7中,装的是FoxitReader,用上面的办法生成的pdf,里面是有颜色,但是复制粘贴到word里面,就还是不能识别颜色;试了下,用adobe reader 9.0,复制粘贴出来到word里面的代码,是带颜色的,但是字体很难看,没法细调,否则颜色就又没了。。。
转载请注明:在路上 » 拷贝Source Insight中的彩色代码的方法|将Source Insight的着色代码拷贝出来(到Word里面)的办法