Exemplo n.º 1
0
void cbStyledTextCtrl::OnKeyDown(wxKeyEvent& event)
{
    switch (event.GetKeyCode())
    {
        case WXK_TAB:
        {
            if (m_tabSmartJump && !(event.ControlDown() || event.ShiftDown() || event.AltDown()))
            {
                if (!AutoCompActive() && m_bracePosition != wxSCI_INVALID_POSITION)
                {
                    m_lastPosition = GetCurrentPos();
                    GotoPos(m_bracePosition);

                    // Need judge if it's the final brace
                    HighlightRightBrace();
                    if (!m_tabSmartJump && CallTipActive())
                        CallTipCancel();
                    return;
                }
            }
        }
        break;

        case WXK_BACK:
        {
            if (m_tabSmartJump)
            {
                if (!(event.ControlDown() || event.ShiftDown() || event.AltDown()))
                {
                    const int pos = GetCurrentPos();
                    const int index = s_leftBrace.Find((wxChar)GetCharAt(pos - 1));
                    if (index != wxNOT_FOUND && (wxChar)GetCharAt(pos) == s_rightBrace.GetChar(index))
                    {
                        CharRight();
                        DeleteBack();
                    }
                }
                else if (m_lastPosition != wxSCI_INVALID_POSITION && event.ControlDown())
                {
                    GotoPos(m_lastPosition);
                    m_lastPosition = wxSCI_INVALID_POSITION;
                    return;
                }
            }
        }
        break;

        case WXK_RETURN:
        case WXK_ESCAPE:
        {
            if (m_tabSmartJump)
                m_tabSmartJump = false;
        }
        break;
    }

    event.Skip();
}
Exemplo n.º 2
0
bool SearchableEditor::find(bool newSearch)
{
    if (!fd)
        fd = new FindDialog(this, ::wxGetTopLevelParent(this));
    if (newSearch || findTextM.empty())
    {
        if (newSearch)
        {
            // find selected text
            wxString findText(GetSelectedText());
            // failing that initialize with the word at the caret
            if (findText.empty())
            {
                int pos = GetCurrentPos();
                int start = WordStartPosition(pos, true);
                int end = WordEndPosition(pos, true);
                if (end > start)
                    findText = GetTextRange(start, end);
            }
            fd->SetFindText(findText);
        }

        // do not re-center dialog if it is already visible
        if (!fd->IsShown())
            fd->Show();
        fd->SetFocus();
        return false;    // <- caller shouldn't care about this
    }

    int start = GetSelectionEnd();
    if (findFlagsM.has(se::FROM_TOP))
    {
        start = 0;
        findFlagsM.remove(se::ALERT);    // remove flag after first find
    }

    int end = GetTextLength();
    int p = FindText(start, end, findTextM, findFlagsM.asStc());
    if (p == -1)
    {
        if (findFlagsM.has(se::WRAP))
            p = FindText(0, end, findTextM, findFlagsM.asStc());
        if (p == -1)
        {
            if (findFlagsM.has(se::ALERT))
                wxMessageBox(_("No more matches"), _("Search complete"), wxICON_INFORMATION|wxOK);
            return false;
        }
    }
    centerCaret(true);
    GotoPos(p);
    GotoPos(p + findTextM.Length());
    SetSelectionStart(p);
    SetSelectionEnd(p + findTextM.Length());
    centerCaret(false);
    return true;
}
Exemplo n.º 3
0
void CodeEditor::OnCharAdded(wxScintillaEvent &event)
{
	char ch = event.GetKey();
	int currentLine = GetCurrentLine();
	int pos = GetCurrentPos();

	if (ch == wxT('\n') && currentLine > 0)
	{
		BeginUndoAction();

		wxString indent = GetLineIndentString(currentLine - 1);

		wxChar b = GetLastNonWhitespaceChar();
		if(b == wxT('{'))
		{
			if(GetUseTabs())
				indent << wxT("\t");
			else
				indent << wxT("    ");
		}

		InsertText(pos, indent);
		GotoPos((int)(pos + indent.Length()));
		ChooseCaretX();

		EndUndoAction();
	}
	else if(ch == wxT('}'))
	{
		BeginUndoAction();

		wxString line = GetLine(currentLine);
		line.Trim(false);
		line.Trim(true);
		if(line.Matches(wxT("}")))
		{
			pos = GetCurrentPos() - 2;
			pos = FindBlockStart(pos, wxT('{'), wxT('}'));

			if(pos != -1)
			{
				wxString indent = GetLineIndentString(LineFromPosition(pos));
				indent << wxT('}');
				DelLineLeft();
				DelLineRight();
				pos = GetCurrentPos();
				InsertText(pos, indent);
				GotoPos((int)(pos + indent.Length()));
				ChooseCaretX();
			}
		}

		EndUndoAction();
	}
}
Exemplo n.º 4
0
void SciEdit::SetText(LPCTSTR szText)
{
	if (szText != NULL)
		Call(SCI_SETTEXT, 0, (LPARAM)szText);
	GotoPos(0);
	SetFocus();
}
Exemplo n.º 5
0
Arquivo: layer.c Projeto: amade/screen
void LGotoPos(Layer *l, int x, int y)
{
	int x2, y2;

	if (l->l_pause.d)
		LayPauseUpdateRegion(l, x, x, y, y);

	for (Canvas *cv = l->l_cvlist; cv; cv = cv->c_lnext) {
		if (l->l_pause.d && cv->c_slorient)
			continue;
		display = cv->c_display;
		if (D_blocked)
			continue;
		if (cv != D_forecv)
			continue;
		x2 = x + cv->c_xoff;
		y2 = y + cv->c_yoff;
		if (x2 < cv->c_xs)
			x2 = cv->c_xs;
		if (y2 < cv->c_ys)
			y2 = cv->c_ys;
		if (x2 > cv->c_xe)
			x2 = cv->c_xe;
		if (y2 > cv->c_ye)
			y2 = cv->c_ye;
		for (Viewport *vp = cv->c_vplist; vp; vp = vp->v_next) {
			if (x2 < vp->v_xs || x2 > vp->v_xe)
				continue;
			if (y2 < vp->v_ys || y2 > vp->v_ye)
				continue;
			GotoPos(x2, y2);
			break;
		}
	}
}
Exemplo n.º 6
0
	/// Indent if newline was added.
	void OnCharAdded(wxScintillaEvent &event) {
		// Change this if support for mac files with \r is needed
		if (event.GetKey() == '\n' || event.GetKey() == '\r') {
			int currentLine = GetCurrentLine();
			if (currentLine <= 0) {
				return;
			}

			// width of one indent character
			int indentWidth = (GetUseTabs() ? GetTabWidth() : 1);
			if (indentWidth == 0) {
				return;
			}

			// indent as prev line level
			int indentSize = GetLineIndentation(currentLine - 1);
			SetLineIndentation(currentLine, indentSize);

			// position = (line start pos) + (tabs count) + (space count)
			GotoPos(PositionFromLine(currentLine)
				+ (indentSize / indentWidth)
				+ (indentSize % indentWidth));

			// notify that the text was changed
			ChangeModified(true);
		}
	}
