PEG Markdown Highlight
|
Highlighter for an NSTextView. More...
#import <HGMarkdownHighlighter.h>
Public Member Functions | |
(id) | - initWithTextView: |
Init new instance while setting targetTextView. | |
(id) | - initWithTextView:waitInterval: |
Init new instance while setting targetTextView and waitInterval. | |
(id) | - initWithTextView:waitInterval:styles: |
Init new instance while setting targetTextView, waitInterval and styles. | |
(void) | - readClearTextStylesFromTextView |
Read and store the representation of "clear" text from the current state of the NSTextView. | |
(void) | - applyStylesFromStylesheet:withErrorDelegate:errorSelector: |
Parse stylesheet and apply the resulting styles. | |
(void) | - parseAndHighlightNow |
Manually invoke parsing and highlighting of the NSTextView contents. | |
(void) | - highlightNow |
Manually invoke highlighting (without parsing) of the NSTextView contents. | |
(void) | - clearHighlighting |
Clear highlighting from the NSTextView. | |
(void) | - activate |
Begin tracking changes in the NSTextView. | |
(void) | - deactivate |
Stop tracking changes in the NSTextView. | |
Properties | |
NSArray * | styles |
The order and styles for higlighting different elements. | |
HGMarkdownHighlightingStyle * | currentLineStyle |
The style for highlighting the current line. | |
NSTimeInterval | waitInterval |
The delay between editing text and it getting highlighted. | |
NSTextView * | targetTextView |
The NSTextView to highlight. | |
BOOL | parseAndHighlightAutomatically |
Whether to parse and highlight after each change. | |
BOOL | isActive |
Whether this highlighter is active. | |
BOOL | resetTypingAttributes |
Whether to reset typing attributes after highlighting. | |
BOOL | makeLinksClickable |
Whether add hyperlink property to links. | |
int | extensions |
The extensions to use for parsing. |
Highlighter for an NSTextView.
Given a reference to an NSTextView, handles the highlighting of its contents based on the Markdown syntax.
- (void) activate |
Begin tracking changes in the NSTextView.
Begin listening for scroll events in the NSTextView's enclosing scroll view and highlighting the visible range upon scrolling. If parseAndHighlightAutomatically is YES, this method will make the highlighter start listening for changes in the target NSTextView's contents.
- (void) applyStylesFromStylesheet: | (NSString *) | stylesheet | |
withErrorDelegate: | (id) | delegate | |
errorSelector: | (SEL) | selector | |
Parse stylesheet and apply the resulting styles.
[in] | stylesheet | The stylesheet string to parse |
[in] | delegate | Delegate object to handle stylesheet parsing errors |
[in] | selector | Selector to be invoked on the specified delegate object when errors occur in stylesheet parsing. The argument sent with the message is an NSArray containing error messages (NSStrings). |
- (void) clearHighlighting |
Clear highlighting from the NSTextView.
This method depends on the values stored by readClearTextStylesFromTextView.
- (void) deactivate |
Stop tracking changes in the NSTextView.
- (void) readClearTextStylesFromTextView |
Read and store the representation of "clear" text from the current state of the NSTextView.
Use this method to tell this highlighter what "clear" formatting should look like. The values stored by this method are used by clearHighlighting.
Note that if you provide the target NSTextView in the init method call, this method will be called automatically at that time.
- (HGMarkdownHighlightingStyle*) currentLineStyle [read, write, retain] |
The style for highlighting the current line.
The value of this property, if set, comes from stylesheets read by calling -applyStylesFromStylesheet:withErrorDelegate:selector:.
- (int) extensions [read, write, assign] |
- (BOOL) isActive [read, write, assign] |
Whether this highlighter is active.
- (BOOL) makeLinksClickable [read, write, assign] |
Whether add hyperlink property to links.
Whether to make all links clickable (i.e. make them behave like hyperlinks).
- (BOOL) parseAndHighlightAutomatically [read, write, assign] |
Whether to parse and highlight after each change.
Whether this highlighter will automatically parse and highlight the text whenever it changes, after a certain delay (determined by waitInterval).
- (BOOL) resetTypingAttributes [read, write, assign] |
Whether to reset typing attributes after highlighting.
Whether to reset the typing attributes of the NSTextView to its default styles after each time highlighting is performed.
This feature depends on the values stored by readClearTextStylesFromTextView.
- (NSArray*) styles [read, write, copy] |
The order and styles for higlighting different elements.
Values must be instances of HGMarkdownHighlightingStyle. The order of objects in this array determines the highlighting order for element types. You can use the helper macros defined in HGMarkdownHighlightingStyle.h to create the array (see the implementation of the private -getDefaultStyles method in this class for an example).