[Chinese-commits] [fqterm] 20/76: rename downloadart.js to downloadart_ansi.js

Boyuan Yang hosiet-guest at moszumanska.debian.org
Thu Oct 27 03:16:58 UTC 2016


This is an automated email from the git hooks/post-receive script.

hosiet-guest pushed a commit to branch master
in repository fqterm.

commit 082f8edfa0f8178fa005cc28e1ec0e06fab74d10
Author: Iru Cai <mytbk920423 at gmail.com>
Date:   Thu May 8 01:51:07 2014 +0800

    rename downloadart.js to downloadart_ansi.js
---
 res/script/downloadart_ansi.js | 44 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/res/script/downloadart_ansi.js b/res/script/downloadart_ansi.js
new file mode 100644
index 0000000..8438a52
--- /dev/null
+++ b/res/script/downloadart_ansi.js
@@ -0,0 +1,44 @@
+fqterm.importFile("utils.js");
+
+// var saveFile = "/tmp/save.txt";
+var LastLine = 23;
+var timeout = 300;
+var retries = 5;
+// when the article is not completely read
+// there'll be a 'XX%' at the last line
+var r = new RegExp("%");
+var esc = new RegExp('\x1b\x1b','g');
+var content = "";
+
+getAnsiLine = function(i){
+    var line = fqterm.getAttrText(i).replace(esc, "\x1b[");
+    return line+"\n";
+}
+    
+// first copy the previous lines
+for (var i=0; i<LastLine; ++i){
+//    fqterm.appendFile(saveFile, getAnsiLine(i));
+    content += getAnsiLine(i);
+}
+
+// then copy until article ends
+while (1){
+    var line = fqterm.getText(LastLine);
+    if (!r.exec(line)){ // article ends
+        break;
+    }
+    var prev = getAnsiLine(LastLine-1);
+    var cur;
+    fqterm.sendString("j");
+    for (var i=0; i<retries; i++){
+        var cur = getAnsiLine(LastLine-1);
+        if (prev == cur){
+            sleep(timeout);
+        }
+    }
+//    fqterm.appendFile(saveFile, cur);
+    content += cur;
+}
+
+fqterm.artDialog(content);
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/chinese/fqterm.git



More information about the Chinese-commits mailing list