diff --git a/Mac-compatibility-build.md b/Mac-compatibility-build.md index cc4c866..a3fa019 100644 --- a/Mac-compatibility-build.md +++ b/Mac-compatibility-build.md @@ -18,6 +18,7 @@ Use [this script](http://devernay.free.fr/hacks/xcodelegacy/) to install older S * --enable-profile * --disable-compat28 * --disable-shared +* --without-liblzma * --without-webviewwebkit * --with-macosx-version-min=10.5 * --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk diff --git a/src/definitions.h b/src/definitions.h index 8c88cc7..b0c4e6c 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -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_CAPTION = "Open Failed"; -// EditPane file extension to lexer mapping +// Typedef some common templates typedef map StringConstMap; typedef map StringMap; @@ -32,7 +32,7 @@ enum myMenuIds { // General Menu ids enum myMenuItemIds { - myID_VIEW_WHITESPACE = wxID_HIGHEST, + myID_VIEW_WHITESPACE = wxID_HIGHEST + 1, myID_VIEW_LINE_ENDINGS, myID_CLOSE_ALL, myID_CLOSE_ALL_BUT_THIS, diff --git a/src/settings/LangConfig.cpp b/src/settings/LangConfig.cpp index 9a5788c..96198f7 100644 --- a/src/settings/LangConfig.cpp +++ b/src/settings/LangConfig.cpp @@ -141,16 +141,8 @@ string LangConfig::GetCurrentLangName() */ string LangConfig::GetLangByName(string name) { - StringMap::iterator it; - - it = this->reverseMap.find(name); - - if (it != reverseMap.end()) - { - return it->second; - } - - return ""; + int count = this->reverseMap.count(name); + return (count > 0) ? this->reverseMap[name] : ""; } /** diff --git a/src/widgets/MainFrame.cpp b/src/widgets/MainFrame.cpp index b9fee72..7b27af2 100644 --- a/src/widgets/MainFrame.cpp +++ b/src/widgets/MainFrame.cpp @@ -136,28 +136,28 @@ void MainFrame::SetupToolbar() void MainFrame::BindEvents() { // File Menu Events - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnNew, this, wxID_NEW); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnOpen, this, wxID_OPEN); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnSave, this, wxID_SAVE); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnSaveAs, this, wxID_SAVEAS); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnCloseTab, this, wxID_CLOSE); - Bind(wxEVT_COMMAND_MENU_SELECTED, &TabContainer::OnCloseAll, notebook, myID_CLOSE_ALL); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnQuit, this, wxID_EXIT); + Bind(wxEVT_MENU, &MainFrame::OnNew, this, wxID_NEW); + Bind(wxEVT_MENU, &MainFrame::OnOpen, this, wxID_OPEN); + Bind(wxEVT_MENU, &MainFrame::OnSave, this, wxID_SAVE); + Bind(wxEVT_MENU, &MainFrame::OnSaveAs, this, wxID_SAVEAS); + Bind(wxEVT_MENU, &MainFrame::OnCloseTab, this, wxID_CLOSE); + Bind(wxEVT_MENU, &TabContainer::OnCloseAll, notebook, myID_CLOSE_ALL); + Bind(wxEVT_MENU, &MainFrame::OnQuit, this, wxID_EXIT); // Edit Menu Events - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditCut, this, wxID_CUT); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditCopy, this, wxID_COPY); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditPaste, this, wxID_PASTE); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditSelectAll, this, wxID_SELECTALL); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditUndo, this, wxID_UNDO); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditRedo, this, wxID_REDO); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditFind, this, wxID_FIND); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditReplace, this, wxID_REPLACE); + Bind(wxEVT_MENU, &MainFrame::OnEditCut, this, wxID_CUT); + Bind(wxEVT_MENU, &MainFrame::OnEditCopy, this, wxID_COPY); + Bind(wxEVT_MENU, &MainFrame::OnEditPaste, this, wxID_PASTE); + Bind(wxEVT_MENU, &MainFrame::OnEditSelectAll, this, wxID_SELECTALL); + Bind(wxEVT_MENU, &MainFrame::OnEditUndo, this, wxID_UNDO); + Bind(wxEVT_MENU, &MainFrame::OnEditRedo, this, wxID_REDO); + Bind(wxEVT_MENU, &MainFrame::OnEditFind, this, wxID_FIND); + Bind(wxEVT_MENU, &MainFrame::OnEditReplace, this, wxID_REPLACE); // View Menu Events - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnToggleWhitespace, this, myID_VIEW_WHITESPACE); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnToggleLineWrap, this, myID_LINE_WRAP); - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnToggleLineEndings, this, myID_VIEW_LINE_ENDINGS); + Bind(wxEVT_MENU, &MainFrame::OnToggleWhitespace, this, myID_VIEW_WHITESPACE); + Bind(wxEVT_MENU, &MainFrame::OnToggleLineWrap, this, myID_LINE_WRAP); + Bind(wxEVT_MENU, &MainFrame::OnToggleLineEndings, this, myID_VIEW_LINE_ENDINGS); // Find/Replace Events Bind(wxEVT_FIND, &MainFrame::OnFindDialog, this, wxID_ANY); @@ -167,10 +167,10 @@ void MainFrame::BindEvents() Bind(wxEVT_FIND_CLOSE, &MainFrame::OnFindDialog, this, wxID_ANY); // Language Selection - Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnLangSelect, this, wxID_ANY); + Bind(wxEVT_MENU, &MainFrame::OnLangSelect, this, wxID_ANY); // 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) { - int selection = event.GetSelection(); - + wxMenu *selectedMenu = (wxMenu *) event.GetEventObject(); wxMenu *langMenu = Glob_menu_bar->GetMenu(myLANG_MENU); - wxMenuItem *sel_item = langMenu->FindItem(selection); - - if (sel_item != NULL) + if (langMenu == NULL) wxLogDebug("Couldn't get lang menu"); + + if (selectedMenu == langMenu) { - wxLogDebug("New language selection"); - + wxMenuItem *sel_item = langMenu->FindChildItem(event.GetId()); wxString itemLabel = sel_item->GetItemLabelText(); + notebook->GetCurrentEditor()->SetCurrentLang(itemLabel.ToStdString()); } else