aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-10-26 22:13:14 +0000
committercorvid <corvid@lavabit.com>2009-10-26 22:13:14 +0000
commit5fa02d927490d64d494eddfb6e0dfcd3332e7a74 (patch)
tree31a9a20f019bc8e40ae28afabc3f2d87a818aa5f /dw
parent30a0ec4bb4d3e79671154852780aa8b52f42f91d (diff)
use spaceStyle in Textblock::motionNotifyImpl when appropriate
Diffstat (limited to 'dw')
-rw-r--r--dw/textblock.cc12
-rw-r--r--dw/textblock.hh2
2 files changed, 10 insertions, 4 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 69239011..4c3fd5b6 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -522,10 +522,11 @@ bool Textblock::motionNotifyImpl (core::EventMotion *event)
if (event->state & core::BUTTON1_MASK)
return sendSelectionEvent (core::SelectionState::BUTTON_MOTION, event);
else {
+ bool inSpace;
int wordIndex, linkOld = hoverLink;
core::style::Tooltip *tooltipOld = hoverTooltip;
- wordIndex = findWord (event->xWidget, event->yWidget);
+ wordIndex = findWord (event->xWidget, event->yWidget, &inSpace);
// cursor from word or widget style
if (wordIndex == -1) {
@@ -533,7 +534,9 @@ bool Textblock::motionNotifyImpl (core::EventMotion *event)
hoverLink = -1;
hoverTooltip = NULL;
} else {
- core::style::Style *style = words->getRef(wordIndex)->style;
+ core::style::Style *style =
+ inSpace ? words->getRef(wordIndex)->spaceStyle :
+ words->getRef(wordIndex)->style;
setCursor (style->cursor);
hoverLink = style->x_link;
hoverTooltip = style->x_tooltip;
@@ -1469,13 +1472,15 @@ int Textblock::findLineOfWord (int wordIndex)
/**
* \brief Find the index of the word, or -1.
*/
-int Textblock::findWord (int x, int y)
+int Textblock::findWord (int x, int y, bool *inSpace)
{
int lineIndex, wordIndex;
int xCursor, lastXCursor, yWidgetBase;
Line *line;
Word *word;
+ *inSpace = false;
+
if ((lineIndex = findLineIndex (y)) >= lines->size ())
return -1;
line = lines->getRef (lineIndex);
@@ -1491,6 +1496,7 @@ int Textblock::findWord (int x, int y)
if (lastXCursor <= x && xCursor > x &&
y > yWidgetBase - word->size.ascent &&
y <= yWidgetBase + word->size.descent) {
+ *inSpace = x >= xCursor - word->effSpace;
return wordIndex;
}
}
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 94dffbac..159402ed 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -265,7 +265,7 @@ protected:
void drawLine (Line *line, core::View *view, core::Rectangle *area);
int findLineIndex (int y);
int findLineOfWord (int wordIndex);
- int findWord (int x, int y);
+ int findWord (int x, int y, bool *inSpace);
Word *addWord (int width, int ascent, int descent,
core::style::Style *style);