void cbStyledTextCtrl::OnMouseMiddleClick(wxMouseEvent& event)
{
    event.Skip();
    // emulate middle mouse paste under all systems due to buggy wxClipboard
    const int pos = PositionFromPoint(wxPoint(event.GetX(), event.GetY()));
    if (pos == wxSCI_INVALID_POSITION || pos != m_middleClickPos)
        return;
    GotoPos(pos);
    if (GetReadOnly())
        return;
    wxTextFileType type;
    switch (GetEOLMode())
    {
        case wxSCI_EOL_CRLF:
            type = wxTextFileType_Dos;
            break;

        case wxSCI_EOL_CR:
            type = wxTextFileType_Mac;
            break;

        case wxSCI_EOL_LF:
            type = wxTextFileType_Unix;
            break;

        default:
            type = wxTextBuffer::typeDefault;
            break;
    }
    AddText(wxTextBuffer::Translate(Manager::Get()->GetEditorManager()->GetSelectionClipboard(), type));
}
Exemplo n.º 8
0
Arquivo: layer.c Projeto: amade/screen
void LPutWinMsg(Layer *l, char *s, int n, struct mchar *r, int x, int y)
{
	int xs2, xe2, y2, len, len2;
	struct mchar or;

	if (x + n > l->l_width)
		n = l->l_width - x;
	if (l->l_pause.d)
		LayPauseUpdateRegion(l, x, x + n - 1, y, y);
	len = strlen(s);
	if (len > n)
		len = n;
	for (Canvas *cv = l->l_cvlist; cv; cv = cv->c_lnext) {
		if (l->l_pause.d && cv->c_slorient)
			continue;
		for (Viewport *vp = cv->c_vplist; vp; vp = vp->v_next) {
			y2 = y + vp->v_yoff;
			if (y2 < vp->v_ys || y2 > vp->v_ye)
				continue;
			xs2 = x + vp->v_xoff;
			xe2 = xs2 + n - 1;
			if (xs2 < vp->v_xs)
				xs2 = vp->v_xs;
			if (xe2 > vp->v_xe)
				xe2 = vp->v_xe;
			if (xs2 > xe2)
				continue;
			display = cv->c_display;
			if (D_blocked)
				continue;
			GotoPos(xs2, y2);
			SetRendition(r);
			len2 = xe2 - (x + vp->v_xoff) + 1;
			if (len2 > len)
				len2 = len;
			PutWinMsg(s, xs2 - x - vp->v_xoff, len2);
			xs2 = x + vp->v_xoff + len2;
			if (xs2 < vp->v_xs)
				xs2 = vp->v_xs;
			or = D_rend;
			GotoPos(xs2, y2);
			SetRendition(&or);
			while (xs2++ <= xe2)
				PUTCHARLP(' ');
		}
	}
}
Exemplo n.º 9
0
/* TextEditor::onCharAdded
 * Called when a character is added to the text
 *******************************************************************/
void TextEditor::onCharAdded(wxStyledTextEvent& e)
{
	// Update line numbers margin width
	string numlines = S_FMT("0%d", GetNumberOfLines());
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, numlines));

	// Auto indent
	int currentLine = GetCurrentLine();
	if (txed_auto_indent && e.GetKey() == '\n')
	{
		// Get indentation amount
		int lineInd = 0;
		if (currentLine > 0)
			lineInd = GetLineIndentation(currentLine - 1);

		// Do auto-indent if needed
		if (lineInd != 0)
		{
			SetLineIndentation(currentLine, lineInd);

			// Skip to end of tabs
			while (1)
			{
				int chr = GetCharAt(GetCurrentPos());
				if (chr == '\t' || chr == ' ')
					GotoPos(GetCurrentPos()+1);
				else
					break;
			}
		}
	}

	// The following require a language to work
	if (language)
	{
		// Call tip
		if (e.GetKey() == '(' && txed_calltips_parenthesis)
		{
			openCalltip(GetCurrentPos());
		}

		// End call tip
		if (e.GetKey() == ')')
		{
			CallTipCancel();
		}

		// Comma, possibly update calltip
		if (e.GetKey() == ',' && txed_calltips_parenthesis)
		{
			//openCalltip(GetCurrentPos());
			//if (CallTipActive())
			updateCalltip();
		}
	}

	// Continue
	e.Skip();
}
Exemplo n.º 10
0
Arquivo: layer.c Projeto: amade/screen
void LClearArea(Layer *l, int xs, int ys, int xe, int ye, int bce, int uself)
{
	int xs2, ys2, xe2, ye2;
	/* Check for zero-height window */
	if (ys < 0 || ye < ys)
		return;

	/* check for magic margin condition */
	if (xs >= l->l_width)
		xs = l->l_width - 1;
	if (xe >= l->l_width)
		xe = l->l_width - 1;
	if (l->l_pause.d)
		LayPauseUpdateRegion(l, xs, xe, ys, ye);
	for (Canvas *cv = l->l_cvlist; cv; cv = cv->c_lnext) {
		if (l->l_pause.d && cv->c_slorient)
			continue;
		display = cv->c_display;
		if (D_blocked)
			continue;
		for (Viewport *vp = cv->c_vplist; vp; vp = vp->v_next) {
			xs2 = xs + vp->v_xoff;
			xe2 = xe + vp->v_xoff;
			ys2 = ys + vp->v_yoff;
			ye2 = ye + vp->v_yoff;
			if (xs2 < vp->v_xs)
				xs2 = vp->v_xs;
			if (xe2 > vp->v_xe)
				xe2 = vp->v_xe;
			if (xs2 > vp->v_xe)
				ys2++;
			if (xe2 < vp->v_xs)
				ye2--;
			if (ys2 < vp->v_ys)
				ys2 = vp->v_ys;
			if (ye2 > vp->v_ye)
				ye2 = vp->v_ye;
			if (ys2 > ye2)
				continue;
			if (xs == 0 || ys2 != ys + vp->v_yoff)
				xs2 = vp->v_xs;
			if (xe == l->l_width - 1 || ye2 != ye + vp->v_yoff)
				xe2 = vp->v_xe;
			display = cv->c_display;
			ClearArea(xs2, ys2, vp->v_xs, vp->v_xe, xe2, ye2, bce, uself);
			if (xe == l->l_width - 1 && xe2 > vp->v_xoff + xe) {
				SetRendition(&mchar_blank);
				for (int y = ys2; y <= ye2; y++) {
					GotoPos(xe + vp->v_xoff + 1, y);
					PUTCHARLP('|');
				}
			}
		}
	}
}
Exemplo n.º 11
0
void wxSTEditorShell::SetPromptText(const wxString& text)
{
    BeginWriteable();
    int length = GetLength();
    wxString promptText = GetPromptText();
    SetTargetStart(length - promptText.Length());
    SetTargetEnd(length);
    ReplaceTarget(text);
    GotoPos(GetLength());
    EndWriteable();
}
Exemplo n.º 12
0
void wxSTEditorShell::AppendText(const wxString &text)
{
    BeginWriteable();                   // make it writeable

    wxSTEditor::AppendText(text);       // write the text
    SetMaxLines(GetMaxLines());         // check for line count overflow
    GotoPos(GetLength());               // put cursor at end
    EmptyUndoBuffer();                  // don't let them undo what you wrote!
                                        //   but they can undo their own typing

    EndWriteable();                     // end the writeable state
}
Exemplo n.º 13
0
bool ctlSQLBox::ReplaceAll(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps)
{
	// Use DoFind to repeatedly replace text
	int count = 0;
	int initialPos = GetCurrentPos();
	GotoPos(0);

	while(DoFind(find, replace, true, wholeWord, matchCase, useRegexps, false, false))
		count++;

	GotoPos(initialPos);

	wxString msg;
	msg.Printf(wxPLURAL("%d replacement made.", "%d replacements made.", count), count);
	wxMessageBox(msg, _("Replace all"), wxOK | wxICON_INFORMATION);

	if (count)
		return true;
	else
		return false;
}
Exemplo n.º 14
0
void wxSTEditorShell::SetPromptText(const wxString& text)
{
    BeginWriteable();
    int length      = GetLength();
    int prompt_line = GetPromptLine();
    int start_pos   = PositionFromLine(prompt_line);
    SetTargetStart(start_pos);
    SetTargetEnd(length);
    ReplaceTarget(text);
    GotoPos(GetLength());
    EndWriteable();
}
Exemplo n.º 15
0
void Edit::OnCharAdded (wxStyledTextEvent &event) {
    char chr = (char)event.GetKey();
    int currentLine = GetCurrentLine();
    // Change this if support for mac files with \r is needed
    if (chr == '\n') {
        int lineInd = 0;
        if (currentLine > 0) {
            lineInd = GetLineIndentation(currentLine - 1);
        }
        if (lineInd == 0) return;
        SetLineIndentation (currentLine, lineInd);
        GotoPos(PositionFromLine (currentLine) + lineInd);
    }
}
Exemplo n.º 16
0
void Edit::OnCharAdded(wxStyledTextEvent &event) {
  event.Skip();
  
  const wxChar c = event.GetKey();
  if (c == wxT('\n')) {
    const int line = GetCurrentLine();
    const int indent = line < 1 ? 0 : GetLineIndentation(line - 1);

    if (indent != 0) {
      SetLineIndentation(line, indent);
      GotoPos(GetLineIndentPosition(line));
    }
  }
}
Exemplo n.º 17
0
bool Edit::FindText(int &found_start, int &found_end, bool find_next)
{
  const int flags = m_FindData.GetFlags();
  const bool find_down = (flags & wxFR_DOWN) ? true : false;
  const wxString find_string = m_FindData.GetFindString();
  found_start = found_end = -1;

  if (find_next) {
    GotoPos(find_down ? GetCurrentPos() : GetCurrentPos() - find_string.size());
  }
  SearchAnchor();

  // search up/down
  found_start = find_down ? SearchNext(flags, find_string) : SearchPrev(flags, find_string);

  // found
  if (found_start > -1) {
    found_end = found_start + find_string.size();
    GotoPos(found_start);
    return true;
  }
  
  return false;
}
Exemplo n.º 18
0
void IWnd_stc::OnCharAdded (wxStyledTextEvent &evt)
{
	char chr = (char)evt.GetKey();
	if (chr == '\n')
	{
		int currentLine = GetCurrentLine();
		if (currentLine < 1) return;

		int lineInd = GetLineIndentation(currentLine - 1);
		if (lineInd == 0) return;

		SetLineIndentation (currentLine, lineInd);
		GotoPos(GetLineIndentPosition(currentLine));
	}

}
Exemplo n.º 19
0
bool wxSTEditorShell::CaretOnPromptLine(STE_CaretPos_Type option)
{
    int prompt_line = GetPromptLine();
    bool on_last    = GetCurrentLine() >= prompt_line;

    //wxPrintf(wxT("Caret on last line total %d current %d onlast %d\n"), total_lines, GetCurrentLine(), (int)on_last);

    if (!on_last && (option != STE_CARET_MOVE_NONE))
    {
        if ((option & STE_CARET_MOVE_LASTLINE) != 0)
            GotoLine(prompt_line);
        else if ((option & STE_CARET_MOVE_ENDTEXT) != 0)
            GotoPos(GetLength());
    }

    return GetCurrentLine() >= prompt_line;
}
Exemplo n.º 20
0
Arquivo: layer.c Projeto: amade/screen
void LPutStr(Layer *l, char *s, int n, struct mchar *r, int x, int y)
{
	char *s2;
	int xs2, xe2, y2;

	if (x + n > l->l_width)
		n = l->l_width - x;
	if (l->l_pause.d)
		LayPauseUpdateRegion(l, x, x + n - 1, y, y);

	for (Canvas *cv = l->l_cvlist; cv; cv = cv->c_lnext) {
		if (l->l_pause.d && cv->c_slorient)
			continue;
		for (Viewport *vp = cv->c_vplist; vp; vp = vp->v_next) {
			y2 = y + vp->v_yoff;
			if (y2 < vp->v_ys || y2 > vp->v_ye)
				continue;
			xs2 = x + vp->v_xoff;
			xe2 = xs2 + n - 1;
			if (xs2 < vp->v_xs)
				xs2 = vp->v_xs;
			if (xe2 > vp->v_xe)
				xe2 = vp->v_xe;
			if (xs2 > xe2)
				continue;
			display = cv->c_display;
			if (D_blocked)
				continue;
			GotoPos(xs2, y2);
			SetRendition(r);
			s2 = s + xs2 - x - vp->v_xoff;
			if (D_encoding == UTF8 && l->l_encoding != UTF8 && (r->font || l->l_encoding)) {
				struct mchar mc;
				mc = *r;
				while (xs2 <= xe2) {
					mc.image = *s2++;
					PutChar(RECODE_MCHAR(&mc), xs2++, y2);
				}
				continue;
			}
			while (xs2++ <= xe2)
				PUTCHARLP(*s2++);
		}
	}
}
Exemplo n.º 21
0
void LogTextControl::addStyledText(const wxString& message, LogStyle style)
{
    if (message.empty())
        return;

    SetReadOnly(false);
    // This implements the typical behaviour for log text controls:
    // When the caret is at the end of the text it will be kept there, keeping
    // the last logged text visible.
    // Otherwise the caret position is not altered, so user can navigate
    // in the already logged text.
    int lenBefore = GetLength();
    bool atEnd = lenBefore == GetCurrentPos();
    AppendText(message);
    int len = GetLength();
    StartStyling(lenBefore, 255);
    SetStyling(len - lenBefore - 1, int(style));
    if (atEnd)
        GotoPos(len);
    SetReadOnly(true);
}
Exemplo n.º 22
0
void SvnBlameEditor::OnContextMenu(wxContextMenuEvent& event)
{
    wxPoint pt       = event.GetPosition();
    wxPoint clientPt = ScreenToClient(pt);

    int margin = GetMarginWidth(0); // get the margin width
    if ( clientPt.x < margin ) {

        GotoPos( PositionFromPoint(clientPt) );
        // Margin context menu
        wxMenu menu;
        menu.Append( XRCID("svn_highlight_revision"), _("Highlight this revision"), _("Highlight this revision"), false);
        menu.Connect(XRCID("svn_highlight_revision"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SvnBlameEditor::OnHighlightRevision), NULL, this);

        PopupMenu(&menu);

    } else {
        wxStyledTextCtrl::OnContextMenu(event);

    }
}
Exemplo n.º 23
0
void
LGotoPos(struct layer *l, int x, int y)
{
  struct canvas *cv;
  struct viewport *vp;
  int x2, y2;

  if (l->l_pause.d)
    LayPauseUpdateRegion(l, x, x, y, y);

  FOR_EACH_UNPAUSED_CANVAS(l,
    {
      display = cv->c_display;
      if (D_blocked)
	continue;
      if (cv != D_forecv)
	continue;
      x2 = x + cv->c_xoff;
      y2 = y + cv->c_yoff;
      debug2("---LGotoPos %d %d\n", x2, y2);
      if (x2 < cv->c_xs)
	x2 = cv->c_xs;
      if (y2 < cv->c_ys)
	y2 = cv->c_ys;
      if (x2 > cv->c_xe)
	x2 = cv->c_xe;
      if (y2 > cv->c_ye)
	y2 = cv->c_ye;
      for (vp = cv->c_vplist; vp; vp = vp->v_next)
	{
	  if (x2 < vp->v_xs || x2 > vp->v_xe)
	    continue;
	  if (y2 < vp->v_ys || y2 > vp->v_ye)
	    continue;
	  GotoPos(x2, y2);
	  break;
	}
    }
  );
Exemplo n.º 24
0
// TOOD: map flags; detect wrap around
void Edit::OnFindDialog(wxFindDialogEvent& event)
{
  wxEventType type = event.GetEventType();

  if(type == wxEVT_FIND || type == wxEVT_FIND_NEXT)
  {
  	const wxString find = event.GetFindString();
    const int curPos = FindLine(event);
    if(curPos > -1) {
      GotoPos(curPos);
      SetSelectionStart(curPos);
      SetSelectionEnd(curPos + find.size());
    }
    else {
      wxLogMessage(wxT("Unable to find \"%s\""), find);
    }
  }
  else if(type == wxEVT_FIND_REPLACE)
  {
    const wxString find = event.GetFindString();
    const int curPos = FindLine(event);
    if(curPos > -1) {
      SetSelectionStart(curPos);
      SetSelectionEnd(curPos + find.size());
      ReplaceSelection(event.GetReplaceString());
    }
    else {
      wxLogMessage(wxT("Unable to find \"%s\""), find);
    }
  }
  else if(type == wxEVT_FIND_REPLACE_ALL) 
  {
    const wxString find = event.GetFindString();
    const wxString replace = event.GetReplaceString();

    const long minPos = GetCurrentPos();
    const long maxPos = GetLastPosition();
    
    int count = 0;
    int curPos = FindText(minPos, maxPos, find);
    while(curPos > minPos) {
      ++count;
      SetSelectionStart(curPos);
      SetSelectionEnd(curPos + find.size());
      ReplaceSelection(replace);
      curPos = FindText(curPos + replace.size(), maxPos, find);
    }
    wxLogMessage(wxT("Replaced %d instance(s) of \"%s\" were replaced with \"%s\""), count, find, replace);
  }
  // FIX ME...
  else if(type == wxEVT_FIND_CLOSE)
  {
/*  
  	if(event.GetDialog() == m_dlgFind) {
  		wxDELETE(m_dlgFind);
  		m_dlgFind = NULL;
  	}
  	else if(event.GetDialog() == m_dlgReplace) {
  		wxDELETE(m_dlgReplace);
  		m_dlgReplace = NULL;
  	}
*/
  }
}
Exemplo n.º 25
0
Arquivo: layer.c Projeto: amade/screen
void LayPause(Layer *layer, bool pause)
{
	Window *win;

	if (layer->l_pause.d == pause)
		return;

	if ((layer->l_pause.d = pause)) {
		/* Start pausing */
		layer->l_pause.top = layer->l_pause.bottom = -1;
		return;
	}

	/* Unpause. So refresh the regions in the displays! */
	if (layer->l_pause.top == -1 && layer->l_pause.bottom == -1)
		return;

	if (layer->l_layfn == &WinLf)	/* Currently, this will always be the case! */
		win = layer->l_data;
	else
		win = NULL;

	for (Canvas *cv = layer->l_cvlist; cv; cv = cv->c_lnext) {
		if (!cv->c_slorient)
			continue;	/* Wasn't split, so already updated. */

		display = cv->c_display;

		for (Viewport *vp = cv->c_vplist; vp; vp = vp->v_next) {
			for (int line = layer->l_pause.top; line <= layer->l_pause.bottom; line++) {
				int xs, xe;

				if (line + vp->v_yoff >= vp->v_ys && line + vp->v_yoff <= vp->v_ye &&
				    ((xs = layer->l_pause.left[line]) >= 0) &&
				    ((xe = layer->l_pause.right[line]) >= 0)) {
					xs += vp->v_xoff;
					xe += vp->v_xoff;

					if (xs < vp->v_xs)
						xs = vp->v_xs;
					if (xe > vp->v_xe)
						xe = vp->v_xe;

					if (layer->l_encoding == UTF8 && xe < vp->v_xe && win) {
						struct mline *ml = win->w_mlines + line;
						if (dw_left(ml, xe, UTF8))
							xe++;
					}

					if (xs <= xe)
						RefreshLine(line + vp->v_yoff, xs, xe, 0);
				}
			}
		}

		if (cv == D_forecv) {
			int cx = layer->l_x + cv->c_xoff;
			int cy = layer->l_y + cv->c_yoff;

			if (cx < cv->c_xs)
				cx = cv->c_xs;
			if (cy < cv->c_ys)
				cy = cv->c_ys;
			if (cx > cv->c_xe)
				cx = cv->c_xe;
			if (cy > cv->c_ye)
				cy = cv->c_ye;

			GotoPos(cx, cy);
		}
	}

	for (int line = layer->l_pause.top; line <= layer->l_pause.bottom; line++)
		layer->l_pause.left[line] = layer->l_pause.right[line] = -1;
}
Exemplo n.º 26
0
void wxSTEditorShell::OnKeyDown(wxKeyEvent &event)
{
    event.Skip(false);
    CheckReadOnly(true);

    switch (event.GetKeyCode())
    {
        case WXK_UP : case WXK_NUMPAD_UP :
        {
            // you can scroll up through multiline entry
            int current_line = GetCurrentLine();
            int prompt_line = GetPromptLine();
            if ((current_line < prompt_line) || (current_line > prompt_line))
                break;

            // up/down arrows go through the history buffer
            wxString promptText = GetPromptText();
            SetPromptText(GetNextHistoryLine(event.GetKeyCode() == WXK_DOWN, promptText));
            return;
        }
        case WXK_DOWN : case WXK_NUMPAD_DOWN :
        {
            // you can scroll down through multiline entry
            int total_lines = GetLineCount();
            total_lines = wxMax(0, total_lines - 1);
            int current_line = GetCurrentLine();
            if (current_line < total_lines)
                break;

            // up/down arrows go through the history buffer
            if ((int)GetHistoryIndex() < (int)GetHistoryCount()-1)
            {
                wxString promptText = GetPromptText();
                SetPromptText(GetNextHistoryLine(event.GetKeyCode() == WXK_DOWN, promptText));
            }
            return;
        }
        case WXK_LEFT : case WXK_NUMPAD_LEFT :
        {
            int current_line = GetCurrentLine();
            int prompt_line = GetPromptLine();
            if (current_line >= prompt_line)
            {
                int caret_pos = 0;
                GetCurLine(&caret_pos);
                if (caret_pos < 1)
                    return;
            }
            break;
        }

        case WXK_PRIOR : case WXK_NUMPAD_PRIOR : //case WXK_NUMPAD_PAGEUP :
        case WXK_NEXT  : case WXK_NUMPAD_NEXT  : //case WXK_NUMPAD_PAGEDOWN :
        case WXK_END   : case WXK_NUMPAD_END   :
        case WXK_HOME  : case WXK_NUMPAD_HOME  :
        case WXK_RIGHT : case WXK_NUMPAD_RIGHT :

        case WXK_SHIFT :
        case WXK_CONTROL :
        case WXK_ALT :
        {
            // default processing for these keys
            event.Skip();
            return;
        }

        case WXK_RETURN : case WXK_NUMPAD_ENTER :
        {
            // put cursor at end if not already on the last line
            if (!CaretOnPromptLine(STE_CARET_MOVE_NONE))
            {
                GotoPos(GetLength());
                return;
            }

            int current_line = GetCurrentLine();
            int prompt_line = GetPromptLine();

            // allow multiline entry for shift+enter
            if ((current_line >= prompt_line) && event.ShiftDown())
            {
                event.Skip();
                return;
            }

            wxString promptText = GetPromptText();

            // goto the end of the line and store the line for the history
            LineEnd();
            if (!promptText.IsEmpty())
                AddHistoryLine(promptText, true);

            // just send the event, the receiver can do what they like
            SendEvent(wxEVT_STESHELL_ENTER, 0, GetState(), promptText);
            return;
        }
        case WXK_BACK :
        {
            // go to the end of the last line if not on last line
            if (!CaretOnPromptLine(STE_CARET_MOVE_NONE))
            {
                GotoPos(GetLength());
                return;
            }
            // don't let them backspace into previous line
            int caret_pos = 0;
            GetCurLine(&caret_pos);
            if (caret_pos < 1)
                return;

            break;
        }
        default : // move cursor to end if not already there
        {
            CaretOnPromptLine(STE_CARET_MOVE_ENDTEXT);
            break;
        }
    }

    event.Skip();
}
Exemplo n.º 27
0
void Ide::GotoCpp(const CppItem& pos)
{
	GotoPos(GetSourceFilePath(pos.file), pos.line);
}
Exemplo n.º 28
0
bool ctlSQLBox::BlockComment(bool uncomment)
{
	wxString lineEnd;
	switch (GetEOLMode())
	{
		case wxSTC_EOL_LF:
			lineEnd = wxT("\n");
			break;
		case wxSTC_EOL_CRLF:
			lineEnd = wxT("\r\n");
			break;
		case wxSTC_EOL_CR:
			lineEnd = wxT("\r");
			break;
	}

	// Save the start position
	const wxString comment = wxT("-- ");
	int start = GetSelectionStart();

	if (!GetSelectedText().IsEmpty())
	{
		wxString selection = GetSelectedText();
		if (!uncomment)
		{
			selection.Replace(lineEnd, lineEnd + comment);
			selection.Prepend(comment);
			if (selection.EndsWith(comment))
				selection = selection.Left(selection.Length() - comment.Length());
		}
		else
		{
			selection.Replace(lineEnd + comment, lineEnd);
			if (selection.StartsWith(comment))
				selection = selection.Right(selection.Length() - comment.Length());
		}
		ReplaceSelection(selection);
		SetSelection(start, start + selection.Length());
	}
	else
	{
		// No text selection - (un)comment the current line
		int column = GetColumn(start);
		int curLineNum = GetCurrentLine();
		int pos = PositionFromLine(curLineNum);

		if (!uncomment)
		{
			InsertText(pos, comment);
		}
		else
		{
			wxString t = GetTextRange(pos, pos + comment.Length());
			if (t == comment)
			{
				// The line starts with a comment, so we remove it
				SetTargetStart(pos);
				SetTargetEnd(pos + comment.Length());
				ReplaceTarget(wxT(""));
			}
			else
			{
				// The line doesn't start with a comment, do nothing
				return false;
			}
		}

		if (GetLineCount() > curLineNum)
		{
			wxString nextLine = GetLine(curLineNum + 1);
			if (nextLine.EndsWith(lineEnd))
				nextLine = nextLine.Left(nextLine.Length() - lineEnd.Length());

			int nextColumn = (nextLine.Length() < (unsigned int)column ? nextLine.Length() : column);
			GotoPos(PositionFromLine(curLineNum + 1) + nextColumn);
		}
	}

	return true;
}
void cbStyledTextCtrl::OnKeyDown(wxKeyEvent& event)
{
    m_lastSelectedText = GetSelectedText();
    bool emulateDwellStart = false;

    switch ( event.GetKeyCode() )
    {
        case _T('I'):
        {
            if (event.GetModifiers() == wxMOD_ALT)
                m_braceShortcutState = true;
            break;
        }

        case WXK_TAB:
        {
            if (m_tabSmartJump && event.GetModifiers() == wxMOD_NONE)
            {
                if (!AutoCompActive() && m_bracePosition != wxSCI_INVALID_POSITION)
                {
                    m_lastPosition = GetCurrentPos();
                    GotoPos(m_bracePosition);

                    // Need judge if it's the final brace
                    HighlightRightBrace();
                    if (!m_tabSmartJump && CallTipActive())
                        CallTipCancel();
                    return;
                }
            }
        }
        break;

        case WXK_BACK:
        {
            if (m_tabSmartJump)
            {
                if (!(event.ControlDown() || event.ShiftDown() || event.AltDown()))
                {
                    const int pos = GetCurrentPos();
                    const int index = s_leftBrace.Find((wxChar)GetCharAt(pos - 1));
                    if (index != wxNOT_FOUND && (wxChar)GetCharAt(pos) == s_rightBrace.GetChar(index))
                    {
                        CharRight();
                        DeleteBack();
                    }
                }
                else if (m_lastPosition != wxSCI_INVALID_POSITION && event.ControlDown())
                {
                    GotoPos(m_lastPosition);
                    m_lastPosition = wxSCI_INVALID_POSITION;
                    return;
                }
            }
        }
        break;

        case WXK_RETURN:
        case WXK_NUMPAD_ENTER:
        case WXK_ESCAPE:
        {
            if (m_tabSmartJump)
                m_tabSmartJump = false;
        }
        break;

        case WXK_CONTROL:
        {
            EmulateDwellStart();
            emulateDwellStart = true;
        }
        break;
        default: break;
    }

    if (event.ControlDown() && !emulateDwellStart)
        EmulateDwellStart();

    event.Skip();
}