Exemple #1
0
void luLogEdit::OnLButtonDBClick(wxMouseEvent& event)
{
	long pos = GetInsertionPoint();
	long x = 0, y = 0;
	PositionToXY(pos, &x, &y);
	wxString line = GetLineText(y);

	//01:15:55: TestError.lua:49: attempt to index field 'object' (a nil value)
	size_t i = wxString(line).MakeLower().find(".lua:");
	if (i != wxString::npos)
	{
		size_t k = line.rfind(':', i);
		size_t p = i+4;
		size_t s = line.find(':', p+1);

		if (k != wxString::npos && p != wxString::npos && s != wxString::npos)
		{
			wxString luaFile = line.SubString(k+1, p-1).Trim().Trim(false);
			wxString lineNo = line.SubString(p+1, s-1).Trim().Trim(false);
			long line = 0;

			if (lineNo.ToLong(&line))
			{
				luMainFrame* frame = getLuMainFrame();
				if (frame) frame->gotoLuaSource(luaFile, line);
			}
		}
	}
	

	event.Skip();
}
Exemple #2
0
long luConsoleEdit::getLastPromptPos()
{
	long x = 0, y = 0;
	long last = GetLastPosition();
	if (!PositionToXY(last, &x, &y))
		return 0;

	return XYToPosition(0, y);
}
Exemple #3
0
int SearchWindow::GetCurrentLine() const
{

    long pos = GetInsertionPoint();

    long x, y;
    PositionToXY(pos, &x, &y);

    return y;

}
void SourceView::OnUpdateUI(wxUpdateUIEvent& event)
{
	long col, line;
	const bool result = PositionToXY(GetInsertionPoint(), &col, &line);
	if(!result)
		line = -1;
	else
		line += 1;//convert to 1-based line numbering

	mainwin->setCurrent(currentfile, line);

	event.Skip();
}
Exemple #5
0
void wxTextCtrl::ShowPosition( long pos )
{
    if (m_windowStyle & wxTE_MULTILINE)
    {
        GtkAdjustment *vp = GTK_TEXT(m_text)->vadj;
        float totalLines =  (float) GetNumberOfLines();
        long posX;
        long posY;
        PositionToXY(pos, &posX, &posY);
        float posLine = (float) posY;
        float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower;
        gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p);
    }
}
Exemple #6
0
wxTextCtrlHitTestResult
wxTextAreaBase::HitTest(const wxPoint& pt, wxTextCoord *x, wxTextCoord *y) const
{
    // implement in terms of the other overload as the native ports typically
    // can get the position and not (x, y) pair directly (although wxUniv
    // directly gets x and y -- and so overrides this method as well)
    long pos;
    wxTextCtrlHitTestResult rc = HitTest(pt, &pos);

    if ( rc != wxTE_HT_UNKNOWN )
    {
        PositionToXY(pos, x, y);
    }

    return rc;
}
Exemple #7
0
// This is hackage to correct a problem on Leopard where the
// caret jumps up two lines when the up arrow is pressed and
// the caret is at the beginning of the line.
void NyqTextCtrl::OnKeyDown(wxKeyEvent & e)
{
   e.Skip();
   if (UMAGetSystemVersion() >= 0x1050) {
      if (e.GetKeyCode() == WXK_UP && e.GetModifiers() == 0) {
         long x;
         long y;
   
         PositionToXY(GetInsertionPoint(), &x, &y);
         if (x == 0 && y > 1) {
            y--;
            SetInsertionPoint(XYToPosition(x, y) - 1);
            e.Skip(false);
         }
      }
   }
}
Exemple #8
0
void luConsoleEdit::OnKeyDown(wxKeyEvent& event)
{
	int ch = event.GetKeyCode();
	wxString str;
	
	if (ch == WXK_UP) 
	{
		pasteCommand(-1);
		return;
	} 
	else if (ch == WXK_DOWN) 
	{
		pasteCommand(+1);
		return;
	} 
	else if (ch == WXK_ESCAPE) 
	{
		pasteCommand(0);
		replaceCommand("");
		return;
	} 
	else if (ch == WXK_LEFT || ch == WXK_BACK) 
	{
		long x = 0, y = 0;
		if (PositionToXY(GetInsertionPoint(), &x, &y))
		{
			if (x <= (int)m_prompt.Length()) 
				return;
		}		
	} 
	else if (ch == WXK_HOME) 
	{
		long x = 0, y = 0;
		if (PositionToXY(GetInsertionPoint(), &x, &y))
		{
			x = m_prompt.Length();
			long pos = XYToPosition(x, y);
			SetSelection(pos, pos);
		}

		return;
	} 
	
	
	if (ch == WXK_RETURN) 
	{
		str = GetLineText(GetNumberOfLines() - 1);
		str.Replace(m_prompt, "");
	}
	else
	{
		event.Skip();
	}

	if (ch == WXK_RETURN) 
	{
		writeLine("\n");

		str.Trim().Trim(false);

		if (!str.IsEmpty()) 
		{
			runCmd(str, false, false);
			addCommand(str);
		} 
				
		writeLine(m_prompt);
		pasteCommand(0);
	}
}
Exemple #9
0
void TextCtrl::OnChar(wxKeyEvent& event)
{
  long from, to;
  GetSelection(&from, &to);
  switch (event.GetKeyCode())
  {
  case WXK_RETURN:
    {
      long int c, l;
      PositionToXY(GetInsertionPoint(), &c, &l);
      wxString line = GetLineText(l);
      WriteText(wxT("\n"));
      for (int i = 0; i < (int)line.Length(); i++)
      {
        if (line.GetChar(i) != ' ')
          break;
        WriteText(wxT(" "));
      }
    }
    return ;
    break;
  case WXK_TAB:
    {
      long int c, l;
      PositionToXY(GetInsertionPoint(), &c, &l);
      do
      {
        WriteText(wxT(" "));
        c++;
      }
      while (c % 4 != 0);
      SetFocus();
    }
    return ;
    break;
  default:
    break;
  }
  if (m_matchParens)
  {
    switch (event.GetKeyCode())
    {
    case '(':
      if (from == to)
      {
        WriteText(wxT("()"));
        SetInsertionPoint(GetInsertionPoint() - 1);
      }
      else
      {
        SetInsertionPoint(to);
        WriteText(wxT(")"));
        SetInsertionPoint(from);
        WriteText(wxT("("));
        SetInsertionPoint(to + 1);
      }
      break;
    case '[':
      if (from == to)
      {
        WriteText(wxT("[]"));
        SetInsertionPoint(GetInsertionPoint() - 1);
      }
      else
      {
        SetInsertionPoint(to);
        WriteText(wxT("]"));
        SetInsertionPoint(from);
        WriteText(wxT("["));
        SetInsertionPoint(to + 1);
      }
      break;
    case '"':
      if (from == to)
      {
        WriteText(wxT("\"\""));
        SetInsertionPoint(GetInsertionPoint() - 1);
      }
      else
      {
        SetInsertionPoint(to);
        WriteText(wxT("\""));
        SetInsertionPoint(from);
        WriteText(wxT("\""));
        SetInsertionPoint(to + 1);
      }
      break;
    default:
      event.Skip();
    }
  }
  else
    event.Skip();
}