Language highlighting selection works!

This commit is contained in:
Tim Warren 2015-05-14 14:59:04 -04:00
parent 469c6d4acf
commit 9904e20f61
4 changed files with 31 additions and 39 deletions

View File

@ -18,6 +18,7 @@ Use [this script](http://devernay.free.fr/hacks/xcodelegacy/) to install older S
* --enable-profile * --enable-profile
* --disable-compat28 * --disable-compat28
* --disable-shared * --disable-shared
* --without-liblzma
* --without-webviewwebkit * --without-webviewwebkit
* --with-macosx-version-min=10.5 * --with-macosx-version-min=10.5
* --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk * --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk

View File

@ -17,7 +17,7 @@ const wxString TYRO_SAVE_ERROR_CAPTION = "Saving Failed";
const wxString TYRO_OPEN_ERROR = "Failed to open the file. Check that it exists, and that you have read permissions."; const wxString TYRO_OPEN_ERROR = "Failed to open the file. Check that it exists, and that you have read permissions.";
const wxString TYRO_OPEN_ERROR_CAPTION = "Open Failed"; const wxString TYRO_OPEN_ERROR_CAPTION = "Open Failed";
// EditPane file extension to lexer mapping // Typedef some common templates
typedef map<string, int> StringConstMap; typedef map<string, int> StringConstMap;
typedef map<string, string> StringMap; typedef map<string, string> StringMap;
@ -32,7 +32,7 @@ enum myMenuIds {
// General Menu ids // General Menu ids
enum myMenuItemIds { enum myMenuItemIds {
myID_VIEW_WHITESPACE = wxID_HIGHEST, myID_VIEW_WHITESPACE = wxID_HIGHEST + 1,
myID_VIEW_LINE_ENDINGS, myID_VIEW_LINE_ENDINGS,
myID_CLOSE_ALL, myID_CLOSE_ALL,
myID_CLOSE_ALL_BUT_THIS, myID_CLOSE_ALL_BUT_THIS,

View File

@ -141,16 +141,8 @@ string LangConfig::GetCurrentLangName()
*/ */
string LangConfig::GetLangByName(string name) string LangConfig::GetLangByName(string name)
{ {
StringMap::iterator it; int count = this->reverseMap.count(name);
return (count > 0) ? this->reverseMap[name] : "";
it = this->reverseMap.find(name);
if (it != reverseMap.end())
{
return it->second;
}
return "";
} }
/** /**

View File

@ -136,28 +136,28 @@ void MainFrame::SetupToolbar()
void MainFrame::BindEvents() void MainFrame::BindEvents()
{ {
// File Menu Events // File Menu Events
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnNew, this, wxID_NEW); Bind(wxEVT_MENU, &MainFrame::OnNew, this, wxID_NEW);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnOpen, this, wxID_OPEN); Bind(wxEVT_MENU, &MainFrame::OnOpen, this, wxID_OPEN);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnSave, this, wxID_SAVE); Bind(wxEVT_MENU, &MainFrame::OnSave, this, wxID_SAVE);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnSaveAs, this, wxID_SAVEAS); Bind(wxEVT_MENU, &MainFrame::OnSaveAs, this, wxID_SAVEAS);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnCloseTab, this, wxID_CLOSE); Bind(wxEVT_MENU, &MainFrame::OnCloseTab, this, wxID_CLOSE);
Bind(wxEVT_COMMAND_MENU_SELECTED, &TabContainer::OnCloseAll, notebook, myID_CLOSE_ALL); Bind(wxEVT_MENU, &TabContainer::OnCloseAll, notebook, myID_CLOSE_ALL);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnQuit, this, wxID_EXIT); Bind(wxEVT_MENU, &MainFrame::OnQuit, this, wxID_EXIT);
// Edit Menu Events // Edit Menu Events
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditCut, this, wxID_CUT); Bind(wxEVT_MENU, &MainFrame::OnEditCut, this, wxID_CUT);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditCopy, this, wxID_COPY); Bind(wxEVT_MENU, &MainFrame::OnEditCopy, this, wxID_COPY);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditPaste, this, wxID_PASTE); Bind(wxEVT_MENU, &MainFrame::OnEditPaste, this, wxID_PASTE);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditSelectAll, this, wxID_SELECTALL); Bind(wxEVT_MENU, &MainFrame::OnEditSelectAll, this, wxID_SELECTALL);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditUndo, this, wxID_UNDO); Bind(wxEVT_MENU, &MainFrame::OnEditUndo, this, wxID_UNDO);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditRedo, this, wxID_REDO); Bind(wxEVT_MENU, &MainFrame::OnEditRedo, this, wxID_REDO);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditFind, this, wxID_FIND); Bind(wxEVT_MENU, &MainFrame::OnEditFind, this, wxID_FIND);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditReplace, this, wxID_REPLACE); Bind(wxEVT_MENU, &MainFrame::OnEditReplace, this, wxID_REPLACE);
// View Menu Events // View Menu Events
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnToggleWhitespace, this, myID_VIEW_WHITESPACE); Bind(wxEVT_MENU, &MainFrame::OnToggleWhitespace, this, myID_VIEW_WHITESPACE);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnToggleLineWrap, this, myID_LINE_WRAP); Bind(wxEVT_MENU, &MainFrame::OnToggleLineWrap, this, myID_LINE_WRAP);
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnToggleLineEndings, this, myID_VIEW_LINE_ENDINGS); Bind(wxEVT_MENU, &MainFrame::OnToggleLineEndings, this, myID_VIEW_LINE_ENDINGS);
// Find/Replace Events // Find/Replace Events
Bind(wxEVT_FIND, &MainFrame::OnFindDialog, this, wxID_ANY); Bind(wxEVT_FIND, &MainFrame::OnFindDialog, this, wxID_ANY);
@ -167,10 +167,10 @@ void MainFrame::BindEvents()
Bind(wxEVT_FIND_CLOSE, &MainFrame::OnFindDialog, this, wxID_ANY); Bind(wxEVT_FIND_CLOSE, &MainFrame::OnFindDialog, this, wxID_ANY);
// Language Selection // Language Selection
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnLangSelect, this, wxID_ANY); Bind(wxEVT_MENU, &MainFrame::OnLangSelect, this, wxID_ANY);
// Help Menu Events // Help Menu Events
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnAbout, this, wxID_ABOUT); Bind(wxEVT_MENU, &MainFrame::OnAbout, this, wxID_ABOUT);
} }
/** /**
@ -607,16 +607,15 @@ void MainFrame::EnableEditControls(bool enable)
*/ */
void MainFrame::OnLangSelect(wxCommandEvent &event) void MainFrame::OnLangSelect(wxCommandEvent &event)
{ {
int selection = event.GetSelection(); wxMenu *selectedMenu = (wxMenu *) event.GetEventObject();
wxMenu *langMenu = Glob_menu_bar->GetMenu(myLANG_MENU); wxMenu *langMenu = Glob_menu_bar->GetMenu(myLANG_MENU);
wxMenuItem *sel_item = langMenu->FindItem(selection); if (langMenu == NULL) wxLogDebug("Couldn't get lang menu");
if (sel_item != NULL) if (selectedMenu == langMenu)
{ {
wxLogDebug("New language selection"); wxMenuItem *sel_item = langMenu->FindChildItem(event.GetId());
wxString itemLabel = sel_item->GetItemLabelText(); wxString itemLabel = sel_item->GetItemLabelText();
notebook->GetCurrentEditor()->SetCurrentLang(itemLabel.ToStdString()); notebook->GetCurrentEditor()->SetCurrentLang(itemLabel.ToStdString());
} }
else else