diff options
| -rw-r--r-- | basicctrls_darwin.m | 54 | ||||
| -rw-r--r-- | common_darwin.m | 3 | ||||
| -rw-r--r-- | control_darwin.m | 2 | ||||
| -rw-r--r-- | objc_darwin.h | 3 |
4 files changed, 61 insertions, 1 deletions
diff --git a/basicctrls_darwin.m b/basicctrls_darwin.m index e0e5f75..c4b90c6 100644 --- a/basicctrls_darwin.m +++ b/basicctrls_darwin.m @@ -9,6 +9,7 @@ #define toNSView(x) ((NSView *) (x)) #define toNSWindow(x) ((NSWindow *) (x)) #define toNSBox(x) ((NSBox *) (x)) +#define toNSTextView(x) ((NSTextView *) (x)) @interface goControlDelegate : NSObject <NSTextFieldDelegate> { @public @@ -217,3 +218,56 @@ void groupSetText(id group, char *text) { [toNSBox(group) setTitle:[NSString stringWithUTF8String:text]]; } + +id newTextbox(void) +{ + NSTextView *tv; + + tv = [[NSTextView alloc] initWithFrame:NSZeroRect]; + // verified against Interface Builder, except for rich text options + [tv setAllowsDocumentBackgroundColorChange:NO]; + [tv setBackgroundColor:[NSColor textBackgroundColor]]; + [tv setTextColor:[NSColor textColor]]; + [tv setAllowsUndo:YES]; + [tv setEditable:YES]; + [tv setSelectable:YES]; + [tv setRichText:NO]; + [tv setImportsGraphics:NO]; + [tv setBaseWritingDirection:NSWritingDirectionNatural]; + // TODO default paragraph format + [tv setAllowsImageEditing:NO]; + [tv setAutomaticQuoteSubstitutionEnabled:NO]; + [tv setAutomaticLinkDetectionEnabled:NO]; + [tv setUsesRuler:NO]; + [tv setRulerVisible:NO]; + [tv setUsesInspectorBar:NO]; + [tv setSelectionGranularity:NSSelectByCharacter]; +//TODO [tv setInsertionPointColor:[NSColor insertionColor]]; + [tv setContinuousSpellCheckingEnabled:NO]; + [tv setGrammarCheckingEnabled:NO]; + [tv setUsesFontPanel:NO]; + [tv setEnabledTextCheckingTypes:0]; + [tv setAutomaticDashSubstitutionEnabled:NO]; + [tv setAutomaticSpellingCorrectionEnabled:NO]; + [tv setAutomaticTextReplacementEnabled:NO]; + [tv setSmartInsertDeleteEnabled:NO]; + [tv setLayoutOrientation:NSTextLayoutOrientationHorizontal]; + // TODO default find panel behavior + // now just to be safe; this will do some of the above but whatever + disableAutocorrect((id) tv); + // this option is complex; just set it to the Interface Builder default + [[tv layoutManager] setAllowsNonContiguousLayout:YES]; + // this will work because it's the same selector + setStandardControlFont((id) tv); + return (id) tv; +} + +char *textboxText(id tv) +{ + return [[toNSTextView(tv) string] UTF8String]; +} + +void textboxSetText(id tv, char *text) +{ + [toNSTextView(tv) setString:[NSString stringWithUTF8String:text]]; +} diff --git a/common_darwin.m b/common_darwin.m index 3043f21..f56ceae 100644 --- a/common_darwin.m +++ b/common_darwin.m @@ -13,4 +13,7 @@ void disableAutocorrect(id onwhat) // don't worry about automatic data detection; it won't change stringValue (thanks pretty_function in irc.freenode.net/#macdev) [tv setAutomaticSpellingCorrectionEnabled:NO]; [tv setAutomaticTextReplacementEnabled:NO]; + [tv setAutomaticQuoteSubstitutionEnabled:NO]; + [tv setAutomaticLinkDetectionEnabled:NO]; + [tv setSmartInsertDeleteEnabled:NO]; } diff --git a/control_darwin.m b/control_darwin.m index 816085b..4ff8777 100644 --- a/control_darwin.m +++ b/control_darwin.m @@ -16,7 +16,7 @@ void controlSetHidden(id control, BOOL hidden) [toNSView(control) setHidden:hidden]; } -// also fine for NSCells +// also fine for NSCells and NSTexts (NSTextViews) void setStandardControlFont(id control) { [toNSControl(control) setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]]; diff --git a/objc_darwin.h b/objc_darwin.h index 9f51b8e..d845a67 100644 --- a/objc_darwin.h +++ b/objc_darwin.h @@ -79,6 +79,9 @@ extern id newLabel(void); extern id newGroup(id); extern const char *groupText(id); extern void groupSetText(id, char *); +extern id newTextbox(id); +extern char *textboxText(id); +extern void textboxSetText(id, char *); /* container_darwin.m */ extern id newContainerView(void *); |
