diff --git a/entry_darwin.m b/entry_darwin.m index 102168be..f2b208bb 100644 --- a/entry_darwin.m +++ b/entry_darwin.m @@ -29,7 +29,7 @@ void finishNewTextField(NSTextField *t, BOOL isEntry) [t setBezelStyle:NSTextFieldSquareBezel]; [t setBezeled:isEntry]; - // TODO autocorrect comment + // we don't need to worry about substitutions/autocorrect here; see window_darwin.m for details [[t cell] setLineBreakMode:NSLineBreakByClipping]; [[t cell] setScrollable:YES]; diff --git a/text_darwin.m b/text_darwin.m index 4f363561..f0d3dab6 100644 --- a/text_darwin.m +++ b/text_darwin.m @@ -12,3 +12,8 @@ char *uiDarwinNSStringToText(NSString *s) } return out; } + +void uiFreeText(char *s) +{ + free(s); +} diff --git a/uipriv_darwin.h b/uipriv_darwin.h index fc6e3cdf..057af1dc 100644 --- a/uipriv_darwin.h +++ b/uipriv_darwin.h @@ -26,6 +26,7 @@ // util_darwin.m extern void setStandardControlFont(NSControl *); +extern void disableAutocorrect(NSTextView *); // container_darwin.m @interface uiContainer : NSView diff --git a/util_darwin.m b/util_darwin.m index 8fbf391b..906a0ead 100644 --- a/util_darwin.m +++ b/util_darwin.m @@ -7,7 +7,14 @@ void setStandardControlFont(NSControl *control) [control setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]]; } -void uiFreeText(char *s) +void disableAutocorrect(NSTextView *tv) { - free(s); + [tv setEnabledTextCheckingTypes:0]; + [tv setAutomaticDashSubstitutionEnabled:NO]; + // 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/window_darwin.m b/window_darwin.m index 690c73ac..9b6949f6 100644 --- a/window_darwin.m +++ b/window_darwin.m @@ -51,7 +51,14 @@ uiWindow *uiNewWindow(char *title, int width, int height) backing:NSBackingStoreBuffered defer:YES]; [d.w setTitle:toNSString(title)]; - // TODO substitutions + + // we do not want substitutions + // text fields, labels, etc. take their smart quotes and other autocorrect settings from their parent window, which provides a shared "field editor" + // so we have to turn them off here + // thanks akempgen in irc.freenode.net/#macdev + // for some reason, this selector returns NSText but is documented to return NSTextView... + // NOTE: if you disagree with me about disabling substitutions, start a github issue with why and I'll be happy to consider it + disableAutocorrect((NSTextView *) [d.w fieldEditor:YES forObject:nil]); // this is what will destroy the window on close [d.w setReleasedWhenClosed:YES];