home *** CD-ROM | disk | FTP | other *** search
/ Openstep 4.2 (Developer) / Openstep Developer 4.2.iso / NextDeveloper / OpenStepConversion / IntermediateFrameworks1 / AppKit.framework / Headers / NSText.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-20  |  23.1 KB  |  718 lines

  1. /*
  2.     Text.h
  3.     Application Kit, Release 2.1J
  4.     Copyright (c) 1988, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. #ifndef TEXT_H
  8. #define TEXT_H
  9. #import "NSView.h"
  10. #import "chunk.h"
  11. #import "color.h"
  12. #import "NSFontManager.h"
  13. #import "readOnlyTextStream.h"
  14. #import "NSSpellChecker.h"
  15. #import "NXRTFDErrors.h"
  16.  
  17. #ifdef KANJI
  18. typedef wchar_t wchar;                // Basic character type
  19. #else KANJI
  20. typedef unsigned char wchar;            // Basic character type
  21. #endif KANJI
  22.  
  23. #define NSTextBlockSize 512
  24.  
  25. typedef struct _NXTextBlock {
  26.     struct _NXTextBlock *next;        /* next text block in link list */
  27.     struct _NXTextBlock *prior;        /* previous text block in link list */
  28.     struct _tbFlags {
  29.     unsigned int    malloced:1;    /* true if block was malloced */
  30.     unsigned int    PAD:15;
  31.     } tbFlags;
  32.     short           chars;        /* number of chars in this block */
  33.     wchar  *text;            /* the text */
  34. } NSTextBlock;
  35.  
  36. /*
  37.  *  NXRun represents a single run of text w/ a given format
  38.  */
  39.   
  40. typedef struct {
  41.     unsigned int underline:1;
  42.     unsigned int dummy:1;        /* unused */
  43.     unsigned int subclassWantsRTF:1;
  44.     unsigned int graphic:1;
  45.     unsigned int forcedSymbol:1;    /* did alt-char force use to use symbol */
  46.     unsigned int RESERVED:11;
  47. } NSRunFlags;
  48.  
  49. typedef struct _NXRun {
  50.     id              font;    /* Font id */
  51.     int             chars;    /* number of chars in run */
  52.     void           *paraStyle;    /* implementation dependent paraStyle
  53.                  * sheet info. */
  54.     float        textGray;    /* text gray of current run */
  55.     int            textRGBColor;    /* text color negative if not set */
  56.     unsigned char   superscript;/* superscript in points */
  57.     unsigned char   subscript;    /* subscript in points */
  58.     id          info;    /* available for subclasses of Text */
  59.     NSRunFlags rFlags;
  60. } NSRun;
  61.  
  62. /*
  63.  *  NXRunArray is a NXChunk that holds the set of formats for a Text object
  64.  */
  65.  
  66. typedef struct _NXRunArray {
  67.     NSTextChunk         chunk;
  68.     NSRun           runs[1];
  69. } NSRunArray;
  70.  
  71. /*
  72.  * NXBreakArray is a NXChunk that holds line break information for a Text
  73.  * Object. it is mostly an array of line descriptors.  each line
  74.  * descriptor contains 3 fields: 
  75.  *
  76.  *     1) line change bit (sign bit), set if this line defines a new height 
  77.  *     2) paragraph end bit (next to sign bit), set if the end of this 
  78.  *       line ends the paragraph 
  79.  *     3) numbers of characters in the line (low order 14 bits) 
  80.  *
  81.  * if the line change bit is set, the descriptor is the first field of a
  82.  * NXHeightChange. since this record is bracketed by negative short
  83.  * values, the breaks array can be sequentially accessed backwards and
  84.  * forwards. 
  85.  */
  86.  
  87. #if m68k
  88. typedef short NSLineDesc;
  89. #else
  90. typedef    int NSLineDesc;
  91. #endif
  92.  
  93. typedef struct _NXHeightInfo {
  94.     float         newHeight;    /* line height from here forward */
  95.     float         oldHeight;    /* height before change */
  96.     NSLineDesc      lineDesc;    /* line descriptor */
  97. } NSHeightInfo;
  98.  
  99. typedef struct _NXHeightChange {
  100.     NSLineDesc      lineDesc;    /* line descriptor */
  101.     NSHeightInfo    heightInfo;
  102. } NSHeightChange;
  103.  
  104. typedef struct _NXBreakArray {
  105.     NSTextChunk         chunk;
  106.     NSLineDesc      breaks[1];
  107. } NSBreakArray;
  108.  
  109. /*
  110.  * NXLay represents a single run of text in a line and records
  111.  * everything needed to select or draw that piece.
  112.  */
  113.  
  114. typedef struct {
  115.     unsigned int mustMove:1;    /* unimplemented */
  116.     unsigned int isMoveChar:1;
  117.     unsigned int RESERVED:14;
  118. } NSLayFlags;
  119.  
  120. typedef struct _NXLay {
  121.     float         x;        /* x coordinate of moveto */
  122.     float         y;        /* y coordinate of moveto */
  123.     short           offset;    /* offset in line array for text */
  124.     short           chars;    /* number of characters in lay */
  125.     id              font;    /* font id */
  126.     void           *paraStyle;    /* implementation dependent fontStyle
  127.                  * sheet info. */
  128.     NSRun *run;            /* run for lay */
  129.     NSLayFlags        lFlags;
  130. } NSLay;
  131.  
  132. /*
  133.  *  NXLayArray is a NXChunk that holds the layout for the current line
  134.  */
  135.  
  136. typedef struct _NXLayArray {
  137.     NSTextChunk         chunk;
  138.     NSLay           lays[1];
  139. } NSLayArray;
  140.  
  141. /*
  142.  *  NXWidthArray is a NXChunk that holds the widths for the current line
  143.  */
  144.  
  145. typedef struct _NXWidthArray {
  146.     NSTextChunk         chunk;
  147.     float         widths[1];
  148. } NSWidthArray;
  149.  
  150. /*
  151.  *  NXCharArray is a NXChunk that holds the chars for the current line
  152.  */
  153.  
  154. typedef struct _NXCharArray {
  155.     NSTextChunk         chunk;
  156.     wchar       text[1];
  157. } NSCharArray;
  158.  
  159. /*
  160.  *  Word definition Finite State Machine transition struct
  161.  */
  162. typedef struct _NXFSM {
  163.     const struct _NXFSM  *next;    /* state to go to, NULL implies final state */
  164.     short           delta;    /* if final state, this undoes lookahead */
  165.     short           token;    /* if final state, < 0 word is newline,
  166.                  * = is dark, > is white space */
  167. } NSFSM;
  168.  
  169. /*
  170.  *  Represents one end of a selection
  171.  */
  172.  
  173. typedef struct _NXSelPt {
  174.     int             cp;        /* character position */
  175.     int             line;    /* offset of LineDesc in break table */
  176.     float         x;        /* x coordinate */
  177.     float         y;        /* y coordinate */
  178.     int             c1st;    /* character position of first character
  179.                  * on the line */
  180.     float         ht;        /* line height */
  181. } NSSelPt;
  182.  
  183. /*
  184.  *  describes tabstop
  185.  */
  186.  
  187. typedef struct _NXTabStop {
  188.     short           kind;    /* only NX_LEFTTAB implemented*/
  189.     float         x;        /* x coordinate for stop */
  190. } NSTabStop;
  191.  
  192. typedef struct _NXTextCache {
  193.     int curPos;            /* current position in text stream */
  194.     NSRun *curRun;        /* cache current block of text and */
  195.     int runFirstPos;        /* character pos that corresponds */
  196.     NSTextBlock *curBlock;    /* cache current block of text and */
  197.     int blockFirstPos;        /* character pos that corresponds */
  198. } NSTextCache;
  199.  
  200. typedef struct _NXLayInfo {
  201.     NSRect rect;        /* bounds rect for current line. */
  202.     float descent;        /* descent for current line, can be reset
  203.                  * by scanFunc */
  204.     float width;        /* width of line */
  205.     float left;        /* left side visible coordinate */
  206.     float right;        /* right side visible coordinate */
  207.     float rightIndent;    /* how much white space is left at right
  208.                  * side of line */
  209.     NSLayArray *lays;        /* scanFunc fills with NXLay items */
  210.     NSWidthArray *widths;    /* scanFunc fills with character widths */
  211.     NSCharArray *chars;        /* scanFunc fills with characters */
  212.     NSTextCache cache;        /* cache of current block & run */
  213.     NSRect *textClipRect;    /* if non-nil, the current clip for drawing */
  214.     struct _lFlags {
  215.     unsigned int horizCanGrow:1;/* 1 if scanFunc should perform dynamic
  216.                  * growing of x margins */
  217.     unsigned int vertCanGrow:1;/* 1 if scanFunc should perform dynamic
  218.                  * growing of y margins */
  219.     unsigned int erase:1;    /* used to tell drawFunc to erase before
  220.                  * drawing line  */
  221.     unsigned int ping:1;    /* used to tell drawFunc to ping server */
  222.     unsigned int endsParagraph:1;/* true if line ends the paragraph, eg
  223.                  * ends in newline */
  224.     unsigned int resetCache:1;/* used in scanFunc to reset local caches */
  225.     unsigned int RESERVED:10;
  226.     } lFlags;
  227. } NSLayInfo;
  228.  
  229. /*
  230.  *  Gives a paragraph fontStyle
  231.  */
  232.  
  233. typedef struct _NXTextStyle {
  234.     float         indent1st;    /* how far first line in paragraph is
  235.                  * indented */
  236.     float         indent2nd;    /* how far second line is indented */
  237.     float         lineHt;    /* line height */
  238.     float         descentLine;/* distance to ascent line from bottom of
  239.                  * line */
  240.     short           alignment;    /* justification */
  241.     short           numTabs;    /* number of tab stops */
  242.     NSTabStop      *tabs;    /* array of tab stops */
  243. } NSTextStyle;
  244.  
  245. typedef enum _NSTextAlignment {
  246.     NSLeftTextAlignment        = 0, /* Visually left aligned */
  247.     NSRightTextAlignment    = 1, /* Visually right aligned */
  248.     NSCenterTextAlignment    = 2,
  249.     NSJustifiedTextAlignment    = 3,
  250.     NSNaturalTextAlignment    = 4  /* Indicates the default alignment for script */
  251. } NSTextAlignment;
  252.  
  253. /* tab stop fontStyles */
  254.  
  255. #define NSLefttabKey 0
  256.  
  257. #define NSBackspaceKey  8
  258. #define NSCarriageReturnKey 13
  259. #define NSDeleteKey ((unsigned short)0x7F)
  260. #define NSBacktabKey 25
  261.  
  262. /* movement codes for movement between fields */
  263.  
  264. #define NSIllegalTextMovement     0
  265. #define NSReturnTextMovement     ((unsigned short)0x10)
  266. #define NSTabTextMovement         ((unsigned short)0x11)
  267. #define NSBacktabTextMovement     ((unsigned short)0x12)
  268. #define NSLeftTextMovement     ((unsigned short)0x13)
  269. #define NSRightTextMovement     ((unsigned short)0x14)
  270. #define NSUpTextMovement         ((unsigned short)0x15)
  271. #define NSDownTextMovement     ((unsigned short)0x16)
  272.  
  273. typedef enum {
  274.     NSLeftAlignedParagraph = NSLeftTextAlignment,
  275.     NSRightAlignedParagraph = NSRightTextAlignment,
  276.     NSCenterAlignedParagraph = NSCenterTextAlignment,
  277.     NSJustificationAlignedParagraph = NSJustifiedTextAlignment,
  278.     NSFirstIndentParagraph,
  279.     NSIndentParagraph,
  280.     NSAddTabParagraph,
  281.     NSRemoveTabParagraph,
  282.     NSLeftMarginParagraph,
  283.     NSRightMarginParagraph
  284. } NSParagraphProperty;
  285.  
  286.  
  287. /* 
  288.     Word tables for various languages.  The SmartLeft and SmartRight arrays
  289.     are suitable as arguments for the messages setPreSelSmartTable: and
  290.     setPostSelSmartTable.  When doing a paste, if the character to the left
  291.     (right) of the new word is not in the left (right) table, an extra space
  292.     is added on that side.  The CharCats tables define the character classes
  293.     used in the word wrap or click tables.  The BreakTables are finite state
  294.     machines that determine word wrapping.  The ClickTables are finite state
  295.     machines that determine which characters are selected when the user
  296.     double clicks.
  297. */
  298.  
  299. extern const unsigned char * const NSEnglishSmartLeftChars;
  300. extern const unsigned char * const NSEnglishSmartRightChars;
  301. extern const unsigned char * const NSEnglishCharCatTable;
  302. extern const NSFSM * const NSEnglishBreakTable;
  303. extern const int NSEnglishBreakTableSize;
  304. extern const NSFSM * const NSEnglishNoBreakTable;
  305. extern const int NSEnglishNoBreakTableSize;
  306. extern const NSFSM * const NSEnglishClickTable;
  307. extern const int NSEnglishClickTableSize;
  308.  
  309. extern const unsigned char * const NSCSmartLeftChars;
  310. extern const unsigned char * const NSCSmartRightChars;
  311. extern const unsigned char * const NSCCharCatTable;
  312. extern const NSFSM * const NSCBreakTable;
  313. extern const int NSCBreakTableSize;
  314. extern const NSFSM * const NSCClickTable;
  315. extern const int NSCClickTableSize;
  316.  
  317. typedef int (*NSTextFunc) (id self, NSLayInfo *layInfo);
  318. typedef unsigned short (*NSCharFilterFunc) (
  319.     unsigned short charCode, int flags, unsigned short charSet);
  320. typedef char  *(*NSTextFilterFunc) (
  321.     id self, unsigned char * insertText, int *insertLength, int position);
  322. #ifdef KANJI
  323. typedef BOOL (*NXclickFunc) ( id self, int clickPos, NSSelPt * left, NSSelPt * right ) ;
  324. #endif
  325.  
  326. @interface NSText : NSView <NXReadOnlyTextStream, NXSelectText, NXChangeSpelling, NXIgnoreMisspelledWords>
  327. {
  328.     const NSFSM        *breakTable;
  329.     const NSFSM        *clickTable;
  330.     const unsigned char *preSelSmartTable;
  331.     const unsigned char *postSelSmartTable;
  332.     const unsigned char *charCategoryTable;
  333.     char                delegateMethods;
  334.     NSCharFilterFunc    charFilterFunc;
  335.     NSTextFilterFunc    textFilterFunc;
  336.     char               *_compilerErrorSpacer;
  337.     NSTextFunc          scanFunc;
  338.     NSTextFunc          drawFunc;
  339.     id                  delegate;
  340.     int                 tag;
  341.     DPSTimedEntry       cursorTE;
  342.     NSTextBlock        *firstTextBlock;
  343.     NSTextBlock        *lastTextBlock;
  344.     NSRunArray         *theRuns;
  345.     NSRun               typingRun;
  346.     NSBreakArray       *theBreaks;
  347.     int                 growLine;
  348.     int                 textLength;
  349.     float             maxY;
  350.     float             maxX;
  351.     NSRect              bodyRect;
  352.     float             borderWidth;
  353.     char                clickCount;
  354.     NSSelPt             sp0;
  355.     NSSelPt             spN;
  356.     NSSelPt             anchorL;
  357.     NSSelPt             anchorR;
  358.     float               backgroundGray;
  359.     float               textGray;
  360.     float               selectionGray;
  361.     NSSize              maxSize;
  362.     NSSize              minSize;
  363.     struct _tFlags {
  364. #ifdef __BIG_ENDIAN__
  365.     unsigned int        _editMode:2;
  366.     unsigned int        _selectMode:2;
  367.     unsigned int        _caretState:2;
  368.     unsigned int        changeState:1;
  369.     unsigned int        charWrap:1;
  370.     unsigned int        haveDown:1;
  371.     unsigned int        anchorIs0:1;
  372.     unsigned int        horizResizable:1;
  373.     unsigned int        vertResizable:1;
  374.     unsigned int        overstrikeDiacriticals:1;
  375.     unsigned int        monoFont:1;
  376.     unsigned int        disableFontPanel:1;
  377.     unsigned int        inClipView:1;
  378. #else
  379.     unsigned int        inClipView:1;
  380.     unsigned int        disableFontPanel:1;
  381.     unsigned int        monoFont:1;
  382.     unsigned int        overstrikeDiacriticals:1;
  383.     unsigned int        vertResizable:1;
  384.     unsigned int        horizResizable:1;
  385.     unsigned int        anchorIs0:1;
  386.     unsigned int        haveDown:1;
  387.     unsigned int        charWrap:1;
  388.     unsigned int        changeState:1;
  389.     unsigned int        _caretState:2;
  390.     unsigned int        _selectMode:2;
  391.     unsigned int        _editMode:2;
  392. #endif
  393.     }                   tFlags;
  394.     void               *_info;
  395.     NXStream           *textStream;
  396.     unsigned int        _reservedText1;
  397.     unsigned int        _reservedText2;
  398. }
  399.  
  400. + initialize;
  401. + excludeFromServicesMenu:(BOOL)flag;
  402. + getDefaultFont;
  403. + setDefaultFont:anObject;
  404.  
  405. - initFrame:(NSRect)frameRect text:(NSString *)theText alignment:(NSTextAlignment)mode;
  406. - initFrame:(NSRect)frameRect;
  407. - (void)dealloc;
  408. - renewRuns:(NSRunArray *)newRuns text:(NSString *)newText frame:(NSRect)newFrame tag:(int)newTag;
  409. - renewFont:newFontId text:(NSString *)newText frame:(NSRect)newFrame tag:(int)newTag;
  410. - renewFont:(NSString *)newFontName size:(float)newFontSize style:(int)newFontStyle text:(NSString *)newText frame:(NSRect)newFrame tag:(int)newTag;
  411. - setEditable:(BOOL)flag;
  412. - (BOOL)isEditable;
  413. - adjustPageHeightNew:(float *)newBottom top:(float)oldTop bottom:(float)oldBottom limit:(float)bottomLimit;
  414. - (NSRect)paragraphRect:(int)prNumber start:(int *)startPos end:(int *)endPos;
  415. - (int)textLength;
  416. - (int)byteLength;
  417. - (int)getSubstring:(char *)buf start:(int)startPos length:(int)numChars;
  418. - setText:(NSString *)aString;
  419. - readText:(NXStream *)stream;
  420. - readRichText:(NXStream *)stream;
  421. - writeText:(NXStream *)stream;
  422. - writeRichText:(NXStream *)stream;
  423. - writeRichText:(NXStream *)stream from:(int)start to:(int)end;
  424. - setCharFilter:(NSCharFilterFunc)aFunc;
  425. - (NSCharFilterFunc)charFilter;
  426. - setTextFilter:(NSTextFilterFunc)aFunc;
  427. - (NSTextFilterFunc)textFilter;
  428. - (const unsigned char *)preSelSmartTable;
  429. - setPreSelSmartTable:(const unsigned char *)aTable;
  430. - (const unsigned char *)postSelSmartTable;
  431. - setPostSelSmartTable:(const unsigned char *)aTable;
  432. - (const unsigned char *)charCategoryTable;
  433. - setCharCategoryTable:(const unsigned char *)aTable;
  434. - (const NSFSM *)breakTable;
  435. - setBreakTable:(const NSFSM *)aTable;
  436. - (const NSFSM *)clickTable;
  437. - setClickTable:(const NSFSM *)aTable;
  438. - setTag:(int)anInt;
  439. - (int)tag;
  440. - setDelegate:anObject;
  441. - delegate;
  442. - setBackgroundGray:(float)value;
  443. - (float)backgroundGray;
  444. - setBackgroundColor:(NXColor)color;
  445. - (NXColor)backgroundColor;
  446. - setTextGray:(float)value;
  447. - setTextColor:(NXColor)color;
  448. - (float)textGray;
  449. - (NXColor)textColor;
  450. - (float)selGray;
  451. - (float)runGray: (NSRun *)run;
  452. - (NXColor)runColor: (NSRun *)run;
  453. - (NXColor)selColor;
  454. - windowChanged:newWindow;
  455. - (NXStream *)stream;
  456. - write:(NXTypedStream *)stream;
  457. - read:(NXTypedStream *)stream;
  458. - readRichText:(NXStream *)stream atPosition:(int)position;
  459. - finishReadingRichText;
  460. - startReadingRichText;
  461. - setRetainedWhileDrawing:(BOOL)aFlag;
  462. - (BOOL) isRetainedWhileDrawing;
  463. #ifndef KANJI
  464. - (NSTextBlock *)firstTextBlock;
  465. - setScanFunc:(NSTextFunc)aFunc;
  466. - (NSTextFunc)scanFunc;
  467. - setDrawFunc:(NSTextFunc)aFunc;
  468. - (NSTextFunc)drawFunc;
  469. #endif
  470.  
  471. - (int)offsetFromPosition: (int)charPos;
  472. - (int)positionFromOffset:(int)offset;
  473. - (int)charLength;
  474.  
  475. #ifdef KANJI
  476. - setClickFunc: (NXclickFunc) clickFunc ;
  477. - (NXclickFunc) clickFunc ;
  478. - (NXStream *) wstream ;
  479. - disableStream ;
  480. #endif
  481.  
  482. /*
  483.  * These methods are now obsolete.  The NeXTstep encoding supports diacritical
  484.  * marks directly (and these methods were never implemented anyway).
  485.  */
  486. - setOverstrikeDiacriticals:(BOOL)flag;
  487. - (int)overstrikeDiacriticals;
  488.  
  489. /*
  490.  * This method is now obsolete.
  491.  * Use writeRichText: and writeRichText:from:to:.
  492.  */
  493. - writeRichText:(NXStream *)stream forRun:(NSRun *)run atPosition:(int)runPosition emitDefaultRichText:(BOOL *)writeDefaultRTF;
  494.  
  495. @end
  496.  
  497. @interface NSText(FrameRect)
  498. - (NSSize)maxSize;
  499. - (NSSize)minSize;
  500. - (BOOL)isHorizResizable;
  501. - (BOOL)isVertResizable;
  502. - setFrameOrigin:(NSPoint)_newOrigin;
  503. - resizeText:(NSRect)oldBounds :(NSRect)maxRect;
  504. - setMaxSize:(NSSize)newMaxSize;
  505. - setMinSize:(NSSize)newMinSize;
  506. - setHorizResizable:(BOOL)flag;
  507. - setVertResizable:(BOOL)flag;
  508. - setFrameSize:(NSSize)_newSize;
  509. - sizeToFit;
  510. @end
  511.  
  512. @interface NSText(Layout)
  513. - (NSTextAlignment)alignment;
  514. - (int)calcLine;
  515. - (void *)calcParagraphStyle:fontId:(int)alignment;
  516. - (BOOL)charWrap;
  517. - (float)descentLine;
  518. - getMarginLeft:(float *)leftMargin right:(float *)rightMargin top:(float *)topMargin bottom:(float *)bottomMargin;
  519. - getMinWidth:(float *)width minHeight:(float *)height maxWidth:(float)widthMax maxHeight:(float)heightMax;
  520. - (void *)defaultParaStyle;
  521. - (float)lineHeight;
  522. - setAlignment:(NSTextAlignment)mode;
  523. - setCharWrap:(BOOL)flag;
  524. - setDescentLine:(float)value;
  525. - setLineHeight:(float)value;
  526. - setMarginLeft:(float)leftMargin right:(float)rightMargin top:(float)topMargin bottom:(float)bottomMargin;
  527. - setNoWrap;
  528. - setParaStyle:(void *)paraStyle;
  529. @end
  530.  
  531. @interface NSText(LinePosition)
  532. - (int)lineFromPosition:(int)position;
  533. - (int)positionFromLine:(int)line;
  534. @end
  535.  
  536. @interface NSText(Drawing)
  537. - drawRect:(NSRect)rect;
  538. @end
  539.  
  540. @interface NSText(Event)
  541. - (BOOL)acceptsFirstResponder;
  542. - becomeFirstResponder;
  543. - becomeKeyWindow;
  544. - clear:sender;
  545. - copy:sender;
  546. - cut:sender;
  547. - delete:sender;
  548. - keyDown:(NXEvent *)theEvent;
  549. - mouseDown:(NXEvent *)theEvent;
  550. - moveCaret:(unsigned short)theKey;
  551. - paste:sender;
  552. - pasteRuler:sender;
  553. - pasteFont:sender;
  554. - resignFirstResponder;
  555. - resignKeyWindow;
  556. - selectAll:sender;
  557. - selectText:sender;
  558. - copyRuler:sender;
  559. - copyFont:sender;
  560. @end
  561.  
  562. @interface NSText(Ruler)
  563. - toggleRuler:sender;
  564. -(BOOL)isRulerVisible;
  565. @end
  566.  
  567. @interface NSText(Selection)
  568. - getSel:(NSSelPt *)start :(NSSelPt *)end;
  569. - hideCaret;
  570. - (BOOL)isSelectable;
  571. - replaceSel:(NSString *)aString;
  572. - replaceSel:(NSString *)aString length:(int)length;
  573. - replaceSel:(NSString *)aString length:(int)length runs:(NSRunArray *)insertRuns;
  574. - replaceSelWithRichText:(NXStream *)stream;
  575. - scrollSelToVisible;
  576. - selectError;
  577. - selectNull;
  578. - setSel:(int)start :(int)end;
  579. - setSelectable:(BOOL)flag;
  580. - setSelGray:(float)value;
  581. - setSelColor:(NXColor) color;
  582. - showCaret;
  583. - subscript:sender;
  584. - superscript:sender;
  585. - underline:sender;
  586. - unscript:sender;
  587. - validRequestorForSendType:(NSString *)sendType andReturnType:(NSString *)returnType;
  588. - readSelectionFromPasteboard:pboard;
  589. - (BOOL)writeSelectionToPasteboard:pboard types:(NSArray *)types;
  590. @end
  591.  
  592. @interface NSText(NSFont)
  593. - changeFont:sender;
  594. - font;
  595. - (BOOL)isFontPanelEnabled;
  596. - (BOOL)isMonoFont;
  597. - setFont:fontObj;
  598. - setFont:fontObj paraStyle:(void *)paraStyle;
  599. - setSelFontFamily:(NSString *)fontName;
  600. - setSelFontSize:(float)size;
  601. - setSelFontStyle:(NSFontTraitMask)traits;
  602. - setSelFont:fontId;
  603. - setSelFont:fontId paraStyle:(void *)paraStyle;
  604. - setFontPanelEnabled:(BOOL)flag;
  605. - setMonoFont:(BOOL)flag;
  606. - changeTabStopAt:(float)oldX to:(float)newX;
  607. - setSelProp:(NSParagraphProperty)prop to:(float)val;
  608. - alignSelLeft:sender;
  609. - alignSelRight:sender;
  610. - alignSelCenter:sender;
  611. @end
  612.  
  613. @interface NSText(SpellChecking)
  614. - showGuessPanel:sender;
  615. - checkSpelling:sender;
  616. @end
  617.  
  618. @interface NSText(Graphics)
  619. - replaceSelWithCell:cell;
  620. - replaceSelWithView:view;
  621. - (NSPoint)locationOfCell:cell;
  622. - setLocation:(NSPoint)origin ofCell:cell;
  623. - (NSPoint)locationOfView:view;
  624. + registerDirective:(NSString *)directive forClass:class;
  625. @end
  626.  
  627. @interface NSText(Find)
  628. - (BOOL)findText:(NSString *)textPattern ignoreCase:(BOOL) ignoreCase backwards:(BOOL) backwards wrap:(BOOL) wrap;
  629. @end
  630.  
  631. @interface NSText (RTFD)
  632. - (NSRTFDError)saveRTFDTo:(NSString *)path removeBackup:(BOOL)removeBackup errorHandler:errorHandler;
  633. - (NSRTFDError)openRTFDFrom:(NSString *)path;
  634. - writeRTFDTo:(NXStream *)stream;
  635. - readRTFDFrom:(NXStream *)stream;
  636. - writeRTFDSelectionTo:(NXStream *)stream;
  637. - replaceSelWithRTFD:(NXStream *)stream;
  638. - setGraphicsImportEnabled:(BOOL) flag;
  639. - (BOOL) isGraphicsImportEnabled;
  640.  
  641. @end
  642.  
  643. @interface NSObject(TextDelegate)
  644. - textWillResize:textObject;
  645. - (NSRect)textDidResize:textObject oldBounds:(NSRect)oldBounds;
  646. - (BOOL)textWillChange:textObject;
  647. - textDidChange:textObject;
  648. - (BOOL)textWillEnd:textObject;
  649. - textDidEnd:textObject endChar:(unsigned short)whyEnd;
  650. - textDidGetKeys:textObject isEmpty:(BOOL)flag;
  651. - textWillSetSel:textObject toFont:font;
  652. - textWillConvert:textObject fromFont:from toFont:to;
  653. - textWillStartReadingRichText:textObject;
  654. - textWillFinishReadingRichText:textObject;
  655. - (NSSize)textWillWrite:textObject;
  656. - textDidRead:textObject paperSize:(NSSize)paperSize;
  657.  
  658. /* The following delegate methods are obsolete and should not be used. */
  659.  
  660. - textWillWriteRichText:textObject stream:(NXStream *)stream forRun:(NSRun *)run atPosition:(int)runPosition emitDefaultRichText:(BOOL *)writeDefaultRichText;
  661. - textWillReadRichText:textObject stream:(NXStream *)stream atPosition:(int)runPosition;
  662. - textPath:(char *)path forText:textObject maxLength:(int)maxLength;
  663.  
  664. @end
  665.  
  666. @interface NSObject(TextCell)
  667. /*
  668.  * Any object added to the Text object via replaceSelWithCell: must
  669.  * respond to all of the following messages:
  670.  */
  671. - highlight:(NSRect)cellFrame inView:controlView lit:(BOOL)flag;
  672. - drawSelf:(NSRect)cellFrame inView:controlView;
  673. - (BOOL)trackMouse:(NXEvent *)theEvent inRect:(NSRect)cellFrame ofView:controlView untilMouseUp:(BOOL)untilMouseUp;
  674. - (NSSize)cellSize;
  675. - readRichText:(NXStream *)stream forView:view;
  676. - writeRichText:(NXStream *)stream forView:view;
  677. @end
  678.  
  679.  
  680. extern void NSTextFontInfo(
  681.     id fid, float *ascender, float *descender, float *lineHt);
  682. extern int NSScanALine(id self, NSLayInfo *layInfo);
  683. extern int NSDrawALine(id self, NSLayInfo *layInfo);
  684. extern unsigned short NSFieldFilter(
  685.     unsigned short theChar, int flags, unsigned short charSet);
  686. extern unsigned short NSEditorFilter(
  687.     unsigned short theChar, int flags, unsigned short charSet);
  688. extern void NSSetTextCache(id self, NSTextCache *cache, int pos);
  689. extern int NSAdjustTextCache(id self, NSTextCache *cache, int pos);
  690. extern void NSFlushTextCache(id self, NSTextCache *cache);
  691. extern void NXWriteWordTable(NXStream *st, const unsigned char *smartLeft,
  692.         const unsigned char *smartRight,
  693.         const unsigned char *charClasses,
  694.         const NSFSM *wrapBreaks, int wrapBreaksCount,
  695.         const NSFSM *clickBreaks, int clickBreaksCount, BOOL charWrap);
  696. extern void NSReadWordTable(NSZone *zone, NXStream *st,
  697.         unsigned char **smartLeft, unsigned char **smartRight,
  698.         unsigned char **charClasses,
  699.         NSFSM **wrapBreaks, int *wrapBreaksCount,
  700.         NSFSM **clickBreaks, int *clickBreaksCount,
  701.         BOOL *charWrap);
  702. #ifdef KANJI
  703. extern BOOL NSClick ( id self, int clickPos, NSSelPt * left, NSSelPt * right );
  704. #endif
  705.  
  706. typedef struct {
  707.     unsigned char primary[256];
  708.     unsigned char secondary[256];
  709.     unsigned char primaryCI[256];
  710.     unsigned char secondaryCI[256];
  711. } NXStringOrderTable;
  712.  
  713. extern int NSOrderStrings(const unsigned char *s1, const unsigned char *s2, BOOL caseSensitive, int length, NXStringOrderTable *table);
  714. extern NXStringOrderTable *NSDefaultStringOrderTable(void);
  715.  
  716. #endif TEXT_H
  717.  
  718.