Example #1
0
bool debug_view_expression::recompute()
{
	bool changed = m_dirty;

	// if dirty, re-evaluate
	if (m_dirty)
	{
		astring oldstring(m_parsed.original_string());
		try
		{
			m_parsed.parse(m_string);
		}
		catch (expression_error &)
		{
			m_parsed.parse(oldstring);
		}
	}

	// if we have a parsed expression, evalute it
	if (!m_parsed.is_empty())
	{
		// recompute the value of the expression
		try
		{
			UINT64 newresult = m_parsed.execute();
			if (newresult != m_result)
			{
				m_result = newresult;
				changed = true;
			}
		}
		catch (expression_error &)
		{
		}
	}

	// expression no longer dirty by definition
	m_dirty = false;
	return changed;
}
Example #2
0
// ------------------------------------------------------------------------------------ RHTML_Tag_Menu - Put -
void RHTMLTagMenu::Put()
{
 fTextView->Window()->Lock();
 BString _str;

 if (menutype!=R_VALUE_MENU)
  fListView->str.CopyInto(_str,1,fListView->str.Length()-1);
 else
  _str=fListView->str;

 fTextView->Delete(fListView->sel1,fListView->sel2);
 fTextView->Select(fListView->sel1,fListView->sel1);
 int32 cursor=fListView->sel1;
 int32 origcursor=fListView->sel1;
 BString oldstring(fTextView->Text());
 std::vector<Cmd> cmd;
 
 if (menutype==R_TAG_MENU)	 // - R_TAG_MENU
 {
  int32 i=0;
  std::map<BString,Tag>::const_iterator tmp;
  for (tmp = fTag.begin();tmp!=fTag.end();tmp++)
   if (tmp->first.ICompare(_str,_str.Length())==0)
   {
    if (i==fListView->CurrentSelection())
    {
     cmd=tmp->second.cmd;
    }
    i++;
   }
 }

 if (menutype==R_PARAM_MENU) // - R_PARAM_MENU
 {
  int32 i=0;
  std::map<BString,Param>::const_iterator tmp;
  for (tmp = fTag[tag].param.begin();tmp!=fTag[tag].param.end();tmp++)
   if (tmp->first.ICompare(_str,_str.Length())==0 && std::find(tags.begin(),tags.end(),tmp->first)==tags.end())
   {
    if (i==fListView->CurrentSelection())
    {
     cmd=tmp->second.cmd;
     BMessage *msg = new BMessage('VALE');
     msg->AddString("tag",tag);
     msg->AddString("param",tmp->first);
     fTextView->MessageReceived(msg);
    }
    i++;
   }
 }

 if (menutype==R_VALUE_MENU) // - R_VALUE_MENU
 {
  int32 i=0;
  std::map<BString,Value>::const_iterator tmp;
  for (tmp = fTag[tag].param[param].value.begin();tmp!=fTag[tag].param[param].value.end();tmp++)
   if (tmp->first.ICompare(_str,_str.Length())==0)
   {
    if (i==fListView->CurrentSelection())
    {
     cmd=tmp->second.cmd;
    }
    i++;
   }
 }
 
 std::vector<Cmd>::const_iterator tmp;
 for (tmp = cmd.begin();tmp!=cmd.end();tmp++)
 {
  if (tmp->type.ICompare("INSERTBACK")==0)
  {
   fTextView->Select(origcursor,origcursor);
   fTextView->Insert(tmp->param.String());
   cursor+=tmp->param.Length();
   origcursor=origcursor+tmp->param.Length();
  }
  if (tmp->type.ICompare("INSERTFOR")==0)
  {
   fTextView->Select(cursor,cursor);
   fTextView->Insert(tmp->param.String());
   cursor+=tmp->param.Length();
  }
  if (tmp->type.ICompare("NEWLINE")==0)
  {
   fTextView->Select(cursor,cursor);
   fTextView->Insert("\n");
   cursor++;
  }
  if (tmp->type.ICompare("SPECIAL")==0)
  {
   if (tmp->param.ICompare("#Color")==0)
   {
    fColorWin->Start(BPoint(Frame().left,Frame().top),fTextView);
   }
  }
  if (tmp->type.ICompare("PUT")==0)
  {
   BString tmp1,tmp2,tmp3;
   tmp1=tmp->param;
   int32 newline=-1;
   int32 pos=-1;
   int32 strpos=0;
   int32 pluspos=0;

   newline=tmp1.FindFirst("\\n",strpos);
   pos=tmp1.FindFirst("%c",strpos);
   if ((pos>=0) && (newline>=0))
   {
    if (pos>newline)
    {
     pos=-1;
     pluspos++;
    }
    else
    {
     newline=-1;
    }
   }

   while (pos>=0 || newline>=0)
   {
    if (newline>=0)
    {
     fTextView->Insert((tmp1.CopyInto(tmp2,strpos,newline-strpos)).String());
     int32 c,d;
     fTextView->GetSelection(&c,&d);
     BString temp="";
     if (d-fTextView->OffsetAt(fTextView->CurrentLine())>0)
     {
      for (int i=fTextView->OffsetAt(fTextView->CurrentLine());i<d;i++)
      {
       if (fTextView->Text()[i]==B_SPACE||fTextView->Text()[i]==B_TAB)
       {
        temp << fTextView->Text()[i];
       } else break;
      }
     }
     fTextView->Insert("\n");
     fTextView->Insert(temp.String());
     tmp1.CopyInto(tmp2,0,newline);
     tmp1.CopyInto(tmp3,newline+2,tmp1.Length()-newline-2);
     tmp1=tmp2;
     tmp1+=tmp3;
     cursor+=newline-strpos+temp.Length()+1;
     strpos=newline;
    }
    if (pos>=0)
    {
     fTextView->Insert((tmp1.CopyInto(tmp2,strpos,pos-strpos)).String());
     tmp1.CopyInto(tmp2,0,pos);
     tmp1.CopyInto(tmp3,pos+2,tmp1.Length()-pos-2);
     tmp1=tmp2;
     tmp1+=tmp3;
     cursor+=pos-strpos+pluspos;
     strpos=pos;
     origcursor+=pos+pluspos;
    }
    newline=-1;
    pos=-1;
    newline=tmp1.FindFirst("\\n",strpos);
    pos=tmp1.FindFirst("%c",strpos);
    if ((pos>=0) && (newline>=0))
    {
     if (pos>newline)
     {
      pos=-1;
      pluspos++;
     }
     else
     {
      newline=-1;
     }
    }
   }
   fTextView->Insert((tmp1.CopyInto(tmp2,strpos,tmp1.Length()-strpos)).String());
   cursor+=tmp1.Length()-strpos;
  }
 }
 fTextView->Select(origcursor,origcursor);
 BMessage *msg= new BMessage('PTFC');
 msg->AddInt32("sel1",fListView->sel1);
 msg->AddInt32("sel2",cursor);
 msg->AddString("oldstring",oldstring);
 fTextView->MessageReceived(msg);
 Stop();
 fTextView->MessageReceived(new BMessage('UPPM'));
 fTextView->Window()->Unlock();
}