Beispiel #1
0
def quote():
    text = utilities.read_selected(False)
    if text:
        Text("``" + text + "\'\'").execute()
    else:
        Text("``\'\'").execute()
        Key("left:2").execute()
Beispiel #2
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)
    '''
    selected_text = utilities.read_selected(True)
    if selected_text:
        opener = enclosure.split('~')[0]
        closer = enclosure.split('~')[1]
        enclosed_text = opener + selected_text + closer
        # Attempt to paste enclosed text without altering clipboard
        if not utilities.paste_string(enclosed_text):
            print("failed to paste {}".format(enclosed_text))
Beispiel #3
0
def begin_end(environment):
    text = utilities.read_selected(False)
    if type(environment) in [str, unicode]:
        env, arg = environment, ""
    elif type(environment) in [tuple, list]:
        env, arg = environment[0], environment[1]
    back_curl("begin", env)
    Text(arg + "\n").execute()
    if text:
        utilities.paste_string(text)
    Key("enter").execute()
    back_curl("end", env)
    if not text:
        Key("up").execute()
Beispiel #4
0
 def _execute(self, data=None):
     orig = utilities.read_selected(self.same_is_okay)
     text = orig.replace(" ", self.space) if orig else ""
     control.nexus().temp = text.replace("\n",
                                         "") if self.remove_cr else text
     return True
Beispiel #5
0
def word_count_from_string():
    raw = utilities.read_selected(True)
    raw_line_list = raw.split("\n")
    sentence_list = word_counter.extract_sentences(raw_line_list)
    words_list = word_counter.extract_words(sentence_list)
    utilities.toast_notify("Word count:", str(len(words_list)))
Beispiel #6
0
 def alias(self, spec):
     spec = str(spec)
     e, text = utilities.read_selected(True)
     if spec and text:
         self.refresh(spec, str(text))