Exemple #1
0
void CodeView::OnScrollPageDown(wxScrollWinEvent& event)
{
    int page;

    if (GetFirstLine() < static_cast<int>(m_CodeViewLine->GetCount() - m_linesShown))
    {
        page = line_info.cursorPosition;
        Scroll(-1, GetFirstLine() + m_linesShown);
        UpdateLastCursorRect();
        line_info.cursorLastPosition = GetLastLine();
        line_info.cursorPosition = line_info.cursorLastPosition;
        page = line_info.cursorPosition - page;
        if (page < static_cast<int>(m_linesShown))
            RefreshRect(*LastCursorRect);
    }
}
Exemple #2
0
long CMUSHclientDoc::SetScroll(long Position, BOOL Visible) 
{

CPoint pt (0, 0);
int lastline = GetLastLine ();
m_bScrollBarWanted = Visible;

  for(POSITION pos = GetFirstViewPosition(); pos != NULL; )
	  {
	  CView* pView = GetNextView(pos);
	  
	  if (pView->IsKindOf(RUNTIME_CLASS(CMUSHView)))
  	  {
		  CMUSHView* pmyView = (CMUSHView*)pView;

      int highest = (lastline * m_FontHeight) - pmyView->GetOutputWindowHeight ();

      // -1 goes to the end
      if (Position == -1)
        pt.y = highest; 
      else
        pt.y = Position;

      if (pt.y < 0)
        pt.y = 0;
      if (pt.y > highest)
        pt.y = highest;

      pmyView->EnableScrollBarCtrl (SB_VERT, Visible);
      if (Position != -2)      // if -2, do not change position
        pmyView->ScrollToPosition (pt, false);
      pmyView->Invalidate ();

	    }	  // end of being a CMUSHView
    }   // end of loop through views


	return eOK;
}   // end of CMUSHclientDoc::SetScroll
Exemple #3
0
// Event handler for Page up/down and direction keys
void CodeView::OnKeyPress(wxKeyEvent& event)
{
    int key;
    ProgramAddress address;
    key = event.GetKeyCode();

    wxCommandEvent evtMakeData(wxEVT_MENU, idPOPUP_MAKEDATA);
    wxCommandEvent evtDisassemble(wxEVT_MENU, idPOPUP_DISASM);
    wxScrollWinEvent evtLineDown(wxEVT_SCROLLWIN_LINEDOWN);
    wxScrollWinEvent evtLineUp(wxEVT_SCROLLWIN_LINEUP);
    wxScrollWinEvent evtPageDown(wxEVT_SCROLLWIN_PAGEDOWN);
    wxScrollWinEvent evtPageUp(wxEVT_SCROLLWIN_PAGEUP);

#define C_KEY   67
#define D_KEY   68

    switch (key)
    {
        case WXK_DOWN:
                        if (line_info.cursorPosition < static_cast<int>(m_CodeViewLine->GetCount() - 1))
                        {
                            if (!MultiSelection)
                                line_info.cursorLastPosition = line_info.cursorPosition;

                            line_info.cursorPosition++;

                            ClearCursor();
                            DoSelection();

                            if (line_info.cursorPosition > GetLastLine())
                                AddPendingEvent(evtLineDown);
                            else
                                RefreshRect(CalcCursorRfshRect());

                            if (line_info.selectedLineCount == 1)
                                TreatSingleSelection();
                            else
                                if (line_info.selectedLineCount > 1)
                                    TreatMultiSelection();

                            if (Selecting)
                                LogIt(wxString::Format("Selection = (%d, %d)", line_info.firstLine, line_info.lastLine));
                        }
                        break;
        case WXK_UP:
                        if (line_info.cursorPosition > 0)
                        {
                            if (!MultiSelection)
                                line_info.cursorLastPosition = line_info.cursorPosition;

                            line_info.cursorPosition--;

                            ClearCursor();
                            DoSelection();

                            if (line_info.cursorPosition < GetFirstLine())
                                AddPendingEvent(evtLineUp);
                            else
                                RefreshRect(CalcCursorRfshRect());

                            if (line_info.selectedLineCount == 1)
                                TreatSingleSelection();
                            else
                                if (line_info.selectedLineCount > 1)
                                    TreatMultiSelection();

                            if (Selecting)
                                LogIt(wxString::Format("Selection = (%d, %d)", line_info.firstLine, line_info.lastLine));
                        }
                        break;
        case WXK_NUMPAD_PAGEDOWN:
        case WXK_PAGEDOWN:
                        AddPendingEvent(evtPageDown);
                        break;
        case WXK_NUMPAD_PAGEUP:
        case WXK_PAGEUP:
                        AddPendingEvent(evtPageUp);
                        break;
        case WXK_SHIFT:
                        if (!Selecting)
							Selecting = true;
                        MultiSelection = true;
                        break;
        case C_KEY:
                        AddPendingEvent(evtDisassemble);
                        break;
        case D_KEY:
                        AddPendingEvent(evtMakeData);
                        break;
        case WXK_F3:
                        if (Process->SearchInstructionArgumentContinue(address))
                        {
                            CenterAddress(address);
                        }

                        LogIt("F3 Key pressed !");
                        break;

        default:
                        LogIt(wxString::Format("%X pressed !",key));
                        event.Skip();
    }
}
Exemple #4
0
/*
** View the source for the lines specified.
*/
int CommandView(char **ptrs)
{
DebugModule    *module;
char	       *srcEnd;
ULONG		addr;
ULONG		lineNum;
char		funcName[MAX_FUNCNAME];
char		sourceName[CCHMAXPATH];

    /*
    ** Get the common data.
    */
    module = FindModule(debugBuffer.MTE, NULL);
    FindSource(module, Linearize(debugBuffer.EIP, debugBuffer.CS),
	       funcName, sourceName, &lineNum);

    /*
    ** View the next lines to be displayed.
    */
    if(ptrs[2] == NULL) {
	DisplaySource(module, sourceName, GetLastLine(module) + 5);
	return -1;
    }

    /*
    ** View a line.
    */
    if(ptrs[2][0] == '.') {

	/*
	** Find the line number or the file name/line number
	*/
	if(isdigit(ptrs[2][1])) {
	    lineNum = atol(&ptrs[2][1]);
	} else {
	    strcpy(sourceName, &ptrs[2][1]);
	    *strrchr(sourceName, ':') = 0;
	    lineNum = atol(strrchr(ptrs[2], ':') + 1);
	}
	DisplaySource(module, sourceName, lineNum);
	return -1;
    }

    /*
    ** Get a view at a given offset.
    */
    if(isxdigit(ptrs[2][0])) {
	/*
	** Find the module associated with the address specified.
	*/
	debugBuffer.Addr = addr = StrToAddr(ptrs[2], TOADDR_CODE);
	DispatchCommand(DBG_C_AddrToObject);

	/*
	** Find the module/source associated with the information given.
	*/
	module = FindModule(debugBuffer.MTE, NULL);
	FindSource(NULL, addr, funcName, sourceName, &lineNum);
	DisplaySource(module, sourceName, lineNum);
	return -1;
    }

    /*
    ** ERROR!
    */
    fprintf(logFile, "Invalid syntax\n");
    return -1;
}
/*------------------------------------------------------------------------
Procedure:     SubClassEdit ID:1
Purpose:       Handles messages to the editbox
Input:         
Output:        
Errors:
--------------------------------------------------------------------------
Edit History:
	14 Sept 2003 - Chris Watford [email protected]
		- Setup handler for up and down arrows
	15 Sept 2003 - Chris Watford [email protected]
		- Setup framework for history on up arrow
		- Saves lines you move off of in the edit buffer
	16 Sept 2003 - Chris Watford [email protected]
		- Proper handling of newline message finished
		- Fixed ENTER on middle of interior line, moves cursor to the end
		  and sends the line
		- Setup the copying and destroying of the old buffer
		- Included buffer rewrite
	17 Sept 2003 - Chris Watford [email protected]
		- Added C-p/C-n support
		- Changed UpArrow to C-UpArrow so as to not confuse users
	18 Sept 2003 - Chris Watford [email protected]
		- Added Left and Right arrow line saving
		- Added backspace and delete line saving and removing
		- Fixed history scrolling
	21 Sept 2003 - Chris Watford [email protected]
		- Fixed pasting errors associated with lines being out of bounds
		  for the buffer
		- Added error handling, possibly able to handle it diff down the
		  line
		- Removed C-Up/C-Dn for history scrolling, buggy at best on my
		  machine
------------------------------------------------------------------------*/
static LRESULT CALLBACK SubClassEdit(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
{
	LRESULT r;
	int postit=0,nl;

	if (msg == WM_CHAR && mp1 == '\r') {
		if (!busy) {
			r =  GetCurLineIndex(hwnd);
			nl = GetNumberOfLines(hwnd);

			// if we're not the last line
			if (r != nl-1)
			{
				// update or add us, we might not have any lines in the edit buffer
				editbuffer_updateoraddline(CurrentEditBuffer, r-LastPromptPosition.line, GetLastLine(hwnd));

				// scroll to the end, add CrLf then post the newline message
				GotoEOF();
				AddStringToControl("\r\n");
				PostMessage(GetParent(hwnd),WM_NEWLINE,0,0);
				return 0;
			}

			CallWindowProc(lpEProc,hwnd,WM_KEYDOWN,VK_END,1);
			CallWindowProc(lpEProc,hwnd,WM_KEYUP,VK_END,1);

			postit = 1;
		}

	}
	else if (msg == WM_CHAR && mp1 == (char)0x08) {
		int lineindex = SendMessage(hwnd, EM_LINEINDEX, LastPromptPosition.line, 0) + 2;
		int curline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)-1,0);
		int nextline = 0;
		int curpoint = 0;

		SendMessage(hwnd, EM_GETSEL, (WPARAM)&curpoint, (LPARAM)NULL); 
		nextline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)(curpoint - 1),0);

		if(curpoint <= lineindex)
		{
			return 0;
		} else if(nextline != curline) {
			// delete the line we're on

			// grab the index
			curline -= LastPromptPosition.line;

			// kill it
			editbuffer_removeline(CurrentEditBuffer, curline);
		}
	}
	else if (msg == WM_KEYDOWN && mp1 == VK_F1) {
		DoHelp(hwnd);
	}
	else if ((msg == WM_KEYDOWN || msg == WM_KEYUP) && mp1 == VK_UP) {
		int curline = GetCurLineIndex(hwnd);

		/*if((msg == WM_KEYDOWN) && (GetKeyState(VK_CONTROL) && 0x8000))
		{	// go forward once in history
			NextHistoryEntry();
			return 0;
		} else */
		if((curline > LastPromptPosition.line) && (curline <= (LastPromptPosition.line + CurrentEditBuffer->LineCount)))
		{
			// update current line
			if (msg == WM_KEYDOWN)
			{
				int lineidx = (curline - LastPromptPosition.line);

				CallWindowProc(lpEProc,hwnd,WM_KEYDOWN,VK_END,1);
				CallWindowProc(lpEProc,hwnd,WM_KEYUP,VK_END,1);
				
				// we may have to add this line, otherwise update it
				editbuffer_updateoraddline(CurrentEditBuffer, lineidx, GetLastLine(hwnd));
			}
		} else {
			return 0;
		}
	}
	else if ((msg == WM_KEYDOWN || msg == WM_KEYUP) && (mp1 == VK_LEFT)) {
		int lineindex = SendMessage(hwnd, EM_LINEINDEX, LastPromptPosition.line, 0) + 2;
		int curline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)-1,0);
		int nextline = 0;
		int curpoint = 0;

		SendMessage(hwnd, EM_GETSEL, (WPARAM)&curpoint, (LPARAM)NULL); 
		nextline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)(curpoint - 1),0);

		if(curpoint <= lineindex)
		{	// no left arrow to the left of the prompt
			return 0;
		} else if(nextline != curline) {
			// update current line
			if (msg == WM_KEYDOWN)
			{
				int lineidx = (curline - LastPromptPosition.line);

				CallWindowProc(lpEProc,hwnd,WM_KEYDOWN,VK_END,1);
				CallWindowProc(lpEProc,hwnd,WM_KEYUP,VK_END,1);
				
				// we may have to add this line, otherwise update it
				editbuffer_updateoraddline(CurrentEditBuffer, lineidx, GetLastLine(hwnd));

				CallWindowProc(lpEProc,hwnd,WM_KEYDOWN,VK_HOME,1);
				CallWindowProc(lpEProc,hwnd,WM_KEYUP,VK_HOME,1);
			}
		}
	}
	else if ((msg == WM_KEYDOWN || msg == WM_KEYUP) && (mp1 == VK_DOWN)) {
		int curline = GetCurLineIndex(hwnd);
		
		/*if((msg == WM_KEYDOWN) && (GetKeyState(VK_CONTROL) && 0x8000))
		{	// go back once in history
			PrevHistoryEntry();
			return 0;
		} else*/
		if((curline >= LastPromptPosition.line) && (curline < (LastPromptPosition.line + CurrentEditBuffer->LineCount)))
		{
			// We don't post the newline, but instead update the current line
			if (msg == WM_KEYDOWN)
			{
				int lineidx = (curline - LastPromptPosition.line);

				CallWindowProc(lpEProc,hwnd,WM_KEYDOWN,VK_END,1);
				CallWindowProc(lpEProc,hwnd,WM_KEYUP,VK_END,1);
				
				editbuffer_updateline(CurrentEditBuffer, lineidx, GetLastLine(hwnd));
			}
		} else {
			return 0;
		}
	}
	else if ((msg == WM_KEYDOWN || msg == WM_KEYUP) && (mp1 == VK_RIGHT)) {
		int lineindex = SendMessage(hwnd, EM_LINEINDEX, LastPromptPosition.line, 0) + 1;
		int curline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)-1,0);
		int nextline = 0;
		int curpoint = 0;

		SendMessage(hwnd, EM_GETSEL, (WPARAM)&curpoint, (LPARAM)NULL); 
		nextline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)(curpoint + 2),0);

		if(curpoint <= lineindex)
		{	// no movement behind the prompt
			return 0;
		} else if((nextline != curline) && (msg = WM_KEYDOWN)) {
			int lineidx = (curline - LastPromptPosition.line);

			CallWindowProc(lpEProc,hwnd,WM_KEYDOWN,VK_END,1);
			CallWindowProc(lpEProc,hwnd,WM_KEYUP,VK_END,1);
			
			editbuffer_updateline(CurrentEditBuffer, lineidx, GetLastLine(hwnd));
		}
	}
	else if ((msg == WM_KEYDOWN) && (mp1 == VK_PRIOR) && (GetKeyState(VK_CONTROL) && 0x8000)) {
		// C-p
		NextHistoryEntry();
		return 0;
	}
	else if ((msg == WM_KEYDOWN) && (mp1 == VK_NEXT) && (GetKeyState(VK_CONTROL) && 0x8000)) {
		// C-n
		PrevHistoryEntry();
		return 0;
	}
	else if ((msg == WM_KEYDOWN || msg == WM_KEYUP) && (mp1 == VK_DELETE)) {
		// see if we're the last char on the line, if so delete the next line
		// don't allow deleting left of the prompt
		int lineindex = SendMessage(hwnd, EM_LINEINDEX, LastPromptPosition.line, 0) + 2;
		int curline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)-1,0);
		int nextline = 0;
		int curpoint = 0;

		SendMessage(hwnd, EM_GETSEL, (WPARAM)&curpoint, (LPARAM)NULL); 
		nextline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)(curpoint + 2),0);

		if(curpoint < lineindex)
		{	// no chomping behind the prompt
			return 0;
		} else if(nextline != curline) {
			// deleting
			// grab the next line index
			curline -= LastPromptPosition.line;

			// kill it
			editbuffer_removeline(CurrentEditBuffer, curline+1);
		}
	}
	else if (msg == WM_PASTE) {
		// if they paste text, allow it
		r = CallWindowProc(lpEProc, hwnd, msg, mp1, mp2);

		// update the current edit buffer
		RefreshCurrentEditBuffer();

		return r;
	}

	// handle errors
	switch(msg)
	{
		case WM_SYNTAXERROR:
		case WM_ILLEGALCHAR:
		case WM_UNBOUNDVAL:
			{	// currently I handle them all the same
				// get the start of the line
				int start = SendMessage(hwnd, EM_LINEINDEX, LastPromptPosition.line, 0) + 2;

				// get the statement that error'd
				NextHistoryEntry();

				// tell the history that the last line errored
				if(History != NULL)
					if(History->Statement != NULL)
						History->Statement->isCorrect = FALSE;

				// highlight the offending chars
				SendMessage(hwnd,EM_SETSEL,(WPARAM)(start + mp1), (LPARAM)(start + mp2));
				
				return 0;
			}
	}

	r = CallWindowProc(lpEProc, hwnd, msg, mp1, mp2);

	if (postit)
		PostMessage(GetParent(hwnd),WM_NEWLINE,0,0);

	return r;
}