Add new X secondary selection behaviour.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26004 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2008-01-26 17:17:04 +00:00
parent fe86875d7e
commit 49399cb0c5
2 changed files with 67 additions and 4 deletions

View file

@ -1,3 +1,9 @@
2008-01-26 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTextView.m (-copySelection, -pasteSelection): Add new X
secondary selection behaviour.
See http://www.freedesktop.org/wiki/Specifications/ClipboardsWiki
2008-01-19 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSFontInfo.m:

View file

@ -5042,7 +5042,41 @@ configuation! */
special section pasteboard */
- (void) copySelection
{
[self writeSelectionToPasteboard: [NSPasteboard pasteboardWithName: @"Selection"]
#if 1
NSString *newSelection;
NSString *oldSelection;
NSRange range = _layoutManager->_selected_range;
if (range.location != NSNotFound && range.length != 0)
{
newSelection = [[self string] substringWithRange: range];
oldSelection = [[NSPasteboard pasteboardWithName: @"Selection"]
stringForType: NSStringPboardType];
if (oldSelection != nil &&
![newSelection isEqualToString: oldSelection])
{
NSPasteboard *secondary;
secondary = [NSPasteboard pasteboardWithName: @"Secondary"];
[secondary declareTypes: [NSArray arrayWithObject: NSStringPboardType]
owner: self];
[secondary setString: oldSelection
forType: NSStringPboardType];
}
else
{
return;
}
}
else
{
return;
}
#endif
[self writeSelectionToPasteboard:
[NSPasteboard pasteboardWithName: @"Selection"]
type: NSStringPboardType];
}
@ -5050,7 +5084,30 @@ configuation! */
special section pasteboard */
- (void) pasteSelection
{
[self readSelectionFromPasteboard: [NSPasteboard pasteboardWithName: @"Selection"]
#if 1
NSString *newSelection;
NSString *oldSelection;
NSRange range = _layoutManager->_selected_range;
if (range.location != NSNotFound && range.length != 0)
{
newSelection = [[self string] substringWithRange: range];
oldSelection = [[NSPasteboard pasteboardWithName: @"Selection"]
stringForType: NSStringPboardType];
if (oldSelection != nil &&
[newSelection isEqualToString: oldSelection])
{
[self readSelectionFromPasteboard:
[NSPasteboard pasteboardWithName: @"Secondary"]
type: NSStringPboardType];
return;
}
}
#endif
[self readSelectionFromPasteboard:
[NSPasteboard pasteboardWithName: @"Selection"]
type: NSStringPboardType];
}