?? editor_output.c
字號:
/****************************************************************************** * * Copyright (c) 2003 Gerhard W. Gruber * * PROJECT: pICE * $Source: /cvsroot/pice/pice/module/editor_output.c,v $ * $Revision: 1.3 $ * $Date: 2004/02/17 23:07:36 $ * $Author: lightweave $ * $Name: $ * * $Log: editor_output.c,v $ * Revision 1.3 2004/02/17 23:07:36 lightweave * * Improved the DEBUG facillity and replaced the configuration handler with a * new code which now can read MS Windows INI style files. See CHANGES.txt for * more details. * Also added a macro which prevents compiling for kernels before 2.4.19. * * Revision 1.2 2003/06/18 22:00:22 lightweave * DEBUG and DEBUG_SERIAL added * * *****************************************************************************/static char *ident = "$Header: /cvsroot/pice/pice/module/editor_output.c,v 1.3 2004/02/17 23:07:36 lightweave Exp $";/*++Copyright (c) 1998-2001 Klaus P. GerlicherModule Name: editor_output.cAbstract: user interface for debuggerEnvironment: Kernel mode onlyAuthor: Klaus P. GerlicherRevision History: 24-Oct-2001: createdCopyright notice: This file may be distributed under the terms of the GNU Public License.--*/////////////////////////////////////////////////////// INCLUDES////#include "remods.h"#include <asm/io.h>#include <stdarg.h>#include "precomp.h"////////////////////////////////////////////////////// DEFINES////#define LINES_IN_COMMAND_BUFFER (64)////////////////////////////////////////////////////// GLOBALS////static UCHAR ucCommandBuffer[256];static USHORT usCurrentPosInInputBuffer=0;// the last command linesstatic char aszCommandLines[LINES_IN_COMMAND_BUFFER][sizeof(ucCommandBuffer)+2];static ULONG ulCommandInPos=0,ulCommandLastPos=0;static ULONG ulCommandCurrentPos=0; // functions of function keyschar *szFunctionKeys[10]={ "mod", // F1 "proc", // F2 "src", // F3 "code", // F4 "x", // F5 "vma", // F6 "", // F7 "t", // F8 "", // F9 "p" // F10};ULONG ulLastLineDisplayedOffset = 0;ULONG ulWindowOffset = 0;static char tempShell[256];//*************************************************************************// GetLinesInCommandHistory()////*************************************************************************ULONG GetLinesInCommandHistory(void){ ULONG ulResult = (ulCommandInPos-ulCommandLastPos)%LINES_IN_COMMAND_BUFFER; ENTER_FUNC(); DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO,"GetLinesInCommandHistory() returns %u (ulIn %u ulLast %u)\n",ulResult,ulCommandInPos,ulCommandLastPos); LEAVE_FUNC(); return ulResult;}//*************************************************************************// AddToCommandLineHistory()////*************************************************************************void AddToCommandLineHistory(LPSTR s){ ULONG i; ENTER_FUNC(); DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO,"AddToCommandLineHistory(%s)\n",s); if(PICE_strlen(s)) { for(i=0;i<LINES_IN_COMMAND_BUFFER;i++) { if(PICE_strcmpi(&aszCommandLines[i][1],s) == 0) { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "command line already exists\n"); goto Quit;; } } aszCommandLines[ulCommandInPos][0]=':'; PICE_strcpy(&aszCommandLines[ulCommandInPos][1],s); ulCommandCurrentPos = ulCommandInPos = (ulCommandInPos +1)%LINES_IN_COMMAND_BUFFER; if(ulCommandInPos == ulCommandLastPos) { ulCommandLastPos = (ulCommandLastPos+1)%LINES_IN_COMMAND_BUFFER; } }Quit: LEAVE_FUNC();}//*************************************************************************// GetFromCommandLineHistory()////*************************************************************************LPSTR GetFromCommandLineHistory(ULONG ulCurrentCommandPos){ LPSTR pRet; ENTER_FUNC(); DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO,"GetFromCommandLineHistory(): current = %u\n",ulCurrentCommandPos); // skip leading ':' pRet = aszCommandLines[ulCurrentCommandPos] + 1; DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "GetFromCommandLineHistory(%s)\n", pRet); LEAVE_FUNC(); return pRet;}//*************************************************************************// bNoCtrlKeys()////*************************************************************************BOOLEAN inline bNoCtrlKeys(void){ return (!bControl && !bAlt && !bShift); }//*************************************************************************// DebuggerEditorOutput()////*************************************************************************void DebuggerEditorOutput(EXCEPTION_FRAME* pFrame){ UCHAR ucKeyPressedWhileIdle; ARGS Args; UCHAR ucConverted; // we have a key press if((ucKeyPressedWhileIdle = GetKeyPolled())!=0) { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "key = %x control = %u shift = %u alt = %u\n", ucKeyPressedWhileIdle, bControl, bShift, bAlt); // if cursor reversed, normalize it again (only graphics) if(bRev) { PrintCursor(TRUE); } // convert key to ANSI, if success add to command buffer and try to // find a command that fits the already entered letters ucConverted = AsciiFromScan((UCHAR)(ucKeyPressedWhileIdle&0x7f)); /////////////////////////////////////////////////////////////////////////////////////// // // NORMAL key shifted and unshifted // if(!bControl && !bAlt && ucConverted) { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "normal key\n"); if(!(usCurrentPosInInputBuffer==0 && ucConverted==' ')) { // if we have space in the command buffer // put the character there if(usCurrentPosInInputBuffer<sizeof(ucCommandBuffer)-1) { ucCommandBuffer[usCurrentPosInInputBuffer++]=ucConverted; // output the character PICE_sprintf(tempShell,"%c",ucConverted); wWindow[OUTPUT_WINDOW].usCurX = usCurrentPosInInputBuffer; Print(OUTPUT_WINDOW,tempShell); } // if we have something in command buffer // try to find command help that fits if(usCurrentPosInInputBuffer) { FindCommand(ucCommandBuffer); } else ShowStoppedMsg(); } } else /////////////////////////////////////////////////////////////////////////////////////// // // NORMAL key while holding down CONTROL // if(bControl && !bAlt && !bShift && ucConverted) { } else /////////////////////////////////////////////////////////////////////////////////////// // // normal key while holding down ALT // if(!bControl && bAlt && !bShift && ucConverted) { } else /////////////////////////////////////////////////////////////////////////////////////// // // normal key while holding down ALT & CONTROL // if(bControl && bAlt && !bShift && ucConverted) { } else /////////////////////////////////////////////////////////////////////////////////////// // // we didn't get a converted key, so this must be a control key // { // RETURN if(bNoCtrlKeys() && ucKeyPressedWhileIdle == SCANCODE_ENTER) { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "RETURN\n"); ucCommandBuffer[usCurrentPosInInputBuffer]=0; if(ucCommandBuffer[0]) { AddToCommandLineHistory(ucCommandBuffer); ClrLines(wWindow[OUTPUT_WINDOW].y+wWindow[OUTPUT_WINDOW].usCurY,1); ulLastLineDisplayedOffset = 0; PrintRingBuffer(wWindow[OUTPUT_WINDOW].cy-1); bNotifyToExit = Parse(pFrame,ucCommandBuffer,FALSE); ShowStoppedMsg(); } else { if(ulLastLineDisplayedOffset) { ulLastLineDisplayedOffset = 0; PrintRingBuffer(wWindow[OUTPUT_WINDOW].cy-1); } } usCurrentPosInInputBuffer=0; PICE_memset(&ucCommandBuffer,0,sizeof(ucCommandBuffer)); } // backspace else if(bNoCtrlKeys() && ucKeyPressedWhileIdle == SCANCODE_BACKSPACE) { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "BACKSPACE\n"); if(usCurrentPosInInputBuffer) { if(usCurrentPosInInputBuffer) FindCommand(ucCommandBuffer); else ShowStoppedMsg(); usCurrentPosInInputBuffer--; ucCommandBuffer[usCurrentPosInInputBuffer]=0; Print(OUTPUT_WINDOW,"\b"); } if(!usCurrentPosInInputBuffer) ShowStoppedMsg(); } // Tab else if(bNoCtrlKeys() && ucKeyPressedWhileIdle==SCANCODE_TAB) { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "TAB\n"); if(usCurrentPosInInputBuffer) { LPSTR pCmd; if((pCmd=FindCommand(ucCommandBuffer)) ) { ULONG i; // clear the displayed command line for(i=0;i<usCurrentPosInInputBuffer;i++) Print(OUTPUT_WINDOW,"\b"); // clear command buffer PICE_memset(&ucCommandBuffer,0,sizeof(ucCommandBuffer)); // copy the found command into command buffer PICE_strcpy(ucCommandBuffer,pCmd); strcat(ucCommandBuffer," "); usCurrentPosInInputBuffer = PICE_strlen(ucCommandBuffer); Print(OUTPUT_WINDOW,ucCommandBuffer); } } } else { // function keys if(bNoCtrlKeys() && ucKeyPressedWhileIdle>=59 && ucKeyPressedWhileIdle<69) { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "FUNCTION %u\n",ucKeyPressedWhileIdle-59); PICE_sprintf(tempShell,":"); ReplaceRingBufferCurrent(tempShell); PICE_memset(&ucCommandBuffer,0,sizeof(ucCommandBuffer)); usCurrentPosInInputBuffer=0; PrintRingBuffer(wWindow[OUTPUT_WINDOW].cy-1); PICE_strcpy(ucCommandBuffer,szFunctionKeys[ucKeyPressedWhileIdle-59]); usCurrentPosInInputBuffer=PICE_strlen(ucCommandBuffer); if(ucCommandBuffer[0]) { ulLastLineDisplayedOffset = 0; PrintRingBuffer(wWindow[OUTPUT_WINDOW].cy-1); bNotifyToExit = Parse(pFrame,ucCommandBuffer,TRUE); PICE_memset(&ucCommandBuffer,0,sizeof(ucCommandBuffer)); usCurrentPosInInputBuffer=0; } } else { switch(ucKeyPressedWhileIdle) { case SCANCODE_ESC: { if(usCurrentPosInInputBuffer) { PICE_sprintf(tempShell,":"); ReplaceRingBufferCurrent(tempShell); PICE_memset(&ucCommandBuffer,0,sizeof(ucCommandBuffer)); usCurrentPosInInputBuffer=0; Print(OUTPUT_WINDOW,""); ShowStoppedMsg(); } } break; case SCANCODE_HOME: // home { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "HOME\n"); // memory window if(bAlt) { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "data window home\n"); OldOffset=0x0; // display data window Args.Value[0]=OldSelector; Args.Value[1]=OldOffset; Args.Count=2; DisplayMemory(pFrame,&Args); } // output window else if(bShift) { DPRINT(PICE_DEBUG, DBT_EDITOR, DBL_INFO, "output window home\n"); if(ulLastLineDisplayedOffset != LinesInRingBuffer()-wWindow[OUTPUT_WINDOW].cy) { ulLastLineDisplayedOffset = LinesInRingBuffer()-wWindow[OUTPUT_WINDOW].cy+1; PrintRingBufferHome(wWindow[OUTPUT_WINDOW].cy-1); } } // source window home else if(bControl) { if(ulCurrentlyDisplayedLineNumber>0) { PICE_SYMBOLFILE_SOURCE* pSrc; if(ConvertTokenToSrcFile(szCurrentFile,(PULONG)&pSrc) ) { ulCurrentlyDisplayedLineNumber = 1; DisplaySourceFile((LPSTR)pSrc+sizeof(PICE_SYMBOLFILE_SOURCE), (LPSTR)pSrc+pSrc->ulOffsetToNext, 1,-1); }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -