summary refs log tree commit diff
path: root/mime/plaintext.py
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2023-01-14 09:07:07 -0500
committerZach DeCook <zachdecook@librem.one>2023-01-14 09:07:07 -0500
commit74c1b89b728d7d1013b714adf39737cd27e045f3 (patch)
treea86a3a6828831155b13de03b2c761510aee383ab /mime/plaintext.py
parentd236dd91d458035a455a4fa4f198aa1fb0e7fad9 (diff)
downloadbrowset-74c1b89b728d7d1013b714adf39737cd27e045f3.tar.gz
mime: Support plaintext format as well
Diffstat (limited to 'mime/plaintext.py')
-rw-r--r--mime/plaintext.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/mime/plaintext.py b/mime/plaintext.py
new file mode 100644
index 0000000..ff548e5
--- /dev/null
+++ b/mime/plaintext.py
@@ -0,0 +1,16 @@
+from textual.widgets import Static
+
+class Plaintext(Static):
+    """Plaintext widget."""
+
+    def __init__(self, fp, id):
+        super().__init__(id=id)
+        self.addlines(fp)
+
+    def addlines(self, fp):
+        for lin in fp:
+            line = lin
+            if type(line) is bytes:
+                line = line.decode("UTF-8")
+            line = line.rstrip("\r\n")
+            self.mount(Static(line, markup=False))