mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 06:10:59 +00:00
More selection fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8451 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d77897ddc3
commit
cfd2ee9935
3 changed files with 36 additions and 10 deletions
|
@ -3,10 +3,14 @@
|
||||||
* Source/NSAttributedString.m: ([-doubleClickAtIndex:]),
|
* Source/NSAttributedString.m: ([-doubleClickAtIndex:]),
|
||||||
Fixed infinite loop. Added code to cope with double click on the
|
Fixed infinite loop. Added code to cope with double click on the
|
||||||
space between words.
|
space between words.
|
||||||
|
* Source/GSSimpleLayoutManager.m: Implemented
|
||||||
|
([-glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:])
|
||||||
* Source/NSTextView.m: ([-selectionRangeForProposedRange:granularity])
|
* Source/NSTextView.m: ([-selectionRangeForProposedRange:granularity])
|
||||||
Re-implemented word selection using ([-doubleClickAtIndex:])
|
Re-implemented word selection using ([-doubleClickAtIndex:])
|
||||||
([-mouseDown:]) creatre proposed range for selection by merging old
|
([-mouseDown:]) creatre proposed range for selection by merging old
|
||||||
selectin range with new location.
|
selection range with new location.
|
||||||
|
Modified ([-characterIndexForPoint:]) to take into account where the
|
||||||
|
character/glyph was clicked on.
|
||||||
|
|
||||||
2000-12-24 Fred Kiefer <FredKiefer@gmx.de>
|
2000-12-24 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
|
|
@ -195,8 +195,9 @@ static NSCharacterSet *invSelectionWordGranularitySet;
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned)glyphIndexForPoint:(NSPoint)point
|
- (unsigned) glyphIndexForPoint: (NSPoint)point
|
||||||
inTextContainer:(NSTextContainer *)aTextContainer
|
inTextContainer: (NSTextContainer*)aTextContainer
|
||||||
|
fractionOfDistanceThroughGlyph: (float*)partialFraction
|
||||||
{
|
{
|
||||||
_GNULineLayoutInfo *currentInfo = [_lineLayoutInformation
|
_GNULineLayoutInfo *currentInfo = [_lineLayoutInformation
|
||||||
objectAtIndex:
|
objectAtIndex:
|
||||||
|
@ -211,12 +212,22 @@ static NSCharacterSet *invSelectionWordGranularitySet;
|
||||||
float fmax = NSMaxX(rect);
|
float fmax = NSMaxX(rect);
|
||||||
float w1, w2;
|
float w1, w2;
|
||||||
|
|
||||||
|
if (partialFraction != 0)
|
||||||
|
{
|
||||||
|
*partialFraction = 0.0;
|
||||||
|
}
|
||||||
if (x <= fmin)
|
if (x <= fmin)
|
||||||
|
{
|
||||||
return MAX(0, min - 1);
|
return MAX(0, min - 1);
|
||||||
|
}
|
||||||
if (x >= fmax)
|
if (x >= fmax)
|
||||||
|
{
|
||||||
return MAX(0, max);
|
return MAX(0, max);
|
||||||
|
}
|
||||||
if (range.length == 1)
|
if (range.length == 1)
|
||||||
|
{
|
||||||
return min;
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
// this should give a good starting index for binary search
|
// this should give a good starting index for binary search
|
||||||
i = (int)((max - min) * (x - fmin) / (fmax - fmin)) + min;
|
i = (int)((max - min) * (x - fmin) / (fmax - fmin)) + min;
|
||||||
|
@ -244,6 +255,10 @@ static NSCharacterSet *invSelectionWordGranularitySet;
|
||||||
i = (max + min) / 2;
|
i = (max + min) / 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (w1 > x)
|
||||||
|
{
|
||||||
|
*partialFraction = 1.0 - (w1 - x)/(w1 - w2);
|
||||||
|
}
|
||||||
return MAX(0, i-1);
|
return MAX(0, i-1);
|
||||||
}
|
}
|
||||||
return MAX(0, min - 1);
|
return MAX(0, min - 1);
|
||||||
|
|
|
@ -3114,12 +3114,19 @@ other than copy/paste or dragging. */
|
||||||
|
|
||||||
- (unsigned) characterIndexForPoint: (NSPoint) point
|
- (unsigned) characterIndexForPoint: (NSPoint) point
|
||||||
{
|
{
|
||||||
unsigned glyphIndex;
|
unsigned index;
|
||||||
|
float fraction;
|
||||||
|
|
||||||
glyphIndex = [_layoutManager glyphIndexForPoint: point
|
index = [_layoutManager glyphIndexForPoint: point
|
||||||
inTextContainer: _textContainer];
|
inTextContainer: _textContainer
|
||||||
|
fractionOfDistanceThroughGlyph: &fraction];
|
||||||
|
|
||||||
return [_layoutManager characterIndexForGlyphAtIndex: glyphIndex];
|
index = [_layoutManager characterIndexForGlyphAtIndex: index];
|
||||||
|
if (fraction > 0.5)
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect) rectForCharacterIndex: (unsigned)index
|
- (NSRect) rectForCharacterIndex: (unsigned)index
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue