diff options
author | Sebastian Geerken <devnull@localhost> | 2014-09-26 14:24:17 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-09-26 14:24:17 +0200 |
commit | 482c58422d36425b3c60ea1a7655b342a5be1228 (patch) | |
tree | 11aebabf42875780f8bc09b7c3e44c2f65f9d4b6 | |
parent | a170867c7b7db49e0d52a51f7321b86348fa9ae7 (diff) |
RTFL.
-rw-r--r-- | dw/iterator.cc | 8 | ||||
-rw-r--r-- | dw/iterator.hh | 2 | ||||
-rw-r--r-- | dw/oofawarewidget.hh | 1 | ||||
-rw-r--r-- | dw/oofawarewidget_iterator.cc | 135 | ||||
-rw-r--r-- | dw/selection.cc | 102 | ||||
-rw-r--r-- | dw/textblock.cc | 15 | ||||
-rw-r--r-- | dw/textblock_iterator.cc | 30 | ||||
-rw-r--r-- | lout/debug.hh | 8 |
8 files changed, 209 insertions, 92 deletions
diff --git a/dw/iterator.cc b/dw/iterator.cc index 0edb580b..dbb779f6 100644 --- a/dw/iterator.cc +++ b/dw/iterator.cc @@ -204,14 +204,6 @@ void Iterator::scrollTo (Iterator *it1, Iterator *it2, int start, int end, } } - -void Iterator::print () -{ - misc::StringBuffer sb; - intoStringBuffer (&sb); - printf ("%s", sb.getChars ()); -} - // ------------------- // EmptyIterator // ------------------- diff --git a/dw/iterator.hh b/dw/iterator.hh index abf31d0b..9460adc4 100644 --- a/dw/iterator.hh +++ b/dw/iterator.hh @@ -86,8 +86,6 @@ public: static void scrollTo (Iterator *it1, Iterator *it2, int start, int end, HPosition hpos, VPosition vpos); - - virtual void print (); }; diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh index 81fafa10..f8c8e214 100644 --- a/dw/oofawarewidget.hh +++ b/dw/oofawarewidget.hh @@ -97,6 +97,7 @@ protected: OOFAwareWidgetIterator (OOFAwareWidget *widget, core::Content::Type mask, bool atEnd, int numContentsInFlow); + void intoStringBuffer(lout::misc::StringBuffer *sb); int compareTo(lout::object::Comparable *other); bool next (); diff --git a/dw/oofawarewidget_iterator.cc b/dw/oofawarewidget_iterator.cc index 74b3ea53..119222c9 100644 --- a/dw/oofawarewidget_iterator.cc +++ b/dw/oofawarewidget_iterator.cc @@ -95,6 +95,15 @@ void OOFAwareWidget::OOFAwareWidgetIterator::getPart (int sectionIndex, } } +void OOFAwareWidget::OOFAwareWidgetIterator::intoStringBuffer (StringBuffer *sb) +{ + Iterator::intoStringBuffer (sb); + sb->append (", sectionIndex = "); + sb->appendInt (sectionIndex); + sb->append (", index = "); + sb->appendInt (index); +} + int OOFAwareWidget::OOFAwareWidgetIterator::compareTo (Comparable *other) { OOFAwareWidgetIterator *otherTI = (OOFAwareWidgetIterator*)other; @@ -107,54 +116,108 @@ int OOFAwareWidget::OOFAwareWidgetIterator::compareTo (Comparable *other) bool OOFAwareWidget::OOFAwareWidgetIterator::next () { - if (content.type == Content::END) - return false; + DBG_OBJ_ENTER0_O ("iterator", 0, getWidget (), + "OOFAwareWidgetIterator/next"); + + DBG_IF_RTFL { + StringBuffer sb; + intoStringBuffer (&sb); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "initial value: %s", + sb.getChars ()); + } + + bool r; - do { - index++; + if (content.type == Content::END) + r = false; + else { + r = true; + bool cancel = false; - if (index >= numParts(sectionIndex)) { - sectionIndex++; - while (sectionIndex < NUM_SECTIONS && numParts (sectionIndex) == 0) + do { + index++; + + if (index >= numParts(sectionIndex)) { sectionIndex++; + while (sectionIndex < NUM_SECTIONS && numParts (sectionIndex) == 0) + sectionIndex++; - if (sectionIndex == NUM_SECTIONS) { - content.type = Content::END; - return false; - } else - index = 0; - } + if (sectionIndex == NUM_SECTIONS) { + content.type = Content::END; + r = false; + cancel = true; + } else + index = 0; + } + + getPart (sectionIndex, index, &content); + } while (!cancel && (content.type & getMask()) == 0); + } - getPart (sectionIndex, index, &content); - } while ((content.type & getMask()) == 0); + DBG_IF_RTFL { + StringBuffer sb; + intoStringBuffer (&sb); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "final value: %s", + sb.getChars ()); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "return value: %s", + r ? "true" : "false"); + } - return true; + DBG_OBJ_LEAVE_O (getWidget ()); + return r; } bool OOFAwareWidget::OOFAwareWidgetIterator::prev () { - if (content.type == Content::START) - return false; + DBG_OBJ_ENTER0_O ("iterator", 0, getWidget (), + "OOFAwareWidgetIterator/prev"); + + DBG_IF_RTFL { + StringBuffer sb; + intoStringBuffer (&sb); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "initial value: %s", + sb.getChars ()); + } - do { - index--; + bool r; - if (index < 0) { - sectionIndex--; - while (sectionIndex >= 0 && numParts (sectionIndex) == 0) + if (content.type == Content::START) + r = false; + else { + r = true; + bool cancel = false; + + do { + index--; + + if (index < 0) { sectionIndex--; + while (sectionIndex >= 0 && numParts (sectionIndex) == 0) + sectionIndex--; - if (sectionIndex < 0) { - content.type = Content::START; - return false; - } else - index = numParts (sectionIndex) - 1; - } - - getPart (sectionIndex, index, &content); - } while ((content.type & getMask()) == 0); + if (sectionIndex < 0) { + content.type = Content::START; + r = false; + cancel = true; + } else + index = numParts (sectionIndex) - 1; + } + + getPart (sectionIndex, index, &content); + } while (!cancel && (content.type & getMask()) == 0); + } + + DBG_IF_RTFL { + StringBuffer sb; + intoStringBuffer (&sb); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "final value: %s", + sb.getChars ()); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "return value: %s", + r ? "true" : "false"); + } - return true; + DBG_OBJ_LEAVE_O (getWidget ()); + return r; } void OOFAwareWidget::OOFAwareWidgetIterator::highlightOOF (int start, int end, @@ -181,12 +244,6 @@ void OOFAwareWidget::OOFAwareWidgetIterator::getAllocationOOF (int start, ->getWidget(index)->getAllocation()); } -void OOFAwareWidget::OOFAwareWidgetIterator::print () -{ - Iterator::print (); - printf (", sectionIndex = %d, index = %d", sectionIndex, index); -} - } // namespace oof } // namespace dw diff --git a/dw/selection.cc b/dw/selection.cc index b67f4a6d..a69eb82a 100644 --- a/dw/selection.cc +++ b/dw/selection.cc @@ -93,63 +93,79 @@ void SelectionState::resetLink () bool SelectionState::buttonPress (Iterator *it, int charPos, int linkNo, EventButton *event) { + DBG_IF_RTFL { + misc::StringBuffer sb; + it->intoStringBuffer (&sb); + DBG_OBJ_ENTER ("events", 0, "buttonPress", "[%s], %d, %d, ...", + sb.getChars (), charPos, linkNo); + } + Widget *itWidget = it->getWidget (); bool ret = false; - if (!event) return ret; - - if (event->button == 3) { - // menu popup - layout->emitLinkPress (itWidget, linkNo, -1, -1, -1, event); - ret = true; - } else if (linkNo != -1) { - // link handling - (void) layout->emitLinkPress (itWidget, linkNo, -1, -1, -1, event); - resetLink (); - linkState = LINK_PRESSED; - linkButton = event->button; - DeepIterator *newLink = new DeepIterator (it); - if (newLink->isEmpty ()) { - delete newLink; + if (event) { + if (event->button == 3) { + // menu popup + layout->emitLinkPress (itWidget, linkNo, -1, -1, -1, event); + ret = true; + } else if (linkNo != -1) { + // link handling + (void) layout->emitLinkPress (itWidget, linkNo, -1, -1, -1, event); resetLink (); - } else { - link = newLink; - // It may be that the user has pressed on something activatable - // (linkNo != -1), but there is no contents, e.g. with images - // without ALTernative text. - if (link) { - linkChar = correctCharPos (link, charPos); - linkNumber = linkNo; + linkState = LINK_PRESSED; + linkButton = event->button; + DeepIterator *newLink = new DeepIterator (it); + if (newLink->isEmpty ()) { + delete newLink; + resetLink (); + } else { + link = newLink; + // It may be that the user has pressed on something activatable + // (linkNo != -1), but there is no contents, e.g. with images + // without ALTernative text. + if (link) { + linkChar = correctCharPos (link, charPos); + linkNumber = linkNo; + } } - } - // We do not return the value of the signal method, - // but we do actually process this event. - ret = true; - } else if (event->button == 1) { - // normal selection handling - highlight (false, 0); - resetSelection (); - - selectionState = SELECTING; - DeepIterator *newFrom = new DeepIterator (it); - if (newFrom->isEmpty ()) { - delete newFrom; + // We do not return the value of the signal method, + // but we do actually process this event. + ret = true; + } else if (event->button == 1) { + // normal selection handling + highlight (false, 0); resetSelection (); - } else { - from = newFrom; - fromChar = correctCharPos (from, charPos); - to = from->cloneDeepIterator (); - toChar = correctCharPos (to, charPos); + + selectionState = SELECTING; + DeepIterator *newFrom = new DeepIterator (it); + if (newFrom->isEmpty ()) { + delete newFrom; + resetSelection (); + } else { + from = newFrom; + fromChar = correctCharPos (from, charPos); + to = from->cloneDeepIterator (); + toChar = correctCharPos (to, charPos); + } + ret = true; } - ret = true; } + DBG_OBJ_MSGF ("events", 1, "=> %s", ret ? "true" : "false"); + DBG_OBJ_LEAVE (); return ret; } bool SelectionState::buttonRelease (Iterator *it, int charPos, int linkNo, EventButton *event) { + DBG_IF_RTFL { + misc::StringBuffer sb; + it->intoStringBuffer (&sb); + DBG_OBJ_ENTER ("events", 0, "buttonRelease", "[%s], %d, %d, ...", + sb.getChars (), charPos, linkNo); + } + Widget *itWidget = it->getWidget (); bool ret = false; @@ -186,6 +202,8 @@ bool SelectionState::buttonRelease (Iterator *it, int charPos, int linkNo, } } + DBG_OBJ_MSGF ("events", 1, "=> %s", ret ? "true" : "false"); + DBG_OBJ_LEAVE (); return ret; } diff --git a/dw/textblock.cc b/dw/textblock.cc index eb412b3d..674c83b9 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -276,6 +276,11 @@ Textblock::Textblock (bool limitTextWidth) hlStart[layer].nChar = 0; hlEnd[layer].index = 0; hlEnd[layer].nChar = 0; + + DBG_OBJ_ARRATTRSET_NUM ("hlStart", layer, "index", hlStart[layer].index); + DBG_OBJ_ARRATTRSET_NUM ("hlStart", layer, "nChar", hlStart[layer].nChar); + DBG_OBJ_ARRATTRSET_NUM ("hlEnd", layer, "index", hlEnd[layer].index); + DBG_OBJ_ARRATTRSET_NUM ("hlEnd", layer, "nChar", hlEnd[layer].nChar); } initNewLine (); @@ -946,6 +951,8 @@ void Textblock::leaveNotifyImpl (core::EventCrossing *event) bool Textblock::sendSelectionEvent (core::SelectionState::EventType eventType, core::MousePositionEvent *event) { + DBG_OBJ_ENTER0 ("events", 0, "sendSelectionEvent"); + core::Iterator *it; int wordIndex; int charPos = 0, link = -1; @@ -1074,11 +1081,17 @@ bool Textblock::sendSelectionEvent (core::SelectionState::EventType eventType, } } } - + + DBG_OBJ_MSGF ("events", 1, "wordIndex = %d", wordIndex); + DBG_MSG_WORD ("events", 1, "<i>this is:</i> ", wordIndex, ""); + it = TextblockIterator::createWordIndexIterator (this, core::Content::maskForSelection (true), wordIndex); r = selectionHandleEvent (eventType, it, charPos, link, event); it->unref (); + + DBG_OBJ_MSGF ("events", 1, "=> %s", r ? "true" : "false"); + DBG_OBJ_LEAVE (); return r; } diff --git a/dw/textblock_iterator.cc b/dw/textblock_iterator.cc index 34a76c08..6eb8d9a3 100644 --- a/dw/textblock_iterator.cc +++ b/dw/textblock_iterator.cc @@ -60,6 +60,10 @@ void Textblock::TextblockIterator::highlight (int start, int end, core::HighlightLayer layer) { if (inFlow ()) { + DBG_OBJ_ENTER_O ("events", 0, getWidget (), "TextblockIterator/highlight", + "[in flow: %d], %d, %d, %d", getInFlowIndex (), + start, end, layer); + Textblock *textblock = (Textblock*)getWidget(); int index = getInFlowIndex (), index1 = index, index2 = index; @@ -86,11 +90,22 @@ void Textblock::TextblockIterator::highlight (int start, int end, textblock->hlEnd[layer].nChar = end; } + DBG_OBJ_ARRATTRSET_NUM_O (textblock, "hlStart", layer, "index", + textblock->hlStart[layer].index); + DBG_OBJ_ARRATTRSET_NUM_O (textblock, "hlStart", layer, "nChar", + textblock->hlStart[layer].nChar); + DBG_OBJ_ARRATTRSET_NUM_O (textblock, "hlEnd", layer, "index", + textblock->hlEnd[layer].index); + DBG_OBJ_ARRATTRSET_NUM_O (textblock, "hlEnd", layer, "nChar", + textblock->hlEnd[layer].nChar); + if (oldStartIndex != textblock->hlStart[layer].index || oldStartChar != textblock->hlStart[layer].nChar || oldEndIndex != textblock->hlEnd[layer].index || oldEndChar != textblock->hlEnd[layer].nChar) textblock->queueDrawRange (index1, index2); + + DBG_OBJ_LEAVE_O (getWidget ()); } else highlightOOF (start, end, layer); } @@ -99,6 +114,10 @@ void Textblock::TextblockIterator::unhighlight (int direction, core::HighlightLayer layer) { if (inFlow ()) { + DBG_OBJ_ENTER_O ("events", 0, getWidget (), + "TextblockIterator/unhighlight", "[in flow: %d], %d, %d", + getInFlowIndex (), direction, layer); + Textblock *textblock = (Textblock*)getWidget(); int index = getInFlowIndex (), index1 = index, index2 = index; @@ -125,11 +144,22 @@ void Textblock::TextblockIterator::unhighlight (int direction, textblock->hlEnd[layer].nChar = INT_MAX; } + DBG_OBJ_ARRATTRSET_NUM_O (textblock, "hlStart", layer, "index", + textblock->hlStart[layer].index); + DBG_OBJ_ARRATTRSET_NUM_O (textblock, "hlStart", layer, "nChar", + textblock->hlStart[layer].nChar); + DBG_OBJ_ARRATTRSET_NUM_O (textblock, "hlEnd", layer, "index", + textblock->hlEnd[layer].index); + DBG_OBJ_ARRATTRSET_NUM_O (textblock, "hlEnd", layer, "nChar", + textblock->hlEnd[layer].nChar); + if (oldStartIndex != textblock->hlStart[layer].index || oldStartChar != textblock->hlStart[layer].nChar || oldEndIndex != textblock->hlEnd[layer].index || oldEndChar != textblock->hlEnd[layer].nChar) textblock->queueDrawRange (index1, index2); + + DBG_OBJ_LEAVE_O (getWidget ()); } else unhighlightOOF (direction, layer); } diff --git a/lout/debug.hh b/lout/debug.hh index 896564cf..c4efbb9a 100644 --- a/lout/debug.hh +++ b/lout/debug.hh @@ -294,6 +294,13 @@ fflush (stdout); \ } D_STMT_END +#define DBG_OBJ_ARRATTRSET_NUM_O(obj, var, ind, attr, val) \ + D_STMT_START { \ + printf (RTFL_PREFIX_FMT "obj-set:%p:%s.%d.%s:%d\n", \ + RTFL_PREFIX_ARGS, obj, var, ind, attr, val); \ + fflush (stdout); \ + } D_STMT_END + #define DBG_OBJ_ARRATTRSET_SYM(var, ind, attr, val) \ D_STMT_START { \ printf (RTFL_PREFIX_FMT "obj-set:%p:%s.%d.%s:%s\n", \ @@ -367,6 +374,7 @@ #define DBG_OBJ_ARRSET_PTR(var, ind, val) D_STMT_NOP #define DBG_OBJ_ARRSET_BOOL(var, ind, val) D_STMT_NOP #define DBG_OBJ_ARRATTRSET_NUM(var, ind, attr, val) D_STMT_NOP +#define DBG_OBJ_ARRATTRSET_NUM_O(obj, var, ind, attr, val) D_STMT_NOP #define DBG_OBJ_ARRATTRSET_SYM(var, ind, attr, val) D_STMT_NOP #define DBG_OBJ_ARRATTRSET_STR(var, ind, attr, val) D_STMT_NOP #define DBG_OBJ_ARRATTRSET_PTR(var, ind, attr, val) D_STMT_NOP |