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

MyDocument Class Reference

#import <MyDocument.h>

Collaboration diagram for MyDocument:

Collaboration graph
[legend]

Detailed Description

Terminal-and-scrollback for SSH sessions.

This is the only document type for Crescat. It encompasses an SSH terminal session, including settings, terminal screen, and scrollback buffer. It manages the SSH login process by presenting password sheets and error messages as needed.

This is the principal controller object. The principal view is the IntegratedTSView in the termView instance variable. The principal model is accessed through [termView terminal], and is a TextStorageTerminal. MyDocument is the delegate of the SSHTask "session," which provides the input and output streams for SSH. Incoming data goes to the terminal model through the lineFilter CharacterLineFilter.

Definition at line 55 of file MyDocument.h.

Public Member Functions

(IBAction) - changeLogging:
 Toggle logging of input data.
(IBAction) - reconnect:
 Connect through a new instance of ssh(1).
(IBAction) - clearScrollback:
 Discard the scrollback text.
(IBAction) - printSelection:
 Print the selected text.
(IBAction) - printScreen:
 Print the terminal screen.
(IBAction) - spellChecking:
 Toggle spell-checking.
(IBAction) - showSessionSettings:
 (brief description) (comprehensive description)
(void) - startSession
 Run a new session.
(void) - startNewSession
 Ask user to configure a new session and run it.
(NSString *) - userName
 User ID for SSH session.
(NSString *) - hostName
 Host address for SSH session.
(void) - setUserName:
 Set the user ID for SSH session.
(void) - setHostName:
 Set the host address for SSH session.
(int) - rows
 Height of terminal screen in lines.
(int) - columns
 Width of terminal screen in characters.
(void) - setRows:
 Set the height of the terminal screen in lines.
(void) - setColumns:
 Set the width of the terminal screen in characters.
(void) - setForeColor:
 Set the "plain" color for text on the terminal screen.
(void) - setBackColor:
 Set the "plain" color for the terminal background.
(void) - setCursorColor:
 Set the color of the terminal cursor.
(id) - sendText:
 AppleScript send-text command.
(NSTextStorage *) - terminalText
 NSTextStorage underlying the terminal.
(id) - init [implementation]
(void) - dealloc [implementation]
(NSString *) - windowNibName [implementation]
(BOOL) - sessionParamsSuffice [implementation]
(void) - windowControllerDidLoadNib: [implementation]
(BOOL) - userPresentsPassword: [implementation]
(ConnectionExpectState- sshNotification: [implementation]
(void) - dataArrivedFromPty: [implementation]
(void) - ptyTaskCompleted: [implementation]
(void) - terminalView:gotKeyData:modifiers: [implementation]
(void) - terminalView:changedGeometryToRows:columns: [implementation]
(BOOL) - textView:clickedOnLink:atIndex: [implementation]
(void) - terminalScreen:sendsReportData: [implementation]
(void) - terminalScreenPrintsScreen: [implementation]
(void) - terminalScreen:printsBuffer: [implementation]
(void) - printBufferDone:success:tempView: [implementation]
(void) - terminalScreen:scrollsOffText: [implementation]
(NSData *) - dataRepresentationOfType: [implementation]
(BOOL) - loadDataRepresentation:ofType: [implementation]
(BOOL) - validateUserInterfaceItem: [implementation]
(id) - handleClearScrollback: [implementation]
(id) - handleFind: [implementation]
(NSColor *) - foreColor [implementation]
(NSColor *) - backColor [implementation]
(NSColor *) - cursorColor [implementation]
(NSString *) - selectedText [implementation]
(NSString *) - fullContent [implementation]
(int) - cursorRow [implementation]
(int) - cursorColumn [implementation]
(void) - setPassword: [implementation]
(void) - printShowingPrintPanel: [implementation]
(void) - printAttributedString: [implementation]
(void) - windowDidBecomeMain: [implementation]
(NSSize) - windowWillResize:toSize: [implementation]

Protected Attributes

IBOutlet IntegratedTSViewtermView
IBOutlet NSButton * testButton
IBOutlet NSButton * logCheckbox
IBOutlet NSWindow * mainWindow
NSMutableDictionary * sessionParams
SSHTasksession
CharacterLineFilterlineFilter
BOOL logInput
ConnectionExpectState state
NSMutableString * sshErrorMessage
NSData * scrollbackTemp


Member Function Documentation

- (NSColor *) backColor   [implementation]
 

Definition at line 582 of file MyDocument.m.

References IntegratedTSView::backColor, and termView.

Here is the call graph for this function:

- (IBAction) changeLogging: (id)  sender  
 

Toggle logging of input data.

This is an IBAction, intended to be sent by a menu item. In addition to toggling the state of the BOOL that controls whether incoming data from the terminal is logged to standard error, this method does a setState: on the sender according to whether the BOOL is on or off.

The validateUserInterface: method will trigger an assertion if an item having this message for its action is not an NSMenuItem or an NSButton.

Parameters:
sender The sender of the action, per IBAction protocol.

Definition at line 462 of file MyDocument.m.

References logInput.

Referenced by validateUserInterfaceItem:.

- (IBAction) clearScrollback: (id)  sender  
 

Discard the scrollback text.

Tells termView to clearBuffer, which releases everything stored in the scrollback buffer, but not the terminal screen.

Parameters:
sender The sender of the action, per IBAction protocol.

Definition at line 53 of file MyDocument.m.

References TallTextView::clearBuffer, and termView.

Referenced by handleClearScrollback:, and validateUserInterfaceItem:.

Here is the call graph for this function:

- (int) columns  
 

Width of terminal screen in characters.

Getter for the horizontal dimension of the terminal screen. KVC compliance for AppleScript.

Return values:
Integer the number of columns in the session terminal screen.

Definition at line 502 of file MyDocument.m.

References IntegratedTSView::columns, and termView.

Referenced by printAttributedString:, and startSession.

- (NSColor *) cursorColor   [implementation]
 

Definition at line 583 of file MyDocument.m.

References IntegratedTSView::cursorColor, and termView.

Here is the call graph for this function:

- (int) cursorColumn   [implementation]
 

Definition at line 657 of file MyDocument.m.

References TextStorageTerminal::cursorLocationX:Y:, IntegratedTSView::terminal, and termView.

Here is the call graph for this function:

- (int) cursorRow   [implementation]
 

Definition at line 650 of file MyDocument.m.

References TextStorageTerminal::cursorLocationX:Y:, IntegratedTSView::terminal, and termView.

Here is the call graph for this function:

- (void) dataArrivedFromPty: (PTYTask *)  aTask   [implementation]
 

Definition at line 212 of file MyDocument.m.

References PTYTask(streamTasks)::availableData, IntegratedTSView::columns, expectNothing, expectPass, expectPassOrKey, expectRejectOrTraffic, expectTraffic, SSHTask::hostName, lineFilter, logInput, mainWindow, CharacterLineFilter::processData:, CrescatAppDelegate::registerSessionWithBanner:, IntegratedTSView::rows, SSHTask::sendStringToHost:, session, IntegratedTSView::setAcceptsKeystrokes:, SSHTask::setRows:columns:, sshErrorMessage, sshNotification:, state, termView, SSHTask::userName, and userPresentsPassword:.

Here is the call graph for this function:

- (NSData *) dataRepresentationOfType: (NSString *)  aType   [implementation]
 

Definition at line 419 of file MyDocument.m.

References TallTextView::attributedString, TallTextView::content, PlainTextFileType, RichTextFileType, SessionFileType, TallTextView::string, and termView.

Here is the call graph for this function:

- (void) dealloc   [implementation]
 

Definition at line 44 of file MyDocument.m.

References mainWindow, session, and sessionParams.

- (NSColor *) foreColor   [implementation]
 

Definition at line 581 of file MyDocument.m.

References IntegratedTSView::foreColor, and termView.

Here is the call graph for this function:

- (NSString *) fullContent   [implementation]
 

Definition at line 645 of file MyDocument.m.

References TallTextView::string, and termView.

Here is the call graph for this function:

- (id) handleClearScrollback: (NSScriptCommand *)  theCommand   [implementation]
 

Definition at line 551 of file MyDocument.m.

References clearScrollback:.

Here is the call graph for this function:

- (id) handleFind: (NSScriptCommand *)  theCommand   [implementation]
 

Definition at line 557 of file MyDocument.m.

References TallTextView::doSearch:backward:caseSensitive:wraps:, and termView.

Here is the call graph for this function:

- (NSString *) hostName  
 

Host address for SSH session.

Getter method for the host address to be used in connecting through ssh(1). KVC compliance for AppleScript.

Return values:
NSString the host address as stored in the document's session parameters.

Definition at line 114 of file MyDocument.m.

References sessionParams.

Referenced by TallTextView::drawPageBorderWithSize:.

- (id) init   [implementation]
 

Definition at line 33 of file MyDocument.m.

References expectPassOrKey, sessionParams, sshErrorMessage, and state.

- (BOOL) loadDataRepresentation: (NSData *)  data
ofType: (NSString *)  aType
  [implementation]
 

Definition at line 445 of file MyDocument.m.

References PlainTextFileType, RichTextFileType, scrollbackTemp, and sessionParams.

- (void) printAttributedString: (NSAttributedString *)  aString   [implementation]
 

Definition at line 704 of file MyDocument.m.

References IntegratedTSView::backColor, TerminalSection::characterSizeForFont:, columns, IntegratedTSView::defaultFont, TextStorageTerminal::defaultFont, IntegratedTSView::foreColor, CrescatAppDelegate::printingFont, rows, TallTextView::setAttributedString:, TallTextView::setDocument:, TallTextView::setPageInfo:, and termView.

Referenced by printScreen:, and printSelection:.

Here is the call graph for this function:

- (void) printBufferDone: (NSDocument *)  me
success: (BOOL)  success
tempView: (void *)  contextInfo
  [implementation]
 

Definition at line 403 of file MyDocument.m.

- (IBAction) printScreen: (id)  sender  
 

Print the terminal screen.

Takes the contents of the terminal view, and renders it in the printer font, with foreground set to black and background to white. Vertical pagination is automatic; horizontally, the view is resized to fit the page. The results are printed via the standard document-modal printing dialog.

Parameters:
sender The sender of the action, per IBAction protocol.

Definition at line 740 of file MyDocument.m.

References printAttributedString:, IntegratedTSView::terminal, termView, and TextStorageTerminal::textStorage.

Referenced by terminalScreenPrintsScreen:, and validateUserInterfaceItem:.

Here is the call graph for this function:

- (IBAction) printSelection: (id)  sender  
 

Print the selected text.

Takes the selection from the document's view, and renders it in the printer font, with foreground set to black and background to white. Vertical pagination is automatic; horizontally, the view is resized to fit the page. The results are printed via the standard document-modal printing dialog.

Parameters:
sender The sender of the action, per IBAction protocol.

Definition at line 735 of file MyDocument.m.

References printAttributedString:, TallTextView::selectedAttributedString, and termView.

Referenced by validateUserInterfaceItem:.

Here is the call graph for this function:

- (void) printShowingPrintPanel: (BOOL)  showPanel   [implementation]
 

Definition at line 671 of file MyDocument.m.

References TallTextView::attributedString, IntegratedTSView::backColor, IntegratedTSView::defaultFont, IntegratedTSView::foreColor, CrescatAppDelegate::printingFont, TallTextView::setAttributedString:, TallTextView::setDocument:, TallTextView::setPageInfo:, and termView.

Here is the call graph for this function:

- (void) ptyTaskCompleted: (PTYTask *)  aTask   [implementation]
 

Definition at line 312 of file MyDocument.m.

References closeWhenSessionCloses(), expectNothing, SSHTask::hostName, mainWindow, OneButtonAlertController::run, session, IntegratedTSView::setAcceptsKeystrokes:, sshErrorMessage, state, termView, and SSHTask::userName.

Here is the call graph for this function:

- (IBAction) reconnect: (id)  sender  
 

Connect through a new instance of ssh(1).

This method resets the connection state to expectPassOrKey, and calls startSession. This initializes a new SSHTask, which initializes a new ssh(1) instance with the current document's settings and begins the state machine's path through connection and authentication.

Parameters:
sender The sender of the action, per IBAction protocol.

Definition at line 58 of file MyDocument.m.

References expectPassOrKey, startSession, and state.

Referenced by validateUserInterfaceItem:.

Here is the call graph for this function:

- (int) rows  
 

Height of terminal screen in lines.

Getter for the vertical dimension of the terminal screen. KVC compliance for AppleScript.

Return values:
Integer the number of rows in the session terminal screen.

Definition at line 501 of file MyDocument.m.

References IntegratedTSView::rows, and termView.

Referenced by printAttributedString:, and startSession.

- (NSString *) selectedText   [implementation]
 

Definition at line 640 of file MyDocument.m.

References TallTextView::selectedAttributedString, and termView.

Here is the call graph for this function:

- (id) sendText: (NSScriptCommand *)  command  
 

AppleScript send-text command.

This method implements the AppleScript command for sending text through the terminal. The parameters include the text to send and whether to follow it with a press of the return key.

Parameters:
command NSScriptCommand, the command, bearing parameters.
Return values:
id the result of the command, probably nil.

Definition at line 528 of file MyDocument.m.

References content(), SSHTask::sendToHost:, and session.

Here is the call graph for this function:

- (BOOL) sessionParamsSuffice   [implementation]
 

Definition at line 71 of file MyDocument.m.

References CrescatAppDelegate::defaultHostSettings, and sessionParams.

Referenced by windowControllerDidLoadNib:.

Here is the call graph for this function:

- (void) setBackColor: (NSColor *)  aColor  
 

Set the "plain" color for the terminal background.

Setter for the background color, the color that fills the portions of the screen for which the host specifies normal-background text. Normally white. KVC compliance for AppleScript.

Parameters:
aColor NSColor, the new background color.

Definition at line 594 of file MyDocument.m.

References EnsureColor(), sessionParams, IntegratedTSView::setBackColor:, and termView.

Referenced by showSessionSettings:.

Here is the call graph for this function:

- (void) setColumns: (int)  newColumns  
 

Set the width of the terminal screen in characters.

Setter for the horizontal dimension of the terminal screen, in charaacters. Values less than 6 or greater than 499 will have no effect. KVC compliance for AppleScript.

Parameters:
newColumns Integer between 6 and 499, the new number of columns.

Definition at line 521 of file MyDocument.m.

References IntegratedTSView::rows, IntegratedTSView::setRows:columns:, and termView.

Referenced by showSessionSettings:.

Here is the call graph for this function:

- (void) setCursorColor: (NSColor *)  aColor  
 

Set the color of the terminal cursor.

Setter for the color of the cursor, the block of highlighting that indicates the location of current focus in the terminal screen. KVC compliance for AppleScript.

Parameters:
aColor NSColor, the new color for the cursor.

Definition at line 603 of file MyDocument.m.

References EnsureColor(), sessionParams, IntegratedTSView::setCursorColor:, and termView.

Referenced by showSessionSettings:.

Here is the call graph for this function:

- (void) setForeColor: (NSColor *)  aColor  
 

Set the "plain" color for text on the terminal screen.

Setter for the foreground color, the color used when the host specifies normal text. Normally black. KVC compliance for AppleScript.

Parameters:
aColor NSColor, the new foreground color.

Definition at line 585 of file MyDocument.m.

References EnsureColor(), sessionParams, IntegratedTSView::setForeColor:, and termView.

Referenced by showSessionSettings:.

Here is the call graph for this function:

- (void) setHostName: (NSString *)  newName  
 

Set the host address for SSH session.

Setter method for the host address to be used in connecting through ssh(1). KVC compliance for AppleScript. This setting has practical effect only when a connection is being made.

Parameters:
newName NSString, the address of the remote host.

Definition at line 509 of file MyDocument.m.

References sessionParams.

- (void) setPassword: (NSString *)  aPassword   [implementation]
 

Definition at line 664 of file MyDocument.m.

References sessionParams.

- (void) setRows: (int)  newRows  
 

Set the height of the terminal screen in lines.

Setter for the vertical dimension of the terminal screen, in lines. Values less than 2 or greater than 255 will have no effect. KVC compliance for AppleScript.

Parameters:
newRows Integer between 2 and 255, the new number of rows.

Definition at line 514 of file MyDocument.m.

References IntegratedTSView::columns, IntegratedTSView::setRows:columns:, and termView.

Referenced by showSessionSettings:.

Here is the call graph for this function:

- (void) setUserName: (NSString *)  newName  
 

Set the user ID for SSH session.

Setter method for the user ID to be used in connnecting through ssh(1). KVC compliance for AppleScript. This setting has practical effect only when a connection is being made.

Parameters:
newName NSString, the name to present to the remote host.

Definition at line 504 of file MyDocument.m.

References sessionParams.

- (IBAction) showSessionSettings: (id)  sender  
 

(brief description) (comprehensive description)

Parameters:
sender The sender of the action, per IBAction protocol.

Definition at line 612 of file MyDocument.m.

References sessionParams, setBackColor:, setColumns:, setCursorColor:, IntegratedTSView::setCursorHeight:, IntegratedTSView::setDeleteIsBackspace:, setForeColor:, setRows:, CrescatAppDelegate::setSettings:forHost:userID:, SessionPanelController::settings, and termView.

Here is the call graph for this function:

- (IBAction) spellChecking: (id)  sender  
 

Toggle spell-checking.

Toggles the state of the sender object using setState: (which more or less restricts this to being sent by an NSMenuItem). When the item is on, starts a once-a-second task that checks the terminal screen for misspellings and highlights them. When off, unschedules the timer task and removes spell-check attributes.

Parameters:
sender The sender of the action, per IBAction protocol.

Definition at line 768 of file MyDocument.m.

References TextStorageTerminal::checkSpelling:, IntegratedTSView::terminal, and termView.

Referenced by validateUserInterfaceItem:.

Here is the call graph for this function:

- (ConnectionExpectState) sshNotification: (NSData *)  noticeData   [implementation]
 

Definition at line 202 of file MyDocument.m.

References expectNothing, expectPass, TwoButtonAlertController::result, and TwoButtonAlertController::run.

Referenced by dataArrivedFromPty:.

Here is the call graph for this function:

- (void) startNewSession  
 

Ask user to configure a new session and run it.

Instantiates a LoginInfoController to run a sheet allowing the user to enter user ID, host name, and possibly other parameters, then calls startSession to start an SSH connection with those parameters.

Definition at line 155 of file MyDocument.m.

References LoginInfoController::results, LoginInfoController::run, sessionParams, and startSession.

Here is the call graph for this function:

- (void) startSession  
 

Run a new session.

Initializes a new SSHTask, which initializes a new ssh(1) instance with the current document's settings and begins the state machine's path through connection and authentication.

Definition at line 116 of file MyDocument.m.

References CrescatAppDelegate::cipherParamFromIndex:, columns, SSHTask::connect, lineFilter, CrescatAppDelegate::protocolParamFromIndex:, rows, session, sessionParams, IntegratedTSView::setBackColor:, SSHTask::setCipher:, SSHTask::setCompression:, IntegratedTSView::setCursorColor:, IntegratedTSView::setCursorHeight:, TextStorageTerminal::setDelegate:, SSHTask::setDelegate:, IntegratedTSView::setDeleteIsBackspace:, TextStorageTerminal::setEatsNewlines:, IntegratedTSView::setForeColor:, SSHTask::setPort:, SSHTask::setProtocol:, IntegratedTSView::setRows:columns:, IntegratedTSView::terminal, and termView.

Referenced by reconnect:, and startNewSession.

Here is the call graph for this function:

- (void) terminalScreen: (TextStorageTerminal *)  screen
printsBuffer: (NSString *)  aBuffer
  [implementation]
 

Definition at line 369 of file MyDocument.m.

References length().

Here is the call graph for this function:

- (void) terminalScreen: (TextStorageTerminal *)  screen
scrollsOffText: (NSAttributedString *)  someText
  [implementation]
 

Definition at line 408 of file MyDocument.m.

References IntegratedTSView::appendAttributedString:, and termView.

Here is the call graph for this function:

- (void) terminalScreen: (TextStorageTerminal *)  screen
sendsReportData: (NSData *)  report
  [implementation]
 

Definition at line 359 of file MyDocument.m.

References SSHTask::sendToHost:, and session.

Here is the call graph for this function:

- (void) terminalScreenPrintsScreen: (TextStorageTerminal *)  screen   [implementation]
 

Definition at line 364 of file MyDocument.m.

References printScreen:.

Here is the call graph for this function:

- (NSTextStorage *) terminalText  
 

NSTextStorage underlying the terminal.

This method affords the AppleScript text suite access to the terminal screen. KVC compliance for AppleScript.

Return values:
NSTextStorage the text storage behind the terminal display.

Definition at line 576 of file MyDocument.m.

References IntegratedTSView::terminal, termView, and TextStorageTerminal::textStorage.

Here is the call graph for this function:

- (void) terminalView: (IntegratedTSView *)  view
changedGeometryToRows: (int)  rows
columns: (int)  columns
  [implementation]
 

Definition at line 338 of file MyDocument.m.

References session, sessionParams, SSHTask::setRows:columns:, and CrescatAppDelegate::setSettings:forHost:userID:.

Here is the call graph for this function:

- (void) terminalView: (IntegratedTSView *)  view
gotKeyData: (NSData *) <