changeset 36:420c3f6d5819

Added the DW2TB macro to plain.cc (same as in html.cc)
author jcid
date Mon, 05 Nov 2007 21:48:59 +0100
parents d9e7b35430de
children d0270b953f4d
files src/plain.cc
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/plain.cc	Mon Nov 05 21:25:14 2007 +0100
+++ b/src/plain.cc	Mon Nov 05 21:48:59 2007 +0100
@@ -31,6 +31,9 @@
 #include "dw/core.hh"
 #include "dw/textblock.hh"
 
+// Dw to Textblock
+#define DW2TB(dw)  ((Textblock*)dw)
+
 using namespace dw;
 using namespace dw::core;
 
@@ -85,7 +88,6 @@
  */
 DilloPlain::DilloPlain(BrowserWindow *p_bw, const DilloUrl *p_url)
 {
-   Textblock *textblock;
    style::StyleAttrs styleAttrs;
    style::FontAttrs fontAttrs;
 
@@ -95,8 +97,7 @@
    /* Init internal variables */
    bw = p_bw;
    url = a_Url_dup(p_url);
-   textblock = new Textblock (false);
-   dw = (Widget*) textblock;
+   dw = new Textblock (false);
    Start_Ofs = 0;
    state = ST_SeekingEol;
 
@@ -116,7 +117,7 @@
    widgetStyle = style::Style::create (layout, &styleAttrs);
 
    /* The context menu */
-   textblock->connectEvent (&plainReceiver);
+   DW2TB(dw)->connectEvent (&plainReceiver);
 
    /* Hook destructor to the dw delete call */
    dw->setDeleteCallback(a_Plain_free, this);
@@ -152,7 +153,6 @@
  */
 void DilloPlain::write(void *Buf, uint_t BufSize, int Eof)
 {
-   Textblock *textblock = (Textblock*)dw;
    char *Start;
    char *data;
    uint_t i, len, MaxBytes;
@@ -171,8 +171,8 @@
          break;
       case ST_Eol:
          data = dStrndup(Start + i - len, len);
-         textblock->addText(a_Misc_expand_tabs(data), widgetStyle);
-         textblock->addParbreak(0, widgetStyle);
+         DW2TB(dw)->addText(a_Misc_expand_tabs(data), widgetStyle);
+         DW2TB(dw)->addParbreak(0, widgetStyle);
          dFree(data);
          if (Start[i] == '\r' && Start[i + 1] == '\n') ++i;
          if (i < MaxBytes) ++i;
@@ -184,13 +184,13 @@
    Start_Ofs += i - len;
    if (Eof && len) {
       data = dStrndup(Start + i - len, len);
-      textblock->addText(a_Misc_expand_tabs(data), widgetStyle);
-      textblock->addParbreak(0, widgetStyle);
+      DW2TB(dw)->addText(a_Misc_expand_tabs(data), widgetStyle);
+      DW2TB(dw)->addParbreak(0, widgetStyle);
       dFree(data);
       Start_Ofs += len;
    }
 
-   textblock->flush();
+   DW2TB(dw)->flush();
 
    if (bw)
       a_UIcmd_set_page_prog(bw, Start_Ofs, 1);