EditorSettingsTerminal::EditorSettingsTerminal( wxWindow* parent )
    : EditorSettingsTerminalBase( parent )
    , TreeBookNode<EditorSettingsTerminal>()

{
    OptionsConfigPtr options = EditorConfigST::Get()->GetOptions();
    m_textCtrlProgramConsoleCmd->SetValue(options->GetProgramConsoleCommand());
    m_checkBoxUseCodeLiteTerminal->SetValue( options->HasOption( OptionsConfig::Opt_Use_CodeLite_Terminal) );
}
EditorOptionsGeneralGuidesPanel::EditorOptionsGeneralGuidesPanel(wxWindow* parent)
    : EditorOptionsGeneralGuidesPanelBase(parent)
    , TreeBookNode<EditorOptionsGeneralGuidesPanel>()
{
    OptionsConfigPtr options = EditorConfigST::Get()->GetOptions();

    m_displayLineNumbers->SetValue(options->GetDisplayLineNumbers());
    m_checkBoxMatchBraces->SetValue(options->GetHighlightMatchedBraces());
    m_showIndentationGuideLines->SetValue(options->GetShowIndentationGuidelines());
    m_highlightCaretLine->SetValue(options->GetHighlightCaretLine());
    m_caretLineColourPicker->SetColour(options->GetCaretLineColour());
    const wxString EOLChoices[] = { wxTRANSLATE("Default"), wxT("Mac (CR)"), wxT("Windows (CRLF)"), wxT("Unix (LF)") };
    m_EOLstringManager.AddStrings(
        sizeof(EOLChoices) / sizeof(wxString), EOLChoices, options->GetEolMode(), m_choiceEOL);
    m_checkBoxHideChangeMarkerMargin->SetValue(options->GetHideChangeMarkerMargin());
    m_checkBoxDisableSemicolonShift->SetValue(options->GetDisableSemicolonShift());

    m_checkBoxMarkdebuggerLine->SetValue(options->HasOption(OptionsConfig::Opt_Mark_Debugger_Line));
    m_colourPickerDbgLine->SetColour(options->GetDebuggerMarkerLine());

    const wxString WhitespaceStyle[] = { wxTRANSLATE("Invisible"),
                                         wxTRANSLATE("Visible always"),
                                         wxTRANSLATE("Visible after indentation") };
    wxString currentWhitespace;
    switch(options->GetShowWhitspaces()) {
    case wxSTC_WS_VISIBLEALWAYS:
        currentWhitespace = wxT("Visible always");
        break;
    case wxSTC_WS_VISIBLEAFTERINDENT:
        currentWhitespace = wxT("Visible after indentation");
        break;
    default:
        currentWhitespace = wxT("Invisible");
        break;
    }
    m_WSstringManager.AddStrings(
        sizeof(WhitespaceStyle) / sizeof(wxString), WhitespaceStyle, currentWhitespace, m_whitespaceStyle);
}
Exemplo n.º 3
0
//------------------------------------
// Handle copy events
//------------------------------------
void EditHandler::ProcessCommandEvent(wxWindow *owner, wxCommandEvent &event)
{
    wxUnusedVar(event);
    LEditor *editor = (LEditor*)owner;
    
    OptionsConfigPtr options = editor->GetOptions();
    // hide completion box
    editor->HideCompletionBox();
    bool isSelectionEmpty = editor->GetSelectedText().IsEmpty();
    
    if (event.GetId() == wxID_COPY) {
        
        // reset the 'full line' copy/cut flag
        editor->SetFullLineCopyCut(false);
        
        if ( isSelectionEmpty && options->HasOption( OptionsConfig::Opt_CopyNothing) ) {
            // do nothing
            
        } else if ( isSelectionEmpty && options->HasOption( OptionsConfig::Opt_CopyLineIfLineNotEmpty ) ) {
            // Copy the line content only when the caret line is not empty
            int lineNumber = editor->GetCurrentLine();
            wxString lineContent = editor->GetLine(lineNumber);
            if ( !lineContent.Trim().Trim(false).IsEmpty() ) {
                editor->CopyAllowLine();
                editor->SetFullLineCopyCut(true);
            }
        } else if ( isSelectionEmpty ) {
            // default behavior
            editor->CopyAllowLine();
            editor->SetFullLineCopyCut(true);

        } else {
            editor->Copy();
        }

    } else if (event.GetId() == wxID_CUT) {
        
        // reset the 'full line' copy/cut flag
        editor->SetFullLineCopyCut(false);
        
        if ( isSelectionEmpty && options->HasOption( OptionsConfig::Opt_CopyNothing) ) {
            // do nothing
            
        } else if ( isSelectionEmpty && options->HasOption( OptionsConfig::Opt_CopyLineIfLineNotEmpty ) ) {
            // Copy the line content only when the caret line is not empty
            int lineNumber = editor->GetCurrentLine();
            wxString lineContent = editor->GetLine(lineNumber);
            if ( !lineContent.Trim().Trim(false).IsEmpty() ) {
                editor->CopyAllowLine();
                editor->LineDelete();
                editor->SetFullLineCopyCut(true);
            }
        } else if ( isSelectionEmpty ) {
            
            // default behavior
            editor->CopyAllowLine();
            editor->LineDelete();
            editor->SetFullLineCopyCut(true);
        
        } else {
            editor->Cut();
        }

    } else if (event.GetId() == wxID_PASTE) {
        if ( editor->IsFullLineCopyCut() ) {
            // paste one line above the caret
            editor->PasteLineAbove();
            
        } else {
            // paste at caret position
            editor->Paste();
            
        }

    } else if (event.GetId() == wxID_UNDO) {
        if (editor->GetCommandsProcessor().CanUndo()) {
            editor->Undo();
            editor->GetCommandsProcessor().DecrementCurrentCommand();
        }

    } else if (event.GetId() == wxID_REDO) {
        if (editor->GetCommandsProcessor().CanRedo()) {
            editor->Redo();
            editor->GetCommandsProcessor().IncrementCurrentCommand();
        }

    } else if (event.GetId() == XRCID("label_current_state")) {
        wxString label = wxGetTextFromUser("What would you like to call the current state?", "Label current state", "", editor);
        if (!label.empty()) {
            editor->GetCommandsProcessor().SetUserLabel(label);
        }

    } else if (event.GetId() == wxID_SELECTALL) {
        editor->SelectAll();

    } else if (event.GetId() == wxID_DUPLICATE) {
        editor->SelectionDuplicate();
    } else if (event.GetId() == XRCID("delete_line_end")) {
        editor->DelLineRight();

    } else if (event.GetId() == XRCID("delete_line_start")) {
        editor->DelLineLeft();

    } else if (event.GetId() == XRCID("delete_line")) {
        editor->LineDelete();

    } else if (event.GetId() == XRCID("trim_trailing")) {
        editor->TrimText(true, false);

    } else if (event.GetId() == XRCID("to_lower")) {
        editor->ChangeCase(true);

    } else if (event.GetId() == XRCID("to_upper")) {
        editor->ChangeCase(false);

    } else if (event.GetId() == XRCID("transpose_lines")) {
        editor->LineTranspose();

    } else if (event.GetId() == wxID_DELETE) {
        editor->DeleteBack();

    } else if (event.GetId() == XRCID("move_line_down")) {

        int curline  = editor->GetCurrentLine();
        int lastline = editor->LineFromPosition(editor->GetLength()-1);

        if (editor->GetSelection().empty()
                ||  (editor->LineFromPos(editor->GetSelectionStart() == editor->LineFromPos(editor->GetSelectionEnd())))) {
            // No selection (or only a trivial 1-line one)
            if (curline != lastline) {
                editor->LineDown();              
                editor->LineTranspose();
            }

        } else {
            editor->MoveSelectedLinesDown();  // There is a selection, so we can move it direct
        }

    } else if (event.GetId() == XRCID("move_line_up")) {

        if (editor->GetSelection().empty()
                ||  (editor->LineFromPos(editor->GetSelectionStart() == editor->LineFromPos(editor->GetSelectionEnd())))) {
            // No selection (or only a trivial 1-line one)
            editor->LineTranspose();
            editor->LineUp();

        } else {
            editor->MoveSelectedLinesUp();  // There is a selection, so we can move it direct
        }

    } else if (event.GetId() == XRCID("center_line")) {
        //editor->VerticalCentreCaret();

    } else if (event.GetId() == XRCID("center_line_roll")) {
        int here    = editor->GetCurrentLine();
        int top     = editor->GetFirstVisibleLine();
        int count   = editor->LinesOnScreen();
        int center  = top + (count / 2);
        if (here < center) {
            for (int lnIterator = 0; lnIterator < center - here; lnIterator++)
                editor->LineScrollUp();   //roll up until we get to center
        } else if (here > center) {
            for (int lnIterator = 0; lnIterator < here - center; lnIterator++)
                editor->LineScrollDown(); //roll down until we get to center
        }

    }
}