Exemplo n.º 1
0
 def test_set_text(self):
     c = Clipboard()
     text = "test"
     c.set_text(text)
     self.assertTrue(c.has_text())
     self.assertEqual(c.get_text(), text)
     self.assertEqual(c.text, text)
Exemplo n.º 2
0
def select_string(include_quotes):
    mouse("left/3").execute()
    clipboard = Clipboard()
    saved_text = clipboard.get_system_text()
    clipboard.set_system_text('')
    left_counter = 0
    while left_counter < 50:
        key("s-left, c-c/3").execute()
        left_counter += 1
        if clipboard.get_system_text().startswith("\""):
            break

    key("left").execute()
    move_right = left_counter
    if not include_quotes:
        move_right -= 1
        key("right").execute()
    key("s-right:%s" % move_right).execute()

    right_counter = 0
    while right_counter < 50:
        key("s-right, c-c/3").execute()
        right_counter += 1
        if clipboard.get_system_text().endswith("\""):
            break

    if not include_quotes:
        key("s-left").execute()

    clipboard.set_text(saved_text)
    clipboard.copy_to_system()
Exemplo n.º 3
0
def get_selected_text():
    clipboard = Clipboard()
    previous = clipboard.get_system_text()
    clipboard.set_system_text("")
    Key("c-c/3").execute()
    selected = clipboard.get_system_text()
    clipboard.set_text(previous)
    clipboard.copy_to_system()
    return selected
Exemplo n.º 4
0
    def test_set_text(self):
        c = Clipboard()
        text = "test"
        c.set_text(text)
        self.assertTrue(c.has_text())
        self.assertEqual(c.get_text(), text)
        self.assertEqual(c.text, text)

        # Setting the text to None clears the stored text.
        c.set_text(None)
        self.assertFalse(c.has_text())
        self.assertIs(c.get_text(), None)
Exemplo n.º 5
0
    def test_get_text(self):
        # Test with an empty Clipboard instance.
        c = Clipboard()
        self.assertIsNone(c.get_text())

        # Test with Unicode text.
        text1 = u"test"
        c.set_text(text1)
        self.assertEqual(c.get_text(), text1)

        # Test with text set to None.
        c.set_text(None)
        self.assertIsNone(c.get_text())

        # Test with binary text.
        text2 = b"test"
        c.set_text(text2)
        self.assertEqual(c.get_text(), text2)
Exemplo n.º 6
0
    def test_get_text(self):
        # Test with an empty Clipboard instance.
        c = Clipboard()
        self.assertIsNone(c.get_text())

        # Test with Unicode text.
        text1 = u"test"
        c.set_text(text1)
        self.assertEqual(c.get_text(), text1)

        # Test with text set to None.
        c.set_text(None)
        self.assertIsNone(c.get_text())

        # Test with binary text.
        text2 = b"test"
        c.set_text(text2)
        self.assertEqual(c.get_text(), text2)

        # Test with format_hdrop.
        with NamedTemporaryFile() as f:
            c = Clipboard(contents={format_hdrop: f.name})
            self.assertIsNone(c.get_text())
Exemplo n.º 7
0
def _set_clipboard_text(text):
    """Sets the system clip board content."""
    clipboard = Clipboard()
    clipboard.set_text(text)  # Restore previous clipboard text.
    clipboard.copy_to_system()
Exemplo n.º 8
0
def _set_clipboard_text(text):
    """Sets the system clip board content."""
    clipboard = Clipboard()
    clipboard.set_text(text)  # Restore previous clipboard text.
    clipboard.copy_to_system()
Exemplo n.º 9
0
def set_clipboard(text):
    clipboard = Clipboard()
    clipboard.set_text(text)
    clipboard.copy_to_system()
Exemplo n.º 10
0
def write_to_shell(text):
    clipboard = Clipboard()
    clipboard.set_text(text)
    clipboard.copy_to_system()
    Mouse("right").execute()