// Insert the single container as the first container in the layout manager before removing the existing pages in order to preserve the shared view state.
/* This method is called at startup and in response to a colors changed notification to fix up the color displayed in the background area of the scrollview (actually clipview) when in "wrap to page" mode.
The reason we need to get fancy here is to assure that the color on Windows is a blend of black and the "3D Objects" color (which is what some Windows apps do). If the color was a regular system color, registering for the notification would not be necessary.
/* Use this method to get the accessory. It reinitailizes the popup, selects the specified item, and also includes or deletes the first entry (corresponding to "Default")
loc++; /* Just skip over the current character... */
}
} else {
loc = NSMaxRange(attachmentRange);
}
}
[attrString endEditing];
}
/* The hyphenation methods are added to NSLayoutManager in OPENSTEP 4.2. Given that we'd like the app to keep on running against earlier versions of OPENSTEP, we make all hyphenation-related calls check to see if they are implemented.
op = [NSPrintOperation printOperationWithView:[scrollView documentView] printInfo:printInfo];
[op setShowPanels:uiFlag];
[op runOperation];
}
- (void)printDocument:(id)sender {
[self printDocumentUsingPrintPanel:YES];
}
- (void)toggleRich:(id)sender {
if (isRichText && ([textStorage length] > 0)) {
int choice = NSRunAlertPanel(NSLocalizedString(@"Make Plain Text", @"Title of alert confirming Make Plain Text"),
NSLocalizedString(@"Convert document to plain text? This will lose fonts, colors, and other text attribute settings.", @"Message confirming Make Plain Text"),
NSLocalizedString(@"OK", @"OK."), NSLocalizedString(@"Cancel", @"Button choice allowing user to cancel."), nil);
NSString *alternate = (cnt + 1 == numFiles) ? nil : NSLocalizedString(@"Abort", @"Button allowing user to abort opening multiple files after one couldn't be opened");
unsigned choice = NSRunAlertPanel(NSLocalizedString(@"File system error", @"Title of alert indicating file couldn't be opened"),
NSLocalizedString(@"Couldn't open file %@.", @"Message indicating file couldn't be opened."),
if (encodingForSaving == UnknownStringEncoding) encodingForSaving = NSUnicodeStringEncoding;
if (haveToChangeType) {
(void)NSRunAlertPanel(NSLocalizedString(@"Save Plain Text", @"Title of save and alert panels when saving plain text"),
NSLocalizedString(@"Document can no longer be saved using its original %@ encoding. Please choose another encoding (%@ is one possibility).", @"Contents of alert panel informing user that the file's string encoding needs to be changed"),
/* The value of updateFileNames: below will have to become conditional on whether we're doing Save To at some point. Also, we'll want to avoid doing the stuff inside the if if we're doing Save To. */
if ([self saveToPath:nameForSaving encoding:encodingForSaving updateFilenames:YES]) {
if (![self isRichText]) encodingIfPlainText = encodingForSaving;
// Generally NSTextStorage's attached to plain text NSTextViews only have one font. But this is not generally true. To ensure the tabstops are uniform throughout the document we always base them on the font of the first character in the NSTextStorage.
validateToggleItem(aCell, [self isRichText], NSLocalizedString(@"&Make Plain Text", @"Menu item to make the current document plain text"), NSLocalizedString(@"&Make Rich Text", @"Menu item to make the current document rich text"));
} else if (action == @selector(togglePageBreaks:)) {
validateToggleItem(aCell, [self hasMultiplePages], NSLocalizedString(@"&Wrap to Window", @"Menu item to cause text to be laid out to size of the window"), NSLocalizedString(@"&Wrap to Page", @"Menu item to cause text to be laid out to the size of the currently selected page type"));
} else if (action == @selector(toggleHyphenation:)) {
if (!hyphenationSupported()) return NO; /* Disable it... */
validateToggleItem(aCell, ([self hyphenationFactor] > 0.0), NSLocalizedString(@"Disallow &Hyphenation", @"Menu item to disallow hyphenation in the document"), NSLocalizedString(@"Allow &Hyphenation", @"Menu item to allow hyphenation in the document"));
}
return YES;
}
static NSString *lastOpenSavePanelDir = nil;
/* Sets the directory in which a save was last done...
/* Get list of supported encodings from the file Encodings.txt (containing comma-separated ints). If the file doesn't exist, a default, built-in list is used.
*/
const int *SupportedEncodings(void) {
static const int *encodings = NULL;
static const int plainTextFileStringEncodingsSupported[] = {