diff --git a/src/widgets/EditPane.cpp b/src/widgets/EditPane.cpp index 29c6b4d..814fb49 100644 --- a/src/widgets/EditPane.cpp +++ b/src/widgets/EditPane.cpp @@ -322,6 +322,7 @@ bool EditPane::FileWritable() void EditPane::BindEvents() { Bind(wxEVT_STC_MARGINCLICK, &EditPane::OnMarginClick, this, wxID_ANY); + Bind(wxEVT_STC_CHARADDED, &EditPane::OnCharAdded, this, wxID_ANY); } /** @@ -341,6 +342,31 @@ void EditPane::OnMarginClick(wxStyledTextEvent& event) } } +/** + * Look at characters added to help with indentation + * + * @param wxStyledTextEvent& event + * @return void + */ +void EditPane::OnCharAdded(wxStyledTextEvent& event) +{ + char chr = (char) event.GetKey(); + int currentLine = this->GetCurrentLine(); + + if (chr == '\n') + { + int lineInd = 0; + if (currentLine > 0) + { + lineInd = this->GetLineIndentation(currentLine - 1); + } + if (lineInd == 0) return; + + this->SetLineIndentation(currentLine, lineInd); + this->GotoPos(this->PositionFromLine(currentLine) + (lineInd / 4)); + } +} + /** * Get the list of keywords for the selected language * @@ -439,7 +465,7 @@ void EditPane::_ApplyTheme(JsonValue lexer_map, int addtoi) this->StyleSetForeground (wxSTC_STYLE_DEFAULT, default_foreground); this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161)); - this->SetMarginWidth (MARGIN_LINE_NUMBERS, TextWidth(wxSTC_STYLE_LINENUMBER, _T("_9999"))); + this->SetMarginWidth (MARGIN_LINE_NUMBERS, TextWidth(wxSTC_STYLE_LINENUMBER, _T("_99999"))); this->StyleSetForeground (wxSTC_STYLE_LINENUMBER, line_number_foreground); this->StyleSetBackground (wxSTC_STYLE_LINENUMBER, line_number_background); this->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER); diff --git a/src/widgets/EditPane.h b/src/widgets/EditPane.h index 1111a71..d7eb3f9 100644 --- a/src/widgets/EditPane.h +++ b/src/widgets/EditPane.h @@ -39,6 +39,7 @@ private: bool FileWritable(); void BindEvents(); void OnMarginClick(wxStyledTextEvent &event); + void OnCharAdded(wxStyledTextEvent &event); void SetTheme(string theme_name); JsonValue GetThemeValue(string type, string key); wxColor GetThemeColor(string type, string key); diff --git a/src/widgets/MainFrame.cpp b/src/widgets/MainFrame.cpp index d00e4c3..9358b4b 100644 --- a/src/widgets/MainFrame.cpp +++ b/src/widgets/MainFrame.cpp @@ -150,6 +150,8 @@ void MainFrame::SetupMenu() //editMenu->Append(wxID_FIND, "&Find\tCtrl+F"); //editMenu->Append(wxID_REPLACE, "&Replace\tCtrl+R"); //editMenu->AppendSeparator(); + editMenu->Append(wxID_PREFERENCES, "&Preferences\tCtrl+P"); + editMenu->AppendSeparator(); editMenu->Append(wxID_SELECTALL, "Select All\tCtrl+A", "Select all the text in the current document"); viewMenu->AppendCheckItem(myID_VIEW_WHITESPACE, "Show Invisible Characters\tCtrl+Shift+I", "Toggle visibility of white space characters"); @@ -409,6 +411,18 @@ void MainFrame::OnToggleWhitespace(wxCommandEvent& event) editor->SetViewEOL(event.IsChecked()); } +void MainFrame::OnFind (wxCommandEvent &WXUNUSED(event)) { +} + +void MainFrame::OnFindNext (wxCommandEvent &WXUNUSED(event)) { +} + +void MainFrame::OnReplace (wxCommandEvent &WXUNUSED(event)) { +} + +void MainFrame::OnReplaceNext (wxCommandEvent &WXUNUSED(event)) { +} + /** * Toggle enable/disable of document-specific controls * diff --git a/src/widgets/MainFrame.h b/src/widgets/MainFrame.h index 438fecb..8930a41 100644 --- a/src/widgets/MainFrame.h +++ b/src/widgets/MainFrame.h @@ -43,12 +43,19 @@ class MainFrame: public wxFrame void OnFileClose(wxCommandEvent &event); void OnSave(wxCommandEvent &event); void OnSaveAs(wxCommandEvent &event); + void OnEditCut(wxCommandEvent &event); void OnEditCopy(wxCommandEvent &event); void OnEditPaste(wxCommandEvent &event); void OnEditSelectAll(wxCommandEvent &event); void OnEditUndo(wxCommandEvent &event); void OnEditRedo(wxCommandEvent &event); + + void OnFind (wxCommandEvent &event); + void OnFindNext (wxCommandEvent &event); + void OnReplace (wxCommandEvent &event); + void OnReplaceNext (wxCommandEvent &event); + void OnCloseTab(wxCommandEvent &event); void OnToggleWhitespace(wxCommandEvent &event); void OnQuit(wxCommandEvent &event);