📄 puttyappui.cpp
字号:
assert(iState == EPuttyUIStateNone); TFileName file; StringToDes(config->keyfile.path, file); if ( CFileListDialog::RunDlgLD(file, EFalse) ) { DesToString(file, config->keyfile.path, sizeof(config->keyfile.path)); } break; } case EPuttyCmdSettingsLoggingType: { assert(iState == EPuttyUIStateNone); assert((config->logtype >= 0) && (config->logtype <= 3)); TInt index(config->logtype); CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog(&index); if ( dlg->ExecuteLD( R_SETTINGS_LOG_TYPE ) ) { config->logtype = index; } break; } case EPuttyCmdSettingsLoggingFile: { assert(iState == EPuttyUIStateNone); TFileName file; StringToDes(config->logfilename.path, file); if ( CFileListDialog::RunDlgLD(file, ETrue) ) { DesToString(file, config->logfilename.path, sizeof(config->logfilename.path)); } break; } case EPuttyCmdLoadSettings: { assert(iState == EPuttyUIStateNone); TFileName file; if ( CFileListDialog::RunDlgLD(file, EFalse) ) { iEngine->ReadConfigFileL(file); ReadUiSettingsL(iEngine->GetConfig()); } break; } case EPuttyCmdSaveSettings: { assert(iState == EPuttyUIStateNone); TFileName file; if ( CFileListDialog::RunDlgLD(file, ETrue) ) { WriteUiSettingsL(iEngine->GetConfig()); iEngine->WriteConfigFileL(file); } break; } case EPuttyCmdSendLine: { if ( iState != EPuttyUIStateConnected ) break; CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(ptr); dlg->SetPredictiveTextInputPermitted(ETrue); text = StringLoader::LoadLC(R_STRING_LINE); dlg->SetPromptL(text->Des()); if( dlg->ExecuteLD(R_SEND_TEXT_DLG) ) { int i = 0; int len = ptr.Length(); while ( i < len ) { iEngine->SendKeypress((TKeyCode)ptr[i++], 0); } iEngine->SendKeypress(EKeyEnter, 0); } CleanupStack::PopAndDestroy(); // text break; } case EPuttyCmdSendText: { if ( iState != EPuttyUIStateConnected ) break; CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(ptr); dlg->SetPredictiveTextInputPermitted(ETrue); text = StringLoader::LoadLC(R_STRING_TEXT); dlg->SetPromptL(text->Des()); if( dlg->ExecuteLD(R_SEND_TEXT_DLG) ) { int i = 0; int len = ptr.Length(); while ( i < len ) { iEngine->SendKeypress((TKeyCode)ptr[i++], 0); } } CleanupStack::PopAndDestroy(); // text break; } case EPuttyCmdSendCtrlKeys: { if ( iState != EPuttyUIStateConnected ) break; CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(ptr); dlg->SetPredictiveTextInputPermitted(EFalse); text = StringLoader::LoadLC(R_STRING_CTRL); dlg->SetPromptL(text->Des()); if( dlg->ExecuteLD(R_SEND_TEXT_DLG) ) { int i = 0; int len = ptr.Length(); while ( i < len ) { iEngine->SendKeypress((TKeyCode)ptr[i++], EModifierCtrl); } } CleanupStack::PopAndDestroy(); // text break; } case EPuttyCmdSendPipe: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress((TKeyCode)'|', 0); } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendBackquote: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress((TKeyCode)'`', 0); } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendCR: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress(EKeyEnter, 0); // enter } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendSpace: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress((TKeyCode)' ', 0); } break; case EPuttyCmdSendEsc: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress((TKeyCode)0x1b, EModifierPureKeycode); // escape } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendCtrlC: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress((TKeyCode)0x03, EModifierPureKeycode); // ctrl-c } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendCtrlD: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress((TKeyCode)0x04, EModifierPureKeycode); // ctrl-d } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendCtrlZ: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress((TKeyCode)26, EModifierPureKeycode); // ctrl-z } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendCtrlAD: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress((TKeyCode)0x01, EModifierPureKeycode); // ctrl-a-d iEngine->SendKeypress((TKeyCode)'d', 0); } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendCtrlBrkt: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress((TKeyCode)0x1d, EModifierPureKeycode); // ctrl-] } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendHome: case EPuttyCmdSendInsert: case EPuttyCmdSendDelete: case EPuttyCmdSendEnd: case EPuttyCmdSendPageUp: case EPuttyCmdSendPageDown: if ( iState == EPuttyUIStateConnected ) { // FIXME: Move logic to engine iEngine->SendKeypress((TKeyCode)0x1b, EModifierPureKeycode); iEngine->SendKeypress((TKeyCode)0x5b, EModifierPureKeycode); iEngine->SendKeypress( (TKeyCode)(0x31 + aCommand - EPuttyCmdSendHome), EModifierPureKeycode); iEngine->SendKeypress((TKeyCode)0x7e, EModifierPureKeycode); } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendAlt0: case EPuttyCmdSendAlt1: case EPuttyCmdSendAlt2: case EPuttyCmdSendAlt3: case EPuttyCmdSendAlt4: case EPuttyCmdSendAlt5: case EPuttyCmdSendAlt6: case EPuttyCmdSendAlt7: case EPuttyCmdSendAlt8: case EPuttyCmdSendAlt9: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress( (TKeyCode)(0x30 + aCommand - EPuttyCmdSendAlt0), EModifierAlt); } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSendAltKeys: { if ( iState != EPuttyUIStateConnected ) break; CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(ptr); dlg->SetPredictiveTextInputPermitted(EFalse); text = StringLoader::LoadLC(R_STRING_ALT); dlg->SetPromptL(text->Des()); if( dlg->ExecuteLD(R_SEND_TEXT_DLG) ) { int i = 0; int len = ptr.Length(); while ( i < len ) { iEngine->SendKeypress((TKeyCode)ptr[i++], EModifierAlt); } } CleanupStack::PopAndDestroy(); // text break; } case EPuttyCmdSendF1: case EPuttyCmdSendF2: case EPuttyCmdSendF3: case EPuttyCmdSendF4: case EPuttyCmdSendF5: case EPuttyCmdSendF6: case EPuttyCmdSendF7: case EPuttyCmdSendF8: case EPuttyCmdSendF9: case EPuttyCmdSendF10: if ( iState == EPuttyUIStateConnected ) { iEngine->SendKeypress( (TKeyCode) (EKeyF1 + (aCommand - EPuttyCmdSendF1)), 0); } else { ShowInformationNoteL(R_STR_NOT_CONNECTED); } break; case EPuttyCmdSaveSettingsAsDefault: { TFileName fileName; fileName = iDataPath; fileName.Append(KDefaultSettingsFile); WriteUiSettingsL(iEngine->GetConfig()); iEngine->WriteConfigFileL(fileName); break; } case EPuttyCmdResetDefaultSettings: { iEngine->SetDefaults(); ReadUiSettingsL(iEngine->GetConfig()); HandleCommandL(EPuttyCmdSaveSettingsAsDefault); break; } case EPuttyCmdNotImplemented: { CAknInformationNote* note = new (ELeave) CAknInformationNote; HBufC* text = StringLoader::LoadLC(R_NOT_IMPLEMENTED); note->ExecuteLD(text->Des()); CleanupStack::PopAndDestroy(text); break; } case EAknSoftkeyBack: case EAknSoftkeyExit: case EEikCmdExit: { if ( iState == EPuttyUIStateConnected ) { if(CAknQueryDialog::NewL()->ExecuteLD(R_REALLY_EXIT)) { CleanupStack::PopAndDestroy(); // buf Exit(); } } else { CleanupStack::PopAndDestroy(); // buf Exit(); } break; } default: break; } CleanupStack::PopAndDestroy(); // buf}void CPuttyAppUi::DoDynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) {#define DIMNOTIDLE(x) aMenuPane->SetItemDimmed((x), (iState != EPuttyUIStateNone)) switch ( aResourceId ) { case R_PUTTY_MENU_PANE: aMenuPane->SetItemDimmed(EPuttyCmdSend, (iState != EPuttyUIStateConnected)); break; case R_PUTTY_SETTINGS_MENU: DIMNOTIDLE(EPuttyCmdSettingsConnection); DIMNOTIDLE(EPuttyCmdSettingsAuthentication); DIMNOTIDLE(EPuttyCmdSettingsLogging); DIMNOTIDLE(EPuttyCmdLoadSettings); DIMNOTIDLE(EPuttyCmdSaveSettings); DIMNOTIDLE(EPuttyCmdSaveSettingsAsDefault); DIMNOTIDLE(EPuttyCmdResetDefaultSettings); break; case R_PUTTY_CONNECTION_MENU: DIMNOTIDLE(EPuttyCmdConnectionConnect); aMenuPane->SetItemDimmed(EPuttyCmdConnectionClose, ((iState == EPuttyUIStateNone) || (iState == EPuttyUIStateDisconnected))); aMenuPane->SetItemDimmed(EPuttyCmdConnectionDisconnect, (iState != EPuttyUIStateConnected)); break; case R_PUTTY_SETTINGS_FONT: { // Add fonts to the menu, with commands starting from // EPuttyCmdSetFont for ( TInt i = 0; i < iNumFonts; i++ ) { CEikMenuPaneItem::SData item; item.iText = *iFonts[i]; item.iCommandId = EPuttyCmdSetFont + i; item.iFlags = 0; item.iCascadeId = 0; aMenuPane->AddMenuItemL(item); } break; } default: ; // Do nothing, keep compiler happy }}// Reads the UI settings (font size, full screen flag) from a config structurevoid CPuttyAppUi::ReadUiSettingsL(Config *aConfig) { // Get the font to use StringToDes(aConfig->font.name, iFontName); // Check that the file exists. If not, use the default font TFileName fontFile; fontFile = iFontPath; fontFile.Append(iFontName); fontFile.Append(KFontExtension); if ( !ConeUtils::FileExists(fontFile) ) { iFontName = KDefaultFont; fontFile = iFontPath; fontFile.Append(KDefaultFont); fontFile.Append(KFontExtension); assert(ConeUtils::FileExists(fontFile)); } // Determine if the display should be full screen or not if( aConfig->width == KFullScreen ) { iFullScreen = ETrue; } else { iFullScreen = EFalse; } if ( iTerminalView ) {// iTerminalView->SetFontL(fontFile); iTerminalView->SetFullScreenL(iFullScreen); } // FIXME: Reverse disabled for now /* if( aConfig->try_palette ) { iTerminal->SetReverse(ETrue); } else { iTerminal->SetReverse(EFalse); } */}// Writes the UI settings (font size, full screen flag) to a config structurevoid CPuttyAppUi::WriteUiSettingsL(Config *aConfig) { TPtr8 fontPtr((TUint8*)aConfig->font.name, sizeof(aConfig->font.name)); fontPtr.Copy(iFontName); fontPtr.Append('\0'); if( iFullScreen ) { aConfig->width = KFullScreen; } else { aConfig->width = KFullScreen - KFullScreen; }}// MDialObserver::DialCompleted()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -