Skip to content

Commit

Permalink
When selecting the "Git" tab, refresh the view
Browse files Browse the repository at this point in the history
Signed-off-by: Eran Ifrah <[email protected]>
  • Loading branch information
eranif committed Dec 17, 2024
1 parent 1238958 commit 10c4108
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 161 deletions.
1 change: 1 addition & 0 deletions CodeLite/codelite_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,4 @@ wxDEFINE_EVENT(wxEVT_OPEN_FILE, clCommandEvent);
wxDEFINE_EVENT(wxEVT_RECENT_WORKSPACE, clRecentWorkspaceEvent);
wxDEFINE_EVENT(wxEVT_FILE_MODIFIED_EXTERNALLY, clFileSystemEvent);
wxDEFINE_EVENT(wxEVT_EDITOR_MARGIN_CLICKED, clEditorEvent);
wxDEFINE_EVENT(wxEVT_OUTPUT_VIEW_TAB_CHANGED, clCommandEvent);
24 changes: 17 additions & 7 deletions CodeLite/codelite_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_GET_TAB_BORDER_COLOUR, clColourEv
// it simply needs to connect the event and avoid calling 'event.Skip();
//----------------------------------------------------------------------
wxDECLARE_EXPORTED_EVENT(
WXDLLIMPEXP_CL, wxEVT_DBG_UI_START,
WXDLLIMPEXP_CL,
wxEVT_DBG_UI_START,
clDebugEvent); // Start. This event is fired when a debug session is starting. The plugin should also set the
// "feaures" field to indicate which features are available by the debugger
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_CONTINUE, clDebugEvent); // Continue
Expand All @@ -641,11 +642,13 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_STEP_OUT, clDebugEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_NEXT, clDebugEvent); // Next line
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_NEXT_INST, clDebugEvent); // Next instruction
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_INTERRUPT, clDebugEvent); // Interrupt the debugger execution
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_SHOW_CURSOR,
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL,
wxEVT_DBG_UI_SHOW_CURSOR,
clDebugEvent); // Set the focus to the current debugger file/line
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_RESTART, clDebugEvent); // Restart the debug session
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_IS_RUNNING, clDebugEvent); // Use evet.SetAnswer() method to reply
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_TOGGLE_BREAKPOINT,
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL,
wxEVT_DBG_UI_TOGGLE_BREAKPOINT,
clDebugEvent); // Toggle breakpoint. Use event.GetFileName() / event.GetInt() for the file:line

/// User added breakpoint from the UI
Expand All @@ -670,18 +673,22 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_EXPR_TOOLTIP, clDebugEvent);
// etc)
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_IS_PLUGIN_DEBUGGER, clDebugEvent);

wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_QUICK_DEBUG,
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL,
wxEVT_DBG_UI_QUICK_DEBUG,
clDebugEvent); // User clicked on the 'Quick Debug' button. Event type is clDebugEvent
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_CORE_FILE,
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL,
wxEVT_DBG_UI_CORE_FILE,
clDebugEvent); // User selected to debug a core file. Event type is clDebugEvent
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_ATTACH_TO_PROCESS,
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL,
wxEVT_DBG_UI_ATTACH_TO_PROCESS,
clDebugEvent); // Attach to process. Use clDebugEvent::GetInt() to get the process ID
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_DELETE_ALL_BREAKPOINTS, clDebugEvent); // Delete all breakpoints
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_ENABLE_ALL_BREAKPOINTS, clDebugEvent); // Enable all breakpoints
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_DBG_UI_DISABLE_ALL_BREAKPOINTS, clDebugEvent); // Disable all breakpoints

// -------------------Debugger events end------------------------------------------------
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_CMD_OPEN_PROJ_SETTINGS,
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL,
wxEVT_CMD_OPEN_PROJ_SETTINGS,
clCommandEvent); // clCommandEvent. Use event.GetString() to get the project name

// event type: clNewProjectEvent
Expand Down Expand Up @@ -985,4 +992,7 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_FILE_MODIFIED_EXTERNALLY, clFileS
// User clicked on a margin with user data
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_EDITOR_MARGIN_CLICKED, clEditorEvent);

// The output view tab changed. The new active tab can be retrieved from event.GetString()
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_OUTPUT_VIEW_TAB_CHANGED, clCommandEvent);

#endif // CODELITE_EVENTS_H
34 changes: 23 additions & 11 deletions Interfaces/imanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ class IManager
/// - "Output View"
virtual void ShowPane(const wxString& pane_name, bool show) = 0;

/// Return true if `pane_name` is shown. If `tab` is not empty, also check that it is the
/// selected tab
virtual bool IsPaneShown(const wxString& pane_name, const wxString& tab = wxEmptyString) = 0;

/**
* @brief show the toolbar. This only works when using the native toolbar
*/
Expand Down Expand Up @@ -243,20 +247,24 @@ class IManager
* @param lineno if lineno is not wxNOT_FOUD, the caret will placed on this line number
* @return Pointer to the newly opened editor or nullptr
*/
virtual IEditor* OpenFile(const wxString& fileName, const wxString& projectName = wxEmptyString,
int lineno = wxNOT_FOUND, OF_extra flags = OF_AddJump) = 0;
virtual IEditor* OpenFile(const wxString& fileName,
const wxString& projectName = wxEmptyString,
int lineno = wxNOT_FOUND,
OF_extra flags = OF_AddJump) = 0;

/**
* @brief open a file with a given tooltip and bitmap
*/
virtual IEditor* OpenFile(const wxString& fileName, const wxString& bmpResourceName,
const wxString& tooltip = wxEmptyString) = 0;
virtual IEditor*
OpenFile(const wxString& fileName, const wxString& bmpResourceName, const wxString& tooltip = wxEmptyString) = 0;

/**
* @brief load a remote file content (represented by the local_path) into an `IEdtor`
*/
virtual IEditor* OpenRemoteFile(const wxString& local_path, const wxString& remote_path,
const wxString& ssh_account, const wxString& tooltip = wxEmptyString) = 0;
virtual IEditor* OpenRemoteFile(const wxString& local_path,
const wxString& remote_path,
const wxString& ssh_account,
const wxString& tooltip = wxEmptyString) = 0;

/**
* @brief open or select ((if the file is already loaded in CodeLite) editor with a given `file_name` to the
Expand Down Expand Up @@ -564,8 +572,11 @@ class IManager
/**
* @brief add a page to the mainbook
*/
virtual bool AddPage(wxWindow* win, const wxString& text, const wxString& tooltip = wxEmptyString,
const wxString& bmpResourceName = wxEmptyString, bool selected = false) = 0;
virtual bool AddPage(wxWindow* win,
const wxString& text,
const wxString& tooltip = wxEmptyString,
const wxString& bmpResourceName = wxEmptyString,
bool selected = false) = 0;

