码迷,mamicode.com
首页 > 其他好文 > 详细

source insight原创

时间:2016-08-30 07:05:08      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:

macro enter_handler()
{
    hbuf = GetCurrentBuf();
    ln   = GetBufLnCur(hbuf);
    line = GetBufLine(hbuf, ln);
    len  = GetBufLineLength(hbuf, ln);

    i = 0;
    j = 0;
    flg = 1;
    s = "";
    tab_indent = 4;
    col = 0;

    if(len > 0)
    {
        while(i<len && flg)
        {
         ch = AsciiFromChar(line[i]);
         if(ch==9)
         {
          i   = i+1;
          col = col + tab_indent;
          continue;
         }
         if(ch==32)
         {
          i   = i+1;
          col = col+1;
          continue;
         }
         flg=0;
        }

        flg = 1;
        j = len - 1;
        while(j>i && flg)
        {
            ch = AsciiFromChar(line[j]);
            if(ch==9||ch==32)
         {
          j = j-1;
          continue;
         }
         flg = 0;
        }
        if(j>=i && AsciiFromChar(line[j])==123)//‘{‘
        {
            col = col + tab_indent;
        }
        col_posi = col;
        while(col > 0)
        {
            s = cat(s, " ");
            col = col - 1;
        }
        InsBufLine(hbuf, ln+1, s);
        SetBufIns(hbuf, ln+1, col_posi);
    }
    else
    {
        //hwnd=GetCurrentWnd();
        //sel=GetWndSel(hwnd);
        //col=sel.ichFirst;
    }
}

source insight原创

标签:

原文地址:http://www.cnblogs.com/authorlcy/p/5820360.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!