discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Announce GWorkspace-0.4pre1


From: Yen-Ju Chen
Subject: Re: Announce GWorkspace-0.4pre1
Date: Thu, 19 Sep 2002 12:59:39 -0400

Hi,

 After a quick try of GWorkspace-0.4pre1,
 I have some little comments.

 First is the Tools->Viewer and Windows->File Viewer looks confusing.
 I don't know what they are (different than content inspectors)
 and nothing happen when I click them (a txt file is selected).

 Second, it seems that the View submenu is handle by GW,
 and it behaves (redraws) a little bit weird
 when changing the view a lot (just keep select different view).

 Last, in the RtfViewer.m, it read a fixed number of
 characters from a file,
 which cause a problem for multibytes languages
 becuase one glyph (2 bytes) might be cut off by the fixed number,
 then the [[NSString alloc] initWithData: encoding:]
 will return nil becuase iconv can't work on the cut-off one.
 Below is a patch, and use a proper encoding.
 Just for reference.
 It just keeps reading until the conversion succeed.
 This method might have a very little side effect,
 but doesn't matter for a content inspector.

 Yen-Ju

*** RtfViewer.m.orig    Thu Sep 19 11:01:11 2002
--- RtfViewer.m Thu Sep 19 12:32:49 2002
***************
*** 28,34 ****
 #include "RtfViewer.h"
 #include "GNUstep.h"

! #define MAXDATA 3000

 @implementation RtfViewer

--- 28,34 ----
 #include "RtfViewer.h"
 #include "GNUstep.h"

! #define MAXDATA 1000

 @implementation RtfViewer

***************
*** 142,153 ****
fileAttributesAtPath: path traverseLink: YES];
     int nbytes = nbytes = [[dict objectForKey: NSFileSize] intValue];
NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath: path];

! data = [handle readDataOfLength: ((nbytes >= MAXDATA) ? MAXDATA : nbytes)];
!     [handle closeFile];

     s = [[NSString alloc] initWithData: data
!                               encoding: NSNonLossyASCIIStringEncoding];
     attrstr = [[NSAttributedString alloc] initWithString: s];
     RELEASE (s);
     AUTORELEASE (attrstr);
--- 142,160 ----
fileAttributesAtPath: path traverseLink: YES];
     int nbytes = nbytes = [[dict objectForKey: NSFileSize] intValue];
NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath: path];
+     int maxbytes = 0;
+     data = [NSMutableData new];

!     do {
!     maxbytes += MAXDATA;
!
! [(NSMutableData *)data appendData: [handle readDataOfLength: ((nbytes >= maxbytes) ? maxbytes : nbytes)]];

     s = [[NSString alloc] initWithData: data
! encoding: [NSString defaultCStringEncoding]];
!     } while ((s == nil) && (maxbytes < nbytes));
!     [handle closeFile];
!     RELEASE(data);
     attrstr = [[NSAttributedString alloc] initWithString: s];
     RELEASE (s);
     AUTORELEASE (attrstr);


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com





reply via email to

[Prev in Thread] Current Thread [Next in Thread]