source insight腳本:源文件和頭文件間切換

// open the corresponding .c or .h file
macro OpenCorrespondingCorHfile()
{
    //返回當前緩衝區的句柄
    hcurrentbuf = getcurrentbuf ()
    //返回與文件緩衝區關聯的文件的名稱。
    bname = getbufname (hcurrentbuf)
    //返回字符串的長度
    len = strlen (bname)
	//返回從(len-2)到(但不包括len)範圍內的bname的中間字符串
    if (".c" == strmid (bname, len-2, len))
    {
        filename = strmid (bname, 0, len-2)#".h"
    }
    else if (".h" == strmid (bname, len-2, len))
    {
        filename = strmid (bname, 0, len-2)#".c"
    }
    else
    {
        filename = nil
    }
    if (filename != nil)
    {
        //將名爲filename的文件打開到文件緩衝區中,並返回文件緩衝區的句柄。
        hbufnext = openbuf (filename)
        if (hbufnext != hnil)
        {
            setcurrentbuf (hbufnext)
        }
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章