Indentation help, and setup for some new functionality

This commit is contained in:
Tim Warren 2015-04-28 14:58:52 -04:00
parent a5da4634ce
commit 6c17981afe
4 changed files with 49 additions and 1 deletions

View File

@ -322,6 +322,7 @@ bool EditPane::FileWritable()
void EditPane::BindEvents() void EditPane::BindEvents()
{ {
Bind(wxEVT_STC_MARGINCLICK, &EditPane::OnMarginClick, this, wxID_ANY); 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 * 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_DEFAULT, default_foreground);
this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161)); 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->StyleSetForeground (wxSTC_STYLE_LINENUMBER, line_number_foreground);
this->StyleSetBackground (wxSTC_STYLE_LINENUMBER, line_number_background); this->StyleSetBackground (wxSTC_STYLE_LINENUMBER, line_number_background);
this->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER); this->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);

View File

@ -39,6 +39,7 @@ private:
bool FileWritable(); bool FileWritable();
void BindEvents(); void BindEvents();
void OnMarginClick(wxStyledTextEvent &event); void OnMarginClick(wxStyledTextEvent &event);
void OnCharAdded(wxStyledTextEvent &event);
void SetTheme(string theme_name); void SetTheme(string theme_name);
JsonValue GetThemeValue(string type, string key); JsonValue GetThemeValue(string type, string key);
wxColor GetThemeColor(string type, string key); wxColor GetThemeColor(string type, string key);

View File

@ -150,6 +150,8 @@ void MainFrame::SetupMenu()
//editMenu->Append(wxID_FIND, "&Find\tCtrl+F"); //editMenu->Append(wxID_FIND, "&Find\tCtrl+F");
//editMenu->Append(wxID_REPLACE, "&Replace\tCtrl+R"); //editMenu->Append(wxID_REPLACE, "&Replace\tCtrl+R");
//editMenu->AppendSeparator(); //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"); 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"); 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()); 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 * Toggle enable/disable of document-specific controls
* *

View File

@ -43,12 +43,19 @@ class MainFrame: public wxFrame
void OnFileClose(wxCommandEvent &event); void OnFileClose(wxCommandEvent &event);
void OnSave(wxCommandEvent &event); void OnSave(wxCommandEvent &event);
void OnSaveAs(wxCommandEvent &event); void OnSaveAs(wxCommandEvent &event);
void OnEditCut(wxCommandEvent &event); void OnEditCut(wxCommandEvent &event);
void OnEditCopy(wxCommandEvent &event); void OnEditCopy(wxCommandEvent &event);
void OnEditPaste(wxCommandEvent &event); void OnEditPaste(wxCommandEvent &event);
void OnEditSelectAll(wxCommandEvent &event); void OnEditSelectAll(wxCommandEvent &event);
void OnEditUndo(wxCommandEvent &event); void OnEditUndo(wxCommandEvent &event);
void OnEditRedo(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 OnCloseTab(wxCommandEvent &event);
void OnToggleWhitespace(wxCommandEvent &event); void OnToggleWhitespace(wxCommandEvent &event);
void OnQuit(wxCommandEvent &event); void OnQuit(wxCommandEvent &event);