TSPreferences

Inherits From:
NSObject

Declared In:
TSPreferences.h

Class Description

Format of the original prefs file:

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

_prefsWindowconnected to the window
_documentFontTextFieldconnected to "Document Font"
_sourceWindowPosMatrixconnected to "Source Window Position"
_syntaxColorButtonconnected to "Syntax Coloring"
_parensMatchButtonconnected to "Parens Matching
_pdfWindowPosMatrixconnected to "PDF Window Position"
_gsColorMatrixconnected to "Ghostscript colors"
_pdfDisplayMatrixconnected to "PDF Display"
_texCommandTextFieldconnected to "TeX program"
_latexCommandTextFieldconnected to "Latex program"
_defaultCommandMatrixconnected to "Default Program"
_undoManagerused for discarding all changes when the cancel button was pressed
_documentFontused 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.

tagmeaning
0Grayscale
1256 Colors
2Thousands 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.