Пример #1
0
def replace(text):
    root = text._root()
    engine = SearchEngine.get(root)
    if not hasattr(engine, "_replacedialog"):
        engine._replacedialog = ReplaceDialog(root, engine)
    dialog = engine._replacedialog
    dialog.open(text)
Пример #2
0
 def do_replace(self):
     prog = self.engine.getprog()
     if not prog:
         return False
     text = self.text
     try:
         first = pos = text.index("sel.first")
         last = text.index("sel.last")
     except TclError:
         pos = None
     if not pos:
         first = last = pos = text.index("insert")
     line, col = SearchEngine.get_line_col(pos)
     chars = text.get("%d.0" % line, "%d.0" % (line+1))
     m = prog.match(chars, col)
     if not prog:
         return False
     new = self._replace_expand(m, self.replvar.get())
     if new is None:
         return False
     text.mark_set("insert", first)
     text.undo_block_start()
     if m.group():
         text.delete(first, last)
     if new:
         text.insert(first, new)
     text.undo_block_stop()
     self.show_hit(first, text.index("insert"))
     self.ok = 0
     return True
Пример #3
0
def grep(text, io=None, flist=None):
    root = text._root()
    engine = SearchEngine.get(root)
    if not hasattr(engine, "_grepdialog"):
        engine._grepdialog = GrepDialog(root, engine, flist)
    dialog = engine._grepdialog
    searchphrase = text.get("sel.first", "sel.last")
    dialog.open(text, searchphrase, io)
Пример #4
0
def grep(text, io=None, flist=None):
    root = text._root()
    engine = SearchEngine.get(root)
    if not hasattr(engine, "_grepdialog"):
        engine._grepdialog = GrepDialog(root, engine, flist)
    dialog = engine._grepdialog
    searchphrase = text.get("sel.first", "sel.last")
    dialog.open(text, searchphrase, io)
Пример #5
0
def _setup(text):
    root = text._root()
    engine = SearchEngine.get(root)
    if not hasattr(engine, "_searchdialog"):
        engine._searchdialog = SearchDialog(root, engine)
    return engine._searchdialog
Пример #6
0
from Search import SearchEngine
from Index import IndexBuilder

builder = IndexBuilder()
search = SearchEngine(builder.Index)
print(builder.Index)
docs = search.match("appl OR cherri OR banana")
print(docs)
Пример #7
0
def _setup(text):
    root = text._root()
    engine = SearchEngine.get(root)
    if not hasattr(engine, "_searchdialog"):
        engine._searchdialog = SearchDialog(root, engine)
    return engine._searchdialog