Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

[feature] Support join multi-lines #67

Closed
Freed-Wu opened this issue Jul 23, 2022 · 1 comment
Closed

[feature] Support join multi-lines #67

Freed-Wu opened this issue Jul 23, 2022 · 1 comment

Comments

@Freed-Wu
Copy link
Contributor

Freed-Wu commented Jul 23, 2022

--- /home/wzy/Desktop/ydcv.py	2022-07-23 21:36:39.586450097 +0800
+++ /usr/lib/python3.10/site-packages/ydcv.py	2022-07-23 22:51:26.334572339 +0800
@@ -344,6 +344,10 @@
                         action="store",
                         default="~/.ydcv_history.txt",
                         help="History file. Default: ~/.ydcv_history.txt")
+    parser.add_argument('--split',
+                        action="store_true",
+                        default=False,
+                        help="Split multi-lines input")
     parser.add_argument('words',
                         nargs='*',
                         help="words to lookup, or quoted sentences to translate.")
@@ -376,12 +380,16 @@
             readline.add_history(word)
     else:
         if options.selection:
-            last = check_output(["xclip", "-o"], universal_newlines=True)
+            last = check_output(["xsel", "-o"], universal_newlines=True)
+            if not options._options.split:
+                last = last.replace("-\n", "").replace("\n", ' ')
             print("Waiting for selection>")
             while True:
                 try:
                     sleep(0.1)
-                    curr = check_output(["xclip", "-o"], universal_newlines=True)
+                    curr = check_output(["xsel", "-o"], universal_newlines=True)
+                    if not options._options.split:
+                        curr = curr.replace("-\n", "").replace("\n", ' ')
                     if curr != last:
                         last = curr
                         if last.strip():
@@ -393,6 +401,8 @@
             while True:
                 try:
                     words = input('> ')
+                    if not options._options.split:
+                        words = words.replace("-\n", "").replace("\n", ' ')
                     if words.strip():
                         lookup_word(words)
                 except KeyboardInterrupt:

Screenshot from 2022-07-23 22-49-40

❯ ydcv --selection
Waiting for selection>
Some earlier results suggest that incorporating local normalization in linear block transform coding methods can improve coding performance
  Translation:
     * 一些早期的研究结果表明,在线性块变换编码方法中加入局部归一化可以提高编码性能
❯ ydcv --selection --split
Waiting for selection>
Some earlier results suggest
that incorporating local normalization in linear block transform coding methods can improve cod-
ing performance
  Translation:
     * 一些早期的结果表明
在线性分块变换编码方法中加入局部归一化可以提高编码质量
荷兰国际集团(ing)性能
@Freed-Wu
Copy link
Contributor Author

Freed-Wu commented Dec 3, 2022

I realize one alternative for myself. Close this issue.

@Freed-Wu Freed-Wu closed this as completed Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant