Beispiel #1
0
    /// <summary>
    ///     Calculates the throughput slope given two history measurements.
    /// </summary>
    /// <param name="fromSetting">
    ///     The control setting to move from.
    /// </param>
    /// <param name="toSetting">
    ///     The control setting to move to.
    /// </param>
    /// <returns>
    ///     A value representing a slope between two measurements.
    /// </returns>
    double HillClimbing::CalculateThroughputSlope(int fromSetting, int toSetting)
    {
        //
        // Configurable constants to control reactiveness of hill climbing
        //
        const double minJustifiesChange = 0.15;         // A minimum fractional change in measurement that justifies a change (cost for making a change)
        const double changeAdjustmentMultiplier = 1.0;  // Controls change factor by reducing uncertainty (bigger number pessimizes change frequency)

        double fractionalChangeInControlSetting = (double) (toSetting - fromSetting) / (double) fromSetting;

        MeasuredHistory * lastHistory = GetHistory(fromSetting);
        MeasuredHistory * currentHistory = GetHistory(toSetting);

        double lastHistoryMean = lastHistory->Mean();
        double currentHistoryMean = currentHistory->Mean();
        double meanChangeInMeasuredValue = currentHistoryMean - lastHistoryMean;
        double fractionalChangeInMeasuredValue = meanChangeInMeasuredValue / lastHistoryMean;

        double slope = (fractionalChangeInMeasuredValue/fractionalChangeInControlSetting) - minJustifiesChange;

        double varianceOfcurrentHistory = currentHistory->VarianceMean();
        double varianceOflastHistory = lastHistory->VarianceMean();
        double standardDeviationOfDifferenceInMeans = sqrt(varianceOfcurrentHistory + varianceOflastHistory);
        double coefficientOfVariationOfChangeInMeasuredValue =
            (abs(meanChangeInMeasuredValue) > 0) ? abs(standardDeviationOfDifferenceInMeans / meanChangeInMeasuredValue) : 0;

        double adjustedSlope = slope * exp(-changeAdjustmentMultiplier * coefficientOfVariationOfChangeInMeasuredValue);

        return adjustedSlope;
    }
//-----------------------------------------------------------------------------
// Purpose: Invokes the replace texture dialog.
//-----------------------------------------------------------------------------
void CTextureBrowser::OnReplace(void)
{
	CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
	if(!pDoc)
		return;

	CReplaceTexDlg dlg(pDoc->GetSelection()->GetCount());

	dlg.m_strFind = m_cTextureWindow.szCurTexture;

	if(dlg.DoModal() != IDOK)
		return;
	
	// mark undo position
	GetHistory()->MarkUndoPosition(pDoc->GetSelection()->GetList(), "Replace Textures");

	if(dlg.m_bMarkOnly)
	{
		pDoc->SelectObject(NULL, scClear);	// clear selection first
	}

	dlg.DoReplaceTextures();

	//EndDialog(IDOK);

	if (m_bUsed)
	{
		SetUsed(TRUE);
	}
}
//-----------------------------------------------------------------------------
// Purpose: Invokes the texture replace dialog.
//-----------------------------------------------------------------------------
void CFaceEditMaterialPage::OnReplace( void )
{
	// Set the material tool current.
	SetMaterialPageTool( MATERIALPAGETOOL_MATERIAL );

	//
	// get active map doc
	//
	CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
	if( !pDoc )
		return;

	// ready the replace dialog
	CReplaceTexDlg dlg( pDoc->GetSelection()->GetCount() );

	// get the texture to replace -- the default texture?!
	dlg.m_strFind = GetDefaultTextureName();

	//
	// open replace dialog -- modal
	//
	if( dlg.DoModal() != IDOK )
		return;
	
	// mark undo position
	GetHistory()->MarkUndoPosition( pDoc->GetSelection()->GetList(), "Replace Textures" );

	if( dlg.m_bMarkOnly )
	{
		pDoc->SelectObject( NULL, scClear );	// clear selection first
	}

	dlg.DoReplaceTextures();
}
Beispiel #4
0
void UpdateHistories(GPtr globals, DialogPtr dp, short count, Str255 hS)
{
	Str255 	s = "";
	Str255  n1 = "";
	Str255	n2 = "";
	Str255	nT = "";
	Str255	ss = "";
	long	x = gCurrentHistory + (kDHistTotal - 1);
	short	loop;

	PICopy(ss, hS, hS[0]+1); // make a new copy

	for (loop = gCurrentHistory; loop < gCurrentHistory + kDHistTotal; loop++)
	{
		GetHistory (globals, loop, s);
		if (loop == gCurrentHistory && !s[0])
		{
			PIGetString(kNoHistories, s);
			PIResetString(ss);
		}
		StuffText (dp, kDHistItem1 + (loop - gCurrentHistory), s);
		if (s[0] < 1 && x > loop-1)
			x = loop-1;
	}

	if (ss[0] > 0)
	{ // got the display string.  Populate it.
		NumToString(gCurrentHistory, n1);
		NumToString(x, n2);
		NumToString(count, nT);
		PIParamText(ss, n1, n2, nT);
	}
	StuffText (dp, kDStatusText, ss);
	// even if nothing, stuff empty or string in field
}
//-----------------------------------------------------------------------------
// Purpose: This function handles the saving of newly clipped solids (derived
//          from an "original" solid).  It handles them in an undo safe fashion.
//   Input: pSolid - the newly clipped solid
//          pOrigSolid - the "original" solid or solid the clipped solid was
//                       derived from
//-----------------------------------------------------------------------------
void Clipper3D::SaveClipSolid( CMapSolid *pSolid, CMapSolid *pOrigSolid )
{
    //
    // no longer a temporary solid
    //
    pSolid->SetTemporary( FALSE );

    //
    // Add the new solid to the original solid's parent (group, entity, world, etc.).
    //
	m_pDocument->AddObjectToWorld(pSolid, pOrigSolid->GetParent());
    
    //
    // handle linking solid into selection -- via selection set when parent is the world
    // and selected, or set the selection state if parent is group or entity in selection set
    //
    if( m_pDocument->Selection_IsSelected( pOrigSolid ) )
    {
        m_pDocument->SelectObject( pSolid, CMapDoc::scSelect );
    }
    else
    {
        pSolid->SetSelectionState( SELECT_NORMAL );
    }

    GetHistory()->KeepNew( pSolid );
}
NS_IMETHODIMP
WebBrowserPersistLocalDocument::GetCacheKey(uint32_t* aKey) {
  *aKey = 0;
  nsCOMPtr<nsISHEntry> history = GetHistory();
  if (history) {
    history->GetCacheKey(aKey);
  }
  return NS_OK;
}
Beispiel #7
0
void Ide::History(int d)
{
	int i = GetHistory(d);
	if(i >= 0) {
		histi = i;
		GotoBookmark(history[histi]);
		SetBar();
	}
}
NS_IMETHODIMP
WebBrowserPersistLocalDocument::GetPostData(nsIInputStream** aStream) {
  nsCOMPtr<nsISHEntry> history = GetHistory();
  if (!history) {
    *aStream = nullptr;
    return NS_OK;
  }
  return history->GetPostData(aStream);
}
Beispiel #9
0
 /// <summary>
 ///     Establishes control setting as current. This is the only method that updates the control settings.
 /// </summary>
 /// <param name="newControlSetting">
 ///     The control setting to be established.
 /// </param>
 void HillClimbing::EstablishControlSetting(unsigned int newControlSetting)
 {
     if (newControlSetting != m_currentControlSetting)
     {
         m_lastControlSetting = m_currentControlSetting;
         m_currentControlSetting = newControlSetting;
         GetHistory(m_currentControlSetting)->Clear(0);
         FlushHistories();
     }
 }
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pError - 
//-----------------------------------------------------------------------------
static void FixEmptyEntity(MapError *pError)
{
	CMapClass *pKillMe = pError->pObjects[0];

	if (pKillMe->GetParent() != NULL)
	{
		GetHistory()->KeepForDestruction(pKillMe);
		pKillMe->GetParent()->RemoveChild(pKillMe);
	}
}
Beispiel #11
0
ZOBJECTHITTEST ZActor::HitTest(const rvector& origin, const rvector& to, float fTime, rvector *pOutPos)
{
	rvector footpos,actor_dir;
	if(!GetHistory(&footpos,&actor_dir,fTime)) return ZOH_NONE;

	if (m_pNPCInfo->bColPick)
	{
		rvector dir = to - origin;
		Normalize(dir);

		RPickInfo pickinfo;
		memset(&pickinfo,0,sizeof(RPickInfo));

		if (m_pVMesh->Pick(origin, dir, &pickinfo))
		{
			*pOutPos = pickinfo.vOut;
			if ((pickinfo.parts == eq_parts_head) || (pickinfo.parts == eq_parts_face))
			{
				return ZOH_HEAD;
			}
			else
			{
				return ZOH_BODY;
			}
		}
	}
	else
	{
		rvector headpos = footpos;
		if (m_pVMesh)
		{
			headpos.z += m_Collision.fHeight - 5.0f;
		}

		rvector ap,cp;
		float fDist=GetDistanceBetweenLineSegment(origin,to,footpos,headpos,&ap,&cp);
		float fDistToThis=Magnitude(origin-cp);
		if(fDist < (m_Collision.fRadius-5.0f))
		{
			rvector dir = to - origin;
			Normalize(dir);

			rvector ap2cp = ap - cp;
			float fap2cpsq = MagnitudeSq(ap2cp);
			float fdiff = sqrt(m_Collision.fRadius*m_Collision.fRadius - fap2cpsq);

			if(pOutPos) *pOutPos = ap-dir*fdiff;;

			return ZOH_BODY;
		}
	}

	return ZOH_NONE;
}
//-----------------------------------------------------------------------------
// Purpose: Handles right mouse button down events in the 3D view.
// Input  : Per CWnd::OnRButtonDown.
// Output : Returns true if the message was handled, false if not.
//-----------------------------------------------------------------------------
bool CToolMaterial::OnRMouseDown3D(CMapView3D *pView, UINT nFlags, CPoint point) 
{
	BOOL bShift = ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0);
	BOOL bEdgeAlign = ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0);
	
	ULONG ulFace;
	CMapClass *pObject = pView->NearestObjectAt(point, ulFace);

	if (pObject != NULL)
	{
		if (pObject->IsMapClass(MAPCLASS_TYPE(CMapSolid)))
		{
			CMapSolid *pSolid = (CMapSolid *)pObject;
			GetHistory()->MarkUndoPosition(NULL, "Apply texture");
			GetHistory()->Keep(pSolid);
			
			// Setup the flags.
			int cmdFlags = 0;
			if(bEdgeAlign)
				cmdFlags |= CFaceEditSheet::cfEdgeAlign;
			
			// If they are holding down the shift key, apply to the entire solid.
			if (bShift)
			{
				int nFaces = pSolid->GetFaceCount();
				for(int i = 0; i < nFaces; i++)
				{
					GetMainWnd()->m_pFaceEditSheet->ClickFace( pSolid, i, cmdFlags, CFaceEditSheet::ModeApplyAll );
				}
			}
			// If not, apply to a single face.
			else
			{
				GetMainWnd()->m_pFaceEditSheet->ClickFace( pSolid, ulFace, cmdFlags, CFaceEditSheet::ModeApplyAll );
			}
		}				
	}
	
	return true;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : uCmd - 
// Output : Returns TRUE on success, FALSE on failure.
//-----------------------------------------------------------------------------
BOOL CFaceEditMaterialPage::OnAlign( UINT uCmd )
{
	// Set the material tool current.
	SetMaterialPageTool( MATERIALPAGETOOL_MATERIAL );

	// mark position in undo stack
	GetHistory()->MarkUndoPosition(NULL, "Align texture");

	CFaceEditSheet *pSheet = ( CFaceEditSheet* )GetParent();
	int faceCount = pSheet->GetFaceListCount();

	for( int i = 0; i < faceCount; i++ )
	{
		CMapFace *pFace = pSheet->GetFaceListDataFace( i );

		CMapSolid *pSolid = pSheet->GetFaceListDataSolid( i );
		GetHistory()->Keep( pSolid );

		switch( uCmd )
		{
			case IDC_ALIGN_WORLD:
			{
				pFace->InitializeTextureAxes( TEXTURE_ALIGN_WORLD, INIT_TEXTURE_AXES | INIT_TEXTURE_FORCE );
				break;
			}

			case IDC_ALIGN_FACE:
			{
				pFace->InitializeTextureAxes( TEXTURE_ALIGN_FACE, INIT_TEXTURE_AXES | INIT_TEXTURE_FORCE );
				break;
			}
		}
	}

	CMapDoc::GetActiveMapDoc()->SetModifiedFlag();

	UpdateDialogData();

	return ( TRUE );
}
void CCommandLineDisplay::InputHistoryUp (void)

//	InputHistoryUp
//
//	Recalls a line from the history buffer

	{
	if (m_iHistoryIndex < (GetHistoryCount()-1))
		{
		m_iHistoryIndex++;
		m_sInput = GetHistory(m_iHistoryIndex);
		m_iCursorPos = m_sInput.GetLength();
		m_bInvalid = true;
		}
	}
	float MaxSimilarityWithHistory(
		uint sentNo,
		const uint idx,
		const uint size
	) {
		std::vector<SelectedWordVector*> history;
		GetHistory(history,sentNo,idx,size);
		float maxSim = 0;
		while(!history.empty()) {
			SelectedWordVector *last = history.back();
			float sim = CosinusSimilarity(
				selectedWords[sentNo][idx].vec,
				last->vec
			);
			if(sim > maxSim || maxSim == 0) maxSim = sim;
			history.pop_back();
		}
		return maxSim;
	}
void CCommandLineDisplay::InputHistoryDown (void)

//	InputHistoryDown
//
//	Recalls a line from the history buffer

	{
	if (m_iHistoryIndex > 0)
		{
		m_iHistoryIndex--;
		m_sInput = GetHistory(m_iHistoryIndex);
		m_iCursorPos = m_sInput.GetLength();
		m_bInvalid = true;
		}
	else
		{
		m_iHistoryIndex = -1;
		ClearInput();
		}
	}
void CCommandLineDisplay::AppendHistory (const CString &sLine)

//	AppendHistory
//
//	Append a line of input to the history buffer

	{
	//	Use case-sensitive compare because sometimes commands differ only
	//	by case.

	if (!strEqualsCase(sLine, GetHistory(0)))
		{
		m_iHistoryStart = (m_iHistoryStart + (MAX_LINES + 1) - 1) % (MAX_LINES + 1);
		if (m_iHistoryStart == m_iHistoryEnd)
			m_iHistoryEnd = (m_iHistoryEnd + (MAX_LINES + 1) - 1) % (MAX_LINES + 1);

		m_History[m_iHistoryStart] = sLine;
		}

	m_iHistoryIndex = -1;
	}
NS_IMETHODIMP
WebBrowserPersistLocalDocument::GetCacheKey(uint32_t* aKey)
{
    nsCOMPtr<nsISHEntry> history = GetHistory();
    if (!history) {
        *aKey = 0;
        return NS_OK;
    }
    nsCOMPtr<nsISupports> abstractKey;
    nsresult rv = history->GetCacheKey(getter_AddRefs(abstractKey));
    if (NS_WARN_IF(NS_FAILED(rv)) || !abstractKey) {
        *aKey = 0;
        return NS_OK;
    }
    nsCOMPtr<nsISupportsPRUint32> u32 = do_QueryInterface(abstractKey);
    if (NS_WARN_IF(!u32)) {
        *aKey = 0;
        return NS_OK;
    }
    return u32->GetData(aKey);
}
//*****************************************************************************	
bool CCeWatchElement::WriteData(CStdioFile& file) const
//*****************************************************************************	
{
	// don't forget to increment the version string if you change anything here
	bool rv = false;
	CString str;

    str = CEWATCH_EXP_NAME + m_Name + CEWATCH_EXP_CRLF;
	file.WriteString(str);

	if (m_Type.GetName().GetLength() > 0)
	{
		str.Format(";%d", (int)m_Type.GetVarKind());
		file.WriteString(m_Type.GetName() + str);
	}
	file.WriteString(CEWATCH_EXP_CRLF);

    str = CEWATCH_EXP_VAL + m_strValue + CEWATCH_EXP_CRLF;
    file.WriteString(str);

	if (m_strFormat.GetLength() > 0)
		file.WriteString(m_strFormat);
	file.WriteString(CEWATCH_EXP_CRLF);

	str.Format("%d", GetHistoryCount());
    str += CEWATCH_EXP_CRLF;
	file.WriteString(str);
	for (int ii = 0; ii < GetHistoryCount(); ii++)
		file.WriteString(GetHistory(ii) + CEWATCH_EXP_CRLF);

	str.Format("%d", GetChildrenCount());
    str += CEWATCH_EXP_CRLF;

	file.WriteString(str);
	rv = true;
	for (ii = 0; ii < GetChildrenCount() && rv; ii++)
		rv &= GetChild(ii)->WriteData(file);

	return rv;;
}
Beispiel #20
0
BOOL PSGame::SaveHistory(LPCTSTR lpszPathName)
{
	CString strName(lpszPathName);

	// Open the history file or create a new one.
	CFile f;
	CFileException e;
	strName = strName.Left(strName.GetLength() - 3);
	strName += "dph";
	f.Open(strName, CFile::modeCreate | CFile::modeWrite, &e);
	if (e.m_cause)
		return FALSE;

	// Save the history.
	PSHistory* pHist = GetHistory();
	ASSERT(pHist);
	CArchive arh(&f, CArchive::store);
	pHist->Serialize(arh);
	arh.Close();
	f.Close();

	return TRUE;
}
Beispiel #21
0
bool kexConsole::ProcessInput(const event_t *ev) {
    if(ev->type == ev_mousedown || ev->type == ev_mouseup ||
        ev->type == ev_mouse) {
            return false;
    }

    if(ev->type == ev_mousewheel && state == CON_STATE_DOWN) {
        switch(ev->data1) {
            case KM_BUTTON_SCROLL_UP:
                LineScroll(1);
                break;
            case KM_BUTTON_SCROLL_DOWN:
                LineScroll(0);
                break;
        }

        return true;
    }

    CheckShift(ev);
    CheckStickyKeys(ev);

    int c = ev->data1;

    switch(state) {
        case CON_STATE_DOWN:
            if(ev->type == ev_keydown) {
                switch(c) {
                    case KKEY_BACKQUOTE:
                        state = CON_STATE_UP;
                        inputSystem->MouseCenter();
                        return true;
                    case KKEY_RETURN:
                        ParseInput();
                        return true;
                    case KKEY_UP:
                        GetHistory(false);
                        return true;
                    case KKEY_DOWN:
                        GetHistory(true);
                        return true;
                    case KKEY_TAB:
                        cvarManager.AutoComplete(typeStr);
                        command.AutoComplete(typeStr);
                        return true;
                    default:
                        ParseKey(c);
                        return true;
                }

                return false;
            }
            break;
        case CON_STATE_UP:
            if(ev->type == ev_keydown) {
                switch(c) {
                    case KKEY_BACKQUOTE:
                        state = CON_STATE_DOWN;
                        return true;
                    default:
                        break;
                }

                return false;
            }
            break;
        default:
            return false;
    }

    return false;
}
void Profiler :: FrameEnd()
{
    assert (I_MaxSamples && "Profiler::FrameEnd() : Create() hasn't been called");

    uint iSample = 0;

    T_FrameEnd = GetTick();

    float T_delta     = T_FrameEnd - T_FrameStart;
    if (T_delta < 0.00000001f)
    {
        while ( iSample < I_MaxSamples && Samples[iSample].FL_valid )
            Samples[iSample++].FL_valid = false;
        T_FrameStart = GetTick();
        return;
    }
    float T_delta_Inv = 1.f / T_delta;
    float W_newRatio  = T_delta * 0.0008f;
    if (W_newRatio > 1.f) W_newRatio = 1.f;
    float W_oldRatio  = 1.f - W_newRatio;

    lines.clear();

    char buff1[256], buff2[256];
    lines.push_back("  Mean :   Min :   Max :    # : Name");

    while ( iSample < I_MaxSamples && Samples[iSample].FL_valid )
    {
        ProfileSample &sample  = Samples[iSample];

        assert ( !sample.I_OpenProfiles &&
                 "Profiler::FrameEnd : Sample hasn't been finished" );

        uint iHistory = GetHistory( sample.Name );
        if (iHistory == I_MaxSamples) continue;

        ProfileSampleHistory &history = History[iHistory];

        float T_Prcnt      = (sample.T_Samples - sample.T_ChildrenSamples) * T_delta_Inv * 100.f;
        if (history.FL_valid)
        {
            history.T_AvgPrcnt = W_oldRatio * history.T_AvgPrcnt
                               + W_newRatio * T_Prcnt;
            if (T_Prcnt < history.T_MinPrcnt)
                history.T_MinPrcnt = T_Prcnt;
            else
                history.T_MinPrcnt = W_oldRatio * history.T_MinPrcnt
                                   + W_newRatio * T_Prcnt;
            if (T_Prcnt > history.T_MaxPrcnt)
                history.T_MaxPrcnt = T_Prcnt;
            else
                history.T_MaxPrcnt = W_oldRatio * history.T_MaxPrcnt
                                   + W_newRatio * T_Prcnt;
        }
        else
            history.T_AvgPrcnt = history.T_MinPrcnt = history.T_MaxPrcnt = T_Prcnt;
        history.FL_valid = true;

        char *name  = buff1;
        char *nameT = buff2;

        strcpy (name, history.Name);
        for (size_t indent=0; indent < sample.I_NumParents; ++indent)
        {
            sprintf( nameT, "    %s", name );
            char* swp = name; name = nameT; nameT = swp;
        }

        sprintf(nameT, " %5.1f : %5.1f : %5.1f : %4d : %s",
            history.T_AvgPrcnt, history.T_MinPrcnt, history.T_MaxPrcnt,
            sample.I_ProfileInstances, name);
        lines.push_back(nameT);

        sample.FL_valid = false;
        ++iSample;
    }

    T_FrameStart = GetTick();
}
//-----------------------------------------------------------------------------
// Purpose: Called when they hit the Find, the Replace, or the Replace All button.
// Input  : uCmd - The ID of the button the user hit, IDC_FIND_NEXT or IDC_REPLACE.
// Output : Returns TRUE to indicate that the message was handled.
//-----------------------------------------------------------------------------
BOOL CSearchReplaceDlg::OnFindReplace(UINT uCmd)
{
	CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
	if (!pDoc)
	{
		return TRUE;
	}

	static FindObject_t FindObject;
	static CMapClass *pLastFound = NULL;
	static nReplaceCount = 0;

	bool bDone = false;

	do
	{
		CMapClass *pObject = NULL;

		if (m_bNewSearch)
		{
			//
			// New search. Fetch the data from the controls.
			//
			UpdateData();
			GetFindCriteria(FindObject, pDoc);

			//
			// We have to keep track of the last object in the iteration for replacement,
			// because replacement is done when me advance to the next object.
			//
			pLastFound = NULL;
			nReplaceCount = 0;

			pObject = FindFirstObject(FindObject);
		}
		else
		{
			pObject = FindNextObject(FindObject);
		}

		//
		// Replace All is undone as single operation. Mark the undo position the first time
		// we find a match during a Replace All.
		//
		if (m_bNewSearch && (uCmd == IDC_REPLACE_ALL) && pObject)
		{
			GetHistory()->MarkUndoPosition(pDoc->Selection_GetList(), "Replace Text");
		}

		//
		// If we have an object to do the replace on, do the replace.
		//
		if (pLastFound && ((uCmd == IDC_REPLACE) || (uCmd == IDC_REPLACE_ALL)))
		{
			if (uCmd == IDC_REPLACE)
			{
				// Allow for undo each time we do a Replace.
				GetHistory()->MarkUndoPosition(NULL, "Replace Text");
			}

			//
			// Do the replace on the last matching object we found. This lets the user see what
			// object will be modified before it is done.
			//
			GetHistory()->Keep(pLastFound);
			nReplaceCount += FindReplace((CMapEntity *)pLastFound, FindObject, m_strReplaceText);

			GetDlgItem(IDCANCEL)->SetWindowText("Close");
		}

		if (pObject)
		{
			//
			// We found an object that satisfies our search.
			//
			if ((uCmd == IDC_FIND_NEXT) || (uCmd == IDC_REPLACE))
			{
				//
				// Highlight the match.
				//
				pDoc->SelectObject(pObject, CMapDoc::scClear | CMapDoc::scSelect);
				pDoc->CenterSelection();
			}

			//
			// Stop after one match unless we are doing a Replace All.
			//
			if (uCmd != IDC_REPLACE_ALL)
			{
				bDone = true;
			}

			m_bNewSearch = false;
			pLastFound = pObject;
		}
		else
		{
			//
			// No more objects in the search set match our criteria.
			//
			if ((m_bNewSearch) || (uCmd != IDC_REPLACE_ALL))
			{
				CString str;
				str.Format("Finished searching for '%s'.", m_strFindText);
				MessageBox(str, "Find/Replace Text", MB_OK);

				// TODO: put the old selection back
			}
			else if (uCmd == IDC_REPLACE_ALL)
			{
				CString str;
				str.Format("Replaced %d occurrences of the string '%s' with '%s'.", nReplaceCount, m_strFindText, m_strReplaceText);
				MessageBox(str, "Find/Replace Text", MB_OK);
			}

			m_bNewSearch = true;
			bDone = true;
		}

	} while (!bDone);

	return TRUE;
}
Beispiel #24
0
// Get command string from user of length no more than maxBytes (including NULL).
// Return number of characters in string (excluding NULL);
// Also includes history functionality using up and down arrow keys (using CmdHistory class).
int CSimWindow::GetCommandString(char *dest, int maxBytes)
{
	int i = 0;
	int c;
	
	while(true) {
		c = getchar();

		// Handle special characters
		if(c == 27) {
			if(extendedKeyPress() && getchar() == 91) {
				c = getchar();
				if(c == 65) {	// Up arrow
					// Get previous entry from history
					i = GetHistory(GET_PREVIOUS, dest, i);
				}
				else if(c == 66) {	// Down arrow
					// Get more recent entry from history
					i = GetHistory(GET_NEXT, dest, i);
				}
			}
			else {		// Escape key
				// Clear current command
				history.Reset();
				for(; i > 0; i--) printf("\b \b");
				continue;
			}
			while(extendedKeyPress()) getchar();	// Clear any buffered characters
		}
		else if(c == 14) {	// Ctrl+n
			// Get more recent entry from history
			i = GetHistory(GET_NEXT, dest, i);
		}
		else if(c == 16) {	// Ctrl+p
			// Get previous entry from history
			i = GetHistory(GET_PREVIOUS, dest, i);
		}
		else if(c == '\n') {
			putchar('\n');
			break;
		}
		else if(c == '\b' || c == 127) {	// Check for backspace or delete
			if(i > 0) {
				// Erase character
				printf("\b \b");
				i--;
			}
		}
		else if((char)c < 32) continue;	// Ignore any other unusual characters

		// Normal case:
		else if(i < maxBytes-1) {
			putchar(c);
			dest[i] = (char)c;
			i++;
		}
	}
	dest[i] = '\0';	// Null terminate string
	
	// Add to history (if not empty)
	if(dest[0] != '\0') history.Add(dest);

	return i;
}
kern_return_t GetServerAttribute(AttributeType attrib, UInt32 /*tagSize*/,
                                            void* /*tags*/, unsigned int bufSize,
                                            unsigned int* attribSize, void** buffer)
{
    Assert(buffer != NULL);
    Assert(sAttributeBuffer != NULL);
    
    if ((attribSize == NULL) || (buffer == NULL))
        return SCParamErr;
    
    *attribSize = 0;
    //use the sAttributeBuffer memory to store the attribute. This buffer
    //should be big enough to store the largest attribute
    *buffer = sAttributeBuffer;
        
    if ((attrib.attribClass != kServerAttr) || (attrib.version != kCurrentVersion))
        return SCUnsupportedAttrib;
    
    kern_return_t theError = SCNoError;
        
    switch (attrib.attribKind)
    {
        case kDNSNameAttr:
        {
            if (bufSize >= sizeof(QTSServerDNSName))
            {
                *attribSize = sizeof(QTSServerDNSName);
                theError = GetServerName((QTSServerDNSName*)sAttributeBuffer);
            }
            else
                theError = SCBufferToSmall;
            break;
        }   
        case kProcessInfoAttr:
        {
            if (bufSize >= sizeof(QTSProcessInfoRec))
            {
                *attribSize = sizeof(QTSProcessInfoRec);
                theError = GetProcessInfo((QTSProcessInfoRec*)sAttributeBuffer);
            }
            else
                theError = SCBufferToSmall;
            break;
        }
        case kVersionAttr:
        {
            if (bufSize >= sizeof(QTSServerVersionRec))
            {
                *attribSize = sizeof(QTSServerVersionRec);
                theError = GetServerVersion((QTSServerVersionRec*)sAttributeBuffer);
            }
            else
                theError = SCBufferToSmall;
            break;
        }   
        case kStatusAttr:
        {
            if (bufSize >= sizeof(QTSServerStatusRec))
            {
                *attribSize = sizeof(QTSServerStatusRec);
                theError = GetServerStatusRec((QTSServerStatusRec*)sAttributeBuffer);
            }
            else
                theError = SCBufferToSmall;
            break;
        }   
        case kRefuseConnectionsAttr:
        {
            if (bufSize >= sizeof(QTSRefuseConnectionsRec))
            {
                *attribSize = sizeof(QTSRefuseConnectionsRec);
                theError = GetRefuseConnections((QTSRefuseConnectionsRec*)sAttributeBuffer);
            }
            else
                theError = SCBufferToSmall;
            break;
        }   
        case kHistoryAttr:
        {
            if (bufSize >= sizeof(QTSServerHistoryRec))
            {
                *attribSize = sizeof(QTSServerHistoryRec);
                theError = GetHistory((QTSServerHistoryRec*)sAttributeBuffer);
            }
            else
                theError = SCBufferToSmall;
            break;
        }
        default:
            theError = SCUnsupportedAttrib;
    }
    return theError;
}
Beispiel #26
0
void cIPLog::GetIPHistory(const string &ip, int limit, ostream &os)
{
	GetHistory(ip, false, limit,os);
}
Beispiel #27
0
void cIPLog::GetNickHistory(const string &ip, int limit, ostream &os)
{
	GetHistory(ip, true, limit,os);
}
Beispiel #28
0
//################################################################################################################################
//--------------------------------------------------------------------------------------------------------------------------------
//函数名称:CLevel1_Sure()
//--------------------------------------------------------------------------------------------------------------------------------
//函数功能:确认键的第一层任务
//--------------------------------------------------------------------------------------------------------------------------------
//输入参数:	tmp为第几个按键的值
//--------------------------------------------------------------------------------------------------------------------------------
//输出参数:	null
//--------------------------------------------------------------------------------------------------------------------------------
//说   明:
//--------------------------------------------------------------------------------------------------------------------------------
//################################################################################################################################
void CLevel1_Sure(uint8 tmp)//第一层任务
{
	uint8 hz[]="请按确定删除";
	uint8 j=1,delflag=1;
	switch(tmp)
	{
        case 1://设置
			GetSetGrap(GetCounter2());
			SetAnnUartFlag(1);
			break;
        case 2://check
			GetCheckGrap(GetCounter2());		
			break;
        case 3://test
			GetTestGrap(GetCounter2());		
			break;
        case 4://reset
			ClearScreen(0);
// 			Waiting_menu();
			ClrCirAlarmData();
			ClrDatatoFlash();
// 			ClrHistoryList();
			
			UartCom(CMD_139W,2);	   //发送心跳命令
			UartCom(CMD_139W,2);
			Led_Fault_Off();
			Led_Fire_Off();
			Fire_Relay_Off();
			Fault_Relay_Off();
			SetAlarmFlag(0,0);
			PWM1_Stop();
// 			ClearScreen(0);
			SysReset_Menu();
			break;
        case 5://system reset
			while(FIO0PIN&(1 << 10))
			{
				if(j==1)
				{
					ClearScreen(0);
					j=0;
				}
				DisplayJBHZK(1,2,16,((hz[0]<<8)+hz[1]));
				DisplayJBHZK(1,2,32,((hz[2]<<8)+hz[3]));
				DisplayJBHZK(1,2,48,((hz[4]<<8)+hz[5]));
				DisplayJBHZK(2,2,0,((hz[6]<<8)+hz[7]));
				DisplayJBHZK(2,2,16,((hz[8]<<8)+hz[9]));
				DisplayJBHZK(2,2,32,((hz[10]<<8)+hz[11]));
				if(!(FIO0PIN&(1 << 25)))
				{
					delflag=0;
					j=1;
					SetMenuFlag(0);
					SubGrapCount();
					SetCounter1(1);
					break;
				}
			}
			if(delflag==1)
			{
				ClearScreen(0);
				Waiting_menu();
				EndInt(); 
				//M25P80_Bulk_Erase();
				M25P80_Section_Erase(0x00000);
				M25P80_Section_Erase(0x10000);
				M25P80_Section_Erase(0x20000);
				M25P80_Section_Erase(0x30000);
//				M25P80_Section_Erase(0x40000);
				M25P80_Section_Erase(0x50000);
				M25P80_Section_Erase(0x60000);
				M25P80_Section_Erase(0x70000);
//				M25P80_Section_Erase(0x80000);
				M25P80_Section_Erase(0x90000);
				M25P80_Section_Erase(0xa0000);
				M25P80_Section_Erase(0xb0000);
				M25P80_Section_Erase(0xc0000);
				M25P80_Section_Erase(0xd0000);
				M25P80_Section_Erase(0xe0000);
				M25P80_Section_Erase(0xf0000);		
				//延时10s
	// 			Delay1Ms(10000);
				StartInt();
				CPSNToFlashInit();
				SendToF_Init();
				MaskPSNInit();
				AlarmInfoInit();
				GetHistory();
	// 			HistConterInit();
				CirAlarmDataInit();
				SetCirAddrCurrent(0);
				ClrCirAlarmData();
				AnnCounterInit();
				InitHistPara();	
				ClearScreen(0);			
				Reset_OK();
			}			
			break;
//		case 6:
//			ClearScreen(0);
//			Waiting_menu();
//			EndInt();
//            M25P80_Section_Erase(0x60000);//地址代表啥
//			M25P80_Section_Erase(0x40000);
//			M25P80_Section_Erase(0x80000);
//			StartInt();
//			ClearScreen(0);
//			His_Reset();
//			break;
        case 6://set speaker
// 			ClearScreen(0);
// 			Speaker_Open_Close(0);
// 			PWM1_Stop();
// 			SetAlarmFlag(0,0);
			CLevel27_Sure();
			break;
		default:break;
	}
// 	vCounter[0] = 1;
}
Beispiel #29
0
// Get command string from user of length no more than maxBytes (including NULL).
// Return number of characters in string (excluding NULL);
// Also includes history functionality using up and down arrow keys (using CmdHistory).
int CSimWindow::GetCommandString(char *dest, int maxBytes)
{
	int i = 0;
	int c;
	
	while(true) {
		c = getch();

		// Handle special characters

		if(c == 224) {
			c = getch();
			if(c == 72) {	// Up arrow
				// Get previous entry from history
				i = GetHistory(GET_PREVIOUS, dest, i);
			}
			else if(c == 80) {	// Down arrow
				// Get more recent entry from history
				i = GetHistory(GET_NEXT, dest, i);
			}
			else while(kbhit()) getch();
			
			continue;
		}
		else if(c == 27) {	// ESC character
			// Clear current command
			history.Reset();
			for(; i > 0; i--) printf("\b \b");
			continue;
		}
		else if(c == 14) {	// Ctrl+n
			// Get more recent entry from history
			i = GetHistory(GET_NEXT, dest, i);
		}
		else if(c == 16) {	// Ctrl+p
			// Get previous entry from history
			i = GetHistory(GET_PREVIOUS, dest, i);
		}
		else if(c == '\r') { //(c == '\n') {
			putchar('\n');
			break;
		}
		else if(c == '\b') {	// Check for backspace
			if(i > 0) {
				// Erase character
				printf("\b \b");
				i--;
			}
		}
		else if(c < 32 || c > 128) continue;	// Ignore any other unusual characters

		// Normal case:
		else if(i < maxBytes-1) {
			putchar(c);
			dest[i] = (char)c;
			i++;
		}
	}
	dest[i] = '\0';	// Null terminate string

	// Add to history (if not empty)
	if(dest[0] != '\0') history.Add(dest);

	return i;
}
Beispiel #30
0
/*****************************************************************************
 * FollowAnchor: follow the current anchor being displayed to the user
 *****************************************************************************/
static void FollowAnchor ( intf_thread_t *p_intf )
{
    intf_sys_t *p_sys;
    decoder_t *p_cmml_decoder;
    char *psz_url = NULL;
    vlc_value_t val;

    msg_Dbg( p_intf, "User followed anchor" );

    p_sys = p_intf->p_sys;
    p_cmml_decoder = p_sys->p_cmml_decoder;

    if( var_Get( p_cmml_decoder, "psz-current-anchor-url", &val ) ==
            VLC_SUCCESS )
    {
        if( val.p_address ) psz_url = val.p_address;
    }

#ifdef CMML_INTF_DEBUG
    msg_Dbg( p_intf, "Current URL is \"%s\"", psz_url );
#endif

    if( psz_url )
    {
        playlist_t *p_playlist;
        playlist_item_t *p_current_item;
        char *psz_uri_to_load;
        mtime_t i_seconds;
        vlc_value_t time;

        p_playlist = (playlist_t *) vlc_object_find( p_intf, 
                VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
        if ( !p_playlist )
        {
            msg_Warn( p_intf, "can't find playlist" );
            return;
        }

        /* Get new URL */
        p_current_item = p_playlist->pp_items[p_playlist->i_index];
#ifdef CMML_INTF_DEBUG
        msg_Dbg( p_intf, "Current playlist item URL is \"%s\"",
                p_current_item->input.psz_uri );
#endif

        psz_uri_to_load = XURL_Concat( p_current_item->input.psz_uri,
                                       psz_url );

#ifdef CMML_INTF_DEBUG
        msg_Dbg( p_intf, "URL to load is \"%s\"", psz_uri_to_load );
#endif

        if( var_Get( p_intf->p_sys->p_input, "time", &time ) )
        {
            msg_Dbg( p_intf, "couldn't get time from current clip" );
            time.i_time = 0;
        }
        i_seconds = time.i_time / 1000000;
#ifdef CMML_INTF_DEBUG
        msg_Dbg( p_intf, "Current time is \"%lld\"", i_seconds );
#endif

        /* TODO: we need a (much) more robust way of detecting whether
         * the file's a media file ... */
        if( strstr( psz_uri_to_load, ".anx" ) != NULL )
        {
            history_t *p_history = NULL;
            history_item_t *p_history_item = NULL;
            char *psz_timed_url;
            
            p_history = GetHistory( p_playlist );

            /* create history item */
            psz_timed_url = GetTimedURLFromPlaylistItem( p_intf, p_current_item );
            p_history_item = historyItem_New( psz_timed_url, psz_timed_url );
            free( psz_timed_url );

            if( !p_history_item )
            {
                msg_Warn( p_intf, "could not initialise history item" );
            }
            else
            {
#ifdef CMML_INTF_DEBUG
                msg_Dbg( p_intf, "history pre-index %d", p_history->i_index );
#endif
                history_PruneAndInsert( p_history, p_history_item );
#ifdef CMML_INTF_DEBUG
                msg_Dbg( p_intf, "new history item at %p, uri is \"%s\"",
                         p_history_item, p_history_item->psz_uri );
                msg_Dbg( p_intf, "history index now %d", p_history->i_index );
#endif
            }

            /* free current-anchor-url */
            free( psz_url );
            val.p_address = NULL;
            if( var_Set( p_cmml_decoder, "psz-current-anchor-url", val ) !=
                    VLC_SUCCESS )
            {
                msg_Dbg( p_intf, "couldn't reset psz-current-anchor-url" );
            }

            ReplacePlaylistItem( p_playlist, psz_uri_to_load );
        }
        else
        {
#ifdef CMML_INTF_DEBUG
            msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url );
#endif
            (void) browser_Open( psz_url );
            playlist_Command( p_playlist, PLAYLIST_PAUSE, 0 );
        }

        free( psz_uri_to_load );

        vlc_object_release( p_playlist );
    }
}