edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Christopher Brannon <chris@the-brannons.com>
To: edbrowse-dev@lists.the-brannons.com
Subject: [Edbrowse-dev] [PATCH] Unbrowse html email during reply.
Date: Wed, 13 Apr 2011 21:26:14 +0000	[thread overview]
Message-ID: <1302729974-23664-1-git-send-email-chris@the-brannons.com> (raw)

edbrowse's internal html representation needs to be stripped from the
message when replying.
(This is a rough draft.  I'm probably missing something.  Works for me.)
---
 src/buffers.c   |   26 ++++++++++++++++++++++++++
 src/eb.h        |    3 ++-
 src/eb.p        |    1 +
 src/fetchmail.c |    3 +++
 todo            |    4 ----
 5 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/src/buffers.c b/src/buffers.c
index b2149b3..8d0a464 100644
--- a/src/buffers.c
+++ b/src/buffers.c
@@ -3305,6 +3305,31 @@ balanceLine(const char *line)
     return false;
 }				/* balanceLine */
 
+/* Unbrowse a region.  Strip html tags. */
+bool
+unbrowseRange(int start, int end)
+{
+    int i;
+    const char *t = NULL;
+    int idx;
+    const char *map = sessionList[context].lw->map;
+
+    if(start < 0 || end < start || start > cw->dol || end > cw->dol) {
+	setError(MSG_BadRange);
+	return false;
+    }
+
+    for(i = start; i <= end; i++) {
+	pst newln = fetchLine(i, 1);
+	t = map + i * LNWIDTH;
+	idx = atoi(t);
+	nzFree(textLines[idx]);
+	textLines[idx] = newln;
+    }
+
+    return true;
+}				/* unbrowseRange */
+
 /* Unfold the buffer into one long, allocated string. */
 bool
 unfoldBuffer(int cx, bool cr, char **data, int *len)
@@ -4798,6 +4823,7 @@ browseCurrentBuffer(void)
 	    rawbuf = newbuf;
 	    rawsize = j;
 	    prepareForBrowse(rawbuf, rawsize);
+	    cw->htmlMailMode = true;
 	}
     }
 
diff --git a/src/eb.h b/src/eb.h
index 8345fd0..3e424d8 100644
--- a/src/eb.h
+++ b/src/eb.h
@@ -348,7 +348,8 @@ struct ebWindow {
 /* Two text modes; these are incompatible with binMode */
     bool utf8Mode;
     bool iso8859Mode;
-    bool browseMode;		/* browsing html */
+    bool browseMode;		/* browsing html or mail */
+    bool htmlMailMode;
     bool changeMode;		/* something has changed in this file */
     bool dirMode;		/* directory mode */
     bool firstOpMode;		/* first change has been made, undo is possible */
diff --git a/src/eb.p b/src/eb.p
index 0e3ebfb..620f677 100644
--- a/src/eb.p
+++ b/src/eb.p
@@ -32,6 +32,7 @@ void gotoLocation(char *url, int delay, bool rf) ;
 bool addTextToBuffer(const pst inbuf, int length, int destl, bool onside) ;
 void delText(int start, int end) ;
 bool readFile(const char *filename, const char *post) ;
+bool unbrowseRange(int first, int last) ;
 bool unfoldBuffer(int cx, bool cr, char **data, int *len) ;
 bool runCommand(const char *line) ;
 bool edbrowseCommand(const char *line, bool script) ;
diff --git a/src/fetchmail.c b/src/fetchmail.c
index 63c8d63..25606d7 100644
--- a/src/fetchmail.c
+++ b/src/fetchmail.c
@@ -2072,6 +2072,9 @@ setupReply(bool all)
 	memcpy(q2, swap, LNWIDTH);
     }
 
+    if(cw->htmlMailMode)
+	unbrowseRange(j + 1, cw->dol);
+
     if(!cw->mailInfo) {
 	cw->browseMode = false;
 	if(all) {
diff --git a/todo b/todo
index 8297d86..a7c16bd 100644
--- a/todo
+++ b/todo
@@ -77,10 +77,6 @@ This is bad htmo, but it happens.
 Are these methods not yet implemented?
 history.go history.back history.forward
 
-re on an html email leaves the internal codes in
-38{link0}  
-In other words it doesn't unbrowse.
-
 imap support.
 
 If edbrowse is started via an ebpager symlink, it should run in
-- 
1.7.3.4


                 reply	other threads:[~2011-04-13 21:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302729974-23664-1-git-send-email-chris@the-brannons.com \
    --to=chris@the-brannons.com \
    --cc=edbrowse-dev@lists.the-brannons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).