/**
* @brief select a window in mainbook
Expand Down Expand Up @@ -705,7 +716,8 @@ class IManager
/**
* @brief display message to the user using the info bar
*/
virtual void DisplayMessage(const wxString& message, int flags = wxICON_INFORMATION,
virtual void DisplayMessage(const wxString& message,
int flags = wxICON_INFORMATION,
const std::vector<std::pair<wxWindowID, wxString>>& buttons = {}) = 0;

/**
Expand All @@ -728,8 +740,8 @@ class IManager
///--------------------

/// Add a book page
virtual void BookAddPage(PaneId pane_id, wxWindow* page, const wxString& label,
const wxString& bmp = wxEmptyString) = 0;
virtual void
BookAddPage(PaneId pane_id, wxWindow* page, const wxString& label, const wxString& bmp = wxEmptyString) = 0;

/// Find a book page by its label
virtual wxWindow* BookGetPage(PaneId pane_id, const wxString& label) = 0;
Expand Down
60 changes: 32 additions & 28 deletions LiteEditor/output_pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ OutputPane::OutputPane(wxWindow* parent, const wxString& caption, long style)
OutputPane::~OutputPane()
{
m_book->Unbind(wxEVT_BOOK_PAGE_CHANGED, &OutputPane::OnPageChanged, this);
EventNotifier::Get()->Disconnect(wxEVT_EDITOR_CLICKED, wxCommandEventHandler(OutputPane::OnEditorFocus), NULL,
this);
EventNotifier::Get()->Disconnect(
wxEVT_EDITOR_CLICKED, wxCommandEventHandler(OutputPane::OnEditorFocus), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_BUILD_STARTED, clBuildEventHandler(OutputPane::OnBuildStarted), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_BUILD_ENDED, clBuildEventHandler(OutputPane::OnBuildEnded), NULL, this);
EventNotifier::Get()->Unbind(wxEVT_EDITOR_CONFIG_CHANGED, &OutputPane::OnSettingsChanged, this);
Expand All @@ -77,23 +77,23 @@ void OutputPane::CreateGUIControls()
SetSizer(mainSizer);
SetMinClientSize(wxSize(-1, 250));
long style = (kNotebook_Default | kNotebook_AllowDnD);
if(EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection() == wxBOTTOM) {
if (EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection() == wxBOTTOM) {
style |= kNotebook_BottomTabs;
} else if(EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection() == wxLEFT) {
} else if (EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection() == wxLEFT) {
#ifdef __WXOSX__
style &= ~(kNotebook_BottomTabs | kNotebook_LeftTabs | kNotebook_RightTabs);
#else
style |= kNotebook_LeftTabs;
#endif
} else if(EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection() == wxRIGHT) {
} else if (EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection() == wxRIGHT) {
#ifdef __WXOSX__
style |= kNotebook_BottomTabs;
#else
style |= kNotebook_RightTabs;
#endif
}
style |= kNotebook_UnderlineActiveTab | kNotebook_FixedWidth;
if(EditorConfigST::Get()->GetOptions()->IsMouseScrollSwitchTabs()) {
if (EditorConfigST::Get()->GetOptions()->IsMouseScrollSwitchTabs()) {
style |= kNotebook_MouseScrollSwitchTabs;
}
m_book = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
Expand Down Expand Up @@ -146,15 +146,15 @@ void OutputPane::CreateGUIControls()
void OutputPane::OnEditorFocus(wxCommandEvent& e)
{
e.Skip();
if(EditorConfigST::Get()->GetOptions()->GetHideOutpuPaneOnUserClick()) {
if (EditorConfigST::Get()->GetOptions()->GetHideOutpuPaneOnUserClick()) {

// Optionally don't hide the various panes (sometimes it's irritating, you click to do something and...)
int cursel(m_book->GetSelection());
if(cursel != wxNOT_FOUND && EditorConfigST::Get()->GetPaneStickiness(m_book->GetPageText(cursel))) {
if (cursel != wxNOT_FOUND && EditorConfigST::Get()->GetPaneStickiness(m_book->GetPageText(cursel))) {
return;
}

if(m_buildInProgress)
if (m_buildInProgress)
return;

wxAuiPaneInfo& info = PluginManager::Get()->GetDockingManager()->GetPane(PANE_OUTPUT);
Expand Down Expand Up @@ -197,17 +197,17 @@ void OutputPane::ApplySavedTabOrder(bool update_ui) const
{
wxArrayString tabs;
int index = -1;
if(!clConfig::Get().GetOutputTabOrder(tabs, index))
if (!clConfig::Get().GetOutputTabOrder(tabs, index))
return;

std::vector<tagTabInfo> vTempstore;
for(size_t t = 0; t < tabs.GetCount(); ++t) {
for (size_t t = 0; t < tabs.GetCount(); ++t) {
wxString title = tabs.Item(t);
if(title.empty()) {
if (title.empty()) {
continue;
}
for(size_t n = 0; n < m_book->GetPageCount(); ++n) {
if(title == m_book->GetPageText(n)) {
for (size_t n = 0; n < m_book->GetPageCount(); ++n) {
if (title == m_book->GetPageText(n)) {
tagTabInfo Tab;
Tab.text = title;
Tab.win = m_book->GetPage(n);
Expand All @@ -223,21 +223,21 @@ void OutputPane::ApplySavedTabOrder(bool update_ui) const

// All the matched tabs are now stored in the vector. Any left in m_book are presumably new additions
// Now prepend the ordered tabs, so that any additions will effectively be appended
for(size_t n = 0; n < vTempstore.size(); ++n) {
for (size_t n = 0; n < vTempstore.size(); ++n) {
m_book->InsertPage(n, vTempstore.at(n).win, vTempstore.at(n).text, false, vTempstore.at(n).bmp);
}

// Restore any saved last selection
// NB: this doesn't actually work atm: the selection is set correctly, but presumably something else changes is
// later
// I've left the code in case anyone ever has time/inclination to fix it
if((index >= 0) && (index < (int)m_book->GetPageCount())) {
if ((index >= 0) && (index < (int)m_book->GetPageCount())) {
m_book->SetSelection(index);
} else if(m_book->GetPageCount()) {
} else if (m_book->GetPageCount()) {
m_book->SetSelection(0);
}

if(update_ui) {
if (update_ui) {
clGetManager()->GetDockingManager()->Update();
}
}
Expand All @@ -251,15 +251,15 @@ void OutputPane::OnSettingsChanged(wxCommandEvent& event)
void OutputPane::OnToggleTab(clCommandEvent& event)
{
// Handle the core tabs
if(m_tabs.count(event.GetString()) == 0) {
if (m_tabs.count(event.GetString()) == 0) {
event.Skip();
return;
}

const Tab& t = m_tabs.find(event.GetString())->second;
if(event.IsSelected()) {
if (event.IsSelected()) {
// Insert the page
if(!clTabTogglerHelper::IsTabInNotebook(PaneId::BOTTOM_BAR, t.m_label)) {
if (!clTabTogglerHelper::IsTabInNotebook(PaneId::BOTTOM_BAR, t.m_label)) {
clGetManager()->BookAddPage(PaneId::BOTTOM_BAR, t.m_window, t.m_label);
} else {
clGetManager()->BookSelectPage(PaneId::BOTTOM_BAR, t.m_label);
Expand All @@ -272,7 +272,7 @@ void OutputPane::OnToggleTab(clCommandEvent& event)

void OutputPane::OnOutputBookFileListMenu(clContextMenuEvent& event)
{
if(event.GetEventObject() != m_book) {
if (event.GetEventObject() != m_book) {
event.Skip();
return;
}
Expand All @@ -283,14 +283,14 @@ void OutputPane::OnOutputBookFileListMenu(clContextMenuEvent& event)

wxMenu* hiddenTabsMenu = new wxMenu();
const wxArrayString& tabs = clGetManager()->GetOutputTabs();
for(size_t i = 0; i < tabs.size(); ++i) {
for (size_t i = 0; i < tabs.size(); ++i) {
const wxString& label = tabs.Item(i);
if((m_book->GetPageIndex(label) != wxNOT_FOUND)) {
if ((m_book->GetPageIndex(label) != wxNOT_FOUND)) {
// Tab is visible, dont show it
continue;
}

if(menu->GetMenuItemCount() > 0 && hiddenTabsMenu->GetMenuItemCount() == 0) {
if (menu->GetMenuItemCount() > 0 && hiddenTabsMenu->GetMenuItemCount() == 0) {
// we are adding the first menu item
menu->AppendSeparator();
}
Expand All @@ -300,7 +300,7 @@ void OutputPane::OnOutputBookFileListMenu(clContextMenuEvent& event)
hiddenTabsMenu->Append(item);

// Output pane does not support "detach"
if(dpi.GetPanes().Index(label) != wxNOT_FOUND) {
if (dpi.GetPanes().Index(label) != wxNOT_FOUND) {
item->Enable(false);
}

Expand All @@ -315,7 +315,7 @@ void OutputPane::OnOutputBookFileListMenu(clContextMenuEvent& event)
tabId);
}

if(hiddenTabsMenu->GetMenuItemCount() == 0) {
if (hiddenTabsMenu->GetMenuItemCount() == 0) {
wxDELETE(hiddenTabsMenu);
} else {
menu->AppendSubMenu(hiddenTabsMenu, _("Hidden Tabs"), _("Hidden Tabs"));
Expand All @@ -333,5 +333,9 @@ void OutputPane::ShowTab(const wxString& name, bool show)
void OutputPane::OnPageChanged(wxBookCtrlEvent& event)
{
event.Skip();
//::SetBestFocus(m_book->GetCurrentPage());
clCommandEvent event_changed{ wxEVT_OUTPUT_VIEW_TAB_CHANGED };
wxString tab_name = GetNotebook()->GetPageText(GetNotebook()->GetSelection());
event_changed.SetString(tab_name);
event_changed.SetEventObject(GetNotebook());
EventNotifier::Get()->AddPendingEvent(event_changed);
}
31 changes: 24 additions & 7 deletions LiteEditor/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,10 @@ IEditor* PluginManager::OpenFile(const wxString& fileName, const wxString& bmpRe
return editor;
}

IEditor* PluginManager::OpenRemoteFile(const wxString& local_path, const wxString& remote_path,
const wxString& ssh_account, const wxString& tooltip)
IEditor* PluginManager::OpenRemoteFile(const wxString& local_path,
const wxString& remote_path,
const wxString& ssh_account,
const wxString& tooltip)
{
return clMainFrame::Get()->GetMainBook()->OpenRemoteFile(local_path, remote_path, ssh_account, tooltip);
}
Expand Down Expand Up @@ -564,8 +566,8 @@ bool PluginManager::ClosePage(const wxFileName& filename)

wxWindow* PluginManager::FindPage(const wxString& text) { return clMainFrame::Get()->GetMainBook()->FindPage(text); }

bool PluginManager::AddPage(wxWindow* win, const wxString& text, const wxString& tooltip,
const wxString& bmpResourceName, bool selected)
bool PluginManager::AddPage(
wxWindow* win, const wxString& text, const wxString& tooltip, const wxString& bmpResourceName, bool selected)
{
int bmp_index = clMainFrame::Get()->GetMainBook()->GetBitmapIndexOrAdd(bmpResourceName);
return clMainFrame::Get()->GetMainBook()->AddBookPage(win, text, tooltip, bmp_index, selected, wxNOT_FOUND);
Expand All @@ -577,7 +579,8 @@ IEditor* PluginManager::OpenFile(const BrowseRecord& rec) { return clMainFrame::

NavMgr* PluginManager::GetNavigationMgr() { return NavMgr::Get(); }

void PluginManager::HookProjectSettingsTab(wxBookCtrlBase* book, const wxString& projectName,
void PluginManager::HookProjectSettingsTab(wxBookCtrlBase* book,
const wxString& projectName,
const wxString& configName)
{
std::map<wxString, IPlugin*>::iterator iter = m_plugins.begin();
Expand All @@ -586,7 +589,8 @@ void PluginManager::HookProjectSettingsTab(wxBookCtrlBase* book, const wxString&
}
}

void PluginManager::UnHookProjectSettingsTab(wxBookCtrlBase* book, const wxString& projectName,
void PluginManager::UnHookProjectSettingsTab(wxBookCtrlBase* book,
const wxString& projectName,
const wxString& configName)
{
std::map<wxString, IPlugin*>::iterator iter = m_plugins.begin();
Expand Down Expand Up @@ -855,6 +859,18 @@ void PluginManager::ShowPane(const wxString& pane_name, bool show)
}
}

bool PluginManager::IsPaneShown(const wxString& pane_name, const wxString& tab)
{
bool is_pane_shown = ManagerST::Get()->IsPaneVisible(pane_name);
if (tab.empty()) {
return is_pane_shown;
}

auto notebook = clMainFrame::Get()->GetOutputPane()->GetNotebook();
return is_pane_shown && (notebook->GetPageIndex(tab) != wxNOT_FOUND) &&
(notebook->GetPageIndex(tab) == notebook->GetSelection());
}

void PluginManager::ToggleSecondarySidebarPane(const wxString& selectedWindow)
{
if (ManagerST::Get()->IsPaneVisible(PANE_RIGHT_SIDEBAR)) {
Expand Down Expand Up @@ -923,7 +939,8 @@ clToolBarGeneric* PluginManager::GetToolBar() { return clMainFrame::Get()->GetPl

clInfoBar* PluginManager::GetInfoBar() { return clMainFrame::Get()->GetMessageBar(); }

void PluginManager::DisplayMessage(const wxString& message, int flags,
void PluginManager::DisplayMessage(const wxString& message,
int flags,
const std::vector<std::pair<wxWindowID, wxString>>& buttons)
{
return clMainFrame::Get()->GetMessageBar()->DisplayMessage(message, flags, buttons);
Expand Down
Loading

0 comments on commit 10c4108

Please sign in to comment.