Turns out @menuat is completely unintrusive, if you don't count the new
@settings node type list entries. Here's the diff... shall I merge w.
trunk?

Cheers -Terry

36c36
<         'popup', # New in Leo 4.4.8.
---
>         'menuat', 'popup', # New in Leo 4.4.8.
78c78
< 
---
>             'menuat':       self.doMenuat,
429a430
>             g.es_print('Using menus from',c.shortFileName(),color='blue')
675a677,782
>     [EMAIL PROTECTED]:tbrown.20080514112857.124:doMenuat
>     def doMenuat (self,p,kind,name,val):
> 
>         if g.app.config.menusList:
>             g.es_print("Patching menu tree: " + name)
> 
>             # get the patch fragment
>             patch = []
>             if p.hasChildren():
>                 # 
> self.doMenus(p.copy().firstChild(),kind,name,val,storeIn=patch)
>                 self.doItems(p.copy(),patch)
>                 self.dumpMenuTree(patch)
> 
>             # setup        
>             parts = name.split()
>             if len(parts) != 3:
>                 parts.append('subtree')
>             targetPath,mode,source = parts
>             if not targetPath.startswith('/'): targetPath = '/'+targetPath
> 
>             ans = self.patchMenuTree(g.app.config.menusList, targetPath)
> 
>             if ans:
>                 g.es_print("Patching ("+mode+' '+source+") at "+targetPath)
> 
>                 list_, idx = ans
> 
>                 if mode not in ('copy', 'cut'):
>                     if source != 'clipboard':
>                         use = patch # [0][1]
>                     else:
>                         if isinstance(self.clipBoard, list):
>                             use = self.clipBoard
>                         else:
>                             use = [self.clipBoard]
>                     g.es_print(str(use))
>                 if mode == 'replace':
>                     list_[idx] = use.pop(0)
>                     while use:
>                         idx += 1
>                         list_.insert(idx, use.pop(0))
>                 elif mode == 'before':
>                     while use:
>                         list_.insert(idx, use.pop())
>                 elif mode == 'after':
>                     while use:
>                         list_.insert(idx+1, use.pop())
>                 elif mode == 'cut':
>                     self.clipBoard = list_[idx]
>                     del list_[idx]
>                 elif mode == 'copy':
>                     self.clipBoard = list_[idx]
>                     g.es_print(str(self.clipBoard))
>                 else:  # append
>                     list_.extend(use)
>             else:
>                 g.es_print("ERROR: didn't find menu path " + targetPath)
> 
>         else:
>             g.es_print("ERROR: @menuat found but no menu tree to patch")
>     [EMAIL PROTECTED]:tbrown.20080514180046.9:getName
>     def getName(self, val, val2=None):
>         if val2 and val2.strip(): val = val2
>         val = val.split('\n',1)[0]
>         for i in "*.-& \t\n":
>             val = val.replace(i,'')
>         return val.lower()
>     [EMAIL PROTECTED]
>     [EMAIL PROTECTED]:tbrown.20080514180046.9:getName
>     [EMAIL PROTECTED]:tbrown.20080514180046.2:dumpMenuTree
>     def dumpMenuTree (self,aList,level=0,path=''):
> 
>         for z in aList:
>             kind,val,val2 = z
>             if kind == '@item':
>                 name = self.getName(val, val2)
>                 g.es_print('%s %s (%s) [%s]' % ('    '*(level+0), val, val2, 
> path+'/'+name))
>             else:
>                 name = self.getName(kind.replace('@menu ',''))
>                 g.es_print('%s %s... [%s]' % ('    '*(level), kind, 
> path+'/'+name))
>                 self.dumpMenuTree(val,level+1,path=path+'/'+name)
>     [EMAIL PROTECTED]:tbrown.20080514180046.2:dumpMenuTree
>     [EMAIL PROTECTED]:tbrown.20080514180046.8:patchMenuTree
>     def patchMenuTree(self, orig, targetPath, path=''):
> 
>         for n,z in enumerate(orig):
>             kind,val,val2 = z
>             if kind == '@item':
>                 name = self.getName(val, val2)
>                 curPath = path+'/'+name
>                 if curPath == targetPath:
>                     g.es_print('Found '+targetPath)
>                     return orig, n
>             else:
>                 name = self.getName(kind.replace('@menu ',''))
>                 curPath = path+'/'+name
>                 if curPath == targetPath:
>                     g.es_print('Found '+targetPath)
>                     return orig, n
>                 ans = self.patchMenuTree(val, targetPath, path=path+'/'+name)
>                 if ans:
>                     return ans
> 
>         return None
>     [EMAIL PROTECTED]:tbrown.20080514180046.8:patchMenuTree
>     [EMAIL PROTECTED]:tbrown.20080514112857.124:doMenuat

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to