Main Page | Modules | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

CrescatAppDelegate Class Reference

#import <CrescatAppDelegate.h>

Collaboration diagram for CrescatAppDelegate:

Collaboration graph
[legend]

Detailed Description

Crescat application delegate.

The application delegate in Crescat has three main chores.

First, it must initialize and serve defaults. It uses its +initialize method to set up the initial values, and has numerous class methods that supply the default values for things like colors, terminal size, etc.

Second, and related, it maintains the database, indexed by host and user name, of settings for sessions.

Third, it handles AppleScript accessors (currently only one).

Definition at line 32 of file CrescatAppDelegate.h.

Public Member Functions

(IBAction) - showPreferences:
 Show the Preferences window and bring it front.
(IBAction) - showSessionManager:
 Show the Session Manager window and bring it forward.
(IBAction) - showFindPanel:
 Show the Find panel and make it key.
(FindPanelController *) - findController
 Return the singleton controller for the Find panel.

Static Public Member Functions

(NSColor *) + foreColor
 Default foreground color.
(NSColor *) + backColor
 Default background color.
(NSColor *) + cursorColor
 Default cursor color.
(float) + cursorProportion
 Default cursor size.
(float) + proportionFromCursorDescription:
 Text cursor descriptions to proportions.
(NSString *) + protocolParamFromIndex:
 Translate menu indices to SSH protocol choices.
(NSString *) + cipherParamFromIndex:
 Translate menu indices to cipher choices Accepts an index in the range 0.
(NSFont *) + defaultFont
 Default terminal font.
(NSFont *) + printingFont
 Default printing font.
(int) + defaultRows
 Default height of new terminals.
(int) + defaultColumns
 Default width of new terminals.
(BOOL) + searchCaseSensitive
 Are Find-panel searches case-sensitive? Queries the application delegate's controller for the Find panel to determine whether searching is to be case-sensitive.
(BOOL) + searchWraps
 Do Find-panel searches wrap around? Queries the controller for the Find panel to determine whether searches that fail at the end of the terminal buffer should retry with the buffer between the top and the start of the search.
(NSString *) + searchString
 The Find string.
(BOOL) + closeWhenSessionCloses
 Does the document close when the connection ends? Returns whether Crescat document windows are supposed to close when the ssh sessions they embody close.
(NSArray *) + hosts
 Array of the names of all known ssh hosts.
(NSString *) + lastHost
 Name of the last host logged into.
(void) + setLastHost:
 Record the last-logged ssh host in defaults.
(NSArray *) + userIDsForHost:
 Known user IDs for use on a host.
(NSString *) + lastUserForHost:
 The name of the last user on a host.
(void) + setLastUser:forHost:
 Set the last-used user name for a host.
(NSDictionary *) + settingsForHost:userID:
 Retrieve the settings for a host/user combination.
(void) + setSettings:forHost:userID:
 Set preferences for a host/user combination.
(void) + deleteHostName:userID:
 Remove a host/user (or all of a host) from the defaults.
(NSMutableDictionary *) + defaultHostSettings
 Settings for hosts not otherwise known.
(PreferenceController *) + sharedPreferenceController
 Return the preference-window controller.
(int) + registerSessionWithBanner:
 Return an ordinal for a window title.

Protected Attributes

PreferenceControllerprefController
HostManagerhostManager
FindPanelControllerfindPanel
NSCountedSet * sessionCounters


Member Function Documentation

+ (NSColor *) backColor  
 

Default background color.

Returns the background (space) color as set in the user defaults. It corresponds to the "terminalDefaults.backColor" default.

Return values:
The default background color.

Referenced by LoginInfoController::setFromDictionary:, and LoginInfoController::setReasonableDefaults.

+ (NSString *) cipherParamFromIndex: (int)  index  
 

Translate menu indices to cipher choices Accepts an index in the range 0.

.2 and returns the -oCipher parameter for the ssh command that corresponds: "3des," "blowfish," or "des." This matches the order of the preference popup for ciphers.

Parameters:
index integer in the range 0..2; anything else will trigger an assertion.
Return values:
NSString a string suitable for the -oCipher parameter for ssh.
Exceptions:
NSAssert if the parameter is not in 0..2.

Referenced by MyDocument::startSession.

+ (BOOL) closeWhenSessionCloses  
 

Does the document close when the connection ends? Returns whether Crescat document windows are supposed to close when the ssh sessions they embody close.

Corresponds to "terminalDefaults.closeOnClose," which defaults to NO.

Return values:
YES if Crescat is to close the session window when the session ends.

+ (NSColor *) cursorColor  
 

Default cursor color.

Returns the cursor color as set in the user defaults. It corresponds to the "terminalDefaults.cursorColor" default.

Return values:
The default cursor color.

Referenced by defaultHostSettings(), TerminalSection::initWithRows:columns:, LoginInfoController::setFromDictionary:, and LoginInfoController::setReasonableDefaults.

+ (float) cursorProportion  
 

Default cursor size.

Returns the portion of a character block taken up by the cursor. Corresponds to the "terminalDefaults.cursorStyle" user preference. In practice (see -[TerminalSection drawBackground] only 1.0, 0.5, and < 0 are significant; anything else is equivalent to 1.0.

Return values:
0..1 proportion of the cursor's space taken up by the cursor block. If < 0, an underline cursor.

Referenced by TerminalSection::initWithRows:columns:.

+ (int) defaultColumns  
 

Default width of new terminals.

New terminal sessions for host/user combinations not previously seen will use terminals with this many characters per line. Corresponds to the "terminalDefaults.defaultColumns" default.

Return values:
Integer the width of new terminals in characters.

Referenced by defaultHostSettings(), LoginInfoController::setFromDictionary:, and LoginInfoController::setReasonableDefaults.

+ (NSFont *) defaultFont  
 

Default terminal font.

This is the terminal font set by the user in the application preferences. It corresponds to the "terminalDefaults.terminalFont" default entry. Crescat has not been tested extensively with any font other than Monaco, nor much at all with any proportional font.

Return values:
NSFont the default font for terminal display.

Referenced by TerminalSection::initWithRows:columns:, IntegratedTSView::initWithRows:columns:, and IntegratedTSView::sizeIncrement.

+ (NSMutableDictionary *) defaultHostSettings  
 

Settings for hosts not otherwise known.

This method returns the defaults dictionary at "terminalDefaults", which is the configuration to be used for new host/user combinations.

Return values:
NSDictionary the default terminal settings.

Referenced by HostManager::addHost:, LoginInfoController::prepareUI, and MyDocument::sessionParamsSuffice.

+ (int) defaultRows  
 

Default height of new terminals.

New terminal sessions for host/user combinations not previously seen will use terminals with this many lines. Corresponds to the "terminalDefaults.defaultRows" default.

Return values:
Integer the height of new terminals in lines.

Referenced by defaultHostSettings(), LoginInfoController::setFromDictionary:, and LoginInfoController::setReasonableDefaults.

+ (void) deleteHostName: (NSString *)  hostName
userID: (NSString *)  nilForAll
 
 

Remove a host/user (or all of a host) from the defaults.

If nilForAll is an NSString, removes the named host/user combination from the defaults database. If nilForAll is nil, removes the host, and all its users, from the database.

Parameters:
hostName NSString, a host name from hosts.
nilForAll NSString, a user name from userIDsForHost:hostName, or nil if you want to delete all entries for the named host.

Referenced by HostManager::deleteSelection:, HostManager::effectChangeInRow:, and CrescatApplication::handleRemoveSessionCommand:.

- (FindPanelController *) findController  
 

Return the singleton controller for the Find panel.

Initializes the singleton FindPanelController if necessary, and returns it.

Return values:
FindPanelController the application delegate's singleton controller for the Find panel.

+ (NSColor *) foreColor  
 

Default foreground color.

Returns the foreground (character) color as set in the user defaults. It corresponds to the "terminalDefaults.foreColor" default.

Return values:
The default foreground color.

Referenced by LoginInfoController::setFromDictionary:, and LoginInfoController::setReasonableDefaults.

+ (NSArray *) hosts  
 

Array of the names of all known ssh hosts.

The top-level grouping for items in the host-manager interface (see HostManager.m) is an entity maintained by the defaults system, an dictionary of dictionaries. Each entry in the top-level dictionary corresponds to a known ssh host. The host dictionaries include addresses plus a dictionary keyed on user names for use on each host, containing settings for use with each host x user pair. Corresponds to the default "hosts". This method returns the key array of the top-level dictionary: The name of every host.

Return values:
NSArray of NSStrings, naming each known host.

Referenced by initialize(), LoginInfoController::initWithParent:, knownHosts(), PreferenceController::loadUI, HostManager::makeDataCache, LoginInfoController::prepareUI, and valueInKnownHostsAtIndex:().

+ (NSString *) lastHost  
 

Name of the last host logged into.

Crescat defaults the login panel to the last host the user logged into. (But see useLastSelection.) This is stored in the "lastHost" default. This is the getter for that value.

Return values:
NSString the name of the last host logged into.

Referenced by PreferenceController::loadUI, and LoginInfoController::prepareUI.

+ (NSString *) lastUserForHost: (NSString *)  hostName  
 

The name of the last user on a host.

Crescat likes to present the last-used user name when a host is selected in the login panel. This corresponds to "hosts[hostName].lastUser" in the defaults.

Parameters:
hostName NSString, the name of a host from the hosts array.
Return values:
NSString the last-used user name for the host, or nil if not set or the host is unknown.

Referenced by LoginInfoController::hostAction:, and LoginInfoController::prepareUI.

+ (NSFont *) printingFont  
 

Default printing font.

This is the printing font set by the user in the application preferences. It corresponds to the "terminalDefaults.printingFont" default entry. The size is the maximum that will be used; Crescat is apt to use a smaller font to fit the width of the screen onto one page.

Return values:
NSFont the default font for printing.

Referenced by MyDocument::printAttributedString:, and MyDocument::printShowingPrintPanel:.

+ (float) proportionFromCursorDescription: (NSString *)  description  
 

Text cursor descriptions to proportions.

Translates "Underline" to -1, "Half-Block" to 0.5, and anything else to 1.0. This is a crude function for turning preference-menu selections into cursor proportions.

Parameters:
description NSString, of which there are three kinds, "Underline," "Half-Block," and anything else.
Return values:
-1 0.5, or 1, depending on the input.

+ (NSString *) protocolParamFromIndex: (int)  index  
 

Translate menu indices to SSH protocol choices.

Accepts an index in the range of 0..3, and returns the -oProtocol parameter for the ssh command that corresponds: "2,1", "1,2", "2", or "1". This matches the order of the preference popup for this setting.

Parameters:
index an integer in the range 0..3; anything else will trigger an assertion.
Return values:
NSString a string suitable for the -oProtocol parameter for ssh.
Exceptions:
NSAssert if an index outside of 0..3 is presented.

Referenced by MyDocument::startSession.

+ (int) registerSessionWithBanner: (NSString *)  banner  
 

Return an ordinal for a window title.

MyDocument names session windows userName @ host. There may be more than one session with the same combination, so MyDocument wants to number them serially. This method takes the banner text and gives the ordinal number for that banner (so userName @ host can become userName @ host -- 2)

Parameters:
banner The string that constitutes the possibly-common part of the window title.
Return values:
The number of times (including this) that banner has been seen.

Referenced by MyDocument::dataArrivedFromPty:.

+ (BOOL) searchCaseSensitive  
 

Are Find-panel searches case-sensitive? Queries the application delegate's controller for the Find panel to determine whether searching is to be case-sensitive.

This is not saved in the defaults system.

Return values:
YES if searches are to be case-sensitive. Defaults to NO.

Referenced by TallTextView::performFindPanelAction:.

+ (NSString *) searchString  
 

The Find string.

The Find panel puts its target string on the find pasteboard, and accepts changes from the find pasteboard. This method returns the contents of the find pasteboard if there is a string there.

Return values:
NSString if the find pasteboard has string contents, nil otherwise.

Referenced by TallTextView::performFindPanelAction:, and TallTextView::validateUserInterfaceItem:.

+ (BOOL) searchWraps  
 

Do Find-panel searches wrap around? Queries the controller for the Find panel to determine whether searches that fail at the end of the terminal buffer should retry with the buffer between the top and the start of the search.

This setting is not saved in the defaults system.

Return values:
YES if searches are to wrap. Defaults to NO.

Referenced by TallTextView::performFindPanelAction:.

+ (void) setLastHost: (NSString *)  hostName  
 

Record the last-logged ssh host in defaults.

This is the setter for the "lastHost" default. If "terminalDefaults.useLastHost" is NO (it defaults to YES), this method has no effect.

Parameters:
hostName NSString, the name of the last host logged into. Should correspond to the name of a host in the hosts array.

Referenced by LoginInfoController::harvestUI.

+ (void) setLastUser: (NSString *)  userName
forHost: (NSString *)  hostName
 
 

Set the last-used user name for a host.

This is the setter corresponding to -lastUserForHost:. The name will be stored in the defaults at "hosts[hostName].lastUser".

Additionally: If a default user (one with an empty name) had previously been defined for the given host, the default user will be renamed to the given user name, on the theory that we have been accumulating settings anonymously, and now have learned the name to attach to them.

Parameters:
userName NSString, the user name to set as the last user for the given host. Must be in userIDsForHost:hostName, or there must be a default user name.
hostName NSString, the host name for which to set the last user. Must be in hosts.

Referenced by LoginInfoController::harvestUI.

+ (void) setSettings: (NSDictionary *)  settings
forHost: (NSString *)  hostName
userID: (NSString *)  userID
 
 

Set preferences for a host/user combination.

This method sets the entry "hosts[hostName].users[userID]" in the defaults to the dictionary in the settings parameter.

Parameters:
settings The new settings for the host/user combination.
hostName The name of the host. Must be from hosts.
userID The name of the user. Must be from userIDsForHost:hostName.

Referenced by HostManager::effectChangeInRow:, LoginInfoController::harvestUI, MyDocument::showSessionSettings:, and MyDocument::terminalView:changedGeometryToRows:columns:.

+ (NSDictionary *) settingsForHost: (NSString *)  hostName
userID: (NSString *)  userID
 
 

Retrieve the settings for a host/user combination.

Preferences, such as colors, terminal geometry, protocols, etc., are stored by Crescat per-host/per-user. This method retrieves those settings by doing two dictionary lookups: "hosts[hostName].users[userName]". The result is an NSDictionary.

Parameters:
hostName NSString, the name of the host, should be from +hosts.
userID NSString, the name of the user, should be from userIDsForHost:hostName.
Return values:
NSDictionary the terminal settings saved for that host and user.

Referenced by CrescatApplication::handleGetSessionCommand:, LoginInfoController::hostAction:, HostManager::makeDataCache, and LoginInfoController::prepareUI.

+ (PreferenceController *) sharedPreferenceController  
 

Return the preference-window controller.

The application delegate owns the PreferenceController object that runs the application preferences window. This method returns a pointer to that object.

Return values:
PreferenceController the application-wide controller for the preferences window.

Referenced by IntegratedTSView::awakeFromNib, TerminalSection::conformHighlighting, TallTextView::drawPageBorderWithSize:, TermLayoutManager::init, TerminalSection::initWithRows:columns:, and TerminalSection::scheduleHighlighting:.

- (IBAction) showFindPanel: (id)  sender  
 

Show the Find panel and make it key.

Initializes the singleton FindPanelController if necessary, makes the associated Find panel visible, and makes it key. An IBAction.

Parameters:
sender The sender of the message, by the IBAction convention.

Referenced by validateUserInterfaceItem:().

- (IBAction) showPreferences: (id)  sender  
 

Show the Preferences window and bring it front.

Initializes the singleton PreferenceController from the terminalDefaults default setting (if necessary), makes the resulting Preference window visible, and orders it front. An IBAction.

Parameters:
sender The sender of the message, by the IBAction convention.

Referenced by validateUserInterfaceItem:().

- (IBAction) showSessionManager: (id)  sender  
 

Show the Session Manager window and bring it forward.

Initializes the singleton HostManager controller if necessary, makes the associated Session Manager window visible, and orders it front. An IBAction.

Parameters:
sender The sender of the message, by the IBAction convention.

Referenced by validateUserInterfaceItem:().

+ (NSArray *) userIDsForHost: (NSString *)  hostName  
 

Known user IDs for use on a host.

The named host is looked up, and the keys of its "users" dictionary are returned. The return value is all the names of known users for the given host. This corresponds to "hosts[hostName].users.@keys".

Parameters:
hostName NSString, the name of a host from the hosts array.
Return values:
NSArray of NSStrings for all known users for the given host, or nil if the host is unknown.

Referenced by CrescatApplication::handleKnownUsersCommand:, and HostManager::makeDataCache.


Field Documentation

- (FindPanelController*) findPanel [protected]
 

Definition at line 36 of file CrescatAppDelegate.h.

Referenced by findController().

- (HostManager*) hostManager [protected]
 

Definition at line 35 of file CrescatAppDelegate.h.

Referenced by showSessionManager:().

- (PreferenceController*) prefController [protected]
 

Definition at line 34 of file CrescatAppDelegate.h.

Referenced by preferenceController().

- (NSCountedSet*) sessionCounters [protected]
 

Definition at line 37 of file CrescatAppDelegate.h.

Referenced by init().


The documentation for this class was generated from the following file:
Generated on Fri Sep 30 12:01:12 2005 for Crescat by  doxygen 1.4.4