コード例 #1
0
def searchIndexedMain(sModeIn):
    if sModeIn=='impl': sMode = searchsipimpl.Searchmodes.SEARCH_IMPLS
    elif sModeIn=='defn': sMode = searchsipimpl.Searchmodes.SEARCH_DEFNS
    elif sModeIn=='all': sMode = searchsipimpl.Searchmodes.ALL_EXCEPT_COMMENTS
    else: assert False
    sPath = ScApp.GetFilePath()
    inidir = os.path.join(ScApp.GetSciteDirectory(), 'plugins', 'plugin_search')
    ininame = os.path.join(inidir, 'projects.cfg')
    ret = searchutil.getprojsection(ininame, sPath)
    if not ret:
        if not os.path.exists(ininame): f=open(ininame,'w'); f.write(' '); f.close()
        n = scmsg.getChoiceShowDialog('This file is not part of a project. Add it to a new project?', ['Yes', 'No'] )
        if n!=0: return
        pos1 = 0
        if n==0:
            folder, leaf = os.path.split(sPath)
            f=open(ininame,'a');
            pos1 = f.tell()
            print 'pos = ',pos1
            f.write('\n\n[project_new_%d]\nsrcdir1=%s\n\n'%(sum(map(ord, sPath)), folder))
            f.close()
        ScApp.OpenFile(ininame)
        if pos1: ScEditor.Select(pos1, pos1+20)
        return
    
    sProjname, sTxtCfg = ret
    sQuery = getQuery()
    searchutil.checkSupportedString(sQuery)
    sipname = os.path.join(inidir, 'db', 'ssip.exe')
    fcfg=open(os.path.join(inidir, 'db', 'ssip.cfg'), 'w')
    fcfg.write(sTxtCfg)
    assert 'dbpath=' not in sTxtCfg
    assert len(sProjname)>0 and '\n' not in sProjname
    fcfg.write('\ndbpath=%s\n'%os.path.join(inidir, 'db', sProjname+'.db'))
    fcfg.close()
    
    os.chdir(os.path.join(inidir, 'db')) # ssip.exe will see that config file
    rawtext = searchutil.runReturnStdout(sipname, ['-s', sQuery])
    results = searchsipimpl.filter(sMode, sQuery, rawtext)
    # todo: if there is only one result, consider opening it automatically
    searchsipimpl.displayResults(results)
コード例 #2
0
def main():
    import scmsg
    ssel = ScEditor.GetSelText()
    if not ssel: print 'no text selected.'; return
    sret = None
    
    n = scmsg.getChoiceShowDialog('Modify text:', 
        ['sort', 'reverse sort','combine lines','args on lines'] )
    if n==0:
        sret = sortLines(ssel, False)
    elif n==1:
        sret = sortLines(ssel, True)
    elif n==2:
        sret = combineLines(ssel)
    elif n==3:
        sret = putArgsOnDifferentLines(ssel)
    
    if sret:
        ScEditor.BeginUndoAction()
        ScEditor.Clear()
        ScEditor.InsertText(sret, ScEditor.GetCurrentPos())
        ScEditor.SetAnchor(ScEditor.GetCurrentPos() + len(sret))
        #don't use Write. we want it all selected
        ScEditor.EndUndoAction()