コード例 #1
0
ファイル: bringme.py プロジェクト: seekM/caster
def bring_add(launch, key):
    '''
    Add current program or highlighted text to bring me
    '''
    key = str(key)
    if launch == "program":
        path = utilities.get_active_window_path()
        if not path:
            # dragonfly.get_engine().speak("program not detected")
            print("Program path for bring me not found ")
    # elif launch == 'file':
    # no way to add file via pyperclip
    else:
        Key("a-d/5").execute()
        fail, path = context.read_selected_without_altering_clipboard()
        if fail == 2:
            #FIXME
            time.sleep(0.1)
            _, path = context.read_selected_without_altering_clipboard()
            if not path:
                # dragonfly.get_engine().speak("nothing selected")
                print("Selection for bring me not found ")
        Key("escape").execute()
    if not path:
        #logger.warn('Cannot add %s as %s to bringme: cannot get path', launch, key)
        return
    CONFIG[launch][key] = path
    utilities.save_toml_file(CONFIG, settings.SETTINGS["paths"]["BRINGME_PATH"])
    refresh()
コード例 #2
0
ファイル: bringme.py プロジェクト: syfenx/Caster
def bring_add(launch, key):
    '''
    Add current program or highlighted text to bring me
    '''
    key = str(key)
    if launch == "program":
        path = utilities.get_active_window_path()
        if not path:
            # dragonfly.get_engine().speak("program not detected")
            print("Program path for bring me not found ")
    # elif launch == 'file':
    # no way to add file via pyperclip
    else:
        Key("a-d/5").execute()
        fail, path = context.read_selected_without_altering_clipboard()
        if fail == 2:
            #FIXME
            time.sleep(0.1)
            _, path = context.read_selected_without_altering_clipboard()
            if not path:
                # dragonfly.get_engine().speak("nothing selected")
                print("Selection for bring me not found ")
        Key("escape").execute()
    if not path:
        #logger.warn('Cannot add %s as %s to bringme: cannot get path', launch, key)
        return
    CONFIG[launch][key] = path
    utilities.save_toml_file(CONFIG,
                             settings.SETTINGS["paths"]["BRINGME_PATH"])
    refresh()
コード例 #3
0
def add_vocab():
    engine = dragonfly.get_engine()
    if engine.name != "natlink":
        utilities.report(
            "feature unavailable in your speech recognition engine",
            speak=True)
        return

    # attempts to get what was highlighted first
    highlighted = context.read_selected_without_altering_clipboard(True)

    # change the following regex to accept alphabetical only
    disallow = "^[A-Za-z]*$"
    selected = None

    if highlighted[0] == 0 and highlighted[1] != "":
        if not re.match(disallow, highlighted[1]):
            utilities.report("only used for single words", speak=True)
            return

        selected = highlighted[1]
    try:
        h_launch.launch(settings.QTYPE_SET, process_set, selected)
    except Exception:
        utilities.simple_log(False)
コード例 #4
0
ファイル: latex.py プロジェクト: mrob95/caster
def quote():
    e, text = context.read_selected_without_altering_clipboard(False)
    if text:
        Text("``" + text + "\'\'").execute()
    else:
        Text("``\'\'").execute()
        Key("left:2").execute()
コード例 #5
0
ファイル: recording.py プロジェクト: j127/caster
def get_chain_alias_spec():
    global MESSAGE_SPLITTER
    result=None
    copy_worked=False
    for i in range(0, 10):
        result=context.read_selected_without_altering_clipboard(True)
        if result[0]==0:
            copy_worked=True
            break
    if copy_worked==True:
        h_launch.launch(settings.QTYPE_INSTRUCTIONS, chain_alias, "Enter_spec_for_command|" + MESSAGE_SPLITTER.join(result[1].split()))
    else:
        utilities.report("copy failed") 
コード例 #6
0
ファイル: dev.py プロジェクト: carver7/caster
def grep_this(path, filetype):
    c = None
    tries=0
    while c is None:
        tries+=1
        results = context.read_selected_without_altering_clipboard()
        error_code = results[0]
        if error_code==0:
            c = results[1]
            break
        if tries>5:
            return False
    grep="D:/PROGRAMS/NON_install/AstroGrep/AstroGrep.exe"
    Popen([grep, "/spath=\""+str(path) +"\"", "/stypes=\""+str(filetype)+"\"", "/stext=\""+str(c)+"\"", "/s"])
コード例 #7
0
def enclose_selected(enclosure):
    ''' 
    Encloses selected text in the appropriate enclosures
    By using the system Clipboard as a buffer ( doesn't delete previous contents)
    '''

    (err, selected_text) = context.read_selected_without_altering_clipboard(True)
    if err == 0:
        opener = enclosure.split('~')[0]
        closer = enclosure.split('~')[1]
        enclosed_text = opener + selected_text + closer
        # Attempt to paste enclosed text without altering clipboard
        if not context.paste_string_without_altering_clipboard(enclosed_text):
            print("failed to paste {}".format(enclosed_text))
コード例 #8
0
ファイル: text_utils.py プロジェクト: seekM/caster
def enclose_selected(enclosure):
    ''' 
    Encloses selected text in the appropriate enclosures
    By using the system Clipboard as a buffer ( doesn't delete previous contents)
    '''

    (err, selected_text) = context.read_selected_without_altering_clipboard(True)
    if err == 0:
        opener = enclosure.split('~')[0]
        closer = enclosure.split('~')[1]
        enclosed_text = opener + selected_text + closer
        # Attempt to paste enclosed text without altering clipboard
        if not context.paste_string_without_altering_clipboard(enclosed_text):
            print("failed to paste {}".format(enclosed_text))
コード例 #9
0
ファイル: recording.py プロジェクト: gitter-badger/caster
def get_chain_alias_spec():
    global MESSAGE_SPLITTER
    result = None
    copy_worked = False
    for i in range(0, 10):
        result = context.read_selected_without_altering_clipboard(True)
        if result[0] == 0:
            copy_worked = True
            break
    if copy_worked == True:
        h_launch.launch(
            settings.QTYPE_INSTRUCTIONS, chain_alias,
            "Enter_spec_for_command|" +
            MESSAGE_SPLITTER.join(result[1].split()))
    else:
        utilities.report("copy failed")
コード例 #10
0
ファイル: dev.py プロジェクト: mrob95/caster
def grep_this(path, filetype):
    c = None
    tries = 0
    while c is None:
        tries += 1
        results = context.read_selected_without_altering_clipboard()
        error_code = results[0]
        if error_code == 0:
            c = results[1]
            break
        if tries > 5:
            return False
    grep = "D:/PROGRAMS/NON_install/AstroGrep/AstroGrep.exe"
    Popen([
        grep, "/spath=\"" + str(path) + "\"",
        "/stypes=\"" + str(filetype) + "\"", "/stext=\"" + str(c) + "\"", "/s"
    ])
コード例 #11
0
ファイル: vocabulary_processing.py プロジェクト: j127/caster
def add_vocab():
    engine=dragonfly.get_engine()
    if engine.name!="natlink":
        utilities.report("feature unavailable in your speech recognition engine", speak=True)
        return
    
    
    # attempts to get what was highlighted first
    highlighted=context.read_selected_without_altering_clipboard(True)
    
    # change the following regex to accept alphabetical only
    disallow="^[A-Za-z]*$"
    selected=None
    
    if highlighted[0]==0 and highlighted[1]!="":
        if not re.match(disallow, highlighted[1]):
            utilities.report("only used for single words", speak=True)
            return
        
        selected=highlighted[1]
    try: 
        h_launch.launch(settings.QTYPE_SET, process_set, selected)
    except Exception:
        utilities.simple_log(False)
コード例 #12
0
def read_highlighted(max_tries):
    for i in range(0, max_tries):
        result = context.read_selected_without_altering_clipboard(True)
        if result[0] == 0: return result[1]
    return None
コード例 #13
0
ファイル: testutils.py プロジェクト: Solar-Plexus/caster
def get_output():
    get_notepad()
    Key("c-a").execute()
    output = context.read_selected_without_altering_clipboard(True)[1]
    Key("backspace").execute()
    return output
コード例 #14
0
ファイル: alias.py プロジェクト: seekM/caster
def read_highlighted(max_tries):
    for i in range(0, max_tries):
        result = context.read_selected_without_altering_clipboard(True)
        if result[0] == 0: return result[1]
    return None
コード例 #15
0
def get_output():
    get_notepad()
    Key("c-a").execute()
    output = context.read_selected_without_altering_clipboard(True)[1]
    Key("backspace").execute()
    return output