diff --git a/new/entry_darwin.m b/new/entry_darwin.m index 102168b..f2b208b 100644 --- a/new/entry_darwin.m +++ b/new/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/new/text_darwin.m b/new/text_darwin.m index 4f36356..f0d3dab 100644 --- a/new/text_darwin.m +++ b/new/text_darwin.m @@ -12,3 +12,8 @@ char *uiDarwinNSStringToText(NSString *s) } return out; } + +void uiFreeText(char *s) +{ + free(s); +} diff --git a/new/uipriv_darwin.h b/new/uipriv_darwin.h index fc6e3cd..057af1d 100644 --- a/new/uipriv_darwin.h +++ b/new/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/new/util_darwin.m b/new/util_darwin.m index 8fbf391..906a0ea 100644 --- a/new/util_darwin.m +++ b/new/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/new/window_darwin.m b/new/window_darwin.m index 690c73a..9b6949f 100644 --- a/new/window_darwin.m +++ b/new/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];