From 824cd84f321d358ab878b99cbaaef936823d8c8b Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Sat, 5 Jan 2013 11:48:21 +0100 Subject: Debug messages. --- dw/iterator.cc | 9 +++++++++ dw/iterator.hh | 2 ++ dw/textblock_linebreaking.cc | 24 +---------------------- dw/types.cc | 45 ++++++++++++++++++++++++++++++++++++++++++++ dw/types.hh | 2 ++ 5 files changed, 59 insertions(+), 23 deletions(-) diff --git a/dw/iterator.cc b/dw/iterator.cc index b6fde502..019d8e07 100644 --- a/dw/iterator.cc +++ b/dw/iterator.cc @@ -186,6 +186,15 @@ void Iterator::scrollTo (Iterator *it1, Iterator *it2, int start, int end, } } + +void Iterator::print () +{ + printf ("in the %s %p, mask ", widget->getClassName(), widget); + Content::printMask (mask); + printf (", pointing at "); + Content::print (&content); +} + // ------------------- // EmptyIterator // ------------------- diff --git a/dw/iterator.hh b/dw/iterator.hh index 222a05c0..12c3d4ac 100644 --- a/dw/iterator.hh +++ b/dw/iterator.hh @@ -85,6 +85,8 @@ public: static void scrollTo (Iterator *it1, Iterator *it2, int start, int end, HPosition hpos, VPosition vpos); + + void print (); }; diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 99552b3d..b8a10207 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -210,29 +210,7 @@ void Textblock::BadnessAndPenalty::print () void Textblock::printWordShort (Word *word) { - switch(word->content.type) { - case core::Content::TEXT: - printf ("\"%s\"", word->content.text); - break; - case core::Content::WIDGET_IN_FLOW: - printf ("", - word->content.widget, word->content.widget->getClassName()); - break; - case core::Content::WIDGET_OOF_REF: - printf ("", - word->content.widget, word->content.widget->getClassName()); - break; - case core::Content::WIDGET_OOF_CONT: - printf ("", - word->content.widget, word->content.widget->getClassName()); - break; - case core::Content::BREAK: - printf (""); - break; - default: - printf (""); - break; - } + core::Content::print (&(word->content)); } void Textblock::printWordFlags (short flags) diff --git a/dw/types.cc b/dw/types.cc index dc243ad7..4835f95b 100644 --- a/dw/types.cc +++ b/dw/types.cc @@ -276,5 +276,50 @@ Content::Type Content::maskForSelection (bool followReferences) return (Content::Type)(Content::SELECTION_CONTENT | widgetMask); } +void Content::print (Content *content) +{ + switch(content->type) { + case START: + printf (""); + break; + case END: + printf (""); + break; + case TEXT: + printf ("\"%s\"", content->text); + break; + case WIDGET_IN_FLOW: + printf ("", + content->widget, content->widget->getClassName()); + break; + case WIDGET_OOF_REF: + printf ("", + content->widget, content->widget->getClassName()); + break; + case WIDGET_OOF_CONT: + printf ("", + content->widget, content->widget->getClassName()); + break; + case BREAK: + printf (""); + break; + default: + printf (""); + break; + } +} + +void Content::printMask (Type mask) +{ + printf ("%s:%s:%s:%s:%s:%s:%s", + (mask & START) ? "st" : "--", + (mask & END) ? "en" : "--", + (mask & TEXT) ? "tx" : "--", + (mask & WIDGET_IN_FLOW) ? "wf" : "--", + (mask & WIDGET_OOF_REF) ? "Wr" : "--", + (mask & WIDGET_OOF_CONT) ? "Wc" : "--", + (mask & BREAK) ? "br" : "--"); +} + } // namespace dw } // namespace core diff --git a/dw/types.hh b/dw/types.hh index 514733a5..e933a98c 100644 --- a/dw/types.hh +++ b/dw/types.hh @@ -223,6 +223,8 @@ struct Content }; static Content::Type maskForSelection (bool followReferences); + static void print (Content *content); + static void printMask (Type mask); }; } // namespace dw -- cgit v1.2.3