void CodeView::OnScrollPageUp(wxScrollWinEvent& event) { int page; if (GetFirstLine() > 0) { page = line_info.cursorPosition; Scroll(-1,GetFirstLine() - m_linesShown); UpdateLastCursorRect(); line_info.cursorLastPosition = GetFirstLine(); line_info.cursorPosition = line_info.cursorLastPosition; page -= line_info.cursorPosition; if (page < static_cast<int>(m_linesShown)) RefreshRect(*LastCursorRect); } }
/** * Description: DecodePacket(). 解析RTSP包 * @param [in] strPacket RTSP包 * @param [out] stResult 解析结果 * @return long. 返回码 */ long CRtspPacket::DecodePacket ( IN const string& strPacket, OUT RTSP::DECODE_RESULT& stResult )const { //long lResult = RTSP::RET_CODE_OK; string strFirstHeader; string strField; //获取首行首字段和头域内容 long lResult = GetFirstLine(strPacket, strFirstHeader, strField); if (RTSP::RET_CODE_OK != lResult) { return lResult; } //响应消息直接返回 if (0 == strFirstHeader.compare(RTSP::RTSP_VERSION)) { stResult.ulMsgType = RTSP::MSG_TYPE_RESP; //获取RTP-Info,只有NAT穿越响应消息才有 (void)GetRtpInfo(strField, stResult); return RTSP::RET_CODE_OK; } //只解析SET_PARAMETER消息 else if (0 != strFirstHeader.compare("SET_PARAMETER")) { return RTSP::RET_CODE_FAIL; } stResult.ulMsgType = RTSP::MSG_TYPE_SET_PARAMETER; //将头域内容的多行转为单行 MuiltLineToOneLine(strField); //获取CSeq lResult = GetFieldValue(strField, "CSeq", stResult.strCSeq); if (RTSP::RET_CODE_OK != lResult) { return RTSP::RET_CODE_FAIL; } //获取播放信息类型 lResult = GetPlayInfoType(strField, stResult.ulPlayInfoType); if (RTSP::RET_CODE_OK != lResult) { return RTSP::RET_CODE_FAIL; } return RTSP::RET_CODE_OK; }
/* Text suchen und selektieten Punkt übergeben */ BOOL SearchText (char* pszKeyStr, POINT* pPoint) { register int i; int iEnd; char szLine [iMaxLineLength]; char *pszAktPos; int iStart = HIWORD (Edit_GetSel (hEditWnd)); int iLineNr = Edit_LineFromChar (hEditWnd, iStart); int iMaxLineNr = Edit_GetLineCount (hEditWnd); int iLineLength = Edit_LineLength (hEditWnd, iStart); /* 1. (akt.) Zeile untersuchen */ if (iLineLength) { for (i = 0; i < sizeof (szLine); i++) szLine [i] = '\0'; GetFirstLine (szLine); if (pszAktPos = CompareStrings (szLine, pszKeyStr)) { iStart += pszAktPos - szLine; iEnd = iStart + strlen (pszKeyStr); pPoint->x = iStart; pPoint->y = iEnd; return (TRUE); } else iStart += strlen (szLine) + 2; // einschl. 0D0A } else iStart += 2; /* alle restlichen Zeilen untersuchen */ for (++iLineNr; iLineNr < iMaxLineNr; iLineNr++) { if (iLineLength = Edit_LineLength (hEditWnd, iStart)) { for (i = 0; i < sizeof (szLine); i++) szLine [i] = '\0'; Edit_GetLine (hEditWnd, iLineNr, szLine, sizeof (szLine) -1); if (pszAktPos = CompareStrings (szLine, pszKeyStr)) { iStart += pszAktPos - szLine; iEnd = iStart + strlen (pszKeyStr); pPoint->x = iStart; pPoint->y = iEnd; return (TRUE); } else iStart += iLineLength + 2; } else iStart += 2; } /* Punkt auf ungültigen Wert setzen */ pPoint->x = -1; pPoint->y = -1; return (FALSE); }
/// mSearch() IPTR mSearch(UNUSED struct IClass *cl, Object *obj, struct MUIP_TextEditor_Search *msg) { struct InstData *data = INST_DATA(cl, obj); STRPTR str = msg->SearchString; LONG len = strlen(str), step = 0; ENTER(); if(len > 0 && len <= 120) { BYTE map[256]; LONG (*StrCmp)(STRPTR, STRPTR, LONG); LONG cursor; struct line_node *line; // if the FromTop flag is set we start the search right from the top if(isFlagSet(msg->Flags, MUIF_TextEditor_Search_FromTop)) { cursor = 0; line = GetFirstLine(&data->linelist); } else { cursor = data->CPos_X; line = data->actualline; } memset(map, len, 256); // if a casesensitive search is requested we use a different // compare function. if(isFlagSet(msg->Flags, MUIF_TextEditor_Search_CaseSensitive)) { StrCmp = Native_strncmp; while(*str) map[(int)*str++] = step--; } else { StrCmp = Utility_strnicmp; while(*str) { map[ToLower(*str)] = step; map[ToUpper(*str++)] = step--; } } if(isFlagSet(msg->Flags, MUIF_TextEditor_Search_Backwards)) { //D(DBF_STARTUP, "MUIF_TextEditor_Search_Backwards search=%s\n", msg->SearchString); if(Enabled(data)) cursor -= len; while(line != NULL) { LONG lenTmp = len; STRPTR contents = line->line.Contents + cursor - lenTmp+1; STRPTR lower = line->line.Contents; while(contents >= lower) { //D(DBF_STARTUP, "MUIF_TextEditor_Search_Backwards previous=%ld, contents=%s\n",line, contents); if(!StrCmp(contents, msg->SearchString, len)) { LONG startx = contents - line->line.Contents; //D(DBF_STARTUP, "MUIF_TextEditor_Search_Backwards found\n"); SimpleMarkText(data, startx, line, startx+len, line); RETURN(TRUE); return TRUE; } contents -= 1; lenTmp += 1; } line = GetPrevLine(line); if(line != NULL) cursor = line->line.Length; } } else { while(line) { LONG skip; STRPTR contents = line->line.Contents + cursor + len-1; STRPTR upper = line->line.Contents + line->line.Length; while(contents < upper) { skip = map[(int)(*contents)]; contents += skip; if(skip <= 0) { if(!StrCmp(contents, msg->SearchString, len)) { LONG startx = contents - line->line.Contents; SimpleMarkText(data, startx, line, startx+len, line); RETURN(TRUE); return TRUE; } contents += len; } } cursor = 0; line = GetNextLine(line); } } } RETURN(FALSE); return FALSE; }
// 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(); } }
void CodeView::OnScrollLineUp(wxScrollWinEvent& event) { Scroll(-1, GetFirstLine() - 1); }
void CodeView::OnScrollLineDown(wxScrollWinEvent& event) { Scroll(-1, GetFirstLine() + 1); RefreshRect(CalcCursorRfshRect()); }
/** * Description: GetNatPacket(). 解析NAT穿越包 * @param [in] strPacket RTSP的NAT包 * @param [out] stNatResult NAT解析结果 * @return long. 返回码 */ long CRtspPacket::DecodeNatPacket ( IN const string& strPacket, OUT RTSP::NAT_DECODE_RESULT& stNatResult ) const { //long lResult = RTSP::RET_CODE_OK; string strFirstHeader; string strField; //获取首行首字段和头域内容 long lResult = GetFirstLine(strPacket, strFirstHeader, strField); if (RTSP::RET_CODE_OK != lResult) { return lResult; } //只解析NAT穿越包 if (0 != strFirstHeader.compare(RTSP::METHOD_RECORD)) { return RTSP::RET_CODE_FAIL; } //将头域内容的多行转为单行 MuiltLineToOneLine(strField); //获取CSeq lResult = GetFieldValue(strField, "CSeq", stNatResult.strCSeq); if (RTSP::RET_CODE_OK != lResult) { return RTSP::RET_CODE_FAIL; } //获取Session lResult = GetFieldValue(strField, "Session", stNatResult.strSession); if (RTSP::RET_CODE_OK != lResult) { return RTSP::RET_CODE_FAIL; } //获取x-NAT-Info string strNatInfo; lResult = GetFieldValue(strField, "x-NAT-Info", strNatInfo); if (RTSP::RET_CODE_OK != lResult) { return RTSP::RET_CODE_FAIL; } //获取协议类型 lResult = GetFieldValue(strNatInfo, "type", stNatResult.strProtocalType, RTSP::SEMI_COLON, RTSP::EQUAL_SIGN); if (RTSP::RET_CODE_OK != lResult) { return RTSP::RET_CODE_FAIL; } //获取IP lResult = GetFieldValue(strNatInfo, "local_addr", stNatResult.strRemoteIp, RTSP::SEMI_COLON, RTSP::EQUAL_SIGN); if (RTSP::RET_CODE_OK != lResult) { return RTSP::RET_CODE_FAIL; } //获取端口号 lResult = GetFieldValue(strNatInfo, "local_port", stNatResult.strRemotePort, RTSP::SEMI_COLON, RTSP::EQUAL_SIGN); if (RTSP::RET_CODE_OK != lResult) { return RTSP::RET_CODE_FAIL; } return RTSP::RET_CODE_OK; }