Author: fredkiefer
Date: Tue Aug 11 23:46:11 2015
New Revision: 38871

URL: http://svn.gna.org/viewcvs/gnustep?rev=38871&view=rev
Log:
        * Source/NSTextView.m: Rewrite
        writeSelectionToPasteboard:... methods.
        Based on patch by Adam Fox <[email protected]>

Modified:
    libs/gui/trunk/ChangeLog
    libs/gui/trunk/Source/NSTextView.m

Modified: libs/gui/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=38871&r1=38870&r2=38871&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog    (original)
+++ libs/gui/trunk/ChangeLog    Tue Aug 11 23:46:11 2015
@@ -1,3 +1,14 @@
+2015-08-11 Fred Kiefer <[email protected]>
+
+       * Source/NSTextView.m: Rewrite
+       writeSelectionToPasteboard:... methods.
+       Based on patch by Adam Fox <[email protected]>
+
+2015-07-26 Riccardo Mottola <[email protected]>
+
+       * Headers/AppKit/NSView.h,
+       * Source/NSView.m: Add alphaValue property.
+
 2015-07-24 Fred Kiefer <[email protected]>
 
        * Source/NSFont.m: Look for xib font property IBIsSystemFont.

Modified: libs/gui/trunk/Source/NSTextView.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSTextView.m?rev=38871&r1=38870&r2=38871&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSTextView.m  (original)
+++ libs/gui/trunk/Source/NSTextView.m  Tue Aug 11 23:46:11 2015
@@ -2546,7 +2546,7 @@
   NSPasteboard *pb = [NSPasteboard pasteboardWithName: NSFontPboard];
 
   [self writeSelectionToPasteboard: pb
-                             type: NSFontPboardType];
+                            types: [NSArray arrayWithObject: 
NSFontPboardType]];
 }
 
 /* Copy the current ruler settings to the ruler pasteboard */
@@ -2555,7 +2555,7 @@
   NSPasteboard *pb = [NSPasteboard pasteboardWithName: NSRulerPboard];
 
   [self writeSelectionToPasteboard: pb
-                             type: NSRulerPboardType];
+                            types: [NSArray arrayWithObject: 
NSRulerPboardType]];
 }
 
 
@@ -3171,21 +3171,36 @@
       if ([self isEditable])
        {
          NSArray *types = nil;
+          NSPasteboard *pb = nil;
          NSString *available;
 
          if (sel_isEqual(action, @selector(paste:)))
-           types = [self readablePasteboardTypes];
+            {
+              types = [self readablePasteboardTypes];
+              pb = [NSPasteboard generalPasteboard];
+            }
          else if (sel_isEqual(action, @selector(pasteAsPlainText:)))
-           types = [NSArray arrayWithObject: NSStringPboardType];
+            {
+              types = [NSArray arrayWithObject: NSStringPboardType];
+              pb = [NSPasteboard generalPasteboard];
+            }
          else if (sel_isEqual(action, @selector(pasteAsRichText:)))
-           types = [NSArray arrayWithObject: NSRTFPboardType];
+            {
+              types = [NSArray arrayWithObject: NSRTFPboardType];
+              pb = [NSPasteboard generalPasteboard];
+            }
          else if (sel_isEqual(action, @selector(pasteFont:)))
-           types = [NSArray arrayWithObject: NSFontPboardType];
+            {
+              types = [NSArray arrayWithObject: NSFontPboardType];
+              pb = [NSPasteboard pasteboardWithName: NSFontPboard];
+            }
          else if (sel_isEqual(action, @selector(pasteRuler:)))
-           types = [NSArray arrayWithObject: NSRulerPboard];
-
-         available = [[NSPasteboard generalPasteboard]
-                       availableTypeFromArray: types];
+            {
+              types = [NSArray arrayWithObject: NSRulerPboard];
+              pb = [NSPasteboard pasteboardWithName: NSRulerPboard];
+            }
+
+         available = [pb availableTypeFromArray: types];
          return available != nil;
        }
       else
@@ -5111,9 +5126,67 @@
 super's implementation of the method to handle any types of data your
 overridden version does not.
 */
-
-  return [self writeSelectionToPasteboard: pboard
-              types: [NSArray arrayWithObject: type]];
+  BOOL ret = NO;
+
+  if ([type isEqualToString: NSStringPboardType])
+    {
+      ret = [pboard setString: [[self string] substringWithRange: 
_layoutManager->_selected_range] 
+                      forType: NSStringPboardType] || ret;
+    }
+  else if ([type isEqualToString: NSRTFPboardType])
+    {
+      ret = [pboard setData: [self RTFFromRange: 
_layoutManager->_selected_range]
+                    forType: NSRTFPboardType] || ret;
+    }
+  else if ([type isEqualToString: NSRTFDPboardType])
+        {
+         ret = [pboard setData: [self RTFDFromRange: 
_layoutManager->_selected_range]
+                       forType: NSRTFDPboardType] || ret;
+       }
+  else if ([type isEqualToString: NSSmartPastePboardType] &&
+      [self selectionGranularity] == NSSelectByWord)
+    {
+      ret = [pboard setData: [NSData data]
+                       forType: NSSmartPastePboardType] || ret;
+    }
+  else if ([type isEqualToString: NSColorPboardType])
+    {
+      NSColor *color;
+      
+      color = [_textStorage attribute: NSForegroundColorAttributeName
+                              atIndex: _layoutManager->_selected_range.location
+                       effectiveRange: 0];
+      if (color != nil)
+        {
+          [color writeToPasteboard:  pboard];
+          ret = YES;
+        }
+    }
+  else if ([type isEqualToString: NSFontPboardType])
+    {
+      NSDictionary *dict;
+      
+      dict = [_textStorage fontAttributesInRange: 
_layoutManager->_selected_range];
+      if (dict != nil)
+        {
+          [pboard setData: [NSArchiver archivedDataWithRootObject: dict]
+                  forType: NSFontPboardType];
+          ret = YES;
+        }
+    }
+  else if ([type isEqualToString: NSRulerPboardType])
+    {
+      NSDictionary *dict;
+      
+      dict = [_textStorage rulerAttributesInRange: 
_layoutManager->_selected_range];
+      if (dict != nil)
+        {
+          [pboard setData: [NSArchiver archivedDataWithRootObject: dict]
+                     forType: NSRulerPboardType];
+          ret = YES;
+        }
+    }
+  return ret;
 }
 
 - (BOOL) writeSelectionToPasteboard: (NSPasteboard *)pboard
@@ -5146,70 +5219,10 @@
   enumerator = [types objectEnumerator];
   while ((type = [enumerator nextObject]) != nil)
     {
-      if ([type isEqualToString: NSStringPboardType])
+      if ([self writeSelectionToPasteboard: pboard type: type])
         {
-         ret = [pboard setString: [[self string] substringWithRange: 
_layoutManager->_selected_range] 
-                       forType: NSStringPboardType] || ret;
-       }
-
-      if ([type isEqualToString: NSRTFPboardType])
-        {
-         ret = [pboard setData: [self RTFFromRange: 
_layoutManager->_selected_range]
-                       forType: NSRTFPboardType] || ret;
-       }
-
-      if ([type isEqualToString: NSRTFDPboardType])
-        {
-         ret = [pboard setData: [self RTFDFromRange: 
_layoutManager->_selected_range]
-                       forType: NSRTFDPboardType] || ret;
-       }
-
-      if ([type isEqualToString: NSSmartPastePboardType] &&
-         [self selectionGranularity] == NSSelectByWord)
-       {
-         ret = [pboard setData: [NSData data]
-                       forType: NSSmartPastePboardType] || ret;
-       }
-
-      if ([type isEqualToString: NSColorPboardType])
-        {
-         NSColor       *color;
-
-         color = [_textStorage attribute: NSForegroundColorAttributeName
-                                 atIndex: 
_layoutManager->_selected_range.location
-                          effectiveRange: 0];
-         if (color != nil)
-           {
-             [color writeToPasteboard:  pboard];
-             ret = YES;
-           }
-       }
-
-      if ([type isEqualToString: NSFontPboardType])
-        {
-         NSDictionary  *dict;
-
-         dict = [_textStorage fontAttributesInRange: 
_layoutManager->_selected_range];
-         if (dict != nil)
-           {
-             [pboard setData: [NSArchiver archivedDataWithRootObject: dict]
-                     forType: NSFontPboardType];
-             ret = YES;
-           }
-       }
-
-      if ([type isEqualToString: NSRulerPboardType])
-        {
-         NSDictionary  *dict;
-
-         dict = [_textStorage rulerAttributesInRange: 
_layoutManager->_selected_range];
-         if (dict != nil)
-           {
-             [pboard setData: [NSArchiver archivedDataWithRootObject: dict]
-                     forType: NSRulerPboardType];
-             ret = YES;
-           }
-       }
+          ret = YES;
+        }
     }
 
   return ret;
@@ -6210,7 +6223,7 @@
 
   [self writeSelectionToPasteboard: 
             [NSPasteboard pasteboardWithName: @"Selection"]
-        type: NSStringPboardType];
+        types: [NSArray arrayWithObject: NSStringPboardType]];
 }
 
 /** Extension method that pastes the current selected text from the 


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to