📄 terminalcontrol.cpp
字号:
if ( iFepEditActive && (aY == iFepEditY) && (aX >= iFepEditX) && (aX < (iFepEditX + iFepEditDisplayLen)) ) { TText c = iFepEditBuf[aX - iFepEditX]; // Map Enter characters or symbols from the the S60 FEP uses to a // unicode line break. See DoCommitFepInlineEditL() below for more // info. if ( (c == 0x21b2) || (c == 0xe125) ) { c = 0x2028; } return c; } return iChars[aX + aY * iCharWidth];}// Update FEP editor displayvoid CTerminalControl::UpdateFepEditDisplay() { TInt oldX = iFepEditX; TInt oldLen = iFepEditDisplayLen; if ( (iFepEditOrigX == -1) || (iFepEditOrigY == -1) ) { return; } // Determine new FEP editor display position and length iFepEditY = iFepEditOrigY; TInt len = iFepEditBuf.Length(); if ( iFepEditOrigX + len > iCharWidth ) { iFepEditX = iCharWidth - len; if ( iFepEditX < 0 ) { iFepEditX = 0; iFepEditDisplayLen = iCharWidth; } else { iFepEditDisplayLen = len; } } else { iFepEditX = iFepEditOrigX; iFepEditDisplayLen = len; } // Update the area covered by both the old and the new FEP edit display TInt updateX = iFepEditX; TInt updateLen = iFepEditDisplayLen; if ( (oldX != -1) && (oldX < updateX) ) { updateX = oldX; } if ( (oldX != -1) && ((oldX + oldLen) > (updateX + updateLen)) ) { updateLen = (oldX + oldLen) - updateX; } UpdateDisplay(updateX, iFepEditY, updateLen);}// CCoeControl::OfferKeyEventL()TKeyResponse CTerminalControl::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType) { LFPRINT((_L("OfferKeyEvent(%d, %d)"), (TInt)aKeyEvent.iCode, (TInt)aType)); if ( aType == EEventKey ) { TUint code = aKeyEvent.iCode; iCtrlDown = EFalse; // Handle cursor keys in selection mode if ( iSelectMode ) { switch ( code ) { case EKeyUpArrow: if ( iSelectY > 0 ) { iSelectY--; if ( iHaveSelection ) { // FIXME: Could be optimized UpdateDisplay(0, iSelectY, iCharWidth); UpdateDisplay(0, iSelectY+1, iCharWidth); } else { UpdateDisplay(iSelectX, iSelectY, 1); UpdateDisplay(iSelectX, iSelectY+1, 1); } } break; case EKeyDownArrow: if ( iSelectY < (iCharHeight-1) ) { iSelectY++; if ( iHaveSelection ) { // FIXME: Could be optimized UpdateDisplay(0, iSelectY-1, iCharWidth); UpdateDisplay(0, iSelectY, iCharWidth); } else { UpdateDisplay(iSelectX, iSelectY-1, 1); UpdateDisplay(iSelectX, iSelectY, 1); } } break; case EKeyLeftArrow: if ( iSelectX > 0 ) { iSelectX--; if ( iSelectX < (iCharWidth-1) ) { UpdateDisplay(iSelectX, iSelectY, 2); } else { UpdateDisplay(iSelectX, iSelectY, 1); } } break; case EKeyRightArrow: if ( iHaveSelection ) { // Note that when there is a selection we'll let the // mark cursor go past the right-hand side of the // terminal by one character. This lets the user select // a line all the way to its end. if ( iSelectX < iCharWidth ) { iSelectX++; if ( iSelectX < iCharWidth ) { UpdateDisplay(iSelectX-1, iSelectY, 2); } else { UpdateDisplay(iSelectX-1, iSelectY, 1); } } } else { if ( iSelectX < (iCharWidth-1) ) { iSelectX++; UpdateDisplay(iSelectX-1, iSelectY, 2); } } break; default: // Pass other keypresses to the observer // FIXME: Is this a good idea after all? iObserver.KeyPressed((TKeyCode)code, (aKeyEvent.iModifiers | iNextKeyModifiers)); iNextKeyModifiers = 0; break; } } else { // Normal mode, pass keypress to the observer iObserver.KeyPressed((TKeyCode)code, aKeyEvent.iModifiers | iNextKeyModifiers); iNextKeyModifiers = 0; return EKeyWasConsumed; } } else if ( (aType == EEventKeyDown) && (aKeyEvent.iCode == EKeyNull) && ((aKeyEvent.iModifiers & EModifierCtrl) != 0) ) { iCtrlDown = ETrue; } else if ( iCtrlDown && (aType == EEventKeyUp) && (aKeyEvent.iCode == EKeyNull) && ((aKeyEvent.iModifiers & EModifierCtrl) == 0) ) { // Ctrl up/down without other keys -- add Ctrl modifier to the next // key. This makes Ctrl behave like a prefix key similar to Shift, // which should improve usability in general and enables Ctrl+key // input on all keys on an E61. iCtrlDown = EFalse; iNextKeyModifiers |= EModifierCtrl; return EKeyWasConsumed; } else { iCtrlDown = EFalse; } return EKeyWasNotConsumed;}// CCoeControl::SizeChanged()void CTerminalControl::SizeChanged() { Resize();}// CCoeControl::InputCapabilities()TCoeInputCapabilities CTerminalControl::InputCapabilities() const { return TCoeInputCapabilities(TCoeInputCapabilities::EAllText | TCoeInputCapabilities::ENavigation, const_cast<CTerminalControl*>(this), NULL);}#ifdef PUTTY_S90// Notify CEikonEnv of pointer events. This ensures the text input window// pops up when the user taps the terminal control.void CTerminalControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) { if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) { iEikonEnv->InformFepOfPenDownEvent(); } if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) { iEikonEnv->InformFepOfPenUpEvent(); } CCoeControl::HandlePointerEventL(aPointerEvent);}#endif// MCoeFepAwareTextEditor::StartFepInlineEditL()void CTerminalControl::StartFepInlineEditL( const TDesC &aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility, const MFormCustomDraw * /*aCustomDraw*/, MFepInlineTextFormatRetriever & /*aInlineTextFormatRetriever*/, MFepPointerEventHandlerDuringInlineEdit & /*aPointerEventHandlerDuringInlineEdit*/) { LFPRINT((_L("StartFepInlineEditL()"))); iFepEditActive = ETrue; iFepCursorVisible = aCursorVisibility; if ( aInitialInlineText.Length() <= iFepEditBuf.MaxLength() ) { iFepEditBuf = aInitialInlineText; } else { iFepEditBuf = aInitialInlineText.Left(iFepEditBuf.MaxLength()); } iFepCursorPos = aPositionOfInsertionPointInInlineText; if ( iFepCursorPos >= iFepEditBuf.Length() ) { iFepCursorPos = iFepEditBuf.Length() - 1; } // Determine FEP editor display location iFepEditOrigX = iCursorX; iFepEditOrigY = iCursorY; iFepEditX = -1; iFepEditY = -1; iFepEditDisplayLen = 0; UpdateFepEditDisplay(); TRACE;}// MCoeFepAwareTextEditor::UpdateFepInlineTextL()void CTerminalControl::UpdateFepInlineTextL( const TDesC& aNewInlineText, TInt aPositionOfInsertionPointInInlineText) { assert(iFepEditActive);#ifdef LOGFILE_ENABLED TBuf<128> buf; buf = _L("UpdateFepInlineTextL({"); for ( TInt i = 0; i < aNewInlineText.Length(); i++ ) { buf.AppendFormat(_L("0x%04x"), (TInt) aNewInlineText[i]); if ( i < (aNewInlineText.Length()-1) ) { buf.Append(_L(", ")); } } buf.AppendFormat(_L("}, %d)"), aPositionOfInsertionPointInInlineText); LFPRINT((buf));#endif if ( aNewInlineText.Length() <= iFepEditBuf.MaxLength() ) { iFepEditBuf = aNewInlineText; } else { iFepEditBuf = aNewInlineText.Left(iFepEditBuf.MaxLength()); } iFepCursorPos = aPositionOfInsertionPointInInlineText; if ( iFepCursorPos >= iFepEditBuf.Length() ) { iFepCursorPos = iFepEditBuf.Length() - 1; } TRACE; UpdateFepEditDisplay(); TRACE;}// MCoeFepAwareTextEditor::UpdateFepInlineTextL()void CTerminalControl::SetInlineEditingCursorVisibilityL( TBool aCursorVisibility) { iFepCursorVisible = aCursorVisibility; LFPRINT((_L("SetInlineEditingCursorVisibilityL(%d)"), (TInt) aCursorVisibility));}// MCoeFepAwareTextEditor::CommitFepInlineEditL()void CTerminalControl::CommitFepInlineEditL(CCoeEnv& /*aConeEnvironment*/) { LFPRINT((_L("CommitFepInlineEditL()")));}// MCoeFepAwareTextEditor::CancelFepInlineEdit()void CTerminalControl::CancelFepInlineEdit() { iFepEditActive = EFalse; LFPRINT((_L("CancelFepInlineEdit()"))); if ( (iFepEditX != -1) && (iFepEditY != -1) ) { TRACE; UpdateDisplay(iFepEditX, iFepEditY, iFepEditDisplayLen); TRACE; }}// MCoeFepAwareTextEditor::DocumentLengthForFep()TInt CTerminalControl::DocumentLengthForFep() const { LFPRINT((_L("DocumentLengthForFep()"))); if ( iFepEditActive ) { LFPRINT((_L(" - returning %d"), iFepEditBuf.Length())); return iFepEditBuf.Length(); } else { LFPRINT((_L(" - returning 0 (not active)"), iFepEditBuf.Length())); return 0; }}// MCoeFepAwareTextEditor::DocumentMaximumLengthForFep()TInt CTerminalControl::DocumentMaximumLengthForFep() const { LFPRINT((_L("DocumentMaximumLengthForFep(), returning %d"), iFepEditBuf.MaxLength())); return iFepEditBuf.MaxLength();}// MCoeFepAwareTextEditor::SetCursorSelectionForFepL()void CTerminalControl::SetCursorSelectionForFepL( const TCursorSelection & /*aCursorSelection*/) { LFPRINT((_L("SetCursorSelectionForFepL()")));}// MCoeFepAwareTextEditor::GetCursorSelectionForFep()void CTerminalControl::GetCursorSelectionForFep( TCursorSelection& aCursorSelection) const { LFPRINT((_L("GetCursorSelectionForFepL()"))); if ( iFepEditActive ) { aCursorSelection.iAnchorPos = iFepCursorPos; aCursorSelection.iCursorPos = iFepCursorPos; } else { aCursorSelection.iAnchorPos = 0; aCursorSelection.iCursorPos = 0; }}// MCoeFepAwareTextEditor::GetEditorContentForFep()void CTerminalControl::GetEditorContentForFep( TDes &aEditorContent, TInt aDocumentPosition, TInt aLengthToRetrieve) const { LFPRINT((_L("GetEditorContentForFepL(des, %d, %d)"), aDocumentPosition, aLengthToRetrieve)); if ( iFepEditActive ) { if ( (aDocumentPosition == -1) && (aLengthToRetrieve == 1) ) { aEditorContent = _L(" "); LFPRINT((_L(" - Returning \" \""))); return; } if ( aDocumentPosition < 0 ) { aLengthToRetrieve += aDocumentPosition; aDocumentPosition = 0; } if ( aLengthToRetrieve <= 0 ) { aLengthToRetrieve = 0; aEditorContent.Zero(); LFPRINT((_L(" - Returning empty"))); return; } TInt bufLen = iFepEditBuf.Length(); if ( aDocumentPosition >= bufLen ) { aDocumentPosition = bufLen - 1; } if ( (aDocumentPosition + aLengthToRetrieve) > bufLen ) { aLengthToRetrieve = bufLen - aDocumentPosition; } aEditorContent = iFepEditBuf.Mid(aDocumentPosition, aLengthToRetrieve);#ifdef LOGFILE_ENABLED TBuf<128> buf; buf = _L(" - Returning {"); for ( TInt i = 0; i < aEditorContent.Length(); i++ ) { buf.AppendFormat(_L("0x%04x"), (TInt) aEditorContent[i]); if ( i < (aEditorContent.Length()-1) ) { buf.Append(_L(", ")); } } buf.Append(_L("}")); LFPRINT((buf));#endif } else { LFPRINT((_L(" - Not active, returning empty"))); aEditorContent.Zero(); }}// MCoeFepAwareTextEditor::GetFormatForFep()void CTerminalControl::GetFormatForFep(TCharFormat& /*aFormat*/, TInt /*aDocumentPosition*/) const { LFPRINT((_L("GetFormatForFep()")));}// MCoeFepAwareTextEditor::GetScreenCoordinatesForFepL()void CTerminalControl::GetScreenCoordinatesForFepL( TPoint& aLeftSideOfBaseLine, TInt& aHeight, TInt& aAscent, TInt /*aDocumentPosition*/) const { LFPRINT((_L("GetScreenCoordinatesForFepL()"))); aLeftSideOfBaseLine = TPoint(0,0); aHeight = 0; aAscent = 0; }// MCoeFepAwareTextEditor::DoCommitFepInlineEditL()void CTerminalControl::DoCommitFepInlineEditL() { LFPRINT((_L("DoCommitFepInlineEditL()"))); for ( TInt i = 0; i < iFepEditBuf.Length(); i++ ) { TText c = iFepEditBuf[i]; // S60 1.2 SDK sends Enter from the FEP by sending a 0xe125 character // (part of Unicode private use area). Presumably at least some S60 // v1 phones do that too. Nokia 6630 and probably other S60 v2.x // phones send 0x21b2 (Unicode arrow symbol, the same shown in // regular editors) in their FEP updates, but cancel the FEP edit // and just send an Enter keypress instead (to OfferKeyEventL()). // // To be on the safe side, we map both these codes and the Unicode // forced line feed to Enter here. FinalChar() maps those to 0x2028, // and the concrete terminal control must map that to a valid character // in the fonts available. if ( (c == 0x21b2) || (c == 0xe125) || (c == 0x2028) ) { c = (TText)EKeyEnter; } LFPRINT((_L(" - Sending 0x%04x"), (TInt) c)); iObserver.KeyPressed((TKeyCode)c, iNextKeyModifiers); } iNextKeyModifiers = 0; iFepEditActive = EFalse; TRACE; if ( (iFepEditX != -1) && (iFepEditY != -1) ) { TRACE; UpdateDisplay(iFepEditX, iFepEditY, iFepEditDisplayLen); TRACE; }}#ifdef PUTTY_S60// MCoeFepAwareTextEditor::Extension1()MCoeFepAwareTextEditor_Extension1 *CTerminalControl::Extension1(TBool &aSetToTrue) {// LFPRINT((_L("Extension1()"))); aSetToTrue = ETrue; return iFepExt1;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -