Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!stadler From: stadler@Apple.COM (Andy Stadler) Newsgroups: comp.sys.mac.programmer Subject: Re: The Eternal Question Message-ID: <36956@apple.Apple.COM> Date: 2 Dec 89 22:44:33 GMT References: <11881@phoenix.Princeton.EDU> Organization: Apple Computer Inc, Cupertino, CA Lines: 65 In article <11881@phoenix.Princeton.EDU> bskendig@phoenix.Princeton.EDU (Brian Kendig) writes: > I have several documents that must be called up by the program. They > range in size from about 5k to 100k. The program must be able to call > text file of arbitrary length in a scrollable window - not just a text > field, but a window in its own right, with a vertical scroll bar. > Reading the text off disk instead of hardcoding it in the stack allows > me more flexibility. I think that I shouldn't have any problem > reading the file (correct me if I'm wrong, but can't variable > containers hold data of arbitrary length?). If I could pass the > container with the text in it to an XCMD that would then display it, > my problems would be solved. You might as well start using separate text files for the text right now. In my group here, we have a -bulletin board- system we use here every day, written with hypercard. And that's exactly how it works- every posting is a text file on a server, and the "news reader" has just 3 cards, a "new listings" card, a "read message" card, and a "write message" card. The reader card just opens a text file, reads it all in, and sticks it in the field. However, I don't think putting >32k into any container, even if it's not a field, is a good idea. If you want to do the file + xcmd route, I'd pass the file name to the xcmd and let it read the data. > First difficulty - how do I coerce TextEdit to show the more than 32k > and still allow for natural scrolling? (This is where the 'Eternal > Question' bit comes into play - I imagine that plenty of people have > asked this before!) If anyone has any code that would do this, or any > suggestions on the matter, believe me, I'm all ears. I know it's > possible - word processors do this kind of thing naturally. Nope. WP's don't use TextEdit. TE is not, and can't be modified to be, capable of > 32k of text. > Second difficulty - how can I determine what word was clicked on in > the text window? I achieve this right now with a lot of calculations > in HyperTalk for the text field, but I'm not sure how I'd go about it > in C. > Any help whatsoever (in the form of ideas or code) would be greatly > appreciated. Most of the hard part of writing textedit is SELECTING and CHANGING the text. You have described a read-only system. So my solution? Write your own read- only textedit. It's really quite easy!!! Just scan through the text, using the TextWidth() call, to calculate the number of characters to display on each line. Save all the line lengths in a big array, and just display 'em yourself with a scroll bar to determine which line to start with. In addition, since you will have all the info about which words are on each line and where, it will be easy to calculate word offsets for "active text". > Also, if you happen to come up with another idea of how > I could go about this whole business of displaying large amounts of > text, please do suggest them! A field with >32k of text is A LOT to read. I strongly suggest you look over the design, and the division of information. Maybe you're trying to put too much on one card. --Andy stadler@apple.com