?? highlight.py
字號:
#single_maps[x[0][0]][x[0][1:2]][x[0]]=x
single_maps[x[0][0]][x[0]]=x
while(curpos < len(aimstr) ):
#print "curpos = " + str(curpos)
Matched = False
## try to find the block obj
for x in block_signs:
if aimstr[curpos:curpos+len(x[0])]==x[0] :
if isinstance(x[1],type('') ) :
endpos = aimstr.find(x[1],curpos+len(x[0]) )
if endpos < 0:
endpos = len(aimstr)
else:
mch=x[1].match( aimstr, curpos+len(x[0]))
if mch :
endpos = mch.end()
else:
endpos = len(aimstr)
x[2](aimstr[curpos:endpos])
curpos= endpos
Matched= True
break
## try to find the single obj
if not Matched :
maxlen=0
maxmatch=None
# Method 1
#if ( aimstr[curpos:curpos+1] in identified_header ):
# le=identified_sign[0].match(aimstr,curpos ).end()-curpos
#maxmatch=findmatch(aimstr, curpos, single_signs , True, le )
#if ( maxmatch ):
# maxlen= len(maxmatch[0])
#
# include Method2 as Methdo3
a0=aimstr[curpos:curpos+1]
if single_maps.has_key(a0):
mlist=single_maps[a0].values()
single_signs=mlist
# Method 2
for x in single_signs:
# this can be mo effectivly by search the single signs with 1/2 mehtod
if len(x[0])>maxlen and x[0].lower()==aimstr[curpos:curpos+len(x[0]) ].lower() :
if ( aimstr[curpos:curpos+1] in identified_header and aimstr[curpos+len(x[0]):curpos+len(x[0])+1] in identified ):
continue
maxlen=len(x[0])
maxmatch=x
for x in reg_signs:
matchobj=x[0].match(aimstr, curpos)
if matchobj and matchobj.end()-curpos > maxlen :
maxlen= matchobj.end()-curpos
maxmatch=x
if maxlen > 0 :
maxmatch[1](aimstr[curpos:curpos+maxlen])
curpos = curpos+maxlen
Matched = True
continue
## try to find next obj
if not Matched :
mch=identified_sign[0].match(aimstr,curpos ) or blank_sign[0].match(aimstr,curpos)
if mch :
#assert mch.end() > curpos
DEFAULT_ACTION(aimstr[curpos:mch.end()])
curpos=mch.end()
else :
DEFAULT_ACTION(aimstr[curpos:curpos+1])
curpos=curpos+1
if __name__=="__main__":
fp=file(__file__)
m=''
for x in fp.readlines():
m=m+x
print len(m)
HightLightString(m)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -