# TSPreferences

Inherits From:
NSObject

Declared In:
TSPreferences.h

## Class Description

Format of the original prefs file:

position | value
0 | version number
1 | textView's font
2 | pdfView's slider value
3-6 | textWindow's frame
7-10 | pdfWindow's frame
11 | TeX command
12 | LaTeX command
13 | display method (Apple or GS)
14 | GS color
15 | preferred TeX command

## Instance Variables

IBOutlet NSWindow *`_prefsWindow`;
IBOutlet NSTextField *`_documentFontTextField`;
IBOutlet NSMatrix *`_sourceWindowPosMatrix`;
IBOutlet NSButton *`_syntaxColorButton`;
IBOutlet NSButton *`_parensMatchButton`;
IBOutlet NSMatrix *`_pdfWindowPosMatrix`;
IBOutlet NSMatrix *`_gsColorMatrix`;
IBOutlet NSMatrix *`_pdfDisplayMatrix`;
IBOutlet NSTextField *`_texCommandTextField`;
IBOutlet NSTextField *`_latexCommandTextField`;
IBOutlet NSMatrix *`_defaultCommandMatrix`;
NSUndoManager *`_undoManager`;
NSFont *`_documentFont`;

_prefsWindow | connected to the window
_documentFontTextField | connected to "Document Font"
_sourceWindowPosMatrix | connected to "Source Window Position"
_syntaxColorButton | connected to "Syntax Coloring"
_parensMatchButton | connected to "Parens Matching
_pdfWindowPosMatrix | connected to "PDF Window Position"
_gsColorMatrix | connected to "Ghostscript colors"
_pdfDisplayMatrix | connected to "PDF Display"
_texCommandTextField | connected to "TeX program"
_latexCommandTextField | connected to "Latex program"
_defaultCommandMatrix | connected to "Default Program"
_undoManager | used for discarding all changes when the cancel button was pressed
_documentFont | used to track the font that the user has selected for the document window

## Method Types

+ sharedInstance
- showPreferences:
- changeDocumentFont:
- sourceWindowPosChanged:
- currentDocumentWindowPosDefault:
- syntaxColorPressed:
- parensMatchPressed:
- pdfWindowPosChanged:
- currentPdfWindowPosDefault:
- ghostscriptColorChanged:
- pdfDisplayMethodChanged:
- currentPdfMagDefault:
- texProgramChanged:
- latexProgramChanged:
- defaultProgramChanged:
- okButtonPressed:
- cancelButtonPressed:
- allTemplateNames
- registerFactoryDefaults
- createDirectoryAtPath:
- copyToTemplateDirectory:
- updateControlsFromUserDefaults:
- updateDocumentFontTextField

## Class Methods

### sharedInstance

+ (id)`sharedInstance`

This class is implemented as singleton, i.e. there is only one single instance in the runtime. This is the designated accessor method to get the shared instance of the Preferences class.

## Instance Methods

### allTemplateNames

- (NSArray *)`allTemplateNames`

This method looks in ~/Library/TeXShop/Templates and returns the filenames minus the extensions of all of the templates found.

### cancelButtonPressed:

- (IBAction)`cancelButtonPressed:`sender

This method is connected to the Cancel button.

### changeDocumentFont:

- (IBAction)`changeDocumentFont:`sender

This method is connected to the 'Set...' button on the 'Document' pane.

Clicking this button will bring up the font panel.

### copyToTemplateDirectory:

- (void)`copyToTemplateDirectory:`(NSString *)fileName

This method is not to be called from outside of this class.

Copies fileName to ~/Library/TeXShop/Templates. This method takes care that no files are overwritten.

### createDirectoryAtPath:

- (void)`createDirectoryAtPath:`(NSString *)path

This method is not to be called from outside of this class.

Creates the directory at path making sure that path does not already exist (which is no problem) and if it exists it is a directory (throws an exception if not).

### currentDocumentWindowPosDefault:

- (IBAction)`currentDocumentWindowPosDefault:`sender

This method is connected to the 'use current pos as default' button on the 'Document' pane.

### currentPdfMagDefault:

- (IBAction)`currentPdfMagDefault:`sender

This method is connected to the 'Use current mag as default' button on the Preview pane'.

### currentPdfWindowPosDefault:

- (IBAction)`currentPdfWindowPosDefault:`sender

This method is connected to the 'use current pos as default' button.

### defaultProgramChanged:

- (IBAction)`defaultProgramChanged:`sender

This method is connected to the "Default Program" matrix on the TeX pane.

A tag of 0 means use TeX, a tag of 1 means use LaTeX.

### ghostscriptColorChanged:

- (IBAction)`ghostscriptColorChanged:`sender

This method is connected to the "Ghostscript Colors" matrix on the Preview pane.

tag | meaning
0 | Grayscale
1 | 256 Colors
2 | Thousands of Colors

### latexProgramChanged:

- (IBAction)`latexProgramChanged:`sender

This method is connected to the textField that holds the LaTeX command. It is located on the TeX pane.

### okButtonPressed:

- (IBAction)`okButtonPressed:`sender

This method is connected to the OK button.

### parensMatchPressed:

- (IBAction)`parensMatchPressed:`sender

This method is connected to the 'parens matching' checkbox.

### pdfDisplayMethodChanged:

- (IBAction)`pdfDisplayMethodChanged:`sender

This method is connected to the "PDF Display" Matrix.

A tag of 0 means use Apple's NSPDFImageRep, a tag of 1 means use Ghostscript.

### pdfWindowPosChanged:

- (IBAction)`pdfWindowPosChanged:`sender

This method is connected to the "PDF Window Position" Matrix.

A tag of 0 means don't save the window position, a tag of 1 to save the setting. This should only flag the request to save the position, the actual saving of position and size can be left to [NSWindow setAutoSaveFrameName].

### registerFactoryDefaults

- (void)`registerFactoryDefaults`

This method is not to be called from outside of this class.

This method will be called when no defaults were registered so far. Since this is the first time that TeXShop runs, we register a standard defaults set (from the FactorDefaults.plist) and fill ~/Library/TeXShop/Templates with our templates.

### showPreferences:

- (IBAction)`showPreferences:`sender

Connected to the "Preferences..." menu item in Application's main menu.

Loads the .nib file if necessary, fills all the controls with the values from the user defaults and makes the window visible.

### sourceWindowPosChanged:

- (IBAction)`sourceWindowPosChanged:`sender

This method is connected to the "Source Window Position" Matrix.

This method will be called when the matrix changes. Target 0 means 'all windows start at a fixed position', target 1 means 'remember window position'.

### syntaxColorPressed:

- (IBAction)`syntaxColorPressed:`sender

This method is connected to the 'syntax coloring' checkbox.

### texProgramChanged:

- (IBAction)`texProgramChanged:`sender

This method is connected to the textField that holds the TeX command. It is located on the TeX pane.

### updateControlsFromUserDefaults:

- (void)`updateControlsFromUserDefaults:`(NSUserDefaults *)defaults

This method is not to be called from outside of this class.

This method retrieves the application preferences from the defaults object and sets the controls in the window accordingly.

### updateDocumentFontTextField

- (void)`updateDocumentFontTextField`

This method is not to be called from outside of this class

This method updates the textField that represents the name of the selected font in the Document pane.

Version 1.1 Copyright ©2001. All Rights Reserved.