Partial solution Source Insight Chinese Input method when the input of the garbled problem and automatically add comments __ garbled problem

Source: Internet
Author: User

Recently in the combination of books to see the Linux kernel source code, many need to annotate the place, need to capitalize or add comments, always need to switch input method, always to do the same repetitive input, it is tortured. After a search, there are many methods on the Internet can not be tried, or is not ideal, but found that the source insight to define the extension of the macro, and on the official web has to add macros to use the function and add a description of the way (in fact, in the source Insight to help you can see these things, just at the beginning did not know, finally decided to write their own extension macros. After two days of efforts, finally basically achieved the expected goal, although the problem is not fully resolved, but has basically met my needs.

1 problems to be solved

Ø when the Chinese input method is opened, the input capitals, brackets, and underscores are generated garbled. After you add an extension macro, you can use ALT + the corresponding key to achieve the above input, and will not generate garbled.

Ø add comments automatically and add "*" automatically after the input line completes

2 Setting the effective step

First step:

Copy the Utils.em file directly to the source Insight\projects\base directory under My Documents, or Projectàopen projectàbase in the source Insight to open the Base project, Then open the project Utils.em file, replace the contents of the file, and then restart the source Insight.

Step Two:

Open Sourceinsight,optionsàkey Assignments, and then search for items in the following list, and then click on "Assign New key" to set the corresponding shortcut key. The shortcut Bar is the shortcut key you want to set, and the list is as follows:

Item

Shortcut keys

Describe

Macro:alta

Alt+a

Enter a

Macro:altb

Alt+b

Enter B

Macro:altc

Alt+c

Enter C

Macro:altd

Alt+d

Enter D

Macro:alte

Alt+e

Enter E

Macro:altf

Alt+f

Enter F

Macro:altg

Alt+g

Enter G

Macro:alth

Alt+h

Input h

Macro:alti

Alt+i

Input I

Macro:altj

Alt+j

Enter J

Macro:altk

Alt+k

Enter K

Macro:altl

Alt+l

Input L

Macro:altm

Alt+m

Enter M

Macro:altn

Alt+n

Enter n

Macro:alto

Alt+o

Enter O

Macro:altp

Alt+p

Input P

Macro:altq

Alt+q

Input Q

Macro:altr

Alt+r

Input R

Macro:alts

Alt+s

Input S

Macro:altt

Alt+t

Input T

Macro:altu

Alt+u

Input U

Macro:altv

Alt+v

Input V

Macro:altw

Ctrl+w (I don't know why I can't set

ALT+W)

Input W

Macro:altx

Alt+x

Enter X

Macro:alty

Alt+y

Enter Y

Macro:altz

Alt+z

Enter Z

Macro:altunderline

alt+-

Enter

Macro:altleftbracket

Alt+9

Enter

Macro:altrightbracket

Alt+0

Enter

Macro:insertasterisk_slash

F5

Insert:

/*

*

*/

Macro:enterkeydown

Enter

Starting with "/*",

"*" is automatically added to the comment at the end of "* *"

Note: The above shortcut key definition is only my personal settings, can be set according to individual needs. Some settings may block the default shortcut keys

3 Utils.em File contents

do not know how to add a file link, so the contents of the file paste out, if you do not know how to set up, you can give me a message, I will try to help, the contents are as follows:

/* Utils.em-a Small collection of useful editing macros/*----------------------------------------------------------
    ---------------I N S e r T H e a D e R inserts a comment header block in the top's the current function.

    This actually works to any type of symbol, not just functions.  To use this, the Define an environment variable "myname" and set it to your email name. eg.
    Set MYNAME=RAYGR-------------------------------------------------------------------------*/Macro Insertheader () {
    Get the owner's name from the environment Variable:myname.
    If the variable doesn ' t exist, then the owner field is skipped. Szmyname = getenv (myname)//Get a handle to the current file buffer and the name//and location of the Curre
    NT symbol where the cursor is. Hbuf = Getcurrentbuf () Szfunc = Getcursymbol () ln = getsymbolline (szfunc)//Begin assembling the title Strin G SZ = "*"/* Convert symbol name to T E X T L i K E t H i S * * * CCH = strlen (szfunc) ich = 0 while (Ich < CCH) {ch = Szfunc[ich]
                if (Ich > 0) if (isupper (ch)) Sz = Cat (SZ, "") Else SZ = Cat (SZ, "") Sz = Cat (SZ, ToUpper (ch)) ich = ich + 1} SZ = Cat (SZ, "* *") Ins Bufline (hbuf, LN, SZ) insbufline (Hbuf, Ln+1, "* *------------------------------------------------------------------- ------")/* If owner variable exists, insert Owner:name/if (strlen (Szmyname) > 0) {Ins
        Bufline (Hbuf, Ln+2, "Owner: @szMyName @") insbufline (Hbuf, Ln+3, "") ln = ln + 4} else ln = ln + 2 insbufline (hbuf, LN, "")//provide an indent already insbufline (Hbuf, ln+1, "--------  -----------------------------------------------------------------*/")//Put the insertion point inside the header Comment Setbufins (hbuf, LN, 4)}/* Insertfileheader:inserts a Comment header block at the "top" of the current function.

   This actually works to any type of symbol, not just functions.  To use this, the Define an environment variable "myname" and set it to your email name. eg. Set MYNAME=RAYGR */Macro Insertfileheader () {szmyname = getenv (myname) hbuf = Getcurrentbuf () Insbufli NE (hbuf, 0, "/*-------------------------------------------------------------------------")/* If owner variable ex ists, insert Owner:name */Insbufline (HBUF, 1, "") if (strlen (Szmyname) > 0) {sz = "O
        Wner: @szMyName @ "Insbufline (hbuf, 2," ") Insbufline (Hbuf, 3, sz) ln = 4} else



ln = 2 Insbufline (hbuf, LN, "-------------------------------------------------------------------------/*")} Inserts "Returns True ... Or False ... "at the current line macro Returntrueorfalse () {hbuf = Getcurrentbuf () ln = Getbuflinecur (hbuf) insbufline (hbuf, LN, "Returns True if successful or False if errors.")}


/* Inserts ifdef REVIEW around the selection/macro Ifdefreview () {Ifdefsz ("REVIEW");


/* Inserts ifdef BOGUS around the selection/macro Ifdefbogus () {Ifdefsz ("BOGUS");


/* Inserts ifdef NEVER around the selection/macro Ifdefnever () {Ifdefsz ("NEVER");
Ask user for ifdef condition and wrap it around current//selection.

Macro Insertifdef () {sz = Ask ("Enter ifdef Condition:") if (sz!= "") Ifdefsz (SZ);}


Macro Insertcplusplus () {Ifdefsz ("__cplusplus");} Wrap ifdef <sz>.
    EndIf around the current selection macro Ifdefsz (SZ) {hwnd = Getcurrentwnd () Lnfirst = Getwndsellnfirst (hwnd) Lnlast = Getwndsellnlast (hwnd) HBUF = Getcurrentbuf () insbufline (Hbuf, Lnfirst, "#ifdef @sz @") Insbufli NE (Hbuf, lnlast+2, "#endif/* @sz @ * *")}//Delete the current line and appends it to the Clipboard buffer Macro Killline () {hbufcur = Getcurrentbuf (); Lncur = Getbuflncur (hbufcur) Hbufclip = Getbufhandle ("Clipboard") appendbufline (Hbufclip, Getbufline, Hbufcur, LnCu
    R)) Delbufline (Hbufcur, Lncur)}//Paste lines killed with Killline (Clipboard is emptied) macro Pastekillline () { Paste Emptybuf (Getbufhandle ("Clipboard"))}//delete all lines in the buffer macro Emptybuf (HBUF) {Lnmax 
= Getbuflinecount (Hbuf) while (Lnmax > 0) {delbufline (hbuf, 0) Lnmax = lnMax-1} //Ask the user for a symbol name, then jump to IT declaration macro Jumpanywhere () {symbol = Ask ("What Declara
    tion would for you? " Jumptosymboldef (symbol)}//List all siblings of a user specified symbol//a sibling are any other symbol declared I
n the same file.
    Macro Outputsiblingsymbols () {symbol = Ask ("What symbol would your like to list siblings for?") Hbuf = listallsiblings (symbol) setcurrentbuf (hBUF)}//Given a symbol name, open the file its declared in and//create a new output buffer listing all of the symbol  s declared//in that file.
Returns the new buffer handle. Macro Listallsiblings (symbol) {loc = getsymbollocation (symbol) if (loc = "") {msg ("@symbol @ No
        T found. ")
        Stop} hbufoutput = Newbuf ("Results") Hbuf = Openbuf (loc.file) if (hbuf = 0) {
        MSG ("Can" T open file.)
    Stop} Isymmax = Getbufsymcount (hbuf) isym = 0;
        while (Isym < Isymmax) {Appendbufline (Hbufoutput, Getbufsymname (Hbuf, isym)) Isym = Isym + 1 } closebuf (HBUF) return HBUFOUTPUT} macro singlelinecomment () {hbuf = Getcurrentbuf () hwnd = Get
 Currentwnd (); Lnfirst = Getwndsellnfirst (hwnd) Lnlast = Getwndsellnlast (hwnd) while (Lnfirst < lnlast+1) {tmpbuf = Getbufline (HB Uf,lnfirst) if (tmpbuf!= Nil) {commentbuf = Cat ("//", TMPBUF) Delbufline (Hbuf,lnfirst) insbufline (hbuf,lnfirst,commentbuf)} Lnfirst = Lnfirst + 1}} macro Strstr (s RC,DST) {Dstlen = strlen (DST) Srclen = strlen (src) loop = 0 Index = 0 while (Loop < Dstlen) {if (dst[loop] = = S Rc[loop]) {index = index +1 loop = loop + 1} else {index = index + 1 loop = 0 if (index + Dstlen
 ) > Srclen) {return Invalid}}} index = Index-dstlen return index} macro singleline_uncomment () {
 Hbuf = Getcurrentbuf () hwnd = Getcurrentwnd (); Lnfirst = Getwndsellnfirst (hwnd) Lnlast = Getwndsellnlast (hwnd) while (Lnfirst < lnlast+1) {tmpbuf = Getbufline (
    Hbuf,lnfirst) if (tmpbuf!= Nil) {index = STRSTR (TMPBUF, "//") if (index!= invalid) {index = index + 2 Uncommentbuf = Strmid (Tmpbuf,index,strlen (TMPBUF)) Delbufline (Hbuf,lnfirst) insbufline (hbuf,lnFirst,unCommentBuf
}} Lnfirst = Lnfirst + 1}} macro Insertasterisk_slash () {hwnd = Getcurrentwnd ()    Lnfirst = Getwndsellnfirst (hwnd) Lnlast = Getwndsellnlast (hwnd) HBUF = Getcurrentbuf () insbufline (HB UF, Lnfirst, "/*") insbufline (Hbuf, lnlast+1, "*") Insbufline (Hbuf, lnlast+2, "* *") Delbufline ( hbuf,lnlast+3) cursor_right cursor_right cursor_down cursor_right end_of_line} macro Insertasterisk ( {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "*")} macro AltA () {hbuf = Getcurrentbuf () if (h BUF!= 0) setbufseltext (hbuf, "A")} macro AltB () {hbuf = Getcurrentbuf () if (hbuf!= 0) Setbufseltext (h BUF, "B")} macro ALTC () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "C")} macro Altd () {h BUF = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "D")} macro Alte () {hbuf = Getcurrentbuf () if (HBU F!= 0) Setbufseltext (hbuf, "E")} macro ALTF () {hbuf = Getcurrentbuf () if (hbuf!= 0) Setbufseltext (hbu
F, "F")} macro ALTG (){hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "G")} macro Alth () {hbuf = Getcurrentbuf () if
      (hbuf!= 0) Setbufseltext (Hbuf, "H")} macro Alti () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "I")} mac Ro Altj () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "J")} macro ALTK () {hbuf = GetCurrent Buf () if (hbuf!= 0) setbufseltext (hbuf, "K")} macro Altl () {hbuf = Getcurrentbuf () if (hbuf!= 0) Se  Tbufseltext (Hbuf, "L")} macro Altm () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "M")} macro Altn () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "N")} macro AltO () {hbuf = GETCURRENTBU F () if (hbuf!= 0) setbufseltext (hbuf, "O")} macro ALTP () {hbuf = Getcurrentbuf () if (hbuf!= 0) Setb Ufseltext (Hbuf, "P")} macro Altq () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "Q")} macro A LtR ()
{hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "R")} macro ALTs () {hbuf = Getcurrentbuf () i F (hbuf!= 0) setbufseltext (hbuf, "S")} macro Altt () {hbuf = Getcurrentbuf () if (hbuf!= 0) Setbufselte 
  XT (Hbuf, "T")} macro Altu () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "U")} macro Altv () { Hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "V")} macro Altw () {hbuf = Getcurrentbuf () if
      (hbuf!= 0) Setbufseltext (Hbuf, "W")} macro AltX () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "X")} mac Ro Alty () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, "Y")} macro Altz () {hbuf = GetCurrent
      Buf () if (hbuf!= 0) setbufseltext (hbuf, "Z")} macro Altunderline () {hbuf = Getcurrentbuf () if (hbuf!= 0) Setbufseltext (Hbuf, "_")} macro Altleftbracket () {hbuf = Getcurrentbuf () if (hbuf!= 0) Setbufseltext (h BUF, "(")
} Macro Altrightbracket () {hbuf = Getcurrentbuf () if (hbuf!= 0) setbufseltext (hbuf, ")"} macro Is_valid_comme NT (src) {srclen = strlen (src) tmp = 0 Index = 0 ch_ascii = 0 while (Index < Srclen) {ch_ascii = ASCIIFROMC
 		Har (Src[index])//is the ASCII value of ' * ' in source insight//are the ASCII value of '/' in Source insight
 				if (Ch_ascii = =) {tmp = index + 1 if (tmp < Srclen) {ch_ascii = Asciifromchar (src[tmp))
 			if (Ch_ascii = =) {return invalid}} return index} else if (Ch_ascii = 47) {
 					TMP = index + 1 if (tmp < Srclen) {ch_ascii = Asciifromchar (src[tmp]) if (Ch_ascii = 42) { return TMP}} else {return invalid}} else if (Ch_ascii!=) {return Inva Lid} index = index + 1} return invalid} macro Enterkeydown () {hwnd = Getcurrentwnd () Lnfirst = Getwndsel
   Lnfirst (HWND) Lnlast = Getwndsellnlast (hwnd) HBUF = Getcurrentbuf () tmpbuf = Getbufline (hbuf,lnfirst) index = 0 TMP = 1 Ins_buf = "" If (tmpbuf!= Nil) {index = is_valid_comment (TMPBUF) if (Index!= invalid  {if (index = = 0) {insbufline (hbuf, lnlast+1, "*")} else {while (tmp < index) {ins_buf = Cat (Ins_buf, "") TMP = tmp + 1} ins_buf = Cat (Ins_buf, "*"
    ) Insbufline (Hbuf, lnlast+1, Ins_buf)}} else {Insert_new_line}} else
    {Insert_new_line} Cursor_down End_of_line}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.