Пример #1
0
void ScrollViewDown( LPCLASSDATA lpcd )
{
	/*
	 *	Are we there already?
	 */
	if ( lpcd->ptViewPos.y > 0 )
	{
		/*
		 *	Go up one.
		 */
		lpcd->ptViewPos.y--;
		VScroll( lpcd, 1 );

		/*
		 *	Setup the scroller.
		 */
		SetupVScroller( lpcd );

		/*
		 *	Caret OK?
		 */
		if ( lpcd->ptCaretPos.y > ( lpcd->ptViewPos.y + lpcd->szViewSize.cy - 1 ))
		{
			/*
			 *	Make it visible.
			 */
			lpcd->ptCaretPos.y = lpcd->ptViewPos.y + lpcd->szViewSize.cy - 1;
			lpcd->ptCaretPos.x = lpcd->nLastColumnPos = 0;
			UpdateCaret( lpcd );
		}
	}
}
Пример #2
0
void ScrollViewUp( LPCLASSDATA lpcd )
{
	int	nLines = ArrayGetSize( lpcd->lpLines ) - 1;

	/*
	 *	Are we there already?
	 */
	if (( lpcd->ptViewPos.y + lpcd->szViewSize.cy - 1 ) < nLines )
	{
		/*
		 *	Go down one.
		 */
		lpcd->ptViewPos.y++;
		VScroll( lpcd, -1 );

		/*
		 *	Setup the scroller.
		 */
		SetupVScroller( lpcd );

		/*
		 *	Caret OK?
		 */
		if ( lpcd->ptCaretPos.y < lpcd->ptViewPos.y )
		{
			/*
			 *	Make it visible.
			 */
			lpcd->ptCaretPos.y = lpcd->ptViewPos.y;
			lpcd->ptCaretPos.x = lpcd->nLastColumnPos = 0;
			UpdateCaret( lpcd );
		}
	}
}
Пример #3
0
static void MoveEol( LPCLASSDATA lpcd )
{
	/*
	 *	Are we already there?
	 */
	if ( lpcd->ptCaretPos.x < GETLINE( lpcd )->nLength )
	{
		/*
		 *	No, move to the end.
		 */
		lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;

		/*
		 *	Save this position.
		 */
		lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );
	}

	/*
	 *	Make sure the care is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}
Пример #4
0
static void MoveHome( LPCLASSDATA lpcd )
{
	/*
	 *	Are we already there?
	 */
	if ( lpcd->ptCaretPos.x > 0 || lpcd->ptCaretPos.y > 0 )
	{
		/*
		 *	No. Put us there.
		 */
		lpcd->ptCaretPos.x = lpcd->ptCaretPos.y = 0;

		/*
		 *	Save this position.
		 */
		lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

		/*
		 *	Make sure the care is in the view.
		 */
		MakeCaretVisible( lpcd );

		/*
		 *	Update caret position.
		 */
		UpdateCaret( lpcd );
	}
}
Пример #5
0
void CaretLeft( LPCLASSDATA lpcd )
{
	/*
	 *	Do we have a block marker?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Move to the start of the block.
		 */
		lpcd->ptCaretPos = lpcd->ptSelStart;

		/*
		 *	Clear the marker.
		 */
		ClearMark( lpcd );

		/*
		 *	Update position.
		 */
		UpdateCaret( lpcd );
		return;
	}
	/*
	 *	Move left....
	 */
	MoveLeft( lpcd );
}
Пример #6
0
void CaretRight( LPCLASSDATA lpcd )
{
	/*
	 *	Block marker set?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Move to the end of the marker.
		 */
		lpcd->ptCaretPos = lpcd->ptSelEnd;

		/*
		 *	Clear marker.
		 */
		ClearMark( lpcd );

		/*
		 *	Update position.
		 */
		UpdateCaret( lpcd );
		return;
	}
	/*
	 *	Move the caret right.
	 */
	MoveRight( lpcd );
}
Пример #7
0
static void MoveUp( LPCLASSDATA lpcd )
{
	/*
	 *	Caret at the first line?
	 */
	if ( lpcd->ptCaretPos.y > 0 )
        {
		/*
		 *	Fast scrolling?
		 */
		if ( Parser->bFastScroll && lpcd->bRepeatMode )
		{
			/* 
			 *	Are we at the top of the view?
			 */
			if ( lpcd->ptCaretPos.y == lpcd->ptViewPos.y )
				/*
				 *	Setup new position.
				 */
				lpcd->ptCaretPos.y = max( lpcd->ptCaretPos.y - 2, 0 );
			else
				/*
				 *	One line up.
				 */
				 lpcd->ptCaretPos.y--;
		}
		else
			/*
			 *	Go one up.
			 */
			lpcd->ptCaretPos.y--;

                /*
		 *	Try to locate the caret as close to the
		 *	last column position as possible since
                 *	the user changed the column.
		 */
		lpcd->ptCaretPos.x = GetTextOffset( lpcd,  lpcd->nLastColumnPos );

                /*
		 *	Are we passed the end?
		 */
                if ( lpcd->ptCaretPos.x > GETLINE( lpcd )->nLength )
	                /*
			 *	Set us at the end.
			 */
			lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;
	}

        /*
	 *	Make sure the care is in the view.
	 */
        MakeCaretVisible( lpcd );

        /*
	 *	Update caret position.
	 */
        UpdateCaret( lpcd );
}
Пример #8
0
void SHotKeyCtrl::SetHotKey( WORD vKey,WORD wModifiers )
{
    m_wVK=vKey;
    m_wModifier=wModifiers;
    UpdateModifier();
    UpdateCaret();
    Invalidate();
}
Пример #9
0
void SHotKeyCtrl::OnKeyUp( UINT nChar, UINT nRepCnt, UINT nFlags )
{
    if(!m_bInSetting) return;

    if(nChar == m_wVK)
    {
        m_bInSetting=FALSE;
    }
    else if(m_wVK==0 && (GetKeyState(VK_SHIFT)&0x8000)==0 && (GetKeyState(VK_MENU)&0x8000)==0 && (GetKeyState(VK_CONTROL)&0x8000)==0)
    {
        m_bInSetting=FALSE;
        UpdateModifier();
        UpdateCaret();
        Invalidate();
    }
    else if(nChar==VK_SHIFT || nChar==VK_MENU || nChar== VK_CONTROL)
    {
        UpdateModifier();
        UpdateCaret();
        Invalidate();
    }
}
Пример #10
0
void CreateTheCaret( LPCLASSDATA lpcd )
{
	int	cx, cy;

	/*
	 *	Make sure the character size is
	 *	present.
	 */
	GetCharSize( NULL, lpcd );

	/*
	 *	Setup caret height.
	 */
	cy = Parser->szCharSize.cy;

	/*
	 *	When in insert mode we switch to the
	 *	block style caret.
	 */
	if ( lpcd->bOverwrite ) cx = Parser->szCharSize.cx;
	else
	{
		/*
		 *	Default width.
		 */
		cx = GetSystemMetrics( SM_CXBORDER );

		/*
		 *	What type of caret?
		 */
		if (      Parser->nCaretType == CARET_WIDE  )  cx *= 2;
		else if ( Parser->nCaretType == CARET_BLOCK ) cx = Parser->szCharSize.cx;
		else if ( Parser->nCaretType == CARET_HORIZONTAL )
		{
			cx = Parser->szCharSize.cx;
			cy = GetSystemMetrics( SM_CYBORDER ) * 2;
		}
	}

	/* 
	 *	Create and update the caret.
	 */
	CreateCaret( lpcd->hWnd, NULL, cx, cy );
	UpdateCaret( lpcd );
}
Пример #11
0
void SHotKeyCtrl::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
{
    if(!m_bInSetting)
    {
        m_bInSetting=TRUE;
        m_wVK=0;
        m_wModifier=m_wInvalidModifier;
    }
    SStringT strKey=GetKeyName(nChar);
    if(!strKey.IsEmpty())
    {
        //
        m_wVK=nChar;
    }
    UpdateModifier();
    UpdateCaret();
    Invalidate();
}
Пример #12
0
void SHotKeyCtrl::OnSetFocus()
{
    IRenderTarget *pRT=GetRenderTarget(NULL,OLEDC_NODRAW);
    CAutoRefPtr<IFont> oldFont;
    pRT->SelectObject(m_curFont,(IRenderObj**)&oldFont);
    SIZE szTxt;
    pRT->MeasureText(_T("A"),1,&szTxt);
    pRT->SelectObject(oldFont);
    ReleaseRenderTarget(pRT);
    GetContainer()->SwndCreateCaret(NULL,1,szTxt.cy);

    CRect rcClient;
    GetClientRect(&rcClient);
    OnSetCaretValidateRect(&rcClient);

    UpdateCaret();
    GetContainer()->SwndShowCaret(TRUE);
}
Пример #13
0
static void MoveLeft( LPCLASSDATA lpcd )
{
        /*
	 *	Caret at the start of the line?
	 */
	if ( lpcd->ptCaretPos.x == 0 )
        {
	        /*
		 *	Yes. Are we at the first line?
		 */
	        if ( lpcd->ptCaretPos.y > 0 )
		{
                        /*
			 *	Go up one.
			 */
			lpcd->ptCaretPos.y--;

                        /*
			 *	Go to the end of the line.
			 */
			lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;
                }
	}
	else
	        /*
		 *	One left.
		 */
	        lpcd->ptCaretPos.x--;

        /*
	 *	Save off this position.
	 */
        lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

        /*
	 *	Make sure the care is in the view.
	 */
        MakeCaretVisible( lpcd );

        /*
	 *	Update caret position.
	 */
        UpdateCaret( lpcd );
}
Пример #14
0
static void MoveSol( LPCLASSDATA lpcd )
{
	int nFirst = 0;
	LPLINE pLine = GETLINE( lpcd );

	/*
	 *	Any characters on the line?
	 */
	if ( pLine->nLength == 0 ) return;

	/*
	 *	Find first character offset.
	 */
	while ( nFirst < pLine->nLength && _istspace( pLine->pcText[ nFirst ] ) ) nFirst++;

	/*
	 *	Are we already there?
	 */
	if ( lpcd->ptCaretPos.x > 0 && lpcd->ptCaretPos.x <= nFirst )
		/*
		 *	No, move to the start.
		 */
		lpcd->ptCaretPos.x = 0;
	else
		/*
		 *	No, move to the start.
		 */
		lpcd->ptCaretPos.x = nFirst;

	/*
	 *	Save this position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Make sure the care is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}
Пример #15
0
static void MoveTabBack( LPCLASSDATA lpcd )
{
	int	nScreenPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x ), nPos;

	/*
	 *	Are we at the start of the line?
	 */
	if ( lpcd->ptCaretPos.x == 0 )
		return;

	/*
	 *	Compute the number of characters we are
	 *	right of a tab-stop.
	 */
	nPos = nScreenPos % Parser->nTabSize;

	/*
	 *	Go left the amount of position computed above
	 *	or a whole tab-stop.
	 */
	nPos = nScreenPos - ( nPos ? nPos : Parser->nTabSize );

	/*
	 *	Position the caret.
	 */
	lpcd->ptCaretPos.x = GetTextOffset( lpcd, nPos );

	/*
	 *	Save this position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Make sure the care is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}
Пример #16
0
static void MoveRight( LPCLASSDATA lpcd )
{
        /*
	 *	Caret at the end of the line?
	 */
	if ( lpcd->ptCaretPos.x == GETLINE( lpcd )->nLength )
        {
	        /*
		 *	Yes. Are we at the last line?
		 */
                if ( lpcd->ptCaretPos.y < ArrayGetSize( lpcd->lpLines ) - 1 )
	        {
		        /*
			 *	Go down one.
			 */
		        lpcd->ptCaretPos.y++;
			lpcd->ptCaretPos.x = 0;
                }
	}
	else
	        /*
		 *	One right.
		 */
	        lpcd->ptCaretPos.x++;

        /*
	 *	Save off this position.
	 */
        lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

        /*
	 *	Make sure the caret is in the view.
	 */
        MakeCaretVisible( lpcd );

        /*
	 *	Update caret position.
         */
	UpdateCaret( lpcd );
}
Пример #17
0
static void MoveEnd( LPCLASSDATA lpcd )
{
	/*
	 *	Are we there yet?
	 */
	if ( lpcd->ptCaretPos.y == ArrayGetSize( lpcd->lpLines ) - 1 && lpcd->ptCaretPos.x == GETLINE( lpcd )->nLength )
		/*
		 *	Yes.
		 */
		return;

	/*
	 *	Put us on the last line.
	 */
	lpcd->ptCaretPos.y = ArrayGetSize( lpcd->lpLines ) - 1;

	/*
	 *	Move us to the end.
	 */
	//lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;   // Modified by Stephan (2005-06-08): Don't jump to the end of the line
  lpcd->ptCaretPos.x = 0;

	/*
	 *	Save this position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Make sure the care is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}
Пример #18
0
void ScrollViewRight( LPCLASSDATA lpcd )
{
	/*
	 *	Are we there already?
	 */
	if ( lpcd->ptViewPos.x > 0 )
	{
		/*
		 *	Go left one.
		 */
		lpcd->ptViewPos.x--;
		InvalidateRect( lpcd->hWnd, NULL, FALSE );

		/*
		 *	Setup the scroller.
		 */
		SetupHScroller( lpcd );

		/*
		 *	Update the caret.
		 */
		UpdateCaret( lpcd );
	}
}
Пример #19
0
void ScrollViewLeft( LPCLASSDATA lpcd )
{
	/*
	 *	Are we there already?
	 */
	if (( lpcd->ptViewPos.x + lpcd->szViewSize.cx - 1 ) < lpcd->nLongestLine )
	{
		/*
		 *	Go right one.
		 */
		lpcd->ptViewPos.x++;
		InvalidateRect( lpcd->hWnd, NULL, FALSE );

		/*
		 *	Setup the scroller.
		 */
		SetupHScroller( lpcd );

		/*
		 *	Update the caret.
		 */
		UpdateCaret( lpcd );
	}
}
Пример #20
0
static void MoveNextWord( LPCLASSDATA lpcd )
{
	/*
	 *	Obtain current caret column and a
	 *	pointer to the line.
	 */
	int	nPos = lpcd->ptCaretPos.x;
	LPLINE	lpLine = GETLINE( lpcd );

	/*
	 *	Are we at the end of the line?
	 */
	if ( nPos == lpLine->nLength )
	{
		/*
		 *	Yes go down one line and to the
		 *	first word on that line.
		 */
		if ( lpcd->ptCaretPos.y < ArrayGetSize( lpcd->lpLines ) - 1 )
		{
			/*
			 *	Start at 0
			 */
			nPos = 0;

			/*
			 *	Go down.
			 */
			lpcd->ptCaretPos.y++;

			/*
			 *	Skip spaces.
			 */
			lpLine = GETLINE( lpcd );

			if ( lpLine->pcText )
			{
				while ( _istspace( lpLine->pcText[ nPos ] ) && nPos < GETLINE( lpcd )->nLength )
					nPos++;
			}

			/*
			 *	Store new column position.
			 */
			lpcd->ptCaretPos.x = nPos;
		}
	}
	else
	{
		BOOL	bBreakOnNonSpace = FALSE;

		/*
		 *	Are we on a white space?
		 */
		if ( _istspace( lpLine->pcText[ nPos ] ))
		{
			/*
			 *	Skip spaces...
			 */
			while ( _istspace( lpLine->pcText[ nPos ] ) && nPos < lpLine->nLength )
				nPos++;
		}
		else if ( IsDelimiter( lpcd, lpLine->pcText [ nPos ] )) /* A delimiter? */
		{
			/*
			 *	Skip all delimiters and white spaces.
			 */
			while (( IsDelimiter( lpcd, lpLine->pcText[ nPos ] ) || _istspace( lpLine->pcText[ nPos ] )) && nPos < lpLine->nLength )
			{
				/*
				 *	White space?
				 */
				if ( _istspace( lpLine->pcText[ nPos ] ))
					/*
					 *	Yes. Break on the next non-white space.
					 */
					bBreakOnNonSpace = TRUE;
				else if ( bBreakOnNonSpace )
					/*
					 *	Stop at this non-white space.
					 */
					break;
				nPos++;
			}
		}
		else
		{
			/*
			 *	Skip all non delimiters and white spaces.
			 */
			while (( IsDelimiter( lpcd, lpLine->pcText[ nPos ] ) == FALSE || _istspace( lpLine->pcText[ nPos ] )) && nPos < lpLine->nLength )
			{
				/*
				 *	White space?
				 */
				if ( _istspace( lpLine->pcText[ nPos ] ))
					/*
					 *	Yes. Break on the next non-white space.
					 */
					bBreakOnNonSpace = TRUE;
				else if ( bBreakOnNonSpace )
					/*
					 *	Stop at this non-white space.
					 */
					break;
				nPos++;
			}
		}

		/*
		 *	Store position.
		 */
		lpcd->ptCaretPos.x = nPos;
	}

	/*
	 *	Save this position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Make sure the caret is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}
Пример #21
0
static void MoveDown( LPCLASSDATA lpcd )
{
	/*
	 *	Caret at the last line?
	 */
	if ( lpcd->ptCaretPos.y < ArrayGetSize( lpcd->lpLines ) - 1 )
	{
		/*
		 *	Fast scrolling?
		 */
		if ( Parser->bFastScroll && lpcd->bRepeatMode )
		{
			/* 
			 *	Are we at the top of the view?
			 */
			if ( lpcd->ptCaretPos.y == ( lpcd->ptViewPos.y + lpcd->szViewSize.cy - 1 ))
				/*
				 *	Setup new position.
				 */
				lpcd->ptCaretPos.y = min( lpcd->ptCaretPos.y + 2, ArrayGetSize( lpcd->lpLines ) - 1 );
			else
				/*
				 *	One line up.
				 */
				 lpcd->ptCaretPos.y++;
		}
		else
			/*
			 *	Go one down.
			 */
			lpcd->ptCaretPos.y++;

                /*
		 *	Try to locate the cursor as close to the
		 *	last column position as possible since
                 *	the user changed the column.
		 */
		lpcd->ptCaretPos.x = GetTextOffset( lpcd, lpcd->nLastColumnPos );

		/*
		 *	Are we passed the end?
		 */
                if ( lpcd->ptCaretPos.x > GETLINE( lpcd )->nLength )
	                /*
			 *	Set us at the end.
			 */
                        lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;
        }
	else
	{
		/*
		 *	Caret at the end of the line?
		 */
    // Modified by Stephan (2005-06-08): Don't jump to end of line
		//if ( lpcd->ptCaretPos.x < GETLINE( lpcd )->nLength )
			//lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;
	}

        /*
	 *	Make sure the care is in the view.
	 */
        MakeCaretVisible( lpcd );

        /*
	 *	Update caret position.
	 */
        UpdateCaret( lpcd );
}
Пример #22
0
void VikeWin::ChangeMode(VikeMode new_mode, wxScintilla *editor)
{
    m_iMode = new_mode;
    UpdateCaret(editor);
    UpdateStatusBar();
}
Пример #23
0
static void MovePrevWord( LPCLASSDATA lpcd )
{
	/*
	 *	Obtain current caret column and
	 *	the line were on.
	 */
	int	nPos = lpcd->ptCaretPos.x;
	LPLINE	lpLine = GETLINE( lpcd );

	/*
	 *	Are we at the start of the line?
	 */
	if ( nPos == 0 )
	{
		/*
		 *	Yes go down one line and to the
		 *	end of that line.
		 */
		if ( lpcd->ptCaretPos.y > 0 )
		{
			/*
			 *	Go up.
			 */
			lpcd->ptCaretPos.y--;

			/*
			 *	Put the caret at the end.
			 */
			lpcd->ptCaretPos.x = GETLINE( lpcd )->nLength;

			if ( lpcd->ptCaretPos.x )
				/*
				 *	Recursivly call ourselves.
				 */
				MovePrevWord( lpcd );
		}
	}
	else
	{
		/*
		 *	Previous character.
		 */
		nPos--;

		/*
		 *	Are we on a white space?
		 */
		if ( _istspace( lpLine->pcText[ nPos ] ))
		{
			/*
			 *	Skip spaces...
			 */
			while ( _istspace( lpLine->pcText[ nPos ] ) && nPos )
				nPos--;
		}

		/*
		 *	Start of the line?
		 */
		if ( nPos )
		{
			/*
			 *	Did we reach a delimiter?
			 */
			if ( IsDelimiter( lpcd, lpLine->pcText[ nPos ] )) /* A delimiter? */
			{
				/*
				 *	Skip all delimiters.
				 */
				while ( IsDelimiter( lpcd, lpLine->pcText[ nPos ] ))
				{
					/*
					 *	White space?
					 */
					if ( _istspace( lpLine->pcText[ nPos ] ))
						break;

					/*
					 *	Start of the line?
					 */
					if ( nPos == 0 )
					{
						/*
						 *	Will force the caret at position 0
						 */
						nPos = -1;
						break;
					}
					nPos--;
				}
				nPos++;
			}
			else
			{
				/*
				 *	Skip all non delimiters.
				 */
				while ( IsDelimiter( lpcd, lpLine->pcText[ nPos ] ) == FALSE )
				{
					/*
					 *	White space?
					 */
					if ( _istspace( lpLine->pcText[ nPos ] ))
						break;

					/*
					 *	Start of the line
					 */
					if ( nPos == 0 )
					{
						/*
						 *	Will force the caret at position 0
						 */
						nPos = -1;
						break;
					}
					nPos--;
				}
				nPos++;
			}
		}

		/*
		 *	Store position.
		 */
		lpcd->ptCaretPos.x = nPos;
	}

	/*
	 *	Save this position.
	 */
	lpcd->nLastColumnPos = GetCaretOffset( lpcd, lpcd->ptCaretPos.x );

	/*
	 *	Make sure the care is in the view.
	 */
	MakeCaretVisible( lpcd );

	/*
	 *	Update caret position.
	 */
	UpdateCaret( lpcd );
}