/* ------------ screen changing key strokes ------------- */ static void DoKeyStroke(WINDOW wnd, int c, PARAM p2) { switch (c) { case RUBOUT: if (wnd->CurrCol == 0 && wnd->CurrLine == 0) break; Backward(wnd); case DEL: DelKey(wnd); break; case SHIFT_HT: ShiftTabKey(wnd, p2); break; case '\t': TabKey(wnd, p2); break; case '\r': if (!isMultiLine(wnd)) { PostMessage(GetParent(wnd), KEYBOARD, c, p2); break; } c = '\n'; default: if (TextBlockMarked(wnd)) { SendMessage(wnd, COMMAND, ID_DELETETEXT, 0); SendMessage(wnd, PAINT, 0, 0); } KeyTyped(wnd, c); break; } }
BOOL TInifile::SetStr(const char *key, const char *val) { if (!val) return DelKey(key); return cur_sec ? cur_sec->AddKey(key, val) : FALSE; }
void CBaseCaret::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags, CView* pView) { UINT txi = m_xi * nRepCnt; UINT txs = m_xs * nRepCnt; DWORD tyi = m_yi * nRepCnt; DWORD tys = m_ys * nRepCnt; UINT OldXPos = m_XPosition; DWORD OldYPos = m_YPosition; int nomove = 0, comment = 0; UINT smaxx = m_maxx; DWORD smaxy = m_maxy; UINT sminx = m_minx; DWORD sminy = m_miny; char tChar; // Arange for clipping function if ( m_Clipping ) { /* m_maxx = m_ClipRect.BottomRight().x; m_maxy = m_ClipRect.BottomRight().y - m_CaretHeight; m_minx = m_ClipRect.TopLeft().x - 2; m_miny = m_ClipRect.TopLeft().y; */ m_maxx = m_ClipXPosition + m_ClipXSize; m_maxy = m_ClipYPosition + m_ClipYSize - m_CaretHeight; m_minx = m_ClipXPosition - 2; m_miny = m_ClipYPosition; } // Move m_Position based on char and max's switch ( nChar ) { case VK_UP: if ( (m_miny + tyi) <= m_YPosition ) { m_YPosition -= tyi; } break; case VK_DOWN: if ( (m_YPosition + tyi) < m_maxy ) { m_YPosition += tyi; } break; case VK_LEFT: if ( m_ControlOn ) { if ( (m_minx + txs) <= m_XPosition ) { m_XPosition -= txs; } else { while ( (m_minx + txi) <= m_XPosition ) { m_XPosition -= txi; } } } else { if ( (m_minx + txi) <= m_XPosition ) { m_XPosition -= txi; } } break; case VK_RIGHT: if ( m_ControlOn ) { if ( (m_XPosition + txs) < m_maxx ) { m_XPosition += txs; } else { while ( (m_XPosition + txi) < m_maxx ) { m_XPosition += txi; } } } else { if ( (m_XPosition + txi) < m_maxx ) { m_XPosition += txi; } } break; case VK_CONTROL: m_ControlOn = 1; nomove = 1; break; case VK_SHIFT: m_ShiftOn = 1; if ( !(nFlags & 0x4000) ) { LeftDown( m_XPosition, m_YPosition, pView ); } nomove = 1; break; case VK_END: if ( m_ControlOn ) { m_YPosition = m_maxy; } else { while ( (m_XPosition + txi) < m_maxx ) { m_XPosition += txi; } } break; case VK_HOME: if ( m_ControlOn ) { m_YPosition = m_miny; } else { while ( (m_minx + txi) <= m_XPosition ) { m_XPosition -= txi; } } break; case VK_NEXT: if ( (m_YPosition + tys) < m_maxy ) { m_YPosition += tys; } else { while ( (m_YPosition + tyi) < m_maxy ) { m_YPosition += tyi; } } break; case VK_PRIOR: if ( (m_miny + tys) <= m_YPosition ) { m_YPosition -= tys; } else { while ( (m_miny + tyi) <= m_YPosition ) { m_YPosition -= tyi; } } break; case VK_RETURN: if ( !m_ShiftOn ) { // Simulate Mouse double click calls. if ( m_ControlOn ) { RightDown( m_XPosition, m_YPosition, pView ); // RightUp( m_XPosition, m_YPosition, pView ); // Select( m_XPosition, m_YPosition, pView ); // RightUp( m_XPosition, m_YPosition, pView ); } else { LeftDown( m_XPosition, m_YPosition, pView ); LeftUp( m_XPosition, m_YPosition, pView ); // Select( m_XPosition, m_YPosition, pView ); // LeftUp( m_XPosition, m_YPosition, pView ); } } nomove = 1; break; case VK_INSERT: InsKey( m_XPosition, m_YPosition, pView); nomove = 1; break; case VK_DELETE: DelKey( m_XPosition, m_YPosition, pView); nomove = 1; break; default: // Here we going to test for alpha ... if ( isprint ( (tChar = MakeAscii(nChar, nFlags)) ) ) { comment = 1; } if ( tChar == 8 ) { if ( (m_minx + txi) < m_XPosition ) { m_XPosition -= txi; } } break; } // Undo clipping function if ( m_Clipping ) { m_maxx = smaxx; m_maxy = smaxy; m_minx = sminx; m_miny = sminy; } // Comment processing if ( comment ) { if ( Comment( tChar, m_XPosition, m_YPosition, pView ) ) { // Advance caret only if char taken if ( (m_XPosition + txi) < m_maxx ) { m_XPosition += txi; } } // return; } // Check if keystroke resulted in movement if ( !nomove ) { // For find again .. CGenedocDoc* pDoc = ((CGenedocView*)pView)->GetDocument(); ASSERT_VALID(pDoc); pDoc->m_pFS.PrevSeq = -1; // If selecting, then call move virtual function if ( m_ShiftOn ) { Move ( m_XPosition, m_YPosition, pView ); } // Check for screen scroll bars positions // CPoint tPos = m_Position; if ( (m_YPosition - m_ScrollYPosition + m_CaretHeight) >= m_ViewYSize && m_YPosition >= m_ScrollYPosition ) { if ( (m_YPosition + m_CaretHeight) > m_maxy ) { m_YPosition -= m_CaretHeight; m_ScrollYPosition = m_maxy - m_ViewYSize; } else { m_ScrollYPosition += m_YPosition - OldYPos; } ((CGenedocView*)pView)->ScrollToPosition ( m_ScrollXPosition, m_ScrollYPosition ); ((CGenedocView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition); } else if ( m_YPosition < m_ScrollYPosition ) { // Changed because of end at second to last line, then page up till error .. if ( OldYPos - m_YPosition > m_ScrollYPosition ) { m_ScrollYPosition = 0; } else { m_ScrollYPosition -= OldYPos - m_YPosition; } ((CGenedocView*)pView)->ScrollToPosition ( m_ScrollXPosition, m_ScrollYPosition ); ((CGenedocView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition); } else if ( m_XPosition - m_ScrollXPosition >= m_ViewXSize && m_XPosition >= m_ScrollXPosition ) { m_ScrollXPosition += m_XPosition - OldXPos; if ( m_XPosition + m_xi == m_maxx ) { m_ScrollXPosition += m_xi; } ((CGenedocView*)pView)->ScrollToPosition ( m_ScrollXPosition, m_ScrollYPosition ); ((CGenedocView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition); } else if ( m_XPosition < m_ScrollXPosition ) { if ( OldXPos - m_XPosition > m_ScrollXPosition ) { m_ScrollXPosition = 0; } else { m_ScrollXPosition -= OldXPos - m_XPosition; } ((CGenedocView*)pView)->ScrollToPosition ( m_ScrollXPosition, m_ScrollYPosition ); ((CGenedocView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition); } // Check if Scroll Call need to be made. // CRect tRect ( m_ScrollPos, m_ViewSize ); if ( !((m_XPosition >= m_ScrollXPosition && m_XPosition < (m_ScrollXPosition + m_ViewXSize)) && (m_YPosition >= m_ScrollYPosition && m_YPosition < (m_ScrollYPosition + m_ViewYSize))) ) { // CPoint tPos = m_ScrollPos; UINT tXPos = m_ScrollXPosition; DWORD tYPos = m_ScrollYPosition; UINT tX = 0; if ( m_maxx > m_ViewXSize ) tX = m_maxx - m_ViewXSize; DWORD tY = 0; if ( m_maxy > m_ViewYSize ) tY = m_maxy - m_ViewYSize; tYPos = m_YPosition < tY ? m_YPosition: tY; tXPos = m_XPosition < tX ? m_XPosition: tX; ((CGenedocView*)pView)->ScrollToPosition ( tXPos, tYPos ); ((CGenedocView*)pView)->GetScrollPosition( &m_ScrollXPosition, &m_ScrollYPosition); } // Set the caret to the current position CaretPos (); } { POSITION tPos = ((CGenedocView*)pView)->m_RowViewList.GetHeadPosition(); CGPRowView *tGP; while ( tPos != NULL ) { tGP = (CGPRowView *)((CGenedocView*)pView)->m_RowViewList.GetNext(tPos); if ( tGP->IsPointWithin( m_XPosition, m_YPosition ) ) { tGP->SetStatusBar(nFlags, m_XPosition, m_YPosition ); break; } } } }