home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-10-15 | 909 b | 50 lines | [TEXT/MMCC] |
- // *
- // * Wrap Tzu
- // * ©1994 Chris K. Thomas. All Rights Reserved.
- // *
- // * 100 15 Oct 94 ckt - new efficientized wrap
-
- #include "TzuTools.h"
- #include "TzuTextUtils.h"
-
- pascal void main(Handle text);
-
- const short leftMargin = 4;
- short rightMargin = 75;
-
- // * Main entry point
- // text - handle to text to be modified
- pascal void main(Handle text)
- {
- EnterCodeResource();
-
- long sizeOfText = GetHandleSize(text);
- Ptr localText = *text;
-
- for(long i=0; i<(sizeOfText-1); i++)
- {
- // set all whitespace and returns to space character
- if(localText[i] == '\r' || localText[i] == '\t')
- {
- localText[i]=' ';
- }
-
- // if we're on the margin
- if(i % rightMargin == 0)
- {
- // backtrack to find the first space
- // character before the margin
- short k = i+1;
- while(--k)
- {
- if(localText[k] == ' ')
- {
- localText[k] = '\r';
- break;
- }
- }
- }
- }
-
- ExitCodeResource();
